Esempio n. 1
0
 private async Task ApplyProtectionDocConventionInfo(ProtectionDoc protectionDoc,
                                                     ConventionInfoDto[] protectionDocConventionInfoDtos)
 {
     await DeleteProtectionDocConventionInfo(protectionDoc, protectionDocConventionInfoDtos);
     await AddRangeProtectionDocConventionInfo(protectionDoc, protectionDocConventionInfoDtos);
     await UpdateProtectionDocConventionInfo(protectionDoc, protectionDocConventionInfoDtos);
 }
Esempio n. 2
0
        private int GetProlongationYears(ProtectionDoc protectionDoc)
        {
            switch (protectionDoc.Type?.Code)
            {
            case DicProtectionDocTypeCodes.ProtectionDocTypeTrademarkCode:
            case DicProtectionDocTypeCodes.RequestTypeTrademarkCode:
            case DicProtectionDocTypeCodes.ProtectionDocTypeNameOfOriginCode:
            case DicProtectionDocTypeCodes.RequestTypeNameOfOriginCode:
                return(10);

            case DicProtectionDocTypeCodes.ProtectionDocTypeInventionCode:
            case DicProtectionDocTypeCodes.RequestTypeInventionCode:
            case DicProtectionDocTypeCodes.ProtectionDocTypeIndustrialSampleCode:
            case DicProtectionDocTypeCodes.RequestTypeIndustrialSampleCode:
                return(5);

            case DicProtectionDocTypeCodes.ProtectionDocTypeUsefulModelCode:
            case DicProtectionDocTypeCodes.RequestTypeUsefulModelCode:
                return(3);

            case DicProtectionDocTypeCodes.ProtectionDocTypeSelectionAchieveCode:
            case DicProtectionDocTypeCodes.RequestTypeSelectionAchieveCode:
                return(10);

            default:
                return(0);
            }
        }
Esempio n. 3
0
        private string GetNextStageCode(ProtectionDoc protectionDoc)
        {
            switch (protectionDoc.CurrentWorkflow.CurrentStage.Code)
            {
            case RouteStageCodes.OD01_1:
                switch (protectionDoc.Type.Code)
                {
                case DicProtectionDocTypeCodes.RequestTypeNameOfOriginCode:
                case DicProtectionDocTypeCodes.ProtectionDocTypeNameOfOriginCode:
                case DicProtectionDocTypeCodes.RequestTypeTrademarkCode:
                case DicProtectionDocTypeCodes.ProtectionDocTypeTrademarkCode:
                    return(RouteStageCodes.OD01_3);

                case DicProtectionDocTypeCodes.ProtectionDocTypeInventionCode:
                case DicProtectionDocTypeCodes.ProtectionDocTypeUsefulModelCode:
                case DicProtectionDocTypeCodes.ProtectionDocTypeSelectionAchieveCode:
                case DicProtectionDocTypeCodes.ProtectionDocTypeIndustrialSampleCode:
                    return(RouteStageCodes.ODParallel);

                default:
                    return(RouteStageCodes.OD01_2_2);
                }

            case RouteStageCodes.PD_TM_AssignmentRegistrationNumber:
                return(RouteStageCodes.PD_TM_PrintingCertificate);
            }

            return(string.Empty);
        }
Esempio n. 4
0
        public void Execute(ProtectionDoc protectionDoc)
        {
            var requestRepository = Uow.GetRepository <ProtectionDoc>();

            requestRepository.Create(protectionDoc);

            Uow.SaveChanges();
        }
Esempio n. 5
0
 private async Task AddRangeIcgsProtectionDoc(ProtectionDoc protectionDoc, IcgsDto[] icgsProtectionDocDtos)
 {
     if (protectionDoc == null || icgsProtectionDocDtos == null || !icgsProtectionDocDtos.Any())
     {
         return;
     }
     var newIcgsProtectionDocs = ConvertToIcgsProtectionDocs(icgsProtectionDocDtos, protectionDoc.Id).Where(x => x.Id == default(int)).ToList();
     await Executor.GetCommand <AddIcgsProtectionDocRangeCommand>().Process(c => c.ExecuteAsync(protectionDoc.Id, newIcgsProtectionDocs));
 }
