public void Invoke(object sender, object element) { if (element is CommandParameters) { CommandParameters cp = (CommandParameters)element; //if (!cp.CommandArguments.ContainsKey("ControlId")) // throw new ArgumentNullException("CommandParameters.ControlId @ GoogleGadgetRefresh"); //string _cid = cp.CommandArguments["ControlId"]; if (HttpContext.Current.Session["ControlId"] == null) { throw new ArgumentNullException("Session.ControlId @ GoogleGadgetRefresh"); } string _cid = HttpContext.Current.Session["ControlId"].ToString(); string id = MetaViewGroupUtil.GetIdFromUniqueKey(cp.CommandArguments["primaryKeyId"]); HttpRequest request = HttpContext.Current.Request; if (request != null) { GoogleGadgetEntity gge = (GoogleGadgetEntity)BusinessManager.Load("GoogleGadget", PrimaryKeyId.Parse(id)); ControlProperties.Provider.SaveValue(_cid, "PageSource", id); if (gge != null) { ControlProperties.Provider.SaveValue(_cid, ControlProperties._titleKey, CHelper.GetResFileString(gge.Title)); } CommandParameters cp2 = new CommandParameters("MC_GG_SelectItem"); Mediachase.Ibn.Web.UI.WebControls.CommandHandler.RegisterCloseOpenedFrameScript(((CommandManager)sender).Page, cp2.ToString()); //((CommandManager)sender).Page.ClientScript.RegisterClientScriptBlock(this.GetType(), Guid.NewGuid().ToString(), "", true); } } }
protected void lbAddItems_Click(object sender, EventArgs e) { string s = Request["__EVENTARGUMENT"]; if (!String.IsNullOrEmpty(s)) { string[] mas = s.Split(new string[] { ";" }, StringSplitOptions.RemoveEmptyEntries); PrimaryKeyId objId = PrimaryKeyId.Parse(Request["ObjectId"]); foreach (string item in mas) { PrimaryKeyId id = PrimaryKeyId.Parse(MetaViewGroupUtil.GetIdFromUniqueKey(item)); string className = MetaViewGroupUtil.GetMetaTypeFromUniqueKey(item); if (!String.IsNullOrEmpty(className) && className != MetaViewGroupUtil.keyValueNotDefined) { EntityObject eo = BusinessManager.Load(className, id); if (eo != null && !String.IsNullOrEmpty(FilterFieldName) && eo.Properties[FilterFieldName] != null) { eo[FilterFieldName] = objId; BusinessManager.Update(eo); } } } CHelper.RequireDataBind(); } }
/// {"primaryKeyId":6, "column":1, "value":"11:21"} public void UpdateGrid(string ContextKey, object[] ChangesArray) { //List<string> fieldName = new List<string>(); MetaGridContextKey gridContextKey = UtilHelper.JsonDeserialize <MetaGridContextKey>(ContextKey); List <MetaObject> changed = new List <MetaObject>(); CHelper.AddToContext("GridUpdated", 1); LoadMetaViewPreference(gridContextKey.ViewName); MetaView CurrentView = GetViewByName(gridContextKey.ViewName); MetaObject[] list = CurrentView.List(mvPref); if (CurrentView.PrimaryGroupBy != null || CurrentView.SecondaryGroupBy == null) { if (CurrentView.SecondaryGroupBy != null) { list = MetaViewGroupUtil.ExcludeCollapsed(MetaViewGroupByType.Secondary, CurrentView.SecondaryGroupBy, CurrentView.PrimaryGroupBy, mvPref, list); } list = MetaViewGroupUtil.ExcludeCollapsed(MetaViewGroupByType.Primary, CurrentView.PrimaryGroupBy, null, mvPref, list); } foreach (Dictionary <string, object> obj in ChangesArray) { int primaryKeyId = Convert.ToInt32(obj["primaryKeyId"]); int columnId = Convert.ToInt32(obj["column"]); string value = Convert.ToString(obj["value"]); MetaObject tmp = GetMetaObjectById(list, primaryKeyId); MetaObject curObject = null; if (tmp != null) { curObject = MetaObjectActivator.CreateInstance(tmp.GetMetaType(), primaryKeyId); } else { continue; } curObject.Properties[GetFieldNameByIndex(columnId)].Value = GetMinutesFromString(value); changed.Add(curObject); } using (TransactionScope tran = DataContext.Current.BeginTransaction()) { foreach (MetaObject changeObj in changed) { changeObj.Save(); } tran.Commit(); } }
private McMetaViewPreference CreateDefaultReportPreferenceTimeTracking(MetaView View) { McMetaViewPreference pref = new McMetaViewPreference(); pref.MetaView = View; pref.ShowAllMetaField(); foreach (MetaField field in pref.GetVisibleMetaField()) { if (field.Name != "Title" && field.Name != "TotalApproved" && field.Name != "Rate" && field.Name != "Cost" && field.Name != "DayT") { pref.HideMetaField(field.Name); } else { if (field.Name == "Title") { pref.SetAttribute <int>(field.Name, McMetaViewPreference.AttrIndex, 0); } else if (field.Name == "DayT") { pref.SetAttribute <int>(field.Name, McMetaViewPreference.AttrIndex, 1); } else if (field.Name == "TotalApproved") { pref.SetAttribute <int>(field.Name, McMetaViewPreference.AttrIndex, 2); } else if (field.Name == "Rate") { pref.SetAttribute <int>(field.Name, McMetaViewPreference.AttrIndex, 3); } else { pref.SetAttribute <int>(field.Name, McMetaViewPreference.AttrIndex, 4); } } } pref.Attributes.Set("PageSize", -1); MetaViewGroupUtil.CollapseAll(MetaViewGroupByType.Secondary, pref); return(pref); }
protected void lbSave_Click(object sender, EventArgs e) { btnSave.Disabled = true; btnCancel.Disabled = true; CommandParameters cp = new CommandParameters("MC_MUI_EntityDD"); if (Request["ReturnCommand"] != null) { cp.CommandName = Request["ReturnCommand"]; } cp.CommandArguments = new System.Collections.Generic.Dictionary <string, string>(); cp.AddCommandArgument("ClassName", ddFilter.SelectedValue); if (Request["ObjectId"] != null) { cp.AddCommandArgument("ObjectId", Request["ObjectId"]); } if (Request["GridId"] != null) { cp.AddCommandArgument("GridId", Request["GridId"]); } if (TreeServiceTargetObjectId != PrimaryKeyId.Empty) { cp.AddCommandArgument("TreeServiceTargetObjectId", TreeServiceTargetObjectId.ToString()); } cp.AddCommandArgument("SelectedValue", hdnValue.Value); if (!String.IsNullOrEmpty(Request["SelectCtrlId"])) { string[] mas = hdnValue.Value.Split(new string[] { "," }, StringSplitOptions.RemoveEmptyEntries); if (mas.Length > 0) { string uid = MetaViewGroupUtil.GetIdFromUniqueKey(mas[0]); if (uid != "null") { cp.AddCommandArgument("SelectObjectId", uid); cp.AddCommandArgument("SelectCtrlId", Request["SelectCtrlId"]); cp.AddCommandArgument("SelectObjectType", ddFilter.SelectedValue); cp.AddCommandArgument("Html", CHelper.GetEntityTitleHtml(ddFilter.SelectedValue, PrimaryKeyId.Parse(uid))); } } } Mediachase.Ibn.Web.UI.WebControls.CommandHandler.RegisterCloseOpenedFrameScript(this.Page, cp.ToString()); }
/// <summary> /// Handles the Click event of the lbAddItems 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 lbAddItems_Click(object sender, EventArgs e) { string s = Request["__EVENTARGUMENT"]; if (!String.IsNullOrEmpty(s)) { string[] mas = s.Split(new string[] { ";" }, StringSplitOptions.RemoveEmptyEntries); foreach (string item in mas) { PrimaryKeyId id = PrimaryKeyId.Parse(MetaViewGroupUtil.GetIdFromUniqueKey(item)); this.Value = MetaViewGroupUtil.GetIdFromUniqueKey(item); string className = MetaViewGroupUtil.GetMetaTypeFromUniqueKey(item); EntityObject obj = BusinessManager.Load(className, id); MetaClass mc = MetaDataWrapper.GetMetaClassByName(obj.MetaClassName); lblValue.Text = obj.Properties[mc.TitleFieldName].Value.ToString(); } this.RaiseBubbleEvent(this, e); } }
protected void lbAddClient_Click(object sender, EventArgs e) { string s = Request["__EVENTARGUMENT"]; if (!String.IsNullOrEmpty(s)) { DataTable dt = (DataTable)ViewState["Participants"]; string[] mas = s.Split(new string[] { ";" }, StringSplitOptions.RemoveEmptyEntries); foreach (string contact in mas) { PrimaryKeyId id = PrimaryKeyId.Parse(MetaViewGroupUtil.GetIdFromUniqueKey(contact)); ContactEntity contactEntity = (ContactEntity)BusinessManager.Load(ContactEntity.GetAssignedMetaClassName(), id); if (contactEntity != null && (!String.IsNullOrEmpty(contactEntity.EMailAddress1) || !String.IsNullOrEmpty(contactEntity.EMailAddress2) || !String.IsNullOrEmpty(contactEntity.EMailAddress3))) { DataRow dr = dt.NewRow(); int iIndex = int.Parse(hdnCurrent.Value); dr["EMailIssueExternalRecipientId"] = --iIndex; hdnCurrent.Value = iIndex.ToString(); if (!String.IsNullOrEmpty(contactEntity.EMailAddress1)) { dr["EMail"] = contactEntity.EMailAddress1; } else if (!String.IsNullOrEmpty(contactEntity.EMailAddress2)) { dr["EMail"] = contactEntity.EMailAddress2; } else if (!String.IsNullOrEmpty(contactEntity.EMailAddress3)) { dr["EMail"] = contactEntity.EMailAddress3; } dt.Rows.Add(dr); } } ViewState["Participants"] = dt; BinddgMemebers(); } }
protected void lbAddItems_Click(object sender, EventArgs e) { string s = Request["__EVENTARGUMENT"]; if (!String.IsNullOrEmpty(s)) { string[] mas = s.Split(new string[] { ";" }, StringSplitOptions.RemoveEmptyEntries); PrimaryKeyId objId = PrimaryKeyId.Parse(Request["ObjectId"]); foreach (string item in mas) { PrimaryKeyId id = PrimaryKeyId.Parse(MetaViewGroupUtil.GetIdFromUniqueKey(item)); string className = MetaViewGroupUtil.GetMetaTypeFromUniqueKey(item); if (!String.IsNullOrEmpty(className) && className != MetaViewGroupUtil.keyValueNotDefined) { FilterElementCollection fec = new FilterElementCollection(); fec.Add(FilterElement.EqualElement(Filter1FieldName, PrimaryKeyId.Parse(Request["ObjectId"]))); fec.Add(FilterElement.EqualElement(Filter2FieldName, id)); EntityObject[] list = BusinessManager.List(BridgeClassName, fec.ToArray()); if (list.Length == 0) { EntityObject eo = BusinessManager.InitializeEntity(BridgeClassName); eo[Filter1FieldName] = PrimaryKeyId.Parse(Request["ObjectId"]); eo[Filter2FieldName] = id; BusinessManager.Create(eo); } } else if (id != PrimaryKeyId.Empty) { EntityObject eo = BusinessManager.InitializeEntity(BridgeClassName); eo[Filter1FieldName] = PrimaryKeyId.Parse(Request["ObjectId"]); eo[Filter2FieldName] = id; BusinessManager.Create(eo); } } CHelper.RequireDataBind(); } }
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 void Invoke(object Sender, object Element) { if (Element is CommandParameters) { CommandParameters cp = (CommandParameters)Element; string[] elems = null; if (cp.CommandArguments.ContainsKey("GridId")) { elems = MetaGridServer.GetCheckedCollection(((CommandManager)Sender).Page, cp.CommandArguments["GridId"]); } List <int> ttbIds = new List <int>(); //fix by DV: 2008-05-14 //Esli vyzyvaetsa s grida (iconka v otklonennih listah), to primitiv v gride ustanovit etot flag //i togda ID budet bratsa iz parametrov, v protivnom sluchae ID - beretsa iz checkboxes if (!cp.CommandArguments.ContainsKey("callFromGrid")) { foreach (string elem in elems) { string type = MetaViewGroupUtil.GetMetaTypeFromUniqueKey(elem); // elem.Split(new string[] { "::" }, StringSplitOptions.RemoveEmptyEntries)[1]; if (type == MetaViewGroupUtil.keyValueNotDefined) { continue; } int id = Convert.ToInt32(MetaViewGroupUtil.GetIdFromUniqueKey(elem), CultureInfo.InvariantCulture); //Convert.ToInt32(elem.Split(new string[] { "::" }, StringSplitOptions.RemoveEmptyEntries)[0], CultureInfo.InvariantCulture); if (type == TimeTrackingEntry.GetAssignedMetaClass().Name) { //TimeTrackingEntry tte = MetaObjectActivator.CreateInstance<TimeTrackingEntry>(TimeTrackingEntry.GetAssignedMetaClass(), id); //if (!ttbIds.Contains(tte.ParentBlockId)) // ttbIds.Add(tte.ParentBlockId); } else { if (!ttbIds.Contains(id)) { ttbIds.Add(id); } } } } else { ttbIds.Add(Convert.ToInt32(MetaViewGroupUtil.GetIdFromUniqueKey(cp.CommandArguments["primaryKeyId"]), CultureInfo.InvariantCulture)); } using (TransactionScope tran = DataContext.Current.BeginTransaction()) { foreach (int ttbId in ttbIds) { TimeTrackingBlock ttb = MetaObjectActivator.CreateInstance <TimeTrackingBlock>(TimeTrackingBlock.GetAssignedMetaClass(), ttbId); StateMachineService sms = ((BusinessObject)ttb).GetService <StateMachineService>(); // process only initial state if (sms.StateMachine.GetStateIndex(sms.CurrentState.Name) == 0) { StateTransition[] availableTransitions = sms.GetNextAvailableTransitions(true); if (availableTransitions.Length > 0) { sms.MakeTransition(availableTransitions[0].Uid); ttb.Save(); } } } tran.Commit(); } } }
/// <summary> /// Handles the RowDataBound event of the MainGrid control. /// </summary> /// <param name="sender">The source of the event.</param> /// <param name="e">The <see cref="System.Web.UI.WebControls.GridViewRowEventArgs"/> instance containing the event data.</param> void MainGrid_RowDataBound(object sender, GridViewRowEventArgs e) { McMetaViewPreference mvPref = GetMetaViewPreference(); for (int i = 0; i < e.Row.Cells.Count; i++) { int index = i - this.CustomColumns.Count; if (this.ShowCheckboxes) { index--; } if (this.ShowCheckboxes && i == 0) { continue; } if (e.Row.RowType == DataControlRowType.DataRow) //if (e.Row.Cells[i].Controls[0] is Mediachase.Ibn.Web.UI.Modules.FieldControls.BaseType) { //e.Row.Cells[i].Attributes.Add("unselectable", "on"); if (index <= this.VisibleMetaFields.Length) { ((BaseType)e.Row.Cells[i].Controls[0]).DataItem = (MetaObject)e.Row.DataItem; } if (index < this.VisibleMetaFields.Length && index >= 0) { ((BaseType)e.Row.Cells[i].Controls[0]).FieldName = this.VisibleMetaFields[index].Name; } if (e.Row.Cells[i].Controls[0] is CustomColumnBaseType) { ((CustomColumnBaseType)e.Row.Cells[i].Controls[0]).ViewName = this.ViewName; ((CustomColumnBaseType)e.Row.Cells[i].Controls[0]).Place = this.PlaceName; if (this.ShowCheckboxes) { index++; } //if (index + this.CustomColumns.Count < this.CustomColumns.Count) if (this.ShowCheckboxes) { ((CustomColumnBaseType)e.Row.Cells[i].Controls[0]).ColumnId = this.CustomColumns[i - 1].Id; } else { ((CustomColumnBaseType)e.Row.Cells[i].Controls[0]).ColumnId = this.CustomColumns[i].Id; } //else if (index < this.CustomColumns.Count) // ((CustomColumnBaseType)e.Row.Cells[i].Controls[0]).ColumnId = this.CustomColumns[index].Id; } if (i + 1 != e.Row.Cells.Count) { e.Row.Cells[i].CssClass = this.GridInnerCssClass; } } } GridViewRow row = e.Row; if (row.RowType == DataControlRowType.Header || row.RowType == DataControlRowType.DataRow) { internalBindRowWidth(ref row); } row.DataBind(); if (row.RowType == DataControlRowType.DataRow) { //if (e.Row.DataItem != null && ((MetaObject)e.Row.DataItem).PrimaryKeyId.HasValue) //{ // if (this.ShowCheckboxes) // { // CheckBox cb = (CheckBox)row.Cells[0].Controls[0]; // cb.Attributes.Add(IbnGridView.primaryKeyIdAttr, ((MetaObject)e.Row.DataItem).PrimaryKeyId.Value.ToString()); // } //} if (e.Row.DataItem != null) { e.Row.Attributes.Add(IbnGridView.primaryKeyIdAttr, String.Format("{0}", MetaViewGroupUtil.CreateUniqueKey(CurrentView, (MetaObject)e.Row.DataItem, this.PrimaryGroupType, this.SecondaryGroupType))); if (this.ShowCheckboxes) { CheckBox cb = (CheckBox)row.Cells[0].Controls[0]; cb.Attributes.Add(IbnGridView.primaryKeyIdAttr, String.Format("{0}", MetaViewGroupUtil.CreateUniqueKey(CurrentView, (MetaObject)e.Row.DataItem, this.PrimaryGroupType, this.SecondaryGroupType))); } } } }
/// <summary> /// Internals the bind. /// </summary> private void internalBind() { MainGrid.Columns.Clear(); McMetaViewPreference mvPref = GetMetaViewPreference(); MainGrid.AllowPaging = true; if (mvPref.Attributes["PageSize"] != null) { int pageSize = Convert.ToInt32(mvPref.Attributes.GetValue("PageSize").ToString()); if (pageSize != -1) { MainGrid.PageSize = pageSize; } else { MainGrid.PageSize = 10000; //MainGrid.AllowPaging = false; } //CHelper.SafeSelect(ddPaging, mvPref.Attributes.Get("PageSize").ToString()); } else { MainGrid.PageSize = 10; mvPref.Attributes.Set("PageSize", 10); Mediachase.Ibn.Core.UserMetaViewPreference.Save((int)DataContext.Current.CurrentUserId, mvPref); } int width = 0; if (this.ShowCheckboxes) { width += 22 + 7; } #region Check Additional columns from xml foreach (MetaGridCustomColumnInfo customColumn in this.CustomColumns) { MainGrid.Columns.Add(customColumn.Column); width += customColumn.Width + 7; } #endregion int counter = 0; foreach (MetaField field in this.VisibleMetaFields) { int cellWidth = 0; if (PlaceName == String.Empty) { MainGrid.Columns.Add((new ListColumnFactory(this.ViewName)).GetColumn(this.Page, field)); } else { MainGrid.Columns.Add((new ListColumnFactory(this.ViewName)).GetColumn(this.Page, field, PlaceName)); } cellWidth = mvPref.GetMetaFieldWidth(counter, 100); if (cellWidth == 0) { cellWidth = 100; } width += cellWidth; counter++; } width += this.VisibleMetaFields.Length * 7; MainGrid.Width = width; #region Adding PrimaryKeyColumn MainGrid.Columns.Add((new ListColumnFactory(this.ViewName)).GetCssColumn(this.Page, CurrentView.MetaClass.Name)); #endregion internalBindHeader(); FilterElement fe = null; if (this.SearchKeyword != string.Empty) { fe = ListManager.CreateFilterByKeyword(mvPref.MetaView.MetaClass, this.SearchKeyword); mvPref.Filters.Add(fe); } MetaObject[] list = CurrentView.List(mvPref); if (fe != null) { mvPref.Filters.Remove(fe); } if (CurrentView.PrimaryGroupBy == null && CurrentView.SecondaryGroupBy == null) { MainGridExt.IsEmpty = (list.Length == 0); if (list.Length == 0) { list = new MetaObject[] { new MetaObject(CurrentView.MetaClass) }; } MainGrid.DataSource = list; } else { if (CurrentView.SecondaryGroupBy != null) { list = MetaViewGroupUtil.ExcludeCollapsed(MetaViewGroupByType.Secondary, CurrentView.SecondaryGroupBy, CurrentView.PrimaryGroupBy, mvPref, list); } list = MetaViewGroupUtil.ExcludeCollapsed(MetaViewGroupByType.Primary, CurrentView.PrimaryGroupBy, null, mvPref, list); MainGridExt.IsEmpty = (list.Length == 0); if (list.Length == 0) { list = new MetaObject[] { new MetaObject(CurrentView.MetaClass) }; } MainGrid.DataSource = list; } this.Count = list.Length; if (MainGridExt.IsEmpty) { this.Count = 0; } MainGrid.DataBind(); internalBindPaging(); if (list.Length == 0) { MainGrid.CssClass = "serverGridBodyEmpty"; } }