protected override int ExecuteWorkImplementation()
        {
            var bibliographicFormat    = m_externalRepositoryRepository.Load <BibliographicFormat>(m_data.BibliographicFormat.Id);
            var externalRepositoryType = m_externalRepositoryRepository.Load <ExternalRepositoryType>(m_data.ExternalRepositoryType.Id);
            var user = m_externalRepositoryRepository.Load <User>(m_userId);

            var externalRepository = new ExternalRepository
            {
                Name                    = m_data.Name,
                Description             = m_data.Description,
                Url                     = m_data.Url,
                Configuration           = m_data.Configuration,
                UrlTemplate             = m_data.UrlTemplate,
                License                 = m_data.License,
                BibliographicFormat     = bibliographicFormat,
                ExternalRepositoryType  = externalRepositoryType,
                CreatedByUser           = user,
                FilteringExpressionSets = new List <FilteringExpressionSet>()
            };

            if (m_data.FilteringExpressionSets != null)
            {
                foreach (var filteringExpressionSet in m_data.FilteringExpressionSets)
                {
                    externalRepository.FilteringExpressionSets.Add(
                        m_externalRepositoryRepository.Load <FilteringExpressionSet>(filteringExpressionSet.Id));
                }
            }

            var resultId = (int)m_externalRepositoryRepository.Create(externalRepository);

            return(resultId);
        }
예제 #2
0
        public AdminController()
        {
            repo      = new LocalDbRepository();
            repo_data = new VisualDataRepository(ConfigurationManager.AppSettings["dbPath"]);
            repo_ext  = new ExternalRepository(ConfigurationManager.AppSettings["dbPath"]);

            //Thread.CurrentThread.CurrentCulture.
        }
예제 #3
0
 public ImportService(ExternalRepository externalRepository, GetCurrentOrganization getCurrentOrganization, SearchVendorsInOrganization searchVendorsInOrganization, SearchAccountsInOrganization searchAccountsInOrganization, Repository repository, IMapper mapper)
 {
     this.externalRepository           = externalRepository;
     this.getCurrentOrganization       = getCurrentOrganization;
     this.searchVendorsInOrganization  = searchVendorsInOrganization;
     this.searchAccountsInOrganization = searchAccountsInOrganization;
     this.repository = repository;
     this.mapper     = mapper;
 }
예제 #4
0
        public JsonResult GetAtcNodes(int?id)
        {
            var repository = new ExternalRepository();
            var list       = repository.GetAtcListByParent(id);
            var customers  = from o in list
                             select new { id = o.id, text = "[" + o.code + "]-" + o.name, children = o.sr_atc_codes1.Any() };

            return(Json(customers.ToArray(), JsonRequestBehavior.AllowGet));
        }
예제 #5
0
파일: DataGen.cs 프로젝트: radevon/unicom
        public void GenerateData(string Identity, DateTime start, double electric, double water, int countMax)
        {
            ExternalRepository repogen = new ExternalRepository(ConfigurationManager.AppSettings["dbPath"]);
            Random             rnd     = new Random(DateTime.Now.Second);

            for (int i = 0; i < countMax; i++)
            {
                repogen.InsertNewRow(start.AddSeconds(i * 5), Identity, electric + i, rnd.NextDouble(), rnd.NextDouble(), rnd.NextDouble(),
                                     rnd.NextDouble() * 10, rnd.NextDouble() * 10, rnd.NextDouble() * 10, 3, water + i, "", 4.45, 0);
            }
        }
예제 #6
0
        public ActionResult SelectDrugForm(string searchTerm, int pageSize, int pageNum)
        {
            var founder        = new ExternalRepository().SearchDrugForm(searchTerm);
            var pagedAttendees = AttendeesToSelect2Format(founder, founder.Count);

            return(new JsonpResult
            {
                Data = pagedAttendees,
                JsonRequestBehavior = JsonRequestBehavior.AllowGet
            });
        }
        public IList <FilteringExpression> GetFilteringExpressionsByExternalRepository(int externalRepositoryId)
        {
            FilteringExpressionSet setAlias        = null;
            ExternalRepository     repositoryAlias = null;

            return(GetSession().QueryOver <FilteringExpression>()
                   .JoinAlias(x => x.FilteringExpressionSet, () => setAlias)
                   .JoinAlias(() => setAlias.ExternalRepositories, () => repositoryAlias)
                   .Where(() => repositoryAlias.Id == externalRepositoryId)
                   .OrderBy(x => x.Id).Asc
                   .List());
        }
        public virtual TotalImportStatistics GetExternalRepositoryStatistics(int repositoryId)
        {
            ExternalRepository      externalRepository      = null;
            ImportedProjectMetadata importedProjectMetadata = null;
            TotalImportStatistics   totalImportStatistics   = null;

            var result = GetSession().QueryOver(() => externalRepository)
                         .JoinAlias(x => x.ImportedProjectMetadata, () => importedProjectMetadata, JoinType.LeftOuterJoin)
                         .Where(() => externalRepository.Id == repositoryId)
                         .SelectList(list => list
                                     .SelectCount(() => importedProjectMetadata.Id).WithAlias(() => totalImportStatistics.NewItems))
                         .TransformUsing(Transformers.AliasToBean <TotalImportStatistics>())
                         .SingleOrDefault <TotalImportStatistics>();

            return(result);
        }
        public virtual ActionResult GetReestrNames(int id, int?type)
        {
            var reestr = new ExternalRepository().GetReestrById(id);

            if (reestr == null)
            {
                return(Json(new
                {
                    isSuccess = false
                }));
            }
            string expirationDate = "";
            string ndNumber       = "";
            bool   isShowChange   = true;
            var    reesrtDrug     = new ExternalRepository().GEtRegisterDrugById(id);

            if (reesrtDrug != null)
            {
                ndNumber = reesrtDrug.nd_number;
            }
            if (reestr.expiration_date != null)
            {
                expirationDate = reestr.expiration_date.Value.ToShortDateString();
                if (type != null && type.Value == 2)
                {
                    var t     = reestr.expiration_date.Value - DateTime.Now;
                    var month = t.TotalDays;

                    if (month < 90)
                    {
                        isShowChange = false;
                    }
                }
            }
            return(Json(new
            {
                reg_date = reestr.reg_date.ToShortDateString(),
                expiration_date = expirationDate,
                nd_number = ndNumber,
                isShowChange,
                isSuccess = true,
                name = reestr.name,
                nameKz = reestr.name_kz
            }));
        }
