Exemplo n.º 1
0
        public void GenerateReport(DateTime ReportStart, DateTime ReportEnd, string OutputFile)
        {
            CSVDelimiter = System.Globalization.CultureInfo.CurrentCulture.TextInfo.ListSeparator;

            string QueryPart = "READDATETIME AS KAYITTARIHSAAT, WINDSPEED AS RUZGARHIZ, EXTERNALTEMP AS HAVASICAKLIK, INTERNALTEMP AS ICSICAKLIK, GEARBOXTEMP AS DISLIKUTUSUSICAKLIK, LOWSPEEDRPM AS ROTORDEVIR, HIGHSPEEDRPM AS ALTERNATORDEVIR, PACALTERNATORVOLTAGEL1 AS ALTERNATORGERILIML1, PACALTERNATORVOLTAGEL2 AS ALTERNATORGERILIML2, PACALTERNATORVOLTAGEL3 AS ALTERNATORGERILIML3, PACALTERNATORCURRENTL1 AS ALTERNATORAKIML1, PACALTERNATORCURRENTL2 AS ALTERNATORAKIML2, PACALTERNATORCURRENTL3 AS ALTERNATORAKIML3";

            string SelectCommandText = "SELECT TOP (100) PERCENT " + QueryPart + " FROM dbo.WTPLCTAGS WHERE (READDATETIME > @STARTTIME) AND (READDATETIME < @ENDTIME) ORDER BY WTPLCTAGID DESC";

            DataSet ReportDataset;

            try
            {
                using (DBUtilsRapor dbr = new DBUtilsRapor())
                {
                    ReportDataset = dbr.GetDataSet(SelectCommandText, ReportStart, ReportEnd);
                }

                ReportWriter = new StreamWriter(OutputFile);
                WriteReportHeader();
                WriteMaximums(ReportStart, ReportEnd);
                WriteReportTable(ReportDataset);
                ReportWriter.Flush();
                ReportWriter.Close();
            }
            catch (Exception)
            {
                throw;
            }
        }
Exemplo n.º 2
0
        private void WriteMaximums(DateTime ReportStart, DateTime ReportEnd)
        {
            StringBuilder Maximums = new StringBuilder();
            DataSet       ReportDataset;

            string SelectCommandText = "SELECT TOP (1) READDATETIME, WINDSPEED FROM dbo.WTPLCTAGS WHERE (READDATETIME > @STARTTIME) AND (READDATETIME < @ENDTIME) ORDER BY WINDSPEED DESC";
            string MaxWindSpeed; string MaxWindSpeedDateTime;

            try
            {
                using (DBUtilsRapor dbr = new DBUtilsRapor())
                {
                    ReportDataset = dbr.GetDataSet(SelectCommandText, ReportStart, ReportEnd);
                }

                MaxWindSpeedDateTime = ((DateTime)ReportDataset.Tables[0].Rows[0][0]).ToString("dd/MM/yyyy HH:mm:ss");
                MaxWindSpeed         = ((double)ReportDataset.Tables[0].Rows[0][1]).ToString("#.00");
            }
            catch (Exception)
            {
                throw;
            }

            ReportDataset.Clear();

            Maximums.AppendLine("Rapordaki En Yuksek Ruzgar Hizi ve Tarihi: " + MaxWindSpeed + " m/s - " + MaxWindSpeedDateTime);
            Maximums.AppendLine();

            ReportWriter.Write(Maximums);
            Maximums.Clear();
        }
Exemplo n.º 3
0
        private void DisplayChart()
        {
            QueryColumn = string.Empty;
            chart1.Series.Clear();

            if (QueryColumns.Count == 0)
            {
                return;
            }

            foreach (var Column in QueryColumns)
            {
                QueryColumn += Column.ToString() + ", ";
                Series Serie = chart1.Series.Add(Column.ToString());
                Serie.XValueMember  = "READDATETIME";
                Serie.YValueMembers = Column.ToString();
                Serie.ChartType     = SeriesChartType.Spline;
            }

            if (QueryColumn.Length > 2)
            {
                QueryColumn = QueryColumn.Substring(0, QueryColumn.Length - 2);
            }

            using (DBUtilsRapor dbu = new DBUtilsRapor())
            {
                try
                {
                    //string SelectCommand = "SELECT TOP (100) PERCENT READDATETIME, " + QueryColumn + " AS DATAVALUES FROM dbo.WTPLCTAGS WHERE (READDATETIME > @STARTTIME) AND(READDATETIME < @ENDTIME) ORDER BY WTPLCTAGID DESC";

                    string SelectCommand = "SELECT TOP (100) PERCENT READDATETIME, " + QueryColumn + " FROM dbo.WTPLCTAGS WHERE (READDATETIME > @STARTTIME) AND(READDATETIME < @ENDTIME) ORDER BY WTPLCTAGID DESC";

                    //string SelectCommand = "SELECT TOP (100) PERCENT READDATETIME, WINDSPEED, INTERNALTEMP FROM dbo.WTPLCTAGS WHERE (READDATETIME > @STARTTIME) AND(READDATETIME < @ENDTIME) ORDER BY WTPLCTAGID DESC";

                    chart1.DataSource = dbu.GetDataSet(SelectCommand, dateTimePicker1.Value, dateTimePicker2.Value);

                    dataGridView1.DataSource = dbu.GetDataSet(SelectCommand, dateTimePicker1.Value, dateTimePicker2.Value).Tables[0];
                    chart1.DataBind();
                    chart1.Update();
                }
                catch (Exception ex)
                {
                    Console.WriteLine(ex.Message);
                }
            }

            //chart1.SaveImage(@"C:\Users\Devrim Ersanli\testimage.jpg", ChartImageFormat.Jpeg);
        }