コード例 #1
0
        public async Task <int> ExecuteAsync(ProtectionDocBulletinRelation protectionDocBulletin)
        {
            var repo = Uow.GetRepository <ProtectionDocBulletinRelation>();
            await repo.CreateAsync(protectionDocBulletin);

            await Uow.SaveChangesAsync();

            return(protectionDocBulletin.Id);
        }
コード例 #2
0
        public async Task <IActionResult> AttachProtectionDocToBulletin([FromBody] BulletinAttachmentDto bulletinAttachmentDto)
        {
            var relation = new ProtectionDocBulletinRelation
            {
                BulletinId      = bulletinAttachmentDto.BulletinId,
                ProtectionDocId = bulletinAttachmentDto.ProtectionDocId
            };
            await Executor.GetCommand <CreateProtectionDocBulletinRelationCommand>()
            .Process(c => c.ExecuteAsync(relation));

            return(NoContent());
        }
コード例 #3
0
        public async Task ExecuteAsync(ProtectionDocBulletinRelation relation)
        {
            var repo        = Uow.GetRepository <ProtectionDocBulletinRelation>();
            var oldRelation = await repo.GetByIdAsync(relation.Id);

            oldRelation.BulletinId      = relation.BulletinId;
            oldRelation.ProtectionDocId = relation.ProtectionDocId;
            oldRelation.IsPublish       = relation.IsPublish;
            repo.Update(oldRelation);

            await Uow.SaveChangesAsync();
        }
コード例 #4
0
        public async Task ExecuteAsync(int protectionDocId, KeyValuePair <string, object>[] pairs)
        {
            if (pairs is null || pairs.Length < 1)
            {
                return;
            }

            var repository       = Uow.GetRepository <ProtectionDoc>();
            var oldProtectionDoc = await NiisAmbientContext.Current.Executor.GetCommand <GetProtectionDocByIdQuery>()
                                   .Process(c => c.ExecuteAsync(protectionDocId));

            foreach (var pair in pairs)
            {
                switch (pair.Key)
                {
                case "validDate":
                {
                    oldProtectionDoc.ValidDate = new DateTimeOffset((DateTime)pair.Value);

                    repository.Update(oldProtectionDoc);
                    await Uow.SaveChangesAsync();
                }
                break;

                case "bulletinId":
                {
                    var relationId = oldProtectionDoc.Bulletins.FirstOrDefault(b => b.IsPublish)?.Id ?? 0;
                    if (relationId != 0)
                    {
                        await NiisAmbientContext.Current.Executor.GetCommand <DeleteProtectionDocBulletinRelationCommand>()
                        .Process(c => c.ExecuteAsync(relationId));
                    }

                    int nextId   = (int)((long)pair.Value);
                    var relation = new ProtectionDocBulletinRelation
                    {
                        BulletinId      = nextId,
                        ProtectionDocId = protectionDocId,
                        IsPublish       = true
                    };
                    await NiisAmbientContext.Current.Executor.GetCommand <CreateProtectionDocBulletinRelationCommand>()
                    .Process(c => c.ExecuteAsync(relation));
                }
                break;

                default:
                    break;
                }
            }
        }
コード例 #5
0
        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());
        }