Esempio n. 6
0
        public async Task <int> ExecuteAsync(ProtectionDoc protectionDoc)
        {
            var protectionDocsRepository = Uow.GetRepository <ProtectionDoc>();

            await protectionDocsRepository.CreateAsync(protectionDoc);

            await Uow.SaveChangesAsync();

            return(protectionDoc.Id);
        }
Esempio n. 7
0
 private async Task AddProtectionDocEarlyRegDtos(ProtectionDoc protectionDoc,
                                                 RequestEarlyRegDto[] protectionDocEarlyRegDtos)
 {
     if (protectionDoc == null || protectionDocEarlyRegDtos == null || !protectionDocEarlyRegDtos.Any())
     {
         return;
     }
     var newprotectionDocEarlyRegDtos = protectionDocEarlyRegDtos.Where(x => !x.Id.HasValue);
     var newProtectionDocEarlyRegs    = _mapper.Map <List <ProtectionDocEarlyReg> >(newprotectionDocEarlyRegDtos).ToList();
     await Executor.GetCommand <AddProtectionDocEarlyRegsRangeCommand>().Process(c => c.ExecuteAsync(protectionDoc.Id, newProtectionDocEarlyRegs));
 }
Esempio n. 8
0
        private async Task UpdateBulletin(ProtectionDoc protectionDoc, ProtectionDocDetailsDto details)
        {
            var relation = protectionDoc.Bulletins.FirstOrDefault(b => b.IsPublish);

            if (relation != null)
            {
                relation.BulletinId = details.BulletinId ?? 0;
                await Executor.GetCommand <UpdateProtectionDocBulletinRelationCommand>()
                .Process(c => c.ExecuteAsync(relation));
            }
        }
Esempio n. 9
0
        private async Task AddRangeProtectionDocConventionInfo(ProtectionDoc protectionDoc,
                                                               ConventionInfoDto[] protectionDocConventionInfoDtos)
        {
            if (protectionDoc == null || protectionDocConventionInfoDtos == null || !protectionDocConventionInfoDtos.Any())
            {
                return;
            }

            var newProtectionDocConventionInfos = _mapper.Map <List <ProtectionDocConventionInfo> >(protectionDocConventionInfoDtos.Where(r => !r.Id.HasValue)).ToList();
            await Executor.GetCommand <AddProtectionDocConventionInfosRangeCommand>().Process(c => c.ExecuteAsync(protectionDoc.Id, newProtectionDocConventionInfos));
        }
