Exemplo n.º 1
0
        public async Task <IActionResult> GetContractsByOwner(Owner.Type ownerType, int ownerId)
        {
            List <Contract> contracts = null;

            switch (ownerType)
            {
            case Owner.Type.Request:
                contracts = await Executor.GetQuery <GetContractsByRequestIdQuery>()
                            .Process(q => q.ExecuteAsync(ownerId));

                break;

            case Owner.Type.ProtectionDoc:
                contracts = await Executor.GetQuery <GetContractsByProtectionDocIdQuery>()
                            .Process(q => q.ExecuteAsync(ownerId));

                break;

            default:
                throw new NotImplementedException();
            }
            var contractDtos = Mapper.Map <List <ContractItemDto> >(contracts);

            return(Ok(contractDtos));
        }
Exemplo n.º 2
0
        public async Task <IActionResult> Delete(Owner.Type ownerType, int id)
        {
            switch (ownerType)
            {
            case Owner.Type.Request:
                await Executor.GetCommand <DeleteRequestCustomerCommand>().Process(c => c.ExecuteAsync(id));

                break;

            case Owner.Type.Contract:
                var contractCustomer = await Executor.GetQuery <GetContractCustomerByIdQuery>()
                                       .Process(q => q.ExecuteAsync(id));

                await Executor.GetCommand <DeleteContractCustomerCommand>().Process(c => c.ExecuteAsync(id));

                await _categoryIdentifier.IdentifyAsync(contractCustomer.ContractId);

                break;

            default:
                throw new ArgumentOutOfRangeException();
            }

            return(NoContent());
        }
Exemplo n.º 3
0
 public Command(int documentId, int userId, MaterialOutgoingDetailDto materialDetailDto, Owner.Type ownerType)
 {
     DocumentId        = documentId;
     UserId            = userId;
     MaterialDetailDto = materialDetailDto;
     OwnerType         = ownerType;
 }
Exemplo n.º 4
0
        public async Task <IActionResult> UpdateSimilarSearchResults(int ownerId, Owner.Type ownerType, string keywords,
                                                                     [FromBody] ExpertSearchSimilarDto[] similarities)
        {
            var query = await _mediator.Send(new Update.Command(similarities, ownerType, ownerId, keywords));

            return(Ok(query));
        }
        /// <summary>
        /// Выполенение запроса.
        /// </summary>
        /// <param name="ownerId">Идентификатор родительской сущности.</param>
        /// <param name="ownerType">Тип родительской сущности.</param>
        /// <param name="nextStageCode">Код следующего этапа рабочего процесса.</param>
        /// <returns></returns>
        public DateTimeOffset Execute(int ownerId, Owner.Type ownerType, string nextStageCode)
        {
            if (Properties.Settings.Default.IsAutoWorkflowInTestMode == true)
            {
                return(DateTimeOffset.Now + Properties.Settings.Default.AutoWorkflowTestDelayTime);
            }
            DateTimeOffset resolveDate;

            switch (ownerType)
            {
            case Owner.Type.Request:
                var request = Executor.GetQuery <GetRequestByIdQuery>().Process(r => r.Execute(ownerId));
                resolveDate = GetResolveDate(request, nextStageCode);
                break;

            case Owner.Type.ProtectionDoc:
                var protectionDoc = Executor.GetQuery <GetProtectionDocByIdQuery>().Process(q => q.Execute(ownerId));
                resolveDate = GetExecutionDate(protectionDoc, DateTimeOffset.Now, nextStageCode);
                break;

            case Owner.Type.Contract:
            default:
                throw new NotImplementedException();
            }

            return(resolveDate);
        }
