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); } }
/// <summary> /// Handles the ServerClick event of the btnAddAndClose control. /// </summary> /// <param name="sender">The source of the event.</param> /// <param name="e">The <see cref="System.EventArgs"/> instance containing the event data.</param> void btnAddAndClose_ServerClick(object sender, EventArgs e) { CustomPageEntity page = null; if (!this.IsAdmin) { page = CustomPageManager.GetCustomPage(PageUid, null, Mediachase.IBN.Business.Security.CurrentUser.UserID); } else { page = CustomPageManager.GetCustomPage(PageUid, ProfileId, UserId); } // if template is changed we should recalculate control places and save data if (page.TemplateId != this.selectedUid) { TemplateChange(page); } else // else just save data (to ensure that changes are made for appropriate layer) { PerformSaveData(page); } this.ForcePostback = true; CommandParameters cp = new CommandParameters("MC_Workspace_EditTemplate"); Mediachase.Ibn.Web.UI.WebControls.CommandHandler.RegisterCloseOpenedFrameScript(this.Page, cp.ToString()); }
private void BindTitle() { CustomPageEntity page = CustomPageManager.GetCustomPage(PageUid, (int?)ProfileId, (int?)UserId); if (page != null) { ctrlTitleText.Text = page.Title; } }
protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack && !String.IsNullOrEmpty(Request["PageUid"])) { CustomPageEntity page = CustomPageManager.GetCustomPage(new Guid(Request["PageUid"]), null, Mediachase.IBN.Business.Security.CurrentUser.UserID); if (page != null) { pT.Title = CHelper.GetResFileString(page.Title); } } }
/// <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); } }
/// <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); } }
/// <summary> /// Raises the <see cref="E:System.Web.UI.Control.Init"></see> event. /// </summary> /// <param name="e">An <see cref="T:System.EventArgs"></see> object that contains the event data.</param> protected override void OnInit(EventArgs e) { base.OnInit(e); string valueData = string.Empty; string valueTemplate = string.Empty; CustomPageEntity page = null; if (!this.IsAdmin) { page = CustomPageManager.GetCustomPage(PageUid, null, (PrimaryKeyId)Mediachase.IBN.Business.Security.CurrentUser.UserID); } else { page = CustomPageManager.GetCustomPage(PageUid, ProfileId, UserId); // CHelper.AddToContext("pageUid", this.PageUid); } cpManager.DataSource = page.TemplateId.ToString(); cpManager.PageUid = this.PageUid; cpManagerExtender.PageUid = this.PageUid; cpManagerExtender.IsAdmin = this.IsAdmin; LayoutContextKey key = new LayoutContextKey(this.PageUid, this.IsAdmin); if (IsAdmin) { key.ProfileId = ProfileId; key.UserId = UserId; } cpManagerExtender.ContextKey = key; cpManager.IsAdmin = this.IsAdmin; if (!IsPostBack) { cpManager.DataBind(); } }
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); }
/// <summary> /// Binds the rep templates. /// </summary> private void BindRepTemplates() { if (this.selectedUid == Guid.Empty) { CustomPageEntity page = null; if (!this.IsAdmin) { page = CustomPageManager.GetCustomPage(PageUid, null, Mediachase.IBN.Business.Security.CurrentUser.UserID); } else { page = CustomPageManager.GetCustomPage(PageUid, ProfileId, UserId); } this.selectedUid = page.TemplateId; } repTemplates.DataSource = GenTemplatesDataSource(); repTemplates.DataBind(); foreach (RepeaterItem item in repTemplates.Items) { Button btn = (Button)item.FindControl("btnCommand"); HtmlGenericControl div = (HtmlGenericControl)item.FindControl("mainItemDiv"); if (btn != null && div != null) { if (new Guid(btn.CommandArgument.ToString()) == this.selectedUid) { div.Attributes.Add("class", "customizeWSTemplateItemSelected"); } div.Attributes.Add("onclick", this.Page.ClientScript.GetPostBackEventReference(btn, btn.CommandArgument)); } } }
/// <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; } }
/// <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); }