Пример #1
0
 /// <summary>
 ///		Required method for Designer support - do not modify
 ///		the contents of this method with the code editor.
 /// </summary>
 private void InitializeComponent()
 {
     ctlDynamicButtons.Command += new CommandEventHandler(Page_Command);
     arrSelectFields            = new UniqueStringCollection();
     arrSelectFields.Add("DATE_MODIFIED");
     arrSelectFields.Add("NOTE_ID");
     this.AppendGridColumns(grdMain, "ProductTemplates.Notes", arrSelectFields);
     if (IsPostBack)
     {
         ctlDynamicButtons.AppendButtons("ProductTemplates.Notes", Guid.Empty, Guid.Empty);
     }
 }
 /// <summary>
 ///		Required method for Designer support - do not modify
 ///		the contents of this method with the code editor.
 /// </summary>
 private void InitializeComponent()
 {
     ctlDynamicButtons.Command += new CommandEventHandler(Page_Command);
     m_sMODULE       = "ProductTemplates";
     arrSelectFields = new UniqueStringCollection();
     arrSelectFields.Add("DATE_ENTERED");
     arrSelectFields.Add("PRODUCT_TEMPLATE_ID");
     this.AppendGridColumns(grdMain, "ProductTemplates.RelatedProducts", arrSelectFields);
     if (IsPostBack)
     {
         ctlDynamicButtons.AppendButtons("ProductTemplates.RelatedProducts", Guid.Empty, Guid.Empty);
     }
 }
 /// <summary>
 ///		Required method for Designer support - do not modify
 ///		the contents of this method with the code editor.
 /// </summary>
 private void InitializeComponent()
 {
     ctlDynamicButtons.Command += new CommandEventHandler(Page_Command);
     m_sMODULE       = "Payments";
     arrSelectFields = new UniqueStringCollection();
     arrSelectFields.Add("DATE_ENTERED");
     arrSelectFields.Add("ID");
     this.AppendGridColumns(grdMain, m_sMODULE + ".PaymentTransactions", arrSelectFields);
     if (IsPostBack)
     {
         ctlDynamicButtons.AppendButtons(m_sMODULE + ".PaymentTransactions", Guid.Empty, Guid.Empty);
     }
 }
 /// <summary>
 ///		Required method for Designer support - do not modify
 ///		the contents of this method with the code editor.
 /// </summary>
 private void InitializeComponent()
 {
     ctlDynamicButtons.Command += new CommandEventHandler(Page_Command);
     m_sMODULE       = "Invoices";
     arrSelectFields = new UniqueStringCollection();
     arrSelectFields.Add("DATE_ENTERED");
     arrSelectFields.Add("INVOICE_ID");
     arrSelectFields.Add("ASSIGNED_USER_ID");
     this.AppendGridColumns(grdMain, "Payments." + m_sMODULE, arrSelectFields);
     if (IsPostBack)
     {
         ctlDynamicButtons.AppendButtons("Payments." + m_sMODULE, Guid.Empty, Guid.Empty);
     }
 }
 /// <summary>
 ///		Required method for Designer support - do not modify
 ///		the contents of this method with the code editor.
 /// </summary>
 private void InitializeComponent()
 {
     m_sMODULE = "Products";
     SetMenu(m_sMODULE);
     arrSelectFields = new UniqueStringCollection();
     arrSelectFields.Add("ID");
     arrSelectFields.Add("NAME");
     this.AppendGridColumns(grdMain, m_sMODULE + ".ListView", arrSelectFields);
     ctlSearchView.Command   = new CommandEventHandler(Page_Command);
     ctlExportHeader.Command = new CommandEventHandler(Page_Command);
     ctlMassUpdate.Command   = new CommandEventHandler(Page_Command);
     if (CRMSecurity.GetUserAccess(m_sMODULE, "delete") < 0 && CRMSecurity.GetUserAccess(m_sMODULE, "edit") < 0)
     {
         ctlMassUpdate.Visible = false;
     }
 }
Пример #6
0
		public static string ExportGridColumns(string sGRID_NAME)
		{
			StringBuilder sbSQL = new StringBuilder();
			UniqueStringCollection arrSelectFields = new UniqueStringCollection();
			// 05/03/2011   Always include the ID as it might be used by the Export code to filter by selected items. 
            arrSelectFields.Add("ID");

			GridColumns(sGRID_NAME, arrSelectFields, null);

			// 04/20/2011   If there are no fields in the GridView.Export, then return all fields (*). 
			if ( arrSelectFields.Count > 1 )
			{
				foreach ( string sField in arrSelectFields )
				{
					if ( sbSQL.Length > 0 )
						sbSQL.Append("     , ");
					sbSQL.AppendLine(sField);
				}
			}
			else
			{
				sbSQL.AppendLine("*");
			}
			return sbSQL.ToString();
		}
Пример #7
0
 protected void Page_Command(object sender, CommandEventArgs e)
 {
     if (e.CommandName == "Search")
     {
         grdMain.CurrentPageIndex = 0;
         grdMain.DataBind();
     }
     else if (e.CommandName == "SortGrid")
     {
         grdMain.SetSortFields(e.CommandArgument as string[]);
         arrSelectFields.Add(grdMain.SortColumn);
     }
     else if (e.CommandName == "MassUpdate")
     {
         string[] arrID = Request.Form.GetValues("chkMain");
         if (arrID != null)
         {
             Stack stk = Utils.FilterByACL_Stack(m_sMODULE, "edit", arrID, "PRODUCT_TEMPLATES");
             if (stk.Count > 0)
             {
                 while (stk.Count > 0)
                 {
                     string sIDs = Utils.BuildMassIDs(stk);
                 }
                 Response.Redirect("Index.aspx");
             }
         }
     }
     else if (e.CommandName == "MassDelete")
     {
         string[] arrID = Request.Form.GetValues("chkMain");
         if (arrID != null)
         {
             Stack stk = Utils.FilterByACL_Stack(m_sMODULE, "delete", arrID, "PRODUCT_TEMPLATES");
             if (stk.Count > 0)
             {
                 while (stk.Count > 0)
                 {
                     string sIDs = Utils.BuildMassIDs(stk);
                 }
                 Response.Redirect("Index.aspx");
             }
         }
     }
     else if (e.CommandName == "Export")
     {
         int nACLACCESS = Security.GetUserAccess(m_sMODULE, "export");
         if (nACLACCESS >= 0)
         {
             if (nACLACCESS == ACL_ACCESS.OWNER)
             {
                 vwMain.RowFilter = "ASSIGNED_USER_ID = '" + Security.USER_ID + "'";
             }
             string[] arrID = Request.Form.GetValues("chkMain");
             CRMExport.Export(vwMain, m_sMODULE, ctlExportHeader.ExportFormat, ctlExportHeader.ExportRange,
                              grdMain.CurrentPageIndex, grdMain.PageSize, arrID);
         }
     }
 }
Пример #8
0
 /// <summary>
 ///		Required method for Designer support - do not modify
 ///		the contents of this method with the code editor.
 /// </summary>
 private void InitializeComponent()
 {
     this.Load += new System.EventHandler(this.Page_Load);
     m_sMODULE = "TQClientAddress";
     SetMenu(m_sMODULE);
     // 02/08/2008   We need to build a list of the fields used by the search clause. 
     arrSelectFields = new UniqueStringCollection();
     arrSelectFields.Add("ID");
 }
Пример #9
0
 /// <summary>
 /// Required method for Designer support - do not modify
 /// the contents of this method with the code editor.
 /// </summary>
 private void InitializeComponent()
 {
     //ctlDynamicButtons.Command += new CommandEventHandler(Page_Command);
     ctlSearchView.Command = new CommandEventHandler(Page_Command);
     m_sMODULE             = "ProductCatalog";
     arrSelectFields       = new UniqueStringCollection();
     arrSelectFields.Add("NAME");
     this.AppendGridColumns(grdMain, m_sMODULE + ".PopupView", arrSelectFields);
     //ctlDynamicButtons.AppendButtons(m_sMODULE + ".PopupView", Guid.Empty, Guid.Empty);
     //if (!IsPostBack)
     //    ctlDynamicButtons.ShowButton("Clear", !TypeConvert.ToBoolean(Request["ClearDisabled"]));
 }
Пример #10
0
 /// <summary>
 /// Required method for Designer support - do not modify
 /// the contents of this method with the code editor.
 /// </summary>
 private void InitializeComponent()
 {
     // ctlDynamicButtons.Command += new CommandEventHandler(Page_Command);
     ctlSearchView.Command = new CommandEventHandler(Page_Command);
     m_sMODULE = "ProductTemplates";
     arrSelectFields = new UniqueStringCollection();
     arrSelectFields.Add("NAME");
     this.AppendGridColumns(grdMain, m_sMODULE + ".PopupView", arrSelectFields);
     // ctlDynamicButtons.AppendButtons(m_sMODULE + ".PopupView", Guid.Empty, Guid.Empty);
     // if (!IsPostBack)
     //     ctlDynamicButtons.ShowButton("Clear", !TypeConvert.ToBoolean(Request["ClearDisabled"]));
 }
Пример #11
0
 /// <summary>
 ///		Required method for Designer support - do not modify
 ///		the contents of this method with the code editor.
 /// </summary>
 private void InitializeComponent()
 {
     this.Load += new System.EventHandler(this.Page_Load);
     //ctlSearchView.Command += new CommandEventHandler(Page_Command);
     //ctlExportHeader.Command += new CommandEventHandler(Page_Command);
     // 11/26/2005   Add fields early so that sort events will get called. 
     m_sMODULE = "TQClientAddress";
     SetMenu(m_sMODULE);
     // 02/08/2008   We need to build a list of the fields used by the search clause. 
     arrSelectFields = new UniqueStringCollection();
     arrSelectFields.Add("ID");
 }
Пример #12
0
 protected void Page_Command(object sender, CommandEventArgs e)
 {
     if (e.CommandName == "Search")
     {
         grdMain.CurrentPageIndex = 0;
         grdMain.DataBind();
     }
     else if (e.CommandName == "SortGrid")
     {
         grdMain.SetSortFields(e.CommandArgument as string[]);
         arrSelectFields.Add(grdMain.SortColumn);
     }
 }
 /// <summary>
 ///		Required method for Designer support - do not modify
 ///		the contents of this method with the code editor.
 /// </summary>
 private void InitializeComponent()
 {
     ctlDynamicButtonsOpen.Command    += new CommandEventHandler(Page_Command);
     ctlDynamicButtonsHistory.Command += new CommandEventHandler(Page_Command);
     m_sMODULE       = "Calls";
     arrSelectFields = new UniqueStringCollection();
     arrSelectFields.Add("DATE_MODIFIED");
     arrSelectFields.Add("ACTIVITY_ID");
     arrSelectFields.Add("ACTIVITY_TYPE");
     arrSelectFields.Add("ACTIVITY_ASSIGNED_USER_ID");
     arrSelectFields.Add("IS_OPEN");
     arrSelectFields.Add("DATE_DUE");
     arrSelectFields.Add("STATUS");
     arrSelectFields.Add("DIRECTION");
     this.AppendGridColumns(grdOpen, "Invoices.Activities.Open", arrSelectFields);
     this.AppendGridColumns(grdHistory, "Invoices.Activities.History", arrSelectFields);
     if (IsPostBack)
     {
         ctlDynamicButtonsOpen.AppendButtons("Invoices.Activities.Open", Guid.Empty, Guid.Empty);
         ctlDynamicButtonsHistory.AppendButtons("Invoices.Activities.History", Guid.Empty, Guid.Empty);
     }
 }
Пример #14
0
		public Stream GetModuleList(string ModuleName)
		{
			HttpApplicationState Application = HttpContext.Current.Application;
			HttpRequest          Request     = HttpContext.Current.Request    ;
			
			WebOperationContext.Current.OutgoingResponse.Headers.Add("Cache-Control", "no-cache");
			WebOperationContext.Current.OutgoingResponse.Headers.Add("Pragma", "no-cache");
			
			if ( Sql.IsEmptyString(ModuleName) )
				throw(new Exception("The module name must be specified."));
			string sTABLE_NAME = Sql.ToString(Application["Modules." + ModuleName + ".TableName"]);
			if ( Sql.IsEmptyString(sTABLE_NAME) )
				throw(new Exception("Unknown module: " + ModuleName));
			// 08/22/2011   Add admin control to REST API. 
			int nACLACCESS = Security.GetUserAccess(ModuleName, "list");
			if ( !Security.IsAuthenticated() || !Sql.ToBoolean(Application["Modules." + ModuleName + ".RestEnabled"]) || nACLACCESS < 0 )
			{
				L10N L10n = new L10N(Sql.ToString(HttpContext.Current.Session["USER_SETTINGS/CULTURE"]));
				throw(new Exception(L10n.Term("ACL.LBL_INSUFFICIENT_ACCESS")));
			}
			
			int    nSKIP     = Sql.ToInteger(Request.QueryString["$skip"   ]);
			int    nTOP      = Sql.ToInteger(Request.QueryString["$top"    ]);
			string sFILTER   = Sql.ToString (Request.QueryString["$filter" ]);
			string sORDER_BY = Sql.ToString (Request.QueryString["$orderby"]);
			// 06/17/2013   Add support for GROUP BY. 
			string sGROUP_BY = Sql.ToString (Request.QueryString["$groupby"]);
			// 08/03/2011   We need a way to filter the columns so that we can be efficient. 
			string sSELECT   = Sql.ToString (Request.QueryString["$select" ]);
			
			Regex r = new Regex(@"[^A-Za-z0-9_]");
			string sFILTER_KEYWORDS = (" " + r.Replace(sFILTER, " ") + " ").ToLower();
			if ( sFILTER_KEYWORDS.Contains(" select ") )
				throw(new Exception("Subqueries are not allowed."));

			UniqueStringCollection arrSELECT = new UniqueStringCollection();
			sSELECT = sSELECT.Replace(" ", "");
			if ( !Sql.IsEmptyString(sSELECT) )
			{
				foreach ( string s in sSELECT.Split(',') )
				{
					string sColumnName = r.Replace(s, "");
					if ( !Sql.IsEmptyString(sColumnName) )
						arrSELECT.Add(sColumnName);
				}
			}
			
			// 06/17/2013   Add support for GROUP BY. 
			DataTable dt = GetTable(sTABLE_NAME, nSKIP, nTOP, sFILTER, sORDER_BY, sGROUP_BY, arrSELECT, null);
			
			string sBaseURI = Request.Url.Scheme + "://" + Request.Url.Host + Request.Url.AbsolutePath.Replace("/GetModuleList", "/GetModuleItem");
			JavaScriptSerializer json = new JavaScriptSerializer();
			// 05/05/2013   No reason to limit the Json result. 
			json.MaxJsonLength = int.MaxValue;
			
			// 05/05/2013   We need to convert the date to the user's timezone. 
			Guid     gTIMEZONE         = Sql.ToGuid  (HttpContext.Current.Session["USER_SETTINGS/TIMEZONE"]);
			TimeZone T10n              = TimeZone.CreateTimeZone(gTIMEZONE);
			string sResponse = json.Serialize(ToJson(sBaseURI, ModuleName, dt, T10n));
			byte[] byResponse = Encoding.UTF8.GetBytes(sResponse);
			return new MemoryStream(byResponse);
		}