Exemplo n.º 6
0
        public async Task <IActionResult> GetByParent(int ownerId, Owner.Type ownerType)
        {
            List <SubjectDto> subjects;

            switch (ownerType)
            {
            case Owner.Type.Request:
                var requestCustomers = await Executor.GetQuery <GetRequestCustomersByRequestIdQuery>()
                                       .Process(q => q.ExecuteAsync(ownerId));

                subjects = Mapper.Map <List <SubjectDto> >(requestCustomers);
                break;

            case Owner.Type.Contract:
                var contractCustomers = Executor.GetQuery <GetContractCustomersByContractIdQuery>()
                                        .Process(q => q.Execute(ownerId));
                subjects = Mapper.Map <List <SubjectDto> >(contractCustomers);
                break;

            case Owner.Type.ProtectionDoc:
                var protectionDocCustomers = await Executor
                                             .GetQuery <GetProtectionDocCustomersByProtectionDocIdQuery>()
                                             .Process(q => q.ExecuteAsync(ownerId));

                subjects = Mapper.Map <List <SubjectDto> >(protectionDocCustomers);
                break;

            default:
                throw new ApplicationException(string.Empty,
                                               new ArgumentException($"{nameof(ownerType)}: {ownerType}"));
            }
            subjects = subjects.OrderBy(s => s.DisplayOrder).ToList();

            return(Ok(subjects));
        }
Exemplo n.º 7
0
        public async Task ExecuteAsync(Owner.Type ownerType, int paymentInvoiceId, DateTimeOffset date)
        {
            var paymentInvoice = await(Executor.GetQuery <GetPaymentInvoiceByIdQuery>()
                                       .Process(q => q.ExecuteAsync(paymentInvoiceId)));

            var chargedStatus = Executor.GetQuery <GetDicPaymentStatusByCodeQuery>()
                                .Process(q => q.Execute(DicPaymentStatusCodes.Charged));

            var user = NiisAmbientContext.Current.User.Identity.UserId;

            paymentInvoice.Status         = chargedStatus;
            paymentInvoice.StatusId       = chargedStatus?.Id ?? 0;
            paymentInvoice.DateComplete   = date;
            paymentInvoice.WriteOffUserId = user;

            var isExportedTo1C = await Executor.GetHandler <ExportPaymentTo1CHandler>().Process(r => r.ExecuteAsync(ownerType,
                                                                                                                    paymentInvoice.Id, PaymentInvoiveChangeFlag.NewChargedPaymentInvoice, chargedStatus.Code, date));

            if (isExportedTo1C)
            {
                //Устанавливаем дату экспорта в 1С если экспорт произошол успешно.
                paymentInvoice.DateExportedTo1C = DateTimeOffset.UtcNow;
            }
            Executor.GetCommand <UpdatePaymentInvoiceCommand>().Process(c => c.Execute(paymentInvoice));
        }
Exemplo n.º 8
0
 public Command(ExpertSearchSimilarDto[] similarResults, Owner.Type ownerType, int ownerId, string keywords)
 {
     SimilarResults = similarResults;
     OwnerType      = ownerType;
     OwnerId        = ownerId;
     Keywords       = keywords;
 }
Exemplo n.º 9
0
        public async Task <IActionResult> ChangeWorkflow(Owner.Type ownerType, [FromBody] int ownerId)
        {
            switch (ownerType)
            {
            case Owner.Type.Request:
                var workflows = await Executor.GetQuery <GetRequestWorkflowsByOwnerIdQuery>()
                                .Process(q => q.ExecuteAsync(ownerId));

                var lastStageBeforeScenario = workflows.OrderBy(w => w.DateCreate)
                                              .LastOrDefault(w => w.IsChangeScenarioEntry == true);
                var requestWorkFlowRequest = new RequestWorkFlowRequest
                {
                    RequestId       = ownerId,
                    NextStageUserId = lastStageBeforeScenario?.CurrentUserId ?? NiisAmbientContext.Current.User.Identity.UserId
                };

                NiisWorkflowAmbientContext.Current.RequestWorkflowService.Process(requestWorkFlowRequest);
                NiisWorkflowAmbientContext.Current.RequestWorkflowService.Process(requestWorkFlowRequest);
                break;

            default:
                throw new NotImplementedException();
            }
            return(NoContent());
        }
