Exemplo n.º 1
0
        /*3.1 UC – BodenWasser Modell - display webpage as IFrame - Jerrey - Start*/
        private void AddSeriesToChartParams(DataSet config, DataRow dr, string serieName, string axisLabel, string gallery, string position, string markerType, string serieColor, string columnName, int pane)
        {
            int rowCount = 0;
            series = new Series();
            series.SerieName = serieName;
            series.Gallery = gallery;
            series.pane = pane;
            series.Color = serieColor;
            series.MarkerType = markerType;
            series.Position = position;
            series.axisLabel = axisLabel;

            series.Stacked = Convert.ToBoolean(dr["stacked"]);
            /* UAT Issue - Data from Mar 1st & from Mar 6th, the moisture value are not correct - Jerrey - Start */
            startDate = BorderWaterModel.StartDate;
            endDate = BorderWaterModel.EndDate;
            //endDate = DateTime.Parse(agriInfo["endDate"].ToString());
            /* UAT Issue - Data from Mar 1st & from Mar 6th, the moisture value are not correct - Jerrey - End */

            /* IM01288870 - New Agricast - Missing data - Jerrey - Begin */
            //noofvalues = ((TimeSpan)(endDate - startDate)).Days / (valuestep == 24 ? 1 : valuestep);
            //noofvalues = (valuestep == 30 && noofvalues > 0) ? noofvalues : noofvalues + 1;
            noofvalues = ((TimeSpan)(endDate.AddDays(1) - startDate)).Days / (valuestep == 24 ? 1 : valuestep);
            /* IM01288870 - New Agricast - Missing data - Jerrey - End */
            double?[] vals = new double?[noofvalues];

            DataRow[] dt = null;
            DateTime from = startDate;
            DateTime to = endDate;

            dt = config.Tables["ChartData"].Select("date>='" + from + "' and date<='" + to + "'", "date asc");
            if (dt != null && dt.Count() != 0)
            {
                if (series.MarkerType.ToString().ToLower() == "marker")
                {
                    ArrayList mks = new ArrayList();
                    ResultMarker marker = null;
                    dswidth = "1";
                    int barwidth = int.Parse(dswidth);
                    string color = dr.Table.Columns.Contains("textColor") ? dr["textColor"].ToString() : Color.Black.Name;
                    for (int x = 0; x < dt.Length; x++)
                    {
                        if (dt[x][columnName].ToString() != "")
                        {
                            marker = new ResultMarker(DateTime.Parse(dt[x][0].ToString()).ToOADate(), 0, color, dt[x][columnName].ToString());
                            marker.width = barwidth;
                            mks.Add(marker);
                        }
                    }
                    objGparams.markers = (ResultMarker[])mks.ToArray(marker.GetType());
                }
                else if (series.MarkerType.ToString().ToLower() == "shader")
                {

                    ResultShade rsh = null;
                    ArrayList shades = new ArrayList();
                    PaletteMap objPm = new PaletteMap();
                    objPm = getPalleteColor(dr["pallete"].ToString());
                    DateTime cdate = startDate;
                    double shadestart = cdate.ToOADate();
                    double shadestop = cdate.ToOADate();
                    double preval = 0d;
                    double curval = 0d;
                    for (int i = 0; i <= dt.Length; i++)
                    {
                        string color = Color.Red.Name;
                        if (i == 0)
                        {
                            if (!string.IsNullOrEmpty(dt[i][columnName].ToString()))
                                curval = double.Parse(dt[i][columnName].ToString());
                            shadestart = DateTime.Parse(dt[i][0].ToString()).ToOADate();
                            preval = curval;
                        }
                        if (i < dt.Length && !string.IsNullOrEmpty(dt[i][columnName].ToString()))
                            curval = double.Parse(dt[i][columnName].ToString());
                        else
                            curval = 0d;

                        if (preval != curval)
                        {
                            shadestop = DateTime.Parse(dt[i - 1][0].ToString()).ToOADate();
                            if (dr.Table.Columns.Contains("pallete"))
                            {
                                color = !string.IsNullOrEmpty(preval.ToString()) ? objPm.getColor(preval, "") : Color.Red.Name;
                            }

                            rsh = new ResultShade(shadestart, shadestop, color);
                            shades.Add(rsh);
                            shadestart = 0d;
                            shadestop = 0d;
                            shadestart = DateTime.Parse(dt[i - 1][0].ToString()).ToOADate();
                            preval = curval;
                        }
                    }
                    if (shades.Count > 0) objGparams.shades = (ResultShade[])shades.ToArray(rsh.GetType());
                }
                else
                {
                    int i = 0;
                    /* IM01288870 - New Agricast - Missing data - Jerrey - Begin */
                    //while (from <= to)
                    while (from <= to.AddDays(1).AddDays(-(valuestep == 24 ? 1 : valuestep)))
                    /* IM01288870 - New Agricast - Missing data - Jerrey - End */
                    {
                        double j;
                        if (bool.Parse(agriInfo["IsGDD"]))
                            if (from != DateTime.Parse(dt[rowCount][0].ToString()))
                            {
                                from = from.AddDays(valuestep == 24 ? 1 : valuestep);
                                i++;
                                continue;
                            }
                        if (dt.Length > rowCount && dt[rowCount][columnName].ToString() != "" && vals.Length > i)
                        {
                            vals[i] = double.TryParse(dt[rowCount][columnName].ToString(), out j) ? j : 0;
                            series.hasvalues = true;
                        }
                        else
                        {
                            missingData = true;
                            series.hasGaps = true;
                        }
                        rowCount++;

                        from = from.AddDays(valuestep == 24 ? 1 : valuestep);
                        i++;
                    }
                }
            }
            if (series.Position.ToLower() == "primary")
            {
                series.MinorY = double.Parse(config.Tables[PrimaryAxis].Rows[0]["minValue"].ToString());
                series.MajorY = double.Parse(config.Tables[PrimaryAxis].Rows[0]["maxvalue"].ToString());
                series.Scale = config.Tables[PrimaryAxis].Rows[0]["ScaleType"].ToString();
            }
            else
            {
                series.MinorY = double.Parse(config.Tables[SecondaryAxis].Rows[0]["minValue"].ToString());
                series.MajorY = double.Parse(config.Tables[SecondaryAxis].Rows[0]["maxvalue"].ToString());
                series.Scale = config.Tables[SecondaryAxis].Rows[0]["ScaleType"].ToString();
            }
            series.values = vals;

            objGparams.addSeries(series);
        }
