| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294 |
- using System;
- using System.Data;
- using System.Configuration;
- using System.Collections;
- using System.Collections.Specialized;
- using System.IO;
- using System.Web;
- using System.Web.Security;
- using System.Web.UI;
- using System.Web.UI.WebControls;
- using System.Web.UI.WebControls.WebParts;
- using System.Web.UI.HtmlControls;
- using com.cloudsoft.utils;
- using System.Text;
- using System.Collections.Generic;
- /// <summary>
- /// Delegate defining the interface for BizRule
- /// </summary>
- public delegate String BizRule(string zRequest);
- /// <summary>
- /// Delegate defining the interface for BizRule
- /// </summary>
- public delegate XMLHelper XMLBizRule(XMLHelper oRequest);
- /// <summary>
- /// Delegate defining the interface for BizRule
- /// </summary>
- public delegate StringBuilder CSVBizRule(XMLHelper oRequest);
- namespace com.cloudsoft.utils
- {
- /// <summary>
- /// UI Helper class. Extends System.Web.UI.Page
- /// Should be used as the extention class in a aspx cs class.
- /// </summary>
- public class UIHelper : System.Web.UI.Page
- {
- /// <summary>
- /// Gets or sets the gprev page Global variable.
- /// </summary>
- /// <value>The gprev page.</value>
- public String gPrevPage
- {
- get { return getSyncKey("gPrevPage"); }
- set { setSyncKey("gPrevPage", value); }
- }
- /// <summary>
- /// Gets or sets the Global method variable.
- /// </summary>
- /// <value>The method.</value>
- public String zgMethod
- {
- get { return getSyncKey("gMethod"); }
- set { setSyncKey("gMethod", value); }
- }
- /// <summary>
- /// Gets or sets the Global current tab variable.
- /// </summary>
- /// <value>The current tab.</value>
- public String gCurrentTab
- {
- get { return getSyncKey("gCurrentTab"); }
- set { setSyncKey("gCurrentTab", value); }
- }
- /// <summary>
- /// Gets or sets the type of the Global page variable usied for paging.
- /// </summary>
- /// <value>The Page number for paging</value>
- public String zgPageType
- {
- get { return getSyncKey("zgPageType"); }
- set { setSyncKey("zgPageType", value); }
- }
- /// <summary>
- /// Gets or sets the Global user id (MUD ID).
- /// </summary>
- /// <value>The MUD ID.</value>
- public virtual String zgUser
- {
- get { return getSyncKey("gUserID"); }
- set { setSyncKey("gUserID", value); }
- }
- /// <summary>
- /// The Root Directory for the web
- /// </summary>
- public String zgRootDirectory = "";
- /// <summary>
- /// The page title
- /// </summary>
- public String zgPageTitle = "";
- /// <summary>
- /// The Full root web directory (eg. http://bresawn0123/cims)
- /// </summary>
- public String zgFullRootWeb = "";
- /// <summary>
- /// The Root of the web (eg. /cims)
- /// </summary>
- public String zgRootWeb = "";
- /// <summary>
- /// Array of Months
- /// </summary>
- public String[] arygMonths = new String[] {"January","February","March","April","May","June","July","August","September","October","November","December"};
- /// <summary>
- /// An Array of slow business rules to be executed
- /// </summary>
- public String[] aSlowRules = new String[] {};
- /// <summary>
- /// Array of returned XML from slow business rules
- /// </summary>
- public String[] aSlowXML = new String[] {};
- /// <summary>
- /// The Global system (eg. cims). Should be overridden
- /// </summary>
- public String zgSystem = "cims";
- /// <summary>
- /// Branding XML
- /// </summary>
- public XMLHelper oBranding = null;
- /// <summary>
- /// Current page
- /// </summary>
- public String gCurrentPage = "";
- /// <summary>
- /// The Name displayed in the title for branding
- /// </summary>
- public String zgGlobalName = "";
- /// <summary>
- /// The Object which raised an error
- /// </summary>
- public String zgErr_Object = "";
- /// <summary>
- /// The Method which raised an error
- /// </summary>
- public String zgErr_Method = "";
- /// <summary>
- /// Determins whether the user is a superuser
- /// </summary>
- public Boolean gbSuperUser = false;
- /// <summary>
- /// Determines whether menu security should be used
- /// </summary>
- public String zgSecurity = "ON";
- /// <summary>
- /// Determines whether tasks should be shown
- /// </summary>
- public Boolean zbShowTasks = false;
- /// <summary>
- /// Default rows per page
- /// </summary>
- public int zgRowsPerPage = 20;
- /// <summary>
- /// Location of the Framework web
- /// </summary>
- public String zgFrameworkWeb = "/WI3/";
- /// <summary>
- /// Full location of the framework web (eg. http://bresawnv0123/wi3)
- /// </summary>
- public String zgFullFrameworkWeb = "";
- private DateTime gdStart;
- public Boolean bTopCalled = false;
- private Hashtable oSyncKeys = new Hashtable();
- private Boolean bInLoad = false;
- /// <summary>
- /// Raises the System.Web.UI.Control.Init event to initialize the page.
- /// </summary>
- /// <param name="e">An System.EventArgs that contains the event data.</param>
- override protected void OnInit(EventArgs e)
- {
- // Load SyncKeys from the Application Definition
- loadSyncKeys();
- zgRootDirectory = Request.MapPath("~");
- zgRootWeb = Request.ApplicationPath + "/";
- zgUser = RequestP("zgUser");
- //WADS: Secure connections...
- string protocolPrepend = "http://";
- if (HttpContext.Current.Request.IsSecureConnection)
- protocolPrepend = "https://";
- zgFullRootWeb = protocolPrepend + Request.ServerVariables["HTTP_HOST"].ToString() + zgRootWeb;
- zgFullFrameworkWeb = protocolPrepend + Request.ServerVariables["SERVER_NAME"].ToString() + zgFrameworkWeb;
- if (Session["MudID"] != null)
- {
- if (zgUser == "")
- zgUser = (String) Session["MudID"];
- }
- else
- {
- if (zgUser == "")
- {
- zgUser = Request.ServerVariables["LOGON_USER"];
- zgUser = zgUser.Substring(zgUser.IndexOf('\\')+1).ToUpper();
- }
- }
- Session["MudID"] = zgUser;
- gdStart = DateTime.Now;
- //zgFrameworkDirectory = Request.MapPath(zgFrameworkWeb) + "\\";
- gPrevPage = RequestP("gPrevPage");
- gCurrentPage = Request.ServerVariables["PATH_INFO"].ToUpper();
- if (gCurrentPage == gPrevPage)
- gCurrentTab = RequestP("gCurrentTab");
- zgMethod = RequestP("gMethod");
- // ----------------------------
- // Page Type Setting
- // ----------------------------
- // MENU: Menu Navigation Page
- // Full branding, Top Menu & Side Menu
- // TABSET: Tab Control Set Navigation Page
- // Full branding, Top Menu, Side Menu or Side TabControl
- // CONTENT: Content only (tab)
- // No Branding, no top menu, no side menu or side tab control
- //
- if (zgPageType == "")
- {
- zgPageType = RequestF("zgPageType");
- switch (zgPageType)
- {
- case "MENU":
- case "CONTENT":
- case "TABSET":
- break;
- default:
- zgPageType = "MENU";
- break;
- }
- }
- base.OnInit(e);
-
- }
- /// <summary>
- /// Determines whether an error is a UI error
- /// </summary>
- /// <param name="err">The Exception</param>
- /// <returns>
- /// <c>true</c> if is UI error; otherwise, <c>false</c>.
- /// </returns>
- public Boolean isUIError(Exception err)
- {
- Boolean boolIsError = false;
- //switch (err.number)
- //{
- // case -2147221005:
-
- // boolIsError = true;
- // break;
- // default:
- // boolIsError = false;
- // break;
- //}
- return boolIsError;
- }
- // ============================================================================
- // Business Rule Execution (Logic Functions)
- // ============================================================================
- /// <summary>
- /// Bubbles an event up to the loadorder if required
- /// </summary>
- public void LoadOrderBubble()
- {
- String zLoadOrder = RequestQS("loadorder");
-
- if (!(zLoadOrder == "None" || zLoadOrder == null) && (zgPageType == "CONTENT"))
- {
- Response.Write("<script language=\"JavaScript\">");
- //WADS: Cross site scripting...
- Response.Write("parent.fnLoad" + zLoadOrder + "(frameElement.id);");
- Response.Write("</script>");
- }
- }
- // ============================================================================
- // TabControl Functions
- // ============================================================================
- /// <summary>
- /// Writes the html for the chosen tabcontrol
- /// </summary>
- /// <param name="zMenu">Name of the Menu (in this case, a page of tabcontrols) to write (will filter on security if set on)</param>
- /// <param name="zTabControl">Name of the TabControl to write</param>
- public void writeTabControl(String zMenu, String zTabControl)
- {
- XMLHelper oXML = getMenuDOM(zMenu);
- if (oXML != null)
- {
- oXML.getNode("/toplevel/navigation/menu[@id='" + zTabControl + "']").transform(zgFullFrameworkWeb + "xsl/UN_TabControl_SC.xsl", Response.Output);
- }
- }
- // ============================================================================
- // Sync Key Functions
- // ============================================================================
- /// <summary>
- /// write SyncKeys to Hidden Fields Should be overriden to include another systems sync keys
- /// </summary>
- public virtual void loadSyncKeys()
- {
- // Add your SyncKeys Here
- SyncKey("gPrevPage");
- SyncKey("gMethod");
- SyncKey("gCurrentTab");
- SyncKey("zgPageType");
- SyncKey("gUserID");
- SyncKey("gdeleteID");
- }
- /// <summary>
- /// Sets a Sync key.
- /// </summary>
- /// <param name="zName">Name of the Sync Key</param>
- public void SyncKey(String zName)
- {
- String zValue = Server.HtmlEncode(Request.Params[zName]);
- if (zValue == null)
- zValue = "";
- if (!oSyncKeys.ContainsKey(zName))
- oSyncKeys.Add(zName, zValue);
- else
- oSyncKeys[zName] = zValue;
- }
- /// <summary>
- /// Gets a sync key.
- /// </summary>
- /// <param name="zName">Name of Sync Key</param>
- /// <returns>The value of the Sync Key</returns>
- public String getSyncKey(String zName)
- {
- return (String) oSyncKeys[zName];
- }
- /// <summary>
- /// Sets the sync key.
- /// </summary>
- /// <param name="zName">Name of the Sync Key</param>
- /// <param name="zValue">The value to set the Sync Key to.</param>
- public void setSyncKey(String zName, String zValue)
- {
- oSyncKeys[zName] = zValue;
- }
- /// <summary>
- /// Write / update syncKeys on the client
- /// </summary>
- public void writeSyncKeys()
- {
- foreach (String zSyncKey in oSyncKeys.Keys)
- {
- Response.Write("\t setSyncKey(\"" + zSyncKey + "\", \"" + oSyncKeys[zSyncKey] + "\");\n");
- }
- }
- /// <summary>
- /// Write syncKeys as hidden fields on the client.
- /// </summary>
- /// <param name="zPageType">The Page Type</param>
- public void writeSyncKeysToInput(String zPageType)
- {
- setSyncKey("zgPageType", zPageType);
- foreach (String zSyncKey in oSyncKeys.Keys)
- {
- Response.Write("<input type=\"hidden\" name=\"" + zSyncKey + "\" value=\"" + oSyncKeys[zSyncKey] + "\" />\n");
- }
- }
- // ============================================================================
- // Paging
- // ============================================================================
- // --------------------------------------------------------------
- // Function: createPaging
- // Purpose: Create a DB paged response (list)
- // Outputs:
- //
- // --------------------------------------------------------------
- /// <summary>
- /// Creates paging HTML.
- /// </summary>
- /// <param name="lCurrentPage">The current page.</param>
- /// <param name="lRows">The total number of rows.</param>
- /// <param name="lRowsPerPage">The rows per page.</param>
- public string createPaging(int lCurrentPage, int lRows, int lRowsPerPage)
- {
- StringBuilder sb = new StringBuilder();
- int i;
- int lPageSet;
- int lFirst;
- int lLast;
- int lPages = 0;
-
- if (lRows > 0)
- lPages = ((lRows-1) / lRowsPerPage)+1;
- if ((lCurrentPage == 0) || (lPages == 0))
- return "";
- lPageSet = ((lCurrentPage-1) / 10) + 1;
- lFirst = ((lPageSet-1) * 10) + 1;
- lLast = lPageSet * 10;
- if (lLast > lPages)
- lLast = lPages;
- sb.Append("<table width='100%'>\r\n");
- sb.Append("<tr>\r\n");
- sb.Append("<td align=\"left\"><font face=\"Verdana,Arial\" size=\"1\">Currently viewing page ");
- sb.Append(lCurrentPage + " out of ");
- sb.Append((lPages == 200) ? "at least 200" : lPages + " pages.</font></td>\r\n");
- sb.Append("<td alight=\"right\">Total found : " + lRows);
- if (lPages==200)
- sb.Append("+");
- sb.Append("</td></tr>\r\n");
- sb.Append("<tr><td colspan=\"2\">\r\n");
- sb.Append("<table><tr>\r\n");
- if (lPageSet > 1)
- {
- sb.Append("<td class=\"nextprev\"><a HREF=\"Javascript: document.forms[0].Page.value=" + (lFirst - 10) + ";document.forms[0].Button_clicked.value=true;document.forms[0].submit()\"><font face=\"marlett\">33</font>prev 10</a> </td>\r\n");
- }
- for (i=lFirst; i < lLast+1; i++)
- {
- if (i > 0 && i <= lPages)
- {
- if (i == lCurrentPage)
- {
- sb.Append("<td class=\"pageno\">[" + i + "]</td>\r\n");
- }
- else
- {
- sb.Append("<td class=\"pageno\"><a HREF=\"Javascript: document.forms[0].Page.value=" + i + ";document.forms[0].Button_clicked.value=true;document.forms[0].submit()\">" + i + "</a></td>\r\n");
- }
- }
- }
- if (lLast < lPages)
- {
- sb.Append("<td class=\"nextprev\"><a HREF=\"Javascript: document.forms[0].Page.value=" + (lLast + 1) + ";document.forms[0].Button_clicked.value=true;document.forms[0].submit()\">next 10<font face=\"marlett\">44</font></a></td>\r\n");
- }
- sb.Append("</tr></table>\r\n");
- sb.Append("</td></tr>\r\n");
- sb.Append("</table>\r\n");
- return sb.ToString();
- }
- // ============================================================================
- // Select Dropdown Utilities
- // ============================================================================
- public String generateSelectionMonth(String name)
- {
- return generateSelectionMonth(name, null);
- }
- /// <summary>
- /// Build a month select dropdown
- /// </summary>
- /// <param name="name">Name of the Select Tag</param>
- /// <param name="selected">Month to be preselected </param>
- /// <returns>HTML for select Month</returns>
- public String generateSelectionMonth(String name, String selected)
- {
- DateTime now = DateTime.Now;
- String arg = selected;
- String output = "";
- int pos = 0;
- int current = 0;
- // Need to determine the current month - number ie Oct is 9 in the array
- if (arg != "" && arg != null)
- {
- String aArg1 = arg.Split(new Char[] { ' ' })[0];
- String[] aArg = aArg1.Split(new Char[] { '-' });
- if (arg.Length == 2)
- current = Convert.ToInt32(arg) - 1;
- else
- {
- for (pos = 0; pos < arygMonths.Length; pos++)
- {
- if (aArg[1].Substring(0, 3).ToUpper() == arygMonths[pos].Substring(0, 3).ToUpper())
- break;
- }
- current = pos;
- }
- }
- else
- current = now.Month - 1;
- // Write the Select tag
- output = "<select name=\'" + name + "\'>";
- // Now add the options for each month
- for (int i = 0; i < arygMonths.Length; i++)
- {
- output += "<option value=\'";
- output += i < 9 ? "0" + Convert.ToString(i + 1) : Convert.ToString(i + 1);
- output += "\'";
- output += (current == i) ? " selected='true'" : "";
- output += ">" + arygMonths[i] + "</option>";
- }
- //Now close the select
- output += "</select>";
- return output;
- }
- public String generateSelectionYear(String name, int yearsForward, int yearsBack)
- {
- return generateSelectionYear(name, yearsForward, yearsBack, null);
- }
- /// <summary>
- /// Build a year select dropdown
- /// </summary>
- /// <param name="name">Name of the Select Tag</param>
- /// <param name="yearsForward">Number of years in the future to include</param>
- /// <param name="yearsBack">Number of years in the past to include</param>
- /// <param name="selected">Year to be preselected</param>
- /// <returns>HTML for select Month</returns>
- public String generateSelectionYear(String name, int yearsForward, int yearsBack, String selected)
- {
- DateTime now = DateTime.Now;
- String arg = selected;
- int current = now.Year;
- int start = current - yearsBack;
- int end = current + yearsForward;
- String output = "";
- //Check to see if a year is already selected, also check if the selected year is
- //greater than the end if if so make the end the selected year
- if (arg != null)
- {
- String aArg1 = arg.Split(new Char[] { ' ' })[0];
- String[] aArg = aArg1.Split(new Char[] { '-' });
- if (aArg.Length > 0 && aArg[0] != "")
- {
- if (arg.Length == 4)
- {
- current = Convert.ToInt32(arg);
- }
- else
- {
- current = Convert.ToInt32(aArg[2]);
- }
- }
- }
- if (current > end)
- end = current;
- // Write the Select tag
- output = "<select name=\'" + name + "\'>";
- // Now add the options for each month
- for (start = start + 0; start <= end; start++)
- {
- output += "<option value=\'" + start + "\'";
- output += current == start ? " selected='true'" : "";
- output += ">" + start + "</option>";
- }
- //Now close the select
- output += "</select>";
- return output;
- }
- /// <summary>
- /// Generates the select value= tag for a select box setting selected=true if the value = previous
- /// </summary>
- /// <param name="zValue">The value of the select option.</param>
- /// <param name="zPrevious">The value to compare.</param>
- /// <returns>Option attributes</returns>
- public String getOption(String zValue, String zPrevious)
- {
- String sReturn = "value=\"" + zValue + "\"";
- if (zValue == zPrevious)
- sReturn += " selected=\"true\"";
- return sReturn;
- }
- /// <summary>
- /// Standard look and field header.
- /// Should be called between a head html section of a web page
- /// </summary>
- /// <param name="zpPageTitle">The Page Title.</param>
- /// <param name="zDep1">Dummy parameter for backward compatibility</param>
- /// <param name="zDep2">Dummy parameter for backward compatibility</param>
- public void Brand_Head(String zpPageTitle, String zDep1, String zDep2)
- {
- Brand_Head(zpPageTitle);
- }
- /// <summary>
- /// Standard look and field header.
- /// Should be called between a head html section of a web page
- /// </summary>
- /// <param name="zpPageTitle">The Page Title.</param>
- /// <param name="zDep1">Dummy parameter for backward compatibility</param>
- public virtual void Brand_Head(String zpPageTitle, String zDep1)
- {
- Brand_Head(zpPageTitle);
- }
- /// <summary>
- /// Standard look and field header.
- /// Should be called between a head html section of a web page
- /// </summary>
- /// <param name="zpPageTitle">The Page Title.</param>
- public void Brand_Head(String zpPageTitle)
- {
- Response.Write(Brand_Head(zpPageTitle, true));
- }
- /// <summary>
- /// Standard look and field header.
- /// Should be inserted between a head html section of a web page
- /// </summary>
- /// <param name="zpPageTitle">The Page Title.</param>
- public string Brand_Head(String zpPageTitle, Boolean ReturnMode)
- {
-
- try
- {
- zgPageTitle = zpPageTitle;
- StringBuilder sb = new StringBuilder();
-
- //WADS REQUIREMENT: 5.1.1
- sb.Append("<meta http-equiv=\"Content-Type\" content=\"text/html; charset=UTF-8\">");
-
- sb.Append("<link href=\"" + zgFullFrameworkWeb + "Styles/style.css\" rel=\"stylesheet\" type=\"text/css\" />");
- sb.Append("<title>" + zgSystem + "_" + zpPageTitle + "</title>");
- sb.Append("<script>");
- sb.Append(" zgRootWeb = \"" + zgRootWeb + "\";");
- sb.Append("</script>");
- sb.Append("<script language=\"Javascript\" src=\"" + zgFullFrameworkWeb + "Javascript/CommonUtils.js\"></script>");
-
- return sb.ToString();
- }
- catch
- {
- return "";
- }
- }
- /// <summary>
- /// Standard Look and field body
- /// Should be called between a body html section of a web page
- /// </summary>
- /// <param name="zMenu">The side menu to display</param>
- /// <param name="zDep">Dummy parameter for backward compatibility</param>
- public void Brand_BodyTop(String zMenu, String zDep)
- {
- Brand_BodyTop(zMenu);
- }
- /// <summary>
- /// Standard Look and field body
- /// Should be called between a body html section of a web page
- /// </summary>
- /// <param name="zMenu">The side menu to display</param>
- /// <param name="zSearch">Dummy parameter for backward compatibility</param>
- /// <param name="bRenderTabCtrl">Dummy parameter for backward compatibility</param>
- public void Brand_BodyTop(String zMenu, String zSearch, Boolean bRenderTabCtrl)
- {
- Brand_BodyTop(zMenu);
- }
- /// <summary>
- /// Gets the menu DOM.
- /// </summary>
- /// <param name="zMenu">The menu name to obrain the DOM for</param>
- /// <returns>An XMLHelper DOM with the menu in it</returns>
- public XMLHelper getMenuDOM(String zMenu)
- {
- XMLHelper oMenu = null;
- if (Session["MenuXML"] == null)
- {
- String zFile = Request.MapPath("~/" + "menu/" + zgSystem + "Menu.xml");
- oMenu = new XMLHelper();
- oMenu.load(zFile);
- if (zgSecurity == "ON")
- {
- XMLHelper oRequest = newRequest("BuildUIMenu");
- //Security_nTX oSec = new Security_nTX();
- //String zResponse = oSec.GetUserResources(oRequest.getRootXML());
- //XMLHelper oResponse = new XMLHelper();
- //oResponse.load(zResponse);
- //Session.Add("UserResources", oResponse);
- //oResponse.appendNode(oMenu.getNode("/toplevel"));
- ////oMenu = oResponse.transform(zgFullFrameworkWeb + "xsl/FilterSideMenu.xsl");
- ////WADS: Secure connections (can't establish secure connection from app)...
- //oMenu = oResponse.transform("http://localhost/wi3/xsl/FilterSideMenu.xsl");
- }
- Session.Add("MenuXML", oMenu);
- }
- else
- {
- oMenu = (XMLHelper)Session["MenuXML"];
- }
- return oMenu;
- }
- /// <summary>
- /// Standard Look and field body
- /// Should be called between a body html section of a web page
- /// </summary>
- /// <param name="zMenu">The side menu to display</param>
- public virtual void Brand_BodyTop(String zMenu)
- {
- try
- {
- bTopCalled = true;
- XMLHelper oMenu = getMenuDOM(zMenu);
- String zXSL = Request.MapPath("~/" + "menu/" + zgSystem + "Branding.xsl");
- Dictionary<string, string> aParams = new Dictionary<string, string>();
- aParams.Add("param1", zgSystem);
- aParams.Add("param2", zMenu);
- aParams.Add("param3", zgRootWeb);
- aParams.Add("param4", zgFullFrameworkWeb);
- aParams.Add("param5", zgPageTitle);
- oBranding = oMenu.transform(zXSL, aParams);
-
- XMLHelper oHead = oBranding.getNode("head");
- Response.Write(oHead.getInnerXML());
- Response.Write("<table width=\"100%\" xxbgcolor=\"#FFFFFF\" border=\"0\" cellpadding=\"0\" cellspacing=\"0\" style=\"margin-top: 1px\">");
- Response.Write("<tr>");
-
- // Get the left menu XML
- if (!zMenu.Equals(""))
- {
- XMLHelper oSide = oBranding.getNode("side");
- Response.Write(oSide.getInnerXML());
- }
- Response.Write("<td width=\"100%\" align=\"left\" valign=\"top\">");
- Response.Write("<table width=\"100%\" align=\"left\" border=\"0\" cellpadding=\"2\" cellspacing=\"0\">");
- XMLHelper oTitle = oBranding.getNode("title");
- Response.Write(oTitle.getInnerXML());
- Response.Write("<tr>\r\n");
- Response.Write("<td colspan=\"" + oTitle.nodeCount("tr/td") + "\" valign=\"Top\">\r\n");
- Response.Write("<div style=\"padding-bottom: 8px; padding-top: 10px; padding-left:8px; padding-right:8px; width:100%; \">\r\n");
- }
- catch {}
- }
- /// <summary>
- /// Standard Look and field Footer
- /// Should be called between at just before the closing body html section of a web page
- /// </summary>
- public virtual void Brand_BodyBottom()
- {
- try
- {
- // ------------------------
- // Write Sync Keys to
- // hidden input fields
- // ------------------------
- gPrevPage = gCurrentPage;
- writeSyncKeysToInput(zgPageType);
- // ------------------------
- // Bubble to load order
- // if required
- // ------------------------
- LoadOrderBubble();
- if (bTopCalled)
- {
- Response.Write(" </div>\r\n");
- Response.Write(" </td>\r\n");
- Response.Write(" </tr>\r\n");
- Response.Write("</table>\r\n");
- Response.Write("</td>\r\n");
- Response.Write("</tr>\r\n");
- Response.Write("</table>\r\n");
- XMLHelper oBottom = oBranding.getNode("bottom");
- Response.Write(oBottom.getInnerXML());
- }
- Response.Write("<script language = \"javascript\">");
- if (bTopCalled)
- {
- Response.Write("try { divGlobalName.innerHTML = \"" + zgGlobalName + "\"; } catch (ex) {} \r\n");
- DateTime dEnd = DateTime.Now;
- TimeSpan tDiff = dEnd.Subtract(gdStart);
- String zDiff = "";
- if (tDiff.Seconds < 1)
- zDiff = tDiff.Milliseconds + " milliseconds";
- else
- zDiff = tDiff.TotalSeconds + " seconds";
- Response.Write("try { document.getElementById(\"idCopyright\").title = \"Render Time : " + zDiff + "\"; } catch (ex) {} ");
- }
- //write sync key information to page
- writeSyncKeys();
- Response.Write("</script>");
- }
- catch {}
- }
- /// <summary>
- /// Transforms the XML with the given XSL file.
- /// </summary>
- /// <param name="xmlFile">The XML file or XML String.</param>
- /// <param name="xslFile">The XSL file.</param>
- /// <returns>The Transformed XML String</returns>
- public String transformXML(String xmlFile, String xslFile)
- {
- return transformXML(xmlFile, xslFile, new Dictionary<string, string>());
- }
- /// <summary>
- /// Transforms the XML with the given XSL file.
- /// </summary>
- /// <param name="xmlFile">The XML file or XML String.</param>
- /// <param name="xslFile">The XSL file.</param>
- /// <param name="aParams">An array of Parameters to pass to the XSL stylesheet.</param>
- /// <returns>The Transformed XML String</returns>
- public String transformXML(String xmlFile, String xslFile, Dictionary<string, string> aParams)
- {
- StringWriter oString = new StringWriter();
- XMLHelper oDOM = new XMLHelper();
- if (xmlFile.StartsWith("<"))
- oDOM.load(xmlFile);
- else
- oDOM.load(Request.MapPath("~/" + xmlFile));
- if (xslFile.Substring(0,5).Contains(":"))
- oDOM.transform(xslFile, aParams, oString);
- else
- oDOM.transform(Request.MapPath("~/" + xslFile), aParams, oString);
- return oString.ToString();
- }
- /// <summary>
- /// Transforms the DOM with the given XSL file.
- /// </summary>
- /// <param name="oDOM">An XMLHelper document</param>
- /// <param name="xslFile">The XSL file.</param>
- public void transformXML(XMLHelper oDOM, String xslFile)
- {
- oDOM.transform(Request.MapPath("~/" + xslFile), Response.Output);
- }
- /// <summary>
- /// Transforms the DOM with the given XSL file.
- /// </summary>
- /// <param name="oDOM">An XMLHelper document</param>
- /// <param name="xslFile">The XSL file.</param>
- /// <param name="aParams">An array of Parameters to pass to the XSL stylesheet.</param>
- public void transformXML(XMLHelper oDOM, String xslFile, Dictionary<string, string> aParams)
- {
- oDOM.transform(Request.MapPath("~/" + xslFile), aParams, Response.Output);
- }
- /// <summary>
- /// Creates a standard request DOM with the resource, system and user (MUD ID).
- /// </summary>
- /// <param name="zResource">The resource (method) of the request.</param>
- /// <returns>A standard request DOM with the resource, system and user</returns>
- public XMLHelper newRequest(String zResource)
- {
- XMLHelper oXML = new XMLHelper();
- oXML.createStandardRequest(zResource, zgUser, zgSystem.ToUpper());
- if (zgSecurity == "OFF")
- oXML.appendAttribute("sec", "off");
- return oXML;
- }
- /// <summary>
- /// Loads a DOM with the XML file or XML String.
- /// </summary>
- /// <param name="zXML">The XML string or file.</param>
- /// <returns>An XML helper DOM</returns>
- public XMLHelper loadDOM(String zXML)
- {
- XMLHelper oDOM = new XMLHelper();
- oDOM.load(zXML);
- return oDOM;
- }
- /// <summary>
- /// Gets a standard request DOM using the Request.Form and Request.QueryString parameters.
- /// </summary>
- /// <param name="zResource">The resource (method) for the request.</param>
- /// <returns>An XMLHelper DOM containing the Request.Form and Request.QueryString parameters.</returns>
- public XMLHelper getRequestDOM(String zResource)
- {
- XMLHelper oDOM = newRequest(zResource);
- oDOM.appendNode(Request.Form);
- oDOM.appendNode(Request.QueryString);
- return oDOM;
- }
- /// <summary>
- /// Gets a request DOM using the Request.Form and Request.QueryString parameters.
- /// </summary>
- /// <returns>An XMLHelper DOM containing the Request.Form and Request.QueryString parameters.</returns>
- public XMLHelper getRequestDOM()
- {
- XMLHelper oDOM = new XMLHelper("request");
- oDOM.appendNode(Request.Form);
- oDOM.appendNode(Request.QueryString);
- return oDOM;
- }
- /// <summary>
- /// Gets the request DOM with Request.QueryString parameters.
- /// </summary>
- /// <returns>An XMLHelper DOM containing Request.QueryString parameters.</returns>
- public XMLHelper getRequestQueryDOM()
- {
- XMLHelper oDOM = new XMLHelper("request");
- oDOM.appendNode(Request.QueryString);
- return oDOM;
- }
- /// <summary>
- /// Gets the request DOM with Request.Form parameters.
- /// </summary>
- /// <returns>An XMLHelper DOM containing Request.Form parameters</returns>
- public XMLHelper getRequestFormDOM()
- {
- XMLHelper oDOM = new XMLHelper("request");
- oDOM.appendNode(Request.Form);
- return oDOM;
- }
- /// <summary>
- /// Executes a business method returning a DOM.
- /// </summary>
- /// <param name="oMethod">The Bizrule method.</param>
- /// <param name="oRequest">The Request DOM.</param>
- /// <returns>An XMLHelper response DOM</returns>
- public XMLHelper executeBizMethodDOM(BizRule oMethod, XMLHelper oRequest)
- {
- return executeBizMethodDOM(oMethod, oRequest.getRootXML(), true);
- }
- /// <summary>
- /// Executes a business method returning a DOM.
- /// </summary>
- /// <param name="oMethod">The Bizrule method.</param>
- /// <param name="zRequestXML">The request XML.</param>
- /// <returns>An XMLHelper response DOM</returns>
- public XMLHelper executeBizMethodDOM(BizRule oMethod, String zRequestXML)
- {
- return executeBizMethodDOM(oMethod, zRequestXML, true);
- }
- /// <summary>
- /// Executes a business method returning a DOM.
- /// </summary>
- /// <param name="oMethod">The Bizrule method.</param>
- /// <param name="zRequestXML">The request XML.</param>
- /// <param name="bDisplayErrors">if set to <c>true</c> [automatically display errors].</param>
- /// <returns>An XMLHelper response DOM</returns>
- public XMLHelper executeBizMethodDOM(BizRule oMethod, String zRequestXML, Boolean bDisplayErrors)
- {
- XMLHelper oDOM = new XMLHelper();
- oDOM.load(executeBizMethod(oMethod, zRequestXML, bDisplayErrors));
- return oDOM;
- }
- /// <summary>
- /// Executes a business method returning an XML String.
- /// </summary>
- /// <param name="oMethod">The Bizrule method.</param>
- /// <param name="oRequest">The Request DOM.</param>
- /// <returns>The response dom as a string</returns>
- public String executeBizMethod(BizRule oMethod, XMLHelper oRequest)
- {
- return executeBizMethod(oMethod, oRequest.getRootXML(), true);
- }
- /// <summary>
- /// Executes a business method returning an XML String.
- /// </summary>
- /// <param name="oMethod">The Bizrule method.</param>
- /// <param name="zRequestXML">The request XML.</param>
- /// <returns>The response dom as a string</returns>
- public String executeBizMethod(BizRule oMethod, String zRequestXML)
- {
- return executeBizMethod(oMethod, zRequestXML, true);
- }
- /// <summary>
- /// Executes a business method returning an XML String.
- /// </summary>
- /// <param name="oMethod">The Bizrule method.</param>
- /// <param name="zRequestXML">The request XML.</param>
- /// <param name="bDisplayErrors">if set to <c>true</c> [automatically display errors].</param>
- /// <returns></returns>
- public String executeBizMethod(BizRule oMethod, String zRequestXML, Boolean bDisplayErrors)
- {
- try
- {
- return oMethod(zRequestXML);
- }
- catch (Exception ex)
- {
- if (bDisplayErrors != false)
- {
- //WADS: Detailed exception info no longer given to the user...
- throw new Exception("You cannot give detailed exception info to the user");
- }
- else
- {
- throw ex;
- }
- }
- }
- /// <summary>
- /// Executes a business method returning an XML String.
- /// </summary>
- /// <param name="oMethod">The XMLBizrule method.</param>
- /// <param name="zRequestXML">The request XML.</param>
- /// <param name="bDisplayErrors">if set to <c>true</c> [automatically display errors].</param>
- /// <returns></returns>
- public XMLHelper executeBizMethod(XMLBizRule oMethod, XMLHelper oRequest, Boolean bDisplayErrors)
- {
- if (bDisplayErrors == true)
- {
- try
- {
- return oMethod(oRequest);
- }
- catch (Exception ex)
- {
- if (bDisplayErrors != false)
- {
- if (ex.Message.Substring(0,9) == "ORA-20000")
- {
- throw ex;
- }
- else
- {
- //WADS: Detailed exception info no longer given to the user...
- throw new Exception("You cannot give detailed exception info to the user");
- }
- }
- else
- {
- throw ex;
- }
- }
- }
- else
- {
- return oMethod(oRequest);
- }
- }
- public StringBuilder executeBizMethod(CSVBizRule oMethod, XMLHelper oRequest)
- {
- return oMethod(oRequest);
- }
- /// <summary>
- /// Displays an error message
- /// </summary>
- /// <param name="ex">The Exception to handle.</param>
- public void handleError(Exception ex)
- {
- handleError(ex, null);
- }
- /// <summary>
- /// Displays an error message
- /// </summary>
- /// <param name="ex">The Exception to handle.</param>
- /// <param name="zRequestXML">The Exception to handle.</param>
- public void handleError(Exception ex, String zRequestXML)
- {
- //WADS: Detailed exception info no longer given to the user...
- throw new Exception("You cannot give detailed exception info to the user");
- }
- /// <summary>
- /// Validates the number.
- /// </summary>
- /// <param name="zInput">The Number to check.</param>
- /// <returns>Converted number as a string</returns>
- public String validNumber(String zInput)
- {
- try
- {
- return Convert.ToDouble(zInput).ToString();
- }
- catch
- {
- return "";
- }
- }
-
- /// <summary>
- /// Returns a default of the checked value is null otherwise it returns a the value to check
- /// </summary>
- /// <param name="oCheck">Value to check.</param>
- /// <param name="zDefault">The default.</param>
- /// <returns>Either the Checked value or the default depending on whether the checked value is null</returns>
- public String ifNull(Object oCheck, String zDefault)
- {
- if (oCheck == null)
- return zDefault;
- else
- return oCheck.ToString();
- }
-
- /// <summary>
- /// Returns a default of the checked value is null otherwise it returns a the value to check
- /// </summary>
- /// <param name="oCheck">Value to check.</param>
- /// <param name="iDefault">The default.</param>
- /// <returns>Either the Checked value or the default depending on whether the checked value is null</returns>
- public int ifNull(Object oCheck, int iDefault)
- {
- if (oCheck == null)
- return iDefault;
- else
- return Convert.ToInt32(oCheck);
- }
- /// <summary>
- /// Determines whether the user has a given resource.
- /// </summary>
- /// <param name="zResourceName">Name of the resource to check.</param>
- /// <returns>
- /// <c>true</c> if the user has the given resource; otherwise, <c>false</c>.
- /// </returns>
- public Boolean hasSecurityResource(String zResourceName)
- {
- XMLHelper oDOM = (XMLHelper)Session["UserResources"];
- if (oDOM == null)
- return false;
- if (oDOM.nodeCount("//resource[@name='" + zResourceName.ToUpper() + "']") == 0)
- return false;
- else
- return true;
- }
- //========================================================================================
- // W A D S
- //========================================================================================
- public String RequestQS(String input)
- {
- String strCheck = ifNull(Request.QueryString[input], "");
- return Server.HtmlEncode(strCheck);
- }
- public int RequestQS(String input, int intDefault)
- {
- return ifNull(Request.QueryString[input], 0);
- }
- public String RequestF(String input)
- {
- String strCheck = ifNull(Request.Form[input], "");
- return Server.HtmlEncode(strCheck);
- }
- public int RequestF(String input, int intDefault)
- {
- return ifNull(Request.Form[input], 0);
- }
- public String RequestFGet(String input)
- {
- String strCheck = ifNull(Request.Form.Get(input), "");
- return Server.HtmlEncode(strCheck);
- }
- public String RequestP(String input)
- {
- String strCheck = ifNull(Request.Params[input], "");
- return Server.HtmlEncode(strCheck);
- }
- public String RequestWADS(String input, String strDefault)
- {
- String strCheck = ifNull(Request[input], strDefault);
- return Server.HtmlEncode(strCheck);
- }
- public String RequestWADS(String input)
- {
- String strCheck = ifNull(Request[input], "");
- return Server.HtmlEncode(strCheck);
- }
- public int RequestWADS(String input, int intDefault)
- {
- return ifNull(Request[input], 0);
- }
- public String RequestCookies(String section, String input)
- {
- String strCookie = "";
- try
- {
- strCookie = Request.Cookies[section][input];
- }
- catch (Exception ex)
- {
- strCookie = "";
- }
- return Server.HtmlEncode(strCookie);
- }
- public String RequestXML(String input)
- // for xml strings do nothing for now; Server.HtmlEncode corrupts xml stings
- {
- String strCheck = ifNull(Request[input], "");
- return strCheck;
- }
- public XMLHelper serialisePost()
- {
- XMLHelper oRequest = new XMLHelper("request");
- oRequest.appendNode("system", zgSystem);
- if (zgSecurity == "OFF") oRequest.appendAttribute("sec", "off");
- foreach (String s in Request.Form)
- {
- if (s != null)
- {
- if (s[0] == '_')
- {
- if (s.Length > 1)
- {
- oRequest.appendAttribute(s.Substring(1), Request.Form[s]);
- }
- }
- else
- {
- //Sync Key
- if (s.StartsWith("g_"))
- {
- String zField = s.Substring(2);
- if (ifNull(Request.Form[zField], "") == "")
- oRequest.setNode(zField, Request.Form[s]);
- }
- else
- {
- oRequest.setNode(s, Request.Form[s]);
- }
- }
- }
- }
- return oRequest;
- }
- }
- }
|