Пример #15
0
 private void GetAssemblyReferenceMap(out FileWithVersionInfo[] volatileRefs, out FileWithVersionInfo[] nonvolatileRefs)
 {
     string fileName = null;
     UniqueStringCollection strings = new UniqueStringCollection(base.AllFileReferences, new FileNameComparer());
     strings.AddRange(PluginAssembly.GetCompatibleAssemblies(base.IsMyExtensions));
     if ((base.Repository != null) && !base.Repository.DynamicSchema)
     {
         strings.Add(base.Repository.CustomAssemblyPath);
         strings.AddRange(base.Repository.GetDriverAssemblies());
         if (base.Repository.DriverLoader.IsValid && (base.Repository.DriverLoader.InternalID == null))
         {
             try
             {
                 fileName = Path.GetFileName(base.Repository.DriverLoader.GetAssemblyPath());
             }
             catch
             {
             }
         }
     }
     List<FileWithVersionInfo> list = new List<FileWithVersionInfo>();
     List<string> assemblyFilePaths = new List<string>();
     foreach (string str2 in strings)
     {
         try
         {
             if (Path.IsPathRooted(str2) && File.Exists(str2))
             {
                 if (!(ShadowAssemblyManager.IsShadowable(str2) && !Path.GetFileName(str2).Equals(fileName, StringComparison.OrdinalIgnoreCase)))
                 {
                     list.Add(new FileWithVersionInfo(str2));
                 }
                 else
                 {
                     assemblyFilePaths.Add(str2);
                 }
             }
         }
         catch
         {
         }
     }
     nonvolatileRefs = (from r in list
         orderby r.FilePath
         select r).ToArray<FileWithVersionInfo>();
     volatileRefs = AssemblyProber.GetSameFolderAssemblyReferenceChain(assemblyFilePaths);
 }
Пример #16
0
 /// <summary>
 ///		Required method for Designer support - do not modify
 ///		the contents of this method with the code editor.
 /// </summary>
 private void InitializeComponent()
 {
     this.Load += new System.EventHandler(this.Page_Load);
     //ctlSearchView.Command += new CommandEventHandler(Page_Command);
     //ctlExportHeader.Command += new CommandEventHandler(Page_Command);
     // 11/26/2005   Add fields early so that sort events will get called. 
     m_sMODULE = "TQMyFavorite";
     SetMenu(m_sMODULE);
     // 02/08/2008   We need to build a list of the fields used by the search clause. 
     arrSelectFields = new UniqueStringCollection();
     arrSelectFields.Add("ID");
     this.AppendGridColumns(grdMain, m_sMODULE + "." + LayoutListView, arrSelectFields);
     grdMain.ItemCommand += grdMain_ItemCommand;
 }
 /// <summary>
 ///		Required method for Designer support - do not modify
 ///		the contents of this method with the code editor.
 /// </summary>
 private void InitializeComponent()
 {
     ctlDynamicButtonsOpen.Command += new CommandEventHandler(Page_Command);
     ctlDynamicButtonsHistory.Command += new CommandEventHandler(Page_Command);
     m_sMODULE = "Calls";
     arrSelectFields = new UniqueStringCollection();
     arrSelectFields.Add("DATE_MODIFIED");
     arrSelectFields.Add("ACTIVITY_ID");
     arrSelectFields.Add("ACTIVITY_TYPE");
     arrSelectFields.Add("ACTIVITY_ASSIGNED_USER_ID");
     arrSelectFields.Add("IS_OPEN");
     arrSelectFields.Add("DATE_DUE");
     arrSelectFields.Add("STATUS");
     arrSelectFields.Add("DIRECTION");
     this.AppendGridColumns(grdOpen, "Invoices.Activities.Open", arrSelectFields);
     this.AppendGridColumns(grdHistory, "Invoices.Activities.History", arrSelectFields);
     if (IsPostBack)
     {
         ctlDynamicButtonsOpen.AppendButtons("Invoices.Activities.Open", Guid.Empty, Guid.Empty);
         ctlDynamicButtonsHistory.AppendButtons("Invoices.Activities.History", Guid.Empty, Guid.Empty);
     }
 }
 /// <summary>
 ///		Required method for Designer support - do not modify
 ///		the contents of this method with the code editor.
 /// </summary>
 private void InitializeComponent()
 {
     m_sMODULE = "Products";
     SetMenu(m_sMODULE);
     arrSelectFields = new UniqueStringCollection();
     arrSelectFields.Add("ID");
     arrSelectFields.Add("NAME");
     this.AppendGridColumns(grdMain, m_sMODULE + ".ListView", arrSelectFields);
     ctlSearchView.Command = new CommandEventHandler(Page_Command);
     ctlExportHeader.Command = new CommandEventHandler(Page_Command);
     ctlMassUpdate.Command = new CommandEventHandler(Page_Command);
     if (CRMSecurity.GetUserAccess(m_sMODULE, "delete") < 0 && CRMSecurity.GetUserAccess(m_sMODULE, "edit") < 0)
         ctlMassUpdate.Visible = false;
 }
Пример #19
0
		/// <summary>
		///		Required method for Designer support - do not modify
		///		the contents of this method with the code editor.
		/// </summary>
		private void InitializeComponent()
		{
			this.Load += new System.EventHandler(this.Page_Load);
			ctlSearchView.Command += new CommandEventHandler(Page_Command);
			m_sMODULE = "BusinessRules";
			SetMenu(m_sMODULE);
			arrSelectFields = new UniqueStringCollection();
			arrSelectFields.Add("NAME");
			this.AppendGridColumns(grdMain, m_sMODULE + "." + LayoutListView, arrSelectFields);
		}
 /// <summary>
 ///		Required method for Designer support - do not modify
 ///		the contents of this method with the code editor.
 /// </summary>
 private void InitializeComponent()
 {
     ctlDynamicButtons.Command += new CommandEventHandler(Page_Command);
     m_sMODULE = "Payments";
     arrSelectFields = new UniqueStringCollection();
     arrSelectFields.Add("DATE_ENTERED");
     arrSelectFields.Add("PAYMENT_ID");
     arrSelectFields.Add("ASSIGNED_USER_ID");
     arrSelectFields.Add("INVOICE_PAYMENT_ID");
     arrSelectFields.Add("INVOICE_ASSIGNED_USER_ID");
     this.AppendGridColumns(grdMain, "Invoices." + m_sMODULE, arrSelectFields);
     if (IsPostBack)
         ctlDynamicButtons.AppendButtons("Invoices." + m_sMODULE, Guid.Empty, Guid.Empty);
 }
Пример #21
0
        public void Start()
        {
            ThreadStart start = null;
            object      obj2;
            QueryCore   core;

            lock ((obj2 = this._locker))
            {
                core = this._query;
                if ((core == null) || this._cancelRequest)
                {
                    return;
                }
                if (this._executionProgress != LINQPad.ExecutionModel.ExecutionProgress.Starting)
                {
                    throw new InvalidOperationException("Cannot call Start twice on Client");
                }
            }
            if ((core.QueryKind == QueryLanguage.SQL) || (core.QueryKind == QueryLanguage.ESQL))
            {
                if (this._compileOnly)
                {
                    this.OnQueryCompleted("", "");
                }
                else
                {
                    lock ((obj2 = this._locker))
                    {
                        this._executionProgress = LINQPad.ExecutionModel.ExecutionProgress.Executing;
                    }
                    Server server = this._serverGenerator(this);
                    lock ((obj2 = this._locker))
                    {
                        if (this._cancelRequest || (server == null))
                        {
                            return;
                        }
                        if (this._server != server)
                        {
                            this.ClearServer();
                        }
                        this._server = server;
                    }
                    server.WriteResultsToGrids = core.ToDataGrids && (core.QueryKind == QueryLanguage.SQL);
                    UniqueStringCollection source = new UniqueStringCollection(new FileNameComparer());
                    if (core.GetDriver(true) != null)
                    {
                        try
                        {
                            source.AddRange(core.Repository.GetDriverAssemblies());
                            if (!((core.QueryKind != QueryLanguage.ESQL) || string.IsNullOrEmpty(core.Repository.CustomAssemblyPath)))
                            {
                                source.Add(core.Repository.CustomAssemblyPath);
                            }
                        }
                        catch
                        {
                        }
                    }
                    server.ExecuteSqlQuery(core.QueryKind, core.Repository, this._source, source.ToArray <string>(), this, this._pluginWinManager);
                }
            }
            else if ((core.Repository != null) && core.Repository.DynamicSchema)
            {
                lock ((obj2 = this._locker))
                {
                    this._executionProgress = LINQPad.ExecutionModel.ExecutionProgress.AwaitingDataContext;
                }
                DataContextManager.GetDataContextInfo(core.Repository, new DataContextCallback(this.GotDataContext), SchemaChangeTestMode.None);
            }
            else
            {
                if (start == null)
                {
                    start = () => this.CompileAndRun(null);
                }
                new Thread(start)
                {
                    Name = "Query Compiler", IsBackground = true
                }.Start();
            }
        }
Пример #22
0
        public static void AppendGridColumns(string sGRID_NAME, DataGrid grd, UniqueStringCollection arrSelectFields)
        {
            if (grd == null)
            {
                return;
            }
            DataTable dt = CRMCache.GridViewColumns(sGRID_NAME);
            if (dt != null)
            {
                DataView dv = dt.DefaultView;
                dv.Sort = "COLUMN_INDEX";

                bool bEnableTeamManagement = Common.Config.enable_team_management();
                foreach (DataRowView row in dv)
                {
                    int nCOLUMN_INDEX = TypeConvert.ToInteger(row["COLUMN_INDEX"]);
                    string sCOLUMN_TYPE = TypeConvert.ToString(row["COLUMN_TYPE"]);
                    string sHEADER_TEXT = TypeConvert.ToString(row["HEADER_TEXT"]);
                    string sSORT_EXPRESSION = TypeConvert.ToString(row["SORT_EXPRESSION"]);
                    string sITEMSTYLE_WIDTH = TypeConvert.ToString(row["ITEMSTYLE_WIDTH"]);
                    string sITEMSTYLE_CSSCLASS = TypeConvert.ToString(row["ITEMSTYLE_CSSCLASS"]);
                    string sITEMSTYLE_HORIZONTAL_ALIGN = TypeConvert.ToString(row["ITEMSTYLE_HORIZONTAL_ALIGN"]);
                    string sITEMSTYLE_VERTICAL_ALIGN = TypeConvert.ToString(row["ITEMSTYLE_VERTICAL_ALIGN"]);
                    bool bITEMSTYLE_WRAP = TypeConvert.ToBoolean(row["ITEMSTYLE_WRAP"]);
                    string sDATA_FIELD = TypeConvert.ToString(row["DATA_FIELD"]);
                    string sDATA_FORMAT = TypeConvert.ToString(row["DATA_FORMAT"]);
                    string sURL_FIELD = TypeConvert.ToString(row["URL_FIELD"]);
                    string sURL_FORMAT = TypeConvert.ToString(row["URL_FORMAT"]);
                    string sURL_TARGET = TypeConvert.ToString(row["URL_TARGET"]);
                    string sLIST_NAME = TypeConvert.ToString(row["LIST_NAME"]);

                    string sURL_MODULE = TypeConvert.ToString(row["URL_MODULE"]);

                    string sURL_ASSIGNED_FIELD = TypeConvert.ToString(row["URL_ASSIGNED_FIELD"]);

                    if (arrSelectFields != null)
                    {
                        arrSelectFields.Add(sDATA_FIELD);
                        if (!TypeConvert.IsEmptyString(sSORT_EXPRESSION))
                            arrSelectFields.Add(sSORT_EXPRESSION);
                        if (!TypeConvert.IsEmptyString(sURL_FIELD))
                        {
                            if (sURL_FIELD.IndexOf(' ') >= 0)
                                arrSelectFields.AddRange(sURL_FIELD.Split(' '));
                            else
                                arrSelectFields.Add(sURL_FIELD);
                            if (!TypeConvert.IsEmptyString(sURL_ASSIGNED_FIELD))
                                arrSelectFields.Add(sURL_ASSIGNED_FIELD);
                        }
                    }

                    HorizontalAlign eHorizontalAlign = HorizontalAlign.NotSet;
                    switch (sITEMSTYLE_HORIZONTAL_ALIGN.ToLower())
                    {
                        case "left": eHorizontalAlign = HorizontalAlign.Left; break;
                        case "right": eHorizontalAlign = HorizontalAlign.Right; break;
                    }
                    VerticalAlign eVerticalAlign = VerticalAlign.NotSet;
                    switch (sITEMSTYLE_VERTICAL_ALIGN.ToLower())
                    {
                        case "top": eVerticalAlign = VerticalAlign.Top; break;
                        case "middle": eVerticalAlign = VerticalAlign.Middle; break;
                        case "bottom": eVerticalAlign = VerticalAlign.Bottom; break;
                    }

                    if (row["ITEMSTYLE_WRAP"] == DBNull.Value)
                        bITEMSTYLE_WRAP = true;
                    DataGridColumn col = null;

                    if (String.Compare(sCOLUMN_TYPE, "BoundColumn", true) == 0
                      && (String.Compare(sDATA_FORMAT, "Date", true) == 0
                          || String.Compare(sDATA_FORMAT, "DateTime", true) == 0
                          || String.Compare(sDATA_FORMAT, "Currency", true) == 0
                          || String.Compare(sDATA_FORMAT, "Image", true) == 0
                         )
                       )
                    {
                        sCOLUMN_TYPE = "TemplateColumn";
                    }
                    if (String.Compare(sCOLUMN_TYPE, "BoundColumn", true) == 0)
                    {
                        if (TypeConvert.IsEmptyString(sLIST_NAME))
                        {

                            BoundColumn bnd = new BoundColumn();
                            bnd.HeaderText = sHEADER_TEXT;
                            bnd.DataField = sDATA_FIELD;
                            bnd.SortExpression = sSORT_EXPRESSION;
                            bnd.ItemStyle.Width = new Unit(sITEMSTYLE_WIDTH);
                            bnd.ItemStyle.CssClass = sITEMSTYLE_CSSCLASS;
                            bnd.ItemStyle.HorizontalAlign = eHorizontalAlign;
                            bnd.ItemStyle.VerticalAlign = eVerticalAlign;
                            bnd.ItemStyle.Wrap = bITEMSTYLE_WRAP;

                            bnd.HeaderStyle.HorizontalAlign = eHorizontalAlign;
                            col = bnd;
                        }
                        else
                        {

                            TemplateColumn tpl = new TemplateColumn();
                            tpl.HeaderText = sHEADER_TEXT;
                            tpl.SortExpression = sSORT_EXPRESSION;
                            tpl.ItemStyle.Width = new Unit(sITEMSTYLE_WIDTH);
                            tpl.ItemStyle.CssClass = sITEMSTYLE_CSSCLASS;
                            tpl.ItemStyle.HorizontalAlign = eHorizontalAlign;
                            tpl.ItemStyle.VerticalAlign = eVerticalAlign;
                            tpl.ItemStyle.Wrap = bITEMSTYLE_WRAP;

                            tpl.HeaderStyle.HorizontalAlign = eHorizontalAlign;
                            tpl.ItemTemplate = new CreateItemTemplateLiteralList(sDATA_FIELD, sLIST_NAME);
                            col = tpl;
                        }
                    }
                    else if (String.Compare(sCOLUMN_TYPE, "TemplateColumn", true) == 0)
                    {

                        TemplateColumn tpl = new TemplateColumn();
                        tpl.HeaderText = sHEADER_TEXT;
                        tpl.SortExpression = sSORT_EXPRESSION;
                        tpl.ItemStyle.Width = new Unit(sITEMSTYLE_WIDTH);
                        tpl.ItemStyle.CssClass = sITEMSTYLE_CSSCLASS;
                        tpl.ItemStyle.HorizontalAlign = eHorizontalAlign;
                        tpl.ItemStyle.VerticalAlign = eVerticalAlign;
                        tpl.ItemStyle.Wrap = bITEMSTYLE_WRAP;

                        tpl.HeaderStyle.HorizontalAlign = eHorizontalAlign;
                        if (String.Compare(sDATA_FORMAT, "HyperLink", true) == 0)
                        {

                            if (sURL_FIELD.IndexOf(' ') >= 0)
                                tpl.ItemTemplate = new CreateItemTemplateHyperLinkOnClick(sDATA_FIELD, sURL_FIELD, sURL_FORMAT, sURL_TARGET, sITEMSTYLE_CSSCLASS, sURL_MODULE, sURL_ASSIGNED_FIELD);
                            else
                                tpl.ItemTemplate = new CreateItemTemplateHyperLink(sDATA_FIELD, sURL_FIELD, sURL_FORMAT, sURL_TARGET, sITEMSTYLE_CSSCLASS, sURL_MODULE, sURL_ASSIGNED_FIELD);
                        }
                        else if (String.Compare(sDATA_FORMAT, "Image", true) == 0)
                        {
                            tpl.ItemTemplate = new CreateItemTemplateImage(sDATA_FIELD, sITEMSTYLE_CSSCLASS);
                        }
                        else
                        {
                            tpl.ItemStyle.CssClass = sITEMSTYLE_CSSCLASS;
                            tpl.ItemTemplate = new CreateItemTemplateLiteral(sDATA_FIELD, sDATA_FORMAT);
                        }
                        col = tpl;
                    }
                    else if (String.Compare(sCOLUMN_TYPE, "HyperLinkColumn", true) == 0)
                    {

                        HyperLinkColumn lnk = new HyperLinkColumn();
                        lnk.HeaderText = sHEADER_TEXT;
                        lnk.DataTextField = sDATA_FIELD;
                        lnk.SortExpression = sSORT_EXPRESSION;
                        lnk.DataNavigateUrlField = sURL_FIELD;
                        lnk.DataNavigateUrlFormatString = sURL_FORMAT;
                        lnk.Target = sURL_TARGET;
                        lnk.ItemStyle.Width = new Unit(sITEMSTYLE_WIDTH);
                        lnk.ItemStyle.CssClass = sITEMSTYLE_CSSCLASS;
                        lnk.ItemStyle.HorizontalAlign = eHorizontalAlign;
                        lnk.ItemStyle.VerticalAlign = eVerticalAlign;
                        lnk.ItemStyle.Wrap = bITEMSTYLE_WRAP;

                        lnk.HeaderStyle.HorizontalAlign = eHorizontalAlign;
                        col = lnk;
                    }
                    if (col != null)
                    {

                        if (sDATA_FIELD == "TEAM_NAME" && !bEnableTeamManagement)
                        {
                            col.Visible = false;
                        }

                        if (nCOLUMN_INDEX >= grd.Columns.Count)
                            grd.Columns.Add(col);
                        else
                            grd.Columns.AddAt(nCOLUMN_INDEX, col);
                    }
                }
            }
        }