Exemplo n.º 2
0
        private void getSunriseSunsetAndShaders()
        {
            // add sunrise / sunset markers
            string color = Color.LightGray.Name;
            ResultShade rsh = null;
            ArrayList shades = new ArrayList();
            DateTime rdate = cUtil.getSunrise(startDate, 47.6, 7.6);
            DateTime sdate = cUtil.getSunset(rdate, 47.6, 7.6);
            int setMin = sdate.Hour * 60 + sdate.Minute;
            int riseMin = rdate.Hour * 60 + rdate.Minute;
            if (setMin > riseMin) setMin -= 24 * 60;

            DateTime cdate = startDate;
            DateTime shadestart = cdate;
            DateTime shadestop = cdate;
            int risemin = riseMin;
            int setmin = setMin;
            int cmin = cdate.Hour * 60 + cdate.Minute;
            int maxvalue = (Math.Abs(_end) - Math.Abs(_start)) * 24 * 60;

            while (cmin < maxvalue + (24 * 60))
            {
                int startmin = setmin;
                int endmin = risemin;
                if (startmin < 0) startmin = 0;
                if (endmin > maxvalue) endmin = maxvalue;
                rsh = new ResultShade((float)cdate.AddMinutes(startmin).ToOADate(),
                    (float)cdate.AddMinutes(endmin).ToOADate(), color);
                shades.Add(rsh);
                risemin += 24 * 60;
                setmin += 24 * 60;
                cmin += 24 * 60;
            }
            if (shades.Count > 0) objGparams.shades = (ResultShade[])shades.ToArray(rsh.GetType());
        }
