示例#1
0
        public ActionResult PassportReviewForm(string WorkflowID, bool editMode, bool?myEntries)
        {
            Session["UserName"] = @User.Identity.Name;
            this._UserName      = Session["UserName"] as string ?? String.Empty;

            if (_UserName == null || _UserName.Equals(String.Empty))
            {
                ViewBag.ErrorMessage = "You must be logged in to continue.";
                return(RedirectToAction("Login", "Login"));
            }

            //now resolve the user profile from AD and Xceed
            StaffADProfile staffADProfile = new StaffADProfile();

            staffADProfile.user_logon_name = _UserName;

            //AD
            ActiveDirectoryQuery activeDirectoryQuery = new ActiveDirectoryQuery(staffADProfile);

            staffADProfile = activeDirectoryQuery.GetStaffProfile();

            if (staffADProfile == null)
            {
                ViewBag.ErrorMessage = "Your profile is not properly setup on the system. Please contact InfoTech.";
                return(RedirectToAction("AwaitingMyApproval", "AwaitingApproval"));
            }

            //Get the request identified by the workflow id and be sure the user is an approver
            List <RequestDetails> requestDetails = new List <RequestDetails>();

            requestDetails = LINQCalls.getExistingPassportEntry(WorkflowID, staffADProfile.employee_number);

            if (requestDetails == null)
            {
                ViewBag.ErrorMessage = "You are not authorized to process this request";
                return(RedirectToAction("AwaitingMyApproval", "AwaitingApproval"));
            }

            List <PassportDetails> passportDetails = new List <PassportDetails>();
            PassportDetails        pDetails        = LINQCalls.getPassportDetails(WorkflowID);

            passportDetails.Add(pDetails);

            EntryModel entryModel = new EntryModel();

            entryModel     = LINQCalls.getWorkflowEntry(WorkflowID);
            entryModel.DOE = LINQCalls.getXceedProfile(entryModel.StaffNumber).doe;

            ViewBag.StaffBranch = entryModel.Branch;
            int      requeststageid  = entryModel.RequestStageId;
            string   requeststage    = entryModel.RequestStage;
            DateTime requestdate     = entryModel.DateSubmitted;
            string   initiatornumber = entryModel.StaffNumber; //LINQCalls.getInitiatorNumber(WorkflowID) ?? staffADProfile.employee_number;

            string cansave = (!requeststage.Equals(INIT_STAGE) && !requeststage.Equals(DENIED) && !requeststage.Equals(APPROVED) &&
                              !initiatornumber.Equals(staffADProfile.employee_number)) ? "true" : "false";

            XElement  ApprovalHistory = LINQCalls.getApprovalHistory(WorkflowID);
            XDocument xDocument       = DataHandlers.ToXDocument(ApprovalHistory);

            List <ApprovalDetails> approvalHistory = xDocument.Descendants("Approvals").Select(det => new ApprovalDetails
            {
                ApproverNames        = det.Element("ApproverName").Value,
                ApproverStaffNumbers = det.Element("ApproverStaffNumber").Value,
                ApprovedStages       = det.Element("ApprovedStage").Value,
                ApproverAction       = det.Element("ApproverAction").Value,
                ApprovalDateTime     = det.Element("ApprovalDateTime").Value,
                ApproverComments     = det.Element("ApproverComment").Value
            }).ToList();

            SuperPassportModel superPassportModel = new SuperPassportModel();

            if (TempData["superPassportModel"] != null)
            {
                superPassportModel = TempData["superPassportModel"] as SuperPassportModel;
            }
            else
            {
                superPassportModel = new SuperPassportModel {
                    WorkflowID        = WorkflowID,
                    RequestStageID    = entryModel.RequestStageId,
                    RequestStage      = entryModel.RequestStage,
                    RequestDate       = entryModel.DateSubmitted,
                    StaffADProfile    = staffADProfile,
                    RequestDetails    = requestDetails,
                    CanSave           = cansave,
                    ApprovalDetails   = approvalHistory,
                    EntryModel        = entryModel,
                    RequestBranch     = entryModel.Branch,
                    RequestBranchCode = entryModel.BranchCode,
                    PassportDetails   = passportDetails
                };
            }

            Session["requestDetails"] = superPassportModel.RequestDetails;
            TempData["editMode"]      = (editMode == true) ? "true" : "false";

            if (TempData["ErrorMessage"] != null)
            {
                ViewBag.ErrorMessage = TempData["ErrorMessage"] as string;
            }

            Session["superPassportModel"] = superPassportModel;

            TempData["superPassportModel"] = superPassportModel;
            return(View(superPassportModel));
        }