Esempio n. 10
0
 public async Task Handle(ProtectionDoc protectionDoc, ProtectionDocDetailsDto protectionDocDetailsDto)
 {
     await ApplyIcgsProtectionDoc(protectionDoc, protectionDocDetailsDto.IcgsRequestDtos);
     await ApplyIcisIds(protectionDoc, protectionDocDetailsDto.IcisRequestIds.ToList());
     await ApplyColorIds(protectionDoc, protectionDocDetailsDto.ColorTzIds.ToList());
     await ApplyProtectionDocInfo(protectionDocDetailsDto, protectionDoc);
     await ApplyProtectionDocEarlyRegDtos(protectionDoc, protectionDocDetailsDto.RequestEarlyRegDtos);
     await ApplyIcfemIds(protectionDoc, protectionDocDetailsDto.IcfemIds.ToList());
     await ApplyIpcIds(protectionDoc, protectionDocDetailsDto.IpcIds.ToList(), protectionDocDetailsDto.MainIpcId);
     await ApplyProtectionDocConventionInfo(protectionDoc, protectionDocDetailsDto.RequestConventionInfoDtos);
     await UpdateBulletin(protectionDoc, protectionDocDetailsDto);
 }
        public async Task ExecuteAsync(ProtectionDoc oldProtectionDoc, ProtectionDoc newProtectionDoc)
        {
            if (newProtectionDoc == null || oldProtectionDoc == null)
            {
                throw new ArgumentNullException(nameof(newProtectionDoc));
            }

            var count = Executor.GetHandler <GetNextCountHandler>().Process(h => h.Execute(oldProtectionDoc.GosNumber));

            newProtectionDoc.GosNumber = $"{oldProtectionDoc.GosNumber}{Convert.ToChar(count + 64)}";
            // newProtectionDoc.GosDate = DateTimeOffset.Now;
        }
 private DateTimeOffset GetExtensionDate(ProtectionDoc protectionDoc)
 {
     return(protectionDoc.Bulletins != null && protectionDoc.Bulletins.Count > 0 ?
            protectionDoc.Bulletins.First().Bulletin.DateCreate.AddMonths(6)
             : DateTimeOffset.Now.DayOfWeek == DayOfWeek.Friday ?
            DateTimeOffset.Now.AddMonths(6)
                 : (int)DateTimeOffset.Now.DayOfWeek < 5 && (int)DateTimeOffset.Now.DayOfWeek > 0 ?
            DateTimeOffset.Now.AddDays(((int)DateTimeOffset.Now.DayOfWeek - 5) * -1).AddMonths(6)
                    : DateTimeOffset.Now.DayOfWeek == DayOfWeek.Saturday ?
            DateTimeOffset.Now.AddDays(6).AddMonths(6)
                      : DateTimeOffset.Now.AddDays(5).AddMonths(6));
 }
        private DateTimeOffset GetValidDate(ProtectionDoc protectionDoc)
        {
            int addYears = 0;

            switch (protectionDoc.Type?.Code)
            {
            case DicProtectionDocTypeCodes.ProtectionDocTypeTrademarkCode:
            case DicProtectionDocTypeCodes.RequestTypeTrademarkCode:
            case DicProtectionDocTypeCodes.RequestTypeNameOfOriginCode:
            case DicProtectionDocTypeCodes.ProtectionDocTypeNameOfOriginCode:
                addYears = 10;
                break;

            case DicProtectionDocTypeCodes.RequestTypeSelectionAchieveCode:
            case DicProtectionDocTypeCodes.ProtectionDocTypeSelectionAchieveCode:
                switch (protectionDoc.SelectionAchieveType.Code)
                {
                case DicSelectionAchieveTypeCodes.Agricultural:
                    addYears = 25;
                    break;

                case DicSelectionAchieveTypeCodes.AnimalHusbandry:
                    addYears = 30;
                    break;

                case DicSelectionAchieveTypeCodes.VarietiesPlant:
                    addYears = 35;
                    break;
                }
                break;

            case DicProtectionDocTypeCodes.RequestTypeUsefulModelCode:
            case DicProtectionDocTypeCodes.ProtectionDocTypeUsefulModelCode:
                addYears = 5;
                break;

            case DicProtectionDocTypeCodes.RequestTypeInventionCode:
            case DicProtectionDocTypeCodes.ProtectionDocTypeInventionCode:
                addYears = 20;
                break;

            case DicProtectionDocTypeCodes.RequestTypeIndustrialSampleCode:
            case DicProtectionDocTypeCodes.ProtectionDocTypeIndustrialSampleCode:
                addYears = 15;
                break;
            }

            return(protectionDoc.DateCreate.AddYears(addYears));
        }
