Пример #1
0
        // This method is now obsolete!
        public void btnWF_Clicked(object sender, EventArgs e)
        {
            ASPxButton pButton = (ASPxButton)sender;

            // This could change - and we should add a tool tip
            String sAction = pButton.Text;

            // Hopefully, this is always set!

            if (Assignment != null)
            {
                // We found a winner!
                // OK - we should now have the assignment ID right in the workflow item!
                WFEngine pWFEngine = GetWFEngine();

                // Handle item with the specified action
                pWFEngine.HandleItemAsync(Assignment.WFAssignId, sAction, null);

                // Change to this if we put this in a callback!
                ASPxWebControl.RedirectOnCallback("/Default.aspx");

                // This doesn't work in a callback!
                // Response.Redirect ("/Default.aspx");
            }
        }
Пример #2
0
        public JsonResult Reject(string wfInstId)
        {
            var    engine  = new WFEngine();
            var    userDal = new UserDAL();
            User   user    = userDal.Get().Where(p => p.WorkflowInstId == Guid.Parse(wfInstId)).FirstOrDefault();
            string ret     = engine.ExecuteWF(user, true);
            RetMsg msg     = new RetMsg();

            if (string.IsNullOrEmpty(ret))
            {
                msg.Code = -1;
                msg.Msg  = "流程" + wfInstId + "驳回失败!";
            }
            else
            {
                msg.Code = 0;
                msg.Msg  = "流程" + wfInstId + "驳回成功!当前节点" + ret;
                msg.Tag  = ret;
                //WFinstanceDAL wfDal = new WFinstanceDAL();
                //WFInstance inst = new WFInstance();
                //inst.WfInstanceId = Guid.Parse(wfInstId);
                //inst.State = nodeName + ",驳回";
                //inst.ApproveTime = DateTime.Now;
                //inst.ApproveUser = "******";
                //wfDal.Update(inst);
            }
            return(Json(msg, JsonRequestBehavior.AllowGet));
        }
Пример #3
0
        protected void cbMasterAction_Callback(object source, CallbackEventArgs e)
        {
            // I'm not sure the action can ever be "Save" at this point
            // This needs to be tightened up...
            if (!e.Parameter.StartsWith("Save"))
            {
                // Handle the workflow action

                // OK - if we get here - assume it's a workflow command
                String sAction = e.Parameter;

                // For now - find the workflow item
                if (Assignment != null)
                {
                    // We found a winner!
                    // OK - we should now have the assignment ID right in the workflow item!
                    WFEngine pWFEngine = GetWFEngine();

                    // Handle item with the specified action
                    pWFEngine.HandleItemAsync(Assignment.WFAssignId, sAction, null);

                    // We'll let the caller do the redirect now
                    // If it's submitted - we never want to stay on this page
                    // ASPxWebControl.RedirectOnCallback ("/Default.aspx");
                }
            }

            e.Result = e.Parameter;
        }
Пример #4
0
        // This is the same as above, except with the addition of a comment to the WF
        protected void cbComments_Callback(object sender, CallbackEventArgsBase e)
        {
            String sAction = e.Parameter;

            //Updating the default comments
            string mainComments = "";

            switch (sAction)
            {
            case "Approve":
                mainComments = "Approved.";
                break;

            case "Revise/Hold":
                mainComments = "Sending to creator for revision because - " + txtComments.Text;
                break;

            case "Decline":
                mainComments = "This was declined because - " + txtComments.Text;
                break;

            default:
                mainComments = "n/a";
                break;
            }

            // Add the comment to the CAR - we'll also add it to the assignment
            // For now - find the workflow item
            if (Assignment != null)
            {
                eCAR3Entities pContext = new eCAR3Entities();
                CARComment    pComment = new CARComment();

                pComment.Comments       = mainComments;
                pComment.UserId         = User.UserId;
                pComment.CARId          = CAR.CARId;
                pComment.Flags          = 0;
                pComment.Recommendation = 0;

                pComment.WFAssignId = Assignment.WFAssignId;
                pContext.CARComments.Add(pComment);
                pComment.Timestmp = DateTime.Now;
                pContext.SaveChanges();

                // We found a winner!
                // OK - we should now have the assignment ID right in the workflow item!
                WFEngine pWFEngine = GetWFEngine();

                // Handle item with the specified action
                pWFEngine.HandleItemAsync(Assignment.WFAssignId, sAction, mainComments);

                // Change to this if we put this in a callback!
                ASPxWebControl.RedirectOnCallback("/Default.aspx");
            }
        }