예제 #10
0
        private ExternalRepository HydrateEntity(ExternalRepository externalRepository)
        {
            if (externalRepository == null)
            {
                return(null);
            }

            switch (externalRepository.Type)
            {
            case RepositoryType.Ftp: externalRepository.DatabaseSource = new FtpDatabaseProvider(_tableStorageProvider, externalRepository.Uri);
                break;

            default:
                throw new NotSupportedException("Unknown repository type");
            }

            return(externalRepository);
        }
예제 #11
0
        public virtual ActionResult GetDrugFormNames(int id)
        {
            var mnn = new ExternalRepository().GetDrugFormById(id);

            if (mnn == null)
            {
                return(Json(new
                {
                    isSuccess = false
                }));
            }

            return(Json(new
            {
                nameRu = mnn.full_name,
                nameKz = mnn.full_name_kz,
                isSuccess = true
            }));
        }
예제 #12
0
        public virtual ActionResult GetAtcNames(int id)
        {
            var atc = new ExternalRepository().GeAtcById(id);

            if (atc == null)
            {
                return(Json(new
                {
                    isSuccess = false
                }));
            }

            return(Json(new
            {
                nameRu = "[" + atc.code + "] - " + atc.name,
                nameKz = "[" + atc.code + "] - " + atc.name_kz,
                isSuccess = true
            }));
        }
예제 #13
0
        public virtual LastImportStatisticsResult GetLastUpdateExternalRepositoryStatistics(int repositoryId)
        {
            ExternalRepository     externalRepository     = null;
            ImportHistory          importHistory1         = null;
            ImportHistory          importHistory2         = null;
            ImportedRecordMetadata importedRecordMetadata = null;
            Snapshot snapshot = null;
            LastImportStatisticsResult lastImportStatisticsResult = null;

            var subQuery = QueryOver.Of(() => importHistory2).Where(x => x.ExternalRepository.Id == repositoryId)
                           .OrderBy(x => x.Date).Desc
                           .Select(x => x.Id)
                           .Take(1);

            var result = GetSession().QueryOver(() => importHistory1)
                         .JoinAlias(() => importHistory1.ExternalRepository, () => externalRepository)
                         .JoinAlias(() => importHistory1.ImportedRecordMetadata, () => importedRecordMetadata, JoinType.LeftOuterJoin)
                         .JoinAlias(() => importedRecordMetadata.Snapshot, () => snapshot, JoinType.LeftOuterJoin)
                         .WithSubquery
                         .WhereProperty(() => importHistory1.Id).Eq(subQuery)
                         .SelectList(list => list
                                     .SelectCount(() => importedRecordMetadata.Id)
                                     .WithAlias(() => lastImportStatisticsResult.TotalItems)
                                     .Select(
                                         Projections.Sum(Projections.Conditional(
                                                             Restrictions.Eq(
                                                                 Projections.Property(() => snapshot.VersionNumber), 1),
                                                             Projections.Constant(1, NHibernateUtil.Int32),
                                                             Projections.Constant(0, NHibernateUtil.Int32))))
                                     .WithAlias(() => lastImportStatisticsResult.NewItems)
                                     .Select(
                                         Projections.Sum(Projections.Conditional(
                                                             Restrictions.Gt(
                                                                 Projections.Property(() => snapshot.VersionNumber), 1),
                                                             Projections.Constant(1, NHibernateUtil.Int32),
                                                             Projections.Constant(0, NHibernateUtil.Int32)))
                                         .WithAlias(() => lastImportStatisticsResult.UpdatedItems)))
                         .TransformUsing(Transformers.AliasToBean <LastImportStatisticsResult>())
                         .SingleOrDefault <LastImportStatisticsResult>();

            return(result);
        }
예제 #14
0
        public virtual ActionResult GetSubstanceNames(int id)
        {
            var substance = new ExternalRepository().GetSubstanceById(id);

            if (substance == null)
            {
                return(Json(new
                {
                    isSuccess = false
                }));
            }
            return(Json(new
            {
                categoryName = GetCategoryName(substance),
                categoryPos = substance.category_pos,
                isAnimal = substance.animal_sign,
                subName = substance.name,
                isSuccess = true
            }));
        }
예제 #15
0
        public virtual ActionResult GetMnnNames(int id)
        {
            var mnn = new ExternalRepository().GetMnnById(id);

            if (mnn == null)
            {
                return(Json(new
                {
                    isSuccess = false
                }));
            }

            return(Json(new
            {
                mnnKz = mnn.name_kz,
                mnnRu = mnn.name_rus,
                mnnEng = mnn.name_lat,
                isSuccess = true
            }));
        }
예제 #16
0
        public void SubmitImport(
            ExternalRepository externalRepository,
            ExternalDatabase externalDatabase)
        {
            ValidateNoImportsInProgress(externalDatabase.Name);

            var jobId     = string.Format("import-{0}-{1}", externalDatabase.Name, Guid.NewGuid());
            var fragments = externalRepository.DatabaseSource.GetDatabaseFragments(externalDatabase.Name);
            var entity    = CreateDatabaseEntity(SystemDatabaseProvider.DefaultContainerName, jobId, externalDatabase.Name, fragments.Count);

            try
            {
                // Stage all the job scripts
                var resourceFiles = InputFileStager.StageImportScripts(_blobStorageProvider);

                // Submit the job and tasks to batch
                SubmitBatchJob(jobId, externalDatabase.Name, fragments, resourceFiles);
            }
            catch (Exception)
            {
                CleanupAfterFailure(jobId, entity);
                throw;
            }
        }
예제 #17
0
 public void AddRepository(ExternalRepository repository)
 {
     _tableStorageProvider.UpsertEntity(repository);
 }