Esempio n. 14
0
 private async Task UpdateProtectionDocConventionInfo(ProtectionDoc protectionDoc, ConventionInfoDto[] protectionDocConventionInfoDtos)
 {
     if (protectionDoc == null || protectionDocConventionInfoDtos == null || !protectionDocConventionInfoDtos.Any() || protectionDoc.ProtectionDocConventionInfos == null || !protectionDoc.ProtectionDocConventionInfos.Any())
     {
         return;
     }
     protectionDoc.ProtectionDocConventionInfos
     .ToList()
     .ForEach(originRc =>
     {
         protectionDocConventionInfoDtos = protectionDocConventionInfoDtos.Where(rc =>
                                                                                 !rc.Equals(_mapper.Map <ConventionInfoDto>(originRc)) && rc.Id.HasValue).ToArray();
     });
     var updateProtectionDocConventionInfos = _mapper.Map <IEnumerable <ProtectionDocConventionInfo> >(protectionDocConventionInfoDtos).ToList();
     await Executor.GetCommand <UpdateProtectionDocConventionInfosRangeCommand>().Process(c => c.ExecuteAsync(protectionDoc.Id, updateProtectionDocConventionInfos));
 }
        /// <summary>
        /// Получает идентификатор адресата для переписки по идентификатору охранного документа.
        /// </summary>
        /// <param name="protectionDocId">Идентификатор охранного документа.</param>
        /// <returns>Идентификатор адресата для переписки.</returns>
        private async Task <int?> GetAddresseeIdByProtectionDocId(int protectionDocId)
        {
            ProtectionDoc protectionDoc = await Executor
                                          .GetQuery <GetProtectionDocByIdWithCustomersAndCustomerRolesQuery>()
                                          .Process(query => query.ExecuteAsync(protectionDocId));

            if (protectionDoc is null)
            {
                throw new DataNotFoundException(nameof(ProtectionDoc),
                                                DataNotFoundException.OperationType.Read, protectionDocId);
            }

            ProtectionDocCustomer addressee = protectionDoc.ProtectionDocCustomers
                                              .FirstOrDefault(customer => customer.CustomerRole.Code == DicCustomerRoleCodes.Correspondence);

            return(addressee?.CustomerId);
        }
Esempio n. 16
0
 private async Task UpdateProtectionDocEarlyRegDtos(ProtectionDoc protectionDoc,
                                                    RequestEarlyRegDto[] protectionDocEarlyRegDtos)
 {
     if (protectionDoc == null || protectionDocEarlyRegDtos == null || !protectionDocEarlyRegDtos.Any() || !protectionDoc.EarlyRegs.Any())
     {
         return;
     }
     protectionDoc.EarlyRegs
     .ToList()
     .ForEach(r =>
     {
         protectionDocEarlyRegDtos = protectionDocEarlyRegDtos
                                     .Where(x => !x.Equals(_mapper.Map <RequestEarlyRegDto>(r)) && x.Id.HasValue)
                                     .ToArray();
     });
     var updateProtectionDocEarlyRegs = _mapper.Map <List <ProtectionDocEarlyReg> >(protectionDocEarlyRegDtos).ToList();
     await Executor.GetCommand <UpdateProtectionDocEarlyRegsRangeCommand>().Process(c => c.ExecuteAsync(protectionDoc.Id, updateProtectionDocEarlyRegs));
 }
Esempio n. 17
0
        private async Task ApplyColorIds(ProtectionDoc protectionDoc, List <int> colorTzIds)
        {
            var originColorTzIds = protectionDoc.ColorTzs.Select(c => c.ColorTzId).ToList();

            var removeColorTzIds = Executor.GetHandler <FilterRemoveIntegerListIdsHandler>().Process(h => h.Execute(colorTzIds, originColorTzIds));

            if (removeColorTzIds.Any())
            {
                await Executor.GetCommand <RemoveColorTzProtectionDocRelationsCommand>().Process(c => c.ExecuteAsync(protectionDoc.Id, removeColorTzIds));
            }

            var addColorTzIds = Executor.GetHandler <FilterAddIntegerListIdsHandler>().Process(h => h.Execute(colorTzIds, originColorTzIds));

            if (addColorTzIds.Any())
            {
                await Executor.GetCommand <AddColorTzProtectionDocRelationsCommand>().Process(c => c.ExecuteAsync(protectionDoc.Id, addColorTzIds));
            }
        }
Esempio n. 18
0
        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");
        }
