Ejemplo n.º 1
0
            private void ApplyIcisIds(Domain.Entities.ProtectionDoc.ProtectionDoc protectionDoc, int[] icisIds)
            {
                protectionDoc.IcisProtectionDocs
                .ToList()
                .ForEach(ir =>
                {
                    if (icisIds.Contains(ir.IcisId))
                    {
                        //Exclude existing row
                        icisIds = icisIds.Where(val => val != ir.IcisId).ToArray();
                    }
                    else
                    {
                        //Clear deleted row
                        _context.ICISProtectionDocs.Remove(ir);
                    }
                });

                //Add new rows
                var newIcisProtectionDocs = icisIds.Select(id => new ICISProtectionDoc {
                    ProtectionDocId = protectionDoc.Id, IcisId = id
                });

                foreach (var icis in newIcisProtectionDocs)
                {
                    protectionDoc.IcisProtectionDocs.Add(icis);
                }
            }
Ejemplo n.º 2
0
            private void ApplyColorIds(Domain.Entities.ProtectionDoc.ProtectionDoc protectionDoc, int[] colorTzIds)
            {
                protectionDoc.ColorTzs
                .ToList()
                .ForEach(ir =>
                {
                    if (colorTzIds.Contains(ir.ColorTzId))
                    {
                        //Exclude existing row
                        colorTzIds = colorTzIds.Where(val => val != ir.ColorTzId).ToArray();
                    }
                    else
                    {
                        //Clear deleted row
                        _context.DicColorTzProtectionDocRelations.Remove(ir);
                    }
                });

                //Add new rows
                var colorTzRequestRelations = colorTzIds.Select(id =>
                                                                new DicColorTZProtectionDocRelation {
                    ProtectionDocId = protectionDoc.Id, ColorTzId = id
                });

                foreach (var colorTzRequestRelation in colorTzRequestRelations)
                {
                    protectionDoc.ColorTzs.Add(colorTzRequestRelation);
                }
            }
Ejemplo n.º 3
0
 private void ApplyRequestConventionInfo(Domain.Entities.ProtectionDoc.ProtectionDoc protectionDoc,
                                         ConventionInfoDto[] requestConventionInfoDtos)
 {
     DeleteRequestConventionInfo(protectionDoc, requestConventionInfoDtos);
     AddRangeRequestConventionInfo(protectionDoc, requestConventionInfoDtos);
     UpdateRequestConventionInfo(protectionDoc, requestConventionInfoDtos);
 }
Ejemplo n.º 4
0
            private void UpdateRequestEarlyRegDtos(Domain.Entities.ProtectionDoc.ProtectionDoc protectionDoc,
                                                   RequestEarlyRegDto[] earlyRegDtos)
            {
                if (protectionDoc == null || earlyRegDtos == null || !earlyRegDtos.Any())
                {
                    return;
                }
                protectionDoc.EarlyRegs
                .ToList()
                .ForEach(r =>
                {
                    earlyRegDtos = earlyRegDtos
                                   .Where(x => !x.Equals(_mapper.Map <ProtectionDocEarlyReg>(r)) && x.Id.HasValue)
                                   .ToArray();
                });
                var updateEarlyRegs = _mapper.Map <IEnumerable <ProtectionDocEarlyReg> >(earlyRegDtos);

                foreach (var earlyReg in updateEarlyRegs)
                {
                    var originEarlyReg = protectionDoc.EarlyRegs.First(x => x.Id == earlyReg.Id);
                    originEarlyReg.RegCountryId   = earlyReg.RegCountryId;
                    originEarlyReg.RegNumber      = earlyReg.RegNumber;
                    originEarlyReg.RegDate        = earlyReg.RegDate;
                    originEarlyReg.EarlyRegTypeId = earlyReg.EarlyRegTypeId;
                }
            }
