public virtual Terrasoft.UI.WebControls.Controls.DataSourceFilterCollection CreateFilter(Terrasoft.UI.WebControls.Controls.DataSource detailDataSource, Guid solutionId, UserConnection userConnection) { var detailSchema = detailDataSource.Schema; Terrasoft.UI.WebControls.Utilities.EntityDataSourceUtilities.InitializeAutoDefStructure(detailDataSource as Terrasoft.UI.WebControls.Controls.EntityDataSource); Terrasoft.UI.WebControls.Controls.DataSourceStructure structure = detailDataSource.CurrentStructure; var filterLeftExpressions = FilterLeftExpressions as Array; if (filterLeftExpressions == null || filterLeftExpressions.Length == 0) { return(null); } Terrasoft.UI.WebControls.Controls.DataSourceFilterCollection filters = structure.CreateFiltersGroup(FilterName, LogicalOperationStrict.Or); foreach (string expression in filterLeftExpressions) { if (expression == null) { continue; } var objectParams = GetFilterRightValue(userConnection) as object[]; if (objectParams != null) { filters.Add( structure.CreateFilterWithParameters(detailSchema, Terrasoft.Core.Entities.FilterComparisonType.Equal, expression, objectParams)); } else { filters.Add( structure.CreateFilterWithParameters(detailSchema, Terrasoft.Core.Entities.FilterComparisonType.Equal, expression, GetFilterRightValue(userConnection))); } } return(filters); }
protected override bool InternalExecute(ProcessExecutingContext context) { var detailPageContainer = DetailPageContainer as Terrasoft.UI.WebControls.Controls.PageContainer; if (detailPageContainer == null) { return(true); } if (string.IsNullOrEmpty(ThrowEventName)) { ThrowEventName = "GridPageRefreshRow"; } if (FilterLeftExpressions != null) { var userConnection = context.UserConnection; var detailDataSource = (detailPageContainer.FindPageControlByName("DataSource")) as Terrasoft.UI.WebControls.Controls.DataSource; if (detailDataSource != null) { //Код, который компилируется только в Workspace CR173347 Terrasoft.UI.WebControls.Controls.DataSourceFilterCollection filter = CreateFilter(detailDataSource, userConnection.Workspace.Id, userConnection); SetFilter(detailPageContainer.PageInstance, filter); } } detailPageContainer.PageInstance.ThrowEvent(ThrowEventName); DetailPageContainer = null; PageDataSource = null; return(true); }
public override void BaseApplyModuleFilters() { var pageInstance = Page.Grid.PageInstance as Terrasoft.WebApp.BaseGridPageSchemaUserControl; var dataSource = pageInstance.DataSource; if (!IsRootFolder && FolderId != Guid.Empty) { var folderInfo = GetFolderInfo(); Guid dynamicFolderTypeId = new Guid("65CA0946-0084-4874-B117-C13199AF3B95"); if (folderInfo == null || DBNull.Value.Equals(folderInfo[0]) || !folderInfo.Length.Equals(2) || !(new Guid(folderInfo[0].ToString())).Equals(dynamicFolderTypeId)) { var folderEntitySchema = dataSource.Schema; SetDetailFilter.FilterName = "FolderFilter"; SetDetailFilter.FilterLeftExpressions = new string[] { "SysFolder" }; SetDetailFilter.FilterRightValue = FolderId; var oldDataSourceFolderFilter = dataSource.CurrentStructure.Filters.FindByName("FolderFilter"); if (oldDataSourceFolderFilter != null) { dataSource.CurrentStructure.Filters.Remove(oldDataSourceFolderFilter); } var filter = SetDetailFilter.CreateFilter(dataSource, Guid.Empty, null); dataSource.CurrentStructure.Filters.Add(filter); } } if (IsRootFolder) { var oldDataSourceFolderFilter = dataSource.CurrentStructure.Filters.FindByName("FolderFilter"); if (oldDataSourceFolderFilter != null) { dataSource.CurrentStructure.Filters.Remove(oldDataSourceFolderFilter); } } pageInstance.Process.SetPropertyValue("SelectedFolderId", FolderId); var primaryColumnName = dataSource.Schema.PrimaryColumn.Name; var structure = dataSource.CurrentStructure; Terrasoft.UI.WebControls.Controls.DataSourceFilterCollection filters = null; string codeName = "CustomSettingsFilter"; var enableContextHelpSysSettingUId = new Guid("D4DF3F32-F46B-1410-D696-485B39C17F9B"); var oldFilters = structure.Filters.FindByName(codeName); if (oldFilters != null) { structure.Filters.Remove(oldFilters); } filters = structure.CreateFiltersGroup(codeName, LogicalOperationStrict.And); filters.Add(structure.CreateFilterWithParameters(dataSource.Schema, Terrasoft.Core.Entities.FilterComparisonType.NotEqual, primaryColumnName, enableContextHelpSysSettingUId)); filters.Add(structure.CreateFilterWithParameters(dataSource.Schema, Terrasoft.Core.Entities.FilterComparisonType.Equal, "IsPersonal", new object[] { false })); structure.Filters.Add(filters); }
public virtual CheckMenuItem CreateViewMenuItem(string viewCode, string viewCaption, Guid viewId) { var item = new CheckMenuItem(); item.Checked = false; item.Group = "ViewFilter"; item.UId = viewId; item.Tag = viewCode; item.Name = "viewMenuItem_" + viewId.ToString("N") + item.Tag; item.Caption = viewCaption; item.AjaxEvents.CheckChange.Event += delegate(object sender, Terrasoft.UI.WebControls.Controls.AjaxEventArgs e){ var menuItem = sender as Terrasoft.UI.WebControls.Controls.CheckMenuItem; if (!menuItem.Checked) { return; } var tabItem = menuItem.Parent as Tab; if (tabItem.Items.Count == 0) { return; } var filterCode = (sender as Terrasoft.UI.WebControls.Controls.CheckMenuItem).Tag; ((TabPanel)tabItem.Parent).SetActiveTab(tabItem); var container = tabItem.Items[0] as PageContainer; if (container != null && container.PageInstance != null) { var dataSource = container.FindPageControlByName("DataSource") as DataSource; if (dataSource == null) { return; } Terrasoft.UI.WebControls.Controls.DataSourceFilterCollection filters = null; var viewFilters = dataSource.FindFiltersGroupByName("ViewFilters"); if (viewFilters != null) { foreach (var filterItem in viewFilters) { filterItem.IsEnabled = filterItem.Name == filterCode; } container.PageInstance.ThrowEvent("ClearData"); dataSource.LoadRows(); } } }; return(item); }
public virtual void SetFilter(Terrasoft.UI.WebControls.PageSchemaUserControl pageInstance, Terrasoft.UI.WebControls.Controls.DataSourceFilterCollection filter) { pageInstance.Process.SetPropertyValue(DetailPageFilterName, filter); }