Пример #5
0
        public JsonResult Approve(string wfInstId)
        {
            var    engine   = new WFEngine();
            var    userDal  = new UserDAL();
            User   user     = userDal.Get().Where(p => p.WorkflowInstId == Guid.Parse(wfInstId)).FirstOrDefault();
            string nodeName = engine.ExecuteWF(user);
            RetMsg msg      = new RetMsg();

            if (string.IsNullOrEmpty(nodeName))
            {
                msg.Code = -1;
                msg.Msg  = "流程" + wfInstId + "执行失败!";
            }
            else
            {
                msg.Code = 0;
                msg.Msg  = "流程" + wfInstId + "执行成功!当前节点" + nodeName;
                msg.Tag  = nodeName;
            }
            return(Json(msg, JsonRequestBehavior.AllowGet));
        }
Пример #6
0
        public ActionResult Edit(User user)
        {
            var userDAL = new UserDAL();

            //新增

            if (user.ID < 1)
            {
                user = userDAL.Add(user);
                var engine = new WFEngine();
                engine.ExecuteWF(user);
                //更新wfid
                userDAL.Update(user);
            }
            else
            {
                //编辑
                userDAL.Update(user);
            }

            Redirect("~/Register/Edit");
            return(View());
        }
Пример #7
0
        protected void cbCreateCAR_Callback(object source, CallbackEventArgs e)
        {
            // Create a new CAR here and redirect to its page...
            eCAR3Entities pContext = new eCAR3Entities();
            CARMaster     pCAR     = new CARMaster();

            string[] parameters = e.Parameter.Split(';');

            string orgInformation   = parameters[0]; // orgId + '|' + locName + '|' + orgPath;
            string orgId            = orgInformation.Split('|')[0];
            string orgLocationName  = orgInformation.Split('|')[1];
            string orgPath          = orgInformation.Split('|')[2];
            var    divisonCharacter = orgPath.Substring(0, 1).ToUpper();

            //var threeCharacterLocation = orgLocationName.Replace(/\s +/ g, '').replace(/\./ g, '').substring(0, 3).toUpperCase();
            var threeCharacterLocation   = orgLocationName.Substring(0, 3).ToUpper();
            var twoDigitYear             = DateTime.Now.Year.ToString().Substring(2, 2); // produces two digit year -- Ex. 2019 = "19"
            var threeDigitUniqueSequence = "XXX";                                        // The database trigger will make this a unique sequential number.
            var projectNumber            = divisonCharacter + '-' + threeCharacterLocation + '-' + twoDigitYear + '-' + threeDigitUniqueSequence;

            string pillarInformation = parameters[1]; // pillarId + '|' + pillarName + '|' + decr;
            string pillarId          = pillarInformation.Split('|')[0];
            string pillarName        = pillarInformation.Split('|')[1];
            string pillarDescr       = pillarInformation.Split('|')[2];

            pCAR.OrgId           = orgId;
            pCAR.ProjectNumber   = projectNumber;
            pCAR.CreatedByUserId = UserId;
            pCAR.CreatedByName   = UserDisplayName;
            pCAR.ProjectTitle    = txtTitle.Text;
            pCAR.CreateTime      = DateTime.Now;
            pCAR.ProjectTypeId   = cbProjectType.Value.ToString(); // Set the dropdown ProjectTypeId
            pCAR.InterestRate    = 0.000;                          // Updated Interest Rate to 0.000
            pCAR.ExchangeRate    = 0;                              // Updated Exchange Rate to 0
            pCAR.UsefulLifeYears = 0;                              // Updated Useful Life Years to 0
            pCAR.LeaseTermYears  = 0;                              // Updated Lease Term Years to 0
            pCAR.NPV             = 0;                              // Updated NPV to 0
            pCAR.IRR             = 0;                              // Updated IRR to 0
            pCAR.CurrencyTypeId  = 1;                              // Updated Currency Type to U.S. Dollar

            //Set Desc fields to empty
            pCAR.ProjectDesc          = "";
            pCAR.ProjectReason        = "";
            pCAR.ProjectJustification = "";
            pCAR.FiscalYear           = DateTime.Now.Year;      // Updated Fiscal Year to current year
            pCAR.PillarId             = pillarId;               // Set the dropdown PillarId
            pCAR.Status = "Active";

            pContext.CARMasters.Add(pCAR);
            pContext.SaveChanges(); // TODD: If we could remove this it may speed things up a bit.

            // We now have the CAR Id
            AddCostSheet(pContext, pCAR.CARId, 1);
            AddCostSheet(pContext, pCAR.CARId, 2);
            AddCostSheet(pContext, pCAR.CARId, 3);
            AddCostSheet(pContext, pCAR.CARId, 4);

            // Bootstrap the workflow process
            // This should probably not be here
            // This should be a function in the workflow engine!
            WFEngine pEngine = GetWFEngine();

            WF pWF = pEngine.CreateWorkflow(pCAR.CARId);

            // This call assigns the workflow to an individual user
            string sURL = pEngine.Assign(pWF, "Create", "CREATE", UserId, null, pCAR.CARId.ToString());

            // Redirect the users browser to the newly create CAR.
            //ASPxWebControl.RedirectOnCallback(sURL); // I removed this because the line below may be a tiny bit faster.
            cbCreateCAR.JSProperties ["cp_result"] = sURL; // Return to the client side where the JavaScript redirects to this CAR page.
        }
