Exemple #1
0
        /// <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();
        }
Exemple #3
0
        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();
            }
        }
Exemple #4
0
        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();
        }
Exemple #5
0
        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();
            }
        }
Exemple #6
0
        /// <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);
                }
            }
        }
Exemple #7
0
        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();
        }
        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()));
            }
        }
        public static CustomerContact GetOwner(string marketId, out bool foundOne)
        {
            //ToDo: create the field in BF for the contact
            // ...may not need the "out-part"
            FilterElementCollection fc = new FilterElementCollection
            {
                FilterElement.EqualElement("MarketToOwn", marketId)
            };

            EntityObject[] result = BusinessManager.List(CustomerContact.ClassName, fc.ToArray(), null);

            if (result != null)
            {
                if (result.Count() == 1)
                {
                    // got the contact
                    foundOne = true;
                    return((CustomerContact)result.FirstOrDefault());
                }
                else
                {
                }        // could be several owners, need some action
            }
            else
            {
            }        // empty

            foundOne = false;
            return(null);
        }
Exemple #10
0
        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);
        }
Exemple #11
0
        /// <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);
                }
            }
        }
Exemple #12
0
        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;
        }
Exemple #13
0
        /// <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();
        }
Exemple #14
0
        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);
        }
        /// <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 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();
        }
Exemple #17
0
        /// <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;
        }
Exemple #18
0
        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();
        }
Exemple #19
0
        public static mcweb_ReportAceRow[] List(FilterElementCollection filters, SortingElementCollection sorting)
        {
            ArrayList list = new ArrayList();

            using (IDataReader reader = DataHelper.List("mcweb_ReportAce", filters, sorting))
            {
                while (reader.Read())
                {
                    list.Add(new mcweb_ReportAceRow(reader));
                }
            }
            return((mcweb_ReportAceRow[])list.ToArray(typeof(mcweb_ReportAceRow)));
        }
        public static SynchronizationReplicaRow[] List(FilterElementCollection filters, SortingElementCollection sorting)
        {
            ArrayList list = new ArrayList();

            using (IDataReader reader = DataHelper.List("SYNCHRONIZATION_REPLICA", filters, sorting))
            {
                while (reader.Read())
                {
                    list.Add(new SynchronizationReplicaRow(reader));
                }
            }
            return((SynchronizationReplicaRow[])list.ToArray(typeof(SynchronizationReplicaRow)));
        }
        public static OutgoingEmailServiceConfigRow[] List(FilterElementCollection filters, SortingElementCollection sorting)
        {
            ArrayList list = new ArrayList();

            using (IDataReader reader = DataHelper.List("OutgoingEmailServiceConfig", filters, sorting))
            {
                while (reader.Read())
                {
                    list.Add(new OutgoingEmailServiceConfigRow(reader));
                }
            }
            return((OutgoingEmailServiceConfigRow[])list.ToArray(typeof(OutgoingEmailServiceConfigRow)));
        }
        public static WebDavStorageElementPropertiesRow[] List(FilterElementCollection filters, SortingElementCollection sorting)
        {
            ArrayList list = new ArrayList();

            using (IDataReader reader = DataHelper.List("WebDavStorageElementProperties", filters, sorting))
            {
                while (reader.Read())
                {
                    list.Add(new WebDavStorageElementPropertiesRow(reader));
                }
            }
            return((WebDavStorageElementPropertiesRow[])list.ToArray(typeof(WebDavStorageElementPropertiesRow)));
        }
Exemple #23
0
        public static SmtpBoxRow[] List(FilterElementCollection filters, SortingElementCollection sorting)
        {
            ArrayList list = new ArrayList();

            using (IDataReader reader = DataHelper.List("SmtpBox", filters, sorting))
            {
                while (reader.Read())
                {
                    list.Add(new SmtpBoxRow(reader));
                }
            }
            return((SmtpBoxRow[])list.ToArray(typeof(SmtpBoxRow)));
        }
        public static WorkflowParticipantRow[] List(FilterElementCollection filters, SortingElementCollection sorting)
        {
            ArrayList list = new ArrayList();

            using (IDataReader reader = DataHelper.List("WorkflowParticipant", filters, sorting))
            {
                while (reader.Read())
                {
                    list.Add(new WorkflowParticipantRow(reader));
                }
            }
            return((WorkflowParticipantRow[])list.ToArray(typeof(WorkflowParticipantRow)));
        }
 private static void DeepRemoveFilter(FilterElementCollection filterColl, FilterElement toRemoveFilter)
 {
     if (filterColl.Contains(toRemoveFilter))
     {
         filterColl.Remove(toRemoveFilter);
     }
     foreach (FilterElement filterEl in filterColl)
     {
         if (filterEl.HasChildElements)
         {
             DeepRemoveFilter(filterEl.ChildElements, toRemoveFilter);
         }
     }
 }
        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();
            }
        }