Exemplo n.º 10
0
        public async Task <IActionResult> ChangeIpcCollection(int ownerId, Owner.Type ownerType,
                                                              [FromBody] List <int> ipcList)
        {
            switch (ownerType)
            {
            case Owner.Type.Request:
                //TODO! реализовать для заявок
                break;

            case Owner.Type.ProtectionDoc:
                var protectionDoc = await Executor.GetQuery <GetProtectionDocByIdQuery>()
                                    .Process(q => q.ExecuteAsync(ownerId));

                var addIds = Executor.GetHandler <FilterAddIntegerListIdsHandler>().Process(h =>
                                                                                            h.Execute(ipcList, protectionDoc.ColorTzs.Select(c => c.ColorTzId).ToList()));
                var removeIds = Executor.GetHandler <FilterRemoveIntegerListIdsHandler>().Process(h =>
                                                                                                  h.Execute(ipcList, protectionDoc.ColorTzs.Select(c => c.ColorTzId).ToList()));

                await Executor.GetCommand <AddIpcProtectionDocRelationsCommand>()
                .Process(c => c.ExecuteAsync(ownerId, addIds));

                await Executor.GetCommand <RemoveIpcProtectionDocRelationsCommand>()
                .Process(c => c.ExecuteAsync(ownerId, removeIds));

                break;

            default:
                throw new NotImplementedException();
            }
            return(NoContent());
        }
Exemplo n.º 11
0
        public async Task <IActionResult> GetIcgs(int ownerId, Owner.Type ownerType)
        {
            List <ICGSRequestItemDto> icgsItemDtos;

            switch (ownerType)
            {
            case Owner.Type.Request:
                var icgsRequests = await Executor.GetQuery <GetIcgsByRequestIdQuery>().Process(q => q.ExecuteAsync(ownerId));

                icgsItemDtos =
                    Mapper.Map <List <ICGSRequest>, List <ICGSRequestItemDto> >(
                        icgsRequests);
                return(Ok(icgsItemDtos));

            case Owner.Type.ProtectionDoc:
                var icgsProtectionDocs = await Executor.GetQuery <GetIcgsByProtectionDocIdQuery>().Process(q => q.ExecuteAsync(ownerId));

                icgsItemDtos =
                    Mapper.Map <List <ICGSProtectionDoc>, List <ICGSRequestItemDto> >(
                        icgsProtectionDocs);
                return(Ok(icgsItemDtos));

            default:
                throw new NotImplementedException();
            }
        }
Exemplo n.º 12
0
        public async Task <IActionResult> AddEarlyRegs(int ownerId, Owner.Type ownerType,
                                                       [FromBody] List <RequestEarlyRegDto> earlyRegDtos)
        {
            switch (ownerType)
            {
            case Owner.Type.Request:
                var requestEarlyRegs = Mapper.Map <List <RequestEarlyRegDto>, List <RequestEarlyReg> >(earlyRegDtos);
                await Executor.GetCommand <AddRequestEarlyRegsRangeCommand>()
                .Process(c => c.ExecuteAsync(ownerId, requestEarlyRegs));

                break;

            case Owner.Type.ProtectionDoc:
                var protectionDocEarlyRegs = Mapper.Map <List <RequestEarlyRegDto>, List <ProtectionDocEarlyReg> >(earlyRegDtos);
                await Executor.GetCommand <AddProtectionDocEarlyRegsRangeCommand>()
                .Process(c => c.ExecuteAsync(ownerId, protectionDocEarlyRegs));

                break;

            default:
                throw new NotImplementedException();
            }


            return(NoContent());
        }
Exemplo n.º 13
0
        public async Task <IActionResult> AddIcgs(int ownerId, Owner.Type ownerType,
                                                  [FromBody] List <ICGSRequestItemDto> icgsItemDtos)
        {
            switch (ownerType)
            {
            case Owner.Type.Request:
                var icgsRequests = Mapper.Map <List <ICGSRequestItemDto>, List <ICGSRequest> >(icgsItemDtos);
                await Executor.GetCommand <AddIcgsRequestRangeCommand>()
                .Process(c => c.ExecuteAsync(ownerId, icgsRequests));

                break;

            case Owner.Type.ProtectionDoc:
                var icgsProtectionDocs = Mapper.Map <List <ICGSRequestItemDto>, List <ICGSProtectionDoc> >(icgsItemDtos);
                await Executor.GetCommand <AddIcgsProtectionDocRangeCommand>()
                .Process(c => c.ExecuteAsync(ownerId, icgsProtectionDocs));

                break;

            default:
                throw new NotImplementedException();
            }


            return(NoContent());
        }