Пример #8
0
        // This fixes up the buttons
        // I'm not sure where the Session comes from
        protected void Page_Load(object sender, EventArgs e)
        {
            //Set CARId to hidden field
            hfCARId.Value = CAR.CARId.ToString();

            // Prevent spoofing
            if (Assignment != null && Assignment.UserId != Master.UserId)
            {
                // You appear to have spoofed the page
                Response.Redirect("~/Unauthorized.aspx");
                return;
            }

            // Nothing further to do with no assignment
            if (Assignment == null)
            {
                //Does user have super user or admin role?
                if (User.HasRole(Role.ADMIN) || User.HasRole(Role.SUPER))
                {
                    //Enable Comments button
                    btnAddComments.ClientVisible = true;
                }



                if (User.HasRole(Role.SUPER) || User.UserName == "Anderson, Howard") //#PFG-KLUDGE
                {
                    btnPrintPowerPoint.ClientVisible = true;                         //Enable PowerPoint Print button
                    btnSave.ClientVisible            = true;                         //Enable Save button
                }

                return;
            }

            // Be sure that this item is still assigned to you
            if (Assignment.CurStatus != "Assigned")
            {
                string sDoneParam = Request["done"];
                if (sDoneParam == null || sDoneParam != "1")
                {
                    Response.Redirect("~/InvalidWorkItem.aspx");
                    return;
                }
            }

            int i = 0;
            List <ASPxButton> lsButtons = new List <ASPxButton>
            {
                btnWF0,
                btnWF1,
                btnWF2,
                btnWF3,
                btnWF4
            };


            foreach (ASPxButton pButton in lsButtons)
            {
                pButton.Visible = false;
            }

            if (Assignment.CurStatus == "Assigned")
            {
                // Do not enable workflow buttons if the item is already done
                btnAddComments.ClientVisible = true;        //Enable Comments button

                //Does user not have super user role?
                if (User.HasRole(Role.SUPER) || User.UserName == "Anderson, Howard") //#PFG-KLUDGE
                {
                    btnPrintPowerPoint.ClientVisible = false;                        //Disable PowerPoint Print button
                }


                // Adjust buttons on the fly
                WFEngine pEngine = GetWFEngine();

                ActionInfo[] aActions = pEngine.GetActions(Assignment.StepName, Assignment.RoleId);
                foreach (ActionInfo pAction in aActions)
                {
                    ASPxButton pButton = lsButtons[i];
                    pButton.Text    = pAction.Action;
                    pButton.ToolTip = pAction.Tooltip;
                    if (pAction.RequireComments)
                    {
                        pButton.ClientSideEvents.Click = "onWFComments";
                    }
                    else
                    {
                        pButton.ClientSideEvents.Click = "onWFButtonClick";
                    }

                    pButton.Visible = true;
                    i++;
                }
            }

            if (!IsPostBack)
            {
                // Use assignment ID to find the row
                // This is now uniform - the checklists do it too
                CARComment pRow = PageContext.CARComments.FirstOrDefault(x => x.WFAssignId == Assignment.WFAssignId);
                if (pRow != null)
                {
                    //if (pRow.Comments != null) {
                    //  Comments.Text = pRow.Comments;
                    //}
                }
            }

            // This should make it so that approvers can add attachments, and collaborators cannot // 3-25-19 Todd changed this so that both Approver and Collaborator can add attachments. Joey requested this change.
            if (Assignment.RoleCategory == "Approver" || Assignment.RoleCategory == "Collaborator")
            {
                //carSummary.UploadEnabled = true;
            }

            //layoutComments.Items [0].Caption = Assignment.Role.RoleName;
        }