Ejemplo n.º 5
0
            private void UpdateRequestConventionInfo(Domain.Entities.ProtectionDoc.ProtectionDoc protectionDoc,
                                                     ConventionInfoDto[] conventionInfoDtos)
            {
                if (protectionDoc == null || conventionInfoDtos == null || !conventionInfoDtos.Any())
                {
                    return;
                }
                protectionDoc.ProtectionDocConventionInfos
                .ToList()
                .ForEach(originRc =>
                {
                    conventionInfoDtos = conventionInfoDtos.Where(rc =>
                                                                  !rc.Equals(_mapper.Map <ConventionInfoDto>(originRc)) && rc.Id.HasValue).ToArray();
                });
                var updateConventionInfos =
                    _mapper.Map <IEnumerable <ProtectionDocConventionInfo> >(conventionInfoDtos);

                foreach (var itemConventionInfo in updateConventionInfos)
                {
                    var originConventionInfo =
                        protectionDoc.ProtectionDocConventionInfos.First(rc => rc.Id == itemConventionInfo.Id);
                    originConventionInfo.CountryId            = itemConventionInfo.CountryId;
                    originConventionInfo.EarlyRegTypeId       = itemConventionInfo.EarlyRegTypeId;
                    originConventionInfo.DateInternationalApp = itemConventionInfo.DateInternationalApp;
                    originConventionInfo.HeadIps = itemConventionInfo.HeadIps;
                    originConventionInfo.RegNumberInternationalApp      = itemConventionInfo.RegNumberInternationalApp;
                    originConventionInfo.TermNationalPhaseFirsChapter   = itemConventionInfo.TermNationalPhaseFirsChapter;
                    originConventionInfo.TermNationalPhaseSecondChapter =
                        itemConventionInfo.TermNationalPhaseSecondChapter;
                }
            }
Ejemplo n.º 6
0
            private void DeleteRequestEarlyRegDtos(Domain.Entities.ProtectionDoc.ProtectionDoc protectionDoc,
                                                   RequestEarlyRegDto[] earlyRegDtos)
            {
                if (protectionDoc?.EarlyRegs == null || !protectionDoc.EarlyRegs.Any())
                {
                    return;
                }

                if (!earlyRegDtos.Any())
                {
                    _context.ProtectionDocEarlyRegs.RemoveRange(protectionDoc.EarlyRegs);
                }
                else
                {
                    protectionDoc.EarlyRegs
                    .ToList()
                    .ForEach(r =>
                    {
                        if (!earlyRegDtos.Select(x => x.Id).Contains(r.Id))
                        {
                            _context.ProtectionDocEarlyRegs.Remove(r);
                        }
                    });
                }
            }
Ejemplo n.º 7
0
            private void DeleteRequestConventionInfo(Domain.Entities.ProtectionDoc.ProtectionDoc protectionDoc,
                                                     ConventionInfoDto[] requestConventionInfoDtos)
            {
                if (protectionDoc?.ProtectionDocConventionInfos == null || !protectionDoc.ProtectionDocConventionInfos.Any())
                {
                    return;
                }

                if (!requestConventionInfoDtos.Any())
                {
                    _context.ProtectionDocConventionInfos.RemoveRange(protectionDoc.ProtectionDocConventionInfos);
                }
                else
                {
                    protectionDoc.ProtectionDocConventionInfos
                    .ToList()
                    .ForEach(rc =>
                    {
                        if (!requestConventionInfoDtos.Select(x => x.Id).Contains(rc.Id))
                        {
                            _context.ProtectionDocConventionInfos.Remove(rc);
                        }
                    });
                }
            }
Ejemplo n.º 8
0
 private void ApplyRequestEarlyRegDtos(Domain.Entities.ProtectionDoc.ProtectionDoc protectionDoc,
                                       RequestEarlyRegDto[] requestEarlyRegDtos)
 {
     DeleteRequestEarlyRegDtos(protectionDoc, requestEarlyRegDtos);
     AddRequestEarlyRegDtos(protectionDoc, requestEarlyRegDtos);
     UpdateRequestEarlyRegDtos(protectionDoc, requestEarlyRegDtos);
 }
Ejemplo n.º 9
0
            private void UpdateRangeIcgsRequest(Domain.Entities.ProtectionDoc.ProtectionDoc protectionDoc, IcgsDto[] icgsDtos)
            {
                if (protectionDoc == null || icgsDtos == null || !icgsDtos.Any())
                {
                    return;
                }
                protectionDoc.IcgsProtectionDocs
                .ToList()
                .ForEach(ir =>
                {
                    icgsDtos = icgsDtos
                               .Where(x => !x.Equals(_mapper.Map <IcgsDto>(ir)) && x.Id.HasValue)
                               .ToArray();
                });

                var updateIcgs = ConvertToIcgs(icgsDtos, protectionDoc.Id);

                foreach (var icgs in updateIcgs)
                {
                    var originIcgs = protectionDoc.IcgsProtectionDocs.First(x => x.Id == icgs.Id);
                    originIcgs.ClaimedDescription  = icgs.ClaimedDescription;
                    originIcgs.Description         = icgs.Description;
                    originIcgs.DescriptionKz       = icgs.DescriptionKz;
                    originIcgs.NegativeDescription = icgs.NegativeDescription;
                    originIcgs.IcgsId = icgs.IcgsId;
                }
            }
