Пример #1
0
        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);
        }
Пример #2
0
        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);
                }
            }
        }
Пример #3
0
        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);
            }
        }
Пример #4
0
        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);

            }
        }
Пример #5
0
        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);
                     */

                }
        }