Пример #1
0
        //Method to fetch the Icon details
        public List<IconData> getWeatherIcons(DTOIcon objParam, string strControlName)
        {
            DataTable dtIconData = new DataTable();
            IconData icon;
            List<IconData> iconlist = new List<IconData>();
            try
            {
                ArrayList al = new ArrayList();
                dtIconData = objIconSvc.getIconData(objParam, strControlName);
                //al = objIconSvc.getWeatherIcons(objParam, strControlName);
                DataTable dtIconList = objIconSvc.getWeatherIconsWithTooltip(objParam, strControlName);
                DateTime startDate = DateTime.Parse(dtIconData.Rows[0][0].ToString()).Date;
                for (int j = 0; j < dtIconList.Rows.Count; j++)
                {
                    icon = new IconData();
                    string day = "";
                    string tooltip = System.Text.RegularExpressions.Regex.Replace(dtIconList.Rows[j][1].ToString(), "<.*?>", string.Empty);
                    if (objParam.iStep == 24)
                    {
                        day = startDate.AddHours(j * objParam.iStep).DayOfWeek.ToString();
                        icon.Date = day;
                        icon.IconToolTip = tooltip.Replace("{day}", day).Replace("{}", "");
                    }
                    else
                    {
                        day = startDate.AddHours(j * objParam.iStep).DayOfWeek.ToString();
                        icon.Date = startDate.AddHours(j * objParam.iStep).ToString();
                        icon.IconToolTip = tooltip.Replace("{day}", day).Replace("{}", "");

                    }
                    string IconURL = dtIconList.Rows[j]["ImageUrl"].ToString();
                    /********IM01144144 - New Agricast Webservices - icons URL - BEGIN ***************************/
                    IconURL=IconURL.Substring(IconURL.IndexOf("\\Images"));
                    //IconURL = System.Configuration.ConfigurationManager.AppSettings["WSHost"].ToString() + IconURL.Substring(IconURL.IndexOf("\\Images"));
                    IconURL = System.Configuration.ConfigurationManager.AppSettings["WSHost"].ToString() + IconURL.Substring(IconURL.IndexOf("\\") + 1);

                    //icon.IconPath = objCommonUtil.toBase64(IconURL);
                    icon.IconPath = IconURL;
                    /********IM01144144 - New Agricast Webservices - icons URL - END ***************************/
                    iconlist.Add(icon);
                }
            }
            catch (Exception ex)
            {
                AgriCastException currEx = new AgriCastException(GetServiceDetails(), ex);
                AgriCastLogger.Publish(currEx, AgriCastLogger.LogType.Error);
            }
            return iconlist;
        }
Пример #2
0
        //Returns list of icons with tooltip text.
        public DataTable getWeatherIconsWithTooltip(DTOIcon objParam, string controlName)
        {
            dtImgList = new DataTable();
            populateObject();
            objParams = objParam;
            if (HttpContext.Current != null)
            {
                getPubSettings(controlName);
            }
            objParams.headerRow = dsData.Tables["ServiceServicePageIcon"].Columns.Contains("plotColumnHeader") ? bool.Parse(dsData.Tables["ServiceServicePageIcon"].Rows[0]["plotColumnHeader"].ToString()) : true;
            dtData = getData(dsData.Tables["ServiceServicePageIconSerie"], temporalAgg, dtSource, _start, _end).Copy();
            //Error in Agricast - Reported by Jerome - Begin*/
            // DataTable dt = step != 1 ? decimate(dtData, dsData.Tables["ServiceServicePageIconSerie"], step) : dtData;
            DataTable dt = decimate(dtData, dsData.Tables["ServiceServicePageIconSerie"], step);
            //Error in Agricast - Reported by Jerome - End*/
            dt.TableName = "IconData";
            dsData.Tables.Add(dt);

            setParams(dsData);
            initSSMinutes();
            dtImgList.Columns.Add("ImageUrl");
            dtImgList.Columns.Add("TooltipText");

            rs_weather ruleset = null;
            ArrayList images = new ArrayList();
            DateTime cdate = DateTime.Now;
            cdate = new DateTime(cdate.Year, cdate.Month, cdate.Day, 0, 0, 0, 0);
            // get time offest for image placement
            int middlenight = 60 * step / 2;
            if (step == 12) middlenight = (RiseMinutes + SetMinutes) / 2;
            if (middlenight > 12 * 60) middlenight -= 12 * 60;
            if (step == 12) middlenight += step * 60; // offset the aggregated data
            DataRow dr;
            cdate = cdate.AddDays(noofdays);

            string isPrintorPDF = "";
            if (CommonUtil.IsSessionAvailable() && HttpContext.Current.Session["isPrintorPDF"] != null)
            {
                isPrintorPDF = HttpContext.Current.Session["isPrintorPDF"].ToString();
                HttpContext.Current.Session.Remove("isPrintorPDF");
            }
            for (int i = 0; i < noofdays * 24 / step; i++)
            {
                DateTime positionDate = cdate.AddMinutes(middlenight);
                bool isnight = objCommon.isNight(positionDate, objDatapoint.stationLatitude, objDatapoint.stationLongitude);
                if (i < dsData.Tables["IconData"].Rows.Count)
                {
                    dr = dsData.Tables["IconData"].Rows[i];
                    //string img = runImageRuleset(ruleset, i, isnight, dr, objParams.Width, objParams.Height, objSvcInfo.IsMobile?"gif":Constants.ICON_IMAGEFORMAT);
                    string img = runImageRuleset(ruleset, i, isnight, dr, objParams.Width, objParams.Height, isPrintorPDF != "" ? "jpeg" : Constants.ICON_IMAGEFORMAT);

                    if (img != null)
                    {
                        images.Add(img);
                    }
                }
                middlenight += step * 60;
            }

            for (int j = 0; j < dtImgList.Rows.Count; j++)
            {
                dtImgList.Rows[j]["ImageUrl"] = images[j].ToString();
            }
            return dtImgList;
        }