Пример #23
0
		// 04/20/2011   Create a new method so that we can get export field. 
		public static void GridColumns(string sGRID_NAME, UniqueStringCollection arrSelectFields, StringCollection arrSkippedFields)
		{
			DataTable dt = SplendidCache.GridViewColumns(sGRID_NAME);
			if ( dt != null )
			{
				// 01/18/2010   To apply ACL Field Security, we need to know if the Module Name, which we will extract from the EditView Name. 
				string sMODULE_NAME = String.Empty;
				string[] arrGRID_NAME = sGRID_NAME.Split('.');
				if ( arrGRID_NAME.Length > 0 )
				{
					if ( arrGRID_NAME[0] == "ListView" || arrGRID_NAME[0] == "PopupView" || arrGRID_NAME[0] == "Activities" )
						sMODULE_NAME = arrGRID_NAME[0];
					// 01/18/2010   A sub-panel should apply the access rules of the related module. 
					else if ( Sql.ToBoolean(HttpContext.Current.Application["Modules." + arrGRID_NAME[1] + ".Valid"]) )
						sMODULE_NAME = arrGRID_NAME[1];
					else
						sMODULE_NAME = arrGRID_NAME[0];
				}
				foreach(DataRow row in dt.Rows)
				{
					string sCOLUMN_TYPE = Sql.ToString (row["COLUMN_TYPE"]);
					string sDATA_FIELD  = Sql.ToString (row["DATA_FIELD" ]);
					string sDATA_FORMAT = Sql.ToString (row["DATA_FORMAT"]);
					
					// 04/20/2011   Export requests will not exclude any fields. 
					if ( arrSkippedFields != null )
					{
						if ( arrSkippedFields.Contains(sDATA_FIELD) || sDATA_FIELD.EndsWith("_ID") || sDATA_FIELD.EndsWith("_CURRENCY") )
							continue;
					}
					
					// 01/18/2010   A field is either visible or not.  At this time, we will not only show a field to its owner. 
					bool bIsReadable  = true;
					if ( SplendidInit.bEnableACLFieldSecurity && !Sql.IsEmptyString(sDATA_FIELD) )
					{
						Security.ACL_FIELD_ACCESS acl = Security.GetUserFieldSecurity(sMODULE_NAME, sDATA_FIELD, Guid.Empty);
						bIsReadable  = acl.IsReadable();
					}
					
					if ( bIsReadable )
					{
						if ( String.Compare(sCOLUMN_TYPE, "TemplateColumn", true) == 0 )
						{
							if ( String.Compare(sDATA_FORMAT, "HyperLink", true) == 0 )
							{
								if ( !Sql.IsEmptyString(sDATA_FIELD) )
									arrSelectFields.Add(sDATA_FIELD);
							}
						}
						else if ( String.Compare(sCOLUMN_TYPE, "BoundColumn", true) == 0 )
						{
							// 09/23/2010   Add the bound field. 
							if ( !Sql.IsEmptyString(sDATA_FIELD) )
								arrSelectFields.Add(sDATA_FIELD);
						}
					}
				}
			}
		}
