コード例 #1
0
        public void OrderChange(string newLayout, string contextKey)
        {
            LayoutContextKey key = UtilHelper.JsonDeserialize <LayoutContextKey>(contextKey);

            if (!key.IsAdmin)
            {
                key.ProfileId = null;
                key.UserId    = Mediachase.IBN.Business.Security.CurrentUser.UserID;
            }

            CustomPageEntity page = CustomPageManager.GetCustomPage(key.PageUid, key.ProfileId, key.UserId);

            if (page == null)
            {
                throw new ArgumentException(String.Format("Cant read setting for page: {0}", key.PageUid));
            }

            if (!(key.IsAdmin || Mediachase.Ibn.Business.Customization.ProfileManager.CheckPersonalization()))
            {
                UserLightPropertyCollection pc = Mediachase.IBN.Business.Security.CurrentUser.Properties;
                pc["userCollapseExpand_" + key.PageUid.ToString("N")] = newLayout;
            }
            else
            {
                CustomPageManager.UpdateCustomPage(key.PageUid, newLayout, page.TemplateId, key.ProfileId, key.UserId);
            }
        }
コード例 #2
0
        /// <summary>
        /// Performs the save data.
        /// </summary>
        private void PerformSaveData()
        {
            string[] Ids = GetCheckedItems();

            List <CpInfo> userList = new List <CpInfo>();

            CustomPageEntity page = null;

            if (!this.IsAdmin)
            {
                page = CustomPageManager.GetCustomPage(PageUid, null, Mediachase.IBN.Business.Security.CurrentUser.UserID);
            }
            else
            {
                page = CustomPageManager.GetCustomPage(PageUid, ProfileId, UserId);
            }
            string userData    = page.JsonData;
            Guid   templateUid = page.TemplateId;

            userList = UtilHelper.JsonDeserialize <List <CpInfo> >(userData.Replace("\\", ""));

            foreach (CpInfo cpItem in userList)
            {
                if (cpItem.Id == this.ColumnId)
                {
                    foreach (string id in Ids)
                    {
                        CpInfoItem newItem = new CpInfoItem();
                        newItem.Collapsed   = "false";
                        newItem.Id          = id;
                        newItem.InstanseUid = Guid.NewGuid().ToString("N");
                        cpItem.Items.Add(newItem);
                    }
                }
            }

            string newJsonData = UtilHelper.JsonSerialize(userList);

            //Perform save to storage
            if (!IsAdmin)
            {
                CustomPageManager.UpdateCustomPage(PageUid, newJsonData, templateUid, null, Mediachase.IBN.Business.Security.UserID);
            }
            else
            {
                CustomPageManager.UpdateCustomPage(PageUid, newJsonData, templateUid, ProfileId, UserId);
            }
        }
コード例 #3
0
        /// <summary>
        /// Performs the save data.
        /// </summary>
        /// <param name="page">The page.</param>
        private void PerformSaveData(CustomPageEntity page)
        {
            string userData    = page.JsonData;
            Guid   templateUid = page.TemplateId;

            List <CpInfo> userList = UtilHelper.JsonDeserialize <List <CpInfo> >(userData.Replace("\\", ""));

            string jsonData = UtilHelper.JsonSerialize(userList);

            //Perform save to storage
            if (!IsAdmin)
            {
                CustomPageManager.UpdateCustomPage(PageUid, jsonData, templateUid, null, Mediachase.IBN.Business.Security.UserID);
            }
            else
            {
                CustomPageManager.UpdateCustomPage(PageUid, jsonData, templateUid, ProfileId, UserId);
            }
        }
コード例 #4
0
        /// <summary>
        /// Performs the save template.
        /// </summary>
        private void PerformSaveTemplate()
        {
            CustomPageEntity page = null;

            if (!IsAdmin)
            {
                page = CustomPageManager.GetCustomPage(PageUid, null, Mediachase.IBN.Business.Security.CurrentUser.UserID);
            }
            else
            {
                page = CustomPageManager.GetCustomPage(PageUid, ProfileId, UserId);
            }

            if (!IsAdmin)
            {
                CustomPageManager.UpdateCustomPage(PageUid, page.JsonData, new Guid(this.selectedUid), null, Mediachase.IBN.Business.Security.UserID);
            }
            else
            {
                CustomPageManager.UpdateCustomPage(PageUid, page.JsonData, new Guid(this.selectedUid), ProfileId, UserId);
            }
        }
