protected void Page_Load(object sender, EventArgs e) { //Authorization checking if (AppSettingsUtility.GetBool(AppSettingsKeys.EnableAuthorization) && Session[SiteConstants.SESSION_USER_AUTHORIZED] == null) { string logonURL = AppSettingsUtility.GetString(AppSettingsKeys.LogOnURL); string returnURL = HttpUtility.UrlEncode(Request.Url.ToString()); string domain = Request.Url.Host; logonURL = logonURL.Replace("[returnURL]", returnURL).Replace("[authDomain]", domain); Response.Redirect(logonURL); } if (System.Web.HttpContext.Current.Session[SiteConstants.SESSION_USER] != null) { TSM.Entity.User user = (TSM.Entity.User)System.Web.HttpContext.Current.Session[SiteConstants.SESSION_USER]; string mail = user.Email; string host = mail.Split('@')[1].ToString(); string mailCred = "intracen.org"; // "intracen.org"; if (host != mailCred) { ScriptManager.RegisterStartupScript(this, GetType(), "authorized", "alert('You are not authorized to enter.'); window.close();", true); } } }
/// <summary> /// home page load pie chart /// </summary> private void PopulatePieChart() { Guid documentTypeVariableID = new Guid(AppSettingsUtility.GetString(AppSettingsKeys.DocumentTypeVariableID)); var cacheProvider = CacheFactory.Get(); if (!cacheProvider.Exists(CacheKeys.CACHE_HOME_PIE_CHART)) { List <PieChartModel> pieChartData = new List <PieChartModel>(); var regionLanguages = ChartService.GetRecordsInRegion(TSMContext.CurrentSiteLanguageID); foreach (var regionLanguage in regionLanguages) { pieChartData.Add(new PieChartModel { name = regionLanguage.Name, y = regionLanguage.RecordCount }); } JavaScriptSerializer serializer = new JavaScriptSerializer(); string jsonData = serializer.Serialize(pieChartData); this.PieChartItems = jsonData; //Add in cache cacheProvider.Add <string>(this.PieChartItems, CacheKeys.CACHE_HOME_PIE_CHART, SiteConstants.CacheDuration); } else { this.PieChartItems = cacheProvider.Get <string>(CacheKeys.CACHE_HOME_PIE_CHART); } }
/// <summary> /// Save user /// </summary> /// <returns></returns> public User SaveUser() { User user = new User(); try { if (this.UserID == Guid.Empty) { user = new User(); } else { user = this.GetUserFull(this.UserID); } user.FirstName = this.FirstName; user.LastName = this.LastName; user.Email = this.Email; user.RoleID = new Guid(AppSettingsUtility.GetString(AppSettingsKeys.AdminRoleID)); user.IsActive = this.IsActive; UserService.Save(user); return(user); } catch (Exception ex) { ErrorLog.WriteLog("ManageUserModel", "save", ex, ""); } return(user); }
/// <summary> /// Validate Captcha /// </summary> /// <param name="userResponse"></param> /// <returns></returns> public bool ValidateCaptcha(string userResponse) { bool SendMail = false; try { string captchaSecretKey = AppSettingsUtility.GetString(AppSettingsKeys.CaptchaSecretKey); var client = new WebClient(); var reply = client.DownloadString(string.Format("https://www.google.com/recaptcha/api/siteverify?secret={0}&response={1}", captchaSecretKey, userResponse)); var captchaResponse = JsonConvert.DeserializeObject <CaptchaResponse>(reply); SendMail = captchaResponse.Success; if (!SendMail) { string errors = string.Empty; foreach (string error in captchaResponse.ErrorCodes) { errors += error + "</br>"; } ErrorLog.WriteLog("ContactUsModel", "ValidateCaptcha", errors, "errors", ""); } } catch (Exception ee) { ErrorLog.WriteLog("ContactUsModel", "OuterValidateCaptcha", ee.ToString(), "errors", ""); } return(SendMail); }
/// <summary> /// Rebuild Index /// </summary> private void RebuildIndex(List <Record_Language> recordLanguages, string indexPath) { var defaultLanguageID = AppSettingsUtility.GetGuid(AppSettingsKeys.DefaultLanguageID); Guid descriptionVariableID = new Guid(AppSettingsUtility.GetString(AppSettingsKeys.DescriptionVariableID)); foreach (var recordLanguage in recordLanguages) { SiteSearchItem siteSearchItem = new SiteSearchItem(); siteSearchItem.ID = recordLanguage.ID.ToString(); siteSearchItem.Title = recordLanguage.Name; var descriptionVariable = recordLanguage.Record.Variables.Where(r => r.VariableID == descriptionVariableID && r.LanguageID == defaultLanguageID).FirstOrDefault(); if (descriptionVariable != null) { siteSearchItem.Description = descriptionVariable.Value; } siteSearchItem.URL = new RecordData().GetRecordUrl(recordLanguage.ID, recordLanguage.Name); siteSearchItem.IsDeleted = recordLanguage.Record.IsDeleted || !recordLanguage.Record.IsActive; SiteSearchService.SaveToIndex(siteSearchItem, indexPath); recordProcessed++; } }
public static List <Record_Variable> GetRecordInYear1(List <Guid> listRecord, Guid languageID) { Guid yearVariableID = new Guid(AppSettingsUtility.GetString(AppSettingsKeys.YearVariableID)); using (var context = new TSMContext()) { //var filteredRecords = GetRecordList(languageID, selectedRegions, selectedCountries, selectedSectors, selectedDocumentTypes, documentTypeVariableID); var filteredRecordsID = listRecord; // var documentTypeVariableID= var result = from r1 in context.Record_Variables where filteredRecordsID.Contains(r1.RecordID) && r1.VariableID == yearVariableID && r1.LanguageID == languageID group r1 by r1.Value into grps select new { value = grps.Key, recordCount = grps.Count() }; List <Record_Variable> recordVariables = new List <Record_Variable>(); Record_Variable recordVaraible; foreach (var record in result) { recordVaraible = new Record_Variable(); recordVaraible.Value = record.value; recordVaraible.RecordCount = record.recordCount; recordVariables.Add(recordVaraible); } return(recordVariables); } }
public static List <Record_Variable> GetThematicFocus(Guid languageID, List <Guid> listOfRecordIds) { Guid startImplementationYear = new Guid(AppSettingsUtility.GetString(AppSettingsKeys.StartYearVariableID)); Guid endImplementationYear = new Guid(AppSettingsUtility.GetString(AppSettingsKeys.EndYearVariableID)); int currentYear = DateTime.Now.Year; List <Guid> recordIdFilteredYear = new List <Guid>(); using (var context = new TSMContext()) { var filteredRecordsID = listOfRecordIds; var result1 = (from rv in context.Record_Variables where filteredRecordsID.Contains(rv.RecordID) && rv.LanguageID == languageID && (rv.VariableID == startImplementationYear || rv.VariableID == endImplementationYear) select rv).ToList(); foreach (var rec in listOfRecordIds) { RecordYear RecVar = new RecordYear(); try { var rec1 = result1.Where(r => r.RecordID == rec && r.VariableID == startImplementationYear).FirstOrDefault().Value; var rec2 = result1.Where(r => r.RecordID == rec && r.VariableID == endImplementationYear).FirstOrDefault().Value; RecVar.RecordID = rec; RecVar.StartYear = Convert.ToInt32(rec1); RecVar.EndYear = Convert.ToInt32(rec2); if (RecVar.EndYear >= currentYear) { recordIdFilteredYear.Add(rec); } } catch { } } var ThematicFocusIds = (from v in context.Variables where v.VariableCategory == VariableCategory.ThematicFocus select v.ID); var query = (from rv in context.Record_Variables.Include("Variable") where recordIdFilteredYear.Contains(rv.RecordID) join vl in context.Variable_Languages on rv.VariableID equals vl.ID where vl.LanguageID == languageID && ThematicFocusIds.Contains(rv.VariableID) && rv.Variable.IsDeleted == false && rv.Variable.IsActive == true && rv.Value == "true" group vl by vl.DisplayName into grps select new { name = grps.Key, count = grps.Count() }).OrderBy(vl => vl.name); List <Record_Variable> listRecordVariable = new List <Record_Variable>(); foreach (var item in query) { Record_Variable recordVariable = new Record_Variable(); recordVariable.VariableName = item.name.ToString(); recordVariable.RecordCount = item.count; listRecordVariable.Add(recordVariable); } return(listRecordVariable); } }
public JsonResult GetCountriesByRegion(Guid regionID) { Guid defaultLanguageID = new Guid(AppSettingsUtility.GetString(AppSettingsKeys.DefaultLanguageID)); ManageNewsModel NewsModel = new ManageNewsModel(); List <Country_Language> lstCountry = NewsModel.GetCountriesByRegion(regionID, defaultLanguageID); return(this.Json(new { Id = lstCountry.Select(c => c.ID), value = lstCountry.Select(c => c.Name) }, JsonRequestBehavior.AllowGet)); }
/// <summary> /// Created to fetch data from List instead of cache /// </summary> /// <param name="languageId"></param> /// <param name="RecordId"></param> /// <param name="variableIDs"></param> /// <param name="variableID"></param> /// <returns></returns> public static string GetVariableValueByVariableIdFromList(Guid languageId, Guid RecordId, List <string> variableIDs, string variableID, List <Record_Variable> recordVariables) { // List<Record_Variable> recordVariables = new List<Record_Variable>(); var variable = recordVariables.Where(rv => rv.VariableID.ToString() == variableID && rv.RecordID == RecordId && rv.LanguageID == languageId).Select(v => v.Value.ToString()).ToList(); Guid RegID = new Guid(AppSettingsUtility.GetString(AppSettingsKeys.Regional)); string DownloadITCOnly = AppSettingsUtility.GetString(AppSettingsKeys.isDownload); string RegionalID = RegID.ToString(); string variableValue = ""; string val = ""; if (variable.Count > 0) { if ((RegionalID != string.Empty) && (variableID == RegionalID)) { if (variable[0] == "0") { val = "false"; variableValue = val; } else if (variable[0] == "1") { val = "true"; variableValue = val; } else { variableValue = string.Join(",", variable); } } else if ((DownloadITCOnly != string.Empty) && (variableID == DownloadITCOnly)) { if (variable[0] == "") { variableValue = "true"; } else { variableValue = string.Join(",", variable); } } else { variableValue = string.Join(",", variable); } } else { variableValue = string.Join(",", variable); } return(variableValue); }
/// <summary> /// Populate Share Link /// </summary> /// <param name="currentURL"></param> public void PopulateShare(string currentURL) { currentURL = HttpContext.Current.Server.UrlEncode(currentURL); string title = HttpContext.Current.Server.UrlEncode(this.Name); this.FBShareLink = AppSettingsUtility.GetString(AppSettingsKeys.FBShare); this.FBShareLink = this.FBShareLink.Replace("[TITLE]", title).Replace("[URL]", currentURL); this.TwitterShareLink = AppSettingsUtility.GetString(AppSettingsKeys.TwitterShare); this.TwitterShareLink = this.TwitterShareLink.Replace("[TITLE]", title).Replace("[URL]", currentURL); this.LinkedinShareLink = AppSettingsUtility.GetString(AppSettingsKeys.LinkedinShare); this.LinkedinShareLink = this.LinkedinShareLink.Replace("[TITLE]", title).Replace("[URL]", currentURL); }
public static List <Region> RecordInRegionGroupWise() { List <Region> countries = new List <Region>(); string currentYear = DateTime.Now.Year.ToString(); Guid yearVariableID = new Guid(AppSettingsUtility.GetString(AppSettingsKeys.YearVariableID)); using (var context = new TSMContext()) { countries = context.Regions.Include("Region_Languages").Include("Records").Where(x => x.IsActive == true).ToList(); } return(countries); }
public void CheckManufacturerResponse() { string manufacturerUrl = AppSettingsUtility.GetString(AppSettingsKeys.ManufacturerUrl); var modifiedManufacturerUrl = manufacturerUrl.Replace("{index}", "0"); var webRequestHelper = new WebRequestHelper(modifiedManufacturerUrl); string response = webRequestHelper.GetResponse(); Assert.AreNotEqual <string>(response, string.Empty); var manufacturers = Program.GetManufaturersFromHtml(response); //Manufacturer count should be 50 for first page Assert.AreEqual <int>(manufacturers.Count, 50); }
/// <summary> /// Populate Pie Chart with SITC and Other type record /// </summary> private void PopulatePieChartOfSitcOtherRecord(Guid languageID, List <Guid> listOfRecordIds) { Guid documentTypeVariableID = new Guid(AppSettingsUtility.GetString(AppSettingsKeys.DocumentTypeVariableID)); var recordCountofSitcAndOther = ChartService.GetSitcAndRecord(languageID, listOfRecordIds); //SITC And WTO this.PieChartItemsSITCCount = recordCountofSitcAndOther.ResultWithSitcWTOCount.ToString(); //OTHER this.PieChartItemsOtherCount = recordCountofSitcAndOther.ResultOfOtherRecordCount.ToString(); }
/// <summary> /// Populate /// </summary> public void Populate() { var cacheProvider = CacheFactory.Get(); if (!cacheProvider.Exists(CacheKeys.CACHE_COUNTRIESMAP)) { this.CountryRecords = new List <CountryRecordsModel>(); Guid defaultLanguageID = new Guid(AppSettingsUtility.GetString(AppSettingsKeys.DefaultLanguageID)); var countryLanguages = CountryService.GetCountriesWithRecord(defaultLanguageID); //Get Minimum record this.MinRecord = (from cl in countryLanguages where cl.Country.Records.Count > 0 select cl.Country.Records.Count).Min(); //Get Max Record this.MaxRecord = (from cl in countryLanguages where cl.Country.Records.Count > 0 select cl.Country.Records.Count).Max(); foreach (var countryLanguage in countryLanguages) { CountryRecordsModel countryRecord = new CountryRecordsModel { CountryCode = countryLanguage.Country.ISOCode, CountryID = countryLanguage.ID.ToString(), CountryName = countryLanguage.Name, RecordCount = countryLanguage.Country.Records.Count, FillOpacity = GetFillOpacity(countryLanguage.Country.Records.Count), GeoJSON = GetGeoJSON(countryLanguage.Country.ISOCode), MinRecord = this.MinRecord, MaxRecord = this.MaxRecord }; if (!string.IsNullOrEmpty(countryRecord.GeoJSON) && countryRecord.RecordCount > 0) { this.CountryRecords.Add(countryRecord); } } //Add to cache cacheProvider.Add <List <CountryRecordsModel> >(this.CountryRecords, CacheKeys.CACHE_COUNTRIESMAP, SiteConstants.CacheDuration); } else { this.CountryRecords = cacheProvider.Get <List <CountryRecordsModel> >(CacheKeys.CACHE_COUNTRIESMAP); } }
private void PopulateStackBarChart(Guid languageID, List <Guid> listOfRecordIds) { Guid documentTypeVariableID = new Guid(AppSettingsUtility.GetString(AppSettingsKeys.DocumentTypeVariableID)); var recordVariables = ChartService.GetRecordPerYearWithDocumentType(languageID, listOfRecordIds); List <string> categories = new List <string>(); foreach (var category in recordVariables) { categories.Add(category.Year); } JavaScriptSerializer serializer = new JavaScriptSerializer(); string jsonData = serializer.Serialize(categories); this.StackBarChartCategory = jsonData; //National Data List <int> nationalData = new List <int>(); foreach (var recordPerDocument in recordVariables) { nationalData.Add(Convert.ToInt32(recordPerDocument.NationalCount)); } JavaScriptSerializer serializerNational = new JavaScriptSerializer(); string jsonDataNational = serializerNational.Serialize(nationalData); this.StackBarChartNationlaItems = jsonDataNational; //International Data List <int> dataInternational = new List <int>(); foreach (var recordPerDocument in recordVariables) { dataInternational.Add(Convert.ToInt32(recordPerDocument.InterNtionalCount)); } JavaScriptSerializer serializerInternational = new JavaScriptSerializer(); string jsonDataInternational = serializerInternational.Serialize(dataInternational); this.StackBarChartInterNationlaItems = jsonDataInternational; }
/// <summary> /// Populate /// </summary> public void Populate(string[] region, string[] country, string[] sector, string[] document, string[] year, string[] period, string[] last_Update, string[] counterpart, string[] DocCheckboxData, string[] thematicCheckboxData, string[] designProcessCheckboxData) { //var cacheProvider = CacheFactory.Get(); //if (!cacheProvider.Exists(CacheKeys.CACHE_COUNTRIESMAP)) //{ this.CountryRecords = new List <CountryRecordsModel>(); Guid defaultLanguageID = new Guid(AppSettingsUtility.GetString(AppSettingsKeys.DefaultLanguageID)); var countryLanguages = CountryService.GetCountriesWithFilterRecord(defaultLanguageID); //Get Minimum record this.MinRecord = (from cl in countryLanguages where cl.Country.Records.Count > 0 select cl.Country.Records.Count).Min(); //Get Max Record this.MaxRecord = (from cl in countryLanguages where cl.Country.Records.Count > 0 select cl.Country.Records.Count).Max(); foreach (var countryLanguage in countryLanguages) { CountryRecordsModel countryRecord = new CountryRecordsModel { CountryCode = countryLanguage.Country.ISOCode, CountryID = countryLanguage.ID.ToString(), CountryName = countryLanguage.Name, RecordCount = countryLanguage.Country.Records.Count, FillOpacity = GetFillOpacity(countryLanguage.Country.Records.Count), GeoJSON = GetGeoJSON(countryLanguage.Country.ISOCode), MinRecord = this.MinRecord, MaxRecord = this.MaxRecord }; if (!string.IsNullOrEmpty(countryRecord.GeoJSON) && countryRecord.RecordCount > 0) { this.CountryRecords.Add(countryRecord); } } //Add to cache //cacheProvider.Add<List<CountryRecordsModel>>(this.CountryRecords, CacheKeys.CACHE_COUNTRIESMAP, SiteConstants.CacheDuration); //} //else //{ // this.CountryRecords = cacheProvider.Get<List<CountryRecordsModel>>(CacheKeys.CACHE_COUNTRIESMAP); //} }
/// <summary> /// Populate Line Chart /// </summary> private void PopulateLineChart() { Guid documentTypeVariableID = new Guid(AppSettingsUtility.GetString(AppSettingsKeys.DocumentTypeVariableID)); var cacheProvider = CacheFactory.Get(); // var recordInYears = ChartService.GetRecordInYear(TSMContext.CurrentSiteLanguageID); var recordInYears = ChartService.GetRecordInYear(TSMContext.CurrentSiteLanguageID); if (!cacheProvider.Exists(CacheKeys.CACHE_HOME_LINE_CHART_CATEGORY)) { List <int> category = new List <int>(); foreach (var recordInYear in recordInYears) { category.Add(Convert.ToInt32(recordInYear.Value)); } JavaScriptSerializer serializer = new JavaScriptSerializer(); string jsonData = serializer.Serialize(category); this.LineChartCategory = jsonData; //Add in cache cacheProvider.Add <string>(this.LineChartCategory, CacheKeys.CACHE_HOME_LINE_CHART_CATEGORY, SiteConstants.CacheDuration); } else { this.LineChartCategory = cacheProvider.Get <string>(CacheKeys.CACHE_HOME_LINE_CHART_CATEGORY); } if (!cacheProvider.Exists(CacheKeys.CACHE_HOME_LINE_CHART_ITEM)) { List <int> data = new List <int>(); foreach (var recordInYear in recordInYears) { data.Add(Convert.ToInt32(recordInYear.RecordCount)); } JavaScriptSerializer serializer = new JavaScriptSerializer(); string jsonData = serializer.Serialize(data); this.LineChartItems = jsonData; //Add in cache cacheProvider.Add <string>(this.LineChartItems, CacheKeys.CACHE_HOME_LINE_CHART_ITEM, SiteConstants.CacheDuration); } else { this.LineChartItems = cacheProvider.Get <string>(CacheKeys.CACHE_HOME_LINE_CHART_ITEM); } }
/// <summary> /// Populate /// </summary> /// <param name="languageID"></param> public void Populate(Guid languageID) { //Countries var countries = CountryService.GetCountries(languageID); Countries = new List <KeyValue>(); foreach (var country in countries) { Countries.Add(new KeyValue { Key = country.ID.ToString(), Value = country.Name }); } //this.Countries.Insert(0, new KeyValue { Key = "", Value = "Country" }); //regions var regions = RegionService.GetRegions(languageID).OrderBy(r => r.Region.Type).ThenBy(r => r.Name); this.Regions = new List <GroupedSelectListItem>(); foreach (var region in regions) { this.Regions.Add(new GroupedSelectListItem { GroupKey = region.Region.Type == RegionType.Economical ? "2" : "1", GroupName = region.Region.Type == RegionType.Economical ? "Economical" : "Geographical", Text = region.Name, Value = region.ID.ToString() }); } //this.Regions.Insert(0, new GroupedSelectListItem { GroupKey = "", GroupName = "", Text = "Region", Value = "" }); //Documents Guid documentTypeVariableID = new Guid(AppSettingsUtility.GetString(AppSettingsKeys.DocumentTypeVariableID)); var choiceLanguages = VariableService.GetChoiceOptions(languageID, documentTypeVariableID); this.DocumentTypes = new List <KeyValue>(); foreach (var choiceLanguage in choiceLanguages) { this.DocumentTypes.Add(new KeyValue { Key = choiceLanguage.ID.ToString(), Value = choiceLanguage.Name }); } }
/// <summary> /// Populate Data /// </summary> public void Populate(Guid languageID) { Guid documentTypeVariableID = new Guid(AppSettingsUtility.GetString(AppSettingsKeys.DocumentTypeVariableID)); var cacheProvider = CacheFactory.Get(); List <Choice_Language> choiceLanguages = new List <Choice_Language>(); //Check if cache exists or not if (!cacheProvider.Exists(CacheKeys.CACHE_DOCUMENT_TYPE)) { choiceLanguages = VariableService.GetChoiceOptions(languageID, documentTypeVariableID); cacheProvider.Add <List <Choice_Language> >(choiceLanguages, CacheKeys.CACHE_DOCUMENT_TYPE, SiteConstants.CacheDuration); } else { choiceLanguages = cacheProvider.Get <List <Choice_Language> >(CacheKeys.CACHE_DOCUMENT_TYPE); } this.Data = new List <KeyValue>(); var national = choiceLanguages.Where(cl => cl.Name.ToLower() == "national").FirstOrDefault(); choiceLanguages = choiceLanguages.Where(cl => cl.Name.ToLower() != "national").OrderBy(cl => cl.Name).ToList(); this.National = new KeyValue(); //Add National if (national != null) { this.National = new KeyValue { Key = national.ID.ToString(), Value = national.Name, ClassName = "first-level", Level = "1" }; } foreach (var choiceLanguage in choiceLanguages) { this.Data.Add(new KeyValue { Key = choiceLanguage.ID.ToString(), Value = choiceLanguage.Name, ClassName = "second-level-last", Level = "2" }); } }
public JsonResult CheckDuplicateNewsTitle(string Title) { bool isNewNews = true; Guid defaultLanguageID = new Guid(AppSettingsUtility.GetString(AppSettingsKeys.DefaultLanguageID)); var result = NewsService.IsSubTitleExists(Title, defaultLanguageID); var cTitle = HttpContext.Request.UrlReferrer.Query.ToString(); if (!cTitle.Contains("?id") && !cTitle.Contains("&id")) { if (result == true) { isNewNews = false; } } return(Json(isNewNews, JsonRequestBehavior.AllowGet)); }
public bool CheckLogin(string userid, string password) { bool success = false; string strAdmin = AppSettingsUtility.GetString(AppSettingsKeys.LoginRebuild); //admin string strPass = AppSettingsUtility.GetString(AppSettingsKeys.PasswordRebuild); //tsmadmin if (userid.Trim() == CustomSecurity.DecryptString(strAdmin, "webspiders")) { if (password == CustomSecurity.DecryptString(strPass, "webspiders")) { Session["LoginValidate"] = "1"; success = true; successLogin = true; } } return(success); }
/// <summary> /// Get Records in Regions pie chart /// </summary> /// <param name="languageID"></param> /// <returns></returns> public static List <Region_Language> GetRecordsInRegion(Guid languageID, List <Guid> listOfRecordId, List <Guid> selectedRegions) { List <Region_Language> regionLanguages = new List <Region_Language>(); List <Region> regions = new List <Region>(); string currentYear = DateTime.Now.Year.ToString(); Guid yearVariableID = new Guid(AppSettingsUtility.GetString(AppSettingsKeys.YearVariableID)); List <Guid> recordIds = GetActiveCurrentYearRecordsIDs(languageID); using (var context = new TSMContext()) { //var filteredRecords = GetRecordList(languageID, selectedRegions, selectedCountries, selectedSectors, selectedDocumentTypes, documentTypeVariableID); // var filteredRecordsID = filteredRecords.Select(r => r.ID).ToList(); var filteredRecordsID = listOfRecordId; if (selectedRegions == null || selectedRegions.Count <= 0) { selectedRegions = (from r in context.Regions select r.ID).ToList(); } var query = (from r in context.Regions.Include("Region_Languages") join rl in context.Region_Languages on r.ID equals rl.ID where selectedRegions.Contains(r.ID) && r.Records.Any(re => filteredRecordsID.Contains(re.ID)) && rl.LanguageID == languageID && r.Type == TSM.Entity.RegionType.Geographical && r.IsDeleted == false && r.IsActive select new { Region = r, RegionName = r.Region_Languages.Where(rec => r.Records.Any(re => filteredRecordsID.Contains(re.ID)) && rec.LanguageID == languageID).FirstOrDefault().Name, RecordCount = r.Records.Where(re => recordIds.Contains(re.ID) && filteredRecordsID.Contains(re.ID)).Count() }).OrderBy(rls => rls.RegionName); foreach (var row in query) { Region_Language regionLanguage = new Region_Language(); regionLanguage.ID = row.Region.ID; regionLanguage.Name = row.RegionName; regionLanguage.RecordCount = row.RecordCount; regionLanguages.Add(regionLanguage); } } return(regionLanguages); }
/// <summary> /// Poulate Country Map /// </summary> /// <param name="countryCodes"></param> /// <returns></returns> public void Populate(string countryCodes) { this.CountryRecords = new List <CountryRecordsModel>(); Guid defaultLanguageID = new Guid(AppSettingsUtility.GetString(AppSettingsKeys.DefaultLanguageID)); var countryLanguages = CountryService.GetCountriesWithRecord(defaultLanguageID); //Get Minimum record this.MinRecord = (from cl in countryLanguages where cl.Country.Records.Count > 0 select cl.Country.Records.Count).Min(); //Get Max Record this.MaxRecord = (from cl in countryLanguages where cl.Country.Records.Count > 0 select cl.Country.Records.Count).Max(); string[] arrCountryCodes = countryCodes.Split(','); foreach (string countryCode in arrCountryCodes) { var countryLanguage = countryLanguages.Where(cl => cl.Country.ISOCode == countryCode).FirstOrDefault(); if (countryLanguage != null) { CountryRecordsModel countryRecord = new CountryRecordsModel { CountryCode = countryLanguage.Country.ISOCode, CountryID = countryLanguage.ID.ToString(), CountryName = countryLanguage.Name, RecordCount = countryLanguage.Country.Records.Count, FillOpacity = GetFillOpacity(countryLanguage.Country.Records.Count), GeoJSON = GetGeoJSON(countryLanguage.Country.ISOCode), MinRecord = this.MinRecord, MaxRecord = this.MaxRecord }; if (!string.IsNullOrEmpty(countryRecord.GeoJSON) && countryRecord.RecordCount > 0) { this.CountryRecords.Add(countryRecord); } } } }
/// <summary> /// Populate Pie Chart /// </summary> private void PopulatePieChart(Guid languageID, List <Guid> listOfRecordIds, List <Guid> region) { Guid documentTypeVariableID = new Guid(AppSettingsUtility.GetString(AppSettingsKeys.DocumentTypeVariableID)); List <PieChartModel> pieChartData = new List <PieChartModel>(); var regionLanguages = ChartService.GetRecordsInRegion(languageID, listOfRecordIds, region); foreach (var regionLanguage in regionLanguages) { pieChartData.Add(new PieChartModel { name = regionLanguage.Name, y = regionLanguage.RecordCount }); } JavaScriptSerializer serializer = new JavaScriptSerializer(); string jsonData = serializer.Serialize(pieChartData); this.PieChartItems = jsonData; }
/// <summary> /// Send Email /// </summary> /// <returns></returns> public bool SendMail(HttpPostedFileBase File) { bool SendMail = false; try { MailMessage mail = new MailMessage(); mail.Subject = AppSettingsUtility.GetString(AppSettingsKeys.MailSubject); mail.Body = ""; string html = System.IO.File.ReadAllText(HttpContext.Current.Server.MapPath("~/mailTemplate/MailBody.html")); mail.Body = string.Format(html, this.Contact, this.Salutation, this.FirstName, this.LastName, this.Email, this.Company, this.JobTitle, this.PhoneNumber, this.Country, this.DocumentName, this.Year, this.DocumentAvailability, this.URL, this.Comments); mail.From = new MailAddress(Email); mail.To.Add(AppSettingsUtility.GetString(AppSettingsKeys.MailTo)); if (File != null) { string fileName = Path.GetFileName(File.FileName); mail.Attachments.Add(new Attachment(File.InputStream, fileName)); } mail.IsBodyHtml = true; using (SmtpClient smtp = new SmtpClient()) { smtp.Host = AppSettingsUtility.GetString(AppSettingsKeys.SmtpHost); smtp.Port = AppSettingsUtility.GetInt(AppSettingsKeys.SmtpPort);; smtp.Send(mail); SendMail = true; } } catch (Exception ex) { ErrorLog.WriteLog("ContactUsModel", "SendEmail", ex, ""); } return(SendMail); }
/// <summary> /// Save Record to XML /// </summary> /// <param name="listofa"></param> private bool Save(List <ExportRecordData> listExportData) { bool success = false; string path = Server.MapPath(AppSettingsUtility.GetString(AppSettingsKeys.RecordFilePath)); try { if (!File.Exists(path)) { XmlDocument doc = new XmlDocument(); FileStream outFile = File.Create(path); XmlSerializer formatter = new XmlSerializer(listExportData.GetType()); formatter.Serialize(outFile, listExportData); success = true; } } catch (Exception ex) { ErrorLog.WriteLog("RebuildDownloadCache", "Save", ex, ""); } return(success); }
/// <summary> /// Defines the entry point of the application. /// </summary> static void Main() { string manufacturerUrl = AppSettingsUtility.GetString(AppSettingsKeys.ManufacturerUrl); for (int count = 0; count < 53; count++) { var modifiedManufacturerUrl = manufacturerUrl.Replace("{index}", count.ToString()); var webRequestHelper = new WebRequestHelper(modifiedManufacturerUrl); string response = webRequestHelper.GetResponse(); var manufacturers = GetManufaturersFromHtml(response); // Add to database if (manufacturers.Count > 0) { manufaturerRepository.Add(manufacturers); } Console.Clear(); Console.Write("Manufacturer Updated: " + count * 50); } }
/// <summary> /// Populate Pie chart of thematic focus /// </summary> private void PopulateBarChartThematicFocus(Guid languageID, List <Guid> listOfRecordIds) { Guid documentTypeVariableID = new Guid(AppSettingsUtility.GetString(AppSettingsKeys.DocumentTypeVariableID)); var recordVariables = ChartService.GetThematicFocus(languageID, listOfRecordIds); //categories List <string> barChartCategory = new List <string>(); foreach (var recordVariable in recordVariables) { barChartCategory.Add(recordVariable.VariableName); //barChartData.Add(new BarChartModel { name = regionLanguage.VariableName, data = regionLanguage.RecordCount }); } JavaScriptSerializer serializerCategory = new JavaScriptSerializer(); string jsonDataCategory = serializerCategory.Serialize(barChartCategory); this.BarChartThematicFocusCategory = jsonDataCategory; //data List <int> barChartData = new List <int>(); foreach (var recordVariable in recordVariables) { barChartData.Add(recordVariable.RecordCount); //barChartData.Add(new BarChartModel { name = regionLanguage.VariableName, data = regionLanguage.RecordCount }); } JavaScriptSerializer serializer = new JavaScriptSerializer(); string jsonData = serializer.Serialize(barChartData); this.BarChartThematicFocusItems = jsonData; }
/// <summary> /// /// </summary> /// <param name="languageID"></param> /// <returns></returns> public static List <Region_Language> GetRecordsInRegion(Guid languageID) { List <Region_Language> regionLanguages = new List <Region_Language>(); List <Region> regions = new List <Region>(); string currentYear = DateTime.Now.Year.ToString(); Guid yearVariableID = new Guid(AppSettingsUtility.GetString(AppSettingsKeys.YearVariableID)); List <Guid> recordIds = GetActiveCurrentYearRecordsIDs(languageID); using (var context = new TSMContext()) { var query = (from r in context.Regions.Include("Region_Languages") join rl in context.Region_Languages on r.ID equals rl.ID where rl.LanguageID == languageID && r.Type == TSM.Entity.RegionType.Geographical && r.IsDeleted == false && r.IsActive select new { Region = r, RegionName = r.Region_Languages.Where(rgl => rgl.LanguageID == languageID).FirstOrDefault().Name, RecordCount = r.Records.Where(re => recordIds.Contains(re.ID)).Count() }).OrderBy(rls => rls.RegionName); foreach (var row in query) { Region_Language regionLanguage = new Region_Language(); regionLanguage.ID = row.Region.ID; regionLanguage.Name = row.RegionName; regionLanguage.RecordCount = row.RecordCount; regionLanguages.Add(regionLanguage); } } return(regionLanguages); }
/// <summary> /// Populate Model /// </summary> /// <param name="id"></param> public void Populate(Guid id, Guid languageID) { try { this.Page = PageService.GetPage(id); if (!ReferenceEquals(this.Page, null)) { this.Page_Language = this.Page.Content_Languages.Where(p => p.LanguageID == languageID).FirstOrDefault(); if (this.Page_Language == null) { Guid defaultLanguageID = new Guid(AppSettingsUtility.GetString(AppSettingsKeys.DefaultLanguageID)); this.Page_Language = this.Page.Content_Languages.Where(p => p.LanguageID == defaultLanguageID).FirstOrDefault(); if (this.Page_Language == null) { this.Page_Language = new Content_Language(); } } this.ID = id; this.BrowserTitle = this.Page_Language.PageTitle; this.MetaKeywords = this.Page_Language.PageKeywords; this.MetaDescription = this.Page_Language.PageMetadata; this.Title = this.Page_Language.Title; this.SubTitle = this.Page_Language.SubTitle; this.Summary = this.Page_Language.Summary; this.Type = (ContentType)this.Page.Type; this.URL = this.Page.URL; this.LanguageID = languageID; //Populate main contents & right section contents JavaScriptSerializer serializer = new JavaScriptSerializer(); if (!string.IsNullOrEmpty(this.Page_Language.Description)) { try { this.MainContents = serializer.Deserialize <List <PageContent> >(this.Page_Language.Description); } catch { } } if (!string.IsNullOrEmpty(this.Page_Language.RightSection)) { try { this.RightSectionContents = serializer.Deserialize <List <PageContent> >(this.Page_Language.RightSection); } catch { } } if (this.MainContents == null || this.MainContents.Count == 0) { this.MainContents = new List <PageContent>(); this.MainContents.Add(new PageContent { Title = "", HTML = "" }); } if (this.RightSectionContents == null || this.RightSectionContents.Count == 0) { this.RightSectionContents = new List <PageContent>(); this.RightSectionContents.Add(new PageContent { Title = "", HTML = "" }); } } } catch (Exception ex) { ErrorLog.WriteLog("ManagePageModel", "Populate", ex, ""); } }