Esempio n. 19
0
        private async Task ApplyIcfemIds(ProtectionDoc protectionDoc, List <int> icfemIds)
        {
            var originIcfemIds = protectionDoc.Icfems.Select(i => i.DicIcfemId).ToList();
            var removeIcfemIds = Executor.GetHandler <FilterRemoveIntegerListIdsHandler>().Process(h => h.Execute(icfemIds, originIcfemIds));

            if (removeIcfemIds.Any())
            {
                await Executor.GetCommand <RemoveIcfemProtectionDocRelationsCommand>()
                .Process(c => c.ExecuteAsync(protectionDoc.Id, removeIcfemIds));
            }

            var addIcfemIds = Executor.GetHandler <FilterAddIntegerListIdsHandler>().Process(h => h.Execute(icfemIds, originIcfemIds));

            if (addIcfemIds.Any())
            {
                await Executor.GetCommand <AddIcfemProtectionDocRelationsCommand>()
                .Process(c => c.ExecuteAsync(protectionDoc.Id, addIcfemIds));
            }
        }
Esempio n. 20
0
        /// <summary>
        /// Возвращает код типа документа исходя из охранного документа.
        /// </summary>
        /// <param name="protectionDoc">Охранный документ.</param>
        /// <returns>Код типа документа.</returns>
        private string GetPatentCode(ProtectionDoc protectionDoc)
        {
            switch (protectionDoc?.Type?.Code)
            {
            case DicProtectionDocTypeCodes.ProtectionDocTypeTrademarkCode:
            case DicProtectionDocTypeCodes.RequestTypeTrademarkCode:
                return(DicDocumentTypeCodes.TrademarkCertificate);

            case DicProtectionDocTypeCodes.ProtectionDocTypeNameOfOriginCode:
            case DicProtectionDocTypeCodes.RequestTypeNameOfOriginCode:
                return(DicDocumentTypeCodes.NmptCertificate);

            case DicProtectionDocTypeCodes.ProtectionDocTypeInventionCode:
            case DicProtectionDocTypeCodes.RequestTypeInventionCode:
                return(DicDocumentTypeCodes.InventionPatent);

                break;

            case DicProtectionDocTypeCodes.ProtectionDocTypeSelectionAchieveCode:
            case DicProtectionDocTypeCodes.RequestTypeSelectionAchieveCode:
                switch (protectionDoc?.SelectionAchieveType?.Code)
                {
                case DicSelectionAchieveTypeCodes.AnimalHusbandry:
                    return(DicDocumentTypeCodes.SelectiveAchievementsAnimalHusbandryPatent);

                case DicSelectionAchieveTypeCodes.Agricultural:
                case DicSelectionAchieveTypeCodes.VarietiesPlant:
                    return(DicDocumentTypeCodes.SelectiveAchievementsAgriculturalPatent);
                }
                break;

            case DicProtectionDocTypeCodes.ProtectionDocTypeUsefulModelCode:
            case DicProtectionDocTypeCodes.RequestTypeUsefulModelCode:
                return(DicDocumentTypeCodes.UsefulModelPatent);

            case DicProtectionDocTypeCodes.ProtectionDocTypeIndustrialSampleCode:
            case DicProtectionDocTypeCodes.RequestTypeIndustrialSampleCode:
                return(DicDocumentTypeCodes.IndustrialDesignsPatent);
            }

            return(null);
        }
Esempio n. 21
0
        private async Task DeleteProtectionDocEarlyRegDtos(ProtectionDoc protectionDoc,
                                                           RequestEarlyRegDto[] protectionDocEarlyRegDtos)
        {
            if (protectionDoc?.EarlyRegs == null || !protectionDoc.EarlyRegs.Any())
            {
                return;
            }

            var earlyRegs = protectionDoc.EarlyRegs.ToList();

            if (!protectionDocEarlyRegDtos.Any())
            {
                await Executor.GetCommand <RemoveProtectionDocEarlyRegsRangeCommand>().Process(c => c.ExecuteAsync(protectionDoc.Id, earlyRegs));
            }
            else
            {
                var deleteEarlyRegs = earlyRegs.Where(r => !protectionDocEarlyRegDtos.Select(x => x.Id).Contains(r.Id)).ToList();
                await Executor.GetCommand <RemoveProtectionDocEarlyRegsRangeCommand>().Process(c => c.ExecuteAsync(protectionDoc.Id, deleteEarlyRegs));
            }
        }