Ejemplo n.º 10
0
            private void ApplyIpcIds(Domain.Entities.ProtectionDoc.ProtectionDoc protectionDoc, int[] ipcIds)
            {
                protectionDoc.IpcProtectionDocs
                .ToList()
                .ForEach(ip =>
                {
                    if (ipcIds.Contains(ip.IpcId))
                    {
                        //Exclude existing row
                        ipcIds = ipcIds.Where(val => val != ip.IpcId).ToArray();
                    }
                    else
                    {
                        //Clear deleted row
                        _context.IpcProtectionDocs.Remove(ip);
                    }
                });
                //Add new rows
                var newIpcs = ipcIds.Select(id => new IPCProtectionDoc {
                    ProtectionDocId = protectionDoc.Id, IpcId = id
                });

                foreach (var newIpc in newIpcs)
                {
                    protectionDoc.IpcProtectionDocs.Add(newIpc);
                }
            }
Ejemplo n.º 11
0
            private void ApplyIcfemIds(Domain.Entities.ProtectionDoc.ProtectionDoc protectionDoc, int[] icfemIds)
            {
                protectionDoc.Icfems
                .ToList()
                .ForEach(ir =>
                {
                    if (icfemIds.Contains(ir.DicIcfemId))
                    {
                        //Exclude existing row
                        icfemIds = icfemIds.Where(val => val != ir.DicIcfemId).ToArray();
                    }
                    else
                    {
                        //Clear deleted row
                        _context.DicIcfemProtectionDocRelations.Remove(ir);
                    }
                });

                //Add new rows
                var newIcfems = icfemIds.Select(id => new DicIcfemProtectionDocRelation()
                {
                    ProtectionDocId = protectionDoc.Id, DicIcfemId = id
                });

                foreach (var newIcfem in newIcfems)
                {
                    protectionDoc.Icfems.Add(newIcfem);
                }
            }
Ejemplo n.º 12
0
 private string GetStringForSorting(Domain.Entities.ProtectionDoc.ProtectionDoc protectionDoc)
 {
     if (CanHaveIpc(protectionDoc))
     {
         return(protectionDoc.IpcProtectionDocs.Where(i => i.IsMain).Select(i => i.Ipc.Code).FirstOrDefault() ??
                protectionDoc.RegNumber);
     }
     return(protectionDoc.RegNumber);
 }
Ejemplo n.º 13
0
        public async Task Handle(ProtectionDocWorkflow protectionDocWorkflow, Domain.Entities.ProtectionDoc.ProtectionDoc protectionDoc)
        {
            var routeStage = protectionDocWorkflow.CurrentStageId.HasValue
                ? Executor.GetQuery <GetDicRouteStageByIdQuery>().Process(q => q.Execute(protectionDocWorkflow.CurrentStageId.Value))
                : null;

            protectionDoc.CurrentWorkflow = protectionDocWorkflow;
            protectionDoc.StatusId        = routeStage?.ProtectionDocStatusId ?? protectionDoc.StatusId;

            await Executor.GetCommand <UpdateProtectionDocCommand>().Process(c => c.ExecuteAsync(protectionDoc.Id, protectionDoc));
        }
Ejemplo n.º 14
0
        private bool CanHaveIpc(Domain.Entities.ProtectionDoc.ProtectionDoc protectionDoc)
        {
            var typesWithIpcCodes = new[]
            {
                DicProtectionDocTypeCodes.ProtectionDocTypeInventionCode,
                DicProtectionDocTypeCodes.ProtectionDocTypeUsefulModelCode,
                DicProtectionDocTypeCodes.RequestTypeInventionCode,
                DicProtectionDocTypeCodes.RequestTypeUsefulModelCode
            };

            return(typesWithIpcCodes.Contains(protectionDoc?.Type?.Code));
        }