Exemple #27
0
        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;
        }
Exemple #28
0
        /// <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();
        }
Exemple #30
0
        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>
        /// Возвращает список событий как виртуальных так и реальных.
        /// </summary>
        /// <param name="filterColl">The filter coll.</param>
        /// <param name="request">The request.</param>
        /// <returns></returns>
        private static IEnumerable <CalendarEventEntity> ListEvents(FilterElementCollection filterColl, CalendarEventListRequest request)
        {
            McEvent mcEvent = null;
            //Конструируем стандартный запрос LIST без критериев содержащих дату начала и конца события
            ListRequest moListRequest = (ListRequest)EventHelper.ConstructRequest <ListRequest>(request.Target, true);

            moListRequest.Filters = filterColl.ToArray();
            moListRequest.Sorting = request.Sorting;
            //выполняем стандартный запрос
            ListResponse listResp = (ListResponse)BusinessManager.Execute(moListRequest);

            if (listResp != null && listResp.EntityObjects != null)
            {
                //Пробегаем по реальным events
                foreach (CalendarEventEntity entity in listResp.EntityObjects)
                {
                    mcEvent = EventHelper.LoadCalEvent(entity.PrimaryKeyId.Value);
                    if (mcEvent.IsReccuring)
                    {
                        iCalDateTime dtReccurBase = mcEvent.DTStart;
                        //Пробегаем по виртуальным events
                        foreach (Occurrence occur in mcEvent.GetOccurrences(mcEvent.DTStart, mcEvent.RecurrenceSeriesEndDate))
                        {
                            //Создаем виртуальные события
                            VirtualEventId vEventId = (VirtualEventId)entity.PrimaryKeyId;
                            vEventId.RecurrenceId = EventHelper.iCalDateTime2Recurrence(dtReccurBase, occur.Period.StartTime);
                            //Set virtual id
                            mcEvent.UID = vEventId.ToString();
                            //Set recurrence-ID
                            mcEvent.Recurrence_ID = occur.Period.StartTime;
                            mcEvent.DTStart       = occur.Period.StartTime;
                            mcEvent.DTEnd         = occur.Period.EndTime;
                            EntityObjectHierarchy recurrenceEntity = EventHelper.ConstructEntityHierarchy(mcEvent);
                            CalendarEventEntity   occurEventEntity = recurrenceEntity.InnerEntity as CalendarEventEntity;
                            if (occurEventEntity != null)
                            {
                                yield return(occurEventEntity);
                            }
                        }
                    }
                    else
                    {
                        yield return(entity);
                    }
                }
            }
        }
Exemple #32
0
        /// <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");
                    }
                }

            }
        }
Exemple #33
0
        /// <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);
        }
        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);
        }
        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);
            }
        }
Exemple #36
0
        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>
        /// 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()));
        }
Exemple #38
0
        /// <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 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);
        }
        /// <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());
        }
Exemple #41
0
        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();
        }
        /// <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);
            }
        }
Exemple #43
0
        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;
        }
Exemple #44
0
        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;
        }
Exemple #45
0
        /// <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);
        }
        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;
        }
Exemple #48
0
        public static WorkflowParticipantRow[] List(FilterElementCollection filters, SortingElementCollection sorting, int start, int count)
        {
            ArrayList list = new ArrayList();

               using (IDataReader reader = DataHelper.List("WorkflowParticipant", filters, sorting))
               {
              while (reader.Read() && count > 0)
              {
                  if (start == 0)
                  {
                      list.Add(new WorkflowParticipantRow(reader));

                      count--;
                  }
                  else start--;
              }
               }
               return (WorkflowParticipantRow[])list.ToArray(typeof(WorkflowParticipantRow));
        }
 public static IDataReader GetReader(FilterElementCollection filters, SortingElementCollection sorting)
 {
     return DataHelper.List("SYNCHRONIZATION_METADATA", filters, sorting);
 }
        public static OutgoingEmailServiceConfigRow[] List(FilterElementCollection filters, SortingElementCollection sorting, int start, int count)
        {
            ArrayList list = new ArrayList();

               using (IDataReader reader = DataHelper.List("OutgoingEmailServiceConfig", filters, sorting))
               {
              while (reader.Read() && count > 0)
              {
                  if (start == 0)
                  {
                      list.Add(new OutgoingEmailServiceConfigRow(reader));

                      count--;
                  }
                  else start--;
              }
               }
               return (OutgoingEmailServiceConfigRow[])list.ToArray(typeof(OutgoingEmailServiceConfigRow));
        }
 public static IDataReader GetReader(FilterElementCollection filters, SortingElementCollection sorting)
 {
     return DataHelper.List("WebDavStorageElementProperties", filters, sorting);
 }