Esempio n. 22
0
        private string GetStatus(Request request, ProtectionDoc protectionDoc)
        {
            if (request != null)
            {
                if (request.StatusId != null)
                {
                    return(request.Status.NameRu);
                }
            }

            if (protectionDoc != null)
            {
                if (protectionDoc.StatusId != null)
                {
                    return(protectionDoc.Status.NameRu);
                }
            }

            return(null);
        }
Esempio n. 23
0
        protected override dynamic GetInternal(Dictionary <string, object> parameters)
        {
            Owner.Type ownerType = (Owner.Type)(int) parameters["OwnerType"];
            int        ownerId   = (int)parameters["RequestId"];

            IEnumerable <string> patentOwnerNames = new string[] { };

            switch (ownerType)
            {
            case Owner.Type.Request:
                Request request = Executor
                                  .GetQuery <GetRequestByIdQuery>()
                                  .Process(query => query.Execute(ownerId));

                if (request != null)
                {
                    patentOwnerNames = request.RequestCustomers
                                       .Where(IsRequestCustomerPatentOwner())
                                       .Select(GetRequestPatentOwnerName());
                }

                break;

            case Owner.Type.ProtectionDoc:

                ProtectionDoc protectionDoc = Executor
                                              .GetQuery <GetProtectionDocByIdQuery>()
                                              .Process(query => query.Execute(ownerId));

                if (protectionDoc != null)
                {
                    patentOwnerNames = protectionDoc.ProtectionDocCustomers
                                       .Where(IsProtectionDocCustomerPatentOwner())
                                       .Select(GetProtectionDocPatentOwnerName());
                }

                break;
            }

            return(string.Join(", ", patentOwnerNames));
        }
        private DateTimeOffset GetExecutionDate(ProtectionDoc protectionDoc, DateTimeOffset startDate, string nextStageCode)
        {
            var calendarProvider = NiisAmbientContext.Current.CalendarProvider;

            var currentStage = protectionDoc.CurrentWorkflow.CurrentStage;

            var executionDate = calendarProvider.GetExecutionDate(startDate, currentStage.ExpirationType, currentStage.ExpirationValue ?? 0);

            if (nextStageCode == RouteStageCodes.OD03_3)
            {
                switch (protectionDoc.Type.Code)
                {
                case DicProtectionDocTypeCodes.ProtectionDocTypeTrademarkCode:
                case DicProtectionDocTypeCodes.ProtectionDocTypeNameOfOriginCode:
                    executionDate = protectionDoc.ValidDate?.AddYears(10) ?? DateTimeOffset.Now.AddYears(20);
                    break;

                case DicProtectionDocTypeCodes.ProtectionDocTypeInventionCode:
                    executionDate = protectionDoc.ValidDate?.AddYears(5) ?? DateTimeOffset.Now.AddYears(20);
                    break;

                case DicProtectionDocTypeCodes.ProtectionDocTypeIndustrialSampleCode:
                    executionDate = protectionDoc.ValidDate?.AddYears(5) ?? DateTimeOffset.Now.AddYears(20);
                    break;

                case DicProtectionDocTypeCodes.ProtectionDocTypeUsefulModelCode:
                    executionDate = protectionDoc.ValidDate?.AddYears(3) ?? DateTimeOffset.Now.AddYears(20);
                    break;

                case DicProtectionDocTypeCodes.ProtectionDocTypeSelectionAchieveCode:
                    executionDate = protectionDoc.ValidDate?.AddYears(10) ?? DateTimeOffset.Now.AddYears(20);
                    break;
                }
            }
            if (nextStageCode == RouteStageCodes.OD05_02)
            {
                executionDate = protectionDoc?.MaintainDate ?? DateTimeOffset.Now.AddYears(1);
            }

            return(executionDate);
        }
