コード例 #1
0
        /// <summary>
        /// Creates a Workflow Response
        /// </summary>
        /// <param name="ado"></param>
        /// <param name="dto"></param>
        /// <param name="ccnUsername"></param>
        /// <returns></returns>
        internal int Create(ADO ado, WorkflowResponse_DTO dto, string ccnUsername)
        {
            var inputParams = new List <ADO_inputParams>()
            {
                new ADO_inputParams()
                {
                    name = "@CcnUsername", value = ccnUsername
                },
                new ADO_inputParams()
                {
                    name = "@RspCode", value = dto.RspCode
                },
                new ADO_inputParams()
                {
                    name = "@CmmCode", value = dto.CmmCode
                },
                new ADO_inputParams()
                {
                    name = "@RlsCode", value = dto.RlsCode
                }
            };
            var retParam = new ADO_returnParam()
            {
                name = "return", value = 0
            };

            //Attempting to create the new entity
            ado.ExecuteNonQueryProcedure("Workflow_WorkflowResponse_Create", inputParams, ref retParam);

            //Assign the returned value for checking and output
            return(retParam.value);
        }
コード例 #2
0
        /// <summary>
        /// Execute
        /// </summary>
        /// <returns></returns>
        protected override bool Execute()
        {
            Workflow_BSO bso              = new Workflow_BSO();
            Account_BSO  aBso             = new Account_BSO();
            bool         responseComplete = false;

            //Create the workflow request
            Response = bso.WorkflowRequestCreate(DTO, Ado, SamAccountName);
            if (Response.error != null)
            {
                return(false);
            }

            //If this is a user with an automatic flow to the next stage, then do the response immediately
            if (bso.HasFastrackPermission(Ado, SamAccountName, DTO.RlsCode, "workflow.fastrack.response"))
            {
                Log.Instance.Debug("Fastrack from Request to Response");
                WorkflowResponse_DTO rspDto = new WorkflowResponse_DTO()
                {
                    RlsCode = DTO.RlsCode, RspCode = Constants.C_WORKFLOW_STATUS_APPROVE, CmmValue = Label.Get("auto-approve-comment")
                };
                Response = bso.WorkflowResponseCreate(rspDto, Ado, SamAccountName);
                if (Response.error != null)
                {
                    return(false);
                }
                responseComplete = true;
            }


            //If this is a user with an automatic flow to the next stage (and the response has been completed), then do the signoff immediately
            if (bso.HasFastrackPermission(Ado, SamAccountName, DTO.RlsCode, "workflow.fastrack.signoff") && responseComplete)
            {
                if (!(IsPowerUser() || IsAdministrator()))
                {
                    Response.error = Label.Get("error.authentication");
                    return(false);
                }
                Log.Instance.Debug("Fastrack from Request to Signoff via Response");
                WorkflowSignoff_DTO sgnDTO = new WorkflowSignoff_DTO()
                {
                    RlsCode = DTO.RlsCode, SgnCode = Constants.C_WORKFLOW_STATUS_APPROVE, CmmValue = Label.Get("auto-approve-signoff")
                };
                Response = bso.WorkflowSignoffCreate(Ado, sgnDTO, SamAccountName);
                if (Response.error != null)
                {
                    return(false);
                }
            }
            return(true);
        }
コード例 #3
0
ファイル: Workflow_BSO.cs プロジェクト: CSOIreland/PxStat
        internal JSONRPC_Output WorkflowResponseCreate(WorkflowResponse_DTO DTO, ADO Ado, string SamAccountName)
        {
            JSONRPC_Output response = new JSONRPC_Output();
            //We need to get the Request for notification purposes
            WorkflowRequest_ADO        adoWrq     = new WorkflowRequest_ADO();
            List <WorkflowRequest_DTO> dtoWrqList = adoWrq.Read(Ado, DTO.RlsCode, true);

            if (dtoWrqList.Count > 1)
            {
                //Multiple requests found for this release
                Log.Instance.Debug("More than one request found for this release ");
                response.error = Label.Get("error.create");
                return(response);
            }

            if (dtoWrqList.Count == 0)
            {
                //No request found for this release
                Log.Instance.Debug("No request found for this release ");
                response.error = Label.Get("error.create");
                return(response);
            }


            //Validation of parameters and user have been successful. We may now proceed to read from the database
            var adoWorkflowRequest = new WorkflowRequest_ADO();

            if (!adoWorkflowRequest.IsCurrent(Ado, DTO.RlsCode))
            {
                //No workflow found
                Log.Instance.Debug("No Live workflow found for this Release Code");
                response.error = Label.Get("error.create");
                return(response);
            }

            var adoWorkflowResponse = new WorkflowResponse_ADO();

            //If this is a Moderator, we need to check if the user is in the same group as the release and has approve rights

            Account_BSO acBso = new Account_BSO();

            if (acBso.IsModerator(Ado, SamAccountName))
            {
                var approveRlsList = adoWorkflowResponse.GetApproverAccess(Ado, SamAccountName, true, DTO.RlsCode);
                if (approveRlsList.data.Count == 0)
                {
                    Log.Instance.Debug("Insufficient access for a Moderator");
                    response.error = Label.Get("error.authentication");
                    return(response);
                }
            }

            //Check that there isn't already a WorkflowResponse for this Release

            if (adoWorkflowResponse.IsInUse(Ado, DTO))
            {
                //Duplicate Workflow exists
                Log.Instance.Debug("Workflow Response exists already, can't create");
                response.error = Label.Get("error.duplicate");
                return(response);
            }


            var adoComment = new Comment_ADO();

            int commentCode = adoComment.Create(Ado, DTO, SamAccountName);

            if (commentCode == 0)
            {
                //Can't create a comment so we can't proceed
                Log.Instance.Debug("Can't create comment - create WorkflowResponse refused");
                response.error = Label.Get("error.create");
                return(response);
            }

            DTO.CmmCode = commentCode;



            int createResponse = adoWorkflowResponse.Create(Ado, DTO, SamAccountName);

            if (createResponse == 0)
            {
                response.error = Label.Get("error.create");
                return(response);
            }

            //If this is a Reject then we must reset the workflow to stop it being current
            if (DTO.RspCode.Equals(Resources.Constants.C_WORKFLOW_STATUS_REJECT))
            {
                WorkflowRequest_DTO_Update dtoRequest = new WorkflowRequest_DTO_Update(DTO.RlsCode)
                {
                    WrqCurrentFlag = false
                };

                adoWorkflowRequest.Update(Ado, dtoRequest, SamAccountName);
            }

            response.data = JSONRPC.success;

            //Get Release
            Release_ADO releaseAdo = new Release_ADO(Ado);
            Release_DTO releaseDTO = Release_ADO.GetReleaseDTO(releaseAdo.Read(DTO.RlsCode, SamAccountName));

            Security.ActiveDirectory_DTO responseUser = new Security.ActiveDirectory_DTO()
            {
                CcnUsername = SamAccountName
            };
            Security.ActiveDirectory_ADO accAdo = new Security.ActiveDirectory_ADO();
            Security.Account_DTO_Read    accDto = new Security.Account_DTO_Read()
            {
                CcnUsername = responseUser.CcnUsername
            };

            DTO.ResponseAccount = accAdo.GetUser(Ado, accDto);

            Email_BSO_NotifyWorkflow notify = new Email_BSO_NotifyWorkflow();

            try
            {
                notify.EmailResponse(dtoWrqList[0], DTO, releaseDTO);
            }
            catch
            { }
            return(response);
        }