Ejemplo n.º 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);
        }
Ejemplo n.º 2
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();
        }
        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()));
            }
        }
Ejemplo n.º 4
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);
        }
Ejemplo n.º 5
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);
                }
            }
        }
Ejemplo n.º 6
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;
        }
Ejemplo n.º 7
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);
        }
Ejemplo n.º 8
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;
        }
Ejemplo n.º 9
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);
        }
        /// <summary>
        /// Preupdates inside transaction.
        /// </summary>
        /// <param name="context">The context.</param>
        protected override void PreUpdateInsideTransaction(BusinessContext context)
        {
            base.PreUpdateInsideTransaction(context);

            // Check that the value of WorkspacePersonalization property changed from True to False
            CustomizationProfileEntity entity = (CustomizationProfileEntity)BusinessManager.Load(CustomizationProfileEntity.ClassName, context.GetTargetPrimaryKeyId().Value);
            if (entity != null
                && (bool)entity.WorkspacePersonalization
                && !(bool)context.Request.Target.Properties[CustomizationProfileEntity.FieldWorkspacePersonalization].Value)
            {
                int profileId = (int)context.GetTargetPrimaryKeyId().Value;

                List<string> users = new List<string>();

                if (profileId > 0)
                {
                    // Get users by profile
                    FilterElementCollection fec = new FilterElementCollection();
                    fec.Add(FilterElement.EqualElement(CustomizationProfileUserEntity.FieldProfileId, profileId));

                    foreach (CustomizationProfileUserEntity user in BusinessManager.List(CustomizationProfileUserEntity.ClassName, fec.ToArray()))
                        users.Add(user.PrimaryKeyId.Value.ToString());
                }
                else // default profile
                {
                    // 1. Get list all users
                    using (IDataReader reader = Mediachase.IBN.Business.User.GetListAll())
                    {
                        while (reader.Read())
                            users.Add(reader["UserId"].ToString());
                    }

                    // 2. Exclude users with non-default profile
                    EntityObject[] entityList = BusinessManager.List(CustomizationProfileUserEntity.ClassName, (new FilterElementCollection()).ToArray());
                    foreach (CustomizationProfileUserEntity puEntity in entityList)
                    {
                        users.Remove(puEntity.PrincipalId.ToString());
                    }
                }

                // Remove CustomPages for all users in Profile
                FilterElementCollection filters = new FilterElementCollection();

                OrBlockFilterElement orBlock = new OrBlockFilterElement();
                foreach (string userId in users)
                    orBlock.ChildElements.Add(FilterElement.EqualElement(CustomPageEntity.FieldUserId, userId));
                filters.Add(orBlock);

                foreach (EntityObject page in BusinessManager.List(CustomPageEntity.ClassName, filters.ToArray()))
                    BusinessManager.Delete(page);
            }
        }
Ejemplo n.º 11
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);
        }