Exemple #52
0
        public static DataTable GetListIncidentsByFilterDataTable(string keyword, FilterElementCollection fec,
			FilterElementCollection fecAbove)
        {
            #region Variables
            int projId = 0; int iManId = 0; int iRespId = 0; int iCreatorId = 0; int iResId = 0;
            int priority_id = -1; int issbox_id = 0; int type_id = 0;
            PrimaryKeyId orgUid = PrimaryKeyId.Empty;
            PrimaryKeyId contactUid = PrimaryKeyId.Empty;
            int state_id = 0; int severity_id = 0; int genCategory_type = 0; int issCategory_type = 0;
            bool isUnansweredOnly = false; bool isOverdueOnly = false;
            #endregion

            foreach (FilterElement fe in fec)
            {
                string source = fe.Source;
                string value = fe.Value.ToString();
                if (fe.ValueIsTemplate)
                    value = TemplateResolver.ResolveAll(value);
                #region BindVariables
                switch (source)
                {
                    case Incident.ProjectFilterKey:
                        projId = int.Parse(value);
                        break;
                    case Incident.ManagerFilterKey:
                        iManId = int.Parse(value);
                        break;
                    case Incident.ResponsibleFilterKey:
                        iRespId = int.Parse(value);
                        break;
                    case Incident.CreatorFilterKey:
                        iCreatorId = int.Parse(value);
                        break;
                    case Incident.PriorityFilterKey:
                        priority_id = int.Parse(value);
                        break;
                    case Incident.IssueBoxFilterKey:
                        issbox_id = int.Parse(value);
                        break;
                    case Incident.TypeFilterKey:
                        type_id = int.Parse(value);
                        break;
                    case Incident.ClientFilterKey:
                        GetContactId(value, out orgUid, out contactUid);
                        break;
                    case Incident.StatusFilterKey:
                        state_id = int.Parse(value);
                        break;
                    case Incident.SeverityFilterKey:
                        severity_id = int.Parse(value);
                        break;
                    case Incident.GenCategoryTypeFilterKey:
                        genCategory_type = int.Parse(value);
                        break;
                    case Incident.GenCategoriesFilterKey:
                        ArrayList alGenCats = new ArrayList();
                        string[] mas = value.Split(new string[] { ";" }, StringSplitOptions.RemoveEmptyEntries);
                        foreach (string s in mas)
                        {
                            if (!alGenCats.Contains(int.Parse(s)))
                                alGenCats.Add(int.Parse(s));
                        }
                        Incident.SaveGeneralCategories(alGenCats);
                        break;
                    case Incident.IssueCategoryTypeFilterKey:
                        issCategory_type = int.Parse(value);
                        break;
                    case Incident.IssueCategoriesFilterKey:
                        ArrayList alIssCats = new ArrayList();
                        string[] masIss = value.Split(new string[] { ";" }, StringSplitOptions.RemoveEmptyEntries);
                        foreach (string s in masIss)
                        {
                            if (!alIssCats.Contains(int.Parse(s)))
                                alIssCats.Add(int.Parse(s));
                        }
                        Incident.SaveIncidentCategories(alIssCats);
                        break;
                    case Incident.UnansweredFilterKey:
                        if (bool.Parse(value))
                            isUnansweredOnly = true;
                        break;
                    case Incident.OverdueFilterKey:
                        if (bool.Parse(value))
                            isOverdueOnly = true;
                        break;
                    default:
                        break;
                }
                #endregion
            }

            foreach (FilterElement fe in fecAbove)
            {
                string source = fe.Source;
                string value = fe.Value.ToString();
                if (fe.ValueIsTemplate)
                    value = TemplateResolver.ResolveAll(value);
                #region BindVariables
                switch (source)
                {
                    case Incident.ProjectFilterKey:
                        projId = int.Parse(value);
                        break;
                    case Incident.ManagerFilterKey:
                        iManId = int.Parse(value);
                        break;
                    case Incident.ResponsibleFilterKey:
                        iRespId = int.Parse(value);
                        break;
                    case Incident.CreatorFilterKey:
                        iCreatorId = int.Parse(value);
                        break;
                    case Incident.PriorityFilterKey:
                        priority_id = int.Parse(value);
                        break;
                    case Incident.IssueBoxFilterKey:
                        issbox_id = int.Parse(value);
                        break;
                    case Incident.TypeFilterKey:
                        type_id = int.Parse(value);
                        break;
                    case Incident.ClientFilterKey:
                        GetContactId(value, out orgUid, out contactUid);
                        break;
                    case Incident.StatusFilterKey:
                        state_id = int.Parse(value);
                        break;
                    case Incident.SeverityFilterKey:
                        severity_id = int.Parse(value);
                        break;
                    case Incident.GenCategoryTypeFilterKey:
                        genCategory_type = int.Parse(value);
                        break;
                    case Incident.GenCategoriesFilterKey:
                        ArrayList alGenCats = new ArrayList();
                        string[] mas = value.Split(new string[] { ";" }, StringSplitOptions.RemoveEmptyEntries);
                        foreach (string s in mas)
                        {
                            if (!alGenCats.Contains(int.Parse(s)))
                                alGenCats.Add(int.Parse(s));
                        }
                        Incident.SaveGeneralCategories(alGenCats);
                        break;
                    case Incident.IssueCategoryTypeFilterKey:
                        issCategory_type = int.Parse(value);
                        break;
                    case Incident.IssueCategoriesFilterKey:
                        ArrayList alIssCats = new ArrayList();
                        string[] masIss = value.Split(new string[] { ";" }, StringSplitOptions.RemoveEmptyEntries);
                        foreach (string s in masIss)
                        {
                            if (!alIssCats.Contains(int.Parse(s)))
                                alIssCats.Add(int.Parse(s));
                        }
                        Incident.SaveIncidentCategories(alIssCats);
                        break;
                    case Incident.UnansweredFilterKey:
                        if (bool.Parse(value))
                            isUnansweredOnly = true;
                        else
                            isUnansweredOnly = false;
                        break;
                    case Incident.OverdueFilterKey:
                        if (bool.Parse(value))
                            isOverdueOnly = true;
                        else
                            isOverdueOnly = false;
                        break;
                    default:
                        break;
                }
                #endregion
            }

            DataTable dt = DBIncident.GetListIncidentsByFilterDataTable(projId, iManId,
                iCreatorId, iResId, iRespId, orgUid, contactUid, issbox_id, priority_id,
                type_id, state_id, severity_id, keyword,
                Security.CurrentUser.UserID, Security.CurrentUser.TimeZoneId,
                Security.CurrentUser.LanguageId, genCategory_type, issCategory_type);

            if (isUnansweredOnly)
            {
                DataTable dtClone = dt.Clone();
                foreach (DataRow dr in dt.Rows)
                {
                    if ((bool)dr["IsNewMessage"])
                    {
                        DataRow drNew = dtClone.NewRow();
                        drNew.ItemArray = dr.ItemArray;
                        dtClone.Rows.Add(drNew);
                    }
                }
                dt = dtClone.Copy();
            }
            if (isOverdueOnly)
            {
                DataTable dtClone = dt.Clone();
                foreach (DataRow dr in dt.Rows)
                {
                    if ((bool)dr["IsOverdue"])
                    {
                        DataRow drNew = dtClone.NewRow();
                        drNew.ItemArray = dr.ItemArray;
                        dtClone.Rows.Add(drNew);
                    }
                }
                dt = dtClone.Copy();
            }
            return dt;
        }