Пример #24
0
		// 02/08/2008   We need to build a list of the fields used by the dynamic grid. 
		// 03/01/2014   Add Preview button. 
		public static void AppendGridColumns(string sGRID_NAME, DataGrid grd, UniqueStringCollection arrSelectFields, CommandEventHandler Page_Command)
		{
			if ( grd == null )
			{
				SplendidError.SystemWarning(new StackTrace(true).GetFrame(0), "DataGrid is not defined for " + sGRID_NAME);
				return;
			}
			DataTable dt = SplendidCache.GridViewColumns(sGRID_NAME);
			if ( dt != null )
			{
				// 01/01/2008   Pull config flag outside the loop. 
				bool bEnableTeamManagement = Crm.Config.enable_team_management();
				// 08/28/2009   Allow dynamic teams to be turned off. 
				bool bEnableDynamicTeams   = Crm.Config.enable_dynamic_teams();
				foreach(DataRow row in dt.Rows)
				{
					int    nCOLUMN_INDEX               = Sql.ToInteger(row["COLUMN_INDEX"              ]);
					string sCOLUMN_TYPE                = Sql.ToString (row["COLUMN_TYPE"               ]);
					string sHEADER_TEXT                = Sql.ToString (row["HEADER_TEXT"               ]);
					string sSORT_EXPRESSION            = Sql.ToString (row["SORT_EXPRESSION"           ]);
					string sITEMSTYLE_WIDTH            = Sql.ToString (row["ITEMSTYLE_WIDTH"           ]);
					string sITEMSTYLE_CSSCLASS         = Sql.ToString (row["ITEMSTYLE_CSSCLASS"        ]);
					string sITEMSTYLE_HORIZONTAL_ALIGN = Sql.ToString (row["ITEMSTYLE_HORIZONTAL_ALIGN"]);
					string sITEMSTYLE_VERTICAL_ALIGN   = Sql.ToString (row["ITEMSTYLE_VERTICAL_ALIGN"  ]);
					bool   bITEMSTYLE_WRAP             = Sql.ToBoolean(row["ITEMSTYLE_WRAP"            ]);
					string sDATA_FIELD                 = Sql.ToString (row["DATA_FIELD"                ]);
					string sDATA_FORMAT                = Sql.ToString (row["DATA_FORMAT"               ]);
					string sURL_FIELD                  = Sql.ToString (row["URL_FIELD"                 ]);
					string sURL_FORMAT                 = Sql.ToString (row["URL_FORMAT"                ]);
					string sURL_TARGET                 = Sql.ToString (row["URL_TARGET"                ]);
					string sLIST_NAME                  = Sql.ToString (row["LIST_NAME"                 ]);
					// 04/28/2006   The module is necessary in order to determine if a user has access. 
					string sURL_MODULE                 = Sql.ToString (row["URL_MODULE"                ]);
					// 05/02/2006   The assigned user id is necessary if the user only has Owner access. 
					string sURL_ASSIGNED_FIELD         = Sql.ToString (row["URL_ASSIGNED_FIELD"        ]);
					// 02/16/2010   Add MODULE_TYPE so that we can lookup custom field IDs. 
					string sMODULE_TYPE = String.Empty;
					try
					{
						sMODULE_TYPE = Sql.ToString (row["MODULE_TYPE"]);
					}
					catch(Exception ex)
					{
						// 06/16/2010   The MODULE_TYPE is not in the view, then log the error and continue. 
						SplendidError.SystemWarning(new StackTrace(true).GetFrame(0), ex);
					}
					// 10/09/2010   Add PARENT_FIELD so that we can establish dependent listboxes. 
					string sPARENT_FIELD = String.Empty;
					try
					{
						sPARENT_FIELD = Sql.ToString (row["PARENT_FIELD"]);
					}
					catch(Exception ex)
					{
						// 10/09/2010   The PARENT_FIELD is not in the view, then log the error and continue. 
						SplendidError.SystemWarning(new StackTrace(true).GetFrame(0), ex);
					}

					if ( (sDATA_FIELD == "TEAM_NAME" || sDATA_FIELD == "TEAM_SET_NAME") )
					{
						if ( bEnableTeamManagement && bEnableDynamicTeams )
						{
							sHEADER_TEXT = ".LBL_LIST_TEAM_SET_NAME";
							sDATA_FIELD  = "TEAM_SET_NAME";
						}
					}
					// 02/08/2008   We need to build a list of the fields used by the dynamic grid. 
					if ( arrSelectFields != null )
					{
						// 08/02/2010   The JavaScript and Hover fields will not have a data field. 
						if ( !Sql.IsEmptyString(sDATA_FIELD) )
							arrSelectFields.Add(sDATA_FIELD);
						if ( !Sql.IsEmptyString(sSORT_EXPRESSION) )
							arrSelectFields.Add(sSORT_EXPRESSION);
						if ( !Sql.IsEmptyString(sURL_FIELD) )
						{
							// 08/02/2010   We want to allow Terminology fields, so exclude anything with a "."
							if ( sURL_FIELD.IndexOf(' ') >= 0 )
							{
								string[] arrURL_FIELD = sURL_FIELD.Split(' ');
								foreach ( string s in arrURL_FIELD )
								{
									if ( !s.Contains(".") && !Sql.IsEmptyString(s) )
										arrSelectFields.Add(s);
								}
							}
							else if ( !sURL_FIELD.Contains(".") )
								arrSelectFields.Add(sURL_FIELD);
							if ( !Sql.IsEmptyString(sURL_ASSIGNED_FIELD) )
								arrSelectFields.Add(sURL_ASSIGNED_FIELD);
						}
						// 10/09/2010   Add PARENT_FIELD so that we can establish dependent listboxes. 
						if ( !Sql.IsEmptyString(sPARENT_FIELD) )
							arrSelectFields.Add(sPARENT_FIELD);
					}
					
					HorizontalAlign eHorizontalAlign = HorizontalAlign.NotSet;
					switch ( sITEMSTYLE_HORIZONTAL_ALIGN.ToLower() )
					{
						case "left" :  eHorizontalAlign = HorizontalAlign.Left ;  break;
						case "right":  eHorizontalAlign = HorizontalAlign.Right;  break;
					}
					VerticalAlign eVerticalAlign = VerticalAlign.NotSet;
					switch ( sITEMSTYLE_VERTICAL_ALIGN.ToLower() )
					{
						case "top"   :  eVerticalAlign = VerticalAlign.Top   ;  break;
						case "middle":  eVerticalAlign = VerticalAlign.Middle;  break;
						case "bottom":  eVerticalAlign = VerticalAlign.Bottom;  break;
					}
					// 11/28/2005   Wrap defaults to true. 
					if ( row["ITEMSTYLE_WRAP"] == DBNull.Value )
						bITEMSTYLE_WRAP = true;

					// 01/18/2010   To apply ACL Field Security, we need to know if the Module Name, which we will extract from the EditView Name. 
					string sMODULE_NAME = String.Empty;
					string[] arrGRID_NAME = sGRID_NAME.Split('.');
					if ( arrGRID_NAME.Length > 0 )
					{
						if ( arrGRID_NAME[0] == "ListView" || arrGRID_NAME[0] == "PopupView" || arrGRID_NAME[0] == "Activities" )
							sMODULE_NAME = arrGRID_NAME[0];
						// 01/18/2010   A sub-panel should apply the access rules of the related module. 
						else if ( Sql.ToBoolean(HttpContext.Current.Application["Modules." + arrGRID_NAME[1] + ".Valid"]) )
							sMODULE_NAME = arrGRID_NAME[1];
						else
							sMODULE_NAME = arrGRID_NAME[0];
					}
					// 01/18/2010   A field is either visible or not.  At this time, we will not only show a field to its owner. 
					bool bIsReadable  = true;
					// 08/02/2010   The JavaScript and Hover fields will not have a data field. 
					if ( SplendidInit.bEnableACLFieldSecurity && !Sql.IsEmptyString(sDATA_FIELD) )
					{
						Security.ACL_FIELD_ACCESS acl = Security.GetUserFieldSecurity(sMODULE_NAME, sDATA_FIELD, Guid.Empty);
						bIsReadable  = acl.IsReadable();
					}

					DataGridColumn col = null;
					// 02/03/2006   Date and Currency must always be handled by CreateItemTemplateLiteral. 
					// Otherwise, the date or time will not get properly translated to the correct timezone. 
					// This bug was reported by David Williams. 
					// 05/20/2009   We need a way to preserve CRLF in description fields. 
					if (     String.Compare(sCOLUMN_TYPE, "BoundColumn", true) == 0 
					  && (   String.Compare(sDATA_FORMAT, "Date"       , true) == 0 
					      || String.Compare(sDATA_FORMAT, "DateTime"   , true) == 0 
					      || String.Compare(sDATA_FORMAT, "Currency"   , true) == 0
					      || String.Compare(sDATA_FORMAT, "Image"      , true) == 0
					      || String.Compare(sDATA_FORMAT, "MultiLine"  , true) == 0
					     )
					   )
					{
						sCOLUMN_TYPE = "TemplateColumn";
					}
					// 03/14/2014   A hidden field does not render.  It is primarily used to add a field to the SQL select list for Business Rules management. 
					else if ( String.Compare(sCOLUMN_TYPE, "Hidden", true) == 0 )
					{
						continue;
					}
					if ( String.Compare(sCOLUMN_TYPE, "BoundColumn", true) == 0 )
					{
						if ( Sql.IsEmptyString(sLIST_NAME) )
						{
							// GRID_NAME, COLUMN_ORDER, COLUMN_TYPE, HEADER_TEXT, DATA_FIELD, SORT_EXPRESSION, ITEMSTYLE_WIDTH
							BoundColumn bnd = new BoundColumn();
							bnd.HeaderText                  = sHEADER_TEXT       ;
							bnd.DataField                   = sDATA_FIELD        ;
							bnd.SortExpression              = sSORT_EXPRESSION   ;
							bnd.ItemStyle.Width             = new Unit(sITEMSTYLE_WIDTH);
							bnd.ItemStyle.CssClass          = sITEMSTYLE_CSSCLASS;
							bnd.ItemStyle.HorizontalAlign   = eHorizontalAlign   ;
							bnd.ItemStyle.VerticalAlign     = eVerticalAlign     ;
							bnd.ItemStyle.Wrap              = bITEMSTYLE_WRAP    ;
							// 04/13/2007   Align the headers to match the data. 
							bnd.HeaderStyle.HorizontalAlign = eHorizontalAlign   ;
							col = bnd;
							// 01/18/2010   Apply ACL Field Security. 
							col.Visible = bIsReadable;
							// 10/23/2012 Kevin.  Allow me to pass data format for gridview bound columns. 
							if ( !Sql.IsEmptyString(sDATA_FORMAT) )
							{
								bnd.DataFormatString = sDATA_FORMAT;
							}
						}
						else
						{
							// GRID_NAME, COLUMN_ORDER, COLUMN_TYPE, HEADER_TEXT, DATA_FIELD, SORT_EXPRESSION, ITEMSTYLE_WIDTH
							TemplateColumn tpl = new TemplateColumn();
							tpl.HeaderText                  = sHEADER_TEXT       ;
							tpl.SortExpression              = sSORT_EXPRESSION   ;
							tpl.ItemStyle.Width             = new Unit(sITEMSTYLE_WIDTH);
							tpl.ItemStyle.CssClass          = sITEMSTYLE_CSSCLASS;
							tpl.ItemStyle.HorizontalAlign   = eHorizontalAlign   ;
							tpl.ItemStyle.VerticalAlign     = eVerticalAlign     ;
							tpl.ItemStyle.Wrap              = bITEMSTYLE_WRAP    ;
							// 04/13/2007   Align the headers to match the data. 
							tpl.HeaderStyle.HorizontalAlign = eHorizontalAlign   ;
							// 10/09/2010   Add PARENT_FIELD so that we can establish dependent listboxes. 
							tpl.ItemTemplate = new CreateItemTemplateLiteralList(sDATA_FIELD, sLIST_NAME, sPARENT_FIELD);
							col = tpl;
							// 01/18/2010   Apply ACL Field Security. 
							col.Visible = bIsReadable;
						}
					}
					else if ( String.Compare(sCOLUMN_TYPE, "TemplateColumn", true) == 0 )
					{
						// GRID_NAME, COLUMN_ORDER, COLUMN_TYPE, HEADER_TEXT, DATA_FIELD, SORT_EXPRESSION, ITEMSTYLE_WIDTH
						TemplateColumn tpl = new TemplateColumn();
						tpl.HeaderText                  = sHEADER_TEXT       ;
						tpl.SortExpression              = sSORT_EXPRESSION   ;
						tpl.ItemStyle.Width             = new Unit(sITEMSTYLE_WIDTH);
						tpl.ItemStyle.CssClass          = sITEMSTYLE_CSSCLASS;
						tpl.ItemStyle.HorizontalAlign   = eHorizontalAlign   ;
						tpl.ItemStyle.VerticalAlign     = eVerticalAlign     ;
						tpl.ItemStyle.Wrap              = bITEMSTYLE_WRAP    ;
						// 04/13/2007   Align the headers to match the data. 
						tpl.HeaderStyle.HorizontalAlign = eHorizontalAlign   ;
						if ( String.Compare(sDATA_FORMAT, "JavaScript", true) == 0 )
						{
							// 08/02/2010   In our application of Field Level Security, we will hide fields by replacing with "."
							if ( SplendidInit.bEnableACLFieldSecurity && !Sql.IsEmptyString(sURL_FIELD) )
							{
								string[] arrURL_FIELD = sURL_FIELD.Split(' ');
								for ( int i=0; i < arrURL_FIELD.Length; i++ )
								{
									Security.ACL_FIELD_ACCESS acl = Security.GetUserFieldSecurity(sMODULE_NAME, sDATA_FIELD, Guid.Empty);
									if ( !acl.IsReadable() )
										arrURL_FIELD[i] = ".";
								}
								sURL_FIELD = String.Join(" ", arrURL_FIELD);
							}
							tpl.ItemTemplate = new CreateItemTemplateJavaScript(sDATA_FIELD, sURL_FIELD, sURL_FORMAT, sURL_TARGET);
						}
						// 02/26/2014   Add Preview button. 
						else if ( String.Compare(sDATA_FORMAT, "JavaImage", true) == 0 )
						{
							if ( SplendidInit.bEnableACLFieldSecurity && !Sql.IsEmptyString(sURL_FIELD) )
							{
								string[] arrURL_FIELD = sURL_FIELD.Split(' ');
								for ( int i=0; i < arrURL_FIELD.Length; i++ )
								{
									Security.ACL_FIELD_ACCESS acl = Security.GetUserFieldSecurity(sMODULE_NAME, sDATA_FIELD, Guid.Empty);
									if ( !acl.IsReadable() )
										arrURL_FIELD[i] = ".";
								}
								sURL_FIELD = String.Join(" ", arrURL_FIELD);
							}
							tpl.ItemTemplate = new CreateItemTemplateJavaScriptImage(sURL_FIELD, sURL_FORMAT, sURL_TARGET);
						}
						// 03/01/2014   Add Preview button. 
						else if ( String.Compare(sDATA_FORMAT, "ImageButton", true) == 0 )
						{
							// 03/01/2014   sURL_FIELD is an internal value, so there is no need to apply ACL rules. 
							tpl.ItemTemplate = new CreateItemTemplateImageButton(sURL_FIELD, sURL_FORMAT, sURL_TARGET, sITEMSTYLE_CSSCLASS, Page_Command);
						}
						else if ( String.Compare(sDATA_FORMAT, "Hover", true) == 0 )
						{
							string sIMAGE_SKIN = sURL_TARGET;
							if ( Sql.IsEmptyString(sIMAGE_SKIN) )
								sIMAGE_SKIN = "info_inline";
							// 08/02/2010   In our application of Field Level Security, we will hide fields by replacing with "."
							if ( SplendidInit.bEnableACLFieldSecurity && !Sql.IsEmptyString(sURL_FIELD) )
							{
								string[] arrURL_FIELD = sURL_FIELD.Split(' ');
								for ( int i=0; i < arrURL_FIELD.Length; i++ )
								{
									Security.ACL_FIELD_ACCESS acl = Security.GetUserFieldSecurity(sMODULE_NAME, sDATA_FIELD, Guid.Empty);
									if ( !acl.IsReadable() )
										arrURL_FIELD[i] = ".";
								}
								sURL_FIELD = String.Join(" ", arrURL_FIELD);
							}
							tpl.ItemTemplate = new CreateItemTemplateHover(sDATA_FIELD, sURL_FIELD, sURL_FORMAT, sIMAGE_SKIN);
						}
						else if ( String.Compare(sDATA_FORMAT, "HyperLink", true) == 0 )
						{
							// 07/26/2007   PopupViews have special requirements.  They need an OnClick action that takes more than one parameter. 
							if ( sURL_FIELD.IndexOf(' ') >= 0 )
								tpl.ItemTemplate = new CreateItemTemplateHyperLinkOnClick(sDATA_FIELD, sURL_FIELD, sURL_FORMAT, sURL_TARGET, sITEMSTYLE_CSSCLASS, sURL_MODULE, sURL_ASSIGNED_FIELD, sMODULE_TYPE);
							else
								tpl.ItemTemplate = new CreateItemTemplateHyperLink(sDATA_FIELD, sURL_FIELD, sURL_FORMAT, sURL_TARGET, sITEMSTYLE_CSSCLASS, sURL_MODULE, sURL_ASSIGNED_FIELD, sMODULE_TYPE);
						}
						else if ( String.Compare(sDATA_FORMAT, "Image", true) == 0 )
						{
							tpl.ItemTemplate = new CreateItemTemplateImage(sDATA_FIELD, sITEMSTYLE_CSSCLASS);
						}
						else
						{
							tpl.ItemStyle.CssClass = sITEMSTYLE_CSSCLASS;
							tpl.ItemTemplate = new CreateItemTemplateLiteral(sDATA_FIELD, sDATA_FORMAT, sMODULE_TYPE);
						}
						col = tpl;
						// 01/18/2010   Apply ACL Field Security. 
						col.Visible = bIsReadable;
					}
					else if ( String.Compare(sCOLUMN_TYPE, "HyperLinkColumn", true) == 0 )
					{
						// GRID_NAME, COLUMN_ORDER, COLUMN_TYPE, HEADER_TEXT, DATA_FIELD, SORT_EXPRESSION, ITEMSTYLE_WIDTH, ITEMSTYLE-CSSCLASS, URL_FIELD, URL_FORMAT
						HyperLinkColumn lnk = new HyperLinkColumn();
						lnk.HeaderText                  = sHEADER_TEXT       ;
						lnk.DataTextField               = sDATA_FIELD        ;
						lnk.SortExpression              = sSORT_EXPRESSION   ;
						lnk.DataNavigateUrlField        = sURL_FIELD         ;
						lnk.DataNavigateUrlFormatString = sURL_FORMAT        ;
						lnk.Target                      = sURL_TARGET        ;
						lnk.ItemStyle.Width             = new Unit(sITEMSTYLE_WIDTH);
						lnk.ItemStyle.CssClass          = sITEMSTYLE_CSSCLASS;
						lnk.ItemStyle.HorizontalAlign   = eHorizontalAlign   ;
						lnk.ItemStyle.VerticalAlign     = eVerticalAlign     ;
						lnk.ItemStyle.Wrap              = bITEMSTYLE_WRAP    ;
						// 04/13/2007   Align the headers to match the data. 
						lnk.HeaderStyle.HorizontalAlign = eHorizontalAlign   ;
						col = lnk;
						// 01/18/2010   Apply ACL Field Security. 
						col.Visible = bIsReadable;
					}
					if ( col != null )
					{
						// 11/25/2006   If Team Management has been disabled, then hide the column. 
						// Keep the column, but hide it so that the remaining column positions will still be valid. 
						// 10/27/2007   The data field was changed to TEAM_NAME on 11/25/2006. It should have been changed here as well. 
						// 08/24/2009   Add support for dynamic teams. 
						if ( (sDATA_FIELD == "TEAM_NAME" || sDATA_FIELD == "TEAM_SET_NAME") && !bEnableTeamManagement )
						{
							col.Visible = false;
						}
						// 11/28/2005   In case the column specified is too high, just append column. 
						if ( nCOLUMN_INDEX >= grd.Columns.Count )
							grd.Columns.Add(col);
						else
							grd.Columns.AddAt(nCOLUMN_INDEX, col);
					}
				}
			}
			// 09/20/2012   We need a SCRIPT field that is form specific. 
			if ( dt.Rows.Count > 0 )
			{
				try
				{
					string sFORM_SCRIPT = Sql.ToString(dt.Rows[0]["SCRIPT"]);
					if ( !Sql.IsEmptyString(sFORM_SCRIPT) )
					{
						// 09/20/2012   The base ID is not the ID of the parent, but the ID of the TemplateControl. 
						sFORM_SCRIPT = sFORM_SCRIPT.Replace("SPLENDID_GRIDVIEW_LAYOUT_ID", grd.TemplateControl.ClientID);
						ScriptManager.RegisterStartupScript(grd, typeof(System.String), sGRID_NAME.Replace(".", "_") + "_SCRIPT", sFORM_SCRIPT, true);
					}
				}
				catch(Exception ex)
				{
					SplendidError.SystemWarning(new StackTrace(true).GetFrame(0), ex);
				}
			}
		}
Пример #25
0
        private void Extract(TagArchive archive, bool recusive, params string[] files)
        {
            extractionActive = true;
            int totalFilesExtracted = 0, totalFilesToExtract = 0;

            List <TagSet> sets = archive.BuildTagLocationList(files, currentGame);

            // Setup the counts.
            foreach (TagSet set in sets)
            {
                totalFilesToExtract += set.Tags.Count;
            }

            progressPanel.TotalExtracted = 0;
            progressPanel.TagCount       = totalFilesToExtract;

            UniqueStringCollection additionalFiles = new UniqueStringCollection();

            try
            {
                foreach (TagSet set in sets)
                {
                    string filename = currentGame.Maps[set.MapIndex].Filename;

                    // UI Update
                    progressPanel.CurrentMap = Path.GetFileName(filename);

                    progressPanel.CurrentMap = filename;
                    progressPanel.OpeningMap = true;
                    IMapFile map = currentGame.CreateMapFileObject();
                    map.Load(currentGame.MapFilePath + "\\" + filename);

                    progressPanel.ExtractingTags = true;
                    // Sort alphabetically so that folders don't get extracted out of order.
                    set.Tags.Sort();

                    // Extract the tags one by one.
                    foreach (string tag in set.Tags)
                    {
                        // UI Update
                        progressPanel.CurrentTag = tag;
                        bool successful = true;
                        try
                        {
                            // Check and see if we have attempted to cancel...
                            if (!extractionActive)
                            {
                                return;
                            }

                            if (!archive.FileExists(tag))
                            {
                                byte[] data = map.GetTag(tag);
                                archive.AddFile(tag, data);
                            }
                        }
                        catch (Exception ex)
                        {
                            successful = false;
                            Output.Write(OutputTypes.Error, "Unable to extract tag '" + tag + ex.Message);
                        }
                        if (successful)
                        {
                            RemoveFromQueue(tag);
                        }
                        totalFilesExtracted++;

                        // UI Update
                        progressPanel.TotalExtracted = totalFilesExtracted;

                        if (recusive)
                        {
                            // Attempt to deserialize the tag, and get its dependencies.
                            string   tagExtension = Path.GetExtension(tag).Trim('.');
                            Type     tagType      = currentGame.TypeTable.LocateEntryByName(tagExtension).TagType;
                            TagPath  poolPath     = new TagPath(tag, currentGame.GameID, TagLocation.Archive);
                            string[] dependencies = Core.Prometheus.Instance.Pool.GetTagReferences(poolPath.ToPath(), tagType);
                            foreach (string dependency in dependencies)
                            {
                                if (!archive.FileExists(dependency))
                                {
                                    additionalFiles.Add(dependency);
                                }
                            }
                        }
                    }
                }
                if (additionalFiles.Count > 0)
                {
                    progressPanel.Title = "Extracting dependencies...";
                    // Extract the additional files.
                    Extract(archive, true, additionalFiles.ToArray());
                }
            }
            finally
            {
                UpdateExtractionButton();
            }
        }
