Пример #1
0
        //---
        //+--
        public static DataTable PeriodicDailyDataSnapshotPresentation(AspDataReadRecordType[] records)
        {
            DataTable fdt = new DataTable();

            fdt.Columns.Add(new DataColumn("measuretype", typeof(string)));
            fdt.Columns.Add(new DataColumn("um", typeof(string)));
            fdt.Columns.Add(new DataColumn("max", typeof(string)));
            fdt.Columns.Add(new DataColumn("hourmax", typeof(string)));
            fdt.Columns.Add(new DataColumn("min", typeof(string)));
            fdt.Columns.Add(new DataColumn("hourmin", typeof(string)));
            fdt.Columns.Add(new DataColumn("mean", typeof(string)));
            fdt.Columns.Add(new DataColumn("Escursion", typeof(string)));
            fdt.Columns.Add(new DataColumn("nmisure", typeof(string)));

            for (int i = 0; i < records.Length; i++)
            {
                DataRow nr = fdt.NewRow();
                AspMeteoParametersType   type  = AspUtility.ReverseDecodeMeteoParametersType(records[i].measuretype);
                AspMeasureDescriptioType dtype = AspUtility.LiteralDecodeMeteoParametersType(type);

                nr["measuretype"] = dtype.Description;
                nr["um"]          = dtype.MeasureUnit;
                nr["max"]         = float.IsNaN(records[i].max) ? AspUtility.BadDataPresentation : records[i].max.ToString("#0.0");
                nr["hourmax"]     = DateTime.MinValue.CompareTo(records[i].datemax) == 0 ? AspUtility.BadDataPresentation : records[i].datemax.ToString("HH:mm");
                nr["min"]         = float.IsNaN(records[i].min) ? AspUtility.BadDataPresentation : records[i].min.ToString("#0.0");
                nr["hourmin"]     = DateTime.MinValue.CompareTo(records[i].datemin) == 0 ? AspUtility.BadDataPresentation : records[i].datemin.ToString("HH:mm");
                nr["mean"]        = float.IsNaN(records[i].mean) ? AspUtility.BadDataPresentation : records[i].mean.ToString("#0.0");
                nr["Escursion"]   = float.IsNaN(records[i].excursion) ? AspUtility.BadDataPresentation : records[i].excursion.ToString("#0.0");
                nr["nmisure"]     = float.IsNaN(records[i].nmisure) ? AspUtility.BadDataPresentation : records[i].nmisure.ToString("#0");

                fdt.Rows.Add(nr);
            }

            fdt.Columns["measuretype"].ColumnName = "Misura";
            fdt.Columns["um"].ColumnName          = "Unità Misura";
            fdt.Columns["max"].ColumnName         = "Massimo";
            fdt.Columns["hourmax"].ColumnName     = "Massimo Ora";
            fdt.Columns["min"].ColumnName         = "Minimo";
            fdt.Columns["hourmin"].ColumnName     = "Minimo Ora";
            fdt.Columns["mean"].ColumnName        = "Media";
            fdt.Columns["Escursion"].ColumnName   = "Escursione";
            fdt.Columns["nmisure"].ColumnName     = "# Misure";

            return(fdt);
        }
Пример #2
0
        //---
        //+--
        public static AspMeteoParametersType[] SequenceHourlyMeasureData()
        {
            AspMeteoParametersType[] sq = new AspMeteoParametersType[13];

            sq[0]  = AspMeteoParametersType.Temperature;
            sq[1]  = AspMeteoParametersType.Umidity;
            sq[2]  = AspMeteoParametersType.Pressure;
            sq[3]  = AspMeteoParametersType.DewPoint;
            sq[4]  = AspMeteoParametersType.Wind;
            sq[5]  = AspMeteoParametersType.WindAngle;
            sq[6]  = AspMeteoParametersType.WindChill;
            sq[7]  = AspMeteoParametersType.HeathIndex;
            sq[8]  = AspMeteoParametersType.Thom;
            sq[9]  = AspMeteoParametersType.UV;
            sq[10] = AspMeteoParametersType.Evapotraspiration;
            sq[11] = AspMeteoParametersType.SolRad;
            sq[12] = AspMeteoParametersType.Rain;

            return(sq);
        }
