protected WebLocationSearch() { objLocPresenter = new locSearchPresenter(this); objNearByPre = new nearbyPointPresenter(this); objSvcInfo = ServiceInfo.ServiceConfig; objDataPointInfo = DataPointInfo.getDataPointObject; objLocInfo = LocationInfo.getLocationInfoObj; }
public ToolBarPresenter(IToolbar ITool) { if (ITool != null) { objITool = ITool; objSvcInfo = (ServiceInfo)HttpContext.Current.Session["objServiceInfo"]; } }
public string checkUnitPalette(string seriePalette) { if (HttpContext.Current.Session == null || HttpContext.Current.Session["serviceInfo"] == null) { objSvcInfo = new ServiceInfo(); } else { objSvcInfo = (ServiceInfo)HttpContext.Current.Session["serviceInfo"]; } if (objSvcInfo.Unit.ToLower() == "metric") { switch (seriePalette) { case "pal_sip_temperaturef": seriePalette = "pal_sip_temperature"; break; case "pal_sip_raininch_8hour": seriePalette = "pal_sip_rain_8hour"; break; case "pal_sip_raininch": seriePalette = "pal_sip_rain"; break; case "pal_winspeedmph": seriePalette = "pal_winspeedkmh"; break; } } else if (objSvcInfo.Unit.ToLower() == "imperial") { switch (seriePalette) { case "pal_sip_temperature": seriePalette = "pal_sip_temperaturef"; break; case "pal_sip_rain_8hour": seriePalette = "pal_sip_raininch_8hour"; break; case "pal_sip_rain": seriePalette = "pal_sip_raininch"; break; case "pal_winspeedkmh": seriePalette = "pal_winspeedmph"; break; } } if (objSvcInfo.WUnit.ToLower() == "beaufort") { switch (seriePalette) { case "pal_winspeedkmh": seriePalette = "pal_winspeedbft"; break; case "pal_winspeedmph": seriePalette = "pal_winspeedbft"; break; } } return seriePalette; }
//public void setWebServiceValues(double dLat, double dLong, DateTime dSunrise, DateTime dSunset) //{ // try // { // objIconSvc.setIconWebServiceValues(dLat, dLong, dSunrise, dSunset); // } // catch (Exception ex) // { // HttpContext.Current.Session["ErrorMessage"] = "The following error occured while setting web service values: " + ex.Message.ToString(); // } //} public void getCultureCode() { try { objSvcInfo = (ServiceInfo)HttpContext.Current.Session["serviceInfo"]; objIIcon.strCulCode = objSvcInfo.Culture; } catch (Exception ex) { HttpContext.Current.Session["ErrorMessage"] = objComUtil.getTransText(Constants.CULTURE_LOADFAILURE) +" : "+ ex.Message.ToString(); } }
public void getCultureCode() { try { objSvcInfo = (ServiceInfo)HttpContext.Current.Session["serviceInfo"]; objITool.strCulCode = objSvcInfo.Culture; } catch (Exception ex) { AgriCastException currEx = new AgriCastException(objSvcPre.GetServiceDetails(), ex); AgriCastLogger.Publish(currEx, AgriCastLogger.LogType.Error); HttpContext.Current.Session["ErrorMessage"] = getTranslatedText(Constants.CULTURE_LOADFAILURE, objSvcInfo.Culture) + ex.Message.ToString(); } }
public void getSessionDetails() { try { HttpSessionState Session = HttpContext.Current.Session; ArrayList ar = new ArrayList(); objSvcInfo = (ServiceInfo)Session["serviceInfo"]; ar.Add(objSvcInfo.ServiceName.ToString()); ar.Add(objSvcInfo.Module.ToString()); ar.Add(objSvcInfo.Culture.ToString()); IWeather.ar = ar; } catch (Exception ex) { AgriCastException currEx = new AgriCastException(objSvcPre.GetServiceDetails(), ex); AgriCastLogger.Publish(currEx, AgriCastLogger.LogType.Error); HttpContext.Current.Session["ErrorMessage"] = objCommonUtil.getTransText(Constants.GEN_SESSIONDETAILS_FAILURE) + ";" + ex.Message.ToString(); } }
public string SerializeCookieString() { HttpSessionState Session = HttpContext.Current.Session; if (HttpContext.Current != null) Session = HttpContext.Current.Session; objDataPointInfo = DataPointInfo.getDataPointObject; objLocInfo = LocationInfo.getLocationInfoObj; if (Session == null || Session["serviceInfo"] == null) { objSvcInfo = new ServiceInfo(); } else { objSvcInfo = (ServiceInfo)Session["serviceInfo"]; } return objLocInfo.searchLocation + "#" + objLocInfo.placeID + "#" + HttpUtility.UrlEncode(objLocInfo.placeName) + "#" + objLocInfo.longitude.ToString(NumberFormatInfo.InvariantInfo) + "#" + objLocInfo.latitude.ToString(NumberFormatInfo.InvariantInfo) + "#" + objLocInfo.CountryCode + "#" + objLocInfo.Provider + "#" + objLocInfo.AdminName + "#" + HttpUtility.UrlEncode(objDataPointInfo.stationName) + "#" + objDataPointInfo.stationLatitude + "#" + objDataPointInfo.stationLongitude + "#" + objSvcInfo.Country + "#" + objSvcInfo.Culture + "#" + objSvcInfo.Module + "#" //+ objSvcInfo.ServiceName + "#" + objSvcInfo.Unit + "#"; }
public LocationInfo DeserializeCookieString(string cookiestr) { string[] values = cookiestr.Split('#'); //int i = 0; HttpSessionState Session = HttpContext.Current.Session; if (HttpContext.Current != null) Session = HttpContext.Current.Session; objDataPointInfo = DataPointInfo.getDataPointObject; objLocInfo = LocationInfo.getLocationInfoObj; if (Session == null || Session["serviceInfo"] == null) { objSvcInfo = new ServiceInfo(); } else { objSvcInfo = (ServiceInfo)Session["serviceInfo"]; } try { int pid=0; double coord=0d; searchLocation = (values[0]); placeID = Int32.TryParse(values[1],out pid)?pid:0; placeName = HttpUtility.UrlDecode(values[2]); longitude = double.TryParse(values[3], out coord) ? coord : 0d; latitude = double.TryParse(values[4],out coord)?coord:0d; CountryCode = (values[5]); if (Enum.IsDefined(typeof(LocationSearchSource), values[6])) Provider = (LocationSearchSource)Enum.Parse(typeof(LocationSearchSource), values[6], true); else Provider = LocationSearchSource.defaultService; AdminName = values[7] ; objDataPointInfo.stationName = HttpUtility.UrlDecode(values[8]); objDataPointInfo.stationLatitude = double.TryParse(values[9],out coord)?coord:0d; objDataPointInfo.stationLongitude = double.TryParse(values[10], out coord) ? coord : 0d; objSvcInfo.Country = (values[11]); objSvcInfo.Culture = (values[12]); objSvcInfo.Module = (values[13]); //objSvcInfo.ServiceName = (values[14]); objSvcInfo.Unit = (values[14]); //objDataPointInfo.CheckStationValidity(); } catch { return null; } return this; }
/*IM01184669 - New Agricast - redirection to a login page if the publication is protected - BEGIN*/ //public void GetMossMenuItems(string ExtNavigation) public void GetMossMenuItems(string ExtNavigation, string MossCultureCode) { //DataSet ds = ServiceObj.GetMossMenuItems(ExtNavigation); DataSet ds = ServiceObj.GetMossMenuItems(ExtNavigation, MossCultureCode); if (ds != null) //objIDefault.dsMossMenu = ServiceObj.GetMossMenuItems(ExtNavigation); objIDefault.dsMossMenu = ServiceObj.GetMossMenuItems(ExtNavigation, MossCultureCode); else { objServiceInfo = (ServiceInfo)HttpContext.Current.Session["serviceInfo"]; /*IM01335823- New Agricast - Session timed out - Return URL and Iframe - Jerrey - Start */ /* as BWM is only for moss site, this logic no longer been used. */ ///*3.1 UC – BodenWasser Modell - display webpage as IFrame - Jerrey - Start*/ ///* after BWM page called, goto another pub, moss=true */ //if (objServiceInfo.Module.ToLower() != "watermodel") // objServiceInfo.Moss = "false"; ///*3.1 UC – BodenWasser Modell - display webpage as IFrame - Jerrey - End*/ /*IM01335823- New Agricast - Session timed out - Return URL and Iframe - Jerrey - End */ } }
public ArrayList GetServiceDetails() { if (HttpContext.Current.Session == null || HttpContext.Current.Session["serviceInfo"] == null) { objServiceInfo = new ServiceInfo(); } else { objServiceInfo = (ServiceInfo)HttpContext.Current.Session["serviceInfo"]; } if (HttpContext.Current.Session == null || HttpContext.Current.Session["objUserInfo"] == null) { objUserInfo = new UserInfo(); } else { objUserInfo = (UserInfo)HttpContext.Current.Session["objUserInfo"]; } ArrayList alError = new ArrayList(); alError.Add(objServiceInfo.ServiceName); alError.Add(objServiceInfo.Module); if (objUserInfo != null) alError.Add(objUserInfo.UserName); else alError.Add(string.Empty); return alError; }
public void CreateTables(string name, string allign, string aggregation, string datasource, int start, int end) { objSvcInfo = (ServiceInfo)HttpContext.Current.Session["serviceInfo"]; GetcompleteSeriesList(allign); GetTableSeries(allign); Itable.dtTableSeries = Itable.dsSeriesData.Tables[0]; //To change first column as based on the chosen unit Itable.dtTableSeries = objSvcPre.ChangeUnits(Itable.dtTableSeries, objSvcInfo.Unit, objSvcInfo.WUnit); Itable.dtTableLegends = Itable.dsSeriesData.Tables[1]; GetSeriesData(Itable.dtTableSeries, aggregation, datasource, start, end, sHours, eHours); //Condition to check for the availability of the data from database if (Itable.dtSeries != null) { Itable.dtByDays = Itable.dtSeries; DataColumn dc = new DataColumn(); dc.ColumnName = getTranslatedText(FIRSTCOLNAME, objSvcInfo.Culture); dc.DefaultValue = null; Itable.dtByDays.Columns.Add(dc); int LastColIndex = Itable.dtByDays.Columns.Count - 1; for (int i = 0; i < Itable.dtByDays.Rows.Count; i++) { DateTime Date = Convert.ToDateTime(Itable.dtByDays.Rows[i][0].ToString()); Itable.dtByDays.Rows[i][LastColIndex] = Date.Hour; } Itable.alSeries = new ArrayList(); for (int i = 1; i < LastColIndex; i++) { Itable.alSeries.Add(Itable.dtByDays.Columns[i].ColumnName.ToString() + "," + Itable.dtTableSeries.Rows[i - 1][1].ToString() + "," + Itable.dtTableSeries.Rows[i - 1][0].ToString() + "," + Itable.dtTableSeries.Rows[i - 1][3].ToString()); } } }
public MobilePresenter() { objComm = new CommonUtil(); objServiceHandler = new ServiceHandler(); objTblSvc = new TableService(); objSvcPre = new ServicePresenter(); svcInfo = ServiceInfo.ServiceConfig; }
public void getWindIconSettings(string allign) { try { objSvcInfo = (ServiceInfo)HttpContext.Current.Session["serviceInfo"]; /*Wind Icon as a Sepearate component -- BEGIN*/ //objIChartIcon.strAllignDetails = objSvc.ReadAllignment(allign,controlName); objIChartIcon.dtWindIconSettings = objSvc.getWindIconSettings(controlName); /*Wind Icon as a Sepearate component -- END*/ } catch (Exception ex) { AgriCastException currEx = new AgriCastException(objSvcPre.GetServiceDetails(), ex); AgriCastLogger.Publish(currEx, AgriCastLogger.LogType.Error); HttpContext.Current.Session["ErrorMessage"] = objComUtil.getTransText(Constants.TAB_ALIGNMENT_FAILURE) + ":" + ex.Message.ToString(); } }
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; } }
public void ReadQueryStringValues() { if (HttpContext.Current.Session == null || HttpContext.Current.Session["serviceInfo"] == null) { objServiceInfo = new ServiceInfo(); } else { objServiceInfo = (ServiceInfo)HttpContext.Current.Session["serviceInfo"]; } objLocInfo = LocationInfo.getLocationInfoObj; objDataPointInfo = DataPointInfo.getDataPointObject; if (HttpContext.Current.Request.QueryString["module"] != null) { //if (objSvcInfo.Module != HttpContext.Current.Request.QueryString["module"]) //{ // if (HttpContext.Current.Session["Rating"] != null) // { // SaveRatings(); // } //} objServiceInfo.Module = HttpContext.Current.Request.QueryString["module"]; } if (HttpContext.Current.Request.QueryString["Culture"] != null) { objServiceInfo.Culture = HttpContext.Current.Request.QueryString["Culture"]; } if (HttpContext.Current.Request.QueryString["Country"] != null) { objServiceInfo.Country = HttpContext.Current.Request.QueryString["Country"]; objLocInfo.CountryCode = HttpContext.Current.Request.QueryString["Country"]; } if (HttpContext.Current.Request.QueryString["Unit"] != null) { objServiceInfo.ServiceName = HttpContext.Current.Request.QueryString["Unit"]; } if (HttpContext.Current.Request.QueryString["Placename"] != null) { objLocInfo.searchLocation = HttpContext.Current.Request.QueryString["Placename"]; //Clearing off datapoint object in case search crtieria is given in query string objDataPointInfo = null; objLocInfo.DataPointInfo = null; //HttpContext.Current.Session["objDataPointInfo"] = null; } if (HttpContext.Current.Request.QueryString["Latitude"] != null && HttpContext.Current.Request.QueryString["Longitude"] != null) { objLocInfo.latitude = Convert.ToDouble(HttpContext.Current.Request.QueryString["Latitude"]); objLocInfo.longitude = Convert.ToDouble(HttpContext.Current.Request.QueryString["Longitude"]); if (HttpContext.Current.Request.QueryString["Placename"] == null) objLocInfo.placeName = "Lat: " + objLocInfo.latitude + " Long: " + objLocInfo.longitude; //Clearing off datapoint object in case search crtieria is given in query string objDataPointInfo = null; objLocInfo.DataPointInfo = null; // HttpContext.Current.Session["objDataPointInfo"] = null; } }
void RewriteModule_BeginRequest(object sender, EventArgs e) { RewriteModuleSectionHandler cfg = (RewriteModuleSectionHandler)ConfigurationManager.GetSection("modulesSection/RewriteModule"); objSvcInfo = new ServiceInfo(); // module is turned off in web.config if (!cfg.RewriteOn) return; string path = HttpContext.Current.Request.Path; // there is nothing to process if (path.Length == 0) return; string lastsegment = path.Substring(path.LastIndexOf('/') + 1); if (!lastsegment.Contains('.') && !path.ToLower().Contains("webservice")) { path += "/default.aspx"; //HttpContext.Current.Response.Redirect(path); } //For aspx page requests that do not have the pubname,add it in the correct format if (path.Contains(".aspx")) { if (!((path.Contains("pub/")) || (path.Contains("Pub/")))) { int i = path.LastIndexOf("/"); string defaultPubName = ConfigurationManager.AppSettings.Get("defaultPub").ToString(); string newpath = cfg.RewriteBase + "Pub/" + defaultPubName + path.Substring(i); path = newpath; // save rewritten path with pubname as original to HttpContext for further use HttpContext.Current.Items.Add("OriginalUrl", path); //Redirect to new path if (HttpContext.Current.Request.QueryString.Count > 0) HttpContext.Current.Response.Redirect(path + "?" + HttpContext.Current.Request.QueryString.ToString()); else HttpContext.Current.Response.Redirect(path); } else { if (!lastsegment.Contains('.') && !path.ToLower().Contains("webservice")) { if (HttpContext.Current.Request.QueryString.Count == 0) HttpContext.Current.Response.Redirect(path); } // save original path to HttpContext for further use HttpContext.Current.Items.Add( "OriginalUrl",HttpContext.Current.Request.RawUrl); } } // load rewriting rules from web.config // and loop through rules collection until first match XmlNode rules = cfg.XmlSection.SelectSingleNode("rewriteRules"); foreach (XmlNode xml in rules.SelectNodes("rule")) { try { Regex re = new Regex(cfg.RewriteBase + xml.Attributes["source"].InnerText, RegexOptions.IgnoreCase); Match match = re.Match(path); if (match.Success) { //SOCB 3-Feb-2012 for mobile pages redirection - Abhijit if (!path.Contains("Mobile")) { bool isMobileRequest = isMobileBrowser();//HttpContext.Current.Request.Browser.IsMobileDevice; string fullSite = ""; if (HttpContext.Current.Request.Cookies["fullsite"] != null) { fullSite = (HttpContext.Current.Request.Cookies["fullsite"].Value ?? "").ToString(); } if ((!isMobileRequest && string.IsNullOrWhiteSpace(fullSite)) || (isMobileRequest && fullSite == "1")) { path = re.Replace(path, xml.Attributes["destination"].InnerText); } else { path = re.Replace(path, xml.Attributes["mobdest"].InnerText); } } else { path = re.Replace(path, xml.Attributes["mobdest"].InnerText); } //EOCB 3-Feb-2012 for mobile pages redirection - Abhijit if (path.Length != 0) { // check for QueryString parameters if (HttpContext.Current.Request.QueryString.Count != 0) { // if there are Query String papameters // then append them to current path string sign = (path.IndexOf('?') == -1) ? "?" : "&"; { path = path + sign + HttpContext.Current.Request.QueryString.ToString(); } } // new path to rewrite to string rew = cfg.RewriteBase + path; // rewrite and save for future use HttpContext.Current.Items.Add("RedirectedUrl", rew); HttpContext.Current.RewritePath(rew); } return; } } catch (Exception ex) { throw (new Exception("Incorrect rule.", ex)); } } return; }
public bool AddToFavorites(string strFavName) { //Update the Dt Favorites Datatable in session ObjUserInfo = (UserInfo)HttpContext.Current.Session["objUserInfo"]; //Location Info object - moved code here - trans message change objLocationinfo = (LocationInfo)HttpContext.Current.Session["objLocationInfo"]; if (ObjUserInfo != null) { //Check if the Newly Added Key allreeady Exists in datatable //check whether the the Dictionary key exists in Datatable var res = from p in ObjUserInfo.DtFavorites.AsEnumerable() where p[Constants.FAV_FAVORITENAME].Equals(strFavName) select p[Constants.FAV_FAVORITENAME]; //when no matach found if (res.ToList().Count == 1) { isFavoriteAdded = false; HttpContext.Current.Session["ErrorMessage"] = getTranslatedText(Constants.FAVORITE_UPDATE_DUPLICATE, objLocationinfo.ServiceInfo.Culture) + strFavName + getTranslatedText(Constants.GENERIC_ALREADYEXISTS, objLocationinfo.ServiceInfo.Culture); } else { //Fetch all the Values from Session isFavoriteAdded = true; //Check if the Object is null if (ObjUserInfo != null) { dtTemp = ObjUserInfo.DtFavorites; dr = dtTemp.NewRow(); //Take the User Entered Favorite name dr[Constants.FAV_Key] = strFavName.Trim(); dr[Constants.FAV_FAVORITENAME] = strFavName.Trim(); //Fetch Id from LocationInfo Object if (objLocationinfo != null) { //Fetch the Datapoint Info from Location Info itself objDataPointInfo = objLocationinfo.DataPointInfo; //Fetch the Service Info from Location Info itself objServiceInfo = objLocationinfo.ServiceInfo; dr[Constants.FAV_ALTITUDE] = objDataPointInfo.altitude;//Altitude dr[Constants.FAV_LATITUDE] = objLocationinfo.latitude;//Place - Latitude dr[Constants.FAV_LONGITUDE] = objLocationinfo.longitude;//Place - Longitiude dr[Constants.FAV_PLACENAME] = objLocationinfo.placeName;//PlaceName dr[Constants.FAV_PLACEID] = objLocationinfo.placeID;//Place ID dr[Constants.FAV_SERVICENAME] = objServiceInfo.ServiceName;//ServieName dr[Constants.FAV_MODULENAME] = objServiceInfo.Module;//ModuleName } //add the New Row to DtFavorites dtTemp.Rows.Add(dr); ObjUserInfo.DtFavorites = dtTemp; //Add the Userinfo Back to Sessions HttpContext.Current.Session["ObjUserInfo"] = ObjUserInfo; } } } return isFavoriteAdded; }
public void setDefaultLoc() { try { IDictionary dict = null; if (HttpContext.Current.Session != null && HttpContext.Current.Session["AuditData"] != null) { dict = (IDictionary)HttpContext.Current.Session["AuditData"]; } objServiceInfo = (ServiceInfo)HttpContext.Current.Session["serviceInfo"]; svc = readConfig(); string defaultLoc = svc.locationSearch.defaultLocation; objLocInfo = LocationInfo.getLocationInfoObj; if (defaultLoc != "" && defaultLoc.Split(',').Count() > 1) { if (objLocInfo.placeName == null || objLocInfo.placeName == "") { objLocInfo.placeName = defaultLoc.Split(',')[0]; } if (objLocInfo.latitude == 0.0) { objLocInfo.latitude = Convert.ToDouble(defaultLoc.Split(',')[1]); } if (objLocInfo.longitude == 0.0) { objLocInfo.longitude = Convert.ToDouble(defaultLoc.Split(',')[2]); } if (dict != null) { dict["locSearchType"] = "defaultLocation"; HttpContext.Current.Session["AuditData"] = dict; } } else if ((bool)(svc.locationSearch.useIPLocation)) { HttpRequest req = HttpContext.Current.Request; //string url = "http://api.hostip.info/get_xml.php?position=true& ip=" + (req.ServerVariables["HTTP_X_FORWARDED_FOR"] ?? req.ServerVariables["REMOTE_ADDR"]); string url = "http://freegeoip.net/xml/" + ( req.ServerVariables["HTTP_X_FORWARDED_FOR"] == null ? req.ServerVariables["REMOTE_ADDR"] : req.ServerVariables["HTTP_X_FORWARDED_FOR"]); string proxyName = ConfigurationManager.AppSettings["proxyName"]; WebClient webClient = new WebClient(); webClient.Encoding = Encoding.UTF8; string username = ConfigurationManager.AppSettings["UserName"] ?? ""; string domain = ConfigurationManager.AppSettings["Domain"] ?? ""; string password = ConfigurationManager.AppSettings["Password"] ?? ""; if (username != "" && password != "") webClient.Credentials = new System.Net.NetworkCredential(username, password, domain); webClient.Headers.Add(HttpRequestHeader.UserAgent, "test"); WebProxy proxy = new WebProxy(proxyName, true); if (username != "" && password != "") proxy.Credentials = new System.Net.NetworkCredential(username, password, domain); webClient.Proxy = proxy; try { string xml = webClient.DownloadString(url); XmlDocument xdoc = new XmlDocument(); xdoc.LoadXml(xml); DataSet dsTest = new DataSet(); dsTest.ReadXml(new XmlNodeReader(xdoc)); if (dsTest != null && dsTest.Tables.Count > 0) { //if (dsTest.Tables.Contains("Hostip") && dsTest.Tables["Hostip"].Rows.Count > 0) //{ // if (dsTest.Tables["Hostip"].Rows[0]["countryAbbrev"].ToString() != "XX") // { // objLocInfo.placeName = dsTest.Tables["Hostip"].Rows[0]["name"].ToString().IndexOf(',') > 0 ? dsTest.Tables["Hostip"].Rows[0]["name"].ToString().Split(',')[0] : dsTest.Tables["Hostip"].Rows[0]["name"].ToString(); // objLocInfo.CountryCode = dsTest.Tables["Hostip"].Rows[0]["countryAbbrev"].ToString(); // } //} //if (dsTest.Tables.Contains("point") && dsTest.Tables["point"].Rows.Count > 0) //{ // string lnglat = dsTest.Tables["point"].Rows[0]["coordinates"].ToString(); // if (lnglat != "") // { // objLocInfo.latitude = Double.Parse(lnglat.Split(',')[1].ToString()); // objLocInfo.longitude = Double.Parse(lnglat.Split(',')[0].ToString()); // } //} if (dsTest.Tables[0].Rows.Count > 0) { objLocInfo.placeName = dsTest.Tables[0].Rows[0]["City"].ToString(); objLocInfo.CountryCode = dsTest.Tables[0].Rows[0]["CountryCode"].ToString(); objLocInfo.latitude = Double.Parse(dsTest.Tables[0].Rows[0]["Latitude"].ToString()); objLocInfo.longitude = Double.Parse(dsTest.Tables[0].Rows[0]["Longitude"].ToString()); } } if (dict != null && objLocInfo.CountryCode != "") { dict["locSearchType"] = "UserIP"; HttpContext.Current.Session["AuditData"] = dict; } } catch (Exception ex) { AgriCastException currEx = new AgriCastException(GetServiceDetails(), ex); AgriCastLogger.Publish(currEx, AgriCastLogger.LogType.Error); } } } catch (Exception ex) { AgriCastException currEx = new AgriCastException(GetServiceDetails(), ex); AgriCastLogger.Publish(currEx, AgriCastLogger.LogType.Error); HttpContext.Current.Session["ErrorMessage"] = util.getTransText(Constants.TOOLBAR_DEFAULTLOCATION) + " : " + ex.Message.ToString(); } }
private string TranslatedText(string label) { if (objSvcInfo == null) objSvcInfo = (ServiceInfo)Session["serviceInfo"]; objPopPresenter = new PopupPresenter(this); objPopPresenter.getTranslatedText(label, objSvcInfo.Culture); return strTransText; }
string TranslatedText(string label) { if (objSvcInfo == null) objSvcInfo = (ServiceInfo)Session["serviceInfo"]; objAgriPresenter.getTranslatedText(label, objSvcInfo.Culture); return strTranslatedText; }
public void GetWindIconSeries(string allign) { try { objSvcInfo = (ServiceInfo)HttpContext.Current.Session["serviceInfo"]; /*Wind Icon as a Sepearate component -- BEGIN*/ //objIChartIcon.dsSeriesData = objSvc.GetTableSeries(allign, controlName); objIChartIcon.dsSeriesData = objSvc.getWindIconSeries(controlName); /*Wind Icon as a Sepearate component -- END*/ } catch (Exception ex) { AgriCastException currEx = new AgriCastException(objSvcPre.GetServiceDetails(), ex); AgriCastLogger.Publish(currEx, AgriCastLogger.LogType.Error); HttpContext.Current.Session["ErrorMessage"] = objComUtil.getTransText(Constants.GEN_LOADSERIES_FALURE) + " : " + ex.Message.ToString(); } }
protected void Page_Load(object sender, EventArgs e) { try { if (Session == null || Session["serviceInfo"] == null) { objSvcInfo = new ServiceInfo(); } else { objSvcInfo = (ServiceInfo)Session["serviceInfo"]; } objAgriPresenter = new AgriInfoPresenter(this, Name); if (HttpContext.Current != null) { objLocInfo = LocationInfo.getLocationInfoObj; } else { objLocInfo = new LocationInfo(); } if (Session["CurrentCulture"] != null) { NewCulture = new CultureInfo(Session["CurrentCulture"].ToString()); } else { /* IM01289657 - New Agricast - Agriinfo - date formatting - Jerrey - Start */ if (string.IsNullOrWhiteSpace(objSvcInfo.Culture)) NewCulture = new CultureInfo("en-GB"); else NewCulture = new CultureInfo(objSvcInfo.Culture); // NewCulture = new CultureInfo("en-GB"); /* IM01289657 - New Agricast - Agriinfo - date formatting - Jerrey - End */ } if (Session["PreviousCulture"] != null) { OldCulture = new CultureInfo(Session["PreviousCulture"].ToString()); } else { OldCulture = new CultureInfo("en-GB"); } //Set the datetime formats //Add for when change Pub, the data formate will not correct - 20140615 - Start url = HttpContext.Current.Request.Url.ToString().ToLower(); url = url.Remove(url.LastIndexOf(".aspx")); root = url.Remove(url.LastIndexOf('/')).Substring(url.IndexOf("pub/") + 4); HttpCookie agriInfoCookiePub = Request.Cookies["AgriInfo_HistoryData_ECMWF"]; if (agriInfoCookiePub != null && Server.UrlDecode(agriInfoCookiePub.Value).ToString() != "") { string[] cookValues = Server.UrlDecode(agriInfoCookiePub.Value).Split('#'); if (cookValues[8] != root) { if (string.IsNullOrWhiteSpace(objSvcInfo.Culture)) { NewCulture = new CultureInfo("en-GB"); } else { NewCulture = new CultureInfo(objSvcInfo.Culture); } OldCulture = new CultureInfo("en-GB"); Session["PreviousCulture"] = null; Session["CurrentCulture"] = null; } } //Add for when change Pub, the data formate will not correct - 20140615 - END oldinfo = OldCulture.DateTimeFormat; newinfo = NewCulture.DateTimeFormat; if (!ExcelFlag) { //if (!IsPostBack) //{ // PopulateAltitude(); //} readDate(); setControlText(); PopulateDropDowns(); loadSeries(); HttpCookie agriInfoCookie = Request.Cookies["AgriInfo_" + objSvcInfo.Module]; if (agriInfoCookie != null && agriInfoCookie.Value.ToString() != "") { DeserializeAgriInfoCookieString(Server.UrlDecode(agriInfoCookie.Value)); } } /*3.1 UC – BodenWasser Modell - display webpage as IFrame - Jerrey - Start*/ if (objSvcInfo.Moss == "true" && objSvcInfo.Module.ToLower() == "watermodel") { if (Session["IAgriInfo"] != null) { objAgriInfo = (Dictionary<string, string>)Session["IAgriInfo"]; } hdnSeries.Value = "gdd_cb_WaterModel"; hdnSeries_ValueChanged("gdd_cb_WaterModel"); hApply_Click(sender, e); } /*3.1 UC – BodenWasser Modell - display webpage as IFrame - Jerrey - End*/ } catch (Exception ex) { AgriCastException currEx = new AgriCastException(objSvcPre.GetServiceDetails(), ex); AgriCastLogger.Publish(currEx, AgriCastLogger.LogType.Error); HttpContext.Current.Session["ErrorMessage"] = TranslatedText(Constants.GENERIC_ERRORONPAGE) + ":" + ex.Message.ToString(); } }
public void CreateTables(string name, string allign, string aggregation, string datasource, int start, int end) { objSvcInfo = (ServiceInfo)HttpContext.Current.Session["serviceInfo"]; //GetcompleteSeriesList(allign); /*Wind Icon as a Sepearate component -- BEGIN*/ //GetTableSeries(allign); GetWindIconSeries(allign); /*Wind Icon as a Sepearate component -- END*/ objIChartIcon.dtTableSeries = objIChartIcon.dsSeriesData.Tables[0]; //To change first column as based on the chosen unit objIChartIcon.dtTableSeries = objSvcPre.ChangeUnits(objIChartIcon.dtTableSeries, objSvcInfo.Unit, objSvcInfo.WUnit); /*Wind Icon as a Sepearate component -- BEGIN*/ //No Legend Needed for wind icons // objIChartIcon.dtTableLegends = objIChartIcon.dsSeriesData.Tables[1]; /*Wind Icon as a Sepearate component -- END*/ GetSeriesData(objIChartIcon.dtTableSeries, aggregation, datasource, start, end, sHours, eHours); //Condition to check for the availability of the data from database if (objIChartIcon.dtSeries != null) { objIChartIcon.dtByDays = objIChartIcon.dtSeries; DataColumn dc = new DataColumn(); dc.ColumnName = getTranslatedText(FIRSTCOLNAME, objSvcInfo.Culture); dc.DefaultValue = null; objIChartIcon.dtByDays.Columns.Add(dc); int LastColIndex = objIChartIcon.dtByDays.Columns.Count - 1; for (int i = 0; i < objIChartIcon.dtByDays.Rows.Count; i++) { DateTime Date = Convert.ToDateTime(objIChartIcon.dtByDays.Rows[i][0].ToString()); objIChartIcon.dtByDays.Rows[i][LastColIndex] = Date.Hour; } objIChartIcon.alSeries = new ArrayList(); for (int i = 1; i < LastColIndex; i++) { //indices in columns in table series //0 - Name , 1 - PallateName ,2 - AggregationFunction , 3 -Transtag //in case of wind icons , no pallete defined in series //0 - Name , 1 - AggregationFunction , 2 -Transtag objIChartIcon.alSeries.Add(objIChartIcon.dtByDays.Columns[i].ColumnName.ToString() + "," + ' ' + "," + objIChartIcon.dtTableSeries.Rows[i - 1][0].ToString() + "," + objIChartIcon.dtTableSeries.Rows[i - 1][2].ToString()); } } }
protected void Page_prerender(object sender, EventArgs e) { if (!ExcelFlag) { setValues(); if (objSvcInfo == null) objSvcInfo = (ServiceInfo)Session["serviceInfo"]; //change altitude value based on culture //if (txtAltitude.Value != string.Empty) //{ // //if ((objSvcInfo.Culture.ToLower().Equals("en-us", StringComparison.CurrentCultureIgnoreCase) || objSvcInfo.Culture.ToLower().Equals("sl-SI", StringComparison.CurrentCultureIgnoreCase))) //{ // if (Session["PreviousCulture"] != null) // { // if (Session["PreviousCulture"].ToString().ToLower() != "en-us" && Session["PreviousCulture"].ToString().ToLower() != "sl-si") // txtAltitude.Value = objComUtil.ConvertValueMetrics(txtAltitude.Value, "m-ft"); // } //} //else //{ // if (Session["PreviousCulture"] != null) // { // if (Session["PreviousCulture"].ToString().ToLower() == "en-us" || Session["PreviousCulture"].ToString().ToLower() == "sl-si") // txtAltitude.Value = objComUtil.ConvertValueMetrics(txtAltitude.Value, "ft-m"); // } //} //} //Change altitude value based on units if (objSvcInfo.Unit.ToLower().Equals("imperial", StringComparison.CurrentCultureIgnoreCase)) { /*IM01288866 - New Agricast - altitude adjustement taking feet and not meters-Begin*/ //if (txtAltitude.Value != string.Empty && lblMasl.InnerText != Constants.FEET_ASL) if (txtAltitude.Value != string.Empty && lblMasl.InnerText == objComUtil.getTransText(Constants.M_ASL)) txtAltitude.Value = objComUtil.ConvertValueMetrics(txtAltitude.Value, "m-ft"); /*IM01288866 - New Agricast - altitude adjustement taking feet and not meters-End*/ /*IM01258137 - New Agricast - Translation - can't translate "{.More}" - BEGIN */ //lblMasl.InnerText = Constants.FEET_ASL; lblMasl.InnerText = TranslatedText(Constants.FEET_ASL); /*IM01258137 - New Agricast - Translation - can't translate "{.More}" - END */ } else if (objSvcInfo.Unit.ToLower().Equals("metric", StringComparison.CurrentCultureIgnoreCase)) { /*IM01288866 - New Agricast - altitude adjustement taking feet and not meters-Begin*/ //if (txtAltitude.Value != string.Empty && lblMasl.InnerText != Constants.M_ASL) if (txtAltitude.Value != string.Empty && lblMasl.InnerText == objComUtil.getTransText(Constants.FEET_ASL)) txtAltitude.Value = objComUtil.ConvertValueMetrics(txtAltitude.Value, "ft-m"); /*IM01288866 - New Agricast - altitude adjustement taking feet and not meters-End*/ /*IM01258137 - New Agricast - Translation - can't translate "{.More}" - BEGIN */ //lblMasl.InnerText = Constants.M_ASL; lblMasl.InnerText = TranslatedText(Constants.M_ASL); /*IM01258137 - New Agricast - Translation - can't translate "{.More}" - END */ } //set the culture info //Commented by Rahul //VariantCulture = new CultureInfo(objSvcInfo.Culture); //Added by Rahul if (objSvcInfo.Culture != "en-GB") { VariantCulture = new CultureInfo(objSvcInfo.Culture); } else { VariantCulture = new CultureInfo("en-US"); } HttpCookie agriInfoCookie = Request.Cookies["AgriInfo_" + objSvcInfo.Module]; if (agriInfoCookie == null || agriInfoCookie.Value.ToString() == "") { PopulateAltitude(); } else { string[] values = Server.UrlDecode(agriInfoCookie.Value).Split('#'); string[] lat = Server.UrlDecode(values[7]).Split('&'); if (objLocInfo.latitude.ToString() != lat[0] || objLocInfo.longitude.ToString() != lat[1]) { PopulateAltitude(); } } checkFields(); if (ddlDuration.SelectedValue.ToString() == "to_date") { divEnd.Attributes.Add("class", "show"); /* IM01289657 - New Agricast - Agriinfo - date formatting - Jerrey - Start */ if (txtEndDate.Value != "") txtEndDate.Value = ShortMonthDayPattern(oldinfo, newinfo, txtEndDate.Value); /* IM01289657 - New Agricast - Agriinfo - date formatting - Jerrey - End */ } else { txtEndDate.Value = ""; divEnd.Attributes.Add("class", "hide"); } //checkFields();//Move up for Date Issue - 20140612 if (hdnSeries.Value != "" && ValidateFields() && AggregationValid) hdnSeries_ValueChanged(hdnSeries.Value.ToString()); if (hdnExpandCollapse.Value != "") { string[] ExpandedNodes = hdnExpandCollapse.Value.Split(';'); foreach (string node in ExpandedNodes) { if (node.Contains("imgSeriesNode")) { string divID = "Div" + node.Substring(13); HtmlGenericControl divCntrl = (HtmlGenericControl)common.FindControlRecursive(this, divID); if (divCntrl != null) { divCntrl.Attributes.Add("class", "show"); Image imgCntrl = (Image)common.FindControlRecursive(this, node); imgCntrl.ImageUrl = BOXMINUS; imgCntrl.Attributes.Add("alt", "-"); } } } } if (hdnSeries.Value != null) { string[] CheckedNodes = hdnSeries.Value.Split(';'); foreach (string node in CheckedNodes) { CheckBox cb = (CheckBox)common.FindControlRecursive(this, node); if (cb != null) { cb.Checked = true; } } } } // if (ExcelFlag) else { ExportData(); } CreateAgriInfoCookie(); //convert the values of the date textboxes into the selected culture if (txtstartDate.Value != "") { //txtstartDate.Value = (DateTime.Parse(txtstartDate.Value)).ToString("MM/dd/yyyy", VariantCulture); //Commented by Rahul //txtstartDate.Value = (GetDateInCorrectFormatGetDate(txtstartDate.Value, false)).ToString(VariantCulture.DateTimeFormat.ShortDatePattern.ToString(), VariantCulture); txtstartDate.Value = ShortMonthDayPattern(oldinfo, newinfo, txtstartDate.Value); //Added by Rahul //txtstartDate.Value = GetDateInCorrectFormat(txtstartDate.Value.ToString(), false); //Add for IM01848073:New Agricast - Agriinfo - error in HU - start if (txtstartDate.Value.EndsWith("/") && newinfo.LongDatePattern.ToString() == "yyyy. MMMM d.") { txtstartDate.Value = txtstartDate.Value.Replace("/", "."); } //Add for IM01848073:New Agricast - Agriinfo - error in HU - end } if (txtPlantingDate != null && txtPlantingDate.Value != "") { //txtPlantingDate.Value = (DateTime.Parse(txtPlantingDate.Value)).ToString("MM/dd/yyyy", VariantCulture); txtPlantingDate.Value = ShortMonthDayPattern(oldinfo, newinfo, txtPlantingDate.Value); //Add for IM01848073:New Agricast - Agriinfo - error in HU - start if (txtPlantingDate.Value.EndsWith("/") && newinfo.LongDatePattern.ToString() == "yyyy. MMMM d.") { txtPlantingDate.Value = txtPlantingDate.Value.Replace("/", "."); } //Add for IM01848073:New Agricast - Agriinfo - error in HU - end } //Add for IM01848073:New Agricast - Agriinfo - error in HU - start if (txtEndDate.Value.EndsWith("/") && newinfo.LongDatePattern.ToString() == "yyyy. MMMM d.") { txtEndDate.Value = txtEndDate.Value.Replace("/", "."); } //Add for IM01848073:New Agricast - Agriinfo - error in HU - end Session["PreviousCulture"] = Session["CurrentCulture"]; }
public DataTable getTableDataForExcelExport(string allign, string name, IRuleSets IRobj) { try { objSvcInfo = (ServiceInfo)HttpContext.Current.Session["serviceInfo"]; strCulCode = objSvcInfo.Culture; PaletteMap objPm; DataSet dsTblSeries = new DataSet(); DataTable dtTableSeries = new DataTable(); DataTable dtSeriesData = new DataTable(); DataSet dsTable = new DataSet(); DataTable dt; string strTblAttributes = objSvc.ReadAllignment(allign, name); int numOfDays = Convert.ToInt32(strTblAttributes.Split(',')[1]); string datasource = strTblAttributes.Split(',')[2]; string aggregation = strTblAttributes.Split(',')[5]; int start = Convert.ToInt32(strTblAttributes.Split(',')[3]); int end = Convert.ToInt32(strTblAttributes.Split(',')[4]); //To handle current date //end = (end > 0 ? end - 1 : end + 1); string ruleset = strTblAttributes.Split(',')[6]; string pallette = strTblAttributes.Split(',')[7]; string Nodename = strTblAttributes.Split(',')[8]; List<string[]> alSeriesLegend = objSvc.getNodeList(allign); dsTblSeries = objSvc.GetTableSeries(allign, name); dtTableSeries = dsTblSeries.Tables[0]; //To change first column as based on the chosen unit dtTableSeries = objSvcPre.ChangeUnits(dtTableSeries, objSvcInfo.Unit, objSvcInfo.WUnit); if (ruleset == string.Empty || ruleset == "") { dtSeriesData = objTblSvc.GetSeriesData(dtTableSeries, aggregation, datasource, start, end, sHours, eHours); dt = dtSeriesData.Copy(); dt.TableName = getTranslatedText(Nodename, strCulCode); dt.Columns[0].ColumnName = getTranslatedText(dt.Columns[0].ColumnName, strCulCode); for (int i = 1; i < dt.Columns.Count; i++) { int count = 1; string ColName = getTranslatedText(dtTableSeries.Rows[i - 1]["trnsTag"].ToString(), strCulCode); for (int j = 0; j < dt.Columns.Count; j++) { if (dt.Columns[j].ColumnName == ColName) { ColName = ColName + "_" + count.ToString(); } } dt.Columns[i].ColumnName = ColName; } return dt; } else { if (IRobj != null) { IRule = IRobj; } IRule.DtInput.Clear(); IRule.DtOutput.Clear(); GetRulesetData(ruleset, IRule); dtSeriesData = objTblSvc.GetSeriesData(RulesetList, aggregation, datasource, start, end, sHours, eHours); dt = dtSeriesData.Copy(); dt.TableName = name; dt.Columns.Add("Hour"); int LastColIndex = dt.Columns.Count - 1; for (int i = 0; i < dt.Rows.Count; i++) { DateTime Date = Convert.ToDateTime(dt.Rows[i][0].ToString()); dt.Rows[i][LastColIndex] = Date.Hour; } IRule.DtInput = dt; IRule.StartDate = System.DateTime.Today.AddDays(start); IRule.EndDate = System.DateTime.Today.AddDays(end); if (IRule.StartDate > IRule.EndDate) { DateTime tmp = IRule.StartDate; IRule.StartDate = IRule.EndDate; IRule.EndDate = tmp; } //if (start < end) //{ // IRule.StartDate = System.DateTime.Today.AddDays(start); // IRule.EndDate = System.DateTime.Today.AddDays(end); //} //else //{ // IRule.StartDate = System.DateTime.Today.AddDays(end); // IRule.EndDate = System.DateTime.Today.AddDays(start); //} GetRulesetData(ruleset, IRule); DataTable dtOut = IRule.DtOutput.Copy(); //dtOut.Rows.Add(DateTime.Today.ToShortDateString(), "1", "2", "X","ResLegRain,ResLegWind"); //dtOut.Rows.Add(DateTime.Today.ToShortDateString(), "1", "2", "X","ResLegRain,ResLegWind"); //create pallette objPm = createPallette(pallette); for (int i = 0; i < dtOut.Rows.Count; i++) { //get the recommendation text in case it exists //if not, get the color name if (dtOut.Rows[i][2].ToString() != string.Empty) dtOut.Rows[i][2] = objPm.getColor(double.Parse(dtOut.Rows[i][2].ToString()), name, "excel") == string.Empty ? System.Drawing.ColorTranslator.FromHtml(objPm.getColor(double.Parse(dtOut.Rows[i][2].ToString()), name)).Name : getTranslatedText(objPm.getColor(double.Parse(dtOut.Rows[i][2].ToString()), name, "excel"), strCulCode); //get the restrictions if (dtOut.Rows[i][3].ToString() != string.Empty) { //Get the Restrictions string[] RestrictionLists = null; if (!string.IsNullOrEmpty(dtOut.Rows[i][4].ToString())) { RestrictionLists = dtOut.Rows[i][4].ToString().Split(','); string restriction = ""; foreach (string restrictionText in RestrictionLists) { restriction = restriction + getTranslatedText(restrictionText, strCulCode) + ","; } dtOut.Rows[i][4] = restriction.Remove(restriction.LastIndexOf(',')); } } } //remove the value column as it shoudnt be displayed in the excel dtOut.Columns.Remove("value"); dtOut.AcceptChanges(); //Change the column names as per culture selected for (int j = 0; j < dtOut.Columns.Count; j++) { dtOut.Columns[j].ColumnName = dtOut.Columns[j].ColumnName != "ColorCode" ? getTranslatedText(dtOut.Columns[j].ColumnName.ToString(), strCulCode) : getTranslatedText("Recommendation", strCulCode); } //Set the table name that comes up as sheet name dtOut.TableName = getTranslatedText(Nodename, strCulCode); return dtOut; } } catch (Exception ex) { AgriCastException currEx = new AgriCastException(objSvcPre.GetServiceDetails(), ex); AgriCastLogger.Publish(currEx, AgriCastLogger.LogType.Error); return null; } }
void CreateAgriInfoCookie() { HttpSessionState Session = HttpContext.Current.Session; if (HttpContext.Current != null) Session = HttpContext.Current.Session; if (Session == null || Session["serviceInfo"] == null) { objSvcInfo = new ServiceInfo(); } else { objSvcInfo = (ServiceInfo)Session["serviceInfo"]; } HttpCookie AgriInfoCookie = new HttpCookie(("AgriInfo_" + objSvcInfo.Module), SerializeAgriInfoCookieString()); AgriInfoCookie.Expires = DateTime.Now.AddDays(365); Response.Cookies.Add(AgriInfoCookie); }
/* SOCB - Alignment Issue - Jerrey - SOCB*/ public int ReadChartWidth(string allign) { try { objSvcInfo = (ServiceInfo)HttpContext.Current.Session["serviceInfo"]; string settings = objSvc.ReadAllignment(allign, controlName); return 0; } catch (Exception ex) { AgriCastException currEx = new AgriCastException(objSvcPre.GetServiceDetails(), ex); AgriCastLogger.Publish(currEx, AgriCastLogger.LogType.Error); HttpContext.Current.Session["ErrorMessage"] = objComUtil.getTransText(Constants.TAB_ALIGNMENT_FAILURE) + ":" + ex.Message.ToString(); } return 0; }
void populateObject() { /*Changes by jerrey - web service issue - added new condition*/ //&& objLocInfo != null && objDatapoint != null) if (HttpContext.Current != null) { objLocInfo = (LocationInfo)HttpContext.Current.Session["objLocationInfo"]; //Web Service Issue if (objLocInfo.DataPointInfo != null && objLocInfo.ServiceInfo != null) { objDatapoint = objLocInfo.DataPointInfo; objSvcInfo = objLocInfo.ServiceInfo; } else { objDatapoint = new DataPointInfo(); objLocInfo = new LocationInfo(); objSvcInfo = new ServiceInfo(); objDatapoint.SunRise = dTSunrise; objDatapoint.SunSet = dTSunset; objDatapoint.stationLatitude = dLatitude; objDatapoint.stationLongitude = dLongitude; objDatapoint.altitude = altitude; objDatapoint.NearbyPointSettings.MaxAllowedDistance = maxDist; objDatapoint.NearbyPointSettings.MaxAllowedAltitude = maxAlt; objSvcInfo.Culture = strCultureCode; objSvcHandler.setSvcHandlerWebSvcValues(strServiceName, strModuleName); //Web service issue fix objLocInfo.DataPointInfo = objDatapoint; HttpContext.Current.Session["objDataPointInfo"] = objDatapoint; objLocInfo.ServiceInfo = objSvcInfo; HttpContext.Current.Session["objLocationInfo"] = objLocInfo; } } }
public void GetcompleteSeriesList(string allign) { try { objSvcInfo = (ServiceInfo)HttpContext.Current.Session["serviceInfo"]; Itable.alSeriesLegend = objSvc.getNodeList(allign); } catch (Exception ex) { AgriCastException currEx = new AgriCastException(objSvcPre.GetServiceDetails(), ex); AgriCastLogger.Publish(currEx, AgriCastLogger.LogType.Error); HttpContext.Current.Session["ErrorMessage"] = objComUtil.getTransText(Constants.GEN_LOADSERIES_FALURE) + " : " + ex.Message.ToString(); } }
public void ExportToExcel(DataSet source) { if (HttpContext.Current.Session == null || HttpContext.Current.Session["serviceInfo"] == null) { objServiceInfo = new ServiceInfo(); } else { objServiceInfo = (ServiceInfo)HttpContext.Current.Session["serviceInfo"]; } objLocInfo = LocationInfo.getLocationInfoObj; try { if (source != null) { String fileName = HttpContext.Current.Request.PhysicalApplicationPath + "/Temp/report.xls"; System.IO.StreamWriter excelDoc; string Loc = getTranslatedText(LOC_DETAILS, getCultureCode()); excelDoc = new System.IO.StreamWriter(fileName); const string startExcelXML = "<xml version>\r\n<Workbook " + "xmlns=\"urn:schemas-microsoft-com:office:spreadsheet\"\r\n" + " xmlns:o=\"urn:schemas-microsoft-com:office:office\"\r\n " + "xmlns:x=\"urn:schemas- microsoft-com:office:" + "excel\"\r\n xmlns:ss=\"urn:schemas-microsoft-com:" + "office:spreadsheet\">\r\n <Styles>\r\n " + "<Style ss:ID=\"Default\" ss:Name=\"Normal\">\r\n " + "<Alignment ss:Vertical=\"Bottom\"/>\r\n <Borders/>" + "\r\n <Font/>\r\n <Interior/>\r\n <NumberFormat/>" + "\r\n <Protection/>\r\n </Style>\r\n " + "<Style ss:ID=\"BoldColumn\">\r\n <Font " + "x:Family=\"Swiss\" ss:Bold=\"1\"/>\r\n </Style>\r\n " + "<Style ss:ID=\"StringLiteral\">\r\n <NumberFormat" + " ss:Format=\"@\"/>\r\n </Style>\r\n <Style " + "ss:ID=\"Decimal\">\r\n <NumberFormat " + "ss:Format=\"0.0\"/>\r\n </Style>\r\n " + "<Style ss:ID=\"Integer\">\r\n <NumberFormat " + "ss:Format=\"0\"/>\r\n </Style>\r\n <Style " + "ss:ID=\"DateLiteral\">\r\n <NumberFormat " + "ss:Format=\"General Date\"/>\r\n </Style>\r\n " + "</Styles>\r\n "; const string endExcelXML = "</Workbook>"; int rowCount = 0; int sheetCount = 1; excelDoc.Write(startExcelXML); for (int i = 0; i < source.Tables.Count; i++) { /* IM01246267 - New agricast - export to excel not working - Begin*/ //Excel Sheet Name Cannot Exceed 31 characters. truncate the sheet name if it exceeds. string strSheetName = source.Tables[i].TableName; if (!string.IsNullOrEmpty(strSheetName)) { if (strSheetName.Length > 31) { strSheetName = strSheetName.Substring(0, 30) + i; } } //excelDoc.Write("<Worksheet ss:Name=\"" + source.Tables[i].TableName + "\">"); excelDoc.Write("<Worksheet ss:Name=\"" + strSheetName + "\">"); /* IM01246267 - New agricast - export to excel not working - Begin*/ excelDoc.Write("<Table>"); excelDoc.Write("<Column ss:AutoFitWidth=\"1\" ss:Width=\"108.75\" ss:Span=\"1\"/>"); //Adding the ist row in each table as the location details excelDoc.Write("<Row><Cell ss:StyleID=\"BoldColumn\"><Data ss:Type=\"String\">"); excelDoc.Write(Loc + " : " + objLocInfo.placeName + " , " + objLocInfo.latitude + " , " + objLocInfo.longitude); excelDoc.Write("</Data></Cell>"); excelDoc.Write("</Row>"); excelDoc.Write("<Row><Cell ss:StyleID=\"BoldColumn\"><Data ss:Type=\"String\">"); excelDoc.Write(""); excelDoc.Write("</Data></Cell>"); excelDoc.Write("</Row>"); excelDoc.Write("<Row>"); for (int x = 0; x < source.Tables[i].Columns.Count; x++) { excelDoc.Write("<Cell ss:StyleID=\"BoldColumn\"><Data ss:Type=\"String\">"); excelDoc.Write(source.Tables[i].Columns[x].ColumnName); excelDoc.Write("</Data></Cell>"); } excelDoc.Write("</Row>"); foreach (DataRow x in source.Tables[i].Rows) { rowCount++; //if the number of rows is > 64000 create a new page to continue output if (rowCount == 64000) { rowCount = 0; sheetCount++; excelDoc.Write("</Table>"); excelDoc.Write(" </Worksheet>"); excelDoc.Write("<Worksheet ss:Name=\"Sheet" + sheetCount + "\">"); excelDoc.Write("<Table>"); } excelDoc.Write("<Row>"); //ID=" + rowCount + " for (int y = 0; y < source.Tables[i].Columns.Count; y++) { System.Type rowType; rowType = x[y].GetType(); switch (rowType.ToString()) { case "System.String": if (y == 0 && objServiceInfo.ServiceName == "geotroll1") { var datetime = DateTime.Parse(x[y].ToString()); string XMLstring = datetime.ToString("dd/MM/yyyy"); excelDoc.Write("<Cell ss:StyleID=\"StringLiteral\">" + "<Data ss:Type=\"String\">"); excelDoc.Write(XMLstring); excelDoc.Write("</Data></Cell>"); } else { string XMLstring = x[y].ToString(); XMLstring = XMLstring.Trim(); XMLstring = XMLstring.Replace("&", "&"); XMLstring = XMLstring.Replace(">", ">"); XMLstring = XMLstring.Replace("<", "<"); excelDoc.Write("<Cell ss:StyleID=\"StringLiteral\">" + "<Data ss:Type=\"String\">"); excelDoc.Write(XMLstring); excelDoc.Write("</Data></Cell>"); } //string XMLstring = x[y].ToString(); // XMLstring = XMLstring.Trim(); // XMLstring = XMLstring.Replace("&", "&"); // XMLstring = XMLstring.Replace(">", ">"); // XMLstring = XMLstring.Replace("<", "<"); // excelDoc.Write("<Cell ss:StyleID=\"StringLiteral\">" + // "<Data ss:Type=\"String\">"); // excelDoc.Write(XMLstring); // excelDoc.Write("</Data></Cell>"); break; //case "System.DateTime": // //Excel has a specific Date Format of YYYY-MM-DD followed by // //the letter 'T' then hh:mm:sss.lll Example 2005-01-31T24:01:21.000 // //The Following Code puts the date stored in XMLDate // //to the format above // DateTime XMLDate = (DateTime)x[y]; // string XMLDatetoString = ""; //Excel Converted Date // XMLDatetoString = XMLDate.Year.ToString() + // "-" + // (XMLDate.Month < 10 ? "0" + // XMLDate.Month.ToString() : XMLDate.Month.ToString()) + // "-" + // (XMLDate.Day < 10 ? "0" + // XMLDate.Day.ToString() : XMLDate.Day.ToString()) + // "T" + // (XMLDate.Hour < 10 ? "0" + // XMLDate.Hour.ToString() : XMLDate.Hour.ToString()) + // ":" + // (XMLDate.Minute < 10 ? "0" + // XMLDate.Minute.ToString() : XMLDate.Minute.ToString()) + // ":" + // (XMLDate.Second < 10 ? "0" + // XMLDate.Second.ToString() : XMLDate.Second.ToString()) + // ".000"; // excelDoc.Write("<Cell ss:StyleID=\"DateLiteral\">" + // "<Data ss:Type=\"DateTime\">"); // excelDoc.Write(XMLDatetoString); // excelDoc.Write("</Data></Cell>"); // break; case "System.DateTime": excelDoc.Write(string.Format("<Cell ss:StyleID=\"DateLiteral\"><Data ss:Type=\"DateTime\">{0:s}</Data></Cell>", x[y])); // {0:s}={0:yyyy'-'MM'-'dd'T'HH':'mm':'ss} SortableDateTimePattern, culture independent break; case "System.Boolean": excelDoc.Write("<Cell ss:StyleID=\"StringLiteral\">" + "<Data ss:Type=\"String\">"); excelDoc.Write(x[y].ToString()); excelDoc.Write("</Data></Cell>"); break; case "System.Int16": case "System.Int32": case "System.Int64": case "System.Byte": excelDoc.Write("<Cell ss:StyleID=\"Integer\">" + "<Data ss:Type=\"Number\">"); excelDoc.Write(x[y].ToString()); excelDoc.Write("</Data></Cell>"); break; case "System.Decimal": case "System.Double": excelDoc.Write("<Cell ss:StyleID=\"Decimal\">" + "<Data ss:Type=\"Number\">"); excelDoc.Write(x[y].ToString()); excelDoc.Write("</Data></Cell>"); break; case "System.DBNull": excelDoc.Write("<Cell ss:StyleID=\"StringLiteral\">" + "<Data ss:Type=\"String\">"); excelDoc.Write(""); excelDoc.Write("</Data></Cell>"); break; default: throw (new Exception(rowType.ToString() + " not handled.")); } } excelDoc.Write("</Row>"); } excelDoc.Write("</Table>"); excelDoc.Write(" </Worksheet>"); } excelDoc.Write(endExcelXML); excelDoc.Close(); FileStream sourceFile = new FileStream(HttpRuntime.AppDomainAppPath + @"Temp\report.xls", FileMode.Open); string name = objServiceInfo.Module.ToString(); float FileSize; FileSize = sourceFile.Length; byte[] getContent = new byte[(int)FileSize]; sourceFile.Read(getContent, 0, (int)sourceFile.Length); sourceFile.Close(); HttpContext.Current.Response.ClearContent(); HttpContext.Current.Response.ClearHeaders(); HttpContext.Current.Response.Buffer = true; //HttpContext.Current.Response.ContentType = "application/ms-excel"; HttpContext.Current.Response.ContentType = "application/vnd.xls"; HttpContext.Current.Response.AddHeader("Content-Length", getContent.Length.ToString()); HttpContext.Current.Response.AddHeader("Content-Disposition", "attachment; filename=" + name + ".xls"); HttpContext.Current.Response.ContentEncoding = System.Text.Encoding.Unicode; HttpContext.Current.Response.BinaryWrite(getContent); } else { HttpContext.Current.Session["ErrorMessage"] = "No data to be exported."; } HttpContext.Current.Response.Flush(); HttpContext.Current.Response.End(); } catch (Exception ex) { AgriCastException currEx = new AgriCastException(GetServiceDetails(), ex); AgriCastLogger.Publish(currEx, AgriCastLogger.LogType.Error); HttpContext.Current.Session["ErrorMessage"] = "The following error occured while exporting data to excel: " + ex.Message.ToString(); } }