Пример #26
0
		/// <summary>
		///		Required method for Designer support - do not modify
		///		the contents of this method with the code editor.
		/// </summary>
		private void InitializeComponent()
		{
			this.Load += new System.EventHandler(this.Page_Load);
			ctlSearchView  .Command += new CommandEventHandler(Page_Command);
			ctlExportHeader.Command += new CommandEventHandler(Page_Command);
			// 11/26/2005   Add fields early so that sort events will get called. 
			m_sMODULE = "UserLogins";
			SetMenu("Users");
			// 02/08/2008   We need to build a list of the fields used by the search clause. 
			arrSelectFields = new UniqueStringCollection();
			arrSelectFields.Add("FULL_NAME");
			// 02/21/2008   IS_ADMIN is used in the grid. 
			arrSelectFields.Add("IS_ADMIN");
			arrSelectFields.Add("DATE_MODIFIED");
			this.AppendGridColumns(grdMain, "Users.LoginView", arrSelectFields);
		}
Пример #27
0
 protected void Page_Command(object sender, CommandEventArgs e)
 {
     if (e.CommandName == "Search")
     {
         grdMain.CurrentPageIndex = 0;
         grdMain.DataBind();
     }
     else if (e.CommandName == "SortGrid")
     {
         grdMain.SetSortFields(e.CommandArgument as string[]);
         arrSelectFields.Add(grdMain.SortColumn);
     }
     else if (e.CommandName == "MassUpdate")
     {
         string[] arrID = Request.Form.GetValues("chkMain");
         if (arrID != null)
         {
             Stack stk = Utils.FilterByACL_Stack(m_sMODULE, "edit", arrID, "INVOICES");
             if (stk.Count > 0)
             {
                 while (stk.Count > 0)
                 {
                     string sIDs = Utils.BuildMassIDs(stk);
                     CommonProcedure.InvoicesMassUpdate(sIDs, ctlMassUpdate.ASSIGNED_USER_ID,
                                                        ctlMassUpdate.PAYMENT_TERMS, ctlMassUpdate.INVOICE_STAGE,
                                                        TimeZone.GetTimeZone.ToServerTime(ctlMassUpdate.DUE_DATE),
                                                        ctlMassUpdate.TEAM_ID);
                 }
                 Response.Redirect("Index.aspx");
             }
         }
     }
     else if (e.CommandName == "MassDelete")
     {
         string[] arrID = Request.Form.GetValues("chkMain");
         if (arrID != null)
         {
             Stack stk = Utils.FilterByACL_Stack(m_sMODULE, "delete", arrID, "INVOICES");
             if (stk.Count > 0)
             {
                 while (stk.Count > 0)
                 {
                     string sIDs = Utils.BuildMassIDs(stk);
                     CommonProcedure.InvoicesMassDelete(sIDs);
                 }
                 Response.Redirect("Index.aspx");
             }
         }
     }
     else if (e.CommandName == "Export")
     {
         // Apply ACL rules to Export.
         int nACLACCESS = Security.GetUserAccess(m_sMODULE, "export");
         if (nACLACCESS >= 0)
         {
             if (nACLACCESS == ACL_ACCESS.OWNER)
             {
                 vwMain.RowFilter = "ASSIGNED_USER_ID = '" + Security.USER_ID + "'";
             }
             string[] arrID = Request.Form.GetValues("chkMain");
             CRMExport.Export(vwMain, m_sMODULE, ctlExportHeader.ExportFormat, ctlExportHeader.ExportRange,
                              grdMain.CurrentPageIndex, grdMain.PageSize, arrID);
         }
     }
 }
Пример #28
0
 /// <summary>
 ///		Required method for Designer support - do not modify
 ///		the contents of this method with the code editor.
 /// </summary>
 private void InitializeComponent()
 {
     this.Load += new System.EventHandler(this.Page_Load);
     // 11/26/2005   Add fields early so that sort events will get called. 
     m_sMODULE = "TQQuoteDetail";
     SetMenu(m_sMODULE);
     // 02/08/2008   We need to build a list of the fields used by the search clause. 
     arrSelectFields = new UniqueStringCollection();
     arrSelectFields.Add("ID");
     arrSelectFields.Add("C_Status");
     this.AppendGridColumns(grdMain, m_sMODULE + "." + LayoutListView, arrSelectFields);
     grdMain.ItemCommand += grdMain_ItemCommand;
     rptModal.ItemDataBound += rptModal_ItemDataBound;
     btnConfirm.Click += btnConfirm_Click;
 }
 /// <summary>
 ///		Required method for Designer support - do not modify
 ///		the contents of this method with the code editor.
 /// </summary>
 private void InitializeComponent()
 {
     ctlDynamicButtons.Command += new CommandEventHandler(Page_Command);
     m_sMODULE = "ProductTemplates";
     arrSelectFields = new UniqueStringCollection();
     arrSelectFields.Add("DATE_ENTERED");
     arrSelectFields.Add("PRODUCT_TEMPLATE_ID");
     this.AppendGridColumns(grdMain, "ProductTemplates.RelatedProducts", arrSelectFields);
     if (IsPostBack)
         ctlDynamicButtons.AppendButtons("ProductTemplates.RelatedProducts", Guid.Empty, Guid.Empty);
 }
 /// <summary>
 ///		Required method for Designer support - do not modify
 ///		the contents of this method with the code editor.
 /// </summary>
 private void InitializeComponent()
 {
     ctlDynamicButtons.Command += new CommandEventHandler(Page_Command);
     m_sMODULE = "Payments";
     arrSelectFields = new UniqueStringCollection();
     arrSelectFields.Add("DATE_ENTERED");
     arrSelectFields.Add("ID");
     this.AppendGridColumns(grdMain, m_sMODULE + ".PaymentTransactions", arrSelectFields);
     if (IsPostBack)
         ctlDynamicButtons.AppendButtons(m_sMODULE + ".PaymentTransactions", Guid.Empty, Guid.Empty);
 }
Пример #31
0
		public Stream GetModuleTable(string TableName)
		{
			HttpApplicationState Application = HttpContext.Current.Application;
			HttpRequest          Request     = HttpContext.Current.Request    ;
			
			WebOperationContext.Current.OutgoingResponse.Headers.Add("Cache-Control", "no-cache");
			WebOperationContext.Current.OutgoingResponse.Headers.Add("Pragma", "no-cache");
			
			int    nSKIP     = Sql.ToInteger(Request.QueryString["$skip"   ]);
			int    nTOP      = Sql.ToInteger(Request.QueryString["$top"    ]);
			string sFILTER   = Sql.ToString (Request.QueryString["$filter" ]);
			string sORDER_BY = Sql.ToString (Request.QueryString["$orderby"]);
			// 06/17/2013   Add support for GROUP BY. 
			string sGROUP_BY = Sql.ToString (Request.QueryString["$groupby"]);
			// 08/03/2011   We need a way to filter the columns so that we can be efficient. 
			string sSELECT   = Sql.ToString (Request.QueryString["$select" ]);
			string[] arrItems = Request.QueryString.GetValues("Items");
			Guid[] Items = null;
			// 06/17/2011   arrItems might be null. 
			if ( arrItems != null && arrItems.Length > 0 )
			{
				Items = new Guid[arrItems.Length];
				for ( int i = 0; i < arrItems.Length; i++ )
				{
					Items[i] = Sql.ToGuid(arrItems[i]);
				}
			}
			Regex r = new Regex(@"[^A-Za-z0-9_]");
			string sFILTER_KEYWORDS = (" " + r.Replace(sFILTER, " ") + " ").ToLower();
			if ( sFILTER_KEYWORDS.Contains(" select ") )
			{
				throw(new Exception("Subqueries are not allowed."));
			}
			if ( sFILTER.Contains(";") )
			{
				// 06/18/2011   This is to prevent the user from attempting to inject SQL. 
				throw(new Exception("A semicolon is not allowed anywhere in a filter. "));
			}
			if ( sORDER_BY.Contains(";") )
			{
				// 06/18/2011   This is to prevent the user from attempting to inject SQL. 
				throw(new Exception("A semicolon is not allowed anywhere in a sort expression. "));
			}
			if ( !Security.IsAuthenticated() )
			{
				L10N L10n = new L10N(Sql.ToString(HttpContext.Current.Session["USER_SETTINGS/CULTURE"]));
				throw(new Exception(L10n.Term("ACL.LBL_INSUFFICIENT_ACCESS")));
			}
			// 08/22/2011   Add admin control to REST API. 
			string sMODULE_NAME = Sql.ToString(Application["Modules." + TableName + ".ModuleName"]);
			// 08/22/2011   Not all tables will have a module name, such as relationship tables. 
			// Tables will get another security filter later in the code. 
			if ( !Sql.IsEmptyString(sMODULE_NAME) )
			{
				int nACLACCESS = Security.GetUserAccess(sMODULE_NAME, "list");
				if ( !Sql.ToBoolean(Application["Modules." + sMODULE_NAME + ".RestEnabled"]) || nACLACCESS < 0 )
				{
					L10N L10n = new L10N(Sql.ToString(HttpContext.Current.Session["USER_SETTINGS/CULTURE"]));
					throw(new Exception(L10n.Term("ACL.LBL_INSUFFICIENT_ACCESS")));
				}
			}
			
			UniqueStringCollection arrSELECT = new UniqueStringCollection();
			sSELECT = sSELECT.Replace(" ", "");
			if ( !Sql.IsEmptyString(sSELECT) )
			{
				foreach ( string s in sSELECT.Split(',') )
				{
					string sColumnName = r.Replace(s, "");
					if ( !Sql.IsEmptyString(sColumnName) )
						arrSELECT.Add(sColumnName);
				}
			}
			
			// 06/17/2013   Add support for GROUP BY. 
			DataTable dt = GetTable(TableName, nSKIP, nTOP, sFILTER, sORDER_BY, sGROUP_BY, arrSELECT, Items);
			
			string sBaseURI = Request.Url.Scheme + "://" + Request.Url.Host + Request.Url.AbsolutePath.Replace("/GetModuleTable", "/GetModuleItem");
			JavaScriptSerializer json = new JavaScriptSerializer();
			// 05/05/2013   No reason to limit the Json result. 
			json.MaxJsonLength = int.MaxValue;
			
			// 05/05/2013   We need to convert the date to the user's timezone. 
			Guid     gTIMEZONE         = Sql.ToGuid  (HttpContext.Current.Session["USER_SETTINGS/TIMEZONE"]);
			TimeZone T10n              = TimeZone.CreateTimeZone(gTIMEZONE);
			string sResponse = json.Serialize(ToJson(sBaseURI, sMODULE_NAME, dt, T10n));
			byte[] byResponse = Encoding.UTF8.GetBytes(sResponse);
			return new MemoryStream(byResponse);
		}