Пример #3
0
        //---
        //+--
        public static DataTable PeriodicMonthlyDataSnapshotPresentation(AspDataReadRecordType[] records)
        {
            DataTable fdt = new DataTable();

            fdt.Columns.Add(new DataColumn("measuretype", typeof(string)));
            fdt.Columns.Add(new DataColumn("um", typeof(string)));
            fdt.Columns.Add(new DataColumn("max", typeof(string)));
            fdt.Columns.Add(new DataColumn("daymax", typeof(string)));
            fdt.Columns.Add(new DataColumn("hourmax", typeof(string)));
            fdt.Columns.Add(new DataColumn("min", typeof(string)));
            fdt.Columns.Add(new DataColumn("daymin", typeof(string)));
            fdt.Columns.Add(new DataColumn("hourmin", typeof(string)));
            fdt.Columns.Add(new DataColumn("mean", typeof(string)));
            fdt.Columns.Add(new DataColumn("Escursion", typeof(string)));
            fdt.Columns.Add(new DataColumn("nmisure", typeof(string)));

            for (int i = 0; i < records.Length; i++)
            {
                DataRow nr = fdt.NewRow();
                AspMeteoParametersType   type  = AspUtility.ReverseDecodeMeteoParametersType(records[i].measuretype);
                AspMeasureDescriptioType dtype = AspUtility.LiteralDecodeMeteoParametersType(type);

                nr["measuretype"] = dtype.Description;
                nr["um"]          = dtype.MeasureUnit;
                nr["max"]         = float.IsNaN(records[i].max) ? AspUtility.BadDataPresentation : records[i].max.ToString("#0.0");
                nr["daymax"]      = float.IsNaN(records[i].max) ? AspUtility.BadDataPresentation : records[i].datemax.Day.ToString();
                nr["hourmax"]     = float.IsNaN(records[i].max) ? AspUtility.BadDataPresentation : string.Format("{0:00}:{1:00}", records[i].datemax.Hour, records[i].datemax.Minute);
                nr["min"]         = float.IsNaN(records[i].min) ? AspUtility.BadDataPresentation : records[i].min.ToString("#0.0");
                nr["daymin"]      = float.IsNaN(records[i].min) ? AspUtility.BadDataPresentation : records[i].datemin.Day.ToString();
                nr["hourmin"]     = float.IsNaN(records[i].min) ? AspUtility.BadDataPresentation : string.Format("{0:00}:{1:00}", records[i].datemin.Hour, records[i].datemin.Minute);
                nr["mean"]        = float.IsNaN(records[i].mean) ? AspUtility.BadDataPresentation : records[i].mean.ToString("#0.0");
                nr["Escursion"]   = float.IsNaN(records[i].excursion) ? AspUtility.BadDataPresentation : records[i].excursion.ToString("#0.0");
                nr["nmisure"]     = float.IsNaN(records[i].nmisure) ? AspUtility.BadDataPresentation : records[i].nmisure.ToString("#0");
                fdt.Rows.Add(nr);
            }

            return(fdt);
        }