예제 #18
0
        protected void FillViewBag(EXP_DrugDeclaration model)
        {
            var drugPrimaryRepo = new DrugPrimaryRepository();

            ViewData["ContractList"] =
                new SelectList(new ContractRepository(false).GetActiveContractListWithInfo(model.OwnerId), "Id",
                               "ContractInfo", model.ContractId);
            var repository = new ReadOnlyDictionaryRepository();

            ViewData["AccelerationTypeList"] = new SelectList(repository.GetAccelerationTypes(), "Id",
                                                              "NameRu", model.AccelerationTypeId);

            ViewData["TypeList"] = new SelectList(repository.GetDicTypes(), "Id",
                                                  "NameRu", model.TypeId);

            if (model.RegisterId > 0 && model.sr_register != null)
            {
                model.ReestrNumber  = model.sr_register.reg_number + "/" + model.sr_register.reg_number_kz;
                model.ReestrRegDate = model.sr_register.reg_date.ToShortDateString();
                if (model.sr_register.expiration_date != null)
                {
                    model.ReestrExpirationDate = model.sr_register.expiration_date.Value.ToShortDateString();
                }
                var reestrDrug = new ExternalRepository().GEtRegisterDrugById(model.RegisterId);
                if (reestrDrug != null)
                {
                    model.NumberNd = reestrDrug.nd_number;
                }
            }

            if (model.ExpDrugChangeTypes.Count == 0)
            {
                model.ExpDrugChangeTypes.Add(new EXP_DrugChangeType());
            }
            if (model.ExpDrugProtectionDocs.Count == 0)
            {
                model.ExpDrugProtectionDocs.Add(new EXP_DrugProtectionDoc());
            }
            if (model.ExpDrugOtherCountries.Count == 0)
            {
                model.ExpDrugOtherCountries.Add(new EXP_DrugOtherCountry());
            }
            if (model.ExpDrugExportTrades.Count == 0)
            {
                model.ExpDrugExportTrades.Add(new EXP_DrugExportTrade());
            }
            if (model.ExpDrugPatents.Count == 0)
            {
                model.ExpDrugPatents.Add(new EXP_DrugPatent());
            }
            if (model.ExpDrugTypes.Count == 0)
            {
                model.ExpDrugTypes.Add(new EXP_DrugType());
            }

            /*  if (model.ExpDrugWrappings.Count == 0)
             * {
             *    model.ExpDrugWrappings.Add(new EXP_DrugWrapping());
             * }*/

            if (model.ExpDrugOrganizationses.Count == 0)
            {
                model.ExpDrugOrganizationses.Add(new EXP_DrugOrganizations());
            }
            if (model.ExpDrugDosages.Count == 0)
            {
                model.ExpDrugDosages.Add(new EXP_DrugDosage());
            }

            /*if (model.ExpDrugPrices.Count == 0)
             * {
             *  model.ExpDrugPrices.Add(new EXP_DrugPrice());
             * }*/
            var externalRepository = new ExternalRepository();
            var countries          = externalRepository.GetCounties().ToArray();

            ViewData["Counties"] = new SelectList(countries, "Id", "name", 0);
            for (var i = 0; i < model.ExpDrugExportTrades.Count; i++)
            {
                ViewData["Counties" + i] = new SelectList(countries, "Id", "name",
                                                          model.ExpDrugExportTrades[i].CountryId);
            }

            var types     = repository.GetDrugType().ToArray();
            var typeKinds = repository.GetDrugTypeKinds().ToArray();

            ViewData["DrugTypes"]     = new SelectList(types, "Id", "NameRu", 0);
            ViewData["DrugTypeKinds"] = new SelectList(typeKinds, "Id", "NameRu", 0);
            for (var i = 0; i < model.ExpDrugTypes.Count; i++)
            {
                ViewData["DrugTypes" + i]     = new SelectList(types, "Id", "NameRu", model.ExpDrugTypes[i].DrugTypeId);
                ViewData["DrugTypeKinds" + i] = new SelectList(typeKinds, "Id", "NameRu",
                                                               model.ExpDrugTypes[i].DrugTypeKind);
            }

            model.AtcCodeses = externalRepository.GetAtcList();

            var methods = externalRepository.GetUseMethods();

            model.MethodUseList = new MultiSelectList(methods, "id", "name", model.MethodUseIds);

            /*  ViewData["SaleTypeList"] = new SelectList(repository.GetSaleType(), "Id",
             *    "NameRu", model.SaleTypeId);*/

            var measures = externalRepository.GetMeasures();

            ViewData["MeasureList"] = new SelectList(measures, "Id",
                                                     "name", null);
            var wrappingTypes = repository.GetWrappingTypes().ToArray();
            var boxes         = externalRepository.GetBoxes().ToArray();

            ViewData["WrappingTypes"]     = new SelectList(wrappingTypes, "Id", "NameRu", 0);
            ViewData["Boxes"]             = new SelectList(boxes, "id", "name", 0);
            ViewData["MeasureShortList"]  = new SelectList(measures, "id", "short_name", 0);
            ViewData["SizeMeasureList"]   = new SelectList(measures, "id", "short_name", 0);
            ViewData["VolumeMeasureList"] = new SelectList(measures, "id", "short_name", 0);

            var booleans = repository.GetBooleanList();

            ViewData["Booleans"] = new SelectList(booleans, "IsSign", "NameRu", false);

            var origins        = repository.GetOrigins().ToArray();
            var plantKinds     = repository.GetPlantKinds().ToArray();
            var normDocs       = repository.GetExpDicNormDocFarms().ToArray();
            var substanceTypes = externalRepository.GetSubstanceTypes().ToArray();

            ViewData["SubstanceTypes"]       = new SelectList(substanceTypes, "Id", "name", null);
            ViewData["Origins"]              = new SelectList(origins, "Id", "NameRu", null);
            ViewData["NormDocs"]             = new SelectList(normDocs, "Id", "NameRu", null);
            ViewData["PlantKinds"]           = new SelectList(plantKinds, "Id", "NameRu", null);
            ViewData["IsControlList"]        = new SelectList(booleans, "IsSign", "NameRu", null);
            ViewData["IsPoisonList"]         = new SelectList(booleans, "IsSign", "NameRu", null);
            ViewData["SubstanceCounties"]    = new SelectList(countries, "Id", "name", 0);
            ViewData["SubstanceMeasureList"] = new SelectList(measures, "id", "short_name", 0);
            var sales = repository.GetSaleType().ToList();

            ViewData["SaleTypeList"] = new SelectList(sales, "Id", "NameRu", null);
            ViewData["BestBeforeMeasureTypeList"] = new SelectList(measures, "id", "short_name",
                                                                   null);
            ViewData["AppPeriodMixMeasureList"] = new SelectList(measures, "id", "short_name",
                                                                 null);
            ViewData["AppPeriodOpenMeasureList"] = new SelectList(measures, "id", "short_name",
                                                                  null);



            var drugDeclarationRepository = new DrugDeclarationRepository();

            for (var i = 0; i < model.ExpDrugDosages.Count; i++)
            {
                var dosage = model.ExpDrugDosages[i];
                if (dosage.ExpDrugWrappings == null || dosage.ExpDrugWrappings.Count == 0)
                {
                    dosage.ExpDrugWrappings = new List <EXP_DrugWrapping> {
                        new EXP_DrugWrapping()
                    };
                }
                if (dosage.ExpDrugSubstances == null || dosage.ExpDrugSubstances.Count == 0)
                {
                    dosage.ExpDrugSubstances = new List <EXP_DrugSubstance> {
                        new EXP_DrugSubstance()
                        {
                            ExpDrugSubstanceManufactures = new List <EXP_DrugSubstanceManufacture>()
                            {
                                new EXP_DrugSubstanceManufacture()
                            }
                        }
                    };
                }
                if (dosage.ExpDrugPrices == null)
                {
                    dosage.ExpDrugPrices = new List <EXP_DrugPrice>();
                }

                ViewData["MeasureList" + dosage.Id] = new SelectList(measures, "Id", "name",
                                                                     model.ExpDrugDosages[i].DosageMeasureTypeId);
                ViewData["SaleTypeList" + dosage.Id] = new SelectList(sales, "Id", "NameRu", model.ExpDrugDosages[i].SaleTypeId);
                ViewData["BestBeforeMeasureTypeList" + dosage.Id] = new SelectList(measures, "id", "short_name",
                                                                                   model.ExpDrugDosages[i].BestBeforeMeasureTypeDicId);
                ViewData["AppPeriodMixMeasureList" + dosage.Id] = new SelectList(measures, "id", "short_name",
                                                                                 model.ExpDrugDosages[i].AppPeriodMixMeasureDicId);
                ViewData["AppPeriodOpenMeasureList" + dosage.Id] = new SelectList(measures, "id", "short_name",
                                                                                  model.ExpDrugDosages[i].AppPeriodOpenMeasureDicId);
                for (var j = 0; j < dosage.ExpDrugWrappings.Count; j++)
                {
                    var wrap = dosage.ExpDrugWrappings[j];
                    ViewData["WrappingTypes" + wrap.Id] = new SelectList(wrappingTypes, "Id", "NameRu",
                                                                         wrap.WrappingTypeId);
                    ViewData["Boxes" + wrap.Id]           = new SelectList(boxes, "Id", "name", wrap.WrappingKindId);
                    ViewData["SizeMeasureList" + wrap.Id] = new SelectList(measures, "Id", "short_name",
                                                                           wrap.SizeMeasureId);
                    ViewData["VolumeMeasureList" + wrap.Id] = new SelectList(measures, "Id", "short_name",
                                                                             wrap.VolumeMeasureId);
                }

                for (var j = 0; j < dosage.ExpDrugPrices.Count; j++)
                {
                    var price = dosage.ExpDrugPrices[j];
                    model.ExpDrugDosages[i].ExpDrugPrices[j].PrimaryText      = drugDeclarationRepository.GetNameByWrappingNames(price.PrimaryValue);
                    model.ExpDrugDosages[i].ExpDrugPrices[j].SecondaryText    = drugDeclarationRepository.GetNameByWrappingNames(price.SecondaryValue);
                    model.ExpDrugDosages[i].ExpDrugPrices[j].IntermediateText = drugDeclarationRepository.GetNameByWrappingNames(price.IntermediateValue);
                }

                for (var j = 0; j < dosage.ExpDrugSubstances.Count; j++)
                {
                    var id = dosage.ExpDrugSubstances[j].Id.ToString();
                    dosage.ExpDrugSubstances[j].CategoryName = GetCategoryName(dosage.ExpDrugSubstances[j].sr_substances);
                    dosage.ExpDrugSubstances[j].CategoryPos  = dosage.ExpDrugSubstances[j].sr_substances?.category_pos;
                    ViewData["SubstanceTypes" + id]          = new SelectList(substanceTypes, "Id", "name",
                                                                              dosage.ExpDrugSubstances[j].SubstanceTypeId);
                    ViewData["Origins" + id]    = new SelectList(origins, "Id", "NameRu", dosage.ExpDrugSubstances[j].OriginId);
                    ViewData["NormDocs" + id]   = new SelectList(normDocs, "Id", "NameRu", dosage.ExpDrugSubstances[j].NormDocFarmId);
                    ViewData["PlantKinds" + id] = new SelectList(plantKinds, "Id", "NameRu",
                                                                 dosage.ExpDrugSubstances[j].PlantKindId);
                    ViewData["SubstanceMeasureList" + id] = new SelectList(measures, "Id", "short_name",
                                                                           dosage.ExpDrugSubstances[j].MeasureId);

                    /*          ViewData["SubstanceCounties" + id] = new SelectList(countries, "Id", "name",
                     *            dosage.ExpDrugSubstances[j].CountryId);*/
                    ViewData["IsControlList" + id] = new SelectList(booleans, "IsSign", "NameRu",
                                                                    dosage.ExpDrugSubstances[j].IsControl);
                    ViewData["IsPoisonList" + id] = new SelectList(booleans, "IsSign", "NameRu",
                                                                   dosage.ExpDrugSubstances[j].IsPoison);

                    /*  ViewData["SubstanceCounties" + i] = new SelectList(countries, "Id", "name",
                     *    dosage.ExpDrugSubstances[j].CountryId);*/
                    if (dosage.ExpDrugSubstances[j].ExpDrugSubstanceManufactures != null)
                    {
                        for (var k = 0; k < dosage.ExpDrugSubstances[j].ExpDrugSubstanceManufactures.Count; k++)
                        {
                            ViewData[
                                "SubstanceCounties" + dosage.ExpDrugSubstances[j].ExpDrugSubstanceManufactures[k].Id
                            ] =
                                new SelectList(countries, "Id", "name",
                                               dosage.ExpDrugSubstances[j].ExpDrugSubstanceManufactures[k].CountryId);
                        }
                    }
                    else
                    {
                        dosage.ExpDrugSubstances[j].ExpDrugSubstanceManufactures =
                            new List <EXP_DrugSubstanceManufacture> {
                            new EXP_DrugSubstanceManufacture()
                        };
                    }
                }
            }



            ViewData["IsGrlsList"] = new SelectList(booleans, "IsSign", "NameRu", model.IsGrls);
            ViewData["IsGmpList"]  = new SelectList(booleans, "IsSign", "NameRu", model.IsGmp);

            var manufactures = repository.GetManufactureTypeList();

            ViewData["ManufactureTypeList"] = new SelectList(manufactures, "Id", "NameRu", model.ManufactureTypeId);

            /*    ViewData["BestBeforeMeasureTypeList"] = new SelectList(measures, "id", "short_name",
             *      model.BestBeforeMeasureTypeDicId);
             *  ViewData["AppPeriodMixMeasureList"] = new SelectList(measures, "id", "short_name",
             *      model.AppPeriodMixMeasureDicId);
             *  ViewData["AppPeriodOpenMeasureList"] = new SelectList(measures, "id", "short_name",
             *      model.AppPeriodOpenMeasureDicId);
             */
            for (var i = 0; i < model.ExpDrugOtherCountries.Count; i++)
            {
                ViewData["OtherCounties" + i] = new SelectList(countries, "Id", "name",
                                                               model.ExpDrugOtherCountries[i].CountryId);
            }

            var orgManufactureTypes = repository.GetDictionaries(CodeConstManager.DIC_ORG_MANUFACTURE_TYPE);
            var countyDics          = repository.GetDictionaries(CodeConstManager.DIC_COUNTRY_TYPE);
            var opfTypeDics         = repository.GetDictionaries(CodeConstManager.DIC_OPF_TYPE);

            ViewData["OrgManufactureTypes"] = new SelectList(orgManufactureTypes, "Id", "Name", null);
            ViewData["CountryDics"]         = new SelectList(countyDics, "Id", "Name", null);
            ViewData["OpfTypeDics"]         = new SelectList(opfTypeDics, "Id", "Name", null);

            for (var i = 0; i < model.ExpDrugOrganizationses.Count; i++)
            {
                var id = model.ExpDrugOrganizationses[i].Id.ToString();
                ViewData["OrgManufactureTypes" + id] = new SelectList(orgManufactureTypes, "Id", "name",
                                                                      model.ExpDrugOrganizationses[i].OrgManufactureTypeDicId);
                ViewData["CountryDics" + id] = new SelectList(countyDics, "Id", "name",
                                                              model.ExpDrugOrganizationses[i].CountryDicId);
                ViewData["OpfTypeDics" + id] = new SelectList(opfTypeDics, "Id", "name",
                                                              model.ExpDrugOrganizationses[i].OpfTypeDicId);
                var manufacture = repository.GetDictionaryById(CodeConstManager.DIC_ORG_MANUFACTURE_TYPE,
                                                               model.ExpDrugOrganizationses[i].OrgManufactureTypeDicId);
                if (manufacture != null)
                {
                    model.ExpDrugOrganizationses[i].ManufactureName = manufacture.Name;
                }
            }
            var changeTypes = repository.GetDicChangeTypes().ToArray();

            ViewData["ChangeTypes"] = new SelectList(changeTypes, "Id", "Code", 0);
            for (var i = 0; i < model.ExpDrugChangeTypes.Count; i++)
            {
                ViewData["ChangeTypes" + i] = new SelectList(changeTypes, "Id", "Code",
                                                             model.ExpDrugChangeTypes[i].ChangeTypeId);
            }

            var markList = drugPrimaryRepo.GetPrimaryMarkList(model.Id, null);

            var remarkTypes = repository.GetRemarkTypes().ToArray();

            ViewData["RemarkTypes" + model.Id] = new SelectList(remarkTypes, "Id", "NameRu",
                                                                null);
            model.ExpExpertiseStageRemarks = new List <EXP_ExpertiseStageRemark>();
            foreach (var expDrugPrimaryRemark in markList)
            {
                model.ExpExpertiseStageRemarks.Add(expDrugPrimaryRemark);
            }

            if (model.ExpExpertiseStageRemarks.Count == 0)
            {
                model.ExpExpertiseStageRemarks.Add(new EXP_ExpertiseStageRemark());
            }
            else
            {
                model.IsShowRemark = true;
            }

            foreach (var expDrugPrimaryRemark in model.ExpExpertiseStageRemarks)
            {
                ViewData["RemarkTypes" + model.Id + "_" + expDrugPrimaryRemark.Id] = new SelectList(remarkTypes,
                                                                                                    "Id", "NameRu",
                                                                                                    expDrugPrimaryRemark.RemarkTypeId);
            }
            ViewBag.PaymentOverdue = model.EXP_DirectionToPays.Any(e => e.Type == 1 &&
                                                                   e.Status.Code == Dictionary.ExpDirectionToPayStatus.PaymentExpired);
            model.Letters = new List <EXP_DrugCorespondence>(drugPrimaryRepo.GetDrugCorespondences(model.Id, true));
        }