Пример #3
0
 public DataTable getIconData(DTOIcon objParam, string controlName)
 {
     populateObject();
     objParams = objParam;
     getPubSettings(controlName);
     dtData = getData(dsData.Tables["ServiceServicePageIconSerie"], temporalAgg, dtSource, _start, _end).Copy();
     return dtData;
 }
Пример #4
0
 //Returns the list of iocns. This is called from Mobile page
 public ArrayList getWeatherIcons(DTOIcon objParam, string controlName)
 {
     dtImgList = new DataTable();
     dtImgList = getWeatherIconsWithTooltip(objParam, controlName);
     ArrayList images = new ArrayList();
     for (int i = 0; i < dtImgList.Rows.Count; i++)
         images.Add(dtImgList.Rows[i][0].ToString());
     return images;
 }
Пример #5
0
        //public ServiceOutput getAgricastServiceData(string strToken, string xmlFeatureRequest, string strServiceID, string strModuleIDs, DateTime dStartDate, DateTime dEndDate, string strCultureCode)
        public ServiceOutput getAgricastServiceData(string strToken, string xmlFeatureRequest, string strServiceID, string strModuleIDs, string dStartDate, string dEndDate, string strCultureCode, string strUnit)
        {
            //HttpContext.Current.Session["MySessionState"] = "Try";
            WebServicePresenter objWebSvcPre = new WebServicePresenter(this);
            xmlFeatureRequest = HttpUtility.UrlDecode(xmlFeatureRequest);
            xmlFeatureRequest = HttpUtility.HtmlDecode(xmlFeatureRequest);
            DTOIcon objParam = new DTOIcon();
            DataSet ds = new DataSet();
            InitialiseOutput();

            /*** Used for Testing Webservice*/
            #region TestData
            //strToken = "agricast";
            //xmlFeatureRequest = "<FeatureRequest><Latitude>47.5</Latitude><Longitude>7.5</Longitude><Altitude>500</Altitude><MaxAltitudeDiff>200</MaxAltitudeDiff><MaxDistanceDiff>450</MaxDistanceDiff></FeatureRequest>";
            //strServiceID = "glbsip02o";
            //strModuleIDs = "vew_daily";
            //dStartDate = System.DateTime.Today.AddDays(-15).ToShortDateString();
            //dEndDate = System.DateTime.Today.AddDays(-11).ToShortDateString();
            //strCultureCode = "en-GB";
            //strUnit = "metric";

            #endregion
            /****End of Test Data****/

            /* IM01770145:New Agricast - AgricastService.svc - remove default token - Modify by Infosys-20140402-start*/
            //if (HttpUtility.HtmlDecode(strToken).ToLower() != "agricast")
            //    return so;

            strToken = HttpUtility.HtmlDecode(strToken);
            // check if the token is valid
            var validToken = Roles.FindUsersInRole(strServiceID, strToken);
            if (validToken.Length == 0)
                return so;

            /* IM01770145:New Agricast - AgricastService.svc - remove default token - Modify by Infosys-20140402-end*/

            //Deserialization of the XML file
            try
            {
                XmlDocument xdoc = new XmlDocument();
                xdoc.LoadXml(xmlFeatureRequest);

                XmlSerializer xSerializer = new XmlSerializer(typeof(FeatureRequest));
                System.IO.StringReader rdr = new StringReader(xmlFeatureRequest);
                objFR = (FeatureRequest)xSerializer.Deserialize(rdr);

                int iResultCount = 10;
                string timezone = objWebSvcPre.getTimeZoneOffset(objFR.Latitude, objFR.Longitude, (int)objFR.MaxDistanceDiff, (int)objFR.Altitude, iResultCount).ToString();
                string sunrise = objWebSvcPre.getSunrise(DateTime.Now.Date, objFR.Latitude, objFR.Longitude).ToString();
                string sunset = objWebSvcPre.getSunset(DateTime.Now.Date, objFR.Latitude, objFR.Longitude).ToString();

                Response res = new Response();
                res.FeatureRequest = objFR;
                res.Sunrise = sunrise;
                res.Sunset = sunset;
                res.TimeZoneOffset = timezone;
                so.FeatureResponse = res;

                DataTable dt = objWebSvcPre.getNeabyStations(objFR.Latitude, objFR.Longitude, (int)objFR.MaxDistanceDiff, (int)objFR.Altitude, iResultCount, HttpUtility.HtmlDecode(strCultureCode));

                stnDet.Name = dt.Rows[0]["Name"].ToString();
                stnDet.Altitude = Int32.Parse(dt.Rows[0]["Altitude"].ToString());
                stnDet.BearingDegrees = double.Parse(dt.Rows[0]["BearingDegrees"].ToString());
                stnDet.Distance = double.Parse(dt.Rows[0]["DistanceKm"].ToString());
                stnDet.Latitude = double.Parse(dt.Rows[0]["Latitude"].ToString());
                stnDet.Longitude = double.Parse(dt.Rows[0]["Longitude"].ToString());
                res.StationDetails = stnDet;
                objWebSvcPre.setServiceHandlerWebServiceValues(HttpUtility.HtmlDecode(strServiceID), "");
                DataTable dtNodes = objWebSvcPre.getNodeList(HttpUtility.HtmlDecode(strModuleIDs));
                /*Unit Implementation in Web Services - Begin*/
                if (string.IsNullOrEmpty(strUnit) || !strUnit.ToLower().Contains("imperial"))
                    /*Unit Implementation in Web Services - End*/
                    strUnit = "metric";

                for (int i = 0; i < dtNodes.Rows.Count; i++)
                {
                    switch (dtNodes.Rows[i]["Node"].ToString())
                    {
                        case "chart":
                            chart = new Chart();
                            DataTable dtChartData = new DataTable();
                            /*Unit Implementation in Web Services - Begin*/
                            dtChartData = objWebSvcPre.getChartData(stnDet.Latitude, stnDet.Longitude, (int)stnDet.Altitude, (int)objFR.MaxAltitudeDiff, (int)objFR.MaxDistanceDiff, dtNodes.Rows[i]["ModuleName"].ToString(), strServiceID, strCultureCode, strUnit);
                            /*Unit Implementation in Web Services - End*/
                            chart.ChartUrl = dtChartData.Rows[0][1].ToString();
                            chart.ModuleID = dtChartData.Rows[0][0].ToString();
                            so.Charts.Add(chart);
                            break;

                        case "icon":
                            icon = new Icons();
                            objWebSvcPre.setIconWebServiceValues(stnDet.Latitude, stnDet.Longitude, (int)stnDet.Altitude, (int)objFR.MaxAltitudeDiff, (int)objFR.MaxDistanceDiff, Convert.ToDateTime(sunrise), Convert.ToDateTime(sunset), strServiceID, dtNodes.Rows[i]["ModuleName"].ToString(), strCultureCode);
                            icon.ModuleID = dtNodes.Rows[i][1].ToString();
                            icon.IconList = objWebSvcPre.getWeatherIcons(objParam, dtNodes.Rows[i]["NodeName"].ToString());
                            so.Icons.Add(icon);
                            break;

                        case "tblDaysRows":
                            tbls = new tables();
                            tbls.tableList = new List<table>();
                            tbls.ModuleID = dtNodes.Rows[i][1].ToString();
                            tbls.tableList = objWebSvcPre.getTableData(stnDet.Latitude, stnDet.Longitude, (int)stnDet.Altitude, (int)objFR.MaxDistanceDiff, (int)objFR.MaxAltitudeDiff, this, dtNodes.Rows[i]["Node"].ToString(), dtNodes.Rows[i]["NodeName"].ToString(), strCultureCode, strServiceID, dtNodes.Rows[i]["ModuleName"].ToString(), HttpUtility.HtmlDecode(strCultureCode), strUnit);
                            so.tables.Add(tbls);
                            break;

                        case "tblSeriesRows":
                            tbls = new tables();
                            tbls.tableList = new List<table>();
                            tbls.ModuleID = dtNodes.Rows[i][1].ToString();

                            tbls.tableList = objWebSvcPre.getTableData(stnDet.Latitude, stnDet.Longitude, (int)stnDet.Altitude, (int)objFR.MaxDistanceDiff, (int)objFR.MaxAltitudeDiff, this, dtNodes.Rows[i]["Node"].ToString(), dtNodes.Rows[i]["NodeName"].ToString(), strCultureCode, strServiceID, dtNodes.Rows[i]["ModuleName"].ToString(), HttpUtility.HtmlDecode(strCultureCode), strUnit);
                            so.tables.Add(tbls);
                            break;

                        //case "nearbyDataPoint":
                        //    ds.Tables.Add(objWebSvcPre.getNeabyStations(objFR.Latitude, objFR.Longitude, (int)objFR.MaxDistanceDiff, (int)objFR.Altitude, iResultCount, HttpUtility.HtmlDecode(strCultureCode)));
                        //    ds.AcceptChanges();
                        //    break;

                        case "legend":
                            legs = new Legend();
                            legs = objWebSvcPre.getLegendData(dtNodes.Rows[i]["NodeName"].ToString());
                            so.Legends.Add(legs);
                            break;

                    }
                }
            }
            catch (Exception ex)
            {

                AgriCastException currEx = new AgriCastException(objWebSvcPre.GetServiceDetails(), ex);
                AgriCastLogger.Publish(currEx, AgriCastLogger.LogType.Error);
                // HttpContext.Current.Session["ErrorMessage"] = objComUtil.getTransText(Constants.WS_GETSVCDATA_FAILURE) + " : " + ex.Message.ToString();
            }
            finally
            {
                IDictionary dictAudit = new Hashtable();
                dictAudit["userIP"] = "";// HttpContext.Current.Request.UserHostAddress;
                dictAudit["userID"] = "";
                dictAudit["token"] = strToken;
                dictAudit["referrer"] = "none";
                /* IM01770145:New Agricast - AgricastService.svc - remove default token - Modify by Infosys-20140402-start*/
                //dictAudit["entrancePath"] = "WebService";
                dictAudit["entrancePath"] = "AgricastService - getAgricastServiceData";
                /* IM01770145:New Agricast - AgricastService.svc - remove default token - Modify by Infosys-20140402-end*/
                dictAudit["culture"] = HttpUtility.HtmlDecode(strCultureCode);
                dictAudit["sessionID"] = "";// HttpContext.Current.Session.SessionID;
                dictAudit["service"] = strServiceID;
                dictAudit["module"] = strModuleIDs;
                dictAudit["locSearchType"] = "";
                dictAudit["locSearchStringType"] = "";
                dictAudit["locSearchString"] = xmlFeatureRequest;
                dictAudit["locSearchDatasource"] = "";
                dictAudit["numOfLocs"] = 0;
                if (objFR.Latitude == 0)
                    dictAudit["searchLat"] = DBNull.Value;
                else
                    dictAudit["searchLat"] = objFR.Latitude;
                if (objFR.Longitude == 0)
                    dictAudit["searchLong"] = DBNull.Value;
                else
                    dictAudit["searchLong"] = objFR.Longitude;
                dictAudit["countryName"] = "";
                dictAudit["locName"] = "";
                dictAudit["weatherDatasource"] = "";
                dictAudit["weatherLat"] = DBNull.Value;
                dictAudit["weatherLong"] = DBNull.Value;
                dictAudit["weatherDateFrom"] = "";
                dictAudit["weatherDateTo"] = "";
                dictAudit["weatherSeries"] = "";
                dictAudit["weatherParams"] = DBNull.Value;
                objWebSvcPre.SaveServiceAuditData(dictAudit);
            }

            return so;
        }