private void BindTemplates() { int projectId = CommonHelper.GetProjectIdByObjectIdObjectType(OwnerId, OwnerTypeId); FilterElementCollection filters = new FilterElementCollection(); filters.Add(FilterElement.EqualElement(WorkflowDefinitionEntity.FieldSupportedIbnObjectTypes, OwnerTypeId)); if (projectId > 0) { // O.R. [2010-02-03]: Allow to select non-project templates for a project OrBlockFilterElement orBlock = new OrBlockFilterElement(); orBlock.ChildElements.Add(FilterElement.EqualElement(WorkflowDefinitionEntity.FieldProjectId, projectId)); orBlock.ChildElements.Add(FilterElement.IsNullElement(WorkflowDefinitionEntity.FieldProjectId)); filters.Add(orBlock); } else { filters.Add(FilterElement.IsNullElement(WorkflowDefinitionEntity.FieldProjectId)); } if (TeplateGroupList.Items.Count > 0) { filters.Add(FilterElement.EqualElement(WorkflowDefinitionEntity.FieldTemplateGroup, int.Parse(TeplateGroupList.SelectedValue))); } TemplateList.Items.Clear(); foreach (WorkflowDefinitionEntity entity in BusinessManager.List(WorkflowDefinitionEntity.ClassName, filters.ToArray())) { TemplateList.Items.Add(new ListItem(entity.Name, entity.PrimaryKeyId.Value.ToString())); } }
/// <summary> /// Deletes the navigation item. /// </summary> /// <param name="fullId">The full id.</param> /// <param name="profileId">The profile id.</param> /// <param name="principalId">The principal id.</param> public static void DeleteNavigationItem(string fullId, PrimaryKeyId?profileId, PrimaryKeyId?principalId) { FilterElementCollection filters = new FilterElementCollection(); filters.Add(new FilterElement(CustomizationItemEntity.FieldXmlFullId, FilterElementType.Like, fullId + "%")); filters.Add(FilterElement.EqualElement(CustomizationItemEntity.FieldStructureType, (int)CustomizationStructureType.NavigationMenu)); filters.Add(FilterElement.EqualElement(CustomizationItemEntity.FieldCommandType, (int)ItemCommandType.Add)); // delete user level only if (principalId.HasValue) { filters.Add(FilterElement.EqualElement(CustomizationItemEntity.FieldPrincipalId, principalId.Value)); } // delete profile and user level else if (profileId.HasValue) { OrBlockFilterElement block = new OrBlockFilterElement(); block.ChildElements.Add(FilterElement.EqualElement(CustomizationItemEntity.FieldProfileId, profileId.Value)); block.ChildElements.Add(FilterElement.IsNotNullElement(CustomizationItemEntity.FieldPrincipalId)); filters.Add(block); } // else delete all - we don't use filter in that case using (TransactionScope transaction = DataContext.Current.BeginTransaction()) { foreach (EntityObject item in BusinessManager.List(CustomizationItemEntity.ClassName, filters.ToArray())) { BusinessManager.Delete(item); } transaction.Commit(); } ClearCache(profileId, principalId); }
public override void DataBind() { if (DataItem != null) { CalendarEventEntity ceo = (CalendarEventEntity)DataItem; FilterElementCollection fec = new FilterElementCollection(); FilterElement fe = FilterElement.EqualElement("EventId", ((VirtualEventId)ceo.PrimaryKeyId).RealEventId); fec.Add(fe); fe = FilterElement.EqualElement("PrincipalId", Mediachase.IBN.Business.Security.CurrentUser.UserID); fec.Add(fe); EntityObject[] list = BusinessManager.List(CalendarEventResourceEntity.ClassName, fec.ToArray()); if (list.Length > 0) { CalendarEventResourceEntity cero = (CalendarEventResourceEntity)list[0]; _resId = cero.PrimaryKeyId.Value; if (cero.Status.HasValue) { if (cero.Status.Value == (int)eResourceStatus.Accepted) { btnAccept.Disabled = true; } if (cero.Status.Value == (int)eResourceStatus.Tentative) { btnTentative.Disabled = true; } if (cero.Status.Value == (int)eResourceStatus.Declined) { btnDecline.Disabled = true; } } } } base.DataBind(); }
/// <summary> /// Resets the custom page. /// </summary> /// <param name="uid">The page uid.</param> /// <param name="profileId">The profile id.</param> /// <param name="userId">The user id.</param> public static void ResetCustomPage(Guid uid, int?profileId, int?userId) { FilterElementCollection filters = new FilterElementCollection(); filters.Add(FilterElement.EqualElement(CustomPageEntity.FieldUid, uid)); if (userId.HasValue) // User layer { filters.Add(FilterElement.EqualElement(CustomPageEntity.FieldUserId, userId.Value)); } else if (profileId.HasValue) // Profile layer { filters.Add(FilterElement.EqualElement(CustomPageEntity.FieldProfileId, profileId.Value)); } else // Site layer { filters.Add(FilterElement.IsNullElement(CustomPageEntity.FieldProfileId)); filters.Add(FilterElement.IsNullElement(CustomPageEntity.FieldUserId)); } foreach (CustomPageEntity page in BusinessManager.List(CustomPageEntity.ClassName, filters.ToArray())) { if (!page.Properties.Contains(LocalDiskEntityObjectPlugin.IsLoadDiskEntityPropertyName)) { BusinessManager.Delete(page); } } }
public override void DataBind() { if (DataItem != null) { CalendarEventEntity ceo = (CalendarEventEntity)DataItem; FilterElementCollection fec = new FilterElementCollection(); FilterElement fe = FilterElement.EqualElement("EventId", ((VirtualEventId)ceo.PrimaryKeyId).RealEventId); fec.Add(fe); fe = FilterElement.EqualElement("PrincipalId", Mediachase.IBN.Business.Security.CurrentUser.UserID); fec.Add(fe); EntityObject[] list = BusinessManager.List(CalendarEventResourceEntity.ClassName, fec.ToArray()); if (list.Length > 0) { CalendarEventResourceEntity cero = (CalendarEventResourceEntity)list[0]; _resId = cero.PrimaryKeyId.Value; if (cero.Status.HasValue) { if (cero.Status.Value == (int)eResourceStatus.Accepted) btnAccept.Disabled = true; if (cero.Status.Value == (int)eResourceStatus.Tentative) btnTentative.Disabled = true; if (cero.Status.Value == (int)eResourceStatus.Declined) btnDecline.Disabled = true; } } } base.DataBind(); }
protected void Page_Load(object sender, EventArgs e) { if (_classes.Count <= 0) { throw new Exception("Classes is required!"); } ddFilter.SelectedIndexChanged += new EventHandler(ddFilter_SelectedIndexChanged); if (!IsPostBack) { BindDropDowns(); btnNew.Visible = _isCanCreate; tblSelect.Visible = true; tblNew.Visible = false; } grdMain.ClassName = ddFilter.SelectedValue; grdMain.ViewName = ""; grdMain.PlaceName = _placeName; grdMain.ProfileName = ProfileName; grdMain.ShowCheckboxes = _isMultipleSelect; FilterElementCollection fec = new FilterElementCollection(); if (!String.IsNullOrEmpty(Request["filterName"]) && !String.IsNullOrEmpty(Request["filterValue"])) { FilterElement fe = FilterElement.EqualElement(Request["filterName"], Request["filterValue"]); FilterElement fe1 = FilterElement.IsNullElement(Request["filterName"]); FilterElement feOr = new OrBlockFilterElement(); feOr.ChildElements.Add(fe); feOr.ChildElements.Add(fe1); fec.Add(feOr); } else if (!String.IsNullOrEmpty(Request["filterName"]) && String.IsNullOrEmpty(Request["filterValue"])) { FilterElement fe = FilterElement.IsNullElement(Request["filterName"]); fec.Add(fe); } if (TreeServiceTargetObjectId != PrimaryKeyId.Empty) { FilterElement fe = new FilterElement(Mediachase.Ibn.Data.Services.TreeService.OutlineNumberFieldName, FilterElementType.NotContains, TreeServiceTargetObjectId.ToString().ToLower()); fec.Add(fe); } grdMain.AddFilters = fec; ctrlGridEventUpdater.ClassName = ddFilter.SelectedValue; ctrlGridEventUpdater.ViewName = ""; ctrlGridEventUpdater.PlaceName = _placeName; ctrlGridEventUpdater.GridId = grdMain.GridClientContainerId; ctrlGridEventUpdater.GridActionMode = Mediachase.UI.Web.Apps.MetaUI.Grid.MetaGridServerEventAction.Mode.ListViewUI; //ddFilter.Visible = (_classes.Count > 1); BindDataGrid(!Page.IsPostBack); BindButtons(); }
private FilterElementCollection GetFilters() { FilterElementCollection coll = new FilterElementCollection(); if (!String.IsNullOrEmpty(ClassName)) { if (ObjectId == null) { throw new ArgumentNullException("QueryString:ObjectId"); } //Profile level if (String.Compare(ClassName, CustomizationProfileEntity.ClassName, true) == 0) { // ProfileId is null OR ProfileId = value OrBlockFilterElement orBlock = new OrBlockFilterElement(); orBlock.ChildElements.Add(FilterElement.IsNullElement(CustomPageEntity.FieldProfileId)); orBlock.ChildElements.Add(FilterElement.EqualElement(CustomPageEntity.FieldProfileId, ObjectId)); coll.Add(orBlock); coll.Add(FilterElement.IsNullElement(CustomPageEntity.FieldUserId)); } //User level if (String.Compare(ClassName, "Principal", true) == 0) { int profileId = ProfileManager.GetProfileIdByUser(); // ProfileId is null AND UserId is null AndBlockFilterElement andBlock1 = new AndBlockFilterElement(); andBlock1.ChildElements.Add(FilterElement.IsNullElement(CustomPageEntity.FieldProfileId)); andBlock1.ChildElements.Add(FilterElement.IsNullElement(CustomPageEntity.FieldUserId)); // ProfileId = value AND UserId is null AndBlockFilterElement andBlock2 = new AndBlockFilterElement(); andBlock2.ChildElements.Add(FilterElement.EqualElement(CustomPageEntity.FieldProfileId, profileId)); andBlock2.ChildElements.Add(FilterElement.IsNullElement(CustomPageEntity.FieldUserId)); // ProfileId is null AND UserId = value AndBlockFilterElement andBlock3 = new AndBlockFilterElement(); andBlock3.ChildElements.Add(FilterElement.IsNullElement(CustomPageEntity.FieldProfileId)); andBlock3.ChildElements.Add(FilterElement.EqualElement(CustomPageEntity.FieldUserId, ObjectId)); OrBlockFilterElement orBlock = new OrBlockFilterElement(); orBlock.ChildElements.Add(andBlock1); orBlock.ChildElements.Add(andBlock2); orBlock.ChildElements.Add(andBlock3); coll.Add(orBlock); } } else { //Site level coll.Add(FilterElement.IsNullElement(CustomPageEntity.FieldProfileId)); coll.Add(FilterElement.IsNullElement(CustomPageEntity.FieldUserId)); } return(coll); }
/// <summary> /// Resets the user settings by profile. /// </summary> /// <param name="uid">The page uid.</param> /// <param name="profileId">The profile id.</param> public static void ResetUserSettingsByProfile(Guid uid, int profileId) { List <string> users = new List <string>(); if (profileId > 0) { FilterElementCollection fec = new FilterElementCollection(); fec.Add(FilterElement.EqualElement(CustomizationProfileUserEntity.FieldProfileId, profileId)); foreach (CustomizationProfileUserEntity entity in BusinessManager.List(CustomizationProfileUserEntity.ClassName, fec.ToArray())) { users.Add(entity.PrincipalId.ToString()); } } else // default profile { // 1. Get list all users using (IDataReader reader = Mediachase.IBN.Business.User.GetListAll()) { while (reader.Read()) { users.Add(reader["UserId"].ToString()); } } // 2. Exclude users with non-default profile EntityObject[] entityList = BusinessManager.List(CustomizationProfileUserEntity.ClassName, (new FilterElementCollection()).ToArray()); foreach (CustomizationProfileUserEntity puEntity in entityList) { users.Remove(puEntity.PrincipalId.ToString()); } } // O.R. [2010-10-05]. Don't process profile without users if (users.Count > 0) { // Remove CustomPages for all users in Profile FilterElementCollection filters = new FilterElementCollection(); filters.Add(FilterElement.EqualElement(CustomPageEntity.FieldUid, uid)); OrBlockFilterElement orBlock = new OrBlockFilterElement(); foreach (string userId in users) { orBlock.ChildElements.Add(FilterElement.EqualElement(CustomPageEntity.FieldUserId, userId)); } filters.Add(orBlock); // Skip CustomPageNormalizationPlugin ListRequest request = new ListRequest(CustomPageEntity.ClassName, filters.ToArray()); request.Parameters.Add("CustomPageNormalizationPlugin", false); ListResponse response = (ListResponse)BusinessManager.Execute(request); foreach (EntityObject page in response.EntityObjects) { BusinessManager.Delete(page); } } }
private FilterElementCollection GetFilters() { FilterElementCollection coll = new FilterElementCollection(); if (!String.IsNullOrEmpty(ClassName)) { if (ObjectId == null) throw new ArgumentNullException("QueryString:ObjectId"); //Profile level if (String.Compare(ClassName, CustomizationProfileEntity.ClassName, true) == 0) { // ProfileId is null OR ProfileId = value OrBlockFilterElement orBlock = new OrBlockFilterElement(); orBlock.ChildElements.Add(FilterElement.IsNullElement(CustomPageEntity.FieldProfileId)); orBlock.ChildElements.Add(FilterElement.EqualElement(CustomPageEntity.FieldProfileId, ObjectId)); coll.Add(orBlock); coll.Add(FilterElement.IsNullElement(CustomPageEntity.FieldUserId)); } //User level if (String.Compare(ClassName, "Principal", true) == 0) { int profileId = ProfileManager.GetProfileIdByUser(); // ProfileId is null AND UserId is null AndBlockFilterElement andBlock1 = new AndBlockFilterElement(); andBlock1.ChildElements.Add(FilterElement.IsNullElement(CustomPageEntity.FieldProfileId)); andBlock1.ChildElements.Add(FilterElement.IsNullElement(CustomPageEntity.FieldUserId)); // ProfileId = value AND UserId is null AndBlockFilterElement andBlock2 = new AndBlockFilterElement(); andBlock2.ChildElements.Add(FilterElement.EqualElement(CustomPageEntity.FieldProfileId, profileId)); andBlock2.ChildElements.Add(FilterElement.IsNullElement(CustomPageEntity.FieldUserId)); // ProfileId is null AND UserId = value AndBlockFilterElement andBlock3 = new AndBlockFilterElement(); andBlock3.ChildElements.Add(FilterElement.IsNullElement(CustomPageEntity.FieldProfileId)); andBlock3.ChildElements.Add(FilterElement.EqualElement(CustomPageEntity.FieldUserId, ObjectId)); OrBlockFilterElement orBlock = new OrBlockFilterElement(); orBlock.ChildElements.Add(andBlock1); orBlock.ChildElements.Add(andBlock2); orBlock.ChildElements.Add(andBlock3); coll.Add(orBlock); } } else { //Site level coll.Add(FilterElement.IsNullElement(CustomPageEntity.FieldProfileId)); coll.Add(FilterElement.IsNullElement(CustomPageEntity.FieldUserId)); } return coll; }
/// <summary> /// Gets the files. /// </summary> /// <param name="structureName">Name of the structure.</param> /// <param name="searchPattern">The search pattern.</param> /// <param name="selectors">The selectors (4st argument - profileId, 5nd argument - principalId).</param> /// <returns></returns> public override FileDescriptor[] GetFiles(string structureName, string searchPattern, Selector[] selectors) { List <FileDescriptor> files = new List <FileDescriptor>(); if (string.Compare(structureName, "Navigation", StringComparison.OrdinalIgnoreCase) == 0 && string.Compare(searchPattern, "*.xml", StringComparison.OrdinalIgnoreCase) == 0) { FilterElementCollection filters; EntityObject[] items; PrimaryKeyId profileId = PrimaryKeyId.Empty; PrimaryKeyId principalId = PrimaryKeyId.Empty; // 1. Global Layer filters = new FilterElementCollection(); filters.Add(FilterElement.EqualElement(CustomizationItemEntity.FieldStructureType, (int)CustomizationStructureType.NavigationMenu)); filters.Add(FilterElement.IsNullElement(CustomizationItemEntity.FieldProfileId)); filters.Add(FilterElement.IsNullElement(CustomizationItemEntity.FieldPrincipalId)); items = BusinessManager.List(CustomizationItemEntity.ClassName, filters.ToArray()); ProcessItems(items, files, NavigationManager.CustomizationLayerGlobal); // 2. Profile Layer if (selectors != null && selectors.Length != 0 && selectors[0].Items.Count > 3 && !string.IsNullOrEmpty(selectors[0].Items[3])) { string profileSelector = selectors[0].Items[3]; if (PrimaryKeyId.TryParse(profileSelector, out profileId)) { filters = new FilterElementCollection(); filters.Add(FilterElement.EqualElement(CustomizationItemEntity.FieldStructureType, (int)CustomizationStructureType.NavigationMenu)); filters.Add(FilterElement.EqualElement(CustomizationItemEntity.FieldProfileId, profileId)); filters.Add(FilterElement.IsNullElement(CustomizationItemEntity.FieldPrincipalId)); items = BusinessManager.List(CustomizationItemEntity.ClassName, filters.ToArray()); ProcessItems(items, files, NavigationManager.CustomizationLayerProfile); } } // 3. User Layer if (selectors != null && selectors.Length != 0 && selectors[0].Items.Count > 4 && !string.IsNullOrEmpty(selectors[0].Items[4])) { string principalSelector = selectors[0].Items[4]; if (PrimaryKeyId.TryParse(principalSelector, out principalId)) { filters = new FilterElementCollection(); filters.Add(FilterElement.EqualElement(CustomizationItemEntity.FieldStructureType, (int)CustomizationStructureType.NavigationMenu)); filters.Add(FilterElement.IsNullElement(CustomizationItemEntity.FieldProfileId)); filters.Add(FilterElement.EqualElement(CustomizationItemEntity.FieldPrincipalId, principalId)); items = BusinessManager.List(CustomizationItemEntity.ClassName, filters.ToArray()); ProcessItems(items, files, NavigationManager.CustomizationLayerUser); } } } return(files.ToArray()); }
/// <summary> /// Gets the files. /// </summary> /// <param name="structureName">Name of the structure.</param> /// <param name="searchPattern">The search pattern.</param> /// <param name="selectors">The selectors (4st argument - profileId, 5nd argument - principalId).</param> /// <returns></returns> public override FileDescriptor[] GetFiles(string structureName, string searchPattern, Selector[] selectors) { List<FileDescriptor> files = new List<FileDescriptor>(); if (string.Compare(structureName, "Navigation", StringComparison.OrdinalIgnoreCase) == 0 && string.Compare(searchPattern, "*.xml", StringComparison.OrdinalIgnoreCase) == 0) { FilterElementCollection filters; EntityObject[] items; PrimaryKeyId profileId = PrimaryKeyId.Empty; PrimaryKeyId principalId = PrimaryKeyId.Empty; // 1. Global Layer filters = new FilterElementCollection(); filters.Add(FilterElement.EqualElement(CustomizationItemEntity.FieldStructureType, (int)CustomizationStructureType.NavigationMenu)); filters.Add(FilterElement.IsNullElement(CustomizationItemEntity.FieldProfileId)); filters.Add(FilterElement.IsNullElement(CustomizationItemEntity.FieldPrincipalId)); items = BusinessManager.List(CustomizationItemEntity.ClassName, filters.ToArray()); ProcessItems(items, files, NavigationManager.CustomizationLayerGlobal); // 2. Profile Layer if (selectors != null && selectors.Length != 0 && selectors[0].Items.Count > 3 && !string.IsNullOrEmpty(selectors[0].Items[3])) { string profileSelector = selectors[0].Items[3]; if (PrimaryKeyId.TryParse(profileSelector, out profileId)) { filters = new FilterElementCollection(); filters.Add(FilterElement.EqualElement(CustomizationItemEntity.FieldStructureType, (int)CustomizationStructureType.NavigationMenu)); filters.Add(FilterElement.EqualElement(CustomizationItemEntity.FieldProfileId, profileId)); filters.Add(FilterElement.IsNullElement(CustomizationItemEntity.FieldPrincipalId)); items = BusinessManager.List(CustomizationItemEntity.ClassName, filters.ToArray()); ProcessItems(items, files, NavigationManager.CustomizationLayerProfile); } } // 3. User Layer if (selectors != null && selectors.Length != 0 && selectors[0].Items.Count > 4 && !string.IsNullOrEmpty(selectors[0].Items[4])) { string principalSelector = selectors[0].Items[4]; if (PrimaryKeyId.TryParse(principalSelector, out principalId)) { filters = new FilterElementCollection(); filters.Add(FilterElement.EqualElement(CustomizationItemEntity.FieldStructureType, (int)CustomizationStructureType.NavigationMenu)); filters.Add(FilterElement.IsNullElement(CustomizationItemEntity.FieldProfileId)); filters.Add(FilterElement.EqualElement(CustomizationItemEntity.FieldPrincipalId, principalId)); items = BusinessManager.List(CustomizationItemEntity.ClassName, filters.ToArray()); ProcessItems(items, files, NavigationManager.CustomizationLayerUser); } } } return files.ToArray(); }
public bool IsEnable(object Sender, object Element) { bool retval = false; if (HttpContext.Current.Items.Contains("OwnerTypeId") && HttpContext.Current.Items.Contains("OwnerId")) { int ownerTypeId = (int)HttpContext.Current.Items["OwnerTypeId"]; int ownerId = (int)HttpContext.Current.Items["OwnerId"]; bool canUpdate = false; if (ownerTypeId == (int)ObjectTypes.Document) { canUpdate = Document.CanUpdate(ownerId); } else if (ownerTypeId == (int)ObjectTypes.Task) { canUpdate = Task.CanUpdate(ownerId); } else if (ownerTypeId == (int)ObjectTypes.ToDo) { canUpdate = ToDo.CanUpdate(ownerId); } else if (ownerTypeId == (int)ObjectTypes.Issue) { canUpdate = Incident.CanUpdate(ownerId); } if (canUpdate) { int projectId = CommonHelper.GetProjectIdByObjectIdObjectType(ownerId, ownerTypeId); FilterElementCollection filters = new FilterElementCollection(); filters.Add(FilterElement.EqualElement(WorkflowDefinitionEntity.FieldSupportedIbnObjectTypes, ownerTypeId)); if (projectId > 0) { // O.R. [2010-02-03]: Allow to select non-project templates for a project OrBlockFilterElement orBlock = new OrBlockFilterElement(); orBlock.ChildElements.Add(FilterElement.EqualElement(WorkflowDefinitionEntity.FieldProjectId, projectId)); orBlock.ChildElements.Add(FilterElement.IsNullElement(WorkflowDefinitionEntity.FieldProjectId)); filters.Add(orBlock); } else { filters.Add(FilterElement.IsNullElement(WorkflowDefinitionEntity.FieldProjectId)); } EntityObject[] items = BusinessManager.List(WorkflowDefinitionEntity.ClassName, filters.ToArray()); if (items != null && items.Length > 0) { retval = true; } } } return(retval); }
public void Invoke(object Sender, object Element) { if (Element is CommandParameters) { CommandParameters cp = (CommandParameters)Element; string[] selectedElements = EntityGrid.GetCheckedCollection(((CommandManager)Sender).Page, cp.CommandArguments["GridId"]); if (selectedElements != null && selectedElements.Length > 0) { int errorCount = 0; string bridgeClassName = CHelper.GetFromContext("ReferenceNN_BridgeClassName").ToString(); string field1Name = CHelper.GetFromContext("ReferenceNN_Field1Name").ToString(); string field2Name = CHelper.GetFromContext("ReferenceNN_Field2Name").ToString(); PrimaryKeyId field1Value = PrimaryKeyId.Parse(CHelper.GetFromContext("ReferenceNN_Field1Value").ToString()); using (TransactionScope tran = DataContext.Current.BeginTransaction()) { foreach (string elem in selectedElements) { string[] parts = elem.Split(new string[] { "::" }, StringSplitOptions.RemoveEmptyEntries); string id = parts[0]; PrimaryKeyId key = PrimaryKeyId.Parse(id); string className = parts[1]; FilterElementCollection fec = new FilterElementCollection(); fec.Add(FilterElement.EqualElement(field1Name, field1Value)); fec.Add(FilterElement.EqualElement(field2Name, key)); EntityObject[] list = BusinessManager.List(bridgeClassName, fec.ToArray()); if (list.Length > 0) { foreach (EntityObject eo in list) { try { BusinessManager.Delete(bridgeClassName, eo.PrimaryKeyId.Value); } catch (Exception ex) { CHelper.GenerateErrorReport(ex); errorCount++; } } } } tran.Commit(); } if (errorCount > 0) { ((CommandManager)Sender).InfoMessage = CHelper.GetResFileString("{IbnFramework.Common:NotAllSelectedItemsWereProcessed}"); } } } CHelper.RequireDataBind(); }
/// <summary> /// Gets the custom page. /// </summary> /// <param name="uid">The page uid.</param> /// <param name="profileId">The profile id.</param> /// <param name="userId">The user id.</param> /// <returns></returns> public static CustomPageEntity GetCustomPage(Guid uid, int? profileId, int? userId) { FilterElementCollection filters = new FilterElementCollection(); filters.Add(FilterElement.EqualElement(CustomPageEntity.FieldUid, uid)); if (userId.HasValue) // User layer { if (!profileId.HasValue) profileId = ProfileManager.GetProfileIdByUser(userId.Value); // ProfileId is null AND UserId is null AndBlockFilterElement andBlock1 = new AndBlockFilterElement(); andBlock1.ChildElements.Add(FilterElement.IsNullElement(CustomPageEntity.FieldProfileId)); andBlock1.ChildElements.Add(FilterElement.IsNullElement(CustomPageEntity.FieldUserId)); // ProfileId = value AND UserId is null AndBlockFilterElement andBlock2 = new AndBlockFilterElement(); andBlock2.ChildElements.Add(FilterElement.EqualElement(CustomPageEntity.FieldProfileId, profileId.Value)); andBlock2.ChildElements.Add(FilterElement.IsNullElement(CustomPageEntity.FieldUserId)); // ProfileId is null AND UserId = value AndBlockFilterElement andBlock3 = new AndBlockFilterElement(); andBlock3.ChildElements.Add(FilterElement.IsNullElement(CustomPageEntity.FieldProfileId)); andBlock3.ChildElements.Add(FilterElement.EqualElement(CustomPageEntity.FieldUserId, userId.Value)); OrBlockFilterElement orBlock = new OrBlockFilterElement(); orBlock.ChildElements.Add(andBlock1); orBlock.ChildElements.Add(andBlock2); orBlock.ChildElements.Add(andBlock3); filters.Add(orBlock); } else if (profileId.HasValue) // Profile layer { filters.Add(FilterElement.IsNullElement(CustomPageEntity.FieldUserId)); OrBlockFilterElement orBlock = new OrBlockFilterElement(); orBlock.ChildElements.Add(FilterElement.EqualElement(CustomPageEntity.FieldProfileId, profileId.Value)); orBlock.ChildElements.Add(FilterElement.IsNullElement(CustomPageEntity.FieldProfileId)); filters.Add(orBlock); } else // Site layer { filters.Add(FilterElement.IsNullElement(CustomPageEntity.FieldProfileId)); filters.Add(FilterElement.IsNullElement(CustomPageEntity.FieldUserId)); } EntityObject[] pages = BusinessManager.List(CustomPageEntity.ClassName, filters.ToArray()); CustomPageEntity retval = null; if (pages.Length > 0) retval = (CustomPageEntity)pages[0]; return retval; }
public override void DataBind() { DataTable dt = new DataTable(); dt.Locale = CultureInfo.InvariantCulture; dt.Columns.Add("AssignmentId", typeof(string)); dt.Columns.Add("Subject", typeof(string)); dt.Columns.Add("User", typeof(string)); dt.Columns.Add("State", typeof(string)); dt.Columns.Add("Result", typeof(int)); dt.Columns.Add("FinishDate", typeof(string)); dt.Columns.Add("Comment", typeof(string)); dt.Columns.Add("Indent", typeof(int)); dt.Columns.Add("ClosedBy", typeof(string)); WorkflowInstanceEntity wfEntity = (WorkflowInstanceEntity)DataItem; // Filter: // 1: WorkflowInstanceId = wfEntity.PrimaryKeyId, // 2: ParentAssignmentId IS NULL (other elements we'll get via the recursion) FilterElementCollection fec = new FilterElementCollection(); fec.Add(FilterElement.EqualElement(AssignmentEntity.FieldWorkflowInstanceId, wfEntity.PrimaryKeyId.Value)); fec.Add(FilterElement.IsNullElement(AssignmentEntity.FieldParentAssignmentId)); // Sorting SortingElementCollection sec = new SortingElementCollection(); sec.Add(new SortingElement(AssignmentEntity.FieldCreated, SortingElementType.Asc)); EntityObject[] assignments = BusinessManager.List(AssignmentEntity.ClassName, fec.ToArray(), sec.ToArray()); ProcessCollection(dt, assignments, wfEntity, 0); AssignmentList.DataSource = dt; AssignmentList.DataBind(); if (dt.Rows.Count > 0) { AssignmentList.Visible = true; NoAssignmentsLabel.Visible = false; } else { AssignmentList.Visible = false; NoAssignmentsLabel.Visible = true; NoAssignmentsLabel.Text = GetGlobalResourceObject("IbnFramework.BusinessProcess", "NoAssignments").ToString(); } }
private void BindDataGrid(bool dataBind) { grdMain.SearchKeyword = tbSearchString.Text.Trim(); DataTable dt = ((DataTable)ViewState["Resources"]).Copy(); FilterElementCollection fec = new FilterElementCollection(); foreach (DataRow dr in dt.Rows) { string[] elem = dr["Id"].ToString().Split(new string[] { "::" }, StringSplitOptions.RemoveEmptyEntries); if (elem[1] != "0") { MetaClass mcEl = MetaDataWrapper.GetMetaClassByName(elem[1]); if (mcEl.IsCard) { elem[1] = mcEl.CardOwner.Name; } } if (elem[1] == ddFilter.SelectedValue) { MetaClass mc = MetaDataWrapper.GetMetaClassByName(ddFilter.SelectedValue); FilterElement fe = FilterElement.NotEqualElement( SqlContext.Current.Database.Tables[mc.DataSource.PrimaryTable].PrimaryKey.Name, PrimaryKeyId.Parse(elem[0])); fec.Add(fe); } } grdMain.AddFilters = fec; if (dataBind) { grdMain.DataBind(); } }
private void BindDataGrid(bool dataBind) { _isFilterSet = false; _filterText = String.Empty; //добавляем к фильтру выбраное значение из левой панели, если включена группировка #region GroupItem if (_isGroupSet) { string groupCurrent = lvp.GroupByFieldName; if (!String.IsNullOrEmpty(groupCurrent) && mc.Fields.Contains(groupCurrent) && groupList.Items.Count > 0 && groupList.SelectedValue != null) { FilterElementCollection fec = new FilterElementCollection(); fec.Add(FilterElement.EqualElement(groupCurrent, groupList.SelectedValue)); grdMain.AddFilters = fec; } } #endregion grdMain.SearchKeyword = txtSearch.Text; if (dataBind) { grdMain.DataBind(); } }
/// <summary> /// Reads the right check. /// </summary> /// <param name="context">The context.</param> private void ReadRightCheck(BusinessContext context) { //Если есть флаг отключить проверку авторизации то ничего не фильтруем if (!SkipSecurityCheckScope.IsActive) { string securityViewQuery = @"SELECT ObjectId FROM [dbo].[CalendarEvent_Security_Read]"; //Добавляем в sql context текущего пользователя SetContextInfo(Security.CurrentUserId); //Для метода List необходимо отфильтровать список согласно security view if (context.GetMethod() == RequestMethod.List) { ListRequest listRequest = context.Request as ListRequest; FilterElementCollection filterColl = new FilterElementCollection(); foreach (FilterElement origFilterEl in listRequest.Filters) { filterColl.Add(origFilterEl); } FilterElement filterEl = new FilterElement("PrimaryKeyId", FilterElementType.In, securityViewQuery); filterColl.Add(filterEl); //перезаписываем старую коллекцию фильтров, новой listRequest.Filters = filterColl.ToArray(); }//Для метода Load необходмио предотвратить загрузку объета не имеющего соотв прав else if (context.GetMethod() == RequestMethod.Load) { LoadRequest loadRequest = context.Request as LoadRequest; PrimaryKeyId eventId = loadRequest.Target.PrimaryKeyId.Value; VirtualEventId vEventId = (VirtualEventId)eventId; if (vEventId.IsRecurrence) { eventId = vEventId.RealEventId; } if (BusinessObject.GetTotalCount(DataContext.Current.GetMetaClass(CalendarEventEntity.ClassName), new FilterElement[] { new FilterElement("PrimaryKeyId", FilterElementType.Equal, eventId), new FilterElement("PrimaryKeyId", FilterElementType.In, securityViewQuery) }) == 0) { throw new Exception("Read access denied"); } } } }
/// <summary> /// Gens the source. /// </summary> /// <param name="text">The text.</param> /// <param name="totalCount">The total count.</param> /// <returns></returns> private DataTable genSource(string text, out int totalCount) { DataTable dt = new DataTable(); dt.Locale = CultureInfo.InvariantCulture; dt.Columns.Add(new DataColumn("PrimaryKeyId", typeof(int))); dt.Columns.Add(new DataColumn(TitleFieldName, typeof(string))); MetaClass mc = MetaDataWrapper.ResolveMetaClassByNameOrCardName(ClassName); FilterElementCollection fec = new FilterElementCollection(); fec.Add(new FilterElement(mc.TitleFieldName, FilterElementType.Contains, text)); if (!String.IsNullOrEmpty(CardFilter)) { string[] mas = CardFilter.Split(new string[] { "," }, StringSplitOptions.RemoveEmptyEntries); if (mas.Length > 0) { OrBlockFilterElement fe = new OrBlockFilterElement(); foreach (string sCard in mas) { fe.ChildElements.Add(FilterElement.EqualElement("Card", sCard.Trim())); } fec.Add(fe); } } MetaObject[] list = MetaObject.List(mc, fec, new SortingElementCollection(SortingElement.Ascending(mc.TitleFieldName))); int count = 0; foreach (MetaObject bo in list) { DataRow row = dt.NewRow(); row["PrimaryKeyId"] = bo.PrimaryKeyId; row[TitleFieldName] = bo.Properties[mc.TitleFieldName].Value.ToString(); dt.Rows.Add(row); count++; if (count > 10) { break; } } totalCount = list.Length; return(dt); }
private void ProcessCollection(DataTable dt, EntityObject[] assignments, WorkflowInstanceEntity wfEntity, int level) { level++; foreach (AssignmentEntity assignment in assignments) { DataRow row = dt.NewRow(); row["AssignmentId"] = assignment.PrimaryKeyId.ToString(); row["Subject"] = assignment.Subject; if (assignment.UserId.HasValue) { row["User"] = CommonHelper.GetUserStatus(assignment.UserId.Value); } row["State"] = CHelper.GetResFileString(MetaEnum.GetFriendlyName(MetaDataWrapper.GetEnumByName("AssignmentState"), assignment.State)); if (assignment.ExecutionResult.HasValue) { row["Result"] = assignment.ExecutionResult.Value; } if (assignment.ActualFinishDate.HasValue) { row["FinishDate"] = String.Concat(assignment.ActualFinishDate.Value.ToShortDateString(), " ", assignment.ActualFinishDate.Value.ToShortTimeString()); } row["Comment"] = CHelper.ParseText(assignment.Comment, true, true, false); row["Indent"] = (level - 1) * indentSize; if (assignment.ClosedBy.HasValue) { row["ClosedBy"] = CommonHelper.GetUserStatus(assignment.ClosedBy.Value); } dt.Rows.Add(row); // Filter: // 1: WorkflowInstanceId = wfEntity.PrimaryKeyId, // 2: ParentAssignmentId = assignment.PrimaryKeyId FilterElementCollection fec = new FilterElementCollection(); fec.Add(FilterElement.EqualElement(AssignmentEntity.FieldWorkflowInstanceId, wfEntity.PrimaryKeyId.Value)); fec.Add(FilterElement.EqualElement(AssignmentEntity.FieldParentAssignmentId, assignment.PrimaryKeyId.Value)); // Sorting SortingElementCollection sec = new SortingElementCollection(); sec.Add(new SortingElement(AssignmentEntity.FieldCreated, SortingElementType.Asc)); EntityObject[] children = BusinessManager.List(AssignmentEntity.ClassName, fec.ToArray(), sec.ToArray()); ProcessCollection(dt, children, wfEntity, level); } }
public override bool CheckVisibility(object dataItem) { if (dataItem != null) { CalendarEventEntity ceo = (CalendarEventEntity)dataItem; FilterElementCollection fec = new FilterElementCollection(); FilterElement fe = FilterElement.EqualElement("EventId", ((VirtualEventId)ceo.PrimaryKeyId).RealEventId); fec.Add(fe); fe = FilterElement.EqualElement("PrincipalId", Mediachase.IBN.Business.Security.CurrentUser.UserID); fec.Add(fe); EntityObject[] list = BusinessManager.List(CalendarEventResourceEntity.ClassName, fec.ToArray()); if (list.Length == 0) return false; } return base.CheckVisibility(dataItem); }
public override void DataBind() { DataTable dt = new DataTable(); dt.Locale = CultureInfo.InvariantCulture; dt.Columns.Add("AssignmentId", typeof(string)); dt.Columns.Add("Subject", typeof(string)); dt.Columns.Add("User", typeof(string)); dt.Columns.Add("State", typeof(string)); dt.Columns.Add("Result", typeof(int)); dt.Columns.Add("FinishDate", typeof(string)); dt.Columns.Add("Comment", typeof(string)); dt.Columns.Add("Indent", typeof(int)); dt.Columns.Add("ClosedBy", typeof(string)); WorkflowInstanceEntity wfEntity = (WorkflowInstanceEntity)DataItem; // Filter: // 1: WorkflowInstanceId = wfEntity.PrimaryKeyId, // 2: ParentAssignmentId IS NULL (other elements we'll get via the recursion) FilterElementCollection fec = new FilterElementCollection(); fec.Add(FilterElement.EqualElement(AssignmentEntity.FieldWorkflowInstanceId, wfEntity.PrimaryKeyId.Value)); fec.Add(FilterElement.IsNullElement(AssignmentEntity.FieldParentAssignmentId)); // Sorting SortingElementCollection sec = new SortingElementCollection(); sec.Add(new SortingElement(AssignmentEntity.FieldCreated, SortingElementType.Asc)); EntityObject[] assignments = BusinessManager.List(AssignmentEntity.ClassName, fec.ToArray(), sec.ToArray()); ProcessCollection(dt, assignments, wfEntity, 0); AssignmentList.DataSource = dt; AssignmentList.DataBind(); if (dt.Rows.Count > 0) { AssignmentList.Visible = true; NoAssignmentsLabel.Visible = false; } else { AssignmentList.Visible = false; NoAssignmentsLabel.Visible = true; NoAssignmentsLabel.Text = GetGlobalResourceObject("IbnFramework.BusinessProcess", "NoAssignments").ToString(); } }
/// <summary> /// Reads the right check. /// </summary> /// <param name="context">The context.</param> private void ReadRightCheck(BusinessContext context) { //Если есть флаг отключить проверку авторизации то ничего не фильтруем if (!SkipSecurityCheckScope.IsActive) { string securityViewQuery = @"SELECT ObjectId FROM [dbo].[CalendarEvent_Security_Read]"; //Добавляем в sql context текущего пользователя SetContextInfo(Security.CurrentUserId); //Для метода List необходимо отфильтровать список согласно security view if (context.GetMethod() == RequestMethod.List) { ListRequest listRequest = context.Request as ListRequest; FilterElementCollection filterColl = new FilterElementCollection(); foreach (FilterElement origFilterEl in listRequest.Filters) { filterColl.Add(origFilterEl); } FilterElement filterEl = new FilterElement("PrimaryKeyId", FilterElementType.In, securityViewQuery); filterColl.Add(filterEl); //перезаписываем старую коллекцию фильтров, новой listRequest.Filters = filterColl.ToArray(); } //Для метода Load необходмио предотвратить загрузку объета не имеющего соотв прав else if (context.GetMethod() == RequestMethod.Load) { LoadRequest loadRequest = context.Request as LoadRequest; PrimaryKeyId eventId = loadRequest.Target.PrimaryKeyId.Value; VirtualEventId vEventId = (VirtualEventId)eventId; if (vEventId.IsRecurrence) { eventId = vEventId.RealEventId; } if (BusinessObject.GetTotalCount(DataContext.Current.GetMetaClass(CalendarEventEntity.ClassName), new FilterElement[] { new FilterElement("PrimaryKeyId", FilterElementType.Equal, eventId), new FilterElement("PrimaryKeyId", FilterElementType.In, securityViewQuery) }) == 0) { throw new Exception("Read access denied"); } } } }
public CalendarItem[] LoadItems(string startDate, string endDate, object calendarExtension) { DateTime viewStartDate = DateTime.Now; DateTime viewEndDate = DateTime.Now; string[] arr = startDate.Split(new char[] { '.' }); viewStartDate = new DateTime(int.Parse(arr[0]), int.Parse(arr[1]), int.Parse(arr[2]), int.Parse(arr[3]), int.Parse(arr[4]), int.Parse(arr[5])); arr = endDate.Split(new char[] { '.' }); viewEndDate = new DateTime(int.Parse(arr[0]), int.Parse(arr[1]), int.Parse(arr[2]), int.Parse(arr[3]), int.Parse(arr[4]), int.Parse(arr[5])); List <CalendarItem> al = new List <CalendarItem>(); FilterElementCollection fec = new FilterElementCollection(); FilterElement fe = new FilterElement(); fe.Type = FilterElementType.GreaterOrEqual; fe.Source = CalendarEventEntity.FieldStart; fe.Value = viewStartDate; fec.Add(fe); fe = new FilterElement(); fe.Type = FilterElementType.LessOrEqual; fe.Source = CalendarEventEntity.FieldStart; fe.Value = viewEndDate; fec.Add(fe); EntityObject[] calList = BusinessManager.List(CalendarEventEntity.ClassName, fec.ToArray()); foreach (EntityObject eo in calList) { CalendarEventEntity info = eo as CalendarEventEntity; CalendarItem it = new CalendarItem(); it.Uid = info.PrimaryKeyId.ToString(); it.StartDate = info.Start.ToString("yyyy.M.d.H.m.s"); it.EndDate = info.End.ToString("yyyy.M.d.H.m.s");; it.Title = String.Format("<div class=\"ibn-propertysheet2\"><a href='{1}{2}'>{0}</a></div>", info.Subject, CHelper.GetAbsolutePath("/Apps/MetaUIEntity/Pages/EntityView.aspx?ClassName=CalendarEvent&ObjectId="), it.Uid); it.Description = info.Body; it.Extensions = (info.RecurrenceId == DateTime.MinValue) ? "0" : "1"; al.Add(it); } return(al.ToArray()); }
public override bool CheckVisibility(object dataItem) { if (dataItem != null) { CalendarEventEntity ceo = (CalendarEventEntity)dataItem; FilterElementCollection fec = new FilterElementCollection(); FilterElement fe = FilterElement.EqualElement("EventId", ((VirtualEventId)ceo.PrimaryKeyId).RealEventId); fec.Add(fe); fe = FilterElement.EqualElement("PrincipalId", Mediachase.IBN.Business.Security.CurrentUser.UserID); fec.Add(fe); EntityObject[] list = BusinessManager.List(CalendarEventResourceEntity.ClassName, fec.ToArray()); if (list.Length == 0) { return(false); } } return(base.CheckVisibility(dataItem)); }
public CalendarItem[] LoadItems(string startDate, string endDate, object calendarExtension) { DateTime viewStartDate = DateTime.Now; DateTime viewEndDate = DateTime.Now; string[] arr = startDate.Split(new char[] { '.' }); viewStartDate = new DateTime(int.Parse(arr[0]),int.Parse(arr[1]), int.Parse(arr[2]),int.Parse(arr[3]),int.Parse(arr[4]), int.Parse(arr[5])); arr = endDate.Split(new char[] { '.' }); viewEndDate = new DateTime(int.Parse(arr[0]), int.Parse(arr[1]), int.Parse(arr[2]), int.Parse(arr[3]), int.Parse(arr[4]), int.Parse(arr[5])); List<CalendarItem> al = new List<CalendarItem>(); FilterElementCollection fec = new FilterElementCollection(); FilterElement fe = new FilterElement(); fe.Type = FilterElementType.GreaterOrEqual; fe.Source = CalendarEventEntity.FieldStart; fe.Value = viewStartDate; fec.Add(fe); fe = new FilterElement(); fe.Type = FilterElementType.LessOrEqual; fe.Source = CalendarEventEntity.FieldStart; fe.Value = viewEndDate; fec.Add(fe); EntityObject[] calList = BusinessManager.List(CalendarEventEntity.ClassName, fec.ToArray()); foreach (EntityObject eo in calList) { CalendarEventEntity info = eo as CalendarEventEntity; CalendarItem it = new CalendarItem(); it.Uid = info.PrimaryKeyId.ToString(); it.StartDate = info.Start.ToString("yyyy.M.d.H.m.s"); it.EndDate = info.End.ToString("yyyy.M.d.H.m.s"); ; it.Title = String.Format("<div class=\"ibn-propertysheet2\"><a href='{1}{2}'>{0}</a></div>", info.Subject, CHelper.GetAbsolutePath("/Apps/MetaUIEntity/Pages/EntityView.aspx?ClassName=CalendarEvent&ObjectId="), it.Uid); it.Description = info.Body; it.Extensions = (info.RecurrenceId == DateTime.MinValue) ? "0" : "1"; al.Add(it); } return al.ToArray(); }
public override void DataBind() { CHelper.AddToContext(_httpContextClassNameKey, ClassName); CHelper.AddToContext(_httpContextFilterFieldNameKey, FilterFieldName); CHelper.AddToContext(_httpContextFilterFieldValueKey, Request["ObjectId"]); if (String.IsNullOrEmpty(ProfileName)) { MetaClass mc = Mediachase.Ibn.Core.MetaDataWrapper.GetMetaClassByName(ClassName); ListViewProfile[] list = ListViewProfile.GetSystemProfiles(ClassName, PlaceName); if (list.Length == 0) { list = ListViewProfile.GetSystemProfiles(ClassName, "EntityList"); if (list.Length == 0) { list = ListViewProfile.GetSystemProfiles(ClassName, String.Empty); if (list.Length == 0) { ListViewProfile lvp = new ListViewProfile(); lvp.Id = Guid.NewGuid().ToString(); lvp.IsPublic = true; lvp.IsSystem = true; lvp.Name = CHelper.GetResFileString(mc.FriendlyName); lvp.ColumnsUI.Add(new ColumnProperties(mc.TitleFieldName, "150px", String.Empty)); lvp.FieldSet.Add(mc.TitleFieldName); lvp.Filters = new FilterElementCollection(); ListViewProfile.SaveSystemProfile(ClassName, PlaceName, Mediachase.Ibn.Data.Services.Security.CurrentUserId, lvp); list = ListViewProfile.GetSystemProfiles(ClassName, String.Empty); } } } ProfileName = list[0].Id; } grdMain.ClassName = ClassName; grdMain.ViewName = ViewName; grdMain.PlaceName = PlaceName; grdMain.ProfileName = ProfileName; grdMain.ShowCheckboxes = ShowCheckBoxes; FilterElementCollection fec = new FilterElementCollection(); fec.Add(FilterElement.EqualElement(FilterFieldName, Request["ObjectId"])); grdMain.AddFilters = fec; grdMain.DataBind(); ctrlGridEventUpdater.ClassName = ClassName; ctrlGridEventUpdater.ViewName = ViewName; ctrlGridEventUpdater.PlaceName = PlaceName; ctrlGridEventUpdater.GridId = grdMain.GridClientContainerId; MainMetaToolbar.ClassName = ClassName; MainMetaToolbar.ViewName = ViewName; MainMetaToolbar.PlaceName = PlaceName; MainMetaToolbar.DataBind(); }
private int BindList() { int itemsCount = 0; FilterElementCollection filters = new FilterElementCollection(); filters.Add(FilterElement.EqualElement(OwnerType, OwnerId)); filters.Add(FilterElement.EqualElement(AssignmentEntity.FieldState, AssignmentState.Active)); // if (AssignmentId != PrimaryKeyId.Empty) // filters.Add(FilterElement.NotEqualElement("PrimaryKeyId", AssignmentId)); EntityObject[] assignments = BusinessManager.List(AssignmentEntity.ClassName, filters.ToArray()); if (assignments != null && assignments.Length > 0) { itemsCount = assignments.Length; AssignmentGrid.DataSource = assignments; AssignmentGrid.DataBind(); } return itemsCount; }
private int BindAssignment() { int itemsCount = 0; if (AssignmentId != PrimaryKeyId.Empty) { FilterElementCollection filters = new FilterElementCollection(); filters.Add(FilterElement.EqualElement(OwnerType, OwnerId)); filters.Add(FilterElement.EqualElement(AssignmentEntity.FieldUserId, Bus.Security.CurrentUser.UserID)); filters.Add(FilterElement.EqualElement(AssignmentEntity.FieldState, AssignmentState.Active)); filters.Add(FilterElement.EqualElement("PrimaryKeyId", AssignmentId)); EntityObject[] assignments = BusinessManager.List(AssignmentEntity.ClassName, filters.ToArray()); if (assignments != null && assignments.Length > 0) { AssignmentEntity assignment = (AssignmentEntity)assignments[0]; SavedPath = AssignmentEntity.GetControlPath(assignment); MCDataBoundControl control = (MCDataBoundControl)LoadAssignment(); if (control != null) { control.DataItem = assignment; control.DataBind(); } itemsCount = 1; } else { SavedPath = String.Empty; MainPlaceHolder.Controls.Clear(); itemsCount = 0; } } return(itemsCount); }
protected void lbAddItems_Click(object sender, EventArgs e) { string s = Request["__EVENTARGUMENT"]; if (!String.IsNullOrEmpty(s)) { string[] mas = s.Split(new string[] { ";" }, StringSplitOptions.RemoveEmptyEntries); PrimaryKeyId objId = PrimaryKeyId.Parse(Request["ObjectId"]); foreach (string item in mas) { PrimaryKeyId id = PrimaryKeyId.Parse(MetaViewGroupUtil.GetIdFromUniqueKey(item)); string className = MetaViewGroupUtil.GetMetaTypeFromUniqueKey(item); if (!String.IsNullOrEmpty(className) && className != MetaViewGroupUtil.keyValueNotDefined) { FilterElementCollection fec = new FilterElementCollection(); fec.Add(FilterElement.EqualElement(Filter1FieldName, PrimaryKeyId.Parse(Request["ObjectId"]))); fec.Add(FilterElement.EqualElement(Filter2FieldName, id)); EntityObject[] list = BusinessManager.List(BridgeClassName, fec.ToArray()); if (list.Length == 0) { EntityObject eo = BusinessManager.InitializeEntity(BridgeClassName); eo[Filter1FieldName] = PrimaryKeyId.Parse(Request["ObjectId"]); eo[Filter2FieldName] = id; BusinessManager.Create(eo); } } else if (id != PrimaryKeyId.Empty) { EntityObject eo = BusinessManager.InitializeEntity(BridgeClassName); eo[Filter1FieldName] = PrimaryKeyId.Parse(Request["ObjectId"]); eo[Filter2FieldName] = id; BusinessManager.Create(eo); } } CHelper.RequireDataBind(); } }
private void GetObjectData() { FilterElementCollection fec = new FilterElementCollection(); FilterElement fe = FilterElement.EqualElement("EventId", _workObjectId); fec.Add(fe); EntityObject[] list = BusinessManager.List(CalendarEventResourceEntity.ClassName, fec.ToArray()); DataTable dt = new DataTable(); dt.Columns.Add(new DataColumn("Id", typeof(string))); dt.Columns.Add(new DataColumn("Name", typeof(string))); DataRow dr; foreach (EntityObject eo in list) { dr = dt.NewRow(); CalendarEventResourceEntity cero = (CalendarEventResourceEntity)eo; if (cero.ContactId.HasValue) { dr["Id"] = String.Format("{0}::{1}", cero.ContactId.Value.ToString(), ContactEntity.GetAssignedMetaClassName()); dr["Name"] = cero.Contact; } else if (cero.OrganizationId.HasValue) { dr["Id"] = String.Format("{0}::{1}", cero.OrganizationId.Value.ToString(), OrganizationEntity.GetAssignedMetaClassName()); dr["Name"] = cero.Organization; } else if (cero.PrincipalId.HasValue) { dr["Id"] = String.Format("{0}::{1}", cero.PrincipalId.Value.ToString(), Principal.GetAssignedMetaClass().Name); dr["Name"] = cero.Principal; } else { dr["Id"] = String.Format("{0}::0", cero.Email); dr["Name"] = cero.Email; } dt.Rows.Add(dr); } ViewState["Resources"] = dt; }
/// <summary> /// Deletes the custom page. /// </summary> /// <param name="uid">The uid.</param> public static void DeleteCustomPage(Guid uid) { FilterElementCollection filters = new FilterElementCollection(); filters.Add(FilterElement.EqualElement(CustomPageEntity.FieldUid, uid)); ListRequest request = new ListRequest(CustomPageEntity.ClassName, filters.ToArray()); request.Parameters.Add("CustomPageNormalizationPlugin", false); ListResponse response = (ListResponse)BusinessManager.Execute(request); foreach (CustomPageEntity page in response.EntityObjects) { if (!page.Properties.Contains(LocalDiskEntityObjectPlugin.IsLoadDiskEntityPropertyName)) BusinessManager.Delete(page); } }
public override void DataBind() { CHelper.AddToContext(_httpContextBridgeClassNameKey, BridgeClassName); CHelper.AddToContext(_httpContextClassNameKey, ClassName); CHelper.AddToContext(_httpContextFilter1FieldNameKey, Filter1FieldName); CHelper.AddToContext(_httpContextFilter1FieldValueKey, ObjectId); CHelper.AddToContext(_httpContextFilter2FieldNameKey, Filter2FieldName); MetaClass mc = Mediachase.Ibn.Core.MetaDataWrapper.GetMetaClassByName(ClassName); grdMain.ClassName = ClassName; grdMain.ViewName = ViewName; grdMain.PlaceName = PlaceName; grdMain.ProfileName = ProfileName; grdMain.ShowCheckboxes = (ObjectId > 0); MetaClass bridgeClass = Mediachase.Ibn.Core.MetaDataWrapper.GetMetaClassByName(BridgeClassName); string pkName = SqlContext.Current.Database.Tables[mc.DataSource.PrimaryTable].PrimaryKey.Name; string bridgeTableName = bridgeClass.DataSource.PrimaryTable; FilterElementCollection fec = new FilterElementCollection(); FilterElement fe; if (ObjectId < 0) // default profile { fe = new FilterElement(pkName, FilterElementType.In, String.Format("(SELECT [{0}] FROM cls_Principal WHERE Card = 'User' AND Activity = 3 AND [{0}] NOT IN (SELECT [{0}] FROM [{1}]))", Filter2FieldName, bridgeTableName)); } else { fe = new FilterElement(pkName, FilterElementType.In, String.Format("(SELECT [{0}] FROM [{1}] WHERE [{2}]={3})", Filter2FieldName, bridgeTableName, Filter1FieldName, ObjectId)); } fec.Add(fe); grdMain.AddFilters = fec; grdMain.DataBind(); ctrlGridEventUpdater.ClassName = ClassName; ctrlGridEventUpdater.ViewName = ViewName; ctrlGridEventUpdater.PlaceName = PlaceName; ctrlGridEventUpdater.GridId = grdMain.GridClientContainerId; MainMetaToolbar.ClassName = ClassName; MainMetaToolbar.ViewName = ViewName; MainMetaToolbar.PlaceName = PlaceName; MainMetaToolbar.DataBind(); }
/// <summary> /// Lists the event. /// </summary> /// <param name="request">The request.</param> /// <remarks> /// - Удаляет FilterElement с source (DTStart, DTEnd)в запросе и формирует на основании их предикат /// позволяющий производить выборку по данным критериям из произвольной коллекции /// /// </remarks> /// <returns></returns> public static ListResponse ListEvent(CalendarEventListRequest request) { List <CalendarEventEntity> retVal = new List <CalendarEventEntity>(); TZID dtStartTZID = String.IsNullOrEmpty(request.DTStartTimeZoneId) ? null : new TZID(request.DTStartTimeZoneId); TZID dtEndTZID = String.IsNullOrEmpty(request.DTEndTimeZoneId) ? null : new TZID(request.DTEndTimeZoneId); //Заполняем FIlterElementCollection элементами исходного массива фильтров FilterElementCollection filterColl = new FilterElementCollection(); foreach (FilterElement filterEl in request.Filters) { filterColl.Add(filterEl); } AndBlockFilterElementPredicate <DateTime> andBlockDTStartFilterPredicate = new AndBlockFilterElementPredicate <DateTime>(); AndBlockFilterElementPredicate <DateTime> andBlockDTEndFilterPredicate = new AndBlockFilterElementPredicate <DateTime>(); ConstructPredicate(andBlockDTStartFilterPredicate, filterColl, CalendarEventEntity.FieldStart); ConstructPredicate(andBlockDTEndFilterPredicate, filterColl, CalendarEventEntity.FieldEnd); //Получаем все FilterElement которые связаны с датой и формируем на основе их дерево выражений foreach (FilterElement filterEl in FindFilterElementBySource(new string[] { CalendarEventEntity.FieldStart, CalendarEventEntity.FieldEnd }, request.Filters, true)) { //Рекурсивно удаляем найденный filterElement из исходного набора DeepRemoveFilter(filterColl, filterEl); } //добавляем дополнительные критерии AddExtraCriteria(filterColl); //Получаем список эвентов retVal.AddRange(ListEvents(filterColl, request)); //Применяем критерии отбора по датам начала и завершения взятые из первоначального запроса, и преобразованные //для отбора из коллекции EntityObjects retVal.RemoveAll(delegate(CalendarEventEntity eventEntity) { return(!andBlockDTStartFilterPredicate.Evaluate(eventEntity.Start)); }); retVal.RemoveAll(delegate(CalendarEventEntity eventEntity) { return(!andBlockDTEndFilterPredicate.Evaluate(eventEntity.End)); }); retVal.Sort(); return(new ListResponse(retVal.ToArray())); }
/// <summary> /// Lists the event. /// </summary> /// <param name="request">The request.</param> /// <remarks> /// - Удаляет FilterElement с source (DTStart, DTEnd)в запросе и формирует на основании их предикат /// позволяющий производить выборку по данным критериям из произвольной коллекции /// /// </remarks> /// <returns></returns> public static ListResponse ListEvent(CalendarEventListRequest request) { List<CalendarEventEntity> retVal = new List<CalendarEventEntity>(); TZID dtStartTZID = String.IsNullOrEmpty(request.DTStartTimeZoneId) ? null : new TZID(request.DTStartTimeZoneId); TZID dtEndTZID = String.IsNullOrEmpty(request.DTEndTimeZoneId) ? null : new TZID(request.DTEndTimeZoneId); //Заполняем FIlterElementCollection элементами исходного массива фильтров FilterElementCollection filterColl = new FilterElementCollection(); foreach (FilterElement filterEl in request.Filters) { filterColl.Add(filterEl); } AndBlockFilterElementPredicate<DateTime> andBlockDTStartFilterPredicate = new AndBlockFilterElementPredicate<DateTime>(); AndBlockFilterElementPredicate<DateTime> andBlockDTEndFilterPredicate = new AndBlockFilterElementPredicate<DateTime>(); ConstructPredicate(andBlockDTStartFilterPredicate, filterColl, CalendarEventEntity.FieldStart); ConstructPredicate(andBlockDTEndFilterPredicate, filterColl, CalendarEventEntity.FieldEnd); //Получаем все FilterElement которые связаны с датой и формируем на основе их дерево выражений foreach (FilterElement filterEl in FindFilterElementBySource(new string[] {CalendarEventEntity.FieldStart, CalendarEventEntity.FieldEnd}, request.Filters, true)) { //Рекурсивно удаляем найденный filterElement из исходного набора DeepRemoveFilter(filterColl, filterEl); } //добавляем дополнительные критерии AddExtraCriteria(filterColl); //Получаем список эвентов retVal.AddRange(ListEvents(filterColl, request)); //Применяем критерии отбора по датам начала и завершения взятые из первоначального запроса, и преобразованные //для отбора из коллекции EntityObjects retVal.RemoveAll(delegate(CalendarEventEntity eventEntity) { return !andBlockDTStartFilterPredicate.Evaluate(eventEntity.Start); }); retVal.RemoveAll(delegate(CalendarEventEntity eventEntity) { return !andBlockDTEndFilterPredicate.Evaluate(eventEntity.End); }); retVal.Sort(); return new ListResponse(retVal.ToArray()); }
/// <summary> /// Deletes the custom page. /// </summary> /// <param name="uid">The uid.</param> public static void DeleteCustomPage(Guid uid) { FilterElementCollection filters = new FilterElementCollection(); filters.Add(FilterElement.EqualElement(CustomPageEntity.FieldUid, uid)); ListRequest request = new ListRequest(CustomPageEntity.ClassName, filters.ToArray()); request.Parameters.Add("CustomPageNormalizationPlugin", false); ListResponse response = (ListResponse)BusinessManager.Execute(request); foreach (CustomPageEntity page in response.EntityObjects) { if (!page.Properties.Contains(LocalDiskEntityObjectPlugin.IsLoadDiskEntityPropertyName)) { BusinessManager.Delete(page); } } }
public bool GenerateAttribute(AttributeMetadata attributeMetadata, IServiceProvider services) { bool generate = _defaultService.GenerateAttribute(attributeMetadata, services); if (generate) { FilterElementCollection collection = new FilterElementCollection(); collection.Clear(); foreach (AttributeFilterElement attributeFilter in _configuration.Filtering.AttributeFilter) { if (attributeFilter.EntityName == attributeMetadata.EntityLogicalName) { collection.Add(attributeFilter); } } generate = DoesMatchSettings(attributeMetadata.LogicalName, "attribute", collection); } return(generate); }
protected void btnDelete_Click(object sender, System.EventArgs e) { CalendarEventEntity ceo = BusinessManager.Load(CalendarEventEntity.ClassName, EventId) as CalendarEventEntity; if (ceo != null) { FilterElementCollection fec = new FilterElementCollection(); PrimaryKeyId realKey = ((VirtualEventId)EventId).RealEventId; FilterElement fe = FilterElement.EqualElement("EventId", realKey); fec.Add(fe); EntityObject[] list = BusinessManager.List(CalendarEventRecurrenceEntity.ClassName, fec.ToArray()); if (list.Length > 0) { CalendarEventRecurrenceEntity cero = (CalendarEventRecurrenceEntity)list[0]; BusinessManager.Delete(cero); Response.Redirect("~/Apps/MetaUIEntity/Pages/EntityView.aspx?ClassName=CalendarEvent&ObjectId=" + realKey.ToString()); } } }
private void BindDataGrid(bool dataBind) { _isFilterSet = false; _filterText = String.Empty; //добавляем к фильтру выбраное значение из левой панели, если включена группировка #region GroupItem int folderId = GetCurrentFolderId(); FilterElementCollection fec = new FilterElementCollection(); fec.Add(FilterElement.EqualElement("FolderId", folderId)); grdMain.AddFilters = fec; #endregion grdMain.SearchKeyword = txtSearch.Text; if (dataBind) { grdMain.DataBind(); } }
/// <summary> /// Postcreate inside transaction. /// </summary> /// <param name="context">The context.</param> protected override void PostCreateInsideTransaction(BusinessContext context) { base.PostCreateInsideTransaction(context); int userId = (int)(PrimaryKeyId)context.Request.Target.Properties[CustomizationProfileUserEntity.FieldPrincipalId].Value; // New profile defines new Left Menu so we should empty cache. DataCache.RemoveByUser(userId.ToString()); // Check WorkspacePersonalization flag in profile and clear user settings for dashboards if the value is False. CustomizationProfileUserEntity profileUserEntity = (CustomizationProfileUserEntity)context.Request.Target; PrimaryKeyId profileId = profileUserEntity.ProfileId; CustomizationProfileEntity profileEntity = (CustomizationProfileEntity)BusinessManager.Load(CustomizationProfileEntity.ClassName, profileId); if (!profileEntity.WorkspacePersonalization) { FilterElementCollection filters = new FilterElementCollection(); filters.Add(FilterElement.EqualElement(CustomPageEntity.FieldUserId, userId)); foreach (EntityObject page in BusinessManager.List(CustomPageEntity.ClassName, filters.ToArray())) BusinessManager.Delete(page); } }
/// <summary> /// Postcreate inside transaction. /// </summary> /// <param name="context">The context.</param> protected override void PostCreateInsideTransaction(BusinessContext context) { base.PostCreateInsideTransaction(context); int userId = (int)(PrimaryKeyId)context.Request.Target.Properties[CustomizationProfileUserEntity.FieldPrincipalId].Value; // New profile defines new Left Menu so we should empty cache. DataCache.RemoveByUser(userId.ToString()); // Check WorkspacePersonalization flag in profile and clear user settings for dashboards if the value is False. CustomizationProfileUserEntity profileUserEntity = (CustomizationProfileUserEntity)context.Request.Target; PrimaryKeyId profileId = profileUserEntity.ProfileId; CustomizationProfileEntity profileEntity = (CustomizationProfileEntity)BusinessManager.Load(CustomizationProfileEntity.ClassName, profileId); if (!profileEntity.WorkspacePersonalization) { FilterElementCollection filters = new FilterElementCollection(); filters.Add(FilterElement.EqualElement(CustomPageEntity.FieldUserId, userId)); foreach (EntityObject page in BusinessManager.List(CustomPageEntity.ClassName, filters.ToArray())) BusinessManager.Delete(page); } }
private int BindList() { int itemsCount = 0; FilterElementCollection filters = new FilterElementCollection(); filters.Add(FilterElement.EqualElement(OwnerType, OwnerId)); filters.Add(FilterElement.EqualElement(AssignmentEntity.FieldUserId, Bus.Security.CurrentUser.UserID)); filters.Add(FilterElement.EqualElement(AssignmentEntity.FieldState, AssignmentState.Active)); // if (AssignmentId != PrimaryKeyId.Empty) // filters.Add(FilterElement.NotEqualElement("PrimaryKeyId", AssignmentId)); EntityObject[] assignments = BusinessManager.List(AssignmentEntity.ClassName, filters.ToArray()); if (assignments != null && assignments.Length > 0) { itemsCount = assignments.Length; AssignmentGrid.DataSource = assignments; AssignmentGrid.DataBind(); } return itemsCount; }
private int BindAssignment() { int itemsCount = 0; if (AssignmentId != PrimaryKeyId.Empty) { FilterElementCollection filters = new FilterElementCollection(); filters.Add(FilterElement.EqualElement(OwnerType, OwnerId)); filters.Add(FilterElement.EqualElement(AssignmentEntity.FieldUserId, Bus.Security.CurrentUser.UserID)); filters.Add(FilterElement.EqualElement(AssignmentEntity.FieldState, AssignmentState.Active)); filters.Add(FilterElement.EqualElement("PrimaryKeyId", AssignmentId)); EntityObject[] assignments = BusinessManager.List(AssignmentEntity.ClassName, filters.ToArray()); if (assignments != null && assignments.Length > 0) { AssignmentEntity assignment = (AssignmentEntity)assignments[0]; SavedPath = AssignmentEntity.GetControlPath(assignment); MCDataBoundControl control = (MCDataBoundControl)LoadAssignment(); if (control != null) { control.DataItem = assignment; control.DataBind(); } itemsCount = 1; } else { SavedPath = String.Empty; MainPlaceHolder.Controls.Clear(); itemsCount = 0; } } return itemsCount; }
private void BindGrid() { DataTable dt = new DataTable(); dt.Columns.Add("Id", typeof(string)); dt.Columns.Add("Name", typeof(string)); string sSearch = tbSearchString.Text.Trim(); FilterElementCollection fec = new FilterElementCollection(); if (!String.IsNullOrEmpty(Request["filterName"]) && !String.IsNullOrEmpty(Request["filterValue"])) { FilterElement fe = FilterElement.EqualElement(Request["filterName"], Request["filterValue"]); FilterElement fe1 = FilterElement.IsNullElement(Request["filterName"]); FilterElement feOr = new OrBlockFilterElement(); feOr.ChildElements.Add(fe); feOr.ChildElements.Add(fe1); fec.Add(feOr); } else if (!String.IsNullOrEmpty(Request["filterName"]) && String.IsNullOrEmpty(Request["filterValue"])) { FilterElement fe = FilterElement.IsNullElement(Request["filterName"]); fec.Add(fe); } MetaObject[] list = MetaObject.List(mc, fec.ToArray()); foreach (MetaObject obj in list) { DataRow row = dt.NewRow(); row["Id"] = obj.PrimaryKeyId.ToString(); if (obj.Properties[mc.TitleFieldName].Value != null) row["Name"] = CHelper.GetResFileString(obj.Properties[mc.TitleFieldName].Value.ToString()); dt.Rows.Add(row); } if (ViewState["SelectItem_Sort"] == null) ViewState["SelectItem_Sort"] = "Name"; if (ViewState["SelectItem_CurrentPage"] == null) ViewState["SelectItem_CurrentPage"] = 0; if (dt.Rows != null && dt.Rows.Count < grdMain.PageSize) grdMain.AllowPaging = false; else grdMain.AllowPaging = true; DataView dv = dt.DefaultView; if (sSearch != String.Empty) { dv.RowFilter = String.Format(CultureInfo.InvariantCulture, "Name LIKE '%{0}%'", sSearch); } dv.Sort = ViewState["SelectItem_Sort"].ToString(); if (ViewState["SelectItem_CurrentPage"] != null && grdMain.AllowPaging) grdMain.CurrentPageIndex = (int)ViewState["SelectItem_CurrentPage"]; grdMain.DataSource = dv; grdMain.DataBind(); foreach (DataGridItem dgi in grdMain.Items) { ImageButton ib = (ImageButton)dgi.FindControl("ibRelate"); if (ib != null) { string sId = dgi.Cells[0].Text; string sAction = CHelper.GetCloseRefreshString(RefreshButton.Replace("xxx", sId)); ib.Attributes.Add("onclick", sAction); } } }
private void ProcessCollection(DataTable dt, EntityObject[] assignments, WorkflowInstanceEntity wfEntity, int level) { level++; foreach (AssignmentEntity assignment in assignments) { DataRow row = dt.NewRow(); row["AssignmentId"] = assignment.PrimaryKeyId.ToString(); row["Subject"] = assignment.Subject; if (assignment.UserId.HasValue) row["User"] = CommonHelper.GetUserStatus(assignment.UserId.Value); row["State"] = CHelper.GetResFileString(MetaEnum.GetFriendlyName(MetaDataWrapper.GetEnumByName("AssignmentState"), assignment.State)); if (assignment.ExecutionResult.HasValue) row["Result"] = assignment.ExecutionResult.Value; if (assignment.ActualFinishDate.HasValue) row["FinishDate"] = String.Concat(assignment.ActualFinishDate.Value.ToShortDateString(), " ", assignment.ActualFinishDate.Value.ToShortTimeString()); row["Comment"] = CHelper.ParseText(assignment.Comment, true, true, false); row["Indent"] = (level - 1) * indentSize; if (assignment.ClosedBy.HasValue) { row["ClosedBy"] = CommonHelper.GetUserStatus(assignment.ClosedBy.Value); } dt.Rows.Add(row); // Filter: // 1: WorkflowInstanceId = wfEntity.PrimaryKeyId, // 2: ParentAssignmentId = assignment.PrimaryKeyId FilterElementCollection fec = new FilterElementCollection(); fec.Add(FilterElement.EqualElement(AssignmentEntity.FieldWorkflowInstanceId, wfEntity.PrimaryKeyId.Value)); fec.Add(FilterElement.EqualElement(AssignmentEntity.FieldParentAssignmentId, assignment.PrimaryKeyId.Value)); // Sorting SortingElementCollection sec = new SortingElementCollection(); sec.Add(new SortingElement(AssignmentEntity.FieldCreated, SortingElementType.Asc)); EntityObject[] children = BusinessManager.List(AssignmentEntity.ClassName, fec.ToArray(), sec.ToArray()); ProcessCollection(dt, children, wfEntity, level); } }
protected void Page_Load(object sender, EventArgs e) { if (_classes.Count <= 0) throw new Exception("Classes is required!"); ddFilter.SelectedIndexChanged += new EventHandler(ddFilter_SelectedIndexChanged); if (!IsPostBack) { BindDropDowns(); btnNew.Visible = _isCanCreate; tblSelect.Visible = true; tblNew.Visible = false; } grdMain.ClassName = ddFilter.SelectedValue; grdMain.ViewName = ""; grdMain.PlaceName = _placeName; grdMain.ProfileName = ProfileName; grdMain.ShowCheckboxes = _isMultipleSelect; FilterElementCollection fec = new FilterElementCollection(); if (!String.IsNullOrEmpty(Request["filterName"]) && !String.IsNullOrEmpty(Request["filterValue"])) { FilterElement fe = FilterElement.EqualElement(Request["filterName"], Request["filterValue"]); FilterElement fe1 = FilterElement.IsNullElement(Request["filterName"]); FilterElement feOr = new OrBlockFilterElement(); feOr.ChildElements.Add(fe); feOr.ChildElements.Add(fe1); fec.Add(feOr); } else if (!String.IsNullOrEmpty(Request["filterName"]) && String.IsNullOrEmpty(Request["filterValue"])) { FilterElement fe = FilterElement.IsNullElement(Request["filterName"]); fec.Add(fe); } if (TreeServiceTargetObjectId != PrimaryKeyId.Empty) { FilterElement fe = new FilterElement(Mediachase.Ibn.Data.Services.TreeService.OutlineNumberFieldName, FilterElementType.NotContains, TreeServiceTargetObjectId.ToString().ToLower()); fec.Add(fe); } grdMain.AddFilters = fec; ctrlGridEventUpdater.ClassName = ddFilter.SelectedValue; ctrlGridEventUpdater.ViewName = ""; ctrlGridEventUpdater.PlaceName = _placeName; ctrlGridEventUpdater.GridId = grdMain.GridClientContainerId; ctrlGridEventUpdater.GridActionMode = Mediachase.UI.Web.Apps.MetaUI.Grid.MetaGridServerEventAction.Mode.ListViewUI; //ddFilter.Visible = (_classes.Count > 1); BindDataGrid(!Page.IsPostBack); BindButtons(); }
protected void lbAddItems_Click(object sender, EventArgs e) { string s = Request["__EVENTARGUMENT"]; if (!String.IsNullOrEmpty(s)) { string[] mas = s.Split(new string[] { ";" }, StringSplitOptions.RemoveEmptyEntries); PrimaryKeyId objId = PrimaryKeyId.Parse(Request["ObjectId"]); foreach (string item in mas) { PrimaryKeyId id = PrimaryKeyId.Parse(MetaViewGroupUtil.GetIdFromUniqueKey(item)); string className = MetaViewGroupUtil.GetMetaTypeFromUniqueKey(item); if (!String.IsNullOrEmpty(className) && className != MetaViewGroupUtil.keyValueNotDefined) { FilterElementCollection fec = new FilterElementCollection(); fec.Add(FilterElement.EqualElement(Filter1FieldName, PrimaryKeyId.Parse(Request["ObjectId"]))); fec.Add(FilterElement.EqualElement(Filter2FieldName, id)); EntityObject[] list = BusinessManager.List(BridgeClassName, fec.ToArray()); if (list.Length == 0) { EntityObject eo = BusinessManager.InitializeEntity(BridgeClassName); eo[Filter1FieldName] = PrimaryKeyId.Parse(Request["ObjectId"]); eo[Filter2FieldName] = id; BusinessManager.Create(eo); } } else if (id != PrimaryKeyId.Empty) { EntityObject eo = BusinessManager.InitializeEntity(BridgeClassName); eo[Filter1FieldName] = PrimaryKeyId.Parse(Request["ObjectId"]); eo[Filter2FieldName] = id; BusinessManager.Create(eo); } } CHelper.RequireDataBind(); } }
/// <summary> /// Resets the custom page. /// </summary> /// <param name="uid">The page uid.</param> /// <param name="profileId">The profile id.</param> /// <param name="userId">The user id.</param> public static void ResetCustomPage(Guid uid, int? profileId, int? userId) { FilterElementCollection filters = new FilterElementCollection(); filters.Add(FilterElement.EqualElement(CustomPageEntity.FieldUid, uid)); if (userId.HasValue) // User layer { filters.Add(FilterElement.EqualElement(CustomPageEntity.FieldUserId, userId.Value)); } else if (profileId.HasValue) // Profile layer { filters.Add(FilterElement.EqualElement(CustomPageEntity.FieldProfileId, profileId.Value)); } else // Site layer { filters.Add(FilterElement.IsNullElement(CustomPageEntity.FieldProfileId)); filters.Add(FilterElement.IsNullElement(CustomPageEntity.FieldUserId)); } foreach (CustomPageEntity page in BusinessManager.List(CustomPageEntity.ClassName, filters.ToArray())) { if (!page.Properties.Contains(LocalDiskEntityObjectPlugin.IsLoadDiskEntityPropertyName)) BusinessManager.Delete(page); } }
/// <summary> /// Resets the user settings by profile. /// </summary> /// <param name="uid">The page uid.</param> /// <param name="profileId">The profile id.</param> public static void ResetUserSettingsByProfile(Guid uid, int profileId) { List<string> users = new List<string>(); if (profileId > 0) { FilterElementCollection fec = new FilterElementCollection(); fec.Add(FilterElement.EqualElement(CustomizationProfileUserEntity.FieldProfileId, profileId)); foreach (CustomizationProfileUserEntity entity in BusinessManager.List(CustomizationProfileUserEntity.ClassName, fec.ToArray())) users.Add(entity.PrincipalId.ToString()); } else // default profile { // 1. Get list all users using (IDataReader reader = Mediachase.IBN.Business.User.GetListAll()) { while (reader.Read()) users.Add(reader["UserId"].ToString()); } // 2. Exclude users with non-default profile EntityObject[] entityList = BusinessManager.List(CustomizationProfileUserEntity.ClassName, (new FilterElementCollection()).ToArray()); foreach (CustomizationProfileUserEntity puEntity in entityList) { users.Remove(puEntity.PrincipalId.ToString()); } } // O.R. [2010-10-05]. Don't process profile without users if (users.Count > 0) { // Remove CustomPages for all users in Profile FilterElementCollection filters = new FilterElementCollection(); filters.Add(FilterElement.EqualElement(CustomPageEntity.FieldUid, uid)); OrBlockFilterElement orBlock = new OrBlockFilterElement(); foreach (string userId in users) orBlock.ChildElements.Add(FilterElement.EqualElement(CustomPageEntity.FieldUserId, userId)); filters.Add(orBlock); // Skip CustomPageNormalizationPlugin ListRequest request = new ListRequest(CustomPageEntity.ClassName, filters.ToArray()); request.Parameters.Add("CustomPageNormalizationPlugin", false); ListResponse response = (ListResponse)BusinessManager.Execute(request); foreach (EntityObject page in response.EntityObjects) BusinessManager.Delete(page); } }
private void BindDGOrganizations(string keyword) { FilterElement fe = CHelper.GetSearchFilterElementByKeyword(keyword, OrganizationEntity.GetAssignedMetaClassName()); FilterElementCollection fec = new FilterElementCollection(); fec.Add(fe); dgOrganizations.DataSource = BusinessManager.List(OrganizationEntity.GetAssignedMetaClassName(), fec.ToArray()); dgOrganizations.DataBind(); int RowCount = dgOrganizations.Items.Count; if (RowCount == 0) { Sep11.Visible = false; Pan11.Visible = false; } else { Sep11.Title = String.Format("{0} ({1})", LocRM.GetString("Organizations"), RowCount); } }
private void BindValues() { CalendarEventEntity ceo = (CalendarEventEntity)DataItem;//BusinessManager.Load(CalendarEventEntity.ClassName, EventId) as CalendarEventEntity; if (ceo != null) { FilterElementCollection fec = new FilterElementCollection(); FilterElement fe = FilterElement.EqualElement("EventId", EventId); fec.Add(fe); EntityObject[] list = BusinessManager.List(CalendarEventRecurrenceEntity.ClassName, fec.ToArray()); if (list.Length > 0) { CalendarEventRecurrenceEntity cero = (CalendarEventRecurrenceEntity)list[0]; lblNoRecurrence.Visible = false; ShowRecurrence.Visible = true; txtStartTime.Text = ceo.Start.ToShortTimeString(); txtEndTime.Text = ceo.End.ToShortTimeString(); Pattern = (byte)cero.RecurrenceType; if (cero.RecurrenceType == (int)eRecurrenceType.RecursWeekly && cero.DayOfWeekMask.HasValue && cero.DayOfWeekMask.Value == (int)eBitDayOfWeek.Weekdays) Pattern = (byte)eRecurrenceType.RecursDaily; if (cero.Interval.HasValue) Frequency = (byte)cero.Interval.Value; if (cero.DayOfWeekMask.HasValue) bWeekdays = (byte)cero.DayOfWeekMask; if (cero.DayOfMonth.HasValue) MonthDay = (byte)cero.DayOfMonth.Value; if (cero.Instance.HasValue) bWeekNumber = (byte)cero.Instance.Value; if (cero.MonthOfYear.HasValue) MonthNumber = (byte)cero.MonthOfYear.Value; if (cero.Occurrences.HasValue) EndAfter = cero.Occurrences.Value; int pattern = Pattern; if (Pattern == 1) pattern = (cero.DayOfWeekMask.HasValue && cero.DayOfWeekMask.Value == (int)eBitDayOfWeek.Weekdays) ? 12 : 11; Label lblControl = (Label)this.FindControl("txtInfo" + pattern); if (lblControl != null) lblControl.Visible = true; if (EndAfter != 0) { lblEnd.Text = LocRM.GetString("Endafter") + ":"; txtEnd.Text = EndAfter.ToString() + " " + LocRM.GetString("occurrences"); } else if (cero.PatternEndDate.HasValue) { lblEnd.Text = LocRM.GetString("Endby") + ":"; txtEnd.Text = cero.PatternEndDate.Value.ToShortDateString(); } } else { lblNoRecurrence.Text = "<br> " + LocRM.GetString("NotSet") + "<br> "; lblNoRecurrence.Visible = true; ShowRecurrence.Visible = false; } } }
public static string GetHistorySystemListViewProfile(string historyClassName, string placeName) { ListViewProfile[] mas = ListViewProfile.GetSystemProfiles(historyClassName, placeName); if (mas.Length == 0) { ListViewProfile profile = new ListViewProfile(); profile.Id = Guid.NewGuid().ToString(); profile.IsPublic = true; profile.IsSystem = true; MetaClass mc = Mediachase.Ibn.Core.MetaDataWrapper.GetMetaClassByName(historyClassName); profile.Name = CHelper.GetResFileString(mc.PluralName); profile.FieldSetName = mc.Name; MetaClass mc2 = Mediachase.Ibn.Core.MetaDataWrapper.GetMetaClassByName(HistoryManager.GetOriginalMetaClassName(historyClassName)); HistoryMetaClassInfo historyInfo = HistoryManager.GetInfo(mc2); Collection<string> selectedFields = historyInfo.SelectedFields; profile.FieldSet = new List<string>(); profile.ColumnsUI = new ColumnPropertiesCollection(); profile.FieldSet.Add(ChangeDetectionService.ModifiedFieldName); profile.FieldSet.Add(mc2.TitleFieldName); profile.ColumnsUI.Add(new ColumnProperties(ChangeDetectionService.ModifiedFieldName, "200px", String.Empty)); profile.ColumnsUI.Add(new ColumnProperties(mc2.TitleFieldName, "200px", String.Empty)); foreach (string fieldName in selectedFields) { if (fieldName == mc2.TitleFieldName || fieldName == ChangeDetectionService.ModifiedFieldName) continue; profile.FieldSet.Add(fieldName); profile.ColumnsUI.Add(new ColumnProperties(fieldName, "200px", String.Empty)); } profile.GroupByFieldName = String.Empty; FilterElementCollection fec = new FilterElementCollection(); FilterElement fe = new FilterElement(); fe.ValueIsTemplate = true; fe.Source = "ObjectId"; fe.Value = "{QueryString:ObjectId}"; fec.Add(fe); profile.Filters = fec; profile.Sorting = new SortingElementCollection(); ListViewProfile.SaveSystemProfile(historyClassName, placeName, Mediachase.IBN.Business.Security.CurrentUser.UserID, profile); mas = ListViewProfile.GetSystemProfiles(historyClassName, placeName); if (mas.Length == 0) throw new Exception("ListViewProfiles are not exist!"); } return mas[0].Id; }
protected void btnDelete_Click(object sender, System.EventArgs e) { CalendarEventEntity ceo = BusinessManager.Load(CalendarEventEntity.ClassName, EventId) as CalendarEventEntity; if (ceo != null) { FilterElementCollection fec = new FilterElementCollection(); PrimaryKeyId realKey = ((VirtualEventId)EventId).RealEventId; FilterElement fe = FilterElement.EqualElement("EventId", realKey); fec.Add(fe); EntityObject[] list = BusinessManager.List(CalendarEventRecurrenceEntity.ClassName, fec.ToArray()); if (list.Length > 0) { CalendarEventRecurrenceEntity cero = (CalendarEventRecurrenceEntity)list[0]; BusinessManager.Delete(cero); Response.Redirect("~/Apps/MetaUIEntity/Pages/EntityView.aspx?ClassName=CalendarEvent&ObjectId=" + realKey.ToString()); } } }
/// <summary> /// Deletes the navigation item. /// </summary> /// <param name="fullId">The full id.</param> /// <param name="profileId">The profile id.</param> /// <param name="principalId">The principal id.</param> public static void DeleteNavigationItem(string fullId, PrimaryKeyId? profileId, PrimaryKeyId? principalId) { FilterElementCollection filters = new FilterElementCollection(); filters.Add(new FilterElement(CustomizationItemEntity.FieldXmlFullId, FilterElementType.Like, fullId + "%")); filters.Add(FilterElement.EqualElement(CustomizationItemEntity.FieldStructureType, (int)CustomizationStructureType.NavigationMenu)); filters.Add(FilterElement.EqualElement(CustomizationItemEntity.FieldCommandType, (int)ItemCommandType.Add)); // delete user level only if (principalId.HasValue) { filters.Add(FilterElement.EqualElement(CustomizationItemEntity.FieldPrincipalId, principalId.Value)); } // delete profile and user level else if (profileId.HasValue) { OrBlockFilterElement block = new OrBlockFilterElement(); block.ChildElements.Add(FilterElement.EqualElement(CustomizationItemEntity.FieldProfileId, profileId.Value)); block.ChildElements.Add(FilterElement.IsNotNullElement(CustomizationItemEntity.FieldPrincipalId)); filters.Add(block); } // else delete all - we don't use filter in that case using (TransactionScope transaction = DataContext.Current.BeginTransaction()) { foreach (EntityObject item in BusinessManager.List(CustomizationItemEntity.ClassName, filters.ToArray())) { BusinessManager.Delete(item); } transaction.Commit(); } ClearCache(profileId, principalId); }
/// <summary> /// Internals the bind. /// </summary> private void internalBind() { MetaClass mc = Mediachase.Ibn.Core.MetaDataWrapper.GetMetaClassByName(ClassName); MainGrid.Columns.Clear(); MainGrid.AllowPaging = true; if (!ShowPaging) { MainGridExt.BottomHeight = 1; SetPageSize(-1); } else { MainGridExt.BottomHeight = 30; MainGrid.PageSize = GetPageSize(); } int width = 0; if (this.ShowCheckboxes) width += 22 + 7; foreach (EntityGridCustomColumnInfo customColumn in this.CustomColumns) { MainGrid.Columns.Add(customColumn.Column); width += customColumn.Width + 7; } int counter = 0; foreach (EntityFieldInfo field in this.VisibleMetaFields) { if (PlaceName == String.Empty) MainGrid.Columns.Add((new ListColumnFactory(this.ViewName)).GetColumn(this.Page, field.Field)); else MainGrid.Columns.Add((new ListColumnFactory(this.ViewName)).GetColumn(this.Page, field.Field, PlaceName)); int cellWidth = GetMetaFieldWidth(counter, field.Width); width += cellWidth; counter++; } width += this.VisibleMetaFields.Length * 7; MainGrid.Width = width; //Adding CssColumn MainGrid.Columns.Add((new ListColumnFactory(this.ViewName)).GetCssColumn(this.Page, ClassName)); internalBindHeader(); FilterElementCollection fec = new FilterElementCollection(); fec.AddRange(CurrentProfile.Filters.ToArray()); if (!String.IsNullOrEmpty(this.SearchKeyword)) { FilterElement fe = CHelper.GetSearchFilterElementByKeyword(this.SearchKeyword, ClassName); fec.Add(fe); } fec.AddRange(AddFilters.ToArray()); //Sorting SortingElementCollection sec = new SortingElementCollection(); string key = GetPropertyKey(SortingPropertyKey); if (_pc[key] != null) { string sort = _pc[key]; SortingElementType set = SortingElementType.Asc; if (sort.IndexOf(" DESC") >= 0) { sort = sort.Substring(0, sort.IndexOf(" DESC")); set = SortingElementType.Desc; } // O.R. [2009-11-02] check that sorting field exists if (mc.Fields.Contains(sort)) { sec.Add(new SortingElement(sort, set)); } else { _pc[key] = null; } } else if (CurrentProfile.Sorting != null) { // O.R. [2009-11-02] check that sorting fields exist foreach (SortingElement sortElement in CurrentProfile.Sorting) { if (!mc.Fields.Contains(sortElement.Source)) { CurrentProfile.Sorting = null; break; } } if (CurrentProfile.Sorting != null) sec = CurrentProfile.Sorting; } if (this.GridFilters.Count > 0) { fec.AddRange(this.GridFilters); } if (this.GridSorting.Count > 0) { sec.AddRange(this.GridSorting); } if (this.CustomDataSource == null) { EntityObject[] list; try { list = BusinessManager.List(ClassName, fec.ToArray(), sec.ToArray()); } catch { string sKey = GetPropertyKey(SortingPropertyKey); _pc[sKey] = null; if (this.Parent != null && this.Parent.Parent != null && this.Parent.Parent.Parent != null && this.Parent.Parent.Parent is Mediachase.Ibn.Web.UI.MetaUIEntity.Modules.EntityList) Mediachase.Ibn.Web.UI.MetaUIEntity.Modules.EntityList.SetProfileName(_pc, ClassName, null); throw; } MainGridExt.IsEmpty = (list.Length == 0); if (list.Length == 0) { list = new EntityObject[] { new EntityObject(ClassName) }; this.Count = 0; } else { this.Count = list.Length; } MainGrid.DataSource = list; } else { MainGrid.DataSource = this.CustomDataSource; this.Count = this.CustomDataSource.Length; } MainGrid.DataBind(); internalBindPaging(); #region Appply paging for dashboard if (this.DashboardMode) { MainGridExt.BottomHeight = 16; //HtmlControl c = (HtmlControl)MainGrid.BottomPagerRow.FindControl("pagingContainer"); //c.Style.Add(HtmlTextWriterStyle.Position, "static"); //c.Style.Add("float", "right"); //MainGridExt.ServicePath = "debug"; } #endregion //if (MainGridExt.IsEmpty) // MainGrid.CssClass = "serverGridBodyEmpty"; }
/// <summary> /// Gets the customization item. /// </summary> /// <param name="fullId">The full id.</param> /// <param name="profileId">The profile id.</param> /// <param name="principalId">The principal id.</param> /// <returns></returns> private static CustomizationItemEntity GetCustomizationItem(string fullId, CustomizationStructureType structureType, ItemCommandType commandType, PrimaryKeyId? profileId, PrimaryKeyId? principalId) { CustomizationItemEntity result = null; FilterElementCollection filters = new FilterElementCollection(); filters.Add(FilterElement.EqualElement(CustomizationItemEntity.FieldXmlFullId, fullId)); filters.Add(FilterElement.EqualElement(CustomizationItemEntity.FieldStructureType, (int)structureType)); filters.Add(FilterElement.EqualElement(CustomizationItemEntity.FieldCommandType, (int)commandType)); // Filter by profile if (profileId.HasValue) filters.Add(FilterElement.EqualElement(CustomizationItemEntity.FieldProfileId, profileId.Value)); else filters.Add(FilterElement.IsNullElement(CustomizationItemEntity.FieldProfileId)); // Filter by principal if (principalId.HasValue) filters.Add(FilterElement.EqualElement(CustomizationItemEntity.FieldPrincipalId, principalId.Value)); else filters.Add(FilterElement.IsNullElement(CustomizationItemEntity.FieldPrincipalId)); EntityObject[] items = BusinessManager.List(CustomizationItemEntity.ClassName, filters.ToArray()); if (items != null && items.Length > 0) { result = items[0] as CustomizationItemEntity; } return result; }
private void BindDataGrid(bool dataBind) { _isFilterSet = false; _filterText = String.Empty; //добавляем к фильтру выбраное значение из левой панели, если включена группировка #region GroupItem int folderId = GetCurrentFolderId(); FilterElementCollection fec = new FilterElementCollection(); fec.Add(FilterElement.EqualElement("FolderId", folderId)); grdMain.AddFilters = fec; #endregion grdMain.SearchKeyword = txtSearch.Text; if (dataBind) grdMain.DataBind(); }
public override void DataBind() { CHelper.AddToContext(_httpContextBridgeClassNameKey, BridgeClassName); CHelper.AddToContext(_httpContextClassNameKey, ClassName); CHelper.AddToContext(_httpContextFilter1FieldNameKey, Filter1FieldName); CHelper.AddToContext(_httpContextFilter1FieldValueKey, Request["ObjectId"]); CHelper.AddToContext(_httpContextFilter2FieldNameKey, Filter2FieldName); MetaClass mc = Mediachase.Ibn.Core.MetaDataWrapper.GetMetaClassByName(ClassName); if (String.IsNullOrEmpty(ProfileName)) { ListViewProfile[] list = ListViewProfile.GetSystemProfiles(ClassName, PlaceName); if (list.Length == 0) { list = ListViewProfile.GetSystemProfiles(ClassName, "EntityList"); if (list.Length == 0) { list = ListViewProfile.GetSystemProfiles(ClassName, String.Empty); if (list.Length == 0) { ListViewProfile lvp = new ListViewProfile(); lvp.Id = Guid.NewGuid().ToString(); lvp.IsPublic = true; lvp.IsSystem = true; lvp.Name = CHelper.GetResFileString(mc.FriendlyName); lvp.ColumnsUI.Add(new ColumnProperties(mc.TitleFieldName, "150px", String.Empty)); lvp.FieldSet.Add(mc.TitleFieldName); lvp.Filters = new FilterElementCollection(); ListViewProfile.SaveSystemProfile(ClassName, PlaceName, Mediachase.Ibn.Data.Services.Security.CurrentUserId, lvp); list = ListViewProfile.GetSystemProfiles(ClassName, String.Empty); } } } ProfileName = list[0].Id; } grdMain.ClassName = ClassName; grdMain.ViewName = ViewName; grdMain.PlaceName = PlaceName; grdMain.ProfileName = ProfileName; grdMain.ShowCheckboxes = ShowCheckBoxes; MetaClass bridgeClass = Mediachase.Ibn.Core.MetaDataWrapper.GetMetaClassByName(BridgeClassName); string pkName = SqlContext.Current.Database.Tables[mc.DataSource.PrimaryTable].PrimaryKey.Name; string bridgeTableName = bridgeClass.DataSource.PrimaryTable; FilterElementCollection fec = new FilterElementCollection(); FilterElement fe = new FilterElement(pkName, FilterElementType.In, String.Format("(SELECT [{0}] FROM [{1}] WHERE [{2}]='{3}')", Filter2FieldName, bridgeTableName, Filter1FieldName, Request["ObjectId"])); //FilterElement fe = new FilterElement(String.Empty, FilterElementType.Custom, // String.Format("[t01].[{0}] IN (SELECT [{1}] FROM [{2}] WHERE [{3}]='{4}')", // pkName, Filter2FieldName, bridgeTableName, Filter1FieldName, Request["ObjectId"])); fec.Add(fe); grdMain.AddFilters = fec; grdMain.DataBind(); ctrlGridEventUpdater.ClassName = ClassName; ctrlGridEventUpdater.ViewName = ViewName; ctrlGridEventUpdater.PlaceName = PlaceName; ctrlGridEventUpdater.GridId = grdMain.GridClientContainerId; MainMetaToolbar.ClassName = ClassName; MainMetaToolbar.ViewName = ViewName; MainMetaToolbar.PlaceName = PlaceName; MainMetaToolbar.DataBind(); }
/// <summary> /// Preupdates inside transaction. /// </summary> /// <param name="context">The context.</param> protected override void PreUpdateInsideTransaction(BusinessContext context) { base.PreUpdateInsideTransaction(context); // Check that the value of WorkspacePersonalization property changed from True to False CustomizationProfileEntity entity = (CustomizationProfileEntity)BusinessManager.Load(CustomizationProfileEntity.ClassName, context.GetTargetPrimaryKeyId().Value); if (entity != null && (bool)entity.WorkspacePersonalization && !(bool)context.Request.Target.Properties[CustomizationProfileEntity.FieldWorkspacePersonalization].Value) { int profileId = (int)context.GetTargetPrimaryKeyId().Value; List<string> users = new List<string>(); if (profileId > 0) { // Get users by profile FilterElementCollection fec = new FilterElementCollection(); fec.Add(FilterElement.EqualElement(CustomizationProfileUserEntity.FieldProfileId, profileId)); foreach (CustomizationProfileUserEntity user in BusinessManager.List(CustomizationProfileUserEntity.ClassName, fec.ToArray())) users.Add(user.PrimaryKeyId.Value.ToString()); } else // default profile { // 1. Get list all users using (IDataReader reader = Mediachase.IBN.Business.User.GetListAll()) { while (reader.Read()) users.Add(reader["UserId"].ToString()); } // 2. Exclude users with non-default profile EntityObject[] entityList = BusinessManager.List(CustomizationProfileUserEntity.ClassName, (new FilterElementCollection()).ToArray()); foreach (CustomizationProfileUserEntity puEntity in entityList) { users.Remove(puEntity.PrincipalId.ToString()); } } // Remove CustomPages for all users in Profile FilterElementCollection filters = new FilterElementCollection(); OrBlockFilterElement orBlock = new OrBlockFilterElement(); foreach (string userId in users) orBlock.ChildElements.Add(FilterElement.EqualElement(CustomPageEntity.FieldUserId, userId)); filters.Add(orBlock); foreach (EntityObject page in BusinessManager.List(CustomPageEntity.ClassName, filters.ToArray())) BusinessManager.Delete(page); } }
private DataTable genSource(string text, out int totalCount) { DataTable dt = new DataTable(); dt.Locale = CultureInfo.InvariantCulture; dt.Columns.Add(new DataColumn("PrimaryKeyId", typeof(int))); dt.Columns.Add(new DataColumn(TitleFieldName, typeof(string))); MetaClass mc = MetaDataWrapper.ResolveMetaClassByNameOrCardName(ClassName); FilterElementCollection fec = new FilterElementCollection(); fec.Add(new FilterElement(mc.TitleFieldName, FilterElementType.Contains, text)); if (!String.IsNullOrEmpty(CardFilter)) { string[] mas = CardFilter.Split(new string[] { "," }, StringSplitOptions.RemoveEmptyEntries); if(mas.Length>0) { OrBlockFilterElement fe = new OrBlockFilterElement(); foreach(string sCard in mas) fe.ChildElements.Add(FilterElement.EqualElement("Card", sCard.Trim())); fec.Add(fe); } } MetaObject[] list = MetaObject.List(mc, fec, new SortingElementCollection(SortingElement.Ascending(mc.TitleFieldName))); int count = 0; foreach (MetaObject bo in list) { DataRow row = dt.NewRow(); row["PrimaryKeyId"] = bo.PrimaryKeyId; row[TitleFieldName] = bo.Properties[mc.TitleFieldName].Value.ToString(); dt.Rows.Add(row); count++; if (count > 10) break; } totalCount = list.Length; return dt; }