/// <summary> /// Запускает рабочий процесс связанный, с охранным документом(ОД), с пометкой "автоматический". /// </summary> /// <param name="workflowTaskEvent">Запланированная задача.</param> private static void ProcessProtectionDocumentWorkflowEvent(WorkflowTaskQueue workflowTaskEvent) { var protectionDocumentWorkFlowRequest = new ProtectionDocumentWorkFlowRequest { ProtectionDocId = workflowTaskEvent.ProtectionDocId ?? default(int), IsAuto = true }; NiisWorkflowAmbientContext.Current.ProtectionDocumentWorkflowService.Process(protectionDocumentWorkFlowRequest); }
private void RequestWorkflows(ProtectionDocumentWorkFlowRequest protectionDocumentWorkFlowRequest) { NetCoreBaseWorkflow <ProtectionDocumentWorkFlowRequest, ProtectionDoc> protectionDocumentWorkFlow; switch (protectionDocumentWorkFlowRequest.CurrentWorkflowObject.Type.Code) { case DicProtectionDocTypeCodes.ProtectionDocTypeTrademarkCode: case DicProtectionDocTypeCodes.RequestTypeTrademarkCode: protectionDocumentWorkFlow = NiisWorkflowAmbientContext.Current.ProtectionDocumentTrademarkWorkflow; break; case DicProtectionDocTypeCodes.ProtectionDocTypeInventionCode: case DicProtectionDocTypeCodes.RequestTypeInventionCode: protectionDocumentWorkFlow = NiisWorkflowAmbientContext.Current.ProtectionDocumentInventionsWorkflow; break; case DicProtectionDocTypeCodes.ProtectionDocTypeSelectionAchieveCode: case DicProtectionDocTypeCodes.RequestTypeSelectionAchieveCode: protectionDocumentWorkFlow = NiisWorkflowAmbientContext.Current .ProtectionDocumentSelectiveAchievementsWorkflow; break; case DicProtectionDocTypeCodes.ProtectionDocTypeNameOfOriginCode: case DicProtectionDocTypeCodes.RequestTypeNameOfOriginCode: protectionDocumentWorkFlow = NiisWorkflowAmbientContext.Current.ProtectionDocumentAppellationOfOriginWorkflow; break; case DicProtectionDocTypeCodes.ProtectionDocTypeIndustrialSampleCode: case DicProtectionDocTypeCodes.RequestTypeIndustrialSampleCode: protectionDocumentWorkFlow = NiisWorkflowAmbientContext.Current.ProtectionDocumentIndustrialDesignsWorkflow; break; case DicProtectionDocTypeCodes.ProtectionDocTypeUsefulModelCode: case DicProtectionDocTypeCodes.RequestTypeUsefulModelCode: protectionDocumentWorkFlow = NiisWorkflowAmbientContext.Current.ProtectionDocumentUsefulModelWorkflow; break; default: throw new NotImplementedException(); } if (protectionDocumentWorkFlow is null) { throw new NotImplementedException(); } protectionDocumentWorkFlow.SetWorkflowRequest(protectionDocumentWorkFlowRequest); protectionDocumentWorkFlow.Process(); }
private void ProcessProtectionDocWorkflow(ProtectionDoc protectionDoc) { var protectionDocumentWorkFlowRequest = new ProtectionDocumentWorkFlowRequest { ProtectionDocId = protectionDoc?.Id ?? default(int), IsAuto = true }; try { NiisWorkflowAmbientContext.Current.ProtectionDocumentWorkflowService.Process(protectionDocumentWorkFlowRequest); } catch (Exception exception) { WriteLogMessage(exception.Message); return; } WriteLogMessage("Processed"); }
private async Task <WorkflowDto> ProcessProtectionDocumentWorkflow(WorkflowDto workflowDto) { var protectionDocumentWorkFlowRequest = new ProtectionDocumentWorkFlowRequest { ProtectionDocId = workflowDto.OwnerId ?? default(int), NextStageUserId = workflowDto.CurrentUserId ?? default(int), NextStageCode = workflowDto.CurrentStageCode, }; NiisWorkflowAmbientContext.Current.ProtectionDocumentWorkflowService.Process(protectionDocumentWorkFlowRequest); var protectionDoc = await Executor.GetQuery <GetProtectionDocByIdQuery>() .Process(q => q.ExecuteAsync(protectionDocumentWorkFlowRequest.ProtectionDocId)); var protectionDocWorkflow = await Executor.GetQuery <GetProtectionDocWorkflowByIdQuery>().Process(r => r.ExecuteAsync(protectionDoc.CurrentWorkflowId ?? default(int))); var responseWorkflowDto = Mapper.Map <ProtectionDocWorkflow, WorkflowDto>(protectionDocWorkflow); return(responseWorkflowDto); }
public void Process(ProtectionDocumentWorkFlowRequest protectionDocumentWorkFlowRequest, int?specialUserId = null) { var current = NiisAmbientContext.Current; ProtectionDocWorkflow specWorkf = null; if (current != null && current.User != null && current.User.Identity != null) { specialUserId = NiisAmbientContext.Current.User.Identity.UserId; } if (specialUserId.HasValue && !_executor .GetQuery <TryGetProtectionDocWorkflowFromParalleByOwnerIdCommand>() .Process(r => r.Execute(protectionDocumentWorkFlowRequest.ProtectionDocId, specialUserId.Value, out specWorkf)) || specWorkf != null && new string[] { RouteStageCodes.OD03_1, RouteStageCodes.OD01_6 }.Contains(specWorkf.CurrentStage.Code) ) { if (protectionDocumentWorkFlowRequest.ProtectionDocId != 0) { protectionDocumentWorkFlowRequest.CurrentWorkflowObject = _executor .GetQuery <GetProtectionDocByIdForWorkflowServiceQuery>().Process(r => r.Execute(protectionDocumentWorkFlowRequest.ProtectionDocId, specialUserId)); if (protectionDocumentWorkFlowRequest.IsAuto) { protectionDocumentWorkFlowRequest.NextStageUserId = protectionDocumentWorkFlowRequest?.CurrentWorkflowObject?.CurrentWorkflow?.CurrentUserId ?? 0; } RequestWorkflows(protectionDocumentWorkFlowRequest); } } }
public void StartWorkflowProccess(ProtectionDocumentWorkFlowRequest workFlowRequest) { NiisWorkflowAmbientContext.Current.ProtectionDocumentWorkflowService.Process(workFlowRequest); }
public async Task <IActionResult> SplitProtectionDoc(int id, [FromBody] IcgsDto[] icgsDtos) { var protectionDoc = await Executor.GetQuery <GetProtectionDocByIdQuery>().Process(q => q.ExecuteAsync(id)); var newProtectionDoc = Mapper.Map <ProtectionDoc>(protectionDoc); #region Создание охранного документа newProtectionDoc.TypeId = protectionDoc.TypeId; newProtectionDoc.SubTypeId = protectionDoc.SubTypeId; newProtectionDoc.DateCreate = DateTimeOffset.Now; newProtectionDoc.RequestId = protectionDoc.RequestId; newProtectionDoc.Transliteration = protectionDoc.Transliteration; await Executor.GetHandler <GenerateNumberForSplitProtectionDocsHandler>().Process(h => h.ExecuteAsync(protectionDoc, newProtectionDoc)); Executor.GetHandler <GenerateBarcodeHandler>().Process(h => h.Execute(newProtectionDoc)); var newProtectionDocId = await Executor.GetCommand <CreateProtectionDocCommand>().Process(c => c.ExecuteAsync(newProtectionDoc)); if (newProtectionDoc.RequestId != null) { //Создаем связь между заявкой и охранным документом. var requestProtectionDocSimilar = new RequestProtectionDocSimilar { RequestId = (int)newProtectionDoc.RequestId, ProtectionDocId = newProtectionDoc.Id, DateCreate = DateTimeOffset.Now }; Executor.GetCommand <CreateRequestProtectionDocSimilarCommand>().Process(r => r.Execute(requestProtectionDocSimilar)); } var newWorkflows = Mapper.Map <ProtectionDocWorkflow[]>(protectionDoc.Workflows).OrderBy(w => w.DateCreate); foreach (var newWorkflow in newWorkflows) { newWorkflow.OwnerId = newProtectionDocId; Executor.GetCommand <CreateProtectionDocWorkflowCommand>().Process(c => c.Execute(newWorkflow)); } var initialStage = await Executor.GetQuery <GetDicRouteStageByCodeQuery>().Process(q => q.ExecuteAsync(protectionDoc.CurrentWorkflow.FromStage.Code)); var initialWorkflow = new ProtectionDocWorkflow() { CurrentUserId = NiisAmbientContext.Current.User.Identity.UserId, OwnerId = newProtectionDocId, CurrentStageId = initialStage.Id, RouteId = initialStage.RouteId, IsComplete = initialStage.IsLast, IsSystem = initialStage.IsSystem, IsMain = initialStage.IsMain, }; var initialWorkflowId = Executor.GetCommand <CreateProtectionDocWorkflowCommand>().Process(c => c.Execute(initialWorkflow)); newProtectionDoc.CurrentWorkflowId = initialWorkflowId; await Executor.GetCommand <UpdateProtectionDocCommand>().Process(c => c.ExecuteAsync(newProtectionDocId, newProtectionDoc)); #endregion await CreatePatentOrCertificate(newProtectionDocId, null); #region МКТУ var newIcgsProtectionDocs = Mapper.Map <ICGSProtectionDoc[]>(icgsDtos); foreach (var newIcgsRequest in newIcgsProtectionDocs) { newIcgsRequest.ProtectionDocId = newProtectionDocId; } await Executor.GetCommand <UpdateIcgsProtectionDocRangeCommand>() .Process(c => c.ExecuteAsync(id, newIcgsProtectionDocs.ToList())); #endregion #region Биб. данные var newConventionInfos = Mapper.Map <ProtectionDocConventionInfo[]>(protectionDoc.ProtectionDocConventionInfos); await Executor.GetCommand <AddProtectionDocConventionInfosRangeCommand>() .Process(c => c.ExecuteAsync(newProtectionDocId, newConventionInfos.ToList())); var newProtectionDocEarlyRegs = Mapper.Map <ProtectionDocEarlyReg[]>(protectionDoc.EarlyRegs); await Executor.GetCommand <AddProtectionDocEarlyRegsRangeCommand>() .Process(c => c.ExecuteAsync(newProtectionDocId, newProtectionDocEarlyRegs.ToList())); var newIpcProtectionDocs = Mapper.Map <IPCProtectionDoc[]>(protectionDoc.IpcProtectionDocs); await Executor.GetCommand <AddIpcProtectionDocRelationsCommand>().Process(c => c.ExecuteAsync(newProtectionDocId, newIpcProtectionDocs.Select(i => i.IpcId).ToList())); var newIcisProtectionDocs = Mapper.Map <ICISProtectionDoc[]>(protectionDoc.IcisProtectionDocs); await Executor.GetCommand <AddIcisProtectionDocRelationsCommand>().Process(c => c.ExecuteAsync(newProtectionDocId, newIcisProtectionDocs.Select(i => i.IcisId).ToList())); await Executor.GetCommand <AddColorTzProtectionDocRelationsCommand>().Process(c => c.ExecuteAsync(newProtectionDocId, protectionDoc.ColorTzs.Select(color => color.ColorTzId).ToList())); await Executor.GetCommand <AddIcfemProtectionDocRelationsCommand>().Process(c => c.ExecuteAsync(newProtectionDocId, protectionDoc.Icfems.Select(i => i.DicIcfemId).ToList())); #endregion #region Контрагенты var newCustomers = Mapper.Map <ProtectionDocCustomer[]>(protectionDoc.ProtectionDocCustomers); await Executor.GetCommand <AddProtectionDocCustomersCommand>().Process(c => c.ExecuteAsync(newProtectionDocId, newCustomers.ToList())); #endregion var protectionDocumentWorkFlowRequest = new ProtectionDocumentWorkFlowRequest() { ProtectionDocId = id, NextStageUserId = protectionDoc.CurrentWorkflow?.FromUserId ?? 0, NextStageCode = protectionDoc.CurrentWorkflow?.FromStage.Code ?? "", }; NiisWorkflowAmbientContext.Current.ProtectionDocumentWorkflowService.Process(protectionDocumentWorkFlowRequest); return(Ok(newProtectionDocId)); }
public async Task <IActionResult> WorkflowCreateMultiple ([FromBody] int[] ids, int userId, int bulletinUserId, int supportUserId, int bulletinId, int nextUserForPrintId, int nextUserForDescriptionsId, int nextUserForMaintenanceId) { var isAllSelected = Convert.ToBoolean(Request.Query["isAllSelected"].ToString()); var hasIpc = Convert.ToBoolean(Request.Query["hasIpc"].ToString()); SelectionMode selectionMode; switch (Request.Query["selectionMode"].ToString()) { case "0": selectionMode = SelectionMode.Including; break; case "1": selectionMode = SelectionMode.Except; break; default: throw new NotImplementedException(); } ids = await _protectionDocService.GenerateGosNumbers(ids, selectionMode, hasIpc, isAllSelected); foreach (var id in ids) { var protectionDoc = await Executor.GetQuery <GetProtectionDocByIdQuery>() .Process(q => q.ExecuteAsync(id)); if (protectionDoc is null) { throw new DataNotFoundException(nameof(ProtectionDoc), DataNotFoundException.OperationType.Read, id); } if (bulletinUserId != 0) { protectionDoc.BulletinUserId = bulletinUserId; } if (supportUserId != 0) { protectionDoc.SupportUserId = supportUserId; } await Executor.GetCommand <UpdateProtectionDocCommand>().Process(c => c.ExecuteAsync(id, protectionDoc)); string stageCode = GetNextStageCode(protectionDoc); var relation = new ProtectionDocBulletinRelation { BulletinId = bulletinId, ProtectionDocId = id, IsPublish = true }; await Executor.GetCommand <CreateProtectionDocBulletinRelationCommand>() .Process(c => c.ExecuteAsync(relation)); if (stageCode != RouteStageCodes.ODParallel) { await CreatePatentOrCertificate(id, userId != 0?userId : nextUserForMaintenanceId); } var protectionDocumentWorkFlowRequest = new ProtectionDocumentWorkFlowRequest { ProtectionDocId = id, NextStageCode = stageCode, NextStageUserId = userId != 0 ? userId : nextUserForMaintenanceId, }; if (nextUserForPrintId > 0) { protectionDocumentWorkFlowRequest.SpecificNextStageUserIds[RouteStageCodes.OD01_3] = nextUserForPrintId; } if (nextUserForDescriptionsId > 0) { protectionDocumentWorkFlowRequest.SpecificNextStageUserIds[RouteStageCodes.OD01_2_2] = nextUserForDescriptionsId; } if (nextUserForMaintenanceId > 0 && bulletinUserId == 0) { protectionDocumentWorkFlowRequest.SpecificNextStageUserIds[RouteStageCodes.OD03_1] = nextUserForMaintenanceId; } if (bulletinUserId > 0 && nextUserForMaintenanceId == 0) { protectionDocumentWorkFlowRequest.SpecificNextStageUserIds[RouteStageCodes.OD01_6] = bulletinUserId; } NiisWorkflowAmbientContext.Current.ProtectionDocumentWorkflowService.Process(protectionDocumentWorkFlowRequest); } return(NoContent()); }