Пример #4
0
        public ViewResult PageChosen(DailyData model, string actionChosen)
        {
            //           switch(model.actionSelected)
            {
                //             case user_display_selection.meteo_daily_graph: return View(); break;
                //             case user_display_selection.meteo_daily_grid: //return View("DailyDataGrid"); break;
                try
                {
                    //model._path = "C:\\Test";
                    model._path = System.Configuration.ConfigurationManager.AppSettings["dataRootFolder"];

                    DateTime date = DateTime.ParseExact(FormAspDateString(model._date), "yyyyMMdd", null);


                    string pf       = AspPath.ComposePath(model._path, AspUtility.ComposeMeteoDirectoryPath(AspDirectoryDeepType.Day, model._station, date));
                    FFile  Readfile = new FFile(model._station, pf);
                    string fpf      = Readfile.Read(AspUtility.LiteralDecodeElaborationType(AspElaborationType.DAY));

                    AspRDailyData rdg = new AspRDailyData(fpf);
                    if (rdg.Read())
                    {
                        model._gridDaily        = AspPeriodicDataUtility.PeriodicDailyDataSnapshotPresentation(rdg.Daily);
                        model._gridHourlyAgg    = AspPeriodicDataUtility.PeriodicDailyDataHourlyPresentation(rdg.DailySequence);
                        model._gridPredawn      = AspPeriodicDataUtility.PeriodicDailyDataSnapshotPresentation(rdg.DailyPredawn);
                        model._gridDailyMorning = AspPeriodicDataUtility.PeriodicDailyDataSnapshotPresentation(rdg.DailyMorning);
                        model._gridDailyNoon    = AspPeriodicDataUtility.PeriodicDailyDataSnapshotPresentation(rdg.DailyAfternoon);
                        model._gridDailyEvening = AspPeriodicDataUtility.PeriodicDailyDataSnapshotPresentation(rdg.DailyEvening);
                        model._gridDailyRain    = AspPeriodicDataUtility.PeriodicDailyRainPresentation(rdg.Rain);
                        model._gridRainPredawn  = AspPeriodicDataUtility.PeriodicDailyRainPresentation(rdg.RainPredawn);
                        model._gridRainMorning  = AspPeriodicDataUtility.PeriodicDailyRainPresentation(rdg.RainMorning);
                        model._gridRainNoon     = AspPeriodicDataUtility.PeriodicDailyRainPresentation(rdg.RainAfternoon);
                        model._gridRainEvening  = AspPeriodicDataUtility.PeriodicDailyRainPresentation(rdg.RainEvening);
                        model._gridHeat         = AspPeriodicDataUtility.PeriodicDailyDataHeatIndexesPresentation(rdg.Heat, rdg.Thom);
                    }

                    /*model._grid.Columns.Add(new DataColumn("Misura", typeof(string)));
                     * model._grid.Columns.Add(new DataColumn("U.M.", typeof(string)));
                     * model._grid.Columns.Add(new DataColumn("Max", typeof(string)));
                     * model._grid.Columns.Add(new DataColumn("H. Max", typeof(string)));
                     * model._grid.Columns.Add(new DataColumn("Min", typeof(string)));
                     * model._grid.Columns.Add(new DataColumn("H. Min", typeof(string)));
                     * model._grid.Columns.Add(new DataColumn("Media", typeof(string)));
                     * model._grid.Columns.Add(new DataColumn("Escursione", typeof(string)));
                     * model._grid.Columns.Add(new DataColumn("N. Misure", typeof(string)));*/

                    //                Queue<ComboSelectionFileParameters> parlist = new Queue<ComboSelectionFileParameters>();
                    ReadMeteoParametersFiles rpars = new ReadMeteoParametersFiles(model._station, model._path);
                    rpars.DelayDeleteMinutes = 0D;
                    rpars.IsDeleteOldFiles   = true;
                    //                rpars.Error += Rpars_Error;

                    // per i colori: http://www.computerhope.com/htmcolor.htm
                    // temperatura
                    AspMeteoParametersType[] p0 = new AspMeteoParametersType[1];
                    p0[0] = AspMeteoParametersType.Temperature;
                    AspMeteoParametersDataGroup dp0 = rpars.Read(p0, date);
                    if (dp0.Isvalid)
                    {
                        /*                   ComboSelectionFileParameters cmbp0 = new ComboSelectionFileParameters();
                         *                 cmbp0.Text = "Temperatura";
                         *                 cmbp0.Params = dp0;
                         *                 cmbp0.color = new Color[1];
                         *                 cmbp0.color[0] = ColorTranslator.FromHtml("#E56717"); // Papaya - arancione scuro
                         *                 cmbp0.Title = "Temperatura";
                         *                 cmbp0.AxisX = string.Format("Orario (data: {0:dd/MM/yyyy})", date);
                         *                 cmbp0.AxixY = "Gradi centigradi";
                         *                 cmbp0.TypeGraph = AspTypeGrapEnum.Line;
                         *                 cmbp0.Delta = 15;
                         *                 parlist.Enqueue(cmbp0); */
                        /*
                         * AspGraphInfoType info;
                         * info.colors = new System.Drawing.Color[1];
                         * info.parameters = dp0;
                         * info.tollerance = 15;
                         * info.type = AspTypeGrapEnum.Line;
                         *
                         * AspDailyGraph graph = new AspDailyGraph(600, 480);
                         * graph.AxisXLabel = string.Format("Orario (data: {0:dd/MM/yyy}", date);
                         * graph.AxisYLabel = "Gradi Centigradi";
                         * graph.PointSize = 5;
                         * graph.Title = "Temperatura";
                         *
                         * if(graph.Create(info, date))
                         * {
                         * model._graph = graph.GetImage;
                         * //byte[] foo = File.ReadAllBytes(graph.GetImage);
                         * //model.graphPath = "data:image/png;base64," + Convert.ToBase64String(foo);
                         * model.graphPath = GetImg(model._graph);
                         * //Passing image data in viewbag to view
                         * ViewBag.ImageData = model.graphPath;
                         * }
                         */
                    }
                    return(View("DailyDataGrid", model));
                }
                catch (Exception ex)
                {
                    return(View("Error.cshtml"));
                }
            }
            return(View());
        }