Esempio n. 25
0
 private async Task DeleteRangeIcgsProtectionDoc(ProtectionDoc protectionDoc, IcgsDto[] icgsProtectionDocDtos)
 {
     if (protectionDoc?.IcgsProtectionDocs == null || !protectionDoc.IcgsProtectionDocs.Any())
     {
         return;
     }
     if (!icgsProtectionDocDtos.Any())
     {
         await Executor.GetCommand <RemoveIcgsProtectionDocRangeCommand>().Process(c => c.ExecuteAsync(protectionDoc.Id, protectionDoc.IcgsProtectionDocs.ToList()));
     }
     else
     {
         var icgsProtectionDocsForDelete = protectionDoc.IcgsProtectionDocs
                                           .Where(ir => !icgsProtectionDocDtos.Select(x => x.Id).Contains(ir.Id))
                                           .ToList();
         if (icgsProtectionDocsForDelete.Any())
         {
             await Executor.GetCommand <RemoveIcgsProtectionDocRangeCommand>().Process(c => c.ExecuteAsync(protectionDoc.Id, icgsProtectionDocsForDelete));
         }
     }
 }
Esempio n. 26
0
        private async Task ApplyIpcIds(ProtectionDoc protectionDoc, List <int> ipcIds, int?mainIpcId)
        {
            var originIpcIds = protectionDoc.IpcProtectionDocs.Select(ip => ip.IpcId).ToList();
            var removeIpcIds = Executor.GetHandler <FilterRemoveIntegerListIdsHandler>().Process(h => h.Execute(ipcIds, originIpcIds));

            if (removeIpcIds.Any())
            {
                await Executor.GetCommand <RemoveIpcProtectionDocRelationsCommand>().Process(c => c.ExecuteAsync(protectionDoc.Id, removeIpcIds));
            }

            var addIcfemIds = Executor.GetHandler <FilterAddIntegerListIdsHandler>().Process(h => h.Execute(ipcIds, originIpcIds));

            if (addIcfemIds.Any())
            {
                await Executor.GetCommand <AddIpcProtectionDocRelationsCommand>().Process(c => c.ExecuteAsync(protectionDoc.Id, addIcfemIds));
            }
            if (mainIpcId.HasValue)
            {
                Executor.GetCommand <SetMainIpcOnIpcProtectionDocCommand>().Process(c => c.Execute(protectionDoc.Id, mainIpcId.Value));
            }
        }
Esempio n. 27
0
        private async Task DeleteProtectionDocConventionInfo(ProtectionDoc protectionDoc,
                                                             ConventionInfoDto[] protectionDocConventionInfoDtos)
        {
            if (protectionDoc?.ProtectionDocConventionInfos == null || !protectionDoc.ProtectionDocConventionInfos.Any())
            {
                return;
            }

            var protectionDocConventionInfos = protectionDoc.ProtectionDocConventionInfos.ToList();

            if (!protectionDocConventionInfoDtos.Any())
            {
                await Executor.GetCommand <RemoveProtectionDocConventionInfosRangeCommand>().Process(c => c.ExecuteAsync(protectionDoc.Id, protectionDocConventionInfos));
            }
            else
            {
                var deleteProtectionDocConventionInfos = protectionDocConventionInfos
                                                         .Where(rc => !protectionDocConventionInfoDtos.Select(x => x.Id).Contains(rc.Id))
                                                         .ToList();
                await Executor.GetCommand <RemoveProtectionDocConventionInfosRangeCommand>().Process(c => c.ExecuteAsync(protectionDoc.Id, deleteProtectionDocConventionInfos));
            }
        }