Пример #32
0
		// 06/17/2013   Add support for GROUP BY. 
		private DataTable GetTable(string sTABLE_NAME, int nSKIP, int nTOP, string sFILTER, string sORDER_BY, string sGROUP_BY, UniqueStringCollection arrSELECT, Guid[] arrITEMS)
		{
			HttpContext          Context     = HttpContext.Current;
			HttpSessionState     Session     = HttpContext.Current.Session;
			HttpApplicationState Application = HttpContext.Current.Application;
			DataTable dt = null;
			try
			{
				// 09/03/2011   We should use the cached layout tables instead of a database lookup for performance reasons. 
				// When getting the layout tables, we typically only need the view name, so extract from the filter string. 
				// The Regex match will allow an OData query. 
				if ( Security.IsAuthenticated() )
				{
					string sMATCH_NAME = String.Empty;
					if ( sTABLE_NAME == "DYNAMIC_BUTTONS" )
					{
						sMATCH_NAME = "VIEW_NAME";
						Match match = Regex.Match(sFILTER, "\\b" + sMATCH_NAME + "\\s*(=|eq)\\s*\'(?<" + sMATCH_NAME + ">([^(\'|\\s)]*))", RegexOptions.ExplicitCapture | RegexOptions.IgnoreCase);
						if ( match.Success )
						{
							string sVIEW_NAME = match.Groups[sMATCH_NAME].Value;
							dt = SplendidCache.DynamicButtons(sVIEW_NAME).Copy();
							if ( dt != null )
							{
								bool bRowsDeleted = false;
								foreach(DataRow row in dt.Rows)
								{
									string sCONTROL_TYPE       = Sql.ToString (row["CONTROL_TYPE"      ]);
									string sMODULE_NAME        = Sql.ToString (row["MODULE_NAME"       ]);
									string sMODULE_ACCESS_TYPE = Sql.ToString (row["MODULE_ACCESS_TYPE"]);
									string sTARGET_NAME        = Sql.ToString (row["TARGET_NAME"       ]);
									string sTARGET_ACCESS_TYPE = Sql.ToString (row["TARGET_ACCESS_TYPE"]);
									bool   bADMIN_ONLY         = Sql.ToBoolean(row["ADMIN_ONLY"        ]);
									
									bool bVisible = (bADMIN_ONLY && Security.isAdmin || !bADMIN_ONLY);
									if ( String.Compare(sCONTROL_TYPE, "Button", true) == 0 || String.Compare(sCONTROL_TYPE, "HyperLink", true) == 0 || String.Compare(sCONTROL_TYPE, "ButtonLink", true) == 0 )
									{
										if ( bVisible && !Sql.IsEmptyString(sMODULE_NAME) && !Sql.IsEmptyString(sMODULE_ACCESS_TYPE) )
										{
											int nACLACCESS = Taoqi.Security.GetUserAccess(sMODULE_NAME, sMODULE_ACCESS_TYPE);
											// 09/03/2011   Can't apply Owner rights without the item record. 
											//bVisible = (nACLACCESS > ACL_ACCESS.OWNER) || (nACLACCESS == ACL_ACCESS.OWNER && ((Security.USER_ID == gASSIGNED_USER_ID) || (!bIsPostBack && rdr == null) || (rdr != null && bShowUnassigned && Sql.IsEmptyGuid(gASSIGNED_USER_ID))));
											if ( bVisible && !Sql.IsEmptyString(sTARGET_NAME) && !Sql.IsEmptyString(sTARGET_ACCESS_TYPE) )
											{
												nACLACCESS = Taoqi.Security.GetUserAccess(sTARGET_NAME, sTARGET_ACCESS_TYPE);
												// 09/03/2011   Can't apply Owner rights without the item record. 
												//bVisible = (nACLACCESS > ACL_ACCESS.OWNER) || (nACLACCESS == ACL_ACCESS.OWNER && ((Security.USER_ID == gASSIGNED_USER_ID) || (!bIsPostBack && rdr == null) || (rdr != null && bShowUnassigned && Sql.IsEmptyGuid(gASSIGNED_USER_ID))));
											}
										}
									}
									if ( !bVisible )
									{
										row.Delete();
										bRowsDeleted = true;
									}
								}
								if ( bRowsDeleted )
									dt.AcceptChanges();
							}
							return dt;
						}
					}
					else if ( sTABLE_NAME == "GRIDVIEWS_COLUMNS" )
					{
						sMATCH_NAME = "GRID_NAME";
						Match match = Regex.Match(sFILTER, "\\b" + sMATCH_NAME + "\\s*(=|eq)\\s*\'(?<" + sMATCH_NAME + ">([^(\'|\\s)]*))", RegexOptions.ExplicitCapture | RegexOptions.IgnoreCase);
						if ( match.Success )
						{
							string sGRID_NAME = match.Groups[sMATCH_NAME].Value;
							dt = SplendidCache.GridViewColumns(sGRID_NAME);
							// 09/03/2011   Apply Field Level Security before sending to the client. 
							if ( dt != null && SplendidInit.bEnableACLFieldSecurity )
							{
								bool bRowsDeleted = false;
								// 09/20/2012   We need a SCRIPT field that is form specific. 
								for ( int i = 0; i < dt.Rows.Count; i++ )
								{
									DataRow row = dt.Rows[i];
									string sDATA_FIELD  = Sql.ToString (row["DATA_FIELD"]);
									string sMODULE_NAME = String.Empty;
									string[] arrGRID_NAME = sGRID_NAME.Split('.');
									if ( arrGRID_NAME.Length > 0 )
									{
										if ( arrGRID_NAME[0] == "ListView" || arrGRID_NAME[0] == "PopupView" || arrGRID_NAME[0] == "Activities" )
											sMODULE_NAME = arrGRID_NAME[0];
										else if ( Sql.ToBoolean(Application["Modules." + arrGRID_NAME[1] + ".Valid"]) )
											sMODULE_NAME = arrGRID_NAME[1];
										else
											sMODULE_NAME = arrGRID_NAME[0];
									}
									bool bIsReadable = true;
									if ( SplendidInit.bEnableACLFieldSecurity && !Sql.IsEmptyString(sDATA_FIELD) )
									{
										Security.ACL_FIELD_ACCESS acl = Security.GetUserFieldSecurity(sMODULE_NAME, sDATA_FIELD, Guid.Empty);
										bIsReadable  = acl.IsReadable();
									}
									if ( !bIsReadable )
									{
										row.Delete();
										bRowsDeleted = true;
									}
									// 09/03/2011   We only need one copy of the SCRIPT field in the first record. 
									if ( i > 0 )
										row["SCRIPT"] = DBNull.Value;
								}
								if ( bRowsDeleted )
									dt.AcceptChanges();
							}
							return dt;
						}
					}
					else if ( sTABLE_NAME == "EDITVIEWS_FIELDS" )
					{
						sMATCH_NAME = "EDIT_NAME";
						Match match = Regex.Match(sFILTER, "\\b" + sMATCH_NAME + "\\s*(=|eq)\\s*\'(?<" + sMATCH_NAME + ">([^(\'|\\s)]*))", RegexOptions.ExplicitCapture | RegexOptions.IgnoreCase);
						if ( match.Success )
						{
							string sEDIT_NAME = match.Groups[sMATCH_NAME].Value;
							dt = SplendidCache.EditViewFields(sEDIT_NAME);
							// 09/03/2011   Apply Field Level Security before sending to the client. 
							if ( dt != null && SplendidInit.bEnableACLFieldSecurity )
							{
								// 09/20/2012   We need a SCRIPT field that is form specific. 
								for ( int i = 0; i < dt.Rows.Count; i++ )
								{
									DataRow row = dt.Rows[i];
									string sFIELD_TYPE    = Sql.ToString (row["FIELD_TYPE"   ]);
									string sDATA_FIELD    = Sql.ToString (row["DATA_FIELD"   ]);
									string sDATA_FORMAT   = Sql.ToString (row["DATA_FORMAT"  ]);
									string sDISPLAY_FIELD = Sql.ToString (row["DISPLAY_FIELD"]);
									string sMODULE_NAME   = String.Empty;
									string[] arrEDIT_NAME = sEDIT_NAME.Split('.');
									if ( arrEDIT_NAME.Length > 0 )
										sMODULE_NAME = arrEDIT_NAME[0];
									bool bIsReadable  = true;
									bool bIsWriteable = true;
									if ( SplendidInit.bEnableACLFieldSecurity )
									{
										// 09/03/2011   Can't apply Owner rights without the item record. 
										Security.ACL_FIELD_ACCESS acl = Security.GetUserFieldSecurity(sMODULE_NAME, sDATA_FIELD, Guid.Empty);
										bIsReadable  = acl.IsReadable();
										// 02/16/2011   We should allow a Read-Only field to be searchable, so always allow writing if the name contains Search. 
										bIsWriteable = acl.IsWriteable() || sEDIT_NAME.Contains(".Search");
									}
									if ( !bIsReadable )
									{
										row["FIELD_TYPE"] = "Blank";
									}
									else if ( !bIsWriteable )
									{
										row["FIELD_TYPE"] = "Label";
									}
									// 09/03/2011   We only need one copy of the SCRIPT field in the first record. 
									if ( i > 0 )
										row["SCRIPT"] = DBNull.Value;
								}
							}
							return dt;
						}
					}
					else if ( sTABLE_NAME == "DETAILVIEWS_FIELDS" )
					{
						sMATCH_NAME = "DETAIL_NAME";
						Match match = Regex.Match(sFILTER, "\\b" + sMATCH_NAME + "\\s*(=|eq)\\s*\'(?<" + sMATCH_NAME + ">([^(\'|\\s)]*))", RegexOptions.ExplicitCapture | RegexOptions.IgnoreCase);
						if ( match.Success )
						{
							string sDETAIL_NAME = match.Groups[sMATCH_NAME].Value;
							dt = SplendidCache.DetailViewFields(sDETAIL_NAME);
							// 09/03/2011   Apply Field Level Security before sending to the client. 
							if ( dt != null && SplendidInit.bEnableACLFieldSecurity )
							{
								// 09/20/2012   We need a SCRIPT field that is form specific. 
								for ( int i = 0; i < dt.Rows.Count; i++ )
								{
									DataRow row = dt.Rows[i];
									string sDATA_FIELD  = Sql.ToString (row["DATA_FIELD"]);
									string sMODULE_NAME = String.Empty;
									string[] arrDETAIL_NAME = sDETAIL_NAME.Split('.');
									if ( arrDETAIL_NAME.Length > 0 )
										sMODULE_NAME = arrDETAIL_NAME[0];
									bool bIsReadable  = true;
									if ( SplendidInit.bEnableACLFieldSecurity && !Sql.IsEmptyString(sDATA_FIELD) )
									{
										// 09/03/2011   Can't apply Owner rights without the item record. 
										Security.ACL_FIELD_ACCESS acl = Security.GetUserFieldSecurity(sMODULE_NAME, sDATA_FIELD, Guid.Empty);
										bIsReadable  = acl.IsReadable();
									}
									if ( !bIsReadable )
									{
										row["FIELD_TYPE"] = "Blank";
									}
									// 09/03/2011   We only need one copy of the SCRIPT field in the first record. 
									if ( i > 0 )
										row["SCRIPT"] = DBNull.Value;
								}
							}
							return dt;
						}
					}
					else if ( sTABLE_NAME == "DETAILVIEWS_RELATIONSHIPS" )
					{
						sMATCH_NAME = "DETAIL_NAME";
						Match match = Regex.Match(sFILTER, "\\b" + sMATCH_NAME + "\\s*(=|eq)\\s*\'(?<" + sMATCH_NAME + ">([^(\'|\\s)]*))", RegexOptions.ExplicitCapture | RegexOptions.IgnoreCase);
						if ( match.Success )
						{
							string sVIEW_NAME = match.Groups[sMATCH_NAME].Value;
							dt = SplendidCache.DetailViewRelationships(sVIEW_NAME).Copy();
							if ( dt != null )
							{
								bool bRowsDeleted = false;
								foreach(DataRow row in dt.Rows)
								{
									string sMODULE_NAME       = Sql.ToString(row["MODULE_NAME" ]);
									string sCONTROL_NAME      = Sql.ToString(row["CONTROL_NAME"]);
									string sMODULE_TABLE_NAME = Sql.ToString(Context.Application["Modules." + sMODULE_NAME + ".TableName"]).ToUpper();
									// 10/09/2012   Make sure to filter by modules with REST enabled. 
									using ( DataView vwSYNC_TABLES = new DataView(SplendidCache.RestTables(sMODULE_TABLE_NAME, true)) )
									{
										bool bVisible = (Taoqi.Security.GetUserAccess(sMODULE_NAME, "list") >= 0) && vwSYNC_TABLES.Count > 0;
										if ( !bVisible )
										{
											row.Delete();
											bRowsDeleted = true;
										}
									}
								}
								if ( bRowsDeleted )
									dt.AcceptChanges();
							}
							return dt;
						}
					}
					else if ( sTABLE_NAME == "TAB_MENUS" )
					{
						dt = SplendidCache.TabMenu();
						return dt;
					}
					Regex r = new Regex(@"[^A-Za-z0-9_]");
					sTABLE_NAME = r.Replace(sTABLE_NAME, "");
					DbProviderFactory dbf = DbProviderFactories.GetFactory();
					using ( IDbConnection con = dbf.CreateConnection() )
					{
						con.Open();
						// 06/03/2011   Cache the Rest Table data. 
						using ( DataTable dtSYNC_TABLES = SplendidCache.RestTables(sTABLE_NAME, false) )
						{
							string sSQL = String.Empty;
							if ( dtSYNC_TABLES != null && dtSYNC_TABLES.Rows.Count > 0 )
							{
								DataRow rowSYNC_TABLE = dtSYNC_TABLES.Rows[0];
								string sMODULE_NAME         = Sql.ToString (rowSYNC_TABLE["MODULE_NAME"        ]);
								string sVIEW_NAME           = Sql.ToString (rowSYNC_TABLE["VIEW_NAME"          ]);
								bool   bHAS_CUSTOM          = Sql.ToBoolean(rowSYNC_TABLE["HAS_CUSTOM"         ]);
								int    nMODULE_SPECIFIC     = Sql.ToInteger(rowSYNC_TABLE["MODULE_SPECIFIC"    ]);
								string sMODULE_FIELD_NAME   = Sql.ToString (rowSYNC_TABLE["MODULE_FIELD_NAME"  ]);
								bool   bIS_RELATIONSHIP     = Sql.ToBoolean(rowSYNC_TABLE["IS_RELATIONSHIP"    ]);
								string sMODULE_NAME_RELATED = Sql.ToString (rowSYNC_TABLE["MODULE_NAME_RELATED"]);
								string sASSIGNED_FIELD_NAME = Sql.ToString (rowSYNC_TABLE["ASSIGNED_FIELD_NAME"]);
								// 09/28/2011   Include the system flag so that we can cache only system tables. 
								bool   bIS_SYSTEM           = Sql.ToBoolean(rowSYNC_TABLE["IS_SYSTEM"          ]);
								// 11/01/2009   Protect against SQL Injection. A table name will never have a space character.
								sTABLE_NAME                 = Sql.ToString (rowSYNC_TABLE["TABLE_NAME"         ]);
								sTABLE_NAME        = r.Replace(sTABLE_NAME       , "");
								sVIEW_NAME         = r.Replace(sVIEW_NAME        , "");
								sMODULE_FIELD_NAME = r.Replace(sMODULE_FIELD_NAME, "");
								
								// 09/28/2011   Non-system tables should not be cached on the server because they can change at any time. 
								// 10/01/2011   We are getting No Response on system tables and no network request is made when online. 
								//if ( !bIS_SYSTEM )
									HttpContext.Current.Response.ExpiresAbsolute = new DateTime(1980, 1, 1, 0, 0, 0, 0);
								
								// 08/03/2011   We need a way to filter the columns so that we can be efficient. 
								if ( arrSELECT != null && arrSELECT.Count > 0 )
								{
									foreach ( string sColumnName in arrSELECT )
									{
										if ( Sql.IsEmptyString(sSQL) )
											sSQL += "select " + sVIEW_NAME + "." + sColumnName + ControlChars.CrLf;
										else
											sSQL += "     , " + sVIEW_NAME + "." + sColumnName + ControlChars.CrLf;
									}
								}
								else
								{
									sSQL = "select " + sVIEW_NAME + ".*" + ControlChars.CrLf;
								}
								// 06/18/2011   The REST API tables will use the view properly, so there is no need to join to the CSTM table. 
								sSQL += "  from " + sVIEW_NAME        + ControlChars.CrLf;
								using ( IDbCommand cmd = con.CreateCommand() )
								{
									cmd.CommandText = sSQL;
									cmd.CommandTimeout = 0;
									// 10/27/2009   Apply the standard filters. 
									// 11/03/2009   Relationship tables will not have Team or Assigned fields. 
									if ( bIS_RELATIONSHIP )
									{
										cmd.CommandText += " where 1 = 1" + ControlChars.CrLf;
										// 11/06/2009   Use the relationship table to get the module information. 
										DataView vwRelationships = new DataView(SplendidCache.ReportingRelationships(Context.Application));
										vwRelationships.RowFilter = "(JOIN_TABLE = '" + sTABLE_NAME + "' and RELATIONSHIP_TYPE = 'many-to-many') or (RHS_TABLE = '" + sTABLE_NAME + "' and RELATIONSHIP_TYPE = 'one-to-many')";
										if ( vwRelationships.Count > 0 )
										{
											foreach ( DataRowView rowRelationship in vwRelationships )
											{
												string sJOIN_KEY_LHS             = Sql.ToString(rowRelationship["JOIN_KEY_LHS"            ]).ToUpper();
												string sJOIN_KEY_RHS             = Sql.ToString(rowRelationship["JOIN_KEY_RHS"            ]).ToUpper();
												string sLHS_MODULE               = Sql.ToString(rowRelationship["LHS_MODULE"              ]);
												string sRHS_MODULE               = Sql.ToString(rowRelationship["RHS_MODULE"              ]);
												string sLHS_TABLE                = Sql.ToString(rowRelationship["LHS_TABLE"               ]).ToUpper();
												string sRHS_TABLE                = Sql.ToString(rowRelationship["RHS_TABLE"               ]).ToUpper();
												string sLHS_KEY                  = Sql.ToString(rowRelationship["LHS_KEY"                 ]).ToUpper();
												string sRHS_KEY                  = Sql.ToString(rowRelationship["RHS_KEY"                 ]).ToUpper();
												string sRELATIONSHIP_TYPE        = Sql.ToString(rowRelationship["RELATIONSHIP_TYPE"       ]);
												string sRELATIONSHIP_ROLE_COLUMN = Sql.ToString(rowRelationship["RELATIONSHIP_ROLE_COLUMN"]).ToUpper();
												sJOIN_KEY_LHS = r.Replace(sJOIN_KEY_LHS, "");
												sJOIN_KEY_RHS = r.Replace(sJOIN_KEY_RHS, "");
												sLHS_MODULE   = r.Replace(sLHS_MODULE  , "");
												sRHS_MODULE   = r.Replace(sRHS_MODULE  , "");
												sLHS_TABLE    = r.Replace(sLHS_TABLE   , "");
												sRHS_TABLE    = r.Replace(sRHS_TABLE   , "");
												sLHS_KEY      = r.Replace(sLHS_KEY     , "");
												sRHS_KEY      = r.Replace(sRHS_KEY     , "");
												if ( sRELATIONSHIP_TYPE == "many-to-many" )
												{
													cmd.CommandText += "   and " + sJOIN_KEY_LHS + " in " + ControlChars.CrLf;
													cmd.CommandText += "(select " + sLHS_KEY + " from " + sLHS_TABLE + ControlChars.CrLf;
													Security.Filter(cmd, sLHS_MODULE, "list");
													cmd.CommandText += ")" + ControlChars.CrLf;
													
													// 11/12/2009   We don't want to deal with relationships to multiple tables, so just ignore for now. 
													if ( sRELATIONSHIP_ROLE_COLUMN != "RELATED_TYPE" )
													{
														cmd.CommandText += "   and " + sJOIN_KEY_RHS + " in " + ControlChars.CrLf;
														cmd.CommandText += "(select " + sRHS_KEY + " from " + sRHS_TABLE + ControlChars.CrLf;
														Security.Filter(cmd, sRHS_MODULE, "list");
														cmd.CommandText += ")" + ControlChars.CrLf;
													}
												}
												else if ( sRELATIONSHIP_TYPE == "one-to-many" )
												{
													cmd.CommandText += "   and " + sRHS_KEY + " in " + ControlChars.CrLf;
													cmd.CommandText += "(select " + sLHS_KEY + " from " + sLHS_TABLE + ControlChars.CrLf;
													Security.Filter(cmd, sLHS_MODULE, "list");
													cmd.CommandText += ")" + ControlChars.CrLf;
												}
											}
										}
										else
										{
											// 11/12/2009   EMAIL_IMAGES is a special table that is related to EMAILS or KBDOCUMENTS. 
											if ( sTABLE_NAME == "EMAIL_IMAGES" )
											{
												// 11/12/2009   There does not appear to be an easy way to filter the EMAIL_IMAGES table. 
												// For now, just return the EMAIL related images. 
												cmd.CommandText += "   and PARENT_ID in " + ControlChars.CrLf;
												cmd.CommandText += "(select ID from EMAILS" + ControlChars.CrLf;
												Security.Filter(cmd, "Emails", "list");
												cmd.CommandText += "union all" + ControlChars.CrLf;
												cmd.CommandText += "select ID from KBDOCUMENTS" + ControlChars.CrLf;
												Security.Filter(cmd, "KBDocuments", "list");
												cmd.CommandText += ")" + ControlChars.CrLf;
											}
											// 11/06/2009   If the relationship is not in the RELATIONSHIPS table, then try and build it manually. 
											// 11/05/2009   We cannot use the standard filter on the Teams table (or TeamNotices). 
											else if ( !Sql.IsEmptyString(sMODULE_NAME) && !sMODULE_NAME.StartsWith("Team") )
											{
												// 11/05/2009   We could query the foreign key tables to perpare the filters, but that is slow. 
												string sMODULE_TABLE_NAME   = Sql.ToString(Context.Application["Modules." + sMODULE_NAME + ".TableName"]).ToUpper();
												if ( !Sql.IsEmptyString(sMODULE_TABLE_NAME) )
												{
													// 06/04/2011   New function to get the singular name. 
													string sMODULE_FIELD_ID = Crm.Modules.SingularTableName(sMODULE_TABLE_NAME) + "_ID";
													
													cmd.CommandText += "   and " + sMODULE_FIELD_ID + " in " + ControlChars.CrLf;
													cmd.CommandText += "(select ID from " + sMODULE_TABLE_NAME + ControlChars.CrLf;
													Security.Filter(cmd, sMODULE_NAME, "list");
													cmd.CommandText += ")" + ControlChars.CrLf;
												}
											}
											// 11/05/2009   We cannot use the standard filter on the Teams table. 
											if ( !Sql.IsEmptyString(sMODULE_NAME_RELATED) && !sMODULE_NAME_RELATED.StartsWith("Team") )
											{
												string sMODULE_TABLE_RELATED = Sql.ToString(Context.Application["Modules." + sMODULE_NAME_RELATED + ".TableName"]).ToUpper();
												if ( !Sql.IsEmptyString(sMODULE_TABLE_RELATED) )
												{
													// 06/04/2011   New function to get the singular name. 
													string sMODULE_RELATED_ID = Crm.Modules.SingularTableName(sMODULE_TABLE_RELATED) + "_ID";
													
													// 11/05/2009   Some tables use ASSIGNED_USER_ID as the relationship ID instead of the USER_ID. 
													if ( sMODULE_RELATED_ID == "USER_ID" && !Sql.IsEmptyString(sASSIGNED_FIELD_NAME) )
														sMODULE_RELATED_ID = sASSIGNED_FIELD_NAME;
													
													cmd.CommandText += "   and " + sMODULE_RELATED_ID + " in " + ControlChars.CrLf;
													cmd.CommandText += "(select ID from " + sMODULE_TABLE_RELATED + ControlChars.CrLf;
													Security.Filter(cmd, sMODULE_NAME_RELATED, "list");
													cmd.CommandText += ")" + ControlChars.CrLf;
												}
											}
										}
									}
									else
									{
										// 02/14/2010   GetTable should only require read-only access. 
										// We were previously requiring Edit access, but that seems to be a high bar. 
										Security.Filter(cmd, sMODULE_NAME, "view");
									}
									if ( !Sql.IsEmptyString(sMODULE_FIELD_NAME) )
									{
										List<string> lstMODULES = AccessibleModules();
										
										if ( sTABLE_NAME == "MODULES" )
										{
											// 11/27/2009   Don't filter the MODULES table. It can cause system tables to get deleted. 
											// 11/28/2009   Keep the filter on the Modules table, but add the System Sync Tables to the list. 
											// We should make sure that the clients do not get module records for unnecessary or disabled modules. 
											Sql.AppendParameter(cmd, lstMODULES.ToArray(), sMODULE_FIELD_NAME);
											// 10/09/2012   We need to make sure to only return modules that are available to REST. 
											cmd.CommandText += "   and MODULE_NAME in (select MODULE_NAME from vwSYSTEM_REST_TABLES)" + ControlChars.CrLf;
										}
										else if ( nMODULE_SPECIFIC == 1 )
										{
											Sql.AppendParameter(cmd, lstMODULES.ToArray(), sMODULE_FIELD_NAME);
										}
										else if ( nMODULE_SPECIFIC == 2 )
										{
											// 04/05/2012   AppendLikeModules is a special like that assumes that the search is for a module related value 
											Sql.AppendLikeModules(cmd, lstMODULES.ToArray(), sMODULE_FIELD_NAME);
										}
										else if ( nMODULE_SPECIFIC == 3 )
										{
											cmd.CommandText += "   and ( 1 = 0" + ControlChars.CrLf;
											cmd.CommandText += "         or " + sMODULE_FIELD_NAME + " is null" + ControlChars.CrLf;
											// 11/02/2009   There are a number of terms with undefined modules. 
											// ACL, ACLActions, Audit, Config, Dashlets, DocumentRevisions, Export, Merge, Roles, SavedSearch, Teams
											cmd.CommandText += "     ";
											Sql.AppendParameter(cmd, lstMODULES.ToArray(), sMODULE_FIELD_NAME, true);
											cmd.CommandText += "       )" + ControlChars.CrLf;
										}
										// 11/22/2009   Make sure to only send the selected user language.  This will dramatically reduce the amount of data. 
										//if ( sTABLE_NAME == "TERMINOLOGY" || sTABLE_NAME == "TERMINOLOGY_HELP" )
										//{
										//	cmd.CommandText += "   and LANG in ('en-US', @LANG)" + ControlChars.CrLf;
										//	string sCULTURE  = Sql.ToString(Session["USER_SETTINGS/CULTURE" ]);
										//	Sql.AddParameter(cmd, "@LANG", sCULTURE);
										//}
									}
		
									if ( arrITEMS != null )
									{
										// 11/13/2009   If a list of items is provided, then the max records field is ignored. 
										nSKIP = 0;
										nTOP = -1;
										Sql.AppendGuids(cmd, arrITEMS, "ID");
									}
									else if ( sTABLE_NAME == "IMAGES" )
									{
										// 02/14/2010   There is no easy way to filter IMAGES table, so we are simply going to fetch 
										// images that the user has created.  Otherwise, images that are accessible to the user will 
										// need to be retrieved by ID.
										Sql.AppendParameter(cmd, Security.USER_ID, "CREATED_BY");
									}
									// 06/18/2011   Tables that are filtered by user should have an explicit filter added. 
									if ( sASSIGNED_FIELD_NAME == "USER_ID" )
									{
										Sql.AppendParameter(cmd, Security.USER_ID, "USER_ID");
									}
									if ( !Sql.IsEmptyString(sFILTER) )
									{
										string sSQL_FILTER = ConvertODataFilter(sFILTER, cmd);
										cmd.CommandText += "   and (" + sSQL_FILTER + ")" + ControlChars.CrLf;;
									}
									if ( Sql.IsEmptyString(sORDER_BY) )
									{
										sORDER_BY = " order by " + sVIEW_NAME + ".DATE_MODIFIED_UTC" + ControlChars.CrLf;
									}
									else
									{
										// 06/18/2011   Allow a comma in a sort expression. 
										r = new Regex(@"[^A-Za-z0-9_, ]");
										sORDER_BY = " order by " + r.Replace(sORDER_BY, "");
									}
									// 06/17/2013   Add support for GROUP BY. 
									if ( !Sql.IsEmptyString(sGROUP_BY) )
									{
										// 06/18/2011   Allow a comma in a sort expression. 
										r = new Regex(@"[^A-Za-z0-9_, ]");
										sGROUP_BY = " group by " + r.Replace(sGROUP_BY, "");
									}
									//cmd.CommandText += sORDER_BY;
// 03/20/2012   Nolonger need to debug these SQL statements. 
//#if DEBUG
//									SplendidError.SystemWarning(new StackTrace(true).GetFrame(0), Sql.ExpandParameters(cmd));
//#endif
									
									using ( DbDataAdapter da = dbf.CreateDataAdapter() )
									{
										((IDbDataAdapter)da).SelectCommand = cmd;
										// 11/08/2009   The table name is required in order to serialize the DataTable. 
										dt = new DataTable(sTABLE_NAME);
										if ( nTOP > 0 )
										{
											if ( nSKIP > 0 )
											{
												int nCurrentPageIndex = nSKIP / nTOP;
												// 06/17/2103   We cannot page a group result. 
												Sql.PageResults(cmd, sTABLE_NAME, sORDER_BY, nCurrentPageIndex, nTOP);
												da.Fill(dt);
											}
											else
											{
												// 06/17/2013   Add support for GROUP BY. 
												cmd.CommandText += sGROUP_BY + sORDER_BY;
												using ( DataSet ds = new DataSet() )
												{
													ds.Tables.Add(dt);
													da.Fill(ds, 0, nTOP, sTABLE_NAME);
												}
											}
										}
										else
										{
											// 06/17/2013   Add support for GROUP BY. 
											cmd.CommandText += sGROUP_BY + sORDER_BY;
											da.Fill(dt);
										}
										// 02/24/2013   Manually add the Calendar entries. 
										if ( sTABLE_NAME == "TERMINOLOGY" && (sFILTER.Contains("MODULE_NAME eq 'Calendar'") || sFILTER.Contains("MODULE_NAME = 'Calendar'")) )
										{
											string sLANG  = Sql.ToString(Session["USER_SETTINGS/CULTURE" ]);
											DataRow row = null;
											row = dt.NewRow();
											row["LANG"        ] = sLANG;
											row["NAME"        ] = "YearMonthPattern";
											row["MODULE_NAME" ] = "Calendar";
											row["DISPLAY_NAME"] = System.Threading.Thread.CurrentThread.CurrentCulture.DateTimeFormat.YearMonthPattern;
											dt.Rows.Add(row);
											row = dt.NewRow();
											row["LANG"        ] = sLANG;
											row["NAME"        ] = "MonthDayPattern";
											row["MODULE_NAME" ] = "Calendar";
											row["DISPLAY_NAME"] = System.Threading.Thread.CurrentThread.CurrentCulture.DateTimeFormat.MonthDayPattern;
											dt.Rows.Add(row);
											row = dt.NewRow();
											row["LANG"        ] = sLANG;
											row["NAME"        ] = "LongDatePattern";
											row["MODULE_NAME" ] = "Calendar";
											row["DISPLAY_NAME"] = System.Threading.Thread.CurrentThread.CurrentCulture.DateTimeFormat.LongDatePattern;
											dt.Rows.Add(row);
											row = dt.NewRow();
											row["LANG"        ] = sLANG;
											row["NAME"        ] = "ShortTimePattern";
											row["MODULE_NAME" ] = "Calendar";
											row["DISPLAY_NAME"] = Sql.ToString(HttpContext.Current.Session["USER_SETTINGS/TIMEFORMAT"]);
											dt.Rows.Add(row);
											row = dt.NewRow();
											row["LANG"        ] = sLANG;
											row["NAME"        ] = "ShortDatePattern";
											row["MODULE_NAME" ] = "Calendar";
											row["DISPLAY_NAME"] = Sql.ToString(HttpContext.Current.Session["USER_SETTINGS/DATEFORMAT"]);
											dt.Rows.Add(row);
											row = dt.NewRow();
											row["LANG"        ] = sLANG;
											row["NAME"        ] = "FirstDayOfWeek";
											row["MODULE_NAME" ] = "Calendar";
											row["DISPLAY_NAME"] = ((int) System.Threading.Thread.CurrentThread.CurrentCulture.DateTimeFormat.FirstDayOfWeek).ToString();
											dt.Rows.Add(row);
										}
										// 01/18/2010   Apply ACL Field Security. 
										// 02/01/2010   System tables may not have a valid Module name, so Field Security will not apply. 
										if ( SplendidInit.bEnableACLFieldSecurity && !Sql.IsEmptyString(sMODULE_NAME) )
										{
											bool bApplyACL = false;
											bool bASSIGNED_USER_ID_Exists = dt.Columns.Contains("ASSIGNED_USER_ID");
											foreach ( DataRow row in dt.Rows )
											{
												Guid gASSIGNED_USER_ID = Guid.Empty;
												if ( bASSIGNED_USER_ID_Exists )
													gASSIGNED_USER_ID = Sql.ToGuid(row["ASSIGNED_USER_ID"]);
												foreach ( DataColumn col in dt.Columns )
												{
													Security.ACL_FIELD_ACCESS acl = Security.GetUserFieldSecurity(sMODULE_NAME, col.ColumnName, gASSIGNED_USER_ID);
													if ( !acl.IsReadable() )
													{
														row[col.ColumnName] = DBNull.Value;
														bApplyACL = true;
													}
												}
											}
											if ( bApplyACL )
												dt.AcceptChanges();
										}
										if ( sTABLE_NAME == "USERS" )
										{
											// 05/24/2014   Provide a way to customize the list of available field names for the Users table. 
											UniqueStringCollection arrUSERS_FIELDS = new UniqueStringCollection();
											string sUSERS_FIELDS = Sql.ToString(Application["CONFIG.rest.Users.Fields"]);
											sUSERS_FIELDS = sUSERS_FIELDS.Replace(",", " ").Trim();
											if ( Sql.IsEmptyString(sUSERS_FIELDS) )
											{
												arrUSERS_FIELDS.Add("ID"               );
												arrUSERS_FIELDS.Add("DELETED"          );
												arrUSERS_FIELDS.Add("CREATED_BY"       );
												arrUSERS_FIELDS.Add("DATE_ENTERED"     );
												arrUSERS_FIELDS.Add("MODIFIED_USER_ID" );
												arrUSERS_FIELDS.Add("DATE_MODIFIED"    );
												arrUSERS_FIELDS.Add("DATE_MODIFIED_UTC");
												arrUSERS_FIELDS.Add("USER_NAME"        );
												arrUSERS_FIELDS.Add("FIRST_NAME"       );
												arrUSERS_FIELDS.Add("LAST_NAME"        );
												arrUSERS_FIELDS.Add("REPORTS_TO_ID"    );
												arrUSERS_FIELDS.Add("EMAIL1"           );
												arrUSERS_FIELDS.Add("STATUS"           );
												arrUSERS_FIELDS.Add("IS_GROUP"         );
												arrUSERS_FIELDS.Add("PORTAL_ONLY"      );
												arrUSERS_FIELDS.Add("EMPLOYEE_STATUS"  );
											}
											else
											{
												foreach ( string sField in sUSERS_FIELDS.Split(' ') )
												{
													if ( !Sql.IsEmptyString(sField) )
														arrUSERS_FIELDS.Add(sField.ToUpper());
												}
											}
											// 11/12/2009   For the USERS table, we are going to limit the data return to the client. 
											foreach ( DataRow row in dt.Rows )
											{
												if ( Sql.ToGuid(row["ID"]) != Security.USER_ID )
												{
													foreach ( DataColumn col in dt.Columns )
													{
														// 11/12/2009   Allow auditing fields and basic user info. 
														if ( !arrUSERS_FIELDS.Contains(col.ColumnName) )
														{
															row[col.ColumnName] = DBNull.Value;
														}
													}
												}
											}
											dt.AcceptChanges();
										}
									}
								}
							}
							else
							{
								SplendidError.SystemError(new StackTrace(true).GetFrame(0), sTABLE_NAME + " cannot be accessed.");
							}
						}
					}
				}
			}
			catch(Exception ex)
			{
				// 12/01/2012   We need a more descriptive error message. 
				//SplendidError.SystemError(new StackTrace(true).GetFrame(0), ex);
				string sMessage = "GetTable(" + sTABLE_NAME + ", " + sFILTER + ", " + sORDER_BY + ") " + ex.Message;
				SplendidError.SystemMessage("Error", new StackTrace(true).GetFrame(0), sMessage);
				throw(new Exception(sMessage));
			}
			return dt;
		}