Exemplo n.º 14
0
        public async Task <IActionResult> GetEarlyRegs(int ownerId, Owner.Type ownerType)
        {
            List <RequestEarlyRegDto> earlyRegDtos;

            switch (ownerType)
            {
            case Owner.Type.Request:
                var requestEarlyRegs = await Executor.GetQuery <GetEarlyRegsByRequestIdQuery>().Process(q => q.ExecuteAsync(ownerId));

                earlyRegDtos =
                    Mapper.Map <List <RequestEarlyReg>, List <RequestEarlyRegDto> >(
                        requestEarlyRegs);
                return(Ok(earlyRegDtos));

            case Owner.Type.ProtectionDoc:
                var protectionDocEarlyRegs = await Executor.GetQuery <GetEarlyRegsByProtectionDocIdQuery>().Process(q => q.ExecuteAsync(ownerId));

                earlyRegDtos =
                    Mapper.Map <List <ProtectionDocEarlyReg>, List <RequestEarlyRegDto> >(
                        protectionDocEarlyRegs);
                return(Ok(earlyRegDtos));

            default:
                throw new NotImplementedException();
            }
        }
Exemplo n.º 15
0
 public Query(Owner.Type owherType, int ownerId, int documentId, int userId)
 {
     OwherType  = owherType;
     OwnerId    = ownerId;
     DocumentId = documentId;
     UserId     = userId;
 }
Exemplo n.º 16
0
        public async Task <IActionResult> Post(Owner.Type ownerType, bool force, [FromBody] PaymentUseDto useDto)
        {
            var paymentUse = _mapper.Map <PaymentUseDto, PaymentUse>(useDto);

            _executor.GetCommand <CreatePaymentUseHandler>().Process(c => c.Execute(ownerType, paymentUse, force));
            PaymentInvoice paymentInvoice = null;

            if (paymentUse.PaymentInvoiceId.HasValue)
            {
                paymentInvoice = await _executor.GetQuery <GetPaymentInvoiceByIdQuery>()
                                 .Process(q => q.ExecuteAsync(paymentUse.PaymentInvoiceId.Value));
            }

            switch (ownerType)
            {
            case Owner.Type.Request:
                var requestId = paymentInvoice?.RequestId;
                NiisWorkflowAmbientContext.Current.RequestWorkflowService.Process(new RequestWorkFlowRequest
                {
                    RequestId        = requestId ?? 0,
                    PaymentInvoiceId = paymentInvoice?.Id,
                    IsAuto           = true
                });

                await Executor.GetHandler <UnsetRequestFormalExamNotPaidHandler>().Process(h => h.ExecuteAsync(requestId ?? 0, paymentInvoice));

                //await Executor.GetHandler<GenerateAutoNotificationHandler>().Process(h => h.Execute(requestId ?? 0));
                break;

            case Owner.Type.ProtectionDoc:
                if (DicTariff.Codes.GetProtectionDocSupportCodes().Contains(paymentInvoice?.Tariff?.Code) ||
                    paymentInvoice?.Tariff?.Code == DicTariff.Codes.ProtectionDocRestore)
                {
                    var protectionDoc = await Executor.GetQuery <GetProtectionDocByIdQuery>().Process(q => q.ExecuteAsync(paymentInvoice?.ProtectionDocId ?? 0));

                    if (protectionDoc != null)
                    {
                        protectionDoc.MaintainDate = protectionDoc.MaintainDate?.AddYears(paymentInvoice?.TariffCount ?? 1)
                                                     ?? DateTimeOffset.Now.AddYears(paymentInvoice?.TariffCount ?? 1);
                        await Executor.GetCommand <UpdateProtectionDocCommand>().Process(c => c.ExecuteAsync(protectionDoc.Id, protectionDoc));
                    }
                }
                NiisWorkflowAmbientContext.Current.ProtectionDocumentWorkflowService.Process(new ProtectionDocumentWorkFlowRequest
                {
                    ProtectionDocId = paymentInvoice?.ProtectionDocId ?? 0,
                    IsAuto          = true
                });
                break;

            case Owner.Type.Contract:
                NiisWorkflowAmbientContext.Current.ContractWorkflowService.Process(new ContractWorkFlowRequest
                {
                    ContractId = paymentInvoice?.ContractId ?? 0,
                    IsAuto     = true
                });
                break;
            }

            return(Ok(_mapper.Map <PaymentUse, PaymentUseDto>(paymentUse)));
        }
