Esempio n. 1
0
        private static void ModifyValue()
        {
            TimeSeriesDataSet ds = CreateDataSet();

            DataTable tbl = ds.Tables[ds.Series[0].TableName];
            double    val = Convert.ToDouble(tbl.Rows[0][1]);

            Console.WriteLine("original value = " + val);
            val           += 1;
            tbl.Rows[0][1] = val;

            GraphData gd = new GraphData(ds, 0);

            Hdb.Instance.SaveChanges("day", gd, true, 'Z');

            ds = CreateDataSet();

            tbl = ds.Tables[ds.Series[0].TableName];

            double val2 = Convert.ToDouble(tbl.Rows[0][1]);

            if (val2 != val)
            {
                Console.WriteLine("Error: Test failed");
            }
            else
            {
                Console.WriteLine("Modify test ok");
            }
        }
Esempio n. 2
0
        private static void DeleteValue()
        {
            TimeSeriesDataSet ds = CreateDataSet();

            DataTable tbl      = ds.Tables[ds.Series[0].TableName];
            int       rowCount = tbl.Rows.Count;

            Console.WriteLine(tbl.Rows[0][1]);
            tbl.Rows[0][1] = DBNull.Value;

            GraphData gd = new GraphData(ds, 0);

            Hdb.Instance.SaveChanges("day", gd, false, 'Z');

            ds = CreateDataSet();

            tbl = ds.Tables[ds.Series[0].TableName];
            if (rowCount != tbl.Rows.Count)
            {
                Console.WriteLine("Error: Delete Test Failed");
            }
            else
            {
                Console.WriteLine("Delete Test ok");
            }
        }
Esempio n. 3
0
 public GraphData(TimeSeriesDataSet ds, int graphNumber)
 {
     dsTables = new DataSet();
     this.ds  = ds;
     SetDefaults();
     this.graphNumber = graphNumber;
     SetGraphTitle();
     SetSeriesTitles();
 }
Esempio n. 4
0
        private static TimeSeriesDataSet CreateDataSet()
        {
            TimeSeriesDataSet ds = new TimeSeriesDataSet();

            ds.Series.AddSeriesRow(0, 1, "CABALLO", "storage",
                                   "HDB", "table0", "", "storage", "acre-feet", "day", false,
                                   2678, false, "r_day", "", false, false, "N2", 0);
            ds.Graph.AddGraphRow(ds.Graph.NewGraphRow());
            ds.Graph[0].GraphType       = "TimeSeries";
            ds.Graph[0].BeginningDate   = new DateTime(2008, 4, 16);
            ds.Graph[0].EndingDate      = new DateTime(2008, 5, 16);
            ds.Graph[0].TimeWindowType  = "FromXToY";
            ds.Graph[0].InstantInterval = 15;
            GraphData gd = new GraphData(ds, 0);

            Hdb.Instance.Fill(gd);
            return(ds);
        }
Esempio n. 5
0
        /// <summary>
        /// Saves Time Series Data Set to xml file.
        /// Set SaveEveryting to true to save everything
        /// inculding the time series data loaded from the database.
        /// Otherwise the time series data tables are not saved.
        /// </summary>
        public void Save(string filename, bool SaveEverything)
        {
            this.FileName = filename;
            if (this.Graph.Rows.Count > 0)
            {
                //this.Graph[0].FileName = filename;
            }

            if (SaveEverything)
            {
                WriteXml(filename);
            }
            else
            {//
                TimeSeriesDataSet ds = new TimeSeriesDataSet();
                for (int i = 0; i < Series.Count; i++)
                {
                    SeriesRow r = ds.Series.NewSeriesRow();
                    ds.Series.AddSeriesRow(r);
                    for (int c = 0; c < Series.Columns.Count; c++)
                    {
                        r[c] = Series[i][c];
                    }
                }
                for (int i = 0; i < Graph.Count; i++)
                {
                    GraphRow r = ds.Graph.NewGraphRow();
                    ds.Graph.AddGraphRow(r);
                    for (int c = 0; c < Graph.Columns.Count; c++)
                    {
                        r[c] = Graph[i][c];
                    }
                }

                ds.WriteXml(filename);
            }
        }
