protected void Page_Load(object sender, EventArgs e) { ServiceInfo objSvc = ServiceInfo.ServiceConfig; ServicePresenter objSvcPre = new ServicePresenter(); lblTitle.Text = objSvcPre.getTranslatedText("ResDisclaimerHeader", (objSvc != null && objSvc.Culture != "") ? objSvc.Culture : "en-GB"); lblDisclaimer.Text = objSvcPre.getTranslatedText("ResDisclaimer", (objSvc != null && objSvc.Culture != "") ? objSvc.Culture : "en-GB"); }
protected void Page_Load(object sender, EventArgs e) { ServicePresenter objSerPre = new ServicePresenter(); CommonUtil objCommonUtil = new CommonUtil(); try { PropertyInfo propertyInfo = ucForeCast.GetType().GetProperty("Filter"); propertyInfo.SetValue(ucForeCast, Convert.ChangeType(false, propertyInfo.PropertyType), null); } catch (Exception ex) { AgriCastException currEx = new AgriCastException(objSerPre.GetServiceDetails(), ex); AgriCastLogger.Publish(currEx, AgriCastLogger.LogType.Error); HttpContext.Current.Session["ErrorMessage"] = objCommonUtil.getTransText(Constants.MOB_LOAD_FAILURE) + " : " + ex.Message.ToString(); } }
public MobilePresenter() { objComm = new CommonUtil(); objServiceHandler = new ServiceHandler(); objTblSvc = new TableService(); objSvcPre = new ServicePresenter(); svcInfo = ServiceInfo.ServiceConfig; }
protected void Page_Load(object sender, EventArgs e) { try { objPreTool = new ToolBarPresenter(this); objSvcInfo = (ServiceInfo)Session["serviceInfo"]; objLocInfo = (LocationInfo)Session["objLocationInfo"]; objSvcPre = new ServicePresenter(); if (!IsPostBack) { //Set the UserName objUserInfo = (UserInfo)Session["objuserinfo"]; if (objUserInfo != null) { /*IM01246266 - New Agricast - can't save a favourite - Begin */ //userName.InnerText = objUserInfo.UserName; if (!string.IsNullOrEmpty(objUserInfo.UserName)) { if (objUserInfo.UserName.IndexOf('^') > -1) { userName.InnerText = objUserInfo.UserName.Substring(objUserInfo.UserName.IndexOf('^') + 1); } } /*IM01246266 - New Agricast - can't save a favourite - End */ } objSvcPre = new ServicePresenter(this); string strLink = ConfigurationManager.AppSettings["link"]; userName.HRef = strLink; //objSvcPre.createServiceSession("Demo"); objPreTool.loadPageSettings(); if (!showFavorites) { imgFav.Visible = false; } else { //getFavorites(); /*IM01246233 :- New Agricast - missing translation tags - Begin */ //add the clientclick event for validation only when Email is enabled Fav_AddToFavorites.Attributes.Add("OnClick", "Javascript:return ValidateFavName(" + "'" + objCommonUtil.getTransText(Constants.FAV_NAME_EMPTY_CHECK) + "'" + ");"); /*IM01246233 :- New Agricast - missing translation tags - End */ } if (!showPrint) imgPrint.Visible = false; if (!showEmail) imgEmail.Visible = false; /*IM01246233 :- New Agricast - missing translation tags - Begin */ else { //add the clientclick event for validation only when Email is enabled EMailPage.Attributes.Add("OnClick", "Javascript:return ValidateEMail(" + "'" + objCommonUtil.getTransText(Constants.EMAIL_ID_EMPTY_CHECK) + "'" + ");"); } /*IM01246233 :- New Agricast - missing translation tags - End */ if (!showExportExcel) btnExcel.Visible = false; if (!showFeedback) imgFB.Visible = false; LoadCulture(); objPreTool.getCultureCode(); changeLabelText(strCulCode); } //Load units if not postback or in case culture has changed. if ((!IsPostBack) || ddlCulture.SelectedValue != objSvcInfo.Culture) LoadUnits(); LoadCustomSettings(); getFavorites(); if (!IsPostBack) { LoadCaptcha(); //set the first value in Dropdown as default unit and add it o session DefaultUnitSettings = dtUnits.Rows[0][0].ToString(); if (objSvcInfo.Unit.Trim() != "") {int count=0; for(int i=0; i< dtUnits.Rows.Count; i++) { if(objSvcInfo.Unit.Trim().ToLower().ToString() == dtUnits.Rows[i][0].ToString().ToLower().Trim()) { ddlUnits.SelectedIndex = ddlUnits.Items.IndexOf(ddlUnits.Items.FindByValue(objSvcInfo.Unit.Trim())); count++; break; } } if (count==0) objSvcInfo.Unit = DefaultUnitSettings; } else objSvcInfo.Unit = DefaultUnitSettings; } setEmailValues(); } catch (Exception ex) { AgriCastException currEx = new AgriCastException(objServicePre.GetServiceDetails(), ex); AgriCastLogger.Publish(currEx, AgriCastLogger.LogType.Error); HttpContext.Current.Session["ErrorMessage"] = objPreTool.getTranslatedText(Constants.TOOLBAR_LOADFAILURE, strCulCode) + ex.Message.ToString(); return; } }
protected void LoadUnits() { try { objSvcPre = new ServicePresenter(this); objSvcPre.loadUnits(); // DefaultUnitSettings = dtUnits.Rows[0][0].ToString(); //objSvcInfo.Unit = DefaultUnitSettings; } catch (Exception ex) { AgriCastException currEx = new AgriCastException(objServicePre.GetServiceDetails(), ex); AgriCastLogger.Publish(currEx, AgriCastLogger.LogType.Error); HttpContext.Current.Session["ErrorMessage"] = objPreTool.getTranslatedText(Constants.UNITS_LOADFAILURE, strCulCode) + ex.Message.ToString(); } }
protected void LoadCustomSettings() { string strCustom = string.Empty; try { objSvcPre = new ServicePresenter(this); objSvcPre.LoadCustomSettings(); // strCustom = "Wind-m/sec,knots#Rain-inches,cm#Temperature-Fahrenheit,Celsius"; string[] settings = strCustomUnits.Split('#'); for (int i = 0; i < settings.Count(); i++) { string Parameter = settings[i].Remove(settings[i].IndexOf("-")); string[] ParameterSettings = settings[i].Substring(settings[i].IndexOf("-") + 1).Split(','); switch (Parameter.ToLower()) { case "wind": ddlWind.Items.Clear(); foreach (string param in ParameterSettings) { ddlWind.Items.Add(new ListItem(objPreTool.getTranslatedText(param, objSvcInfo.Culture), param)); } ddlWind.DataBind(); Wind.Attributes.Add("class", "show"); break; case "rain": foreach (string param in ParameterSettings) { ddlRain.Items.Add(param); } ddlRain.DataBind(); Rain.Attributes.Add("class", "show"); break; case "temperature": foreach (string param in ParameterSettings) { ddlTemp.Items.Add(param); } ddlTemp.DataBind(); Temp.Attributes.Add("class", "show"); break; default: break; } } } catch (Exception ex) { AgriCastException currEx = new AgriCastException(objServicePre.GetServiceDetails(), ex); AgriCastLogger.Publish(currEx, AgriCastLogger.LogType.Error); HttpContext.Current.Session["ErrorMessage"] = objPreTool.getTranslatedText(Constants.UNITS_LOADFAILURE, strCulCode) + ex.Message.ToString(); } }
//Method to populate the language dropdwon. Fetches the values from Pub.config file protected void LoadCulture() { try { objSvcPre = new ServicePresenter(this); objSvcPre.loadCulture(); } catch (Exception ex) { AgriCastException currEx = new AgriCastException(objServicePre.GetServiceDetails(), ex); AgriCastLogger.Publish(currEx, AgriCastLogger.LogType.Error); HttpContext.Current.Session["ErrorMessage"] = objPreTool.getTranslatedText(Constants.CULTURE_LOADFAILURE, strCulCode) + ex.Message.ToString(); } }
protected void gv_Favorites_RowDataBound(object obj, GridViewRowEventArgs e) { try { /* IM01365142 - New Agricast - Favorite table - translation for "Edit" and "Delete" - Jerrey - Begin */ if (e.Row.RowType == DataControlRowType.Header) { e.Row.Cells[3].Text = string.Format("{0} / {1}", objPreTool.getTranslatedText(Constants.FAV_EDIT, strCulCode), objPreTool.getTranslatedText(Constants.FAV_DELETE, strCulCode)); } /* IM01365142 - New Agricast - Favorite table - translation for "Edit" and "Delete" - Jerrey - End */ if (e.Row.RowType == DataControlRowType.DataRow) { LinkButton lbButton = new LinkButton(); lbButton.Text = e.Row.Cells[0].Text; e.Row.Cells[0].Controls.Add(lbButton); lbButton.CommandName = "Select"; lbButton.CommandArgument = index.ToString(); index++; /* IM01365225 - New Agricast - favorite - Service Name - Jerrey - Begin */ objSvcPre = new ServicePresenter(); Label lblModuleName = new Label(); lblModuleName.Text = e.Row.Cells[1].Text; lblModuleName.Visible = false; e.Row.Cells[1].Controls.Add(lblModuleName); Label lblModuleTransTag = new Label(); lblModuleTransTag.Text = objSvcPre.GetServicePageTransTag(lblModuleName.Text); e.Row.Cells[1].Controls.Add(lblModuleTransTag); /* IM01365225 - New Agricast - favorite - Service Name - Jerrey - End */ } //hide the key field in the GRID e.Row.Cells[4].Visible = false; } catch (Exception ex) { AgriCastException currEx = new AgriCastException(objSvcPre.GetServiceDetails(), ex); AgriCastLogger.Publish(currEx, AgriCastLogger.LogType.Error); HttpContext.Current.Session["ErrorMessage"] = objPreTool.getTranslatedText(Constants.GENERIC_ERRORONPAGE, strCulCode) + ex.Message.ToString(); } }
/* Agricast CR - R2 - Mobile site-Login Page and service configuration changes - End */ /// <summary> /// To display Tablular list data /// </summary> /// public void DisplayTableData() { try { //Create the Mobile Presenter objMobPresenter = new MobilePresenter(); DataSet ds = new DataSet(); //Call the Mobile Presenter ds = objMobPresenter.GetTableData(alIocnList, Node, Name); /* Agricast CR - R2 - Mobile site-Login Page and service configuration changes - Begin */ /* 2.2 If we add a new series in service configuration under mobile section e.g. relative humidity, it should be displayed on mobile. */ dtSeries = ds.Tables[0]; /* Agricast CR - R2 - Mobile site-Login Page and service configuration changes - End */ dtByDays = ds.Tables[1]; /* Agricast CR - R2 - Mobile site-Login Page and service configuration changes - Begin */ /* 2.2 If we add a new series in service configuration under mobile section e.g. relative humidity, it should be displayed on mobile. */ // commented for CR //changeColNames(dtByDays); /* Agricast CR - R2 - Mobile site-Login Page and service configuration changes - End */ modifyData(dtByDays); if (dtByDays.Rows.Count > 0) { dFirstDate = DateTime.Parse(dtByDays.Rows[0][DATE].ToString()); } DataTable dtFiltered; if (Filter) { dtFiltered = dtByDays.Select("" + DATE + "='" + dFirstDate.AddDays(1) + "' or " + DATE + "='" + dFirstDate.AddDays(2) + "'").CopyToDataTable(); } else { dtFiltered = dtByDays; } if (dtFiltered.Rows.Count > 0) { Repeater1.DataSource = dtFiltered; Repeater1.DataBind(); } /* Agricast CR - R2 - Mobile site-Login Page and service configuration changes - Begin */ /* 2.2 If we add a new series in service configuration under mobile section e.g. relative humidity, it should be displayed on mobile. */ // commented for CR //DataTable dtSeries = ds.Tables[0]; //foreach (DataRow dr in dtSeries.Rows) //{ // if (dr["trnsTag"].ToString().ToLower().Contains("temp")) // { // if (dr["trnsTag"].ToString().ToLower().Contains("max")) // Max = getTranslatedText(dr["trnsTag"].ToString()); // else // Min = getTranslatedText(dr["trnsTag"].ToString()); // } // if (dr["trnsTag"].ToString().Contains("_wind_")) // Wind = getTranslatedText(dr["trnsTag"].ToString()); // if (dr["trnsTag"].ToString().Contains(TRNSTAG_RAIN)) // Rain = getTranslatedText(dr["trnsTag"].ToString()); //} /* Agricast CR - R2 - Mobile site-Login Page and service configuration changes - End */ } catch (Exception ex) { objSvcPre = new ServicePresenter(); AgriCastException currEx = new AgriCastException(objSvcPre.GetServiceDetails(), ex); AgriCastLogger.Publish(currEx, AgriCastLogger.LogType.Error); HttpContext.Current.Session["ErrorMessage"] = objCommonUtil.getTransText(Constants.MOB_DISPLAYTABLE_ERROR) + " : " + ex.Message.ToString(); } }
void modifyData(DataTable dt) { try { for (int i = 0; i < dt.Rows.Count; i++) { for (int j = 0; j < dt.Columns.Count; j++) { Type typ = dt.Rows[i][j].GetType(); switch (typ.Name.ToLower()) { case "int32": dt.Rows[i][j] = Math.Round(Convert.ToDouble(dt.Rows[i][j])); break; case "decimal": dt.Rows[i][j] = Math.Round(Convert.ToDouble(dt.Rows[i][j])); break; } } } } catch (Exception ex) { objSvcPre = new ServicePresenter(); AgriCastException currEx = new AgriCastException(objSvcPre.GetServiceDetails(), ex); AgriCastLogger.Publish(currEx, AgriCastLogger.LogType.Error); HttpContext.Current.Session["ErrorMessage"] = objCommonUtil.getTransText(Constants.MOB_MODIFYDATA_ERROR) + " : " + ex.Message.ToString(); } }
string getTranslatedText(string text) { if (Session["serviceInfo"] != null) { svcInfo = (ServiceInfo)Session["serviceInfo"]; } else { svcInfo = ServiceInfo.ServiceConfig; } try { string strCul = svcInfo.Culture; objSvcPre = new ServicePresenter(); text = objSvcPre.getTranslatedText(text, strCul); } catch (Exception ex) { AgriCastException currEx = new AgriCastException(objSvcPre.GetServiceDetails(), ex); AgriCastLogger.Publish(currEx, AgriCastLogger.LogType.Error); HttpContext.Current.Session["ErrorMessage"] = objCommonUtil.getTransText(Constants.MOB_TRANS_ERROR) + " : " + ex.Message.ToString(); } return text; }
protected void Page_Load(object sender, EventArgs e) { try { //Get the NodeList List<string[]> objList = objServiceHandler.getNodeList(SERVICEPAGENAME); for (int i = 0; i < objList.Count; i++) { if (objList[i].Contains("icon") && objList[i][1].ToString().ToLower().Contains("detail")) { //Name = objList[i][1].ToString(); //Node = objList[i][0].ToString(); // objIconPre = new IconPresenter(this, Name); //Get The Icon data //objIconPre.getIconData(); alIocnList = objMobPresenter.GetIconData(objList[i][1].ToString()); iIconsCount = alIocnList.Count; } if (objList[i].Contains("tblSeriesRows") && objList[i][1].ToString().ToLower().Contains("detail")) { Name = objList[i][1].ToString(); Node = objList[i][0].ToString(); //objTablePre = new TablePresenter(this, Name); DisplayTableData(); } //if (objList[i].Contains("tblDaysRows")) //{ // //Load spray window user control // NameSpray = objList[i][1].ToString(); // NodeSpray = objList[i][0].ToString(); //} } if (svcInfo.Unit.ToLower() == "imperial") { TUnit = "F"; PUnit = "in"; } switch (svcInfo.WUnit.ToLower()) { case "beaufort": WUnit = "bft"; break; case "mph": WUnit = "mph"; break; case "kmh": WUnit = "kmh"; break; } // ChangeLabelText(); } catch (Exception ex) { objSvcPre = new ServicePresenter(); AgriCastException currEx = new AgriCastException(objSvcPre.GetServiceDetails(), ex); AgriCastLogger.Publish(currEx, AgriCastLogger.LogType.Error); HttpContext.Current.Session["ErrorMessage"] = objCommonUtil.getTransText(Constants.MOB_LOAD_FAILURE) + " : " + ex.Message.ToString(); return; } }
protected void Page_Load(object sender, EventArgs e) { if (Session == null || Session["serviceInfo"] == null) objSvcInfo = new ServiceInfo(); else objSvcInfo = (ServiceInfo)Session["serviceInfo"]; objDataPointInfo = DataPointInfo.getDataPointObject; objLocInfo = new LocationInfo(); HttpCookie locCookie = Request.Cookies["ais_LocationInfo"]; if (locCookie != null) { LocationInfo newInfo = objLocInfo.DeserializeCookieString(locCookie.Value); if (newInfo != null) { Session["objLocationInfo"] = newInfo; objLocInfo = newInfo; } if (Session["AuditData"] != null) { IDictionary dict = (IDictionary)Session["AuditData"]; dict["locSearchType"] = "By Cookie"; Session["AuditData"] = dict; } } objSvcPre = new ServicePresenter(this); //set the Cutlure code from ObjLocation object to Service info //this is used in Login page for tranlsation if (objLocInfo != null && objLocInfo.ServiceInfo != null) objSvcInfo.Culture = objLocInfo.ServiceInfo.Culture; objSvcPre.getNodeList1("servicePage"); // get weather icon info var iconNode = alNodeList.FirstOrDefault(q => q[0].ToString() == "icon"); if (iconNode != null) { common.LoadCtrl<Icon>(this.Page, weatherIcons, "Icon", iconNode[1].ToString(), ""); } /* Agricast CR - R6 - Add wind icons and legend for Humidity - Begin */ /*Wind icons a seperate entity - BEGIN*/ var windIconNode = alNodeList.FirstOrDefault(q => q[0].ToString() == "windIcon"); if (windIconNode != null) { //common.LoadCtrl(this.Page, windIcons, "WebChartIcons"); common.LoadCtrl<WebChartIcons>(this.Page, windIcons, "WebChartIcons", windIconNode[1].ToString(), ""); } /*Wind icons a seperate entity - END*/ /* Agricast CR - R6 - Add wind icons and legend for Humidity - End */ var imgPath = HttpUtility.UrlDecode(Request.QueryString["img"]).Replace("'","").Replace('>',' ').Replace('<', ' ').Replace('"',' ').Replace(':',' ').Replace(';',' '); if (!string.IsNullOrEmpty(imgPath)) { imgPath = Server.HtmlDecode(imgPath); if (!IsPostBack) { imgBigger.ImageUrl = imgPath; } } }
public void DisplayLegend(string node, string name) { try { string TransString = string.Empty; //GetLegenddetails(node, name); //load only if station is selected //if (objDataPointInfo != null && (objDataPointInfo.stationLatitude != 0.0 || objDataPointInfo.stationLongitude != 0.0)) { Label lblLegend = new Label(); TransString = ""; lblLegend.Text = TransString; lblLegend.CssClass = "label250"; lblLegend.ID = "lbl_" + name; StringBuilder sbBody = new StringBuilder(); StringBuilder sb1; StringBuilder sb; ServiceHandler serviceHandlerObj = new ServiceHandler(); DataTable dtLegenddetails = serviceHandlerObj.GetLegendData(name); string legendPath = dtLegenddetails.Rows[0][2].ToString().ToString(); using (StreamReader sr = new StreamReader(HttpRuntime.AppDomainAppPath + @"\Legends\" + legendPath)) { String line; // Read and display lines from the file until the end of the file is reached. while ((line = sr.ReadLine()) != null) { sbBody.Append(line); } sb1 = new StringBuilder(sbBody.ToString().Substring(sbBody.ToString().IndexOf("<div"), (sbBody.ToString().IndexOf("</div>") - sbBody.ToString().IndexOf("<div") + 6))); string strLegend = sb1.ToString(); //get delimiters from web.config string startDelimiter = ConfigurationManager.AppSettings["startDelimiter"] != null && ConfigurationManager.AppSettings["startDelimiter"] != string.Empty ? ConfigurationManager.AppSettings["startDelimiter"] : "{"; string endDelimiter = ConfigurationManager.AppSettings["endDelimiter"] != null && ConfigurationManager.AppSettings["endDelimiter"] != string.Empty ? ConfigurationManager.AppSettings["endDelimiter"] : "}"; while (strLegend.IndexOf(endDelimiter) != -1) { int start = strLegend.IndexOf(startDelimiter); int end = strLegend.IndexOf(endDelimiter); string text = strLegend.Substring(start, end - start + startDelimiter.Count()); if (text != string.Empty) { TransString = getTransText(text.Substring(startDelimiter.Count(), text.Length - (endDelimiter.Count() + startDelimiter.Count()))); strLegend = strLegend.Remove(start) + TransString + strLegend.Substring(end + endDelimiter.Count()); } } sb = new StringBuilder(strLegend); } HtmlGenericControl div1 = new HtmlGenericControl("div"); div1.ID = "divLegend_" + name; LiteralControl literal = new LiteralControl(sb.ToString()); literal.ID = "legend_" + name; //System.Web.UI.WebControls.Image img = new System.Web.UI.WebControls.Image(); //img.ImageUrl = "~/Images/boxminus.gif"; //img.ID = "img1_" + name; //img.ClientIDMode = ClientIDMode.Static; //CentrePlaceHolder.Controls.Add(img); CentrePlaceHolder.Controls.Add(lblLegend); div1.Controls.Add(literal); CentrePlaceHolder.Controls.Add(div1); } } catch (Exception ex) { objSvcPre = new ServicePresenter(); AgriCastException currEx = new AgriCastException(objSvcPre.GetServiceDetails(), ex); AgriCastLogger.Publish(currEx, AgriCastLogger.LogType.Error); HttpContext.Current.Session["ErrorMessage"] = objCommonUtil.getTransText(Constants.MOB_DISPLAYLEGEND_ERROR) + " : " + ex.Message.ToString(); } }