예제 #19
0
        protected void FillDeclarationControl(EXP_DrugDeclaration model)
        {
            model.EditorId            = UserHelper.GetCurrentEmployee().Id.ToString();
            model.ExpDrugExportTrades = new List <EXP_DrugExportTrade>();
            var exportTrades = model.EXP_DrugExportTrade.OrderBy(e => e.Id);

            foreach (var record in exportTrades)
            {
                model.ExpDrugExportTrades.Add(record);
            }

            model.ExpDrugPatents = new List <EXP_DrugPatent>();
            var expPatent = model.EXP_DrugPatent.OrderBy(e => e.Id);

            foreach (var record in expPatent)
            {
                model.ExpDrugPatents.Add(record);
            }

            model.ExpDrugTypes = new List <EXP_DrugType>();
            var expDrugType = model.EXP_DrugType.OrderBy(e => e.Id);

            foreach (var record in expDrugType)
            {
                model.ExpDrugTypes.Add(record);
            }

            /*     model.ExpDrugWrappings = new List<EXP_DrugWrapping>();
             *   var expDrugWrapping = model.EXP_DrugWrapping.OrderBy(e => e.Id);
             *   foreach (var record in expDrugWrapping)
             *   {
             *       model.ExpDrugWrappings.Add(record);
             *   }*/

            model.ExpDrugOtherCountries = new List <EXP_DrugOtherCountry>();
            var expDrugOtherCountries = model.EXP_DrugOtherCountry.OrderBy(e => e.Id);

            foreach (var record in expDrugOtherCountries)
            {
                model.ExpDrugOtherCountries.Add(record);
            }
            model.ExpDrugProtectionDocs = new List <EXP_DrugProtectionDoc>();
            var expDrugProtectionDocs = model.EXP_DrugProtectionDoc.OrderBy(e => e.Id);

            foreach (var record in expDrugProtectionDocs)
            {
                model.ExpDrugProtectionDocs.Add(record);
            }
            model.ExpDrugOrganizationses = new List <EXP_DrugOrganizations>();
            var expDrugOrganizationses = model.EXP_DrugOrganizations.OrderBy(e => e.Id);

            foreach (var record in expDrugOrganizationses)
            {
                model.ExpDrugOrganizationses.Add(record);
            }
            model.ExpDrugDosages = new List <EXP_DrugDosage>();
            var expDrugDosages = model.EXP_DrugDosage.OrderBy(e => e.Id);

            model.ConclusionSafetyReports = new List <ConclusionSafetyReport>();
            foreach (var record in expDrugDosages)
            {
                if (record.RegisterId > 0 && record.sr_register != null)
                {
                    record.ReestrNumber  = record.sr_register.reg_number + "/" + record.sr_register.reg_number_kz;
                    record.ReestrRegDate = record.sr_register.reg_date.ToShortDateString();
                    if (record.sr_register.expiration_date != null)
                    {
                        record.ReestrExpirationDate = record.sr_register.expiration_date.Value.ToShortDateString();
                    }
                    var reestrDrug = new ExternalRepository().GEtRegisterDrugById(record.RegisterId);
                    if (reestrDrug != null)
                    {
                        record.NumberNd = reestrDrug.nd_number;
                    }
                }
                record.ExpDrugWrappings = new List <EXP_DrugWrapping>();
                foreach (var expDrugWrapping in record.EXP_DrugWrapping)
                {
                    record.ExpDrugWrappings.Add(expDrugWrapping);
                }
                record.ExpDrugPrices = new List <EXP_DrugPrice>();
                foreach (var drugPrice in record.EXP_DrugPrice)
                {
                    record.ExpDrugPrices.Add(drugPrice);
                }
                model.ExpDrugDosages.Add(record);

                record.ExpDrugSubstances = new List <EXP_DrugSubstance>();

                for (var d = 0; d < record.EXP_DrugSubstance.Count; d++)
                {
                    record.ExpDrugSubstances.Add(record.EXP_DrugSubstance.ToList()[d]);
                    record.EXP_DrugSubstance.ToList()[d].ExpDrugSubstanceManufactures = new List <EXP_DrugSubstanceManufacture>();
                    foreach (var expDrugSubstanceManufacture in record.EXP_DrugSubstance.ToList()[d].EXP_DrugSubstanceManufacture)
                    {
                        record.EXP_DrugSubstance.ToList()[d].ExpDrugSubstanceManufactures.Add(expDrugSubstanceManufacture);
                    }
                }

                /*      foreach (var substance in record.EXP_DrugSubstance)
                 *    {
                 *        record.ExpDrugSubstances.Add(substance);
                 *
                 *    }*/

                if (model.StatusId > 6)
                {
                    model.ConclusionSafetyReports.Add(new SafetyreportRepository().ConclusionSafetyReportsFromDosage(record.Id, false));
                    model.ConclusionSafetyReports.Add(new SafetyreportRepository().ConclusionSafetyReportsFromDosage(record.Id, true));
                }
            }
            if (model.StatusId > 6)
            {
                var item = new SafetyreportRepository().ConclusionSafetyReportsFromFiles(model.Id, UserHelper.GetCurrentEmployee());
                foreach (var conclusionSafetyReport in item)
                {
                    model.ConclusionSafetyReports.Add(conclusionSafetyReport);
                }
            }
            if (model.ConclusionSafetyReports.Count > 0)
            {
                model.IsShowConclision = true;
            }
            model.ExpDrugChangeTypes = new List <EXP_DrugChangeType>();
            var changeTypes = model.EXP_DrugChangeType.OrderBy(e => e.Id);

            foreach (var record in changeTypes)
            {
                model.ExpDrugChangeTypes.Add(record);
            }

            /*  model.ExpDrugPrices = new List<EXP_DrugPrice>();
             * var expDrugPrices = model.EXP_DrugPrice.OrderBy(e => e.Id);
             * foreach (var record in expDrugPrices)
             * {
             *    model.ExpDrugPrices.Add(record);
             * }*/
            model.MethodUseIds =
                model.EXP_DrugUseMethod.Select(e => e.UseMethodsId.ToString(CultureInfo.InvariantCulture)).ToList();

            if (model.TypeId > 1)
            {
                if (model.TypeId == 3)
                {
                    model.IsShowChange = true;
                }
                else
                {
                    if (model.sr_register != null && model.sr_register.expiration_date != null)
                    {
                        if (model.TypeId != 2)
                        {
                            var t     = model.sr_register.expiration_date.Value - model.CreatedDate;
                            var month = t.TotalDays;

                            if (month > 90)
                            {
                                model.IsShowChange = true;
                            }
                        }
                    }
                }
            }

            var primaryEntity = new PrimaryEntity
            {
                EXP_DrugDeclaration = model,
                DrugDeclarationId   = model.ObjectId,
                Editor = UserHelper.GetCurrentEmployee(),
                ExpExpertiseStageRemarks = new List <EXP_ExpertiseStageRemark>(),
            };

            FillViewBag(model);
        }
        protected virtual void FillDosageControl(EXP_ExpertiseStageDosage model)
        {
            var externalRepository = new ExternalRepository();
            var repository         = new ReadOnlyDictionaryRepository();
            var measures           = externalRepository.GetMeasures();

            var wrappingTypes = repository.GetWrappingTypes().ToArray();
            var boxes         = externalRepository.GetBoxes().ToArray();
            //            var remarkTypes = repository.GetRemarkTypes().ToArray();
            var sales = repository.GetSaleType().ToList();
            var drugDeclarationRepository = new DrugDeclarationRepository();

            model.EXP_DrugDosage.ExpDrugWrappings  = new List <EXP_DrugWrapping>();
            model.EXP_DrugDosage.ExpDrugPrices     = new List <EXP_DrugPrice>();
            model.EXP_DrugDosage.ExpDrugSubstances = new List <EXP_DrugSubstance>();
            //            model.EXP_DrugDosage.ExpDrugAppDosageRemarks = new List<EXP_DrugAppDosageRemark>();
            //            model.EXP_DrugDosage.ExpDrugAppDosageResults = new List<EXP_DrugAppDosageResult>();

            /*  foreach (var expDrugAppDosageRemark in model.EXP_DrugDosage.EXP_DrugAppDosageRemark)
             * {
             *  model.EXP_DrugDosage.ExpDrugAppDosageRemarks.Add(expDrugAppDosageRemark);
             * }
             * if (model.EXP_DrugDosage.ExpDrugAppDosageRemarks.Count == 0)
             * {
             *  model.EXP_DrugDosage.ExpDrugAppDosageRemarks.Add(new EXP_DrugAppDosageRemark());
             * }
             *
             * foreach (var expDrugAppDosageRemark in model.EXP_DrugDosage.EXP_DrugAppDosageResult)
             * {
             *  model.EXP_DrugDosage.ExpDrugAppDosageResults.Add(expDrugAppDosageRemark);
             * }
             * if (model.EXP_DrugDosage.ExpDrugAppDosageResults.Count == 0)
             * {
             *  model.EXP_DrugDosage.ExpDrugAppDosageResults.Add(new EXP_DrugAppDosageResult());
             * }
             */
            /*  ViewData["RemarkTypes" + model.EXP_DrugDosage.DrugDeclarationId] = new SelectList(remarkTypes, "Id", "NameRu",
             *   null);
             * foreach (var wrap in model.EXP_DrugDosage.ExpDrugAppDosageResults)
             * {
             *  ViewData["ResultTypes" + model.EXP_DrugDosage.DrugDeclarationId + "_" + wrap.Id] = new SelectList(remarkTypes, "Id", "NameRu",
             *      wrap.RemarkTypeId);
             * }
             * foreach (var wrap in model.EXP_DrugDosage.ExpDrugAppDosageRemarks)
             * {
             *  ViewData["RemarkTypes" + model.EXP_DrugDosage.DrugDeclarationId + "_" + wrap.Id] = new SelectList(remarkTypes, "Id", "NameRu",
             *      wrap.RemarkTypeId);
             * }*/

            foreach (var expDrugWrapping in model.EXP_DrugDosage.EXP_DrugWrapping)
            {
                model.EXP_DrugDosage.ExpDrugWrappings.Add(expDrugWrapping);
            }

            foreach (var expDrugWrapping in model.EXP_DrugDosage.EXP_DrugPrice)
            {
                model.EXP_DrugDosage.ExpDrugPrices.Add(expDrugWrapping);
            }
            for (var d = 0; d < model.EXP_DrugDosage.EXP_DrugSubstance.Count; d++)
            {
                model.EXP_DrugDosage.ExpDrugSubstances.Add(model.EXP_DrugDosage.EXP_DrugSubstance.ToList()[d]);
                if (model.EXP_DrugDosage.EXP_DrugSubstance.ToList()[d].ExpDrugSubstanceManufactures == null)
                {
                    model.EXP_DrugDosage.EXP_DrugSubstance.ToList()[d].ExpDrugSubstanceManufactures = new List <EXP_DrugSubstanceManufacture>();
                }

                foreach (var expDrugSubstanceManufacture in model.EXP_DrugDosage.EXP_DrugSubstance.ToList()[d].EXP_DrugSubstanceManufacture)
                {
                    model.EXP_DrugDosage.EXP_DrugSubstance.ToList()[d].ExpDrugSubstanceManufactures.Add(expDrugSubstanceManufacture);
                }
            }

            /* foreach (var expDrugWrapping in model.EXP_DrugDosage.EXP_DrugSubstance)
             * {
             *   model.EXP_DrugDosage.ExpDrugSubstances.Add(expDrugWrapping);
             *   foreach (var expDrugSubstanceManufacture in expDrugWrapping.EXP_DrugSubstanceManufacture)
             *   {
             *       model.EXP_DrugDosage.ExpDrugSubstances.Add(expDrugWrapping);
             *   }
             * }*/
            if (model.EXP_DrugDosage.ExpDrugWrappings == null || model.EXP_DrugDosage.ExpDrugWrappings.Count == 0)
            {
                model.EXP_DrugDosage.ExpDrugWrappings = new List <EXP_DrugWrapping>();
            }
            if (model.EXP_DrugDosage.ExpDrugSubstances == null || model.EXP_DrugDosage.ExpDrugSubstances.Count == 0)
            {
                model.EXP_DrugDosage.ExpDrugSubstances = new List <EXP_DrugSubstance> ();
            }
            if (model.EXP_DrugDosage.ExpDrugPrices == null)
            {
                model.EXP_DrugDosage.ExpDrugPrices = new List <EXP_DrugPrice>();
            }
            ViewData["MeasureList" + model.EXP_DrugDosage.Id] = new SelectList(measures, "Id", "name",
                                                                               model.EXP_DrugDosage.DosageMeasureTypeId);
            ViewData["SaleTypeList" + model.EXP_DrugDosage.Id] = new SelectList(sales, "Id", "NameRu", model.EXP_DrugDosage.SaleTypeId);
            ViewData["BestBeforeMeasureTypeList" + model.EXP_DrugDosage.Id] = new SelectList(measures, "id", "short_name",
                                                                                             model.EXP_DrugDosage.BestBeforeMeasureTypeDicId);
            ViewData["AppPeriodMixMeasureList" + model.EXP_DrugDosage.Id] = new SelectList(measures, "id", "short_name",
                                                                                           model.EXP_DrugDosage.AppPeriodMixMeasureDicId);
            ViewData["AppPeriodOpenMeasureList" + model.EXP_DrugDosage.Id] = new SelectList(measures, "id", "short_name",
                                                                                            model.EXP_DrugDosage.AppPeriodOpenMeasureDicId);
            for (var j = 0; j < model.EXP_DrugDosage.ExpDrugWrappings.Count; j++)
            {
                var wrap = model.EXP_DrugDosage.ExpDrugWrappings[j];
                ViewData["WrappingTypes" + wrap.Id] = new SelectList(wrappingTypes, "Id", "NameRu",
                                                                     wrap.WrappingTypeId);
                ViewData["Boxes" + wrap.Id]           = new SelectList(boxes, "Id", "name", wrap.WrappingKindId);
                ViewData["SizeMeasureList" + wrap.Id] = new SelectList(measures, "Id", "short_name",
                                                                       wrap.SizeMeasureId);
                ViewData["VolumeMeasureList" + wrap.Id] = new SelectList(measures, "Id", "short_name",
                                                                         wrap.VolumeMeasureId);
            }
            var origins        = repository.GetOrigins().ToArray();
            var plantKinds     = repository.GetPlantKinds().ToArray();
            var substanceTypes = externalRepository.GetSubstanceTypes().ToArray();
            var countries      = externalRepository.GetCounties().ToArray();
            var booleans       = repository.GetBooleanList();

            for (var j = 0; j < model.EXP_DrugDosage.ExpDrugSubstances.Count; j++)
            {
                var ids = model.EXP_DrugDosage.ExpDrugSubstances[j].Id.ToString();
                model.EXP_DrugDosage.ExpDrugSubstances[j].CategoryName =
                    GetCategoryName(model.EXP_DrugDosage.ExpDrugSubstances[j].sr_substances);
                model.EXP_DrugDosage.ExpDrugSubstances[j].CategoryPos =
                    model.EXP_DrugDosage.ExpDrugSubstances[j].sr_substances?.category_pos;
                ViewData["SubstanceTypes" + ids] = new SelectList(substanceTypes, "Id", "name",
                                                                  model.EXP_DrugDosage.ExpDrugSubstances[j].SubstanceTypeId);
                ViewData["Origins" + ids] = new SelectList(origins, "Id", "NameRu",
                                                           model.EXP_DrugDosage.ExpDrugSubstances[j].OriginId);
                ViewData["PlantKinds" + ids] = new SelectList(plantKinds, "Id", "NameRu",
                                                              model.EXP_DrugDosage.ExpDrugSubstances[j].PlantKindId);
                ViewData["SubstanceMeasureList" + ids] = new SelectList(measures, "Id", "short_name",
                                                                        model.EXP_DrugDosage.ExpDrugSubstances[j].MeasureId);
                ViewData["SubstanceCounties" + ids] = new SelectList(countries, "Id", "name",
                                                                     model.EXP_DrugDosage.ExpDrugSubstances[j].CountryId);
                ViewData["IsControlList" + ids] = new SelectList(booleans, "IsSign", "NameRu",
                                                                 model.EXP_DrugDosage.ExpDrugSubstances[j].IsControl);
                ViewData["NormDocs" + ids] = new SelectList(repository.GetExpDicNormDocFarms().ToArray(), "Id", "NameRu",
                                                            model.EXP_DrugDosage.ExpDrugSubstances[j].NormDocFarmId);
                ViewData["IsPoisonList" + ids] = new SelectList(booleans, "IsSign", "NameRu",
                                                                model.EXP_DrugDosage.ExpDrugSubstances[j].IsPoison);

                /*      ViewData["SubstanceCounties" + ids] = new SelectList(countries, "Id", "name",
                 *        model.EXP_DrugDosage.ExpDrugSubstances[j].CountryId);*/
                if (model.EXP_DrugDosage.ExpDrugSubstances[j].ExpDrugSubstanceManufactures != null)
                {
                    for (var k = 0;
                         k < model.EXP_DrugDosage.ExpDrugSubstances[j].ExpDrugSubstanceManufactures.Count;
                         k++)
                    {
                        ViewData["SubstanceCounties" + model.EXP_DrugDosage.ExpDrugSubstances[j].ExpDrugSubstanceManufactures[k].Id.ToString()] = new SelectList(countries, "Id", "name",
                                                                                                                                                                 model.EXP_DrugDosage.ExpDrugSubstances[j].ExpDrugSubstanceManufactures[k].CountryId);
                    }
                }
            }

            for (var j = 0; j < model.EXP_DrugDosage.ExpDrugPrices.Count; j++)
            {
                var price = model.EXP_DrugDosage.ExpDrugPrices[j];
                model.EXP_DrugDosage.ExpDrugPrices[j].PrimaryText =
                    drugDeclarationRepository.GetNameByWrappingNames(price.PrimaryValue);
                model.EXP_DrugDosage.ExpDrugPrices[j].SecondaryText =
                    drugDeclarationRepository.GetNameByWrappingNames(price.SecondaryValue);
                model.EXP_DrugDosage.ExpDrugPrices[j].IntermediateText =
                    drugDeclarationRepository.GetNameByWrappingNames(price.IntermediateValue);
            }
        }