Esempio n. 6
0
        /// <summary>
        /// Append another dataset this DataSet
        /// </summary>
        /// <param name="fileName"></param>
        public void AppendXmlFile(string fileName)
        {
            var ds = new TimeSeriesDataSet();

            ds.ReadXmlFile(fileName);

            int graphNum = this.Graph.GetMaxGraphNumber() + 1;

            foreach (var gr in ds.Graph)
            {
                if (gr.Name.Trim() == "")
                {
                    gr.Name = "Config" + graphNum;
                }

                var row = Graph.NewGraphRow();
                row.ItemArray   = gr.ItemArray;
                row.GraphNumber = graphNum;
                Graph.AddGraphRow(row);

                // use GraphData class to filter out Series Rows.
                GraphData gd = new GraphData(ds, gr.GraphNumber);

                int sn = this.Series.GetMaxSeriesNumber() + 1;
                foreach (var s in gd.SeriesRows)
                {
                    var row1 = Series.NewSeriesRow();
                    row1.ItemArray    = s.ItemArray;
                    row1.SeriesNumber = sn++;
                    row1.GraphNumber  = graphNum;
                    Series.AddSeriesRow(row1);
                }

                graphNum++;
            }
        }
Esempio n. 7
0
 public GraphListEditor(TimeSeriesDataSet ds)
 {
     InitializeComponent();
     this.dataSet = ds;
     LoadGraphList();
 }
Esempio n. 8
0
        /// <summary>
        /// This overloaded StandardTChart is used with WebChart.
        /// </summary>
        /// <param name="ds"></param>
        /// <param name="tChart1"></param>
        /// <returns></returns>
        static Chart StandardTChart(TimeSeriesDataSet ds, Chart tChart1)
        {
            if (tChart1 == null)
            {
                tChart1 = new Chart();
            }
            if (ds == null || ds.Series.Rows.Count == 0)
            {
                return(tChart1);
            }

            try
            {
                tChart1.Aspect.View3D     = false;
                tChart1.Aspect.Orthogonal = false;
                tChart1.Series.Clear();

                int sz = ds.Series.Count;
                if (sz == 1) // single graph series.
                {
                    tChart1.Legend.Visible = false;
                    //tChart1.Text = ds.Series[0].Title;
                }
                else
                {
                    tChart1.Legend.Visible   = true;
                    tChart1.Legend.Alignment = LegendAlignments.Top;
                    //tChart1.Text = "";
                }

                //tChart1.Text = ds.Graph[0].Title;

                string unitsOfFirstSeries = ds.Series[0].Units.Trim();
                for (int i = 0; i < sz; i++)
                {
                    string    tblName    = ds.Series[i].TableName;
                    DataTable dataTable  = ds.Tables[tblName];
                    string    columnName = dataTable.Columns[1].ColumnName;
                    double    avg        = AverageOfColumn(dataTable, columnName);
                    Steema.TeeChart.Styles.Line series = TChartSeries(tChart1, dataTable, columnName, avg);
                    series.Title = ds.Series[i].Title;
                    if (i > 0) // check units to determine what yaxis to use(left,or right)
                    {
                        string units = ds.Series[i].Units.Trim();
                        if (units != unitsOfFirstSeries)
                        {
                            series.VertAxis = Steema.TeeChart.Styles.VerticalAxis.Right;
                            tChart1.Axes.Right.Labels.Color = Color.Red;//series.Color;
                        }
                    }
                    tChart1.Series.Add(series);
                }

                //tChart1.Zoom.Undo();
                //tChart1.Zoom.ZoomPercent(97);
            }
            catch (Exception exc)
            {
                //System.Windows.Forms.MessageBox.Show("Error\n","\n"+exc.ToString());
                throw exc;
            }
            return(tChart1);
        }