Пример #1
0
        // Chart Rendering When the page loaded.
        private void RenderCurrentChart()
        {
            SqlConnection conn = null;

            try
            {
                while (IsReading)
                {
                    conn = new SqlConnection(connString);
                    conn.Open();

                    SqlCommand    Cmd = new SqlCommand("SELECT TOP (15) [TimestampUTC],[Value] FROM[ION_Data].[dbo].[vCurrent] ORDER BY TimestampUTC DESC", conn);
                    SqlDataReader Sdr = Cmd.ExecuteReader();

                    while (Sdr.Read())
                    {
                        CurrentChartValues.Add(new SampleChart
                        {
                            DateTime = Sdr.GetDateTime(0).AddHours(9),
                            Value    = Sdr.GetDouble(1),
                        });
                    }

                    Current = Convert.ToDouble((CurrentChartValues[0].Value.ToString("N2")));

                    var now = DateTime.Now;
                    SetAxisLimits(now);

                    if (conn != null)
                    {
                        conn.Close();
                    }

                    Thread.Sleep(60000);
                    CurrentChartValues.Clear();
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
            finally
            {
                if (conn != null)
                {
                    conn.Close();
                }
            }
        }
Пример #2
0
        /// <summary>
        /// Update the current cartesian graph
        /// </summary>
        /// <param name="currentLevel"></param>
        /// <param name="now"></param>
        private void updateCurrentValues(float currentLevel, DateTime now)
        {
            Console.WriteLine("Updating current widget");
            this.Dispatcher.Invoke(() => {
                if (currentItemCount > cartesianItemMaxCount)
                {
                    CurrentChartValues.Clear();
                    currentItemCount = 0;
                }
                else
                {
                    currentItemCount += 1;
                }

                CurrentChartValues.Add(new MeasureModel {
                    Value    = currentLevel,
                    DateTime = now
                });
                this.currentValueTextBlock.Text = "Current : " + currentLevel;
            });
        }