Esempio n. 1
0
        protected void Page_Load(object sender, EventArgs e)
        {
            try
            {
              //  btnsave.Attributes.Add("onclick", "javascript:closePopup();");

                //ScriptManager.RegisterStartupScript(this, typeof(string),"focus", "self.focus();", true);
                if (HttpContext.Current.Request.QueryString.Count != 0)
                {
                    setControlText();
                    objAdvancedOptionInfo = new AdvancedOptionInfo();
                    objSeriesInfo = SeriesInfo.getSeriesInfoObject;

                    objAdvancedOptionInfo.Series = HttpContext.Current.Request.QueryString["series"];
                    objAdvancedOptionInfo.Serie = HttpContext.Current.Request.QueryString["serie"];
                    if (!IsPostBack)
                    {
                        objPopPresenter = new PopupPresenter(this);
                        objPopPresenter.GetAdvancedOptions(objAdvancedOptionInfo.Series, objAdvancedOptionInfo.Serie);

                        if (al[0][1] != "")
                        {
                            string[] AggFunctions = al[0][1].Split(',');
                            foreach (string Aggregation in AggFunctions)
                            {
                                if (Aggregation.Trim() != "")
                                    ddlAggregationFunction.Items.Add(newItem(Aggregation, Aggregation));
                            }
                            ddlAggregationFunction.DataBind();
                        }
                        else
                        {
                            lblAggregationFunction.Attributes.Add("class","hide");
                            ddlAggregationFunction.CssClass = "hide";
                        }
                        if (al[1][1].ToString() != "")
                        {
                            if (al[1][1].Trim().ToLower() == "true")
                            {
                                cbAccumulate.Checked = true;
                            }
                        }
                        else
                        {
                            lblAccumulate.Attributes.Add("class", "hide");
                            cbAccumulate.CssClass = "hide";
                        }

                        if (al[2][1].ToString() != "0" && (al[2][1].ToString() != ""))
                        {
                            int Year = Int32.Parse(al[2][1]);
                            int currYear = DateTime.Now.Year;
                            ddlYear.Items.Add("");
                            for (int i = currYear; i >= Year; i--)
                            {
                                ddlYear.Items.Add(i.ToString());
                            }
                            ddlYear.DataBind();
                        }
                        else
                        {
                            lblYearCompare.Attributes.Add("class", "hide");
                            ddlYear.CssClass = "hide";
                        }

                        if (al[3][1] != "")
                        {
                            string[] Trends = al[3][1].Split(',');
                            ddlTrends.Items.Add("");
                            foreach (string trend in Trends)
                            {
                                ddlTrends.Items.Add(newItem(trend, trend));
                            }
                            ddlTrends.DataBind();
                        }
                        else
                        {
                            ddlTrends.CssClass = "hide";
                            lblTrends.Attributes.Add("class", "hide");
                            ddlTrends.Visible = false;
                            lblTrends.Visible = false;
                        }

                        if (al[4][1] != "")
                        {
                            if (al[4][1].Trim().ToLower() != "true")
                            {
                                cbAltitude.Enabled = false;
                            }
                        }
                        else
                        {
                            lblAltitude.Attributes.Add("class", "hide");
                            cbAltitude.CssClass = "hide";
                        }

                        if (al.Count == 8)
                        {

                            if (al[5][1] != "")
                            {
                                string[] Methods = al[5][1].Split(',');
                                ddlMethod.Items.Add("");
                                foreach (string Method in Methods)
                                {
                                    ddlMethod.Items.Add(newItem(Method, Method));
                                }
                                ddlMethod.DataBind();
                            }
                            else
                            {
                                ddlMethod.CssClass = "hide";
                                lblMethod.Attributes.Add("class", "hide");
                                ddlMethod.Visible = false;
                                lblMethod.Visible = false;
                            }

                            if (al[6][1] != "")
                            {
                                txtCap.Text = al[6][1].ToString();
                            }
                            else
                            {
                                txtCap.CssClass = "hide";
                                lblCap.Attributes.Add("class", "hide");
                                txtCap.Visible = false;
                                lblCap.Visible = false;
                            }

                            if (al[7][1] != "")
                            {
                                txtBase.Text = al[7][1].ToString();
                            }
                            else
                            {
                                txtBase.CssClass = "hide";
                                lblBase.Attributes.Add("class", "hide");
                                txtBase.Visible = false;
                                lblBase.Visible = false;
                            }
                        }
                        else
                        {
                            ddlMethod.CssClass = "hide";
                            lblMethod.Attributes.Add("class", "hide");
                            ddlMethod.Visible = false;
                            lblMethod.Visible = false;
                            txtCap.CssClass = "hide";
                            lblCap.Attributes.Add("class", "hide");
                            txtCap.Visible = false;
                            lblCap.Visible = false;
                            txtBase.CssClass = "hide";
                            lblBase.Attributes.Add("class", "hide");
                            txtBase.Visible = false;
                            lblBase.Visible = false;
                        }

                        if (objSeriesInfo.SeriesList != null)
                        {
                            foreach (AdvancedOptionInfo obj in objSeriesInfo.SeriesList)
                            {
                                if ((obj.Series == objAdvancedOptionInfo.Series) && (obj.Serie == objAdvancedOptionInfo.Serie))
                                {
                                    if (obj.Aggregation.ToString() != "")
                                    ddlAggregationFunction.SelectedValue = obj.Aggregation.ToString();
                                    if(obj.Accumulate.ToString()!="")
                                    cbAccumulate.Checked = bool.Parse(obj.Accumulate.ToString());
                                    ddlYear.SelectedValue = obj.Year.ToString();
                                    if(obj.Trend.ToString()!="")
                                    ddlTrends.SelectedValue = obj.Trend.ToString();
                                    if (obj.Altitude.ToString() != "")
                                    cbAltitude.Checked = bool.Parse(obj.Altitude.ToString());
                                    if (obj.Method.ToString() != "")
                                        ddlMethod.SelectedValue = obj.Method.ToString();
                                    if (obj.Cap.ToString() != "")
                                        txtCap.Text = obj.Cap.ToString();
                                    if (obj.Base.ToString() != "")
                                        txtBase.Text = obj.Base.ToString();

                                }

                            }
                        }

                    }

                }
            }
            catch (Exception ex)
            {
                AgriCastException currEx = new AgriCastException(objSvcPre.GetServiceDetails(), ex);
                AgriCastLogger.Publish(currEx, AgriCastLogger.LogType.Error);
                HttpContext.Current.Session["ErrorMessage"] = "The page could not be loaded due to the following error: " + ex.Message.ToString();
            }
        }