コード例 #5
0
        public void Delete(string newLayout, string contextKey)
        {
            //ToDo: Clear ControlProperties collection for deleted node (do it in provider)
            LayoutContextKey key = UtilHelper.JsonDeserialize <LayoutContextKey>(contextKey);

            if (!key.IsAdmin)
            {
                key.ProfileId = null;
                key.UserId    = Mediachase.IBN.Business.Security.CurrentUser.UserID;
            }

            CustomPageEntity page = CustomPageManager.GetCustomPage(key.PageUid, key.ProfileId, key.UserId);

            if (page == null)
            {
                throw new ArgumentException(String.Format("Cant read setting for page: {0}", key.PageUid));
            }


            if (!key.IsAdmin)
            {
                List <CpInfo> list = UtilHelper.JsonDeserialize <List <CpInfo> >(page.JsonData);
                foreach (CpInfo item in list)
                {
                    foreach (CpInfoItem internalItem in item.Items)
                    {
                        if (!newLayout.Contains(internalItem.InstanseUid))
                        {
                            //ToDo: make method to get "wrapControl{0}_{1}"
                            ControlProperties.Provider.DeleteValue(String.Format("wrapControl{0}_{1}", internalItem.Id.ToLower().Replace("-", ""), internalItem.InstanseUid));
                        }
                    }
                }
            }

            CustomPageManager.UpdateCustomPage(key.PageUid, newLayout, page.TemplateId, key.ProfileId, key.UserId);
        }
コード例 #6
0
        /// <summary>
        /// Handles the ItemCommand event of the grdMain control.
        /// </summary>
        /// <param name="source">The source of the event.</param>
        /// <param name="e">The <see cref="System.Web.UI.WebControls.DataGridCommandEventArgs"/> instance containing the event data.</param>
        void grdMain_ItemCommand(object source, DataGridCommandEventArgs e)
        {
            if (e.CommandName == "Add")
            {
                string        Ids      = e.CommandArgument.ToString();
                List <CpInfo> userList = new List <CpInfo>();

                CustomPageEntity page = null;
                if (!this.IsAdmin)
                {
                    page = CustomPageManager.GetCustomPage(PageUid, null, Mediachase.IBN.Business.Security.CurrentUser.UserID);
                }
                else
                {
                    page = CustomPageManager.GetCustomPage(PageUid, ProfileId, UserId);
                }

                string userData    = page.JsonData;
                Guid   templateUid = page.TemplateId;

                List <ColumnInfo> list = new List <ColumnInfo>();
                if (this.IsAdmin)
                {
                    WorkspaceTemplateInfo wti = WorkspaceTemplateFactory.GetTemplateInfo(templateUid.ToString());
                    list = UtilHelper.JsonDeserialize <List <ColumnInfo> >(wti.ColumnInfo);
                }
                userList = UtilHelper.JsonDeserialize <List <CpInfo> >(userData.Replace("\\", ""));

                List <string> currentColumnsId = new List <string>();
                foreach (CpInfo cpItem in userList)
                {
                    currentColumnsId.Add(cpItem.Id);
                }

                List <CpInfo> newUserList = new List <CpInfo>();
                newUserList.AddRange(userList);

                if (this.IsAdmin)
                {
                    foreach (CpInfo cpItem in userList)
                    {
                        foreach (ColumnInfo info in list)
                        {
                            if (currentColumnsId.Contains(info.Id))
                            {
                                continue;
                            }

                            CpInfo cInfo = new CpInfo();
                            cInfo.Id    = info.Id;
                            cInfo.Items = new List <CpInfoItem>();
                            newUserList.Add(cInfo);
                        }
                    }
                }

                foreach (CpInfo cpItem in newUserList)
                {
                    if (cpItem.Id == this.ColumnId)
                    {
                        CpInfoItem newItem = new CpInfoItem();
                        newItem.Collapsed   = "false";
                        newItem.Id          = Ids;
                        newItem.InstanseUid = Guid.NewGuid().ToString("N");
                        cpItem.Items.Add(newItem);
                    }
                }

                string newJsonData = UtilHelper.JsonSerialize(newUserList);

                // Perform save to storage
                if (!IsAdmin)
                {
                    CustomPageManager.UpdateCustomPage(PageUid, newJsonData, templateUid, null, Mediachase.IBN.Business.Security.UserID);
                }
                else
                {
                    CustomPageManager.UpdateCustomPage(PageUid, newJsonData, templateUid, ProfileId, UserId);
                }

                divTemplateUpdate.Style.Add(HtmlTextWriterStyle.Display, "block");
                this.ForcePostback = true;
            }
        }
