/// <summary> /// Populate Data /// </summary> public void Populate() { Guid langaugeID = TSMContext.CurrentSiteLanguageID; this.Data = new List <KeyValue>(); var cacheProvider = CacheFactory.Get(); if (!cacheProvider.Exists(CacheKeys.CACHE_TSM_INT_SECTORS_DROPDOWN)) { var internationalSectors = SectorService.GetTSMSectors(langaugeID, Entity.NomenclatureType.International); var parentSectors = internationalSectors.Where(ts => ts.ParentID == null).OrderBy(ts => ts.Type).ThenBy(ts => ts.Name).ToList(); //First Level Loop foreach (var parentSector in parentSectors) { KeyValue keyValue = new KeyValue { Key = parentSector.ID.ToString(), Value = parentSector.Name, ClassName = "first-level", Level = "1" }; this.Data.Add(keyValue); var sectors = internationalSectors.Where(ts => ts.ParentID == parentSector.ID).OrderBy(ts => ts.Name).ToList(); //Second Level Loop foreach (var sector in sectors) { KeyValue keyValueSector = new KeyValue { Key = sector.ID.ToString(), Value = sector.Name, ClassName = "second-level", Level = "2" }; this.Data.Add(keyValueSector); var childSectors = internationalSectors.Where(ts => ts.ParentID == sector.ID).OrderBy(ts => ts.Name).ToList(); if (childSectors.Count == 0) { keyValueSector.ClassName = "second-level-last"; } //Third Level loop foreach (var childSector in childSectors) { KeyValue keyValueChildSector = new KeyValue { Key = childSector.ID.ToString(), Value = childSector.Name, ClassName = "third-level", Level = "3" }; this.Data.Add(keyValueChildSector); } } } //Add in Cache cacheProvider.Add <List <KeyValue> >(this.Data, CacheKeys.CACHE_TSM_INT_SECTORS_DROPDOWN, SiteConstants.CacheDuration); } else { this.Data = cacheProvider.Get <List <KeyValue> >(CacheKeys.CACHE_TSM_INT_SECTORS_DROPDOWN); } }
/// <summary> /// Populate Nomenclature Sectors /// </summary> /// <param name="nomenclatureType"></param> /// <param name="type"></param> public void Populate(NomenclatureType nomenclatureType, SectorType type) { Guid langaugeID = TSMContext.CurrentSiteLanguageID; this.Data = new List <KeyValue>(); var tsmSectors = SectorService.GetTSMSectors(langaugeID, nomenclatureType); //filter by type var parentSectors = tsmSectors.Where(ts => ts.ParentID == null && ts.Type == type).OrderBy(ts => ts.Type).ThenBy(ts => ts.Name).ToList(); //First Level Loop foreach (var parentSector in parentSectors) { KeyValue keyValue = new KeyValue { Key = parentSector.ID.ToString(), Value = parentSector.Name, ClassName = "first-level", Level = "1" }; this.Data.Add(keyValue); var sectors = tsmSectors.Where(ts => ts.ParentID == parentSector.ID).OrderBy(ts => ts.Name).ToList(); //Second Level Loop foreach (var sector in sectors) { KeyValue keyValueSector = new KeyValue { Key = sector.ID.ToString(), Value = sector.Name, ClassName = "second-level", Level = "2" }; this.Data.Add(keyValueSector); var childSectors = tsmSectors.Where(ts => ts.ParentID == sector.ID).OrderBy(ts => ts.Name).ToList(); if (childSectors.Count == 0) { keyValueSector.ClassName = "second-level-last"; } //Third Level loop foreach (var childSector in childSectors) { KeyValue keyValueChildSector = new KeyValue { Key = childSector.ID.ToString(), Value = childSector.Name, ClassName = "third-level", Level = "3" }; this.Data.Add(keyValueChildSector); } } } }
/// <summary> /// Populate /// </summary> /// <param name="id"></param> /// <returns></returns> public bool Populate(Guid id, string urlPath) { bool isExists = false; var languageID = TSMContext.CurrentSiteLanguageID; this.ThematicFocus = new List <string>(); this.DesignProcess = new List <string>(); try { this.RecordLanguage = RecordService.GetRecordLanguage(id, languageID); if (this.RecordLanguage != null) { isExists = true; this.Name = RecordLanguage.Name; this.ID = id.ToString(); //Document Type var documentType = RecordLanguage.Record.Variables.Where(v => v.VariableID == AppSettingsUtility.GetGuid(AppSettingsKeys.DocumentTypeVariableID) && v.LanguageID == languageID).FirstOrDefault(); if (documentType != null) { this.DocumentType = documentType.Value; } //Description var description = RecordLanguage.Record.Variables.Where(v => v.VariableID == AppSettingsUtility.GetGuid(AppSettingsKeys.DescriptionVariableID) && v.LanguageID == languageID).FirstOrDefault(); if (description != null) { this.Description = description.Value; } this.Region = GetRegionName(RecordLanguage, languageID); this.Countries = GetCountryNames(RecordLanguage, languageID); // Year var year = RecordLanguage.Record.Variables.Where(v => v.VariableID == AppSettingsUtility.GetGuid(AppSettingsKeys.YearVariableID) && v.LanguageID == languageID).FirstOrDefault(); if (year != null) { this.Year = year.Value; } //last updated var lastUpdated = RecordLanguage.Record.Variables.Where(v => v.VariableID == AppSettingsUtility.GetGuid(AppSettingsKeys.LastUpdatedVariableID) && v.LanguageID == languageID).FirstOrDefault(); if (lastUpdated != null) { this.LastUpdated = GetLastUpdatedValue(lastUpdated.Value); } //Implementation Period var startYear = RecordLanguage.Record.Variables.Where(v => v.VariableID == AppSettingsUtility.GetGuid(AppSettingsKeys.StartYearVariableID) && v.LanguageID == languageID).FirstOrDefault(); var endYear = RecordLanguage.Record.Variables.Where(v => v.VariableID == AppSettingsUtility.GetGuid(AppSettingsKeys.EndYearVariableID) && v.LanguageID == languageID).FirstOrDefault(); if (startYear != null) { this.ImplementationPeriod = startYear.Value; } if (endYear != null) { this.ImplementationPeriod += "/" + endYear.Value; } var variableLanguages = VariableService.GetVariables(languageID); //Thematic focus var thematicVariables = variableLanguages.Where(vl => vl.Variable.VariableCategory == VariableCategory.ThematicFocus && CompareVariableValue(RecordLanguage.Record.Variables, vl, "true")).ToList(); foreach (var variableLanguage in thematicVariables) { this.ThematicFocus.Add(variableLanguage.DisplayName); } this.ThematicFocus = this.ThematicFocus.OrderBy(tf => tf).ToList(); //design process focus var designProcessVariables = variableLanguages.Where(vl => vl.Variable.VariableCategory == VariableCategory.DesignProcess && CompareVariableValue(RecordLanguage.Record.Variables, vl, "true")).ToList(); foreach (var variableLanguage in designProcessVariables) { this.DesignProcess.Add(variableLanguage.DisplayName); } this.DesignProcess = this.DesignProcess.OrderBy(dp => dp).ToList(); //Populate Sectors var sectorLanguages = PrioritySectorService.GetSectors(languageID); var tsmSectors = SectorService.GetTSMSectors(languageID); List <Guid> sectorIds = this.RecordLanguage.Record.Sectors.Select(s => s.ID).ToList(); this.ServiceSectors = PopulateSectors(sectorIds, sectorLanguages, tsmSectors, SectorType.Service); this.ProductSectors = PopulateSectors(sectorIds, sectorLanguages, tsmSectors, SectorType.Product); //Populate Files this.Files = new List <Document>(); if (RecordLanguage.Record.Documents != null) { this.Files = RecordLanguage.Record.Documents; } //Get Public var isPub = RecordLanguage.Record.Variables.Where(v => v.VariableID == AppSettingsUtility.GetGuid(AppSettingsKeys.isDownload) && v.LanguageID == languageID).FirstOrDefault(); if (isPub != null) { if (isPub.Value == "true") { this.isPublic = "ITCdownload"; } else { this.isPublic = "Regulardownload"; } } else { this.isPublic = "Regulardownload"; } //Link Record var linkRecord = RecordLanguage.Record.Variables.Where(v => v.VariableID == AppSettingsUtility.GetGuid(AppSettingsKeys.RecordLink) && v.LanguageID == languageID).FirstOrDefault(); if (linkRecord != null) { this.recordLink = linkRecord.Value; } this.ZipFilePath = ""; this.LoginStat = ""; this.urlPathForDoc = urlPath.ToString(); } } catch (Exception ex) { ErrorLog.WriteLog("DocumentDetailModel", "Populate", ex, ""); } return(isExists); }