Пример #5
0
        public ViewResult displayPage(DailyGraph model)
        {
            try
            {
                //model._path = "C:\\Test";
                model._path = System.Configuration.ConfigurationManager.AppSettings["dataRootFolder"];

                DateTime date = DateTime.ParseExact(FormAspDateString(model._date), "yyyyMMdd", null);


                string pf       = AspPath.ComposePath(model._path, AspUtility.ComposeMeteoDirectoryPath(AspDirectoryDeepType.Day, model._station, date));
                FFile  Readfile = new FFile(model._station, pf);
                string fpf      = Readfile.Read(AspUtility.LiteralDecodeElaborationType(AspElaborationType.DAY));

                AspRDailyData rdg = new AspRDailyData(fpf);
                //if (rdg.Read())
                //{
                //    model._grid = AspPeriodicDataUtility.PeriodicDailyDataSnapshotPresentation(rdg.Daily);
                //}
                ReadMeteoParametersFiles rpars = new ReadMeteoParametersFiles(model._station, model._path);
                rpars.DelayDeleteMinutes = 0D;
                rpars.IsDeleteOldFiles   = true;
                //                rpars.Error += Rpars_Error;

                // per i colori: http://www.computerhope.com/htmcolor.htm
                // temperatura
                AspMeteoParametersType[] p0 = new AspMeteoParametersType[1];
                p0[0] = AspMeteoParametersType.Temperature;
                AspMeteoParametersDataGroup dp0 = rpars.Read(p0, date);
                if (dp0.Isvalid)
                {
                    /*                   ComboSelectionFileParameters cmbp0 = new ComboSelectionFileParameters();
                     *                 cmbp0.Text = "Temperatura";
                     *                 cmbp0.Params = dp0;
                     *                 cmbp0.color = new Color[1];
                     *                 cmbp0.color[0] = ColorTranslator.FromHtml("#E56717"); // Papaya - arancione scuro
                     *                 cmbp0.Title = "Temperatura";
                     *                 cmbp0.AxisX = string.Format("Orario (data: {0:dd/MM/yyyy})", date);
                     *                 cmbp0.AxixY = "Gradi centigradi";
                     *                 cmbp0.TypeGraph = AspTypeGrapEnum.Line;
                     *                 cmbp0.Delta = 15;
                     *                 parlist.Enqueue(cmbp0); */
                    AspGraphInfoType info;
                    info.colors     = new System.Drawing.Color[1];
                    info.parameters = dp0;
                    info.tollerance = 15;
                    info.type       = AspTypeGrapEnum.Line;

                    AspDailyGraph graph = new AspDailyGraph(600, 480);
                    graph.AxisXLabel = string.Format("Orario (data: {0:dd/MM/yyy}", date);
                    graph.AxisYLabel = "Gradi Centigradi";
                    graph.PointSize  = 5;
                    graph.Title      = "Temperatura";

                    if (graph.Create(info, date))
                    {
                        model._graphTemp = graph.GetImage;
                        //byte[] foo = File.ReadAllBytes(graph.GetImage);
                        //model.graphPath = "data:image/png;base64," + Convert.ToBase64String(foo);
                        model.graphPath1 = GetImg(model._graphTemp);
                        //Passing image data in viewbag to view
                        ViewBag.ImageData1 = model.graphPath1;
                    }
                }
                else
                {
                    throw new Exception("Dati giornalieri della stazione specificati inesistenti");
                }

                // temperatura, temp max e temp min
                AspMeteoParametersType[] p1 = new AspMeteoParametersType[3];
                p1[0] = AspMeteoParametersType.TemperatureMin;
                p1[1] = AspMeteoParametersType.TemperaturaMax;
                p1[2] = AspMeteoParametersType.Temperature;
                AspMeteoParametersDataGroup dp1 = rpars.Read(p1, date);
                if (dp1.Isvalid)
                {
                    AspGraphInfoType info;
                    info.colors     = new System.Drawing.Color[3];
                    info.parameters = dp1;
                    info.tollerance = 15;
                    info.type       = AspTypeGrapEnum.Line;

                    AspDailyGraph graph = new AspDailyGraph(600, 480);
                    graph.AxisXLabel = string.Format("Orario (data: {0:dd/MM/yyy}", date);
                    graph.AxisYLabel = "Gradi Centigradi";
                    graph.PointSize  = 5;
                    graph.Title      = "Temperatura (Arancione, minima blu, massima rossa)";

                    if (graph.Create(info, date))
                    {
                        model._graphTempMaxMin = graph.GetImage;
                        //byte[] foo = File.ReadAllBytes(graph.GetImage);
                        //model.graphPath = "data:image/png;base64," + Convert.ToBase64String(foo);
                        model.graphPath2 = GetImg(model._graphTempMaxMin);
                        //Passing image data in viewbag to view
                        ViewBag.ImageData2 = model.graphPath2;
                    }
                }

                // temperatura e dewpoint
                AspMeteoParametersType[] p2 = new AspMeteoParametersType[2];
                p2[0] = AspMeteoParametersType.DewPoint;
                p2[1] = AspMeteoParametersType.Temperature;
                AspMeteoParametersDataGroup dp2 = rpars.Read(p2, date);
                if (dp2.Isvalid)
                {
                    AspGraphInfoType info;
                    info.colors     = new System.Drawing.Color[2];
                    info.parameters = dp2;
                    info.tollerance = 15;
                    info.type       = AspTypeGrapEnum.Line;

                    AspDailyGraph graph = new AspDailyGraph(600, 480);
                    graph.AxisXLabel = string.Format("Orario (data: {0:dd/MM/yyy}", date);
                    graph.AxisYLabel = "Gradi Centigradi";
                    graph.PointSize  = 5;
                    graph.Title      = "Temperatura (arancione) e Dewpoint (blu)";

                    if (graph.Create(info, date))
                    {
                        model._graphTempDewP = graph.GetImage;
                        //byte[] foo = File.ReadAllBytes(graph.GetImage);
                        //model.graphPath = "data:image/png;base64," + Convert.ToBase64String(foo);
                        model.graphPath3 = GetImg(model._graphTempDewP);
                        //Passing image data in viewbag to view
                        ViewBag.ImageData3 = model.graphPath3;
                    }
                }

                // temperatura e heat index
                AspMeteoParametersType[] p3 = new AspMeteoParametersType[2];
                p3[0] = AspMeteoParametersType.HeathIndex;
                p3[1] = AspMeteoParametersType.Temperature;
                AspMeteoParametersDataGroup dp3 = rpars.Read(p3, date);
                if (dp3.Isvalid)
                {
                    AspGraphInfoType info;
                    info.colors     = new System.Drawing.Color[2];
                    info.parameters = dp3;
                    info.tollerance = 15;
                    info.type       = AspTypeGrapEnum.Line;

                    AspDailyGraph graph = new AspDailyGraph(600, 480);
                    graph.AxisXLabel = string.Format("Orario (data: {0:dd/MM/yyy}", date);
                    graph.AxisYLabel = "Gradi Centigradi";
                    graph.PointSize  = 5;
                    graph.Title      = "Temperatura (arancione) e Heat Index (blu)";

                    if (graph.Create(info, date))
                    {
                        model._graphTempHeat = graph.GetImage;
                        //byte[] foo = File.ReadAllBytes(graph.GetImage);
                        //model.graphPath = "data:image/png;base64," + Convert.ToBase64String(foo);
                        model.graphPath4 = GetImg(model._graphTempHeat);
                        //Passing image data in viewbag to view
                        ViewBag.ImageData4 = model.graphPath4;
                    }
                }

                // temperatura e Wind Chill
                AspMeteoParametersType[] p5 = new AspMeteoParametersType[2];
                p5[0] = AspMeteoParametersType.WindChill;
                p5[1] = AspMeteoParametersType.Temperature;
                AspMeteoParametersDataGroup dp5 = rpars.Read(p5, date);
                if (dp5.Isvalid)
                {
                    AspGraphInfoType info;
                    info.colors     = new System.Drawing.Color[2];
                    info.parameters = dp5;
                    info.tollerance = 15;
                    info.type       = AspTypeGrapEnum.Line;

                    AspDailyGraph graph = new AspDailyGraph(600, 480);
                    graph.AxisXLabel = string.Format("Orario (data: {0:dd/MM/yyy}", date);
                    graph.AxisYLabel = "Gradi Centigradi";
                    graph.PointSize  = 5;
                    graph.Title      = "Temperatura (arancione) e Wind Chill (blu)";

                    if (graph.Create(info, date))
                    {
                        model._graphTempWindChill = graph.GetImage;
                        //byte[] foo = File.ReadAllBytes(graph.GetImage);
                        //model.graphPath = "data:image/png;base64," + Convert.ToBase64String(foo);
                        model.graphPath6 = GetImg(model._graphTempWindChill);
                        //Passing image data in viewbag to view
                        ViewBag.ImageData5 = model.graphPath6;
                    }
                }

                // Vento  e vento max
                AspMeteoParametersType[] p4 = new AspMeteoParametersType[2];
                p4[0] = AspMeteoParametersType.windmax;
                p4[1] = AspMeteoParametersType.Wind;
                AspMeteoParametersDataGroup dp4 = rpars.Read(p4, date);
                if (dp4.Isvalid)
                {
                    AspGraphInfoType info;
                    info.colors     = new System.Drawing.Color[2];
                    info.parameters = dp4;
                    info.tollerance = 15;
                    info.type       = AspTypeGrapEnum.Line;

                    AspDailyGraph graph = new AspDailyGraph(600, 480);
                    graph.AxisXLabel = string.Format("Orario (data: {0:dd/MM/yyy}", date);
                    graph.AxisYLabel = "Velocità in Km/h";
                    graph.PointSize  = 5;
                    graph.Title      = "Vel. vento (arancione) e vel. raffiche (porpora)";

                    if (graph.Create(info, date))
                    {
                        model._graphWind = graph.GetImage;
                        //byte[] foo = File.ReadAllBytes(graph.GetImage);
                        //model.graphPath = "data:image/png;base64," + Convert.ToBase64String(foo);
                        model.graphPath5 = GetImg(model._graphWind);
                        //Passing image data in viewbag to view
                        ViewBag.ImageData6 = model.graphPath5;
                    }
                }

                // pioggia
                AspMeteoParametersType[] p6 = new AspMeteoParametersType[1];
                p6[0] = AspMeteoParametersType.Rain;
                AspMeteoParametersDataGroup dp6 = rpars.Read(p6, date);
                if (dp6.Isvalid)
                {
                    AspGraphInfoType info;
                    info.colors     = new System.Drawing.Color[1];
                    info.parameters = dp6;
                    info.tollerance = 15;
                    info.type       = AspTypeGrapEnum.Line;

                    AspDailyGraph graph = new AspDailyGraph(600, 480);
                    graph.AxisXLabel = string.Format("Orario (data: {0:dd/MM/yyy}", date);
                    graph.AxisYLabel = "millimetri";
                    graph.PointSize  = 5;
                    graph.Title      = "Pioggia";

                    if (graph.Create(info, date))
                    {
                        model._graphRain = graph.GetImage;
                        //byte[] foo = File.ReadAllBytes(graph.GetImage);
                        //model.graphPath = "data:image/png;base64," + Convert.ToBase64String(foo);
                        model.graphPath7 = GetImg(model._graphRain);
                        //Passing image data in viewbag to view
                        ViewBag.ImageData7 = model.graphPath7;
                    }
                }

                return(View("DailyDataGraph", model));
            }
            catch (Exception ex)
            {
                ViewBag.Message = string.Format("Hello {0}.\\nCurrent Date and Time: {1}", ex.Message, DateTime.Now.ToString());
                return(View("Error"));
            }
        }