Exemple #53
0
        /// <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;
        }
Exemple #54
0
        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);
                }
            }
        }
        public static SynchronizationMetadataRow[] List(FilterElementCollection filters, SortingElementCollection sorting, int start, int count)
        {
            ArrayList list = new ArrayList();

               using (IDataReader reader = DataHelper.List("SYNCHRONIZATION_METADATA", filters, sorting))
               {
              while (reader.Read() && count > 0)
              {
                  if (start == 0)
                  {
                      list.Add(new SynchronizationMetadataRow(reader));

                      count--;
                  }
                  else start--;
              }
               }
               return (SynchronizationMetadataRow[])list.ToArray(typeof(SynchronizationMetadataRow));
        }
Exemple #56
0
 public static IDataReader GetReader(FilterElementCollection filters, SortingElementCollection sorting)
 {
     return DataHelper.List("WorkflowParticipant", filters, sorting);
 }
Exemple #57
0
        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 static IDataReader GetReader(FilterElementCollection filters, SortingElementCollection sorting)
 {
     return DataHelper.List("OutgoingEmailServiceConfig", filters, sorting);
 }
Exemple #59
0
        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);
            }
        }
        public static WebDavStorageElementPropertiesRow[] List(FilterElementCollection filters, SortingElementCollection sorting)
        {
            ArrayList list = new ArrayList();

               using (IDataReader reader = DataHelper.List("WebDavStorageElementProperties", filters, sorting))
               {
              while (reader.Read())
              {
                  list.Add(new WebDavStorageElementPropertiesRow(reader));
              }
               }
               return (WebDavStorageElementPropertiesRow[])list.ToArray(typeof(WebDavStorageElementPropertiesRow));
        }