Exemplo n.º 17
0
        public IActionResult GetAddresseeByOwnerId(Owner.Type ownerType, int id)
        {
            switch (ownerType)
            {
            case Owner.Type.Request:
            {
                var addresseeInfo = _executor.GetQuery <GetAddresseeByRequestIdQuery>().Process(q => q.Execute(id));
                var addressee     = addresseeInfo.addressee;
                var subject       = _mapper.Map <CustomerShortInfoDto>(addressee);
                subject.OwnerAddresseeAddress = addresseeInfo.requestAddresseeAddress;
                return(Ok(subject));
            }

            case Owner.Type.Contract:
            {
                var addresseeInfo = _executor.GetQuery <GetAddresseeByContractIdQuery>().Process(q => q.Execute(id));
                var addressee     = addresseeInfo.addressee;
                var subject       = _mapper.Map <CustomerShortInfoDto>(addressee);
                subject.OwnerAddresseeAddress = addresseeInfo.contractAddresseeAddress;
                return(Ok(subject));
            }

            default:
                throw new ArgumentOutOfRangeException();
            }
        }
Exemplo n.º 18
0
 public async Task <IActionResult> DeleteSeveral(Owner.Type ownerType, [FromBody] int[] ids)
 {
     foreach (var id in ids)
     {
         await Delete(ownerType, id);
     }
     return(NoContent());
 }
Exemplo n.º 19
0
 public async Task <IActionResult> PostSeveral(Owner.Type ownerType, [FromBody] SubjectDto[] subjectDtos)
 {
     foreach (var subjectDto in subjectDtos)
     {
         await AttachCustomerPrivate(subjectDto, ownerType);
     }
     return(NoContent());
 }
Exemplo n.º 20
0
        public async Task <IActionResult> Resend(Owner.Type ownerType, int ownerId, int documentId)
        {
            await _mediator.Send(new Notifications.Email.Query(ownerType, ownerId, documentId, User.Identity.GetUserId()));

            var result = await _mediator.Send(new Notifications.List.Query(ownerType, ownerId, documentId));

            return(Ok(result));
        }
Exemplo n.º 21
0
 public async Task <IActionResult> PutSeveral(Owner.Type ownerType, [FromBody] SubjectDto[] subjectDtos)
 {
     foreach (var subjectDto in subjectDtos)
     {
         await Put(subjectDto.Id, ownerType, subjectDto);
     }
     return(NoContent());
 }
Exemplo n.º 22
0
        public async Task <IActionResult> GetInvoicesExcel(int ownerId, Owner.Type ownerType)
        {
            var paymentInvoices = await GetPaymentInvoicesRequest(ownerId, ownerType);

            var fileStream = Executor.GetCommand <GetExcelFileCommand>().Process(q => q.Execute(paymentInvoices, Request));

            return(File(fileStream, GetExcelFileCommand.ContentType, GetExcelFileCommand.DefaultFileName));
        }
