public void Invoke(object Sender, object Element) { if (Element is CommandParameters) { CommandParameters cp = (CommandParameters)Element; int todoId = int.Parse(cp.CommandArguments["ObjectId"]); if (cp.CommandArguments.ContainsKey("SelectedValue")) { string[] elemsToAdd = cp.CommandArguments["SelectedValue"].Split(new string[] { ";" }, StringSplitOptions.RemoveEmptyEntries); using (DbTransaction tran = DbTransaction.Begin()) { foreach (string elem in elemsToAdd) { int selectedValue = 0; if (int.TryParse(elem, out selectedValue)) { if (ToDo.CanUpdate(selectedValue)) { ToDo.CreateToDoLink(selectedValue, todoId); } } } tran.Commit(); } } CHelper.RequireBindGrid(); } }
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"]; if (ownerTypeId == (int)ObjectTypes.Document) { retval = Document.CanUpdate(ownerId); } else if (ownerTypeId == (int)ObjectTypes.Task) { retval = Task.CanUpdate(ownerId); } else if (ownerTypeId == (int)ObjectTypes.ToDo) { retval = ToDo.CanUpdate(ownerId); } else if (ownerTypeId == (int)ObjectTypes.Issue) { retval = Incident.CanUpdate(ownerId); } } return(retval); }
private static void VerifyCanUpdate(int todoId) { if (!ToDo.CanUpdate(todoId)) { throw new AccessDeniedException(); } }
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); }
private void BindToolBar() { tbMetaInfo.AddText((Header == "") ? LocRM.GetString("tabMetaData") : Header); bool CanUpdate = false; string postfix = ""; if (Request["ProjectID"] != null) { CanUpdate = Project.CanUpdate(int.Parse(Request["ProjectID"])); } if (Request["IncidentID"] != null) { CanUpdate = Incident.CanUpdate(int.Parse(Request["IncidentID"])); } if (Request["DocumentID"] != null) { CanUpdate = Document.CanUpdate(int.Parse(Request["DocumentID"])); } if (Request["EventID"] != null) { CanUpdate = CalendarEntry.CanUpdate(int.Parse(Request["EventID"])); } if (Request["TaskID"] != null) { CanUpdate = Task.CanUpdate(int.Parse(Request["TaskID"])); } if (Request["ToDoID"] != null) { CanUpdate = ToDo.CanUpdate(int.Parse(Request["ToDoID"])); } if (CanUpdate) { bool HasMetaFields = false; MetaClass mc = MetaClass.Load(GetMetaClassName()); if (mc != null && mc.UserMetaFields.Count > 0) { HasMetaFields = true; } if (HasMetaFields) { tbMetaInfo.AddRightLink( String.Format("<img alt='' src='../Layouts/Images/Edit.gif'/> {0}", LocRM.GetString("Edit")), String.Format("../Common/MetaDataEdit.aspx?id={0}&class={1}{2}", GetObjectId(), GetMetaClassName(), postfix)); } if (HasMetaFields && tblCustomFields.Rows.Count == 0) { BindText2(); } else if (!HasMetaFields) { BindText1(); } } }
private void BindToolbar() { secHeader.AddText(LocRM.GetString("ToDoResources")); if ((incidentId > 0 && ToDo.CanUpdateIncidentTodo(ToDoID, incidentId)) || (documentId > 0 && ToDo.CanUpdateDocumentTodo(ToDoID, documentId)) || (taskId > 0 && ToDo.CanUpdate(ToDoID, taskId)) || ToDo.CanUpdate(ToDoID)) { #region Resource Utilization if (dgMembers.Items.Count > 0 && !Security.CurrentUser.IsExternal) { string text = String.Format(CultureInfo.InvariantCulture, "<img alt='' src='{0}'/> {1}", Page.ResolveUrl("~/Layouts/Images/ResUtil.png"), LocRM2.GetString("Utilization")); string link = String.Format(CultureInfo.InvariantCulture, "javascript:OpenPopUpNoScrollWindow('{0}?users={1}&ObjectId={2}&ObjectTypeId={3}',750,300)", Page.ResolveUrl("~/Common/ResourceUtilGraphForObject.aspx"), users, ToDoID, (int)ObjectTypes.ToDo); secHeader.AddRightLink(text, link); } #endregion CommandManager cm = CommandManager.GetCurrent(this.Page); CommandParameters cp = new CommandParameters("MC_PM_ToDoResEdit"); string cmd = cm.AddCommand("ToDo", "", "ToDoView", cp); cmd = cmd.Replace("\"", """); if (secHeaderExternal != null && dgMembers.Items.Count == 0) { secHeaderExternal.AddLinkAt(0, "<img alt='' src='../Layouts/Images/icons/newgroup.gif' title='" + LocRM.GetString("Add") + "'/>", "javascript:" + cmd); secHeaderExternal.AddSeparatorAt(1); } else { secHeader.AddRightLink("<img alt='' src='../Layouts/Images/icons/editgroup.gif'/> " + LocRM.GetString("Modify"), "javascript:" + cmd); } } if (hideifempty && dgMembers.Items.Count == 0) { this.Visible = false; } else { this.Visible = true; } }
private void BinddgMembers() { dgMembers.Columns[1].HeaderText = LocRM.GetString("UserName"); dgMembers.Columns[2].HeaderText = LocRM.GetString("OverallStatus"); dgMembers.Columns[3].Visible = (compltype == (int)CompletionType.All && ToDo.CanUpdate(ToDoID)); dt = Mediachase.IBN.Business.ToDo.GetListResourcesDataTable(ToDoID); dgMembers.DataSource = dt; dgMembers.DataBind(); ArrayList userList = new ArrayList(); foreach (DataRow row in dt.Rows) { int principalId = (int)row["UserId"]; if (Mediachase.IBN.Business.User.IsGroup(principalId)) { using (IDataReader reader = SecureGroup.GetListAllUsersInGroup(principalId, false)) { while (reader.Read()) { if (!userList.Contains((int)reader["UserId"])) { userList.Add((int)reader["UserId"]); } } } } else { if (!userList.Contains(principalId)) { userList.Add(principalId); } } } users = String.Empty; foreach (int userId in userList) { if (!String.IsNullOrEmpty(users)) { users += ","; } users += userId.ToString(); } bind = true; }
internal static void UpdateConfigurationInfo(int todoId, int activationTypeId, int completionTypeId, bool mustBeConfirmed, bool checkAccess) { if (checkAccess && !ToDo.CanUpdate(todoId)) { throw new AccessDeniedException(); } using (DbTransaction tran = DbTransaction.Begin()) { if (0 < DbTodo2.UpdateConfigurationInfo(todoId, activationTypeId, completionTypeId, mustBeConfirmed)) { SystemEvents.AddSystemEvents(SystemEventTypes.Todo_Updated_ConfigurationInfo, todoId); } tran.Commit(); } }
internal static void UpdatePriority(int todoId, int priorityId, bool checkAccess) { if (checkAccess && !ToDo.CanUpdate(todoId)) { throw new AccessDeniedException(); } using (DbTransaction tran = DbTransaction.Begin()) { if (0 < DbTodo2.UpdatePriority(todoId, priorityId)) { SystemEvents.AddSystemEvents(SystemEventTypes.Todo_Updated_Priority, todoId); } tran.Commit(); } }
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 && Element is CommandParameters) { CommandParameters cp = (CommandParameters)Element; if (cp.CommandArguments["primaryKeyId"] == null) { throw new ArgumentException("PrimaryKeyId is null for WFInstanceStartEnableHandler"); } PrimaryKeyId pk = PrimaryKeyId.Parse(cp.CommandArguments["primaryKeyId"]); WorkflowInstanceEntity entity = (WorkflowInstanceEntity)BusinessManager.Load(WorkflowInstanceEntity.ClassName, pk); retval = (entity.State == (int)BusinessProcessState.Pending); } } return(retval); }
public static void UpdateTaskToDo(int todoId, int taskId, int managerId, string title, string description, DateTime startDate, DateTime finishDate, int priorityId, int activationTypeId, int completionTypeId, bool mustBeConfirmed, bool completeTask, int taskTime, ArrayList categories, PrimaryKeyId contactUid, PrimaryKeyId orgUid) { if (!ToDo.CanUpdate(todoId, taskId)) { throw new AccessDeniedException(); } using (DbTransaction tran = DbTransaction.Begin()) { UpdateGeneralInfo(todoId, title, description, false); UpdateTimeline(todoId, startDate, finishDate, taskTime, false); UpdatePriority(todoId, priorityId, false); UpdateCategories(ListAction.Set, todoId, categories, false); UpdateConfigurationInfo(todoId, activationTypeId, completionTypeId, mustBeConfirmed, false); UpdateClient(todoId, contactUid, orgUid, false); UpdateManager(todoId, managerId, false); DBToDo.AddTaskToDo(taskId, todoId, completeTask); tran.Commit(); } }