Ejemplo n.º 12
0
        private EntityObject[] GetEntityObjectListForExport()
        {
            string variant = "0";

            if (Request["variant"] != null)
            {
                variant = Request["variant"];
            }

            SortingElementCollection sec = new SortingElementCollection();

            if (_pc[grdMain.GetPropertyKey(EntityGrid.SortingPropertyKey)] != null)
            {
                string             sort = _pc[grdMain.GetPropertyKey(EntityGrid.SortingPropertyKey)];
                SortingElementType set  = SortingElementType.Asc;
                if (sort.IndexOf(" DESC") >= 0)
                {
                    sort = sort.Substring(0, sort.IndexOf(" DESC"));
                    set  = SortingElementType.Desc;
                }

                sec.Add(new SortingElement(sort, set));
            }

            int pageSize = 10;

            if (_pc[grdMain.GetPropertyKey(EntityGrid.PageSizePropertyKey)] != null)
            {
                pageSize = Convert.ToInt32(_pc[grdMain.GetPropertyKey(EntityGrid.PageSizePropertyKey)].ToString());
                if (pageSize == -1)
                {
                    pageSize = 10000;
                }
            }
            int pageIndex = 0;

            if (_pc["EntityList_" + ClassName + "_" + _profileName + "_PageIndex"] != null)
            {
                pageIndex = int.Parse(_pc["EntityList_" + ClassName + "_" + _profileName + "_PageIndex"]);
            }

            ListViewProfile lvp = null;

            switch (variant)
            {
            case "1":                           //OnlyView
                lvp = ListViewProfile.Load(ClassName, _profileName, _placeName);
                if (sec.Count == 0)
                {
                    sec = lvp.Sorting;
                }
                return(BusinessManager.List(ClassName, lvp.Filters.ToArray(), sec.ToArray()));

            case "2":                           //Only Visible
                lvp = ListViewProfile.Load(ClassName, _profileName, _placeName);

                FilterElementCollection fec = new FilterElementCollection(lvp.Filters.ToArray());

                if (!String.IsNullOrEmpty(txtSearch.Text))
                {
                    FilterElement fe = CHelper.GetSearchFilterElementByKeyword(txtSearch.Text, ClassName);
                    fec.Add(fe);
                }

                EntityObject[]      list    = BusinessManager.List(ClassName, fec.ToArray(), sec.ToArray());
                List <EntityObject> newList = new List <EntityObject>();
                int start  = pageIndex * pageSize;
                int finish = start + pageSize;
                for (int i = start; i <= finish && i < list.Length; i++)
                {
                    newList.Add(list[i]);
                }
                return(newList.ToArray());

            case "3":                           //Only Selected
                string              values           = Request["ids"];
                string[]            selectedElements = values.Split(new string[] { ";" }, StringSplitOptions.RemoveEmptyEntries);
                List <PrimaryKeyId> listPkey         = new List <PrimaryKeyId>();
                foreach (string elem in selectedElements)
                {
                    string       id  = elem.Split(new string[] { "::" }, StringSplitOptions.RemoveEmptyEntries)[0];
                    PrimaryKeyId key = PrimaryKeyId.Parse(id);
                    if (key != PrimaryKeyId.Empty)
                    {
                        listPkey.Add(key);
                    }
                }
                FilterElementCollection fecPkey = new FilterElementCollection();
                foreach (PrimaryKeyId id in listPkey)
                {
                    FilterElement fe = FilterElement.EqualElement(FilterElement.PrimaryKeyFieldName, id);
                    fecPkey.Add(fe);
                }
                FilterElement orFilter = new OrBlockFilterElement(fecPkey.ToArray());
                fecPkey.Clear();
                fecPkey.Add(orFilter);

                return(BusinessManager.List(ClassName, fecPkey.ToArray(), sec.ToArray()));

            default:                            //All
                return(BusinessManager.List(ClassName, (new FilterElementCollection()).ToArray(), sec.ToArray()));
            }
        }
Ejemplo n.º 13
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);
        }
Ejemplo n.º 14
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);
            }
        }
Ejemplo n.º 15
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);
                }
            }
        }
Ejemplo n.º 16
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;
        }
Ejemplo n.º 17
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();
        }