Esempio n. 28
0
        private async Task UpdateRangeIcgsProtectionDoc(ProtectionDoc protectionDoc, IcgsDto[] icgsProtectionDocDtos)
        {
            var isNotNeedUpdateIcgsProtectionDoc = (protectionDoc == null || icgsProtectionDocDtos == null || !icgsProtectionDocDtos.Any() || !protectionDoc.IcgsProtectionDocs.Any());

            if (isNotNeedUpdateIcgsProtectionDoc)
            {
                return;
            }

            protectionDoc.IcgsProtectionDocs
            .ToList()
            .ForEach(ir =>
            {
                icgsProtectionDocDtos = icgsProtectionDocDtos
                                        .Where(x => !x.Equals(_mapper.Map <IcgsDto>(ir)) && x.Id.HasValue)
                                        .ToArray();
            });

            var updateIcgsProtectionDocs = ConvertToIcgsProtectionDocs(icgsProtectionDocDtos, protectionDoc.Id).ToList();
            await Executor.GetCommand <UpdateIcgsProtectionDocRangeCommand>()
            .Process(c => c.ExecuteAsync(protectionDoc.Id, updateIcgsProtectionDocs));
        }
Esempio n. 29
0
        public async Task ExecuteAsync(int protectionDocId, ProtectionDoc newProtectionDoc)
        {
            var repository       = Uow.GetRepository <ProtectionDoc>();
            var oldProtectionDoc = await repository.GetByIdAsync(protectionDocId);

            oldProtectionDoc.DateUpdate             = DateTimeOffset.Now;
            oldProtectionDoc.GosDate                = newProtectionDoc.GosDate;
            oldProtectionDoc.GosNumber              = newProtectionDoc.GosNumber;
            oldProtectionDoc.BulletinUserId         = newProtectionDoc.BulletinUserId;
            oldProtectionDoc.SupportUserId          = newProtectionDoc.SupportUserId;
            oldProtectionDoc.BeneficiaryTypeId      = newProtectionDoc.BeneficiaryTypeId;
            oldProtectionDoc.ConventionTypeId       = newProtectionDoc.ConventionTypeId;
            oldProtectionDoc.CurrentWorkflowId      = newProtectionDoc.CurrentWorkflowId;
            oldProtectionDoc.Description            = newProtectionDoc.Description;
            oldProtectionDoc.DisclaimerKz           = newProtectionDoc.DisclaimerKz;
            oldProtectionDoc.DisclaimerRu           = newProtectionDoc.DisclaimerRu;
            oldProtectionDoc.Image                  = newProtectionDoc.Image;
            oldProtectionDoc.NameEn                 = newProtectionDoc.NameEn;
            oldProtectionDoc.NameRu                 = newProtectionDoc.NameRu;
            oldProtectionDoc.NameKz                 = newProtectionDoc.NameKz;
            oldProtectionDoc.OutgoingDate           = newProtectionDoc.OutgoingDate;
            oldProtectionDoc.OutgoingNumber         = newProtectionDoc.OutgoingNumber;
            oldProtectionDoc.PreviewImage           = newProtectionDoc.PreviewImage;
            oldProtectionDoc.Referat                = newProtectionDoc.Referat;
            oldProtectionDoc.SelectionAchieveTypeId = newProtectionDoc.SelectionAchieveTypeId;
            oldProtectionDoc.SelectionFamily        = newProtectionDoc.SelectionFamily;
            oldProtectionDoc.SubTypeId              = newProtectionDoc.SubTypeId;
            oldProtectionDoc.Transliteration        = newProtectionDoc.Transliteration;
            oldProtectionDoc.TypeTrademarkId        = newProtectionDoc.TypeTrademarkId;
            oldProtectionDoc.ValidDate              = newProtectionDoc.ValidDate;
            oldProtectionDoc.MaintainDate           = newProtectionDoc.MaintainDate;
            oldProtectionDoc.PageCount              = newProtectionDoc.PageCount;
            oldProtectionDoc.SendTypeId             = newProtectionDoc.SendTypeId;
            oldProtectionDoc.AddresseeId            = newProtectionDoc.AddresseeId;
            repository.Update(oldProtectionDoc);
            await Uow.SaveChangesAsync();
        }
        public ProtectionDoc Execute(ProtectionDoc protectionDoc)
        {
            //TODO! Сгенерировать штрихкод

            return(protectionDoc);
        }