private bool CurrentStageContains(Domain.Entities.Document.Document document, params string[] codes) { return(codes.Contains(document.CurrentWorkflow.CurrentStage.Code)); }
public async Task CreateAuthorsCertificate(int protectionDocId, int[] authorIds, int userId) { var protectionDoc = await _executor.GetQuery <GetProtectionDocByIdQuery>().Process(q => q.ExecuteAsync(protectionDocId)); string authorCertificateCode = null; switch (protectionDoc.Type?.Code) { case DicProtectionDocTypeCodes.ProtectionDocTypeInventionCode: authorCertificateCode = DicDocumentTypeCodes.InventionAuthorCertificate; break; case DicProtectionDocTypeCodes.ProtectionDocTypeSelectionAchieveCode: switch (protectionDoc.SelectionAchieveType?.Code) { case DicSelectionAchieveTypeCodes.AnimalHusbandry: authorCertificateCode = DicDocumentTypeCodes.AnimalHusbandrySelectiveAchievementAuthorCertificate; break; case DicSelectionAchieveTypeCodes.Agricultural: case DicSelectionAchieveTypeCodes.VarietiesPlant: authorCertificateCode = DicDocumentTypeCodes.AgriculturalSelectiveAchievementAuthorCertificate; break; } break; case DicProtectionDocTypeCodes.ProtectionDocTypeUsefulModelCode: authorCertificateCode = DicDocumentTypeCodes.UsefulModelAuthorCertificate; break; case DicProtectionDocTypeCodes.ProtectionDocTypeIndustrialSampleCode: authorCertificateCode = DicDocumentTypeCodes.IndustrialDesignAuthorCertificate; break; } if (authorCertificateCode != null) { var authors = protectionDoc.ProtectionDocCustomers.Where(pc => authorIds.Contains(pc.Id)); List <PaymentInvoice> invoices = null; if (protectionDoc.PaymentInvoices == null || protectionDoc.PaymentInvoices.Count < 1) { throw new DataNotFoundException(nameof(PaymentInvoice), DataNotFoundException.OperationType.Read, protectionDocId); } invoices = protectionDoc .PaymentInvoices .Where(pi => new string[] { "702", "702.1", "702.2", "702.3" }.Contains(pi.Tariff.Code) && pi.Status.Code == DicPaymentStatusCodes.Credited).ToList(); if (invoices == null || invoices.Count < 1) { throw new DataNotFoundException(nameof(PaymentInvoice), DataNotFoundException.OperationType.Read, protectionDocId); } for (int i = 0; i < authors.Count(); i++) { var userInputDto = new UserInputDto { Code = authorCertificateCode, Fields = new List <KeyValuePair <string, string> >(), OwnerId = protectionDocId, OwnerType = Owner.Type.ProtectionDoc, SelectedRequestIds = new List <int> { protectionDocId }, Index = i + 1, }; var documentType = _executor.GetQuery <BusinessLogic.Dictionaries.DicDocumentType.GetDicDocumentTypeByCodeQuery>() .Process(q => q.Execute(authorCertificateCode)); if (documentType == null) { throw new DataNotFoundException(nameof(Domain.Entities.Dictionaries.DicDocumentType), DataNotFoundException.OperationType.Read, authorCertificateCode); } int currentUserId = userId; int?addresseeId = protectionDoc.ProtectionDocCustomers.FirstOrDefault(c => c.CustomerRole.Code == DicCustomerRoleCodes.Correspondence)?.CustomerId; var document = new Domain.Entities.Document.Document { TypeId = documentType.Id, AddresseeId = addresseeId, DocumentType = DocumentType.Internal, DateCreate = DateTimeOffset.Now, DateUpdate = DateTimeOffset.Now, StatusId = _executor.GetQuery <BusinessLogic.Dictionaries.DicDocumentStatusQuery.GetDocumentStatusByCodeQuery>().Process(q => q.Execute(DicDocumentStatusCodes.InWork)).Id }; var documentId = await _executor.GetCommand <CreateDocumentCommand>().Process(c => c.ExecuteAsync(document)); await _executor.GetCommand <BusinessLogic.Documents.ManyToManyRelations.AddProtectionDocDocumentsCommand>().Process(c => c.ExecuteAsync(new List <Domain.Entities.ProtectionDoc.ProtectionDocDocument> { new Domain.Entities.ProtectionDoc.ProtectionDocDocument { ProtectionDocId = protectionDocId, DocumentId = documentId } })); var documentWorkflow = await _executor.GetQuery <BusinessLogic.Workflows.Documents.GetInitialDocumentWorkflowQuery>().Process(q => q.ExecuteAsync(documentId, userId)); await _executor.GetCommand <BusinessLogic.Workflows.Documents.ApplyDocumentWorkflowCommand>().Process(c => c.ExecuteAsync(documentWorkflow)); await _executor.GetCommand <UpdateDocumentCommand>().Process(c => c.Execute(document)); await _executor.GetHandler <BusinessLogic.Documents.Numbers.GenerateDocumentBarcodeHandler>().Process(c => c.ExecuteAsync(documentId)); await _executor.GetHandler <BusinessLogic.Documents.Numbers.GenerateRegisterDocumentNumberHandler>().Process(c => c.ExecuteAsync(documentId)); await _executor.GetCommand <BusinessLogic.Documents.UserInput.CreateUserInputCommand>().Process(c => c.ExecuteAsync(documentId, userInputDto)); if (documentId > 0 && invoices.Count > 0) { var invoice = invoices[i]; invoice.StatusId = _executor.GetHandler <GetPaymentStatusByCodeQuery>().Process(x => x.Execute(DicPaymentStatusCodes.Distributed)).Id; invoice.DateUpdate = DateTimeOffset.Now; invoice.WriteOffUserId = NiisAmbientContext.Current.User.Identity.UserId; } } _executor.GetCommand <UpdatePaymentInvoicesCommand>().Process(x => x.Execute(invoices)); } }
/// <summary> /// Логика обработки этапов при исходящем документе "Запрос экспертизы по существу (ИЗ-2а_kz)" /// или "30_Запрос экспертизы заявки на выдачу патента на изобретение (Форма ИЗ-2б)" /// </summary> /// <param name="document">Документ</param> /// <param name="request">Заявка</param> /// <returns>Запрос для получения этапа "Запрос экспертизы"</returns> private Expression <Func <DicRouteStage, bool> > SubstantiveExaminationRequestLogic(Domain.Entities.Document.Document document, Domain.Entities.Request.Request request) { if (CurrentStageContains(document, "OUT03.1")) { if (CurrentStageContains(request, "B03.2.4")) { return(s => s.Code.Equals("B03.3.1.1")); } } return(null); }
/// <summary> /// Логика обработки этапов при входящем документе "33_Уведомление о принятии решения о выдаче патента (УВ-Кб)" /// </summary> /// <param name="document">Документ</param> /// <param name="request">Заявка</param> /// <returns>Запрос для получения этапа "Подготовка для передачи в Госреестр"</returns> private Expression <Func <DicRouteStage, bool> > PreparationToGosRegisterTransferLogic(Domain.Entities.Document.Document document, Domain.Entities.Request.Request request) { if (CurrentStageContains(request, "B03.3.5") && CurrentStageContains(document, "OUT03.1")) { return(s => s.Code.Equals("B03.3.7.1")); } if (CurrentStageContains(request, "B03.3.4.1.0") && CurrentStageContains(document, "OUT03.1")) { return(s => s.Code.Equals("B03.3.7.1")); } return(null); }
/// <summary> /// Логика обработки этапов при исходящем документе "4.20_Уведомление на изобретение (неподан. в связи с отсутствием оплаты за прием заявки)_ИЗ" /// </summary> /// <param name="document">Документ</param> /// <param name="request">Заявка</param> /// <returns>Запрос для получения этапа "Признаны неподанными или ошибочно зарегистрированные"</returns> private Expression <Func <DicRouteStage, bool> > PaymentlessInventionRequestLogic(Domain.Entities.Document.Document document, Domain.Entities.Request.Request request) { if (CurrentStageContains(document, "OUT03.1")) { if (CurrentStageContains(request, "X01") && FromStageContains(request, "B02.2.0.0")) { return(s => s.Code.Equals("B04.0.0.1")); } } return(null); }
/// <summary> /// Логика обработки этапов при исходящем документе "4.7_Уведомление о положительном результате ФЭ" /// </summary> /// <param name="document">Документ</param> /// <param name="request">Заявка</param> /// <returns>Запрос для получения этапа "Готовые для передачи на экспертизу по существу"</returns> private Expression <Func <DicRouteStage, bool> > ReadyToMeritsExaminationLogic(Domain.Entities.Document.Document document, Domain.Entities.Request.Request request) { if (CurrentStageContains(document, "OUT03.1")) { if (CurrentStageContains(request, "B03.2.1")) { if (HasPaidInvoices(request, DicTariff.Codes.ExaminationOfApplicationForInventionMerits) || HasPaidInvoices(request, DicTariff.Codes.AcceleratedExaminationOfApplicationForInventionMerits) || HasPaidInvoices(request, DicTariff.Codes.ExaminationOfApplicationForInventionMeritsWithInternationalReport) || HasPaidInvoices(request, DicTariff.Codes.ExaminationOfApplicationForInventionMeritsWithSearchReport)) { return(s => s.Code.Equals("B03.2.1.1")); } } } return(null); }