/// <summary>
        /// Запускает рабочий процесс, связанный с договором, с пометкой "автоматический".
        /// </summary>
        /// <param name="workflowTaskEvent"></param>
        private static void ProcessContractWorkflowEvent(WorkflowTaskQueue workflowTaskEvent)
        {
            var сontractWorkFlowRequest = new ContractWorkFlowRequest
            {
                ContractId = workflowTaskEvent.ContractId ?? default(int),
                IsAuto     = true
            };

            NiisWorkflowAmbientContext.Current.ContractWorkflowService.Process(сontractWorkFlowRequest);
        }
Esempio n. 2
0
        private void RequestWorkflows(ContractWorkFlowRequest contractWorkFlowRequest)
        {
            NetCoreBaseWorkflow <ContractWorkFlowRequest, Contract> contractWorkFlow = NiisWorkflowAmbientContext.Current.ContractWorkflow;

            if (contractWorkFlow == null)
            {
                throw new NotImplementedException();
            }

            contractWorkFlow.SetWorkflowRequest(contractWorkFlowRequest);

            contractWorkFlow.Process();
        }
Esempio n. 3
0
        public void Process(ContractWorkFlowRequest contractWorkFlowRequest)
        {
            if (contractWorkFlowRequest.ContractId != 0)
            {
                //contractWorkFlowRequest.CurrentWorkflowObject = _executor.GetQuery<GetContractByIdQuery>().Process(r => r.Execute(contractWorkFlowRequest.ContractId));
                contractWorkFlowRequest.CurrentWorkflowObject = _executor.GetQuery <GetContractByIdForWorkflowServiceQuery>().Process(r => r.Execute(contractWorkFlowRequest.ContractId));
                if (contractWorkFlowRequest.IsAuto)
                {
                    contractWorkFlowRequest.NextStageUserId = contractWorkFlowRequest.CurrentWorkflowObject.CurrentWorkflow.CurrentUserId ?? 0;
                }

                RequestWorkflows(contractWorkFlowRequest);
            }
        }
Esempio n. 4
0
        private async Task <WorkflowDto> ProcessContractWorkflow(WorkflowDto workflowDto)
        {
            var contractWorkFlowRequest = new ContractWorkFlowRequest
            {
                ContractId      = workflowDto.OwnerId ?? default(int),
                NextStageUserId = workflowDto.CurrentUserId ?? default(int),
                NextStageCode   = workflowDto.CurrentStageCode,
            };

            NiisWorkflowAmbientContext.Current.ContractWorkflowService.Process(contractWorkFlowRequest);
            var contract = await Executor.GetQuery <GetContractByIdQuery>().Process(q => q.ExecuteAsync(contractWorkFlowRequest.ContractId));

            SetFullExpertiseExecutor(contract);
            SetApplicationDateCreate(contract);
            await CreatePaymentInvoicesForContact(contract);

            var contractWorkflow = await Executor.GetQuery <GetContractWorkflowByIdQuery>().Process(r => r.ExecuteAsync(contract.CurrentWorkflowId ?? default(int)));

            var responseWorkflowDto = Mapper.Map <ContractWorkflow, WorkflowDto>(contractWorkflow);

            return(responseWorkflowDto);
        }
Esempio n. 5
0
        public async Task <IActionResult> Put(int id, [FromBody] ContractDetailDto contractDetailDto)
        {
            var contractId = contractDetailDto.Id = id;

            var contractRequestRelationsDtos      = new List <ContractRequestRelationDto>();
            var contractProtectionDocRelationDtos = new List <ContractProtectionDocRelationDto>();

            foreach (var ownerDto in contractDetailDto.Owners)
            {
                contractRequestRelationsDtos.Add(new ContractRequestRelationDto
                {
                    ContractId = contractId,
                    Request    = new RequestItemDto {
                        Id = ownerDto.OwnerId
                    }
                });
            }

            foreach (var ownerDto in contractDetailDto.ProtectionDocsOwners)
            {
                contractProtectionDocRelationDtos.Add(new ContractProtectionDocRelationDto
                {
                    ContractId    = contractId,
                    ProtectionDoc = new ProtectionDocItemDto {
                        Id = ownerDto.OwnerId
                    }
                });
            }

            var contract = Executor.GetQuery <GetContractByIdWithoutIncludingQuery>().Process(q => q.Execute(contractDetailDto.Id));

            Mapper.Map(contractDetailDto, contract);

            Executor.CommandChain()
            .AddCommand <UpdateContractCommand>(c => c.Execute(contract))
            .AddCommand <DeleteContractRequestRelationsCommand>(c => c.Execute(contractId, contractRequestRelationsDtos))
            .AddCommand <CreateContractRequestRelationsCommand>(c => c.Execute(contractId, contractRequestRelationsDtos))
            .AddCommand <UpdateContractRequestRelationsCommand>(c => c.Execute(contractId, contractRequestRelationsDtos))
            .AddCommand <DeleteContractProtectionDocRelationsCommand>(c => c.Execute(contractId, contractProtectionDocRelationDtos))
            .AddCommand <CreateContractProtectionDocRelationsCommand>(c => c.Execute(contractId, contractProtectionDocRelationDtos))
            .AddCommand <UpdateContractProtectionDocRelationsCommand>(c => c.Execute(contractId, contractProtectionDocRelationDtos))
            .ExecuteAllWithTransaction();

            var updatedContract = await Executor.GetQuery <GetContractByIdQuery>().Process(q => q.ExecuteAsync(contractId));

            var addressee = updatedContract.Addressee;

            if (addressee != null)
            {
                addressee.Apartment = contractDetailDto.Apartment;
                addressee.Address   = contractDetailDto.AddresseeAddress;
                await Executor.GetCommand <UpdateDicCustomerCommand>().Process(c => c.ExecuteAsync(addressee));
            }

            var updatedContractDetailDto = Mapper.Map <Contract, ContractDetailDto>(updatedContract);

            var contractWorkFlowRequest = new ContractWorkFlowRequest
            {
                ContractId      = updatedContract.Id,
                NextStageUserId = updatedContract.CurrentWorkflow.CurrentUserId ?? default(int),
                NextStageCode   = updatedContract.CurrentWorkflow.CurrentStage.Code,
            };

            NiisWorkflowAmbientContext.Current.ContractWorkflowService.Process(contractWorkFlowRequest);

            return(Ok(updatedContractDetailDto));
        }