public WebMethodResponse WorkflowAck(int wid, WorkflowAction action, string comment) { WebMethodResponse resp = new WebMethodResponse(); ApprovalWorkflow wf = ApprovalWorkflow.CreateApprovalWorkflow(wid); if (wf == null) return new WebMethodResponse(false, "Approver Workflow Failed", "Unknown approver"); switch (action) { case WorkflowAction.Approved : return wf.Approve(); case WorkflowAction.Change : return wf.RequestToChange(comment); case WorkflowAction.Denied : return wf.Deny(comment); } return new WebMethodResponse(false, "Approver Workflow Failed", "Unknown action"); }
public WebMethodResponse RequestChanged() { WebMethodResponse resp = new WebMethodResponse(); try { using (var db = new SNAPDatabaseDataContext()) { var req = db.SNAP_Requests.Single(r => r.pkId == _id); var accessTeamWF = req.SNAP_Workflows.Single(x => x.actorId == AccessTeamActorId); var result = reqStateTransition(req, RequestState.Change_Requested, RequestState.Open, accessTeamWF, WorkflowState.Change_Requested, WorkflowState.Pending_Acknowledgement); if (result) { db.SubmitChanges(); resp = new WebMethodResponse(true, "Request Changed", "Success"); } else { resp = new WebMethodResponse(false, "Request Changed Error", SeeDetailsReqTracking); } } } catch (Exception ex) { Logger.Fatal("AccessRequest - RequestChanged, Message:" + ex.Message + ", StackTrace: " + ex.StackTrace); resp = new WebMethodResponse(false, "Request Changed Exception", ex.Message); } return resp; }
public WebMethodResponse RequestToChange(string comment) { WebMethodResponse resp = new WebMethodResponse(); try { using (var db = new SNAPDatabaseDataContext()) { var req = db.SNAP_Requests.Single(r => r.pkId == _id); var accessTeamWF = req.SNAP_Workflows.Single(x => x.actorId == AccessTeamActorId); var result = reqStateTransition(req, RequestState.Pending, RequestState.Change_Requested, accessTeamWF, WorkflowState.Pending_Workflow, WorkflowState.Change_Requested); comment = comment.Replace("<br />", string.Empty); if (result) { addAccessTeamComment(accessTeamWF, comment, CommentsType.Requested_Change); // NOTE: don't send AIM extra email when AIM is the one making the change. if (req.submittedBy.ToString() != req.userId.ToString()) { Email.SendTaskEmail(EmailTaskType.UpdateRequester, req.userId + "@apollogrp.edu", req.userDisplayName, _id, req.submittedBy, WorkflowState.Change_Requested, comment); } Email.SendTaskEmail(EmailTaskType.UpdateRequester, req.submittedBy + "@apollogrp.edu", Utilities.GetFullNameByLoginId(req.submittedBy), _id, req.submittedBy, WorkflowState.Change_Requested, comment); db.SubmitChanges(); resp = new WebMethodResponse(true, "Request Change", "Success"); } else { resp = new WebMethodResponse(false, "Request Change Error", SeeDetailsReqTracking); } } } catch (Exception ex) { Logger.Fatal("AccessRequest - RequestToChange, Message:" + ex.Message + ", StackTrace: " + ex.StackTrace); resp = new WebMethodResponse(false, "Request Change Exception", ex.Message); } return resp; }
public WebMethodResponse FinalizeRequest() { WebMethodResponse resp = new WebMethodResponse(); try { using (var db = new SNAPDatabaseDataContext()) { var req = db.SNAP_Requests.Single(r => r.pkId == _id); var accessTeamWF = req.SNAP_Workflows.Single(x => x.actorId == AccessTeamActorId); var result = reqStateTransition(req, RequestState.Pending, RequestState.Closed, accessTeamWF, WorkflowState.Pending_Provisioning, WorkflowState.Closed_Completed) || reqStateTransition(req, RequestState.Pending, RequestState.Closed, accessTeamWF, WorkflowState.Approved, WorkflowState.Closed_Completed); if (result) { if (req.submittedBy.ToString() != req.userId.ToString()) { Email.SendTaskEmail(EmailTaskType.UpdateRequester, req.userId + "@apollogrp.edu", req.userDisplayName, _id, req.submittedBy, WorkflowState.Closed_Completed, null); } Email.SendTaskEmail(EmailTaskType.UpdateRequester, req.submittedBy + "@apollogrp.edu", Utilities.GetFullNameByLoginId(req.submittedBy), _id, req.submittedBy, WorkflowState.Closed_Completed, null); db.SubmitChanges(); resp = new WebMethodResponse(true, "Finalization", "Success"); } else { resp = new WebMethodResponse(false, "Finalization Error", SeeDetailsReqTracking); } } } catch (Exception ex) { Logger.Fatal("AccessRequest - FinalizeRequest, Message:" + ex.Message + ", StackTrace: " + ex.StackTrace); resp = new WebMethodResponse(false, "Finalization Exception", ex.Message); } return resp; }
public WebMethodResponse NoAccess(WorkflowAction action, string comment) { WebMethodResponse resp = new WebMethodResponse(); WorkflowState wfState = WorkflowState.Not_Active; CommentsType commentType = CommentsType.Cancelled; switch (action) { case WorkflowAction.Denied: wfState = WorkflowState.Closed_Denied; commentType = CommentsType.Denied; break; case WorkflowAction.Cancel: wfState = WorkflowState.Closed_Cancelled; commentType = CommentsType.Cancelled; break; case WorkflowAction.Abandon: wfState = WorkflowState.Closed_Abandon; commentType = CommentsType.Abandon; break; } try { using (var db = new SNAPDatabaseDataContext()) { var req = db.SNAP_Requests.Single(r => r.pkId == _id); var accessTeamWF = req.SNAP_Workflows.Single(x => x.actorId == AccessTeamActorId); var currentAccessTeamWFState = (WorkflowState) accessTeamWF.SNAP_Workflow_States.Single(s => s.completedDate == null).workflowStatusEnum; var result = reqStateTransition(req, RequestState.Pending, RequestState.Closed, accessTeamWF, currentAccessTeamWFState, /* WorkflowState.Pending_Workflow,*/ wfState) || reqStateTransition(req, RequestState.Change_Requested, RequestState.Closed, accessTeamWF, currentAccessTeamWFState, /* WorkflowState.Pending_Workflow,*/ wfState); if (result) { comment = comment.Replace("<br />", string.Empty); addAccessTeamComment(accessTeamWF, comment, commentType); if (req.submittedBy.ToString() != req.userId.ToString()) { Email.SendTaskEmail(EmailTaskType.UpdateRequester, req.userId + "@apollogrp.edu", req.userDisplayName, _id, req.submittedBy, (WorkflowState)wfState, comment); } Email.SendTaskEmail(EmailTaskType.UpdateRequester, req.submittedBy + "@apollogrp.edu", Utilities.GetFullNameByLoginId(req.submittedBy), _id, req.submittedBy, (WorkflowState)wfState, comment); db.SubmitChanges(); resp = new WebMethodResponse(true, "Cancel/Deny", "Success"); } else { resp = new WebMethodResponse(false, "Cancel/Deny Error", SeeDetailsReqTracking); } } } catch (Exception ex) { Logger.Fatal("AccessRequest - NoAccess, Message:" + ex.Message + ", StackTrace: " + ex.StackTrace); resp = new WebMethodResponse(false, "Cancel/Deny Exception", ex.Message); } return resp; }
/// <summary> /// Call this method when you have a WF in place and in pending approval stage and u want to make mod to the approver list /// </summary> /// <param name="mgrusrId"></param> /// <param name="actorIDs"></param> /// <returns></returns> public WebMethodResponse EditWorkflow(string mgrusrId, List<int> actorIDs) { WebMethodResponse resp = new WebMethodResponse(); var mgrActorId = ApprovalWorkflow.GetActorIdByUserId(ActorGroupType.Manager, mgrusrId); if (mgrActorId != 0) { // who is in pending state, we need to remember to inform the pending approver her new due day var currentPendingApproverType = GetPendingApprovalActorType(); if (currentPendingApproverType != -1) { actorIDs.Add(mgrActorId); using (var db = new SNAPDatabaseDataContext()) { var check = editWorkflowCheck(db, actorIDs, currentPendingApproverType); if (check.Success) { var req = db.SNAP_Requests.Single(r => r.pkId == _id); var accessTeamWF = req.SNAP_Workflows.Single(x => x.actorId == AccessTeamActorId); // make sure accessTeamWF stat is pending apporal if ( accessTeamWF.SNAP_Workflow_States.Count( s => s.completedDate == null && s.workflowStatusEnum == (byte) WorkflowState.Workflow_Created) == 1) { var newActorIds = editApprovalWorkFlow(db, actorIDs); db.SubmitChanges(); req = db.SNAP_Requests.Single(r => r.pkId == _id); foreach (var wf in req.SNAP_Workflows) { if (wf.actorId != AccessTeamActorId && newActorIds.Contains(wf.actorId)) { InformNewPendingApproverNewDueDate(wf, currentPendingApproverType); // update the request table if (wf.SNAP_Actor.SNAP_Actor_Group.actorGroupType == (byte)ActorApprovalType.Manager) { req.managerUserId = wf.SNAP_Actor.userId; req.managerDisplayName = wf.SNAP_Actor.displayName; } } } //addAccessTeamComment(accessTeamWF, "Workflow editted @" + DateTime.Now, CommentsType.Access_Notes_AccessTeam); db.SubmitChanges(); // in case we are removing the last approver who has not approved yet, or removing special approver editWorkflowCompletionCheck(_id, db); resp = new WebMethodResponse(true, "Workflow Change", "Success"); } else { resp = new WebMethodResponse(false, "Workflow Change Error", SeeDetailsReqTracking); } } else { resp = check; } } } } return resp; }
/// <summary> /// call this method when one creates the workflow the first time or after request to change /// </summary> /// <param name="actorIds"></param> /// <returns></returns> public WebMethodResponse CreateWorkflow(List<int> actorIds) { WebMethodResponse resp = new WebMethodResponse(); var result = false; try { using (var db = new SNAPDatabaseDataContext()) { SNAP_Workflow accessTeamWF; DateTime? dueDate; SNAP_Request req; initializeData(db, WorkflowState.Pending_Workflow, out req, out accessTeamWF, out dueDate); result = reqStateTransition(req, RequestState.Pending, RequestState.Pending, accessTeamWF, WorkflowState.Pending_Workflow, WorkflowState.Workflow_Created); if (result) { result = mustHaveManagerInWorkflow(db, actorIds); if (result) { createrApprovalWorkFlow(db, actorIds); addAccessTeamComment(accessTeamWF, "Due Date: " + Convert.ToDateTime(dueDate).ToString("MMM d, yyyy"), CommentsType.Workflow_Created); db.SubmitChanges(); resp = new WebMethodResponse(true, "Workflow Creation", "Success"); } else { resp = new WebMethodResponse(false, "Workflow Creation Error", "Missing Manager. Please adjust manager. "); } } else { resp = new WebMethodResponse(false, "Workflow Creation Error", SeeDetailsReqTracking); } } if (result) InformApproverForAction(); } catch (Exception ex) { Logger.Fatal("AccessRequest - CreateWorkflow, Message:" + ex.Message + ", StackTrace: " + ex.StackTrace); resp = new WebMethodResponse(false, "Workflow Creation Exception", ex.Message); } return resp; }
public WebMethodResponse CreateServiceDeskTicket() { WebMethodResponse resp = new WebMethodResponse(); try { using (var db = new SNAPDatabaseDataContext()) { SNAP_Workflow accessTeamWF; DateTime? dueDate; SNAP_Request req; initializeData(db, WorkflowState.Approved, out req, out accessTeamWF, out dueDate); var result = reqStateTransition(req, RequestState.Pending, RequestState.Pending, accessTeamWF , WorkflowState.Approved, WorkflowState.Pending_Provisioning); if (result) { var sdSource = ConfigurationManager.AppSettings["SDSource"]; switch (sdSource) { case "CASD": resp = createCASDTicket(db, accessTeamWF, dueDate, req); break; case "HPSM" : resp = createHPSMTicket(db, accessTeamWF, dueDate, req); break; default : resp = new WebMethodResponse(false, "Ticket Creation Error", SeeDetailsReqTracking); break; } } else { resp = new WebMethodResponse(false, "Ticket Creation Error", SeeDetailsReqTracking); } } } catch (Exception ex) { Logger.Error("[SNAP] AccessRequest > CreateServiceDeskTicket", ex); resp = new WebMethodResponse(false, "Ticket Creation Exception", ex.Message); } return resp; }
public WebMethodResponse AddComment(string comment, CommentsType type) { WebMethodResponse resp = new WebMethodResponse(); comment = comment.Replace("<br />", string.Empty); try { using (var db = new SNAPDatabaseDataContext()) { var req = db.SNAP_Requests.Single(r => r.pkId == _id); req.SNAP_Request_Comments.Add(new SNAP_Request_Comment() { commentText = comment, commentTypeEnum = (byte)type, createdDate = DateTime.Now }); db.SubmitChanges(); resp = new WebMethodResponse(true, "Add Comment", "Success"); } } catch (Exception ex) { Logger.Fatal("AccessRequest - AddComment, Message:" + ex.Message + ", StackTrace: " + ex.StackTrace); resp = new WebMethodResponse(false, "Add Comment Exception", ex.Message); } return resp; }
public WebMethodResponse Ack() { WebMethodResponse resp = new WebMethodResponse() ; try { using (var db = new SNAPDatabaseDataContext()) { SNAP_Workflow accessTeamWF; DateTime? dueDate; SNAP_Request req; initializeData(db, WorkflowState.Pending_Acknowledgement, out req, out accessTeamWF, out dueDate); var result = reqStateTransition(req, RequestState.Open, RequestState.Pending, accessTeamWF, WorkflowState.Pending_Acknowledgement, WorkflowState.Pending_Workflow); if (result) { addAccessTeamComment(accessTeamWF, "Due Date: " + Convert.ToDateTime(dueDate).ToString("MMM d, yyyy"), CommentsType.Acknowledged); db.SubmitChanges(); resp = new WebMethodResponse(true, "Acknowledgement", "Success"); } else { resp = new WebMethodResponse(false, "Acknowledgement Error", SeeDetailsReqTracking); } } } catch (Exception ex) { Logger.Fatal("AccessRequest - Ack, Message:" + ex.Message + ", StackTrace: " + ex.StackTrace); resp = new WebMethodResponse(false, "Acknowledgement Exception", ex.Message); } return resp; }