示例#2
0
        public ActionResult ViewPassport(string WorkflowID, bool editMode, bool?myEntries, bool?viewMode)
        {
            Session["UserName"] = @User.Identity.Name;
            this._UserName      = Session["UserName"] as string ?? "";

            if (_UserName == null || _UserName.Equals(String.Empty))
            {
                ViewBag.ErrorMessage = "You must be logged in to continue.";
                return(RedirectToAction("AwaitingMyApproval", "AwaitingApproval"));
            }

            //now resolve the user profile from AD and Xceed
            StaffADProfile staffADProfile = new StaffADProfile();

            staffADProfile.user_logon_name = _UserName;

            //AD
            ActiveDirectoryQuery activeDirectoryQuery = new ActiveDirectoryQuery(staffADProfile);

            staffADProfile             = activeDirectoryQuery.GetStaffProfile();
            staffADProfile.branch_code = LINQCalls.getEntryProfile(WorkflowID).branch_code;
            staffADProfile.branch_name = LINQCalls.getEntryProfile(WorkflowID).branch_name;

            if (staffADProfile == null)
            {
                ViewBag.ErrorMessage = "Your profile is not properly setup on the system. Please contact InfoTech.";
                return(RedirectToAction("AwaitingMyApproval", "AwaitingApproval"));
            }

            //Get the request identified by the workflow id
            List <RequestDetails> requestDetails = new List <RequestDetails>();

            if (myEntries != null && myEntries == true)
            {
                string entrykey = staffADProfile.employee_number + "_" + staffADProfile.branch_code;
                requestDetails = LINQCalls.getExistingPassportEntry(WorkflowID, staffADProfile.employee_number, entrykey);
            }
            else
            {
                requestDetails = LINQCalls.getExistingPassportEntry(WorkflowID, staffADProfile.employee_number);
            }

            EntryModel entryModel = new EntryModel();

            entryModel          = LINQCalls.getWorkflowEntry(WorkflowID);
            ViewBag.StaffBranch = entryModel.Branch;
            int      requeststageid  = entryModel.RequestStageId;
            string   requeststage    = entryModel.RequestStage;
            DateTime requestdate     = entryModel.DateSubmitted;
            string   initiatornumber = LINQCalls.getInitiatorNumber(WorkflowID) ?? staffADProfile.employee_number;

            string cansave = (requeststage.Equals(INIT_STAGE) || requeststage.Equals(DENIED)) && initiatornumber.Equals(staffADProfile.employee_number)
                                            ? "true" : "false";

            staffADProfile.appperiod = entryModel.AppraisalPeriod;

            XElement  ApprovalHistory = LINQCalls.getApprovalHistory(WorkflowID);
            XDocument xDocument       = DataHandlers.ToXDocument(ApprovalHistory);

            List <ApprovalDetails> approvalHistory = xDocument.Descendants("Approvals").Select(det => new ApprovalDetails
            {
                ApproverNames        = det.Element("ApproverName").Value,
                ApproverStaffNumbers = det.Element("ApproverStaffNumber").Value,
                ApprovedStages       = det.Element("ApprovedStage").Value,
                ApproverAction       = det.Element("ApproverAction").Value,
                ApprovalDateTime     = det.Element("ApprovalDateTime").Value
            })
                                                     .ToList();

            SuperPassportModel superPassportModel = new SuperPassportModel();

            if (TempData["superPassportModel"] != null)
            {
                superPassportModel = TempData["superPassportModel"] as SuperPassportModel;
            }
            else
            {
                superPassportModel = new SuperPassportModel {
                    WorkflowID        = WorkflowID,
                    RequestStageID    = entryModel.RequestStageId,
                    RequestStage      = entryModel.RequestStage,
                    RequestDate       = entryModel.DateSubmitted,
                    StaffADProfile    = staffADProfile,
                    RequestDetails    = requestDetails,
                    CanSave           = cansave,
                    ApprovalDetails   = approvalHistory,
                    EntryModel        = entryModel,
                    RequestBranch     = entryModel.Branch,
                    RequestBranchCode = entryModel.BranchCode
                };
            }

            Session["requestDetails"] = superPassportModel.RequestDetails;
            TempData["editMode"]      = (editMode == true) ? null : "false";

            if (TempData["ErrorMessage"] != null)
            {
                ViewBag.ErrorMessage = TempData["ErrorMessage"] as string;
            }

            TempData["superPassportModel"] = superPassportModel;
            return(RedirectToAction("PassportInputForm"));
        }