Exemplo n.º 23
0
        /// <summary>
        /// Создает документ и прикрепляет его к родительской сущности, указывая исполнителя по идентификатору.
        /// <para></para>
        /// Если в параметр <paramref name="executorId"/> передан <see langword="null"/>, то указывает исполнителем текущего пользователя.
        /// </summary>
        /// <param name="ownerId">Идентификатор родительской сущности.</param>
        /// <param name="ownerType">Тип родительской сущности.</param>
        /// <param name="patentCode">Код типа документа.</param>
        /// <param name="documentType">Тип документа.</param>
        /// <param name="userInput">Пользовательский ввод.</param>
        /// <param name="executorId">Идентификатор исполнителя.</param>
        /// <returns>Идентификатор созданного документа.</returns>
        private async Task <int> CreateDocument(int ownerId, Owner.Type ownerType, string patentCode, DocumentType documentType, UserInputDto userInput, int?executorId)
        {
            if (executorId.HasValue)
            {
                return(await CreateDocumentWithExecutor(ownerId, ownerType, patentCode, documentType, userInput, executorId.Value));
            }

            return(await CreateDocumentWithCurrentUserAsExecutor(ownerId, ownerType, patentCode, documentType, userInput));
        }
        /// <summary>
        /// Выполнение обработчика.
        /// </summary>
        /// <param name="ownerId">Идентификатор родительской сущности.</param>
        /// <param name="ownerType">Тип родительской сущности.</param>
        /// <param name="documentTypeCode">Код типа документа.</param>
        /// <param name="type">Тип документа.</param>
        /// <param name="userInput">Пользовательский ввод.</param>
        /// <param name="executorId">Идентификатор исполнителя.</param>
        /// <returns>Идентификатор созданного документа.</returns>
        public async Task <int> ExecuteAsync(
            int ownerId,
            Owner.Type ownerType,
            string documentTypeCode,
            DocumentType type,
            UserInputDto userInput,
            int executorId)
        {
            DicDocumentType documentType = GetDocumentTypeWithValidation(documentTypeCode);

            int?addresseeId = await GetAddresseeId(ownerId, ownerType);

            Document document = new Document
            {
                TypeId       = documentType.Id,
                AddresseeId  = addresseeId,
                DocumentType = type,
                DateCreate   = DateTimeOffset.Now
            };

            int documentId = await Executor
                             .GetCommand <CreateDocumentCommand>()
                             .Process(command => command.ExecuteAsync(document));

            await AddDocumentToOwner(ownerId, ownerType, documentId);

            DocumentWorkflow documentWorkflow = await Executor
                                                .GetQuery <GetInitialDocumentWorkflowQuery>()
                                                .Process(query => query.ExecuteAsync(documentId, executorId));

            await Executor
            .GetCommand <ApplyDocumentWorkflowCommand>()
            .Process(command => command.ExecuteAsync(documentWorkflow));

            await Executor
            .GetCommand <UpdateDocumentCommand>()
            .Process(command => command.Execute(document));

            await Executor
            .GetHandler <GenerateDocumentBarcodeHandler>()
            .Process(handler => handler.ExecuteAsync(documentId));

            await Executor
            .GetHandler <GenerateRegisterDocumentNumberHandler>()
            .Process(handler => handler.ExecuteAsync(documentId));

            await Executor
            .GetCommand <CreateUserInputCommand>()
            .Process(command => command.ExecuteAsync(documentId, userInput));

            await Executor
            .GetHandler <ProcessWorkflowByDocumentIdHandler>()
            .Process(handler => handler.ExecuteAsync(documentId));

            return(document.Id);
        }
Exemplo n.º 25
0
        public void Execute(Owner.Type ownerType, PaymentUse paymentUse, bool force)
        {
            Executor.CommandChain()
            .AddCommand <CreditPaymentInvoiceCommand>(c => c.Execute(ownerType, paymentUse, force))
            .AddCommand <CreatePaymentUseCommand>(c => c.Execute(paymentUse))
            .ExecuteAllWithTransaction();

            Executor.GetCommand <UpdatePaymentStatusCommand>()
            .Process(c => c.Execute(paymentUse.PaymentId.Value));
        }
