protected void _submitForm_Click(object sender, EventArgs e) { int requestID; var sendEmail = true; try { List<RequestData> newRequestDataList = RequestFormRequestData(_requestForm); if (BrandNewRequest()) { var xmlInput = RequestData.ToXml(newRequestDataList); ADUserDetail detail = Apollo.AIM.SNAP.CA.DirectoryServices.GetUserByLoginName(_requestorLoginId.Text); using (var db = new SNAPDatabaseDataContext()) { requestID = db.usp_insert_request_xml(xmlInput, SnapSession.CurrentUser.LoginId, _requestorLoginId.Text, _requestorId.Text, detail.Title, _managerLoginId.Text, _managerName.Text); if (requestID > 0) { SnapSession.SelectedRequestId = requestID.ToString(); SnapSession.UseSelectedRequestId = true; } else { Logger.Fatal("SNAP: Request Form - Submit failure", "Unknown Error"); sendEmail = false; } } } else { requestID = System.Convert.ToInt32(SnapSession.SelectedRequestId); updateRequestUsrInfo(requestID, SnapSession.CurrentUser.LoginId, _requestorLoginId.Text, _requestorId.Text, _managerLoginId.Text, _managerName.Text); RequestData.UpdateRequestData(newRequestDataList, _requestFormData); var accessReq = new AccessRequest(requestID); if (!accessReq.RequestChanged().Success) { sendEmail = false; } } if (sendEmail) { if (SnapSession.CurrentUser.LoginId != _requestorLoginId.Text) { Email.SendTaskEmail(EmailTaskType.ProxyForAffectedEndUser, SnapSession.CurrentUser.LoginId + "@apollogrp.edu", SnapSession.CurrentUser.FullName, requestID, _requestorId.Text); } Email.SendTaskEmail(EmailTaskType.AccessTeamAcknowledge, ConfigurationManager.AppSettings["AIM-DG"], null, requestID, _requestorId.Text); Email.SendTaskEmail(EmailTaskType.UpdateRequester, _requestorLoginId.Text + "@apollogrp.edu", _requestorId.Text, requestID, _requestorId.Text, WorkflowState.Pending_Acknowledgement, null); // TODO: UserLoginId concatenates with @apollogrp, but that may not be the addy. } } catch (Exception ex) { Logger.Fatal("RequestForm - _submitForm_Click, Message:" + ex.Message + ", StackTrace: " + ex.StackTrace); } WebUtilities.Redirect(PageNames.USER_VIEW); }
public void EXEC_usp_open_request_tab() { using (var db = new SNAPDatabaseDataContext()) { var req = db.SNAP_Requests.Single(x => x.submittedBy == "UnitTester"); var accessReq = new AccessRequest(req.pkId); accessReq.Ack(); } using (var db = new SNAPDatabaseDataContext()) { var req = db.SNAP_Requests.Single(x => x.submittedBy == "UnitTester"); Assert.IsTrue(req.statusEnum == (byte)RequestState.Pending); var accessReq = new AccessRequest(req.pkId); accessReq.RequestToChange("TEST"); } usp_open_request_tabResult t = new usp_open_request_tabResult(); t.requestId = 0; t.userId = "test"; t.userDisplayName = "test"; t.userTitle = "test"; t.submittedBy = "test"; t.managerUserId = "test"; t.managerDisplayName = "test"; t.statusEnum = 0; t.isChanged = false; t.ticketNumber = "test"; t.fieldId = 0; t.fieldLabel = "test"; t.fieldText = "ttest"; t.modifiedDate = DateTime.Now; t.createdDate = DateTime.Now; using (var db = new SNAPDatabaseDataContext()) { var req = db.SNAP_Requests.Single(x => x.submittedBy == "UnitTester"); Assert.IsTrue(req.statusEnum == (byte)RequestState.Change_Requested); var test = db.usp_open_request_tab(req.userId, req.pkId).First(); Assert.IsTrue(test.requestId > 0); Console.WriteLine(test.requestId); Console.WriteLine(test.userId); Console.WriteLine(test.userDisplayName); Console.WriteLine(test.userTitle); Console.WriteLine(test.submittedBy); Console.WriteLine(test.managerUserId); Console.WriteLine(test.managerDisplayName); Console.WriteLine(test.statusEnum); Console.WriteLine(test.isChanged); Console.WriteLine(test.ticketNumber); Console.WriteLine(test.fieldId); Console.WriteLine(test.fieldLabel); Console.WriteLine(test.fieldText); Console.WriteLine(test.modifiedDate); Console.WriteLine(test.createdDate); } }
public static WebMethodResponse ApproverActions(int requestId, WorkflowAction action, string comments) { var currentUsrId = SnapSession.CurrentUser.DistributionGroup != null ? SnapSession.CurrentUser.DistributionGroup : SnapSession.CurrentUser.LoginId; int wfId = 0; using (var db = new SNAPDatabaseDataContext()) { wfId = db.GetActiveWorkflowId(requestId, currentUsrId); if (wfId == 0) return new WebMethodResponse(false, "Approver Action Failed", "Approver has nothing to approve"); } var accessReq = new AccessRequest(requestId); comments = comments.FromJSONStringToObj<string>(); return accessReq.WorkflowAck(wfId, action, comments); }
public static WebMethodResponse BuilderActions(int requestId, WorkflowAction action) { //TODO: get actorId from current user var accessReq = new AccessRequest(requestId); switch (action) { case WorkflowAction.Cancel: return accessReq.NoAccess(action, ""); case WorkflowAction.Complete: return accessReq.FinalizeRequest(); case WorkflowAction.Ticket: return accessReq.CreateServiceDeskTicket(); default: return new WebMethodResponse(false, "BuilderActions", "Unknown action"); } }
public static WebMethodResponse AccessTeamActions(int requestId, WorkflowAction action, string comments) { //TODO: get actorId from current user var accessReq = new AccessRequest(requestId); comments = comments.FromJSONStringToObj<string>(); switch (action) { case WorkflowAction.Ack: return accessReq.Ack(); case WorkflowAction.Change: return accessReq.RequestToChange(comments); case WorkflowAction.Cancel: return accessReq.NoAccess(action, comments); case WorkflowAction.Denied: return accessReq.NoAccess(action, comments); default: return new WebMethodResponse(false, "AIM", "Unknown operation"); } }
public void ShouldHandleAIMCancelWhenRequestInRequestToChangeState() { using (var db = new SNAPDatabaseDataContext()) { var accessReq = createTestWorkflow(db, new List<int>() { managerActorId, teamApprovalActorId, windowsServerActorId, databaseActorId, networkShareActorId }); var wfs = accessReq.FindApprovalTypeWF(db, (byte)ActorApprovalType.Manager); Assert.IsTrue(wfs[0].SNAP_Workflow_States.Single(s => s.workflowStatusEnum == (byte)WorkflowState.Pending_Approval).completedDate == null); accessReq.WorkflowAck(wfs[0].pkId, WorkflowAction.Change); accessReq.NoAccess(WorkflowAction.Cancel, "Cancel it"); } using (var db = new SNAPDatabaseDataContext()) { var req = db.SNAP_Requests.Single(x => x.submittedBy == "UnitTester"); var accessReq = new AccessRequest(req.pkId); var wfs = accessReq.FindApprovalTypeWF(db, (byte)ActorApprovalType.Workflow_Admin); Assert.IsTrue(req.statusEnum == (byte)RequestState.Closed); verifyWorkflowState(wfs[0], WorkflowState.Closed_Cancelled); verifyWorkflowComment(wfs[0], CommentsType.Cancelled); } }
public void ShouldHandleAbandonInPendingTechApprovalState() { using (var db = new SNAPDatabaseDataContext()) { var accessReq = createTestWorkflow(db, new List<int>() { managerActorId, teamApprovalActorId, windowsServerActorId, //databaseActorId, //networkShareActorId }); // get manager approal var wfs = accessReq.FindApprovalTypeWF(db, (byte)ActorApprovalType.Manager); Assert.IsTrue(wfs[0].SNAP_Workflow_States.Single(s => s.workflowStatusEnum == (byte)WorkflowState.Pending_Approval).completedDate == null); accessReq.WorkflowAck(wfs[0].pkId, WorkflowAction.Approved); // get team approval wfs = accessReq.FindApprovalTypeWF(db, (byte)ActorApprovalType.Team_Approver); accessReq.WorkflowAck(wfs[0].pkId, WorkflowAction.Approved); // get technical approval wfs = accessReq.FindApprovalTypeWF(db, (byte)ActorApprovalType.Technical_Approver); accessReq.WorkflowAck(wfs[0].pkId, WorkflowAction.Approved); accessReq.NoAccess(WorkflowAction.Abandon, "Reach Max Overdue"); } using (var db = new SNAPDatabaseDataContext()) { var req = db.SNAP_Requests.Single(x => x.submittedBy == "UnitTester"); var accessReq = new AccessRequest(req.pkId); var wfs = accessReq.FindApprovalTypeWF(db, (byte)ActorApprovalType.Workflow_Admin); Assert.IsTrue(req.statusEnum == (byte)RequestState.Closed); verifyWorkflowStateComplete(wfs[0], WorkflowState.Closed_Abandon); verifyWorkflowComment(wfs[0], CommentsType.Abandon); } }
public void ShouldHandleRemoveInactiveApprovers() { using (var db = new SNAPDatabaseDataContext()) { var accessReq = createTestWorkflow(db, new List<int>() { managerActorId, windowsServerActorId, databaseActorId, }); } using (var db = new SNAPDatabaseDataContext()) { var req = db.SNAP_Requests.Single(x => x.submittedBy == "UnitTester"); var accessReq = new AccessRequest(req.pkId); accessReq.EditWorkflow(managerUserId, new List<int>() { managerActorId }); Assert.IsTrue(req.statusEnum == (byte) RequestState.Pending); var wfs = accessReq.FindApprovalTypeWF(db, (byte)ActorApprovalType.Workflow_Admin); Assert.IsTrue(wfs[0].SNAP_Workflow_States.OrderByDescending(s=>s.pkId). First().workflowStatusEnum == (byte)WorkflowState.Workflow_Created); } }
public void ShouldHandleFromManagerToTeamToOneTechicalApprove() { using (var db = new SNAPDatabaseDataContext()) { var accessReq = createTestWorkflow(db, new List<int>() { managerActorId, teamApprovalActorId, windowsServerActorId, databaseActorId, networkShareActorId }); // get manager approal var wfs = accessReq.FindApprovalTypeWF(db, (byte)ActorApprovalType.Manager); Assert.IsTrue(wfs[0].SNAP_Workflow_States.Single(s => s.workflowStatusEnum == (byte)WorkflowState.Pending_Approval).completedDate == null); accessReq.WorkflowAck(wfs[0].pkId, WorkflowAction.Approved); // get team approval wfs = accessReq.FindApprovalTypeWF(db, (byte)ActorApprovalType.Team_Approver); accessReq.WorkflowAck(wfs[0].pkId, WorkflowAction.Approved); // get technical approval wfs = accessReq.FindApprovalTypeWF(db, (byte)ActorApprovalType.Technical_Approver); accessReq.WorkflowAck(wfs[0].pkId, WorkflowAction.Approved); } using (var db = new SNAPDatabaseDataContext()) { var req = db.SNAP_Requests.Single(x => x.submittedBy == "UnitTester"); var accessReq = new AccessRequest(req.pkId); var accessTeamWF = req.SNAP_Workflows.Single(w => w.actorId == 1); // actid = 1 => accessTeam var accessTeamState = accessTeamWF.SNAP_Workflow_States.Single(s => s.workflowStatusEnum == (byte)WorkflowState.Workflow_Created); Assert.IsTrue(accessTeamState.completedDate == null); // can't complete this yet, need to wait for all technical approvals } }
public void ShouldHandleFromManagerToTeamToAllTechicalApprove() { using (var db = new SNAPDatabaseDataContext()) { var accessReq = createTestWorkflow(db, new List<int>() { managerActorId, teamApprovalActorId, windowsServerActorId, databaseActorId, networkShareActorId }); // get manager approal //ystem.Threading.Thread.Sleep(90000); var wfs = accessReq.FindApprovalTypeWF(db, (byte)ActorApprovalType.Manager); Assert.IsTrue(wfs[0].SNAP_Workflow_States.Single(s => s.workflowStatusEnum == (byte)WorkflowState.Pending_Approval).completedDate == null); accessReq.WorkflowAck(wfs[0].pkId, WorkflowAction.Approved); // get team approval //System.Threading.Thread.Sleep(90000); wfs = accessReq.FindApprovalTypeWF(db, (byte)ActorApprovalType.Team_Approver); accessReq.WorkflowAck(wfs[0].pkId, WorkflowAction.Approved); // get all technical approval // !!! for individual test, please uncommnet it // !!! comment it out to save time //System.Threading.Thread.Sleep(90000); wfs = accessReq.FindApprovalTypeWF(db, (byte)ActorApprovalType.Technical_Approver); accessReq.WorkflowAck(wfs[0].pkId, WorkflowAction.Approved); accessReq.WorkflowAck(wfs[1].pkId, WorkflowAction.Approved); accessReq.WorkflowAck(wfs[2].pkId, WorkflowAction.Approved); } using (var db = new SNAPDatabaseDataContext()) { var req = db.SNAP_Requests.Single(x => x.submittedBy == "UnitTester"); var accessReq = new AccessRequest(req.pkId); //var accessTeamWF = req.SNAP_Workflows.Single(w => w.actorId == 1); // actid = 1 => accessTeam var accessTeamWF = accessReq.FindApprovalTypeWF(db, (byte)ActorApprovalType.Workflow_Admin)[0]; // there is only on workflow admin var accessTeamState = accessTeamWF.SNAP_Workflow_States.Single(s => s.workflowStatusEnum == (byte)WorkflowState.Workflow_Created); Assert.IsTrue(accessTeamState.completedDate != null); // all technical approval received, complete it accessTeamState = accessTeamWF.SNAP_Workflow_States.Single(s => s.workflowStatusEnum == (byte)WorkflowState.Approved); Assert.IsTrue(accessTeamState.completedDate == null); // all technical approval received, complete it // make sure approving manager wf propergates notify and due date to final state var firstApprover = accessReq.FindApprovalTypeWF(db, (byte)ActorApprovalType.Technical_Approver)[0]; var firstApproverPendingState = firstApprover.SNAP_Workflow_States.Single(s => s.workflowStatusEnum == (byte)WorkflowState.Pending_Approval); var firstApproverApproveState = firstApprover.SNAP_Workflow_States.Single(s => s.workflowStatusEnum == (byte)WorkflowState.Approved); Assert.IsTrue(firstApproverPendingState.notifyDate == firstApproverApproveState.notifyDate); Assert.IsTrue(firstApproverPendingState.dueDate == firstApproverApproveState.dueDate); } }
public void ShouldHandleFromManagerToTeamApproveAndModifyTechApprover() { using (var db = new SNAPDatabaseDataContext()) { var accessReq = createTestWorkflow(db, new List<int>() { managerActorId, teamApprovalActorId, windowsServerActorId, //databaseActorId, //networkShareActorId }); // get manager approal var wfs = accessReq.FindApprovalTypeWF(db, (byte)ActorApprovalType.Manager); Assert.IsTrue(wfs[0].SNAP_Workflow_States.Single(s => s.workflowStatusEnum == (byte)WorkflowState.Pending_Approval).completedDate == null); accessReq.WorkflowAck(wfs[0].pkId, WorkflowAction.Approved); // get team approval wfs = accessReq.FindApprovalTypeWF(db, (byte)ActorApprovalType.Team_Approver); accessReq.WorkflowAck(wfs[0].pkId, WorkflowAction.Approved); accessReq.EditWorkflow(managerUserId, new List<int>() { teamApprovalActorId, //windowsServerActorId, databaseActorId, //networkShareActorId }); } using (var db = new SNAPDatabaseDataContext()) { var req = db.SNAP_Requests.Single(x => x.submittedBy == "UnitTester"); var accessReq = new AccessRequest(req.pkId); var wfs = accessReq.FindApprovalTypeWF(db, (byte)ActorApprovalType.Manager); verifyWorkflowTransition(wfs[0], WorkflowState.Pending_Approval, WorkflowState.Approved); wfs = accessReq.FindApprovalTypeWF(db, (byte)ActorApprovalType.Team_Approver); verifyWorkflowTransition(wfs[0], WorkflowState.Pending_Approval, WorkflowState.Approved); wfs = accessReq.FindApprovalTypeWF(db, (byte)ActorApprovalType.Technical_Approver); verifyWorkflowTransition(wfs[0], WorkflowState.Not_Active, WorkflowState.Pending_Approval); Assert.IsTrue(wfs[0].actorId == databaseActorId); } }
public void ShouldNotEnterToDifferentStateWhenNotReady() { using (var db = new SNAPDatabaseDataContext()) { var req = db.SNAP_Requests.Single(x => x.submittedBy == "UnitTester"); var accessReq = new AccessRequest(req.pkId); Assert.IsFalse(accessReq.CreateServiceDeskTicket().Success); Assert.IsFalse(accessReq.CreateWorkflow(new List<int>() { 1, 2, 3 }).Success); Assert.IsFalse(accessReq.FinalizeRequest().Success); Assert.IsFalse(accessReq.RequestChanged().Success); accessReq.Ack(); Assert.IsFalse(accessReq.CreateServiceDeskTicket().Success); Assert.IsFalse(accessReq.Ack().Success); Assert.IsFalse(accessReq.FinalizeRequest().Success); Assert.IsFalse(accessReq.RequestChanged().Success); } }
public void ShouldHandleUpdateCreateWorkFlowByRemovingTechApproval() { int goneWFid = 0; // set up for first request to change using (var db = new SNAPDatabaseDataContext()) { var accessReq = createTestWorkflow(db, new List<int>() { managerActorId, teamApprovalActorId, windowsServerActorId, //databaseActorId, //networkShareActorId }); // get manager approal var wfs = accessReq.FindApprovalTypeWF(db, (byte)ActorApprovalType.Manager); Assert.IsTrue( wfs[0].SNAP_Workflow_States.Single( s => s.workflowStatusEnum == (byte)WorkflowState.Pending_Approval).completedDate == null); accessReq.WorkflowAck(wfs[0].pkId, WorkflowAction.Approved); // get team approval wfs = accessReq.FindApprovalTypeWF(db, (byte)ActorApprovalType.Team_Approver); accessReq.WorkflowAck(wfs[0].pkId, WorkflowAction.Approved); goneWFid = wfs[0].pkId; // get technical approval, but the last one request to change wfs = accessReq.FindApprovalTypeWF(db, (byte)ActorApprovalType.Technical_Approver); //accessReq.WorkflowAck(wfs[0].pkId, WorkflowAction.Approved); //accessReq.WorkflowAck(wfs[1].pkId, WorkflowAction.Approved); accessReq.WorkflowAck(wfs[0].pkId, WorkflowAction.Change, "change it"); } using (var db = new SNAPDatabaseDataContext()) { var req = db.SNAP_Requests.Single(x => x.submittedBy == "UnitTester"); var accessReq = new AccessRequest(req.pkId); Assert.IsTrue(req.statusEnum == (byte)RequestState.Change_Requested); var wfs = accessReq.FindApprovalTypeWF(db, (byte)ActorApprovalType.Technical_Approver); //verifyWorkflowStateComplete(wfs[0], WorkflowState.Approved); //verifyWorkflowStateComplete(wfs[1], WorkflowState.Approved); verifyWorkflowStateComplete(wfs[0], WorkflowState.Change_Requested); verifyWorkflowComment(wfs[0], CommentsType.Requested_Change); wfs = accessReq.FindApprovalTypeWF(db, (byte)ActorApprovalType.Workflow_Admin); Assert.IsTrue(wfs[0].SNAP_Workflow_States.Single(s => s.workflowStatusEnum == (byte)WorkflowState.Change_Requested).completedDate == null); } // recreate wf using (var db = new SNAPDatabaseDataContext()) { var req = db.SNAP_Requests.Single(x => x.submittedBy == "UnitTester"); var accessReq = new AccessRequest(req.pkId); accessReq.RequestChanged(); accessReq.Ack(); accessReq.CreateWorkflow(new List<int>() { managerActorId, //teamApprovalActorId, windowsServerActorId, //databaseActorId, //networkShareActorId }); // get technical approval, but the last one request to change var wfs = accessReq.FindApprovalTypeWF(db, (byte)ActorApprovalType.Technical_Approver); Assert.IsTrue(wfs.Count == 1); /* var noSuchWorkflow = db.SNAP_Workflows.Where(w => w.actorId == teamApprovalActorId); Assert.IsTrue(noSuchWorkflow.Count() == 0); */ var noSuchWorkflow = req.SNAP_Workflows.Where(w => w.actorId == teamApprovalActorId); Assert.IsTrue(noSuchWorkflow.Count() == 0); var noSuchWorkflowState = db.SNAP_Workflow_States.Where(s => s.workflowId == goneWFid); //var noSuchWorkflowState = reNAP_Workflow_States.Where(s => s.workflowId == goneWFid); Assert.IsTrue(noSuchWorkflowState.Count() == 0); var noSuchWorkflowComment = db.SNAP_Workflow_Comments.Where(c => c.workflowId == goneWFid); Assert.IsTrue(noSuchWorkflowComment.Count() == 0); } }
public void ShouldCreateWorkflowByAccessTeam() { using (var db = new SNAPDatabaseDataContext()) { var req = db.SNAP_Requests.Single(x => x.submittedBy == "UnitTester"); var accessReq = new AccessRequest(req.pkId); accessReq.Ack(); accessReq.CreateWorkflow(new List<int>() { managerActorId }); var accessTeamWF = db.SNAP_Workflows.Single(x => x.requestId == req.pkId && x.actorId == accessTeamActorId); var accessTeamWFStates = db.SNAP_Workflow_States.Where(x => x.workflowId == accessTeamWF.pkId); foreach (var s in accessTeamWFStates) { Console.WriteLine(s.workflowId + "," + s.workflowStatusEnum + "," + ((s.completedDate != null) ? s.completedDate.ToString() : "TBD")); } verifyWorkflowState(accessTeamWF, WorkflowState.Workflow_Created); var managerWF = db.SNAP_Workflows.Single(x => x.requestId == req.pkId && x.actorId == managerActorId); var managerWFStates = db.SNAP_Workflow_States.Where(x => x.workflowId == managerWF.pkId); foreach (var s in managerWFStates) { Console.WriteLine(s.workflowId + "," + s.workflowStatusEnum + "," + ((s.completedDate != null) ? s.completedDate.ToString() : "TBD")); } verifyWorkflowStateComplete(managerWF, WorkflowState.Not_Active); verifyWorkflowState(managerWF, WorkflowState.Pending_Approval); } }
public void ShouldHandleTechicalApprovalDeniedRequest() { using (var db = new SNAPDatabaseDataContext()) { var accessReq = createTestWorkflow(db, new List<int>() { managerActorId, teamApprovalActorId, windowsServerActorId, databaseActorId, networkShareActorId }); // get manager approval var wfs = accessReq.FindApprovalTypeWF(db, (byte)ActorApprovalType.Manager); Assert.IsTrue(wfs[0].SNAP_Workflow_States.Single(s => s.workflowStatusEnum == (byte)WorkflowState.Pending_Approval).completedDate == null); accessReq.WorkflowAck(wfs[0].pkId, WorkflowAction.Approved); // get team approval wfs = accessReq.FindApprovalTypeWF(db, (byte)ActorApprovalType.Team_Approver); accessReq.WorkflowAck(wfs[0].pkId, WorkflowAction.Approved); // get technical disapproval wfs = accessReq.FindApprovalTypeWF(db, (byte)ActorApprovalType.Technical_Approver); accessReq.WorkflowAck(wfs[0].pkId, WorkflowAction.Denied, "Bad!!!"); } using (var db = new SNAPDatabaseDataContext()) { var req = db.SNAP_Requests.Single(x => x.submittedBy == "UnitTester"); var accessReq = new AccessRequest(req.pkId); var wfs = accessReq.FindApprovalTypeWF(db, (byte)ActorApprovalType.Workflow_Admin); verifyWorkflowStateComplete(wfs[0], WorkflowState.Workflow_Created); verifyWorkflowStateComplete(wfs[0], WorkflowState.Closed_Denied); Assert.IsTrue(req.statusEnum == (byte)RequestState.Closed); var wf = accessReq.FindApprovalTypeWF(db, (byte)ActorApprovalType.Technical_Approver)[0]; Assert.IsTrue(wf.SNAP_Workflow_Comments.Count(c => c.commentTypeEnum == (byte)CommentsType.Denied) > 0); verifyWorkflowComment(wf, CommentsType.Denied); } }
public void ShouldHandleTeamApproverRequestToChange() { using (var db = new SNAPDatabaseDataContext()) { var accessReq = createTestWorkflow(db, new List<int>() { managerActorId, teamApprovalActorId, windowsServerActorId, databaseActorId, networkShareActorId }); // get manager approal var wfs = accessReq.FindApprovalTypeWF(db, (byte)ActorApprovalType.Manager); Assert.IsTrue(wfs[0].SNAP_Workflow_States.Single(s => s.workflowStatusEnum == (byte)WorkflowState.Pending_Approval).completedDate == null); accessReq.WorkflowAck(wfs[0].pkId, WorkflowAction.Approved); // get team approer request to change wfs = accessReq.FindApprovalTypeWF(db, (byte)ActorApprovalType.Team_Approver); accessReq.WorkflowAck(wfs[0].pkId, WorkflowAction.Change); /* accessReq.RequestChanged(); */ } using (var db = new SNAPDatabaseDataContext()) { var req = db.SNAP_Requests.Single(x => x.submittedBy == "UnitTester"); var accessReq = new AccessRequest(req.pkId); Assert.IsTrue(req.statusEnum == (byte)RequestState.Change_Requested); var wfs = accessReq.FindApprovalTypeWF(db, (byte)ActorApprovalType.Team_Approver); Assert.IsTrue(wfs[0].SNAP_Workflow_States.Single(s => s.workflowStatusEnum == (byte)WorkflowState.Change_Requested).completedDate != null); verifyWorkflowStateComplete(wfs[0], WorkflowState.Change_Requested); wfs = accessReq.FindApprovalTypeWF(db, (byte)ActorApprovalType.Workflow_Admin); Assert.IsTrue(wfs[0].SNAP_Workflow_States.Single(s => s.workflowStatusEnum == (byte)WorkflowState.Change_Requested).completedDate == null); verifyWorkflowState(wfs[0], WorkflowState.Change_Requested); } }
public void ShouldHandleRemoveLastAproverAfterAllApproved() { using (var db = new SNAPDatabaseDataContext()) { var accessReq = createTestWorkflow(db,new List<int>() { managerActorId, windowsServerActorId, databaseActorId, }); // get manager approval var wfs = accessReq.FindApprovalTypeWF(db, (byte)ActorApprovalType.Manager); Assert.IsTrue(wfs[0].SNAP_Workflow_States.Single(s => s.workflowStatusEnum == (byte)WorkflowState.Pending_Approval).completedDate == null); accessReq.WorkflowAck(wfs[0].pkId, WorkflowAction.Approved); wfs = accessReq.FindApprovalTypeWF(db, (byte)ActorApprovalType.Technical_Approver); accessReq.WorkflowAck(wfs[0].pkId, WorkflowAction.Approved); accessReq.EditWorkflow(managerUserId, new List<int>() { databaseActorId }); } using (var db = new SNAPDatabaseDataContext()) { var req = db.SNAP_Requests.Single(x => x.submittedBy == "UnitTester"); var accessReq = new AccessRequest(req.pkId); var wfs = accessReq.FindApprovalTypeWF(db, (byte)ActorApprovalType.Workflow_Admin); verifyWorkflowTransition(wfs[0], WorkflowState.Workflow_Created, WorkflowState.Approved); } }
public void ShouldHandleCreateSDTicket() { using (var db = new SNAPDatabaseDataContext()) { var accessReq = createTestWorkflow(db, new List<int>() { managerActorId, teamApprovalActorId, windowsServerActorId, //databaseActorId, //networkShareActorId }); // get manager approal var wfs = accessReq.FindApprovalTypeWF(db, (byte)ActorApprovalType.Manager); Assert.IsTrue(wfs[0].SNAP_Workflow_States.Single(s => s.workflowStatusEnum == (byte)WorkflowState.Pending_Approval).completedDate == null); accessReq.WorkflowAck(wfs[0].pkId, WorkflowAction.Approved); // get team approval wfs = accessReq.FindApprovalTypeWF(db, (byte)ActorApprovalType.Team_Approver); accessReq.WorkflowAck(wfs[0].pkId, WorkflowAction.Approved); // get technical approval wfs = accessReq.FindApprovalTypeWF(db, (byte)ActorApprovalType.Technical_Approver); accessReq.WorkflowAck(wfs[0].pkId, WorkflowAction.Approved); // create SD ticket accessReq.CreateServiceDeskTicket(); // For dev: // login to to http://awhdht02.devapollogrp.edu/CAisd/pdmweb.exe // sign in as svc_cap/S31H9D&2j6 // look at Change Orders/Unassinged/all } using (var db = new SNAPDatabaseDataContext()) { var req = db.SNAP_Requests.Single(x => x.submittedBy == "UnitTester"); var accessReq = new AccessRequest(req.pkId); var wfs = accessReq.FindApprovalTypeWF(db, (byte)ActorApprovalType.Workflow_Admin); verifyWorkflowStateComplete(wfs[0], WorkflowState.Approved); Assert.IsTrue(wfs[0].SNAP_Workflow_States.Single(s => s.workflowStatusEnum == (byte)WorkflowState.Pending_Provisioning).completedDate == null); Assert.IsNotNull(req.ticketNumber); } }
public void ShouldHandleFinalizeRequestWithSDticket() { using (var db = new SNAPDatabaseDataContext()) { var accessReq = createTestWorkflow(db, new List<int>() { managerActorId, teamApprovalActorId, windowsServerActorId, //databaseActorId, //networkShareActorId }); // get manager approal var wfs = accessReq.FindApprovalTypeWF(db, (byte)ActorApprovalType.Manager); Assert.IsTrue(wfs[0].SNAP_Workflow_States.Single(s => s.workflowStatusEnum == (byte)WorkflowState.Pending_Approval).completedDate == null); accessReq.WorkflowAck(wfs[0].pkId, WorkflowAction.Approved); // get team approval wfs = accessReq.FindApprovalTypeWF(db, (byte)ActorApprovalType.Team_Approver); accessReq.WorkflowAck(wfs[0].pkId, WorkflowAction.Approved); // get technical approval wfs = accessReq.FindApprovalTypeWF(db, (byte)ActorApprovalType.Technical_Approver); accessReq.WorkflowAck(wfs[0].pkId, WorkflowAction.Approved); // create SD ticket //accessReq.CreateServiceDeskTicket(); // finalize it accessReq.FinalizeRequest(); } using (var db = new SNAPDatabaseDataContext()) { var req = db.SNAP_Requests.Single(x => x.submittedBy == "UnitTester"); var accessReq = new AccessRequest(req.pkId); var wfs = accessReq.FindApprovalTypeWF(db, (byte)ActorApprovalType.Workflow_Admin); //verifyWorkflowStateComplete(wfs[0], WorkflowState.Pending_Provisioning); verifyWorkflowStateComplete(wfs[0], WorkflowState.Closed_Completed); Assert.IsTrue(req.statusEnum == (byte)RequestState.Closed); } }
public void ShouldRequestToChangeByAccessTeanMultipleTimes() { var accessTeamId = 1; for (int i = 0; i < 5; i++) { using (var db = new SNAPDatabaseDataContext()) { var accessReq = createAndAckAccessReq(db); //accessReq.RequestToChange("Please change it"); accessReq.RequestToChange(accessTeamId, "Please change it"); } using (var db = new SNAPDatabaseDataContext()) { var req = db.SNAP_Requests.Single(x => x.submittedBy == "UnitTester"); Assert.IsTrue(req.statusEnum == (byte) RequestState.Change_Requested); Assert.IsTrue(req.SNAP_Workflows[0].SNAP_Workflow_States.Count(s => s.workflowStatusEnum == (byte) WorkflowState.Change_Requested) > i); Assert.IsTrue(req.SNAP_Workflows[0].SNAP_Workflow_Comments.Count(c => c.commentTypeEnum == (byte) CommentsType.Requested_Change) > i); } using (var db = new SNAPDatabaseDataContext()) { var req = db.SNAP_Requests.Single(x => x.submittedBy == "UnitTester"); var accessReq = new AccessRequest(req.pkId); accessReq.RequestChanged(); } using (var db = new SNAPDatabaseDataContext()) { var req = db.SNAP_Requests.Single(x => x.submittedBy == "UnitTester"); Assert.IsTrue(req.statusEnum == (byte) RequestState.Open); var cnt = i + 1; Assert.IsTrue(req.SNAP_Workflows[0].SNAP_Workflow_States.Count(s => s.workflowStatusEnum == (byte) WorkflowState.Pending_Acknowledgement) > cnt); } } }
public void ShouldHandleFromManagerToTeamOnly() { using (var db = new SNAPDatabaseDataContext()) { var accessReq = createTestWorkflow(db, new List<int>() { managerActorId, teamApprovalActorId, }); // get manager approal var wfs = accessReq.FindApprovalTypeWF(db, (byte)ActorApprovalType.Manager); Assert.IsTrue(wfs[0].SNAP_Workflow_States.Single(s => s.workflowStatusEnum == (byte)WorkflowState.Pending_Approval).completedDate == null); accessReq.WorkflowAck(wfs[0].pkId, WorkflowAction.Approved); } using (var db = new SNAPDatabaseDataContext()) { var req = db.SNAP_Requests.Single(x => x.submittedBy == "UnitTester"); var accessReq = new AccessRequest(req.pkId); var wfs = accessReq.FindApprovalTypeWF(db, (byte)ActorApprovalType.Manager); verifyWorkflowStateComplete(wfs[0], WorkflowState.Pending_Approval); verifyWorkflowStateComplete(wfs[0], WorkflowState.Approved); wfs = accessReq.FindApprovalTypeWF(db, (byte)ActorApprovalType.Team_Approver); verifyWorkflowState(wfs[0], WorkflowState.Pending_Approval); wfs = accessReq.FindApprovalTypeWF(db, (byte)ActorApprovalType.Workflow_Admin); Assert.IsTrue( wfs[0].SNAP_Workflow_States.Count( w => w.completedDate == null && w.workflowStatusEnum == (byte) WorkflowState.Workflow_Created) == 1); } }
public void ShouldReturnWorkflowIdByFromRequestIDAndUsrId() { SNAP_Request req; SNAP_Workflow wf; AccessRequest accessReq; using (var db = new SNAPDatabaseDataContext()) { req = db.SNAP_Requests.Single(x => x.submittedBy == "UnitTester"); accessReq = new AccessRequest(req.pkId); accessReq.Ack(); accessReq.CreateWorkflow(new List<int>() {managerActorId, teamApprovalActorId, windowsServerActorId,databaseActorId,networkShareActorId}); //Assert.IsTrue(db.GetActiveWorkflowId(req.pkId, managerUserId) == managerActorId); Assert.IsTrue(db.GetActiveWorkflowId(req.pkId, managerUserId) != 0); // they are not active approver yet //Assert.IsTrue(db.GetActiveWorkflowId(req.pkId, teamApprovalUserId) == 0); //Assert.IsTrue(db.GetActiveWorkflowId(req.pkId, WindowsServerUserId) == 0); wf = accessReq.FindApprovalTypeWF(db, (byte) ActorApprovalType.Manager)[0]; accessReq.WorkflowAck(wf.pkId, WorkflowAction.Approved); } using (var db = new SNAPDatabaseDataContext()) { req = db.SNAP_Requests.Single(x => x.submittedBy == "UnitTester"); // this is the only active approver //Assert.IsTrue(db.GetActiveWorkflowId(req.pkId, teamApprovalUserId) == teamApprovalActorId); Assert.IsTrue(db.GetActiveWorkflowId(req.pkId, teamApprovalUserId) != 0); // this are not active approver //Assert.IsTrue(db.GetActiveWorkflowId(req.pkId, managerUserId) == 0); //Assert.IsTrue(db.GetActiveWorkflowId(req.pkId, WindowsServerUserId) == 0); } using (var db = new SNAPDatabaseDataContext()) { req = db.SNAP_Requests.Single(x => x.submittedBy == "UnitTester"); wf = accessReq.FindApprovalTypeWF(db, (byte) ActorApprovalType.Team_Approver)[0]; accessReq.WorkflowAck(wf.pkId, WorkflowAction.Approved); } using (var db = new SNAPDatabaseDataContext()) { // these are active approvers /* Assert.IsTrue(db.GetActiveWorkflowId(req.pkId, WindowsServerUserId) == windowsServerActorId); Assert.IsTrue(db.GetActiveWorkflowId(req.pkId, networkShareUserId) == networkShareActorId); Assert.IsTrue(db.GetActiveWorkflowId(req.pkId, databaseUserId) == databaseActorId); */ Assert.IsTrue(db.GetActiveWorkflowId(req.pkId, WindowsServerUserId) != 0); Assert.IsTrue(db.GetActiveWorkflowId(req.pkId, networkShareUserId) != 0); Assert.IsTrue(db.GetActiveWorkflowId(req.pkId, databaseUserId) != 0); // there are not active approvers //Assert.IsTrue(db.GetActiveWorkflowId(req.pkId, managerUserId) == 0); //Assert.IsTrue(db.GetActiveWorkflowId(req.pkId, teamApprovalUserId) == 0); } }
static bool overdue(SNAP_Workflow_State wfState, string overdueType) { DateTime dueDate = DateTime.Parse(wfState.dueDate.ToString()); TimeSpan diff = DateTime.Now.Subtract(dueDate); int overdueAlertIntervalInDays = Convert.ToInt16(ConfigurationManager.AppSettings["OverdueAlertIntervalInDays"]); int overdueAlertMaxDay = Convert.ToInt16(ConfigurationManager.AppSettings["OverdueAlertMaxDay"]); if (overdueAlertMaxDay <= 0 || overdueAlertIntervalInDays <= 0) return false; if (wfState.workflowStatusEnum != (byte)WorkflowState.Pending_Approval && wfState.workflowStatusEnum != (byte)WorkflowState.Change_Requested) return false; if (diff.Days >= overdueAlertMaxDay && (wfState.workflowStatusEnum == (byte)WorkflowState.Pending_Approval || wfState.workflowStatusEnum == (byte)WorkflowState.Change_Requested)) { var accessReq = new AccessRequest(wfState.SNAP_Workflow.requestId); accessReq.NoAccess(WorkflowAction.Abandon, string.Format("Request has been abandoned because of inactivity. Maximum overdue days ({0}) for action reached.", overdueAlertMaxDay)); return false; } if (diff.Days < overdueAlertMaxDay && diff.Days > 0) { // at least more than 24 hours over due if (diff.Days % overdueAlertIntervalInDays == 1 || overdueAlertIntervalInDays == 1) // also every x interval days to send alert { if (wfState.workflowStatusEnum == (byte)WorkflowState.Pending_Approval || wfState.workflowStatusEnum == (byte)WorkflowState.Change_Requested) { wfState.SNAP_Workflow.SNAP_Workflow_Comments.Add(new SNAP_Workflow_Comment() { commentText = "Overdue: " + overdueType.Replace('_', ' '), commentTypeEnum = (byte) CommentsType.Email_Reminder, createdDate = DateTime.Now }); return true; } } } return false; }
private AccessRequest createAndAckAccessReq(SNAPDatabaseDataContext db) { var req = db.SNAP_Requests.Single(x => x.submittedBy == "UnitTester"); var accessReq = new AccessRequest(req.pkId); accessReq.Ack(); return accessReq; }
public static WebMethodResponse AccessComments(int requestId, CommentsType action, string comments) { var accessReq = new AccessRequest(requestId); comments = comments.FromJSONStringToObj<string>(); return accessReq.AddComment(comments, action); }
public void ShouldHandleFromManagerToTeamToLastTechicalRequestToChangeLoop() { // set up for first request to change using (var db = new SNAPDatabaseDataContext()) { var accessReq = createTestWorkflow(db, new List<int>() { managerActorId, teamApprovalActorId, windowsServerActorId, databaseActorId, networkShareActorId }); // get manager approal var wfs = accessReq.FindApprovalTypeWF(db, (byte)ActorApprovalType.Manager); Assert.IsTrue( wfs[0].SNAP_Workflow_States.Single( s => s.workflowStatusEnum == (byte)WorkflowState.Pending_Approval).completedDate == null); accessReq.WorkflowAck(wfs[0].pkId, WorkflowAction.Approved); // get team approval wfs = accessReq.FindApprovalTypeWF(db, (byte)ActorApprovalType.Team_Approver); accessReq.WorkflowAck(wfs[0].pkId, WorkflowAction.Approved); // get technical approval, but the last one request to change wfs = accessReq.FindApprovalTypeWF(db, (byte)ActorApprovalType.Technical_Approver); accessReq.WorkflowAck(wfs[0].pkId, WorkflowAction.Approved); accessReq.WorkflowAck(wfs[1].pkId, WorkflowAction.Approved); accessReq.WorkflowAck(wfs[2].pkId, WorkflowAction.Change, "change it"); } using (var db = new SNAPDatabaseDataContext()) { var req = db.SNAP_Requests.Single(x => x.submittedBy == "UnitTester"); var accessReq = new AccessRequest(req.pkId); Assert.IsTrue(req.statusEnum == (byte)RequestState.Change_Requested); var wfs = accessReq.FindApprovalTypeWF(db, (byte)ActorApprovalType.Technical_Approver); verifyWorkflowStateComplete(wfs[0], WorkflowState.Approved); verifyWorkflowStateComplete(wfs[1], WorkflowState.Approved); verifyWorkflowStateComplete(wfs[2], WorkflowState.Change_Requested); verifyWorkflowComment(wfs[2], CommentsType.Requested_Change); wfs = accessReq.FindApprovalTypeWF(db, (byte)ActorApprovalType.Workflow_Admin); Assert.IsTrue(wfs[0].SNAP_Workflow_States.Single(s => s.workflowStatusEnum == (byte)WorkflowState.Change_Requested).completedDate == null); } for (int i = 0; i < 5; i++) using (var db = new SNAPDatabaseDataContext()) { var req = db.SNAP_Requests.Single(x => x.submittedBy == "UnitTester"); var accessReq = new AccessRequest(req.pkId); accessReq.RequestChanged(); accessReq.Ack(); accessReq.CreateWorkflow(new List<int>() { managerActorId, teamApprovalActorId, windowsServerActorId, //databaseActorId, networkShareActorId }); var accessWF = accessReq.FindApprovalTypeWF(db, (byte)ActorApprovalType.Workflow_Admin); var state = accessWF[0].SNAP_Workflow_States.Single(s => s.workflowStatusEnum == (byte)WorkflowState.Workflow_Created && s.completedDate == null); // get lastest 'pending approval' for the workflowadmin state // get manager approal var wfs = accessReq.FindApprovalTypeWF(db, (byte)ActorApprovalType.Manager); //Assert.IsTrue(wfs[0].SNAP_Workflow_States.Single(s => s.workflowStatusEnum == (byte)WorkflowState.Pending_Approval).completedDate == null); accessReq.WorkflowAck(wfs[0].pkId, WorkflowAction.Approved); Assert.IsTrue( wfs[0].SNAP_Workflow_States.Count( s => s.completedDate != null && s.workflowStatusEnum == (byte)WorkflowState.Approved && s.pkId > state.pkId) == 1); // get team approval wfs = accessReq.FindApprovalTypeWF(db, (byte)ActorApprovalType.Team_Approver); accessReq.WorkflowAck(wfs[0].pkId, WorkflowAction.Approved); Assert.IsTrue( wfs[0].SNAP_Workflow_States.Count( s => s.completedDate != null && s.workflowStatusEnum == (byte)WorkflowState.Approved && s.pkId > state.pkId) == 1); var r = new Random(); //var last = r.Next(2); var last = r.Next(1); //var last = 0; // get only one technical request to change wfs = accessReq.FindApprovalTypeWF(db, (byte)ActorApprovalType.Technical_Approver); for (int x = 0; x <= last; x++) { accessReq.WorkflowAck(wfs[x].pkId, WorkflowAction.Approved); Assert.IsTrue( wfs[0].SNAP_Workflow_States.Count( s => s.completedDate != null && s.workflowStatusEnum == (byte)WorkflowState.Approved && s.pkId > state.pkId) == 1); } accessReq.WorkflowAck(wfs[++last].pkId, WorkflowAction.Change, "change it"); Assert.IsTrue( wfs[last].SNAP_Workflow_States.Count( s => s.completedDate != null && s.workflowStatusEnum == (byte)WorkflowState.Change_Requested && s.pkId > state.pkId) == 1); /* Assert.IsTrue(accessWF[0].SNAP_Workflow_States.Single( s => s.completedDate == null && s.workflowStatusEnum == (byte)WorkflowState.Change_Requested) == 1); */ } }
public void ShouldCreateWorkflowByAccessTeamAndThenMakeModification() { using (var db = new SNAPDatabaseDataContext()) { var accessReq = createTestWorkflow(db, new List<int>() { managerActorId, teamApprovalActorId, windowsServerActorId }); } using (var db = new SNAPDatabaseDataContext()) { var req = db.SNAP_Requests.Single(x => x.submittedBy == "UnitTester"); var accessReq = new AccessRequest(req.pkId); accessReq.EditWorkflow(managerUserId, new List<int>() { windowsServerActorId, databaseActorId, networkShareActorId }); //accessReq.CreateWorkflow(new List<int>() { managerActorId }); var accessTeamWF = db.SNAP_Workflows.Single(x => x.requestId == req.pkId && x.actorId == accessTeamActorId); var accessTeamWFStates = db.SNAP_Workflow_States.Where(x => x.workflowId == accessTeamWF.pkId); foreach (var s in accessTeamWFStates) { Console.WriteLine(s.workflowId + "," + s.workflowStatusEnum + "," + ((s.completedDate != null) ? s.completedDate.ToString() : "TBD")); } verifyWorkflowState(accessTeamWF, WorkflowState.Workflow_Created); var managerWF = db.SNAP_Workflows.Single(x => x.requestId == req.pkId && x.actorId == managerActorId); var managerWFStates = db.SNAP_Workflow_States.Where(x => x.workflowId == managerWF.pkId); foreach (var s in managerWFStates) { Console.WriteLine(s.workflowId + "," + s.workflowStatusEnum + "," + ((s.completedDate != null) ? s.completedDate.ToString() : "TBD")); } verifyWorkflowStateComplete(managerWF, WorkflowState.Not_Active); verifyWorkflowState(managerWF, WorkflowState.Pending_Approval); var wfs = accessReq.FindApprovalTypeWF(db, (byte)ActorApprovalType.Team_Approver); Assert.IsTrue(wfs.Count == 0); wfs = accessReq.FindApprovalTypeWF(db, (byte)ActorApprovalType.Technical_Approver); Assert.IsTrue(wfs.Count == 3); foreach(var wf in wfs) { verifyWorkflowState(wf, WorkflowState.Not_Active); } } }
public void ShouldAllowAccessTeamToComment() { using (var db = new SNAPDatabaseDataContext()) { var req = db.SNAP_Requests.Single(x => x.submittedBy == "UnitTester"); var accessReq = new AccessRequest(req.pkId); accessReq.AddComment("This is access team comment", CommentsType.Access_Notes_AccessTeam); accessReq.AddComment("This is access team for approver comment", CommentsType.Access_Notes_ApprovingManager); accessReq.AddComment("This is access team for requestor comment", CommentsType.Access_Notes_Requestor); accessReq.AddComment("This is access team for superuser comment", CommentsType.Access_Notes_SuperUser); } using (var db = new SNAPDatabaseDataContext()) { var req = db.SNAP_Requests.Single(x => x.submittedBy == "UnitTester"); Assert.IsTrue(req.SNAP_Request_Comments.Count == 4); } }
public static WebMethodResponse EditWorkflow(int requestId, string managerUserId, string actorIds) { var accessReq = new AccessRequest(requestId); List<int> actorsList = GetActorsList(actorIds); return accessReq.EditWorkflow(managerUserId, actorsList); }
public void ShouldCreateWorkflowByAccessTeamUsingMgrUsrId() { var mgrUid = "pxlee"; removeManagerActorByUserId(mgrUid); using (var db = new SNAPDatabaseDataContext()) { var req = db.SNAP_Requests.Single(x => x.submittedBy == "UnitTester"); var accessReq = new AccessRequest(req.pkId); accessReq.Ack(); accessReq.CreateWorkflow(mgrUid, new List<int>() { teamApprovalActorId }); var mgrGroupId = db.SNAP_Actor_Groups.Single(g => g.actorGroupType == (byte) ActorGroupType.Manager).pkId; var newManagerActorId = db.SNAP_Actors.Single(a => a.userId == mgrUid && a.actor_groupId == mgrGroupId).pkId; var accessTeamWF = db.SNAP_Workflows.Single(x => x.requestId == req.pkId && x.actorId == accessTeamActorId); var accessTeamWFStates = db.SNAP_Workflow_States.Where(x => x.workflowId == accessTeamWF.pkId); foreach (var s in accessTeamWFStates) { Console.WriteLine(s.workflowId + "," + s.workflowStatusEnum + "," + ((s.completedDate != null) ? s.completedDate.ToString() : "TBD")); } verifyWorkflowState(accessTeamWF, WorkflowState.Workflow_Created); var managerWF = db.SNAP_Workflows.Single(x => x.requestId == req.pkId && x.actorId == newManagerActorId); var managerWFStates = db.SNAP_Workflow_States.Where(x => x.workflowId == managerWF.pkId); foreach (var s in managerWFStates) { Console.WriteLine(s.workflowId + "," + s.workflowStatusEnum + "," + ((s.completedDate != null) ? s.completedDate.ToString() : "TBD")); } verifyWorkflowStateComplete(managerWF, WorkflowState.Not_Active); verifyWorkflowState(managerWF, WorkflowState.Pending_Approval); } }