Esempio n. 2
0
        void UpdateSeries(string checkedSeries)
        {
            string[] seriesList = checkedSeries.Split(';');
            dtData = ReadSeriesDetails(seriesList);
            List<string[]> alColumns = new List<string[]>();

            objSeriesInfo = SeriesInfo.getSeriesInfoObject;
            if (objSeriesInfo.SeriesList != null && !IsGDD)
            {
                foreach (AdvancedOptionInfo obj in objSeriesInfo.SeriesList)
                {
                    string addlInfo = "";
                    if (obj.Year.ToString() != string.Empty && obj.Year.ToString() != "0")
                    {
                        DataRow drNew;
                        for (int i = 0; i < dtData.Rows.Count; i++)
                        {
                            if (dtData.Rows[i]["name"].ToString().ToLower() == obj.Serie.ToLower() && dtData.Rows[i]["year"].ToString() == string.Empty
                                && "node" + dtData.Rows[i]["panel"].ToString() == obj.Series.ToString())
                            {
                                drNew = dtData.NewRow();
                                drNew["Name"] = dtData.Rows[i]["Name"];
                                drNew["trnsTag"] = dtData.Rows[i]["trnsTag"];
                                drNew["aggregationfunction"] = dtData.Rows[i]["aggregationfunction"];
                                drNew["markerType"] = dtData.Rows[i]["markerType"];
                                drNew["axisPosition"] = dtData.Rows[i]["axisPosition"];
                                drNew["gallery"] = dtData.Rows[i]["gallery"];
                                drNew["stacked"] = dtData.Rows[i]["stacked"];
                                drNew["color"] = dtData.Rows[i]["color"];
                                drNew["panel"] = dtData.Rows[i]["panel"];
                                drNew["addlInfo"] = dtData.Rows[i]["addlInfo"];
                                drNew["trnsTag"] = dtData.Rows[i]["trnsTag"];
                                drNew["year"] = obj.Year.ToString();
                                dtData.Rows.Add(drNew);
                                addlInfo = obj.Year.ToString();
                            }
                        }

                    }
                    addlInfo = addlInfo + "," + obj.Aggregation.ToString();
                    string column = obj.Aggregation.ToString() + obj.Serie;
                    if (obj.Trend != "")
                    {
                        column = column + obj.Trend.Trim();
                        addlInfo = addlInfo + "," + obj.Trend.Trim();
                    }
                    if (obj.Altitude != "")
                    {
                        //objLocInfo.DataPointInfo.altitude = Int32.Parse(obj.Altitude.ToString());
                        column = bool.Parse(obj.Altitude.ToString()) ? column + "_altAdj" : column;
                        addlInfo = addlInfo + "," + TranslatedText("AltAdjustment");
                    }
                    if (obj.Accumulate != "")
                    {
                        column = bool.Parse(obj.Accumulate) ? "acc" + column : column;
                        addlInfo = addlInfo + "," + TranslatedText("accumilate");
                    }

                    alColumns.Add(new string[] { column, obj.Serie, obj.Series, addlInfo });
                }
            }
            if (alColumns.Count > 0)
            {
                foreach (DataRow dr in dtData.Rows)
                {
                    foreach (string[] ser in alColumns)
                    {
                        if (dr["name"].ToString().ToLower() == ser[1].ToString().ToLower())
                        {
                            string agg = ser[0].ToString().Substring(0, 3).ToLower();
                            if ((agg == "sum" || agg == "max" || agg == "min" || agg == "avg"))
                            {
                                ser[0] = ser[0].ToString().Substring(3, ser[0].ToString().Length - 3).ToLower();
                                dr["aggregationfunction"] = agg;
                            }

                            agg = ser[0].ToString().Length > 6 ? ser[0].ToString().Substring(0, 6).ToLower() : "";
                            if ((agg == "accsum" || agg == "accmax" || agg == "accmin" || agg == "accavg"))
                            {
                                if (ddlAggregate.SelectedValue == "daily")
                                {
                                    ser[0] = agg.Substring(0, 3) + ser[0].ToString().Substring(6, ser[0].ToString().Length - 6).ToLower();
                                }
                                else
                                {
                                    ser[0] = ser[0].ToString().Substring(6, ser[0].ToString().Length - 6).ToLower();
                                }
                                dr["aggregationfunction"] = agg;
                            }

                            if (dr["year"].ToString() == string.Empty && "node" + dr["panel"].ToString() == ser[2].ToString())
                            {
                                dr["name"] = ser[0].ToString();
                                dr["addlInfo"] = ser[3].ToString();
                            }
                        }
                    }
                }
            }
            if (IsGDD && !ExcelFlag)
            {
                List<AdvancedOptionInfo> serie = new List<AdvancedOptionInfo>();
                string addlInfo = "";
                if (objSeriesInfo.SeriesList != null)
                {
                    var sers = from ser in objSeriesInfo.SeriesList
                               where ser.Serie.ToLower().Contains("gdd")
                               select ser;
                    serie.AddRange(sers.ToList());
                }

                /*3.1 UC – BodenWasser Modell - display webpage as IFrame - Jerrey - Start*/

                if (serie.ToList() != null && serie.ToList().Count > 0)
                {
                    if (objAgriInfo.ContainsKey("Method"))
                        objAgriInfo["Method"] = serie.ToList()[0].Method;
                    else
                        objAgriInfo.Add("Method", serie.ToList()[0].Method);

                    if (objAgriInfo.ContainsKey("Cap"))
                        objAgriInfo["Cap"] = serie.ToList()[0].Cap;
                    else
                        objAgriInfo.Add("Cap", serie.ToList()[0].Cap);

                    if (objAgriInfo.ContainsKey("Base"))
                        objAgriInfo["Base"] = serie.ToList()[0].Base;
                    else
                        objAgriInfo.Add("Base", serie.ToList()[0].Base);
                    addlInfo = serie.ToList()[0].Method + "," + serie.ToList()[0].Cap + "," + serie.ToList()[0].Base;
                    dtData.Rows[0]["addlInfo"] = addlInfo;
                }
                else
                {
                    objAgriPresenter.getGDDvalues();
                    if (objAgriInfo.ContainsKey("Method"))
                        objAgriInfo["Method"] = GddValues[0];
                    else
                        objAgriInfo.Add("Method", GddValues[0]);

                    if (objAgriInfo.ContainsKey("Cap"))
                        objAgriInfo["Cap"] = GddValues[2];
                    else
                        objAgriInfo.Add("Cap", GddValues[2]);

                    if (objAgriInfo.ContainsKey("Base"))
                        objAgriInfo["Base"] = GddValues[1];
                    else
                        objAgriInfo.Add("Base", GddValues[1]);
                    addlInfo = GddValues[0] + "," + GddValues[2] + "," + GddValues[1];
                    dtData.Rows[0]["addlInfo"] = addlInfo;
                }

                /*3.1 UC – BodenWasser Modell - display webpage as IFrame - Jerrey - End*/
            }

            if (objAgriInfo.Count == 0)
            {
                objAgriInfo = (Dictionary<string, string>)Session["IAgriInfo"];
                objAgriInfo["IsGDD"] = IsGDD.ToString();
            }
            else
            {
                if (objAgriInfo.ContainsKey("IsGDD"))
                    objAgriInfo["IsGDD"] = IsGDD.ToString();
                else
                    objAgriInfo.Add("IsGDD", IsGDD.ToString());
            }
            //if (IsGDD)
            //    objAgriInfo["aggregation"] = "Daily";
            Session["IAgriInfo"] = objAgriInfo;
        }