Пример #33
0
		/// <summary>
		/// Required method for Designer support - do not modify
		/// the contents of this method with the code editor.
		/// </summary>
		private void InitializeComponent()
		{    
			this.Load += new System.EventHandler(this.Page_Load);
			ctlDynamicButtons.Command += new CommandEventHandler(Page_Command);
			ctlSearchView    .Command += new CommandEventHandler(Page_Command);
			m_sMODULE = "DynamicLayout";
			arrSelectFields = new UniqueStringCollection();
			arrSelectFields.Add("DETAIL_NAME");
			this.AppendGridColumns(grdMain, m_sMODULE + ".DetailView.PopupView", arrSelectFields);
			ctlDynamicButtons.AppendButtons(m_sMODULE + ".PopupView", Guid.Empty, Guid.Empty);
		}
Пример #34
0
		/// <summary>
		///		Required method for Designer support - do not modify
		///		the contents of this method with the code editor.
		/// </summary>
		private void InitializeComponent()
		{
			this.Load += new System.EventHandler(this.Page_Load);
			ctlSearchView  .Command += new CommandEventHandler(Page_Command);
			ctlExportHeader.Command += new CommandEventHandler(Page_Command);
            m_sMODULE = "TQAccount";
			SetMenu(m_sMODULE);
			arrSelectFields = new UniqueStringCollection();
            arrSelectFields.Add("ID");
            arrSelectFields.Add("C_UserID");
            arrSelectFields.Add("C_Status");
			arrSelectFields.Add("isCompanyAdmin");
			this.AppendGridColumns(grdMain, m_sMODULE + "." + LayoutListView, arrSelectFields);

            grdMain.ItemCommand += grdMain_ItemCommand;
		}