Exemplo n.º 26
0
        public async Task Execute(Owner.Type ownerType, int ownerId, string documentTypeCode)
        {
            try
            {
                List <PaymentInvoice> paymentInvoices;
                switch (ownerType)
                {
                case Owner.Type.Request:
                    paymentInvoices = await Executor.GetQuery <GetPaymentInvoicesByRequestIdQuery>()
                                      .Process(q => q.ExecuteAsync(ownerId));

                    break;

                default:
                    throw new NotImplementedException();
                }
                var chargedStatus = Executor.GetQuery <GetDicPaymentStatusByCodeQuery>()
                                    .Process(q => q.Execute(DicPaymentStatusCodes.Charged));
                var tariffCodes = DocumentTypesTariffConfig
                                  .Where(c => c.DocumentTypeCodes.Contains(documentTypeCode)).SelectMany(c => c.TariffCodes);
                var invoicesToCharge = paymentInvoices.Where(pi =>
                                                             pi.Status.Code == DicPaymentStatusCodes.Credited && tariffCodes.Contains(pi.Tariff.Code));
                var systemUser = Executor.GetQuery <GetUserByXinQuery>()
                                 .Process(q => q.Execute(UserConstants.SystemUserXin));

                //TODO?
                foreach (var paymentInvoice in invoicesToCharge)
                {
                    var date = DateTimeOffset.UtcNow;
                    paymentInvoice.Status         = chargedStatus;
                    paymentInvoice.StatusId       = chargedStatus?.Id ?? 0;
                    paymentInvoice.DateComplete   = date;
                    paymentInvoice.WriteOffUserId = systemUser?.Id;

                    var isExportedTo1C = await Executor.GetHandler <ExportPaymentTo1CHandler>().Process(r => r.ExecuteAsync(ownerType,
                                                                                                                            paymentInvoice.Id,
                                                                                                                            PaymentInvoiveChangeFlag.NewChargedPaymentInvoice, chargedStatus.Code, date));

                    if (isExportedTo1C)
                    {
                        //Устанавливаем дату экспорта в 1С если экспорт произошол успешно.
                        paymentInvoice.DateExportedTo1C = DateTimeOffset.UtcNow;
                    }
                    Executor.GetCommand <UpdatePaymentInvoiceCommand>().Process(c => c.Execute(paymentInvoice));
                }
            }
            catch (Exception ex)
            {
                var log = new LogRecord();
                log.LogType      = LogType.General;
                log.LogErrorType = LogErrorType.Error;
                log.Message      = "Charge Paymenrt Invoice Error " + ex.StackTrace;
                var logId = await Executor.GetCommand <CreateLogRecordCommand>().Process(q => q.ExecuteAsync(log));
            }
        }
Exemplo n.º 27
0
        public async Task <IActionResult> Get(Owner.Type ownerType, int ownerId)
        {
            Attachment attachment = null;

            switch (ownerType)
            {
            case Owner.Type.Request:
                var request = await _executor.GetQuery <GetRequestByIdQuery>().Process(q => q.ExecuteAsync(ownerId));

                attachment = request?.MainAttachment;
                break;

            case Owner.Type.Contract:
                var contract = await _executor.GetQuery <GetContractByIdQuery>().Process(q => q.ExecuteAsync(ownerId));

                attachment = contract?.MainAttachment;
                break;

            case Owner.Type.ProtectionDoc:
                var protectionDoc = await _executor.GetQuery <GetProtectionDocByIdQuery>().Process(q => q.ExecuteAsync(ownerId));

                attachment = protectionDoc?.MainAttachment;
                break;

            default:
                throw new ArgumentOutOfRangeException(nameof(ownerType), ownerType, null);
            }

            if (attachment == null)
            {
                var documentName = ownerType == Owner.Type.Request ? nameof(Request) : nameof(Document);
                throw new DataNotFoundException(documentName, DataNotFoundException.OperationType.Read,
                                                ownerId);
            }

            var fileContent = await _fileStorage.GetAsync(attachment.BucketName, attachment.OriginalName);

            var extention = Path.GetExtension(attachment.OriginalName);

            if (extention != null && extention.ToLower().Contains("odt"))
            {
                using (var memoryStream = new MemoryStream())
                {
                    memoryStream.Write(fileContent, 0, fileContent.Length);
                    memoryStream.Seek(0, SeekOrigin.Begin);
                    var contentType = attachment.ContentType;

                    var newName = attachment.ValidName.Replace(".odt", ".pdf");
                    var pdf     = _fileConverter.DocxToPdf(memoryStream, newName);
                    return(File(pdf.File, contentType, newName));
                }
            }

            return(File(fileContent, attachment.ContentType, attachment.ValidName));
        }