Exemplo n.º 3
0
        void setParamsHistory(DataSet config, FeatureResponse featureResponse = null)
        {
            objGparams.Height = Int32.Parse(config.Tables[CHART].Rows[0]["height"].ToString());
            objGparams.Width = Int32.Parse(config.Tables[CHART].Rows[0]["width"].ToString());
            objGparams.WaterMark = cUtil.getApplPath(@"Images\") + config.Tables[CHART].Rows[0]["watermark"].ToString();
            int cols = 1;
            foreach (DataRow dr in config.Tables[ChartSerie].Select("", "panel"))
            {
                int rowCount = 0;
                series = new Series();
                string extras = dr["addlInfo"].ToString() != "" ? " (" + dr["addlInfo"].ToString().TrimStart(',') + ")" : "";
                if (dr.Table.Columns.Contains("trnsTag"))
                    series.SerieName = cUtil.getTransText(dr["trnsTag"].ToString()) + extras;
                else
                    series.SerieName = dr["name"].ToString() + extras;
                series.MarkerType = dr["markerType"].ToString();
                series.Position = dr["axisPosition"].ToString();
                series.Stacked = Convert.ToBoolean(dr["stacked"]);
                series.Gallery = dr["gallery"].ToString();
                series.Color = dr["color"].ToString();
                series.pane = dr.Table.Columns.Contains("panel") ? Int32.Parse(dr["panel"].ToString()) : 1;
                series.axisLabel = (dr.Table.Columns.Contains("labeltext") && dr["labeltext"].ToString() != "") ? cUtil.getTransText(dr["labeltext"].ToString()) : "";
                /* IM01288870 - New Agricast - Missing data - Jerrey - Begin */
                //noofvalues = ((TimeSpan)(endDate - startDate)).Days / (valuestep == 24 ? 1 : valuestep);
                //noofvalues = (valuestep == 30 && noofvalues > 0) ? noofvalues : noofvalues + 1;
                noofvalues = ((TimeSpan)(endDate.AddDays(1) - startDate)).Days / (valuestep == 24 ? 1 : valuestep);
                /* IM01288870 - New Agricast - Missing data - Jerrey - End */
                double?[] vals = new double?[noofvalues];
                DataRow[] dt = null;
                DateTime from = startDate;
                DateTime to = endDate;
                if (dr["year"].ToString() != "")
                {
                    from = new DateTime(Int32.Parse(dr["year"].ToString()), from.Month, (from.Month == 2 && from.Day > 28) ? 28 : from.Day);
                    int range = (endDate.Year - startDate.Year);
                    to = new DateTime(Int32.Parse(dr["year"].ToString()) + range, to.Month, (to.Month == 2 && to.Day > 28) ? 28 : to.Day);
                    if (range != 0)
                        series.SerieName = series.SerieName + " " + dr["year"].ToString() + "-" + (Int32.Parse(dr["year"].ToString()) + range).ToString();
                    else
                        series.SerieName = series.SerieName + " " + dr["year"].ToString();
                    if (to > DateTime.Parse(config.Tables["ChartData"].Select("date=max(date)")[0]["date"].ToString()))
                    {
                        to = DateTime.Parse(config.Tables["ChartData"].Select("date=max(date)")[0]["date"].ToString());
                    }
                }
                dt = config.Tables["ChartData"].Select("date>='" + from + "' and date<='" + to + "'", "date asc");
                if (dt != null && dt.Count() != 0)
                {
                    if (series.MarkerType.ToString().ToLower() == "marker")
                    {
                        ArrayList mks = new ArrayList();
                        ResultMarker marker = null;
                        dswidth = "1";
                        int barwidth = int.Parse(dswidth);
                        string color = dr.Table.Columns.Contains("textColor") ? dr["textColor"].ToString() : Color.Black.Name;
                        for (int x = 0; x < dt.Length; x++)
                        {
                            if (dt[x][cols].ToString() != "")
                            {
                                marker = new ResultMarker(DateTime.Parse(dt[x][0].ToString()).ToOADate(), 0, color, dt[x][cols].ToString());
                                marker.width = barwidth;
                                //marker.label = dt[x][cols].ToString();
                                mks.Add(marker);
                            }
                        }
                        objGparams.markers = (ResultMarker[])mks.ToArray(marker.GetType());
                    }
                    else if (series.MarkerType.ToString().ToLower() == "shader")
                    {

                        ResultShade rsh = null;
                        ArrayList shades = new ArrayList();
                        PaletteMap objPm = new PaletteMap();
                        objPm = getPalleteColor(dr["pallete"].ToString());
                        DateTime cdate = startDate;
                        double shadestart = cdate.ToOADate();
                        double shadestop = cdate.ToOADate();
                        double preval = 0d;
                        double curval = 0d;
                        for (int i = 0; i <= dt.Length; i++)
                        {
                            string color = Color.Red.Name;
                            if (i == 0)
                            {
                                if (!string.IsNullOrEmpty(dt[i][cols].ToString()))
                                    curval = double.Parse(dt[i][cols].ToString());
                                shadestart = DateTime.Parse(dt[i][0].ToString()).ToOADate();
                                preval = curval;
                            }
                            if (i < dt.Length && !string.IsNullOrEmpty(dt[i][cols].ToString()))
                                curval = double.Parse(dt[i][cols].ToString());
                            else
                                curval = 0d;

                            if (preval != curval)
                            {
                                shadestop = DateTime.Parse(dt[i - 1][0].ToString()).ToOADate();
                                if (dr.Table.Columns.Contains("pallete"))
                                {
                                    color = !string.IsNullOrEmpty(preval.ToString()) ? objPm.getColor(preval, "") : Color.Red.Name;
                                }

                                rsh = new ResultShade(shadestart, shadestop, color);
                                shades.Add(rsh);
                                shadestart = 0d;
                                shadestop = 0d;
                                shadestart = DateTime.Parse(dt[i - 1][0].ToString()).ToOADate();
                                preval = curval;
                            }
                        }
                        if (shades.Count > 0) objGparams.shades = (ResultShade[])shades.ToArray(rsh.GetType());
                    }
                    else
                    {
                        int i = 0;
                        from = DateTime.Parse(dt[0]["date"].ToString());
                        /* IM01288870 - New Agricast - Missing data - Jerrey - Begin */
                        //while (from <= to)
                        while (from <= to.AddDays(1).AddDays(-(valuestep == 24 ? 1 : valuestep)))
                        /* IM01288870 - New Agricast - Missing data - Jerrey - End */
                        {
                            double j;
                            if (dt.Length > rowCount && dt[rowCount][cols].ToString() != "" && vals.Length > i)
                            {
                                vals[i] = double.TryParse(dt[rowCount][cols].ToString(), out j) ? j : 0;
                                series.hasvalues = true;
                            }
                            else
                            {
                                missingData = true;
                                series.hasGaps = true;
                            }
                            rowCount++;
                            //}
                            from = from.AddDays(valuestep == 24 ? 1 : valuestep);
                            i++;
                        }
                    }
                }
                if (series.Position.ToLower() == "primary")
                {
                    series.MinorY = double.Parse(config.Tables[PrimaryAxis].Rows[0]["minValue"].ToString());
                    series.MajorY = double.Parse(config.Tables[PrimaryAxis].Rows[0]["maxvalue"].ToString());
                    series.Scale = config.Tables[PrimaryAxis].Rows[0]["ScaleType"].ToString();
                }
                else
                {
                    series.MinorY = double.Parse(config.Tables[SecondaryAxis].Rows[0]["minValue"].ToString());
                    series.MajorY = double.Parse(config.Tables[SecondaryAxis].Rows[0]["maxvalue"].ToString());
                    series.Scale = config.Tables[SecondaryAxis].Rows[0]["ScaleType"].ToString();
                }
                series.values = vals;
                objGparams.addSeries(series);
                cols++;
            }

            objGparams.LeftScaleType = config.Tables[PrimaryAxis].Rows[0]["scaleType"].ToString();
            objGparams.LeftAxisLabel = cUtil.getTransText(config.Tables[PrimaryAxis].Rows[0]["trnsTag"].ToString());
            objGparams.Ymax = double.Parse(config.Tables[PrimaryAxis].Rows[0]["maxValue"].ToString());
            objGparams.Ymin = double.Parse(config.Tables[PrimaryAxis].Rows[0]["minValue"].ToString());

            objGparams.RightAxisLabel = cUtil.getTransText(config.Tables[SecondaryAxis].Rows[0]["trnsTag"].ToString());
            objGparams.RightScaleType = config.Tables[SecondaryAxis].Rows[0]["scaletype"].ToString();
            objGparams.Y2max = double.Parse(config.Tables[SecondaryAxis].Rows[0]["maxValue"].ToString());
            objGparams.Y2min = double.Parse(config.Tables[SecondaryAxis].Rows[0]["minValue"].ToString());

            objGparams.BottomLabels = getLabelsHistory(startDate, selectedEndDate, valuestep);
            string distText = cUtil.getTransText("ResDistanceFrom");
            string stationInfo = dpi.stationName.ToString();
            string lattranslate = objSvcPre.getTranslatedText("Lat", culture);
            string longtranslate = objSvcPre.getTranslatedText("Long", culture);
            stationInfo = stationInfo.Replace("Lat", lattranslate);
            stationInfo = stationInfo.Replace("Long", longtranslate);
            if (featureResponse != null && dpi.stationLatitude != featureResponse.Latitude && dpi.stationLongitude != featureResponse.Longitude)
            {
                distText = distText.Replace("{Dist}", featureResponse.Distance.ToString());
                distText = distText.Replace("{Dir}", cUtil.getTextDirection(Convert.ToInt32(featureResponse.BearingDegrees)));
                distText = distText.Replace("{Elevation}", featureResponse.Altitude.ToString());
                stationInfo = lattranslate + ":" + featureResponse.Latitude + ";" + longtranslate + ":" + featureResponse.Longitude;
            }
            else
            {
                distText = distText.Replace("{Dist}", dpi.distance.ToString());
                distText = distText.Replace("{Dir}", dpi.directionLetter);
                distText = distText.Replace("{Elevation}", dpi.altitude.ToString());
            }

            distText = distText.Replace("{CityName}", HttpUtility.HtmlDecode((LocationInfo.getLocationInfoObj).placeName));
            distText = distText.Replace("<strong>", "").Replace("</strong>", "");

            /*IM01166162 - AgriInfo UI Issues - BEGIN*/
            //objGparams.Title = cUtil.getTransText("weather") + " " + cUtil.getTransText("for") + " " + dpi.stationName.ToString() +" "+ distText + "\n" +
            //                    cUtil.getTransText("from")+ " " + startDate.ToString("dd-MMM-yyyy", new CultureInfo(culture)) + " " +
            //                    cUtil.getTransText("to") + " " + selectedEndDate.ToString("dd-MMM-yyyy", new CultureInfo(culture)) + " " + cUtil.getTransText("aggregation")+" :"+ cUtil.getTransText(agriInfo["aggregation"]);
            /*IM01848085 - New Agricast - Agriinfo - "location" name not translatable - BEGIN*/
            //objGparams.Title = cUtil.getTransText("weather") + " " + cUtil.getTransText("for") + " " + dpi.stationName.ToString() + "#" + distText + "#"

            /* IM01848087 - New Agricast - AgriInfo chart title - changing the structure of the lines - Start */
            if (culture == "hu-HU")
            {
                //objGparams.Title = cUtil.getTransText("weather") + " " + cUtil.getTransText("for") + " " + stationInfo + "#" + distText + "#"
                //    /*IM01848085 - New Agricast - Agriinfo - "location" name not translatable - END*/
                //    /* IM01289657 - New Agricast - Agriinfo - date formatting - Jerrey - Start */
                //                    + FormatDateTime(startDate, culture) + " " + cUtil.getTransText("from") //startDate.ToString("dd-MMM-yyyy", new CultureInfo(culture))
                //                    + " " + FormatDateTime(selectedEndDate, culture) + " " + cUtil.getTransText("to") //selectedEndDate.ToString("dd-MMM-yyyy", new CultureInfo(culture))
                //    /* IM01289657 - New Agricast - Agriinfo - date formatting - Jerrey - End */
                //                    + " " + cUtil.getTransText("Aggregation") + ": " + cUtil.getTransText(agriInfo["aggregation"]);
                objGparams.Title = cUtil.getTransText("weather") + " " + cUtil.getTransText("for") + " " + stationInfo + "#" + distText;
            }
            else
            {
                //objGparams.Title = cUtil.getTransText("weather") + " " + cUtil.getTransText("for") + " " + stationInfo + "#" + distText + "#"
                //    /*IM01848085 - New Agricast - Agriinfo - "location" name not translatable - END*/
                //    /* IM01289657 - New Agricast - Agriinfo - date formatting - Jerrey - Start */
                //    + cUtil.getTransText("from") + " " + FormatDateTime(startDate, culture) //startDate.ToString("dd-MMM-yyyy", new CultureInfo(culture))
                //    + " " + cUtil.getTransText("to") + " " + FormatDateTime(selectedEndDate, culture) //selectedEndDate.ToString("dd-MMM-yyyy", new CultureInfo(culture))
                //    /* IM01289657 - New Agricast - Agriinfo - date formatting - Jerrey - End */
                //    + " " + cUtil.getTransText("Aggregation") + ": " + cUtil.getTransText(agriInfo["aggregation"]);
                objGparams.Title = cUtil.getTransText("weather") + " " + cUtil.getTransText("for") + " " + stationInfo + "#" + distText;
            }
            /* IM01848087 - New Agricast - AgriInfo chart title - changing the structure of the lines - End */
            /*IM01166162 - AgriInfo UI Issues - END*/
            if (missingData)
                objGparams.warning = cUtil.getTransText("wm_warning") + ":" + cUtil.getTransText("This chart has been plotted with missing data.");
               // objGparams.FooterText += cUtil.getTransText("chartcopyright");
        }