Ejemplo n.º 18
0
        /// <summary>
        /// Gets the list of TimeTrackingBlockTypeInstances
        /// </summary>
        /// <returns></returns>
        public static DataTable GetBlockTypeInstances()
        {
            MetaClass mc = GetBlockTypeInstanceMetaClass();

            FilterElement orBlock = new OrBlockFilterElement();
            orBlock.ChildElements.Add(new FilterElement(BlockTypeInstanceFieldName_Project, FilterElementType.IsNull, null));
            orBlock.ChildElements.Add(FilterElement.EqualElement(BlockTypeInstanceFieldName_Status, 1));
            orBlock.ChildElements.Add(FilterElement.EqualElement(BlockTypeInstanceFieldName_Status, 5));

            TimeTrackingBlockTypeInstance[] mas = MetaObject.List<TimeTrackingBlockTypeInstance>(mc, new FilterElementCollection(orBlock), new SortingElementCollection(new SortingElement(BlockTypeFieldName_IsProject, SortingElementType.Asc), new SortingElement(BlockTypeFieldName_Title, SortingElementType.Asc)));
            DataTable dt = new DataTable();
            dt.Columns.Add(new DataColumn("Title", typeof(string)));
            dt.Columns.Add(new DataColumn("PrimaryKeyId", typeof(string)));
            dt.Columns.Add(new DataColumn("IsProject", typeof(bool)));
            DataRow dr;
            foreach (MetaObject mo in mas)
            {
                dr = dt.NewRow();
                dr["Title"] = mo.Properties[mc.TitleFieldName].Value.ToString();
                dr["PrimaryKeyId"] = mo.PrimaryKeyId.ToString();
                dr["IsProject"] = (((TimeTrackingBlockTypeInstance)mo).ProjectId != null);
                dt.Rows.Add(dr);
            }
            return dt;
        }
        /// <summary>
        /// Preupdates inside transaction.
        /// </summary>
        /// <param name="context">The context.</param>
        protected override void PreUpdateInsideTransaction(BusinessContext context)
        {
            base.PreUpdateInsideTransaction(context);

            // Check that the value of WorkspacePersonalization property changed from True to False
            CustomizationProfileEntity entity = (CustomizationProfileEntity)BusinessManager.Load(CustomizationProfileEntity.ClassName, context.GetTargetPrimaryKeyId().Value);

            if (entity != null &&
                (bool)entity.WorkspacePersonalization &&
                !(bool)context.Request.Target.Properties[CustomizationProfileEntity.FieldWorkspacePersonalization].Value)
            {
                int profileId = (int)context.GetTargetPrimaryKeyId().Value;

                List <string> users = new List <string>();

                if (profileId > 0)
                {
                    // Get users by profile
                    FilterElementCollection fec = new FilterElementCollection();
                    fec.Add(FilterElement.EqualElement(CustomizationProfileUserEntity.FieldProfileId, profileId));

                    foreach (CustomizationProfileUserEntity user in BusinessManager.List(CustomizationProfileUserEntity.ClassName, fec.ToArray()))
                    {
                        users.Add(user.PrimaryKeyId.Value.ToString());
                    }
                }
                else                 // default profile
                {
                    // 1. Get list all users
                    using (IDataReader reader = Mediachase.IBN.Business.User.GetListAll())
                    {
                        while (reader.Read())
                        {
                            users.Add(reader["UserId"].ToString());
                        }
                    }

                    // 2. Exclude users with non-default profile
                    EntityObject[] entityList = BusinessManager.List(CustomizationProfileUserEntity.ClassName, (new FilterElementCollection()).ToArray());
                    foreach (CustomizationProfileUserEntity puEntity in entityList)
                    {
                        users.Remove(puEntity.PrincipalId.ToString());
                    }
                }

                // Remove CustomPages for all users in Profile
                FilterElementCollection filters = new FilterElementCollection();

                OrBlockFilterElement orBlock = new OrBlockFilterElement();
                foreach (string userId in users)
                {
                    orBlock.ChildElements.Add(FilterElement.EqualElement(CustomPageEntity.FieldUserId, userId));
                }
                filters.Add(orBlock);

                foreach (EntityObject page in BusinessManager.List(CustomPageEntity.ClassName, filters.ToArray()))
                {
                    BusinessManager.Delete(page);
                }
            }
        }
Ejemplo n.º 20
0
        public static FilterElement[] CreateFiltersByEmail(string metaClassName, string senderEmail)
        {
            if (metaClassName == null)
                throw new ArgumentNullException("metaClassName");
            if (senderEmail == null)
                throw new ArgumentNullException("senderEmail");

            OrBlockFilterElement orBlock = new OrBlockFilterElement();

            Mediachase.Ibn.Data.Meta.Management.MetaFieldType emailType = DataContext.Current.GetMetaFieldType("EMail");

            foreach (Mediachase.Ibn.Data.Meta.Management.MetaField metaField in DataContext.Current.GetMetaClass(metaClassName).Fields)
            {
                if (metaField.GetMetaType() == emailType)
                {
                    orBlock.ChildElements.Add(FilterElement.EqualElement(metaField.Name, senderEmail));
                }
            }

            return new FilterElement[] { orBlock };
        }
Ejemplo n.º 21
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);
                }
            }
        }
Ejemplo n.º 22
0
        /// <summary>
        /// Gets the list of project TimeTrackingBlockTypeInstances
        /// </summary>
        /// <returns></returns>
        public static TimeTrackingBlockTypeInstance[] GetProjectBlockTypeInstances()
        {
            MetaClass mc = TimeTrackingManager.GetBlockTypeInstanceMetaClass();

            FilterElement orBlock = new OrBlockFilterElement();
            orBlock.ChildElements.Add(FilterElement.EqualElement("StatusId", 1));
            orBlock.ChildElements.Add(FilterElement.EqualElement("StatusId", 5));

            return MetaObject.List<TimeTrackingBlockTypeInstance>(mc,
                new FilterElementCollection(orBlock),
                new SortingElementCollection(new SortingElement("Title", SortingElementType.Asc)));
        }
Ejemplo n.º 23
0
        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()));
            }
        }