Exemplo n.º 28
0
        public async Task <IActionResult> Resend(Owner.Type ownerType, int ownerId, int documentId)
        {
            var document = await _executor.GetQuery <GetDocumentByIdQuery>().Process(q => q.ExecuteAsync(documentId));

            if (document != null)
            {
                new NotificationTaskQueueRegister(_templateGeneratorFactory).AddNotificationsByOwnerType(documentId, Owner.Type.Material);
            }

            var result = await _executor.GetQuery <GetNotificationsQuery>().Process(q => q.ExecuteAsync(ownerType, documentId));

            return(Ok(result));
        }
Exemplo n.º 29
0
        public async Task <IActionResult> ChangeIcfemCollection(int ownerId, Owner.Type ownerType,
                                                                [FromBody] List <int> icfemList)
        {
            List <int> addIds;
            List <int> removeIds;

            switch (ownerType)
            {
            case Owner.Type.Request:
                var request = await Executor.GetQuery <GetRequestByIdQuery>().Process(q => q.ExecuteAsync(ownerId));

                addIds = Executor.GetHandler <FilterAddIntegerListIdsHandler>().Process(h =>
                                                                                        h.Execute(icfemList, request.Icfems.Select(c => c.DicIcfemId).ToList()));
                removeIds = Executor.GetHandler <FilterRemoveIntegerListIdsHandler>().Process(h =>
                                                                                              h.Execute(icfemList, request.Icfems.Select(c => c.DicIcfemId).ToList()));

                await Executor.GetCommand <AddIcfemRequestRelationsCommand>()
                .Process(c => c.ExecuteAsync(ownerId, addIds));

                var removeIcfemRequest = await Executor.GetQuery <GetIcfemRequestsByRequestIdAndIcfemIdsQuery>()
                                         .Process(q => q.ExeciuteAsync(request.Id, removeIds));

                await Executor.GetCommand <DeleteRangeIcfemRequestCommand>()
                .Process(c => c.ExecuteAsync(removeIcfemRequest));

                break;

            case Owner.Type.ProtectionDoc:
                var protectionDoc = await Executor.GetQuery <GetProtectionDocByIdQuery>()
                                    .Process(q => q.ExecuteAsync(ownerId));

                addIds = Executor.GetHandler <FilterAddIntegerListIdsHandler>().Process(h =>
                                                                                        h.Execute(icfemList, protectionDoc.Icfems.Select(c => c.DicIcfemId).ToList()));
                removeIds = Executor.GetHandler <FilterRemoveIntegerListIdsHandler>().Process(h =>
                                                                                              h.Execute(icfemList, protectionDoc.Icfems.Select(c => c.DicIcfemId).ToList()));

                await Executor.GetCommand <AddIcfemProtectionDocRelationsCommand>()
                .Process(c => c.ExecuteAsync(ownerId, addIds));

                await Executor.GetCommand <RemoveIcfemProtectionDocRelationsCommand>()
                .Process(c => c.ExecuteAsync(ownerId, removeIds));

                break;

            default:
                throw new NotImplementedException();
            }
            return(NoContent());
        }
        /// <summary>
        /// Получает идентификатор адресата для переписки по идентификатору и типу родительской сущности.
        /// </summary>
        /// <param name="ownerId">Идентификатор родительской сущности.</param>
        /// <param name="ownerType">Тип родительской сущности.</param>
        /// <returns>Идентификатор адресата для переписки.</returns>
        private async Task <int?> GetAddresseeId(int ownerId, Owner.Type ownerType)
        {
            switch (ownerType)
            {
            case Owner.Type.Request:
                return(await GetAddresseeIdByRequestId(ownerId));

            case Owner.Type.ProtectionDoc:
                return(await GetAddresseeIdByProtectionDocId(ownerId));

            case Owner.Type.Contract:
                return(await GetAddresseeIdByContractId(ownerId));
            }

            throw new NotImplementedException();
        }