Ejemplo n.º 15
0
            private void AddRangeIcgsRequest(Domain.Entities.ProtectionDoc.ProtectionDoc protectionDoc, IcgsDto[] icgsDtos)
            {
                if (protectionDoc == null || icgsDtos == null || !icgsDtos.Any())
                {
                    return;
                }
                var newIcgs = ConvertToIcgs(icgsDtos, protectionDoc.Id).Where(x => x.Id == default(int));

                foreach (var icgs in newIcgs)
                {
                    protectionDoc.IcgsProtectionDocs.Add(icgs);
                }
            }
Ejemplo n.º 16
0
            private void AddRangeRequestConventionInfo(Domain.Entities.ProtectionDoc.ProtectionDoc protectionDoc,
                                                       ConventionInfoDto[] conventionInfoDtos)
            {
                if (protectionDoc == null || conventionInfoDtos == null || !conventionInfoDtos.Any())
                {
                    return;
                }

                var newRequestConventionInfoDtos =
                    _mapper.Map <IEnumerable <ProtectionDocConventionInfo> >(
                        conventionInfoDtos.Where(r => !r.Id.HasValue));

                foreach (var item in newRequestConventionInfoDtos)
                {
                    protectionDoc.ProtectionDocConventionInfos.Add(item);
                }
            }
Ejemplo n.º 17
0
            private void AddRequestEarlyRegDtos(Domain.Entities.ProtectionDoc.ProtectionDoc protectionDoc,
                                                RequestEarlyRegDto[] earlyRegDtos)
            {
                if (protectionDoc == null || earlyRegDtos == null || !earlyRegDtos.Any())
                {
                    return;
                }
                var earlyRegTypePriorityDataId = _context.DicEarlyRegTypes
                                                 .First(x => x.Code.Equals(EarlyRegTypePriorityDataCode)).Id; // TODO временно выбираем только Приоритетные данные
                var newrequestEarlyRegDtos = earlyRegDtos.Where(x => !x.Id.HasValue);
                var newRequestEarlyRegs    =
                    _mapper.Map <IEnumerable <ProtectionDocEarlyReg> >(newrequestEarlyRegDtos);

                foreach (var requestEarlyReg in newRequestEarlyRegs)
                {
                    requestEarlyReg.ProtectionDocId = protectionDoc.Id;
                    requestEarlyReg.EarlyRegTypeId  = earlyRegTypePriorityDataId;
                    protectionDoc.EarlyRegs.Add(requestEarlyReg);
                }
            }
Ejemplo n.º 18
0
 private void DeleteRangeIcgsRequest(Domain.Entities.ProtectionDoc.ProtectionDoc protectionDoc, IcgsDto[] icgsDtos)
 {
     if (protectionDoc?.IcgsProtectionDocs == null || !protectionDoc.IcgsProtectionDocs.Any())
     {
         return;
     }
     if (!icgsDtos.Any())
     {
         _context.ICGSProtectionDocs.RemoveRange(protectionDoc.IcgsProtectionDocs);
     }
     else
     {
         protectionDoc.IcgsProtectionDocs
         .ToList()
         .ForEach(ir =>
         {
             if (!icgsDtos.Select(x => x.Id).Contains(ir.Id))
             {
                 _context.ICGSProtectionDocs.Remove(ir);
             }
         });
     }
 }
Ejemplo n.º 19
0
 private void ApplyIcgsRequest(Domain.Entities.ProtectionDoc.ProtectionDoc protectionDoc, IcgsDto[] icgsRequestDtos)
 {
     DeleteRangeIcgsRequest(protectionDoc, icgsRequestDtos);
     AddRangeIcgsRequest(protectionDoc, icgsRequestDtos);
     UpdateRangeIcgsRequest(protectionDoc, icgsRequestDtos);
 }
Ejemplo n.º 20
0
            private void ApplyRequestInfo(ProtectionDocDetailsDto protectionDocDetailsDto, Domain.Entities.ProtectionDoc.ProtectionDoc protectionDoc)
            {
                var protectionDocInfo = _mapper.Map <ProtectionDocDetailsDto, ProtectionDocInfo>(protectionDocDetailsDto);

                if (protectionDocInfo == null)
                {
                    return;
                }

                protectionDoc.ProtectionDocInfo = protectionDocInfo;
            }