public void Invoke(object Sender, object Element) { object objectid = CHelper.GetFromContext("ObjectId"); object classNameObject = CHelper.GetFromContext("ClassName"); if (objectid != null && classNameObject != null) { PrimaryKeyId key = (PrimaryKeyId)objectid; string className = (string)classNameObject; int errorCount = 0; try { BusinessManager.Delete(className, key); } catch (Exception ex) { CHelper.GenerateErrorReport(ex); errorCount++; } if (errorCount > 0) { ((CommandManager)Sender).InfoMessage = CHelper.GetResFileString("{IbnFramework.Common:ActionWasNotProcessed}"); } else { ((Control)Sender).Page.Response.Redirect(CHelper.GetLinkEntityList(className)); } } }
protected void Page_Load(object sender, EventArgs e) { if (CHelper.GetFromContext(String.Format("{0}_MultiValue", FieldName)) != null && Value != CHelper.GetFromContext(String.Format("{0}_MultiValue", FieldName))) { List <int> lst = new List <int>((int[])CHelper.GetFromContext(String.Format("{0}_MultiValue", FieldName))); foreach (DataGridItem dgi in grdMain.Items) { foreach (Control control in dgi.Cells[1].Controls) { if (control is CheckBox) { CheckBox checkBox = (CheckBox)control; int itemId = int.Parse(dgi.Cells[0].Text); if (lst.Contains(itemId)) { checkBox.Checked = true; } } } } } }
public bool IsEnable(object Sender, object Element) { bool retval = true; object id = CHelper.GetFromContext("ListFolderId"); if (id != null) { int iid = -1; int.TryParse(id.ToString(), out iid); if (iid == -1) { retval = false; } else if (iid > 0) { if (iid == (int)ListManager.GetPublicRoot().PrimaryKeyId.Value) { return(false); } if (iid == (int)ListManager.GetPrivateRoot(Mediachase.IBN.Business.Security.CurrentUser.UserID).PrimaryKeyId.Value) { return(false); } ListFolder fld = new ListFolder(iid); if (!fld.ParentId.HasValue && fld.FolderType == ListFolderType.Project) { return(false); } } } return(retval); }
/// <summary> /// Handles the PreRenderComplete event of the Page 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 Page_PreRenderComplete(object sender, EventArgs e) { object needtodatabind = CHelper.GetFromContext("NeedToDataBind"); if (needtodatabind != null && needtodatabind.ToString() == "true") { CHelper.RemoveFromContext("NeedToDataBind"); } }
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(); }
protected override void OnItemCreated(RepeaterItemEventArgs e) { if (e.Item.ItemType == ListItemType.Item || e.Item.ItemType == ListItemType.AlternatingItem) { string sControl = ""; MetaObject mo = (MetaObject)e.Item.DataItem; if (mo != null) { string className = CHelper.GetFromContext("ClassName").ToString(); //hack IBN4.6 if (className.ToLower().Equals("timetrackingentry")) { className = "TimeTrackingBlock"; } // sControl = EventCode.GetEventControlVirtualPath("~/Apps", mo, className); if (String.IsNullOrEmpty(sControl)) { sControl = _defaultTemplate; } ViewState["Template_" + e.Item.ItemIndex.ToString()] = sControl; } else { if (ViewState["Template_" + e.Item.ItemIndex.ToString()] != null) { sControl = ViewState["Template_" + e.Item.ItemIndex.ToString()].ToString(); } else { return; } } if (String.IsNullOrEmpty(sControl)) { } else if (sControl == _defaultTemplate) { ItemTemplate = new EventDefaultTemp(ItemCssClass); } else { ItemTemplate = this.Page.LoadTemplate(sControl); } this.InitializeItem(e.Item); } base.OnItemCreated(e); }
protected void Page_PreRender(object sender, System.EventArgs e) { object rebindObj = CHelper.GetFromContext("RebindAssignments"); if (rebindObj != null && (bool)rebindObj) { BindData(); } // Check visibility else if (IsPostBack && AssignmentGrid.Rows.Count == 0 && String.IsNullOrEmpty(SavedPath)) { this.Visible = false; } }
string generateExcelScript() { StringBuilder sb = new StringBuilder(); sb.Append("function excelExportActionScript(obj, showModal) {"); string url = this.Page.ResolveUrl("~/Apps/TimeTracking/Pages/Public/TimeTrackingExport.aspx"); url += String.Format("?ViewName={0}&StartDate={1}", CHelper.GetFromContext("MetaViewName"), dtcWeek.SelectedDate); sb.AppendFormat("window.open('{0}', 'ExportExcel', 'resizible=0,scrollbars=0,height=300,width=300,top=100,left=100'); return false;", url); sb.Append("}"); return(sb.ToString()); }
public bool IsEnable(object Sender, object Element) { bool retval = false; object obj = CHelper.GetFromContext("SelectedWeek"); if (obj != null) { DateTime selectedWeek = (DateTime)obj; if (selectedWeek == CHelper.GetRealWeekStartByDate(DateTime.UtcNow)) { retval = true; } } return(retval); }
public bool IsEnable(object Sender, object Element) { bool retval = true; object id = CHelper.GetFromContext("ListFolderId"); if (id != null) { int iid = -1; int.TryParse(id.ToString(), out iid); if (iid == -1) { retval = false; } } return(retval); }
/// <summary> /// Handles the PreRender event of the Page 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> protected void Page_PreRender(object sender, EventArgs e) { object needtodatabind = CHelper.GetFromContext("NeedToDataBind"); if (needtodatabind != null && needtodatabind.ToString() == "true") { xmlStruct.CheckVisibleTab = mc; xmlStruct.DataBind(); } object rebindPage = CHelper.GetFromContext("RebindPage"); if (rebindPage != null && rebindPage.ToString() == "true") { MakeDataBind(this); } }
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; 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]; try { EntityObject obj = BusinessManager.Load(className, key); string fieldName = (string)CHelper.GetFromContext(_httpContextFilterFieldNameKey); obj.Properties[fieldName].Value = null; BusinessManager.Update(obj); } catch (Exception ex) { CHelper.GenerateErrorReport(ex); errorCount++; } } tran.Commit(); } if (errorCount > 0) { ((CommandManager)Sender).InfoMessage = CHelper.GetResFileString("{IbnFramework.Common:NotAllSelectedItemsWereProcessed}"); } } } CHelper.RequireDataBind(); }
void Page_PreRenderComplete(object sender, EventArgs e) { if (xmlStruct.Controls.Count == 0) { divNoDetails.Visible = true; } else { divNoDetails.Visible = false; } CHelper.RequireDataBind(false); object needtoclearselector = CHelper.GetFromContext("NeedToClearSelector"); if (needtoclearselector != null && needtoclearselector.ToString().ToLower() == "true") { CHelper.RemoveFromContext("NeedToClearSelector"); } }
protected void Page_PreRender(object sender, EventArgs e) { if (BindSectionHeader) { BindToolbar(); } if (CHelper.NeedToDataBind()) { xmlStruct.CheckVisibleTab = mc; xmlStruct.DataBind(); } object rebindPage = CHelper.GetFromContext("RebindPage"); if (rebindPage != null && rebindPage.ToString() == "true") { MakeDataBind(this); } }
public override void DataBind() { BusinessObject bo = (BusinessObject)DataItem; if (bo == null) { return; } Mediachase.Ibn.Data.Services.EventService es = bo.GetService <Mediachase.Ibn.Data.Services.EventService>(); if (es == null) { this.Visible = false; return; } ICollection <EventGroup> mas = es.LoadEvents(); grdMain.DataSource = mas; grdMain.PageSize = PageSize; object pIndex = CHelper.GetFromContext(this.ClientID + "_NewPageIndex"); if (pIndex != null) { int iIndex = int.Parse(pIndex.ToString()); CHelper.RemoveFromContext(this.ClientID + "_NewPageIndex"); grdMain.PageIndex = iIndex; } int pageIndex = mas.Count / grdMain.PageSize; if (pageIndex > 0 && mas.Count % grdMain.PageSize == 0) { pageIndex = pageIndex - 1; } if (grdMain.PageIndex > pageIndex) { grdMain.PageIndex = pageIndex; } grdMain.DataBind(); }
protected override void OnPreRender(EventArgs e) { object needtoclearselector = CHelper.GetFromContext("NeedToClearSelector"); if (needtoclearselector != null && needtoclearselector.ToString().ToLower() == "true") { ctrlUpdate.Value = ""; xmlStruct.Controls.Clear(); CHelper.UpdateParentPanel(this); } if (CHelper.NeedToDataBind()) { xmlStruct.DataBind(); CHelper.UpdateParentPanel(this); } base.OnPreRender(e); Page.ClientScript.RegisterClientScriptBlock(this.GetType(), Guid.NewGuid().ToString("N"), String.Format("<link rel='stylesheet' type='text/css' href='{0}' />", CHelper.GetAbsolutePath("/styles/IbnFramework/FrameworkUtilTopTabs.css"))); }
public void Invoke(object Sender, object Element) { if (Element is CommandParameters) { object id = CHelper.GetFromContext("ListFolderId"); if (id != null) { int iid = -1; int.TryParse(id.ToString(), out iid); ListFolder folder = new ListFolder(iid); UserLightPropertyCollection _pc = Mediachase.IBN.Business.Security.CurrentUser.Properties; if (folder.ParentId.HasValue) { _pc["ListInfo_FolderId_EntityList_GroupItemKey"] = folder.ParentId.Value.ToString(); } ListManager.DeleteFolder(iid); ((Control)Sender).Page.Response.Redirect("~/Apps/ListApp/Pages/ListAppList.aspx"); } } }
public bool IsEnable(object Sender, object Element) { if (Mediachase.IBN.Business.Security.CurrentUser.IsExternal) { return(false); } if (Element is CommandParameters) { CommandParameters cp = (CommandParameters)Element; string containerKey = CHelper.GetFromContext(Mediachase.Ibn.Web.UI.FileLibrary.Modules.FileStorage._containerKeyKey).ToString(); string containerName = CHelper.GetFromContext(Mediachase.Ibn.Web.UI.FileLibrary.Modules.FileStorage._containerNameKey).ToString(); UserLightPropertyCollection _pc = Mediachase.IBN.Business.Security.CurrentUser.Properties; int folderId = int.Parse(_pc["fs_FolderId_" + containerKey]); FileStorage fs = FileStorage.Create(containerName, containerKey); if (fs.CanUserWrite(folderId)) { return(true); } } return(false); }
public void Invoke(object Sender, object Element) { if (Element is CommandParameters) { CommandParameters cp = (CommandParameters)Element; if (cp.CommandArguments["groupType"] == null || cp.CommandArguments["primaryKeyId"] == null) { throw new ArgumentException("Some expected parameters are null for CollapseExpandBlockTimesheetHandler"); } string ViewName = CHelper.GetFromContext("MetaViewName").ToString(); if (ViewName != null && ViewName != string.Empty) { MetaView CurrentView = Mediachase.Ibn.Data.DataContext.Current.MetaModel.MetaViews[ViewName]; if (CurrentView == null) { throw new ArgumentException(String.Format("Cant find MetaView: {0}", ViewName)); } McMetaViewPreference mvPref = Mediachase.Ibn.Core.UserMetaViewPreference.Load(CurrentView, Mediachase.IBN.Business.Security.CurrentUser.UserID); if (cp.CommandArguments["groupType"] == MetaViewGroupByType.Primary.ToString()) { MetaViewGroupUtil.CollapseOrExpand(MetaViewGroupByType.Primary, mvPref, cp.CommandArguments["primaryKeyId"]); } else { MetaViewGroupUtil.CollapseOrExpand(MetaViewGroupByType.Secondary, mvPref, cp.CommandArguments["primaryKeyId"]); } CHelper.RequireBindGrid(); CHelper.AddToContext("DontShowEditPopup", 1); UserMetaViewPreference.Save(Mediachase.IBN.Business.Security.CurrentUser.UserID, mvPref); } } }
public bool IsEnable(object Sender, object Element) { bool retval = false; NameValueCollection qs = ((Control)Sender).Page.Request.QueryString; if (!String.IsNullOrEmpty(qs["ViewName"])) { if (ListManager.MetaClassIsList(qs["ViewName"])) { int listId = ListManager.GetListIdByClassName(qs["ViewName"]); return(ListInfoBus.CanWrite(listId)); } } if (!String.IsNullOrEmpty(qs["ClassName"])) { if (ListManager.MetaClassIsList(qs["ClassName"])) { int listId = ListManager.GetListIdByClassName(qs["ClassName"]); return(ListInfoBus.CanWrite(listId)); } } object className = CHelper.GetFromContext("Reference1N_ClassName"); if (className != null && ListManager.MetaClassIsList(className.ToString())) { int listId = ListManager.GetListIdByClassName(className.ToString()); return(ListInfoBus.CanWrite(listId)); } className = CHelper.GetFromContext("ReferenceNN_ClassName"); if (className != null && ListManager.MetaClassIsList(className.ToString())) { int listId = ListManager.GetListIdByClassName(className.ToString()); return(ListInfoBus.CanWrite(listId)); } return(retval); }
protected override void OnPreRender(EventArgs e) { _pc["EntityList_" + ClassName + "_" + _profileName + "_PageIndex"] = grdMain.PageIndex.ToString(); //кнопка очистить фильтр у key-textbox btnClear.Visible = !String.IsNullOrEmpty(txtSearch.Text); //стиль key-textbox txtSearch.BorderWidth = 1; txtSearch.BorderStyle = BorderStyle.Solid; txtSearch.Style.Add(HtmlTextWriterStyle.Padding, "2px"); txtSearch.BorderColor = Color.FromArgb(127, 157, 185); txtSearch.BackColor = (!String.IsNullOrEmpty(txtSearch.Text)) ? Color.FromArgb(255, 240, 144) : Color.White; //если необходимо перебиндить датагрид if (CHelper.NeedToBindGrid()) { //если кто-то где-то изменил значение quickfilter с ролью - надо перезагрузить вид if (String.Compare(_profileName, ddProfiles.SelectedValue, true) != 0) { this.Page.Response.Redirect(this.Page.Request.RawUrl, true); return; } //биндим датагрид BindDataGrid(true); //обновляем UpdatePanel грида grdMainPanel.Update(); } //собираем текст FilterView string sText = String.Empty; if (!String.IsNullOrEmpty(_filterText)) { sText = _filterText; } else { if (_isFilterSet) { sText = GetGlobalResourceObject("IbnFramework.Global", "FilterIsSet").ToString(); } else { sText = GetGlobalResourceObject("IbnFramework.Global", "FilterIsNotSet").ToString(); } } FilterIsSet.ForeColor = Color.FromArgb(0x90, 0x90, 0x90); FilterIsSet.Text = sText; int currentUserId = Mediachase.Ibn.Data.Services.Security.CurrentUserId; //в случае, если отображаемый набор фильтров создан текущим пользователем - он может его удалить //генерируем imagebutton справа от набора фильтров ibDeleteInfo.ToolTip = GetGlobalResourceObject("IbnFramework.Incident", "_mc_DeleteView").ToString(); ibDeleteInfo.Attributes.Add("onclick", String.Format("return confirm('{0}');", GetGlobalResourceObject("IbnFramework.Incident", "_mc_DeleteViewWarning").ToString())); ibDeleteInfo.Visible = Mediachase.Ibn.Core.ListViewProfile.CanDelete(ClassName, ddProfiles.SelectedValue, _placeName, currentUserId); ibEditInfo.ToolTip = GetGlobalResourceObject("IbnFramework.Common", "Edit").ToString(); CommandManager cm = CommandManager.GetCurrent(this.Page); CommandParameters cp = new CommandParameters("MC_MUI_ProfileEdit"); cp.CommandArguments = new Dictionary <string, string>(); cp.AddCommandArgument("ClassName", ClassName); cp.AddCommandArgument("uid", ddProfiles.SelectedValue); string scriptEdit = cm.AddCommand(ClassName, ViewName, _placeName, cp); ibEditInfo.Attributes.Add("onclick", String.Format("javascript:{{{0};return false;}}", scriptEdit)); ibEditInfo.Visible = Mediachase.Ibn.Core.ListViewProfile.CanDelete(ClassName, ddProfiles.SelectedValue, _placeName, currentUserId); cp = new CommandParameters("MC_MUI_ProfileNew"); cp.CommandArguments = new Dictionary <string, string>(); cp.AddCommandArgument("ClassName", ClassName); scriptEdit = cm.AddCommand(ClassName, ViewName, _placeName, cp); scriptEdit = scriptEdit.Replace("\"", """); AddNewViewScript = scriptEdit; hfFilterValue.Value = ddProfiles.SelectedValue; // Printer Varsion if (CHelper.GetFromContext(CHelper.PrinterVersionKey) != null && (bool)CHelper.GetFromContext(CHelper.PrinterVersionKey)) { CHelper.PrintControl(PrepareExportGrid(), CHelper.GetResFileString(mc.PluralName), this.Page); dgExport.Visible = false; } base.OnPreRender(e); }