Ejemplo n.º 1
0
    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();

        }
    }
Ejemplo n.º 2
0
    /* 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();

        }
    }
Ejemplo n.º 3
0
    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();

        }
    }
Ejemplo n.º 4
0
    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;
    }
Ejemplo n.º 5
0
    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;
        }
    }
Ejemplo n.º 6
0
    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();

        }
    }