コード例 #7
0
        /// <summary>
        /// Templates the change.
        /// </summary>
        /// <param name="page">The page.</param>
        private void TemplateChange(CustomPageEntity page)
        {
            string userSettings = page.JsonData;

            List <CpInfo> list = UtilHelper.JsonDeserialize <List <CpInfo> >(userSettings);

            WorkspaceTemplateInfo wti = WorkspaceTemplateFactory.GetTemplateInfo(this.selectedUid.ToString());

            if (wti == null)
            {
                throw new NullReferenceException(String.Format("Cant find template: {0}", this.selectedUid));
            }

            List <ColumnInfo> templateColumn = UtilHelper.JsonDeserialize <List <ColumnInfo> >(wti.ColumnInfo);

            if (templateColumn.Count == 0)
            {
                throw new ArgumentException("Template must contain minumum 1 column");
            }

            if (list.Count == 0)
            {
                throw new ArgumentException("Invalid workspace personalize data");
            }

            int       counter      = 0;
            ArrayList deletedItems = new ArrayList();

            foreach (CpInfo info in list)
            {
                if (!templateColumn.Contains(new ColumnInfo(info.Id)))
                {
                    info.Id = templateColumn[0].Id;

                    if (counter > 0)
                    {
                        foreach (CpInfoItem item in info.Items)
                        {
                            list[0].Items.Add(item);
                        }

                        deletedItems.Add(info);
                    }
                }

                counter++;
            }

            if (deletedItems.Count > 0)
            {
                foreach (CpInfo info in deletedItems)
                {
                    list.Remove(info);
                }
            }

            string jsonData = UtilHelper.JsonSerialize(list);

            if (!this.IsAdmin)
            {
                CustomPageManager.UpdateCustomPage(PageUid, jsonData, this.selectedUid, null, Mediachase.IBN.Business.Security.UserID);
            }
            else
            {
                CustomPageManager.UpdateCustomPage(PageUid, jsonData, this.selectedUid, ProfileId, UserId);
            }
        }
コード例 #8
0
        /// <summary>
        /// Gets the ids for control place.
        /// </summary>
        /// <param name="id">The id.</param>
        /// <returns></returns>
        String GetIdsForControlPlace(string id)
        {
            String retVal       = String.Empty;
            string userSettings = string.Empty;

            // using if getting old settings from database(controls without instanceUid)
            bool _updateUidFlag = false;

            CustomPageEntity page = null;

            if (!IsAdmin)
            {
                page = CustomPageManager.GetCustomPage(PageUid, null, Mediachase.IBN.Business.Security.CurrentUser.UserID);
            }
            else
            {
                page = CustomPageManager.GetCustomPage(PageUid, ProfileId, UserId);
            }
            userSettings = page.JsonData;

            List <CpInfo> list = UtilHelper.JsonDeserialize <List <CpInfo> >(userSettings);

            foreach (CpInfo cpInfo in list)
            {
                if (cpInfo.Id == id)
                {
                    for (int i = 0; i < cpInfo.Items.Count; i++)
                    {
                        if (String.IsNullOrEmpty(cpInfo.Items[i].InstanseUid))
                        {
                            cpInfo.Items[i].InstanseUid = Guid.NewGuid().ToString("N");
                            _updateUidFlag = true;
                        }
                        retVal += String.Format("{0}^{1}^{2}:", cpInfo.Items[i].Id, cpInfo.Items[i].Collapsed, cpInfo.Items[i].InstanseUid);                         //cpInfo.Items[i].Id + ":";
                    }
                }
            }

            #region Update InstanceUid to database
            if (_updateUidFlag)
            {
                string userData = UtilHelper.JsonSerialize(list);

                if (!IsAdmin)
                {
                    CustomPageManager.UpdateCustomPage(PageUid, userData, page.TemplateId, null, Mediachase.IBN.Business.Security.CurrentUser.UserID);
                }
                else
                {
                    CustomPageManager.UpdateCustomPage(PageUid, userData, page.TemplateId, ProfileId, UserId);
                }
            }
            #endregion


            if (retVal.Length > 0)
            {
                retVal = retVal.TrimEnd(':');
            }

            return(retVal);
        }