Пример #35
0
 public void Start()
 {
     ThreadStart start = null;
     object obj2;
     QueryCore core;
     lock ((obj2 = this._locker))
     {
         core = this._query;
         if ((core == null) || this._cancelRequest)
         {
             return;
         }
         if (this._executionProgress != LINQPad.ExecutionModel.ExecutionProgress.Starting)
         {
             throw new InvalidOperationException("Cannot call Start twice on Client");
         }
     }
     if ((core.QueryKind == QueryLanguage.SQL) || (core.QueryKind == QueryLanguage.ESQL))
     {
         if (this._compileOnly)
         {
             this.OnQueryCompleted("", "");
         }
         else
         {
             lock ((obj2 = this._locker))
             {
                 this._executionProgress = LINQPad.ExecutionModel.ExecutionProgress.Executing;
             }
             Server server = this._serverGenerator(this);
             lock ((obj2 = this._locker))
             {
                 if (this._cancelRequest || (server == null))
                 {
                     return;
                 }
                 if (this._server != server)
                 {
                     this.ClearServer();
                 }
                 this._server = server;
             }
             server.WriteResultsToGrids = core.ToDataGrids && (core.QueryKind == QueryLanguage.SQL);
             UniqueStringCollection source = new UniqueStringCollection(new FileNameComparer());
             if (core.GetDriver(true) != null)
             {
                 try
                 {
                     source.AddRange(core.Repository.GetDriverAssemblies());
                     if (!((core.QueryKind != QueryLanguage.ESQL) || string.IsNullOrEmpty(core.Repository.CustomAssemblyPath)))
                     {
                         source.Add(core.Repository.CustomAssemblyPath);
                     }
                 }
                 catch
                 {
                 }
             }
             server.ExecuteSqlQuery(core.QueryKind, core.Repository, this._source, source.ToArray<string>(), this, this._pluginWinManager);
         }
     }
     else if ((core.Repository != null) && core.Repository.DynamicSchema)
     {
         lock ((obj2 = this._locker))
         {
             this._executionProgress = LINQPad.ExecutionModel.ExecutionProgress.AwaitingDataContext;
         }
         DataContextManager.GetDataContextInfo(core.Repository, new DataContextCallback(this.GotDataContext), SchemaChangeTestMode.None);
     }
     else
     {
         if (start == null)
         {
             start = () => this.CompileAndRun(null);
         }
         new Thread(start) { Name = "Query Compiler", IsBackground = true }.Start();
     }
 }
Пример #36
0
		/// <summary>
		/// Required method for Designer support - do not modify
		/// the contents of this method with the code editor.
		/// </summary>
		private void InitializeComponent()
		{    
			this.Load += new System.EventHandler(this.Page_Load);
			ctlDynamicButtons.Command += new CommandEventHandler(Page_Command);
			ctlSearchView    .Command += new CommandEventHandler(Page_Command);
			ctlNewRecord     .Command += new CommandEventHandler(Page_Command);
			ctlCheckAll      .Command += new CommandEventHandler(Page_Command);
			m_sMODULE = "BusinessRules";
			arrSelectFields = new UniqueStringCollection();
			arrSelectFields.Add("NAME");
			this.AppendGridColumns(grdMain, m_sMODULE + ".PopupView", arrSelectFields);
			ctlDynamicButtons.AppendButtons(m_sMODULE + ".Popup" + (bMultiSelect ? "MultiSelect" : "View"), Guid.Empty, Guid.Empty);
			if ( !IsPostBack && !bMultiSelect )
				ctlDynamicButtons.ShowButton("Clear", !Sql.ToBoolean(Request["ClearDisabled"]));
		}
Пример #37
0
 /// <summary>
 ///		Required method for Designer support - do not modify
 ///		the contents of this method with the code editor.
 /// </summary>
 private void InitializeComponent()
 {
     this.Load += new System.EventHandler(this.Page_Load);
     m_sMODULE = "TQQuoteCheck";
     SetMenu(m_sMODULE);
     // 02/08/2008   We need to build a list of the fields used by the search clause. 
     arrSelectFields = new UniqueStringCollection();
     arrSelectFields.Add("ID");
     arrSelectFields.Add("C_Status");
     this.AppendGridColumns(grdMain, m_sMODULE + "." + LayoutListView, arrSelectFields);
     grdMain.ItemCommand += grdMain_ItemCommand;
 }
Пример #38
0
 /// <summary>
 /// Required method for Designer support - do not modify
 /// the contents of this method with the code editor.
 /// </summary>
 private void InitializeComponent()
 {
     this.Load += new System.EventHandler(this.Page_Load);
     ctlDynamicButtons.Command += new CommandEventHandler(Page_Command);
     ctlSearchView.Command += new CommandEventHandler(Page_Command);
     ctlCheckAll.Command += new CommandEventHandler(Page_Command);
     m_sMODULE = "TQClient";
     // 07/26/2007   Use the new PopupView so that the view is customizable. 
     // 02/08/2008   We need to build a list of the fields used by the search clause. 
     arrSelectFields = new UniqueStringCollection();
     arrSelectFields.Add("C_ClientShortName");
     // 08/01/2010   We need a separate view to select the Full Name instead of the User Name. 
     this.AppendGridColumns(grdMain, m_sMODULE + ".PopupView" + (Sql.ToString(Request["C_ClientShortName"]) == "1" ? "Name" : ""), arrSelectFields);
     // 04/29/2008   Make use of dynamic buttons. 
     ctlDynamicButtons.AppendButtons(m_sMODULE + ".Popup" + (bMultiSelect ? "MultiSelect" : "View"), Guid.Empty, Guid.Empty);
     if (!IsPostBack && !bMultiSelect)
         ctlDynamicButtons.ShowButton("Clear", !Sql.ToBoolean(Request["ClearDisabled"]));
 }
Пример #39
0
		/// <summary>
		///		Required method for Designer support - do not modify
		///		the contents of this method with the code editor.
		/// </summary>
		private void InitializeComponent()
		{
			this.Load += new System.EventHandler(this.Page_Load);
			ctlDynamicButtons.Command += new CommandEventHandler(Page_Command);
			m_sMODULE = "UserSignatures";
			arrSelectFields = new UniqueStringCollection();
			arrSelectFields.Add("NAME");
			this.AppendGridColumns(grdMain, "Users." + m_sMODULE, arrSelectFields);
			if ( IsPostBack )
				ctlDynamicButtons.AppendButtons("Users." + m_sMODULE, Guid.Empty, Guid.Empty);
		}
Пример #40
0
		/// <summary>
		///		Required method for Designer support - do not modify
		///		the contents of this method with the code editor.
		/// </summary>
		private void InitializeComponent()
		{
			this.Load += new System.EventHandler(this.Page_Load);
			ctlDynamicButtons.Command += new CommandEventHandler(Page_Command);
			m_sMODULE = "Users";
			// 04/26/2008   We need to build a list of the fields used by the search clause. 
			arrSelectFields = new UniqueStringCollection();
			arrSelectFields.Add("DATE_ENTERED");
			arrSelectFields.Add("USER_ID"     );
			arrSelectFields.Add("USER_NAME"   );
			arrSelectFields.Add("FULL_NAME"   );
			arrSelectFields.Add("EMAIL1"      );
			arrSelectFields.Add("PHONE_WORK"  );
			if ( IsPostBack )
				ctlDynamicButtons.AppendButtons("ACLRoles." + m_sMODULE, Guid.Empty, Guid.Empty);
		}
Пример #41
0
 /// <summary>
 ///		Required method for Designer support - do not modify
 ///		the contents of this method with the code editor.
 /// </summary>
 private void InitializeComponent()
 {
     this.Load += new System.EventHandler(this.Page_Load);
     // 11/26/2005   Add fields early so that sort events will get called. 
     m_sMODULE = "TQOrderDetailSell";
     SetMenu(m_sMODULE);
     // 02/08/2008   We need to build a list of the fields used by the search clause. 
     arrSelectFields = new UniqueStringCollection();
     arrSelectFields.Add("ID");
     arrSelectFields.Add("C_Status");
     arrSelectFields.Add("C_CarID");
     arrSelectFields.Add("C_ShippingUrl");
     arrSelectFields.Add("C_Driver");
     arrSelectFields.Add("C_Tel");
     this.AppendGridColumns(grdMain, m_sMODULE + "." + LayoutListView, arrSelectFields);
 }
Пример #42
0
		/// <summary>
		///		Required method for Designer support - do not modify
		///		the contents of this method with the code editor.
		/// </summary>
		private void InitializeComponent()
		{
			this.Load += new System.EventHandler(this.Page_Load);
			ctlSearchView  .Command += new CommandEventHandler(Page_Command);
			ctlExportHeader.Command += new CommandEventHandler(Page_Command);
			// 11/26/2005   Add fields early so that sort events will get called. 
			// 03/18/2010   Change base module to SystemLog. 
			m_sMODULE = "SystemLog";
			SetMenu(m_sMODULE);
			// 02/08/2008   We need to build a list of the fields used by the search clause. 
			arrSelectFields = new UniqueStringCollection();
			arrSelectFields.Add("DATE_ENTERED"    );
			arrSelectFields.Add("USER_ID"         );
			arrSelectFields.Add("USER_NAME"       );
			arrSelectFields.Add("MACHINE"         );
			arrSelectFields.Add("ASPNET_SESSIONID");
			arrSelectFields.Add("REMOTE_HOST"     );
			arrSelectFields.Add("SERVER_HOST"     );
			arrSelectFields.Add("TARGET"          );
			arrSelectFields.Add("ERROR_TYPE"      );
			arrSelectFields.Add("MESSAGE"         );
			arrSelectFields.Add("FILE_NAME"       );
			arrSelectFields.Add("METHOD"          );
			arrSelectFields.Add("LINE_NUMBER"     );
			arrSelectFields.Add("RELATIVE_PATH"   );
			arrSelectFields.Add("PARAMETERS"      );
		}