示例#1
0
        public void CreateExcel(string templateFileName, string savePath, SheetItems items)
        {
            Excel.Application excel    = null;
            Excel.Workbook    workbook = null;

            try
            {
                excel    = new Excel.Application();
                workbook = excel.Workbooks.Open(System.Windows.Forms.Application.StartupPath + "\\ReportTemplate\\" + templateFileName);

                LogGenerator.AppendLog("Excel Generate " + items.Name, LogType.Common, this);
                GenerateReport(workbook, items);
                workbook.SaveAs(savePath);
            }
            catch (Exception ex)
            {
                LogGenerator.AppendLog(ex.StackTrace, LogType.Exception, this);
                MessageBox.Show(ex.Message);
            }
            finally
            {
                workbook.Close(false);
                ReleaseObject(ref workbook);
                excel.Quit();
                ReleaseObject(ref excel);
            }
        }
示例#2
0
        private DataTable GetResultByQuery(string query, SqlConnection conn)
        {
            DataTable      dataTable = new DataTable();
            SqlDataAdapter da        = null;

            try
            {
                SqlCommand cmd = new SqlCommand(query, conn);
                cmd.CommandTimeout = 0;
                conn.Open();
                LogGenerator.AppendLog(query, LogType.SQLQuery, this);
                da = new SqlDataAdapter(cmd);

                da.Fill(dataTable);
                da.Dispose();
            }
            catch (Exception ex)
            {
                LogGenerator.AppendLog(ex.StackTrace, LogType.Exception, this);
                MessageBox.Show(ex.Message);
            }
            finally
            {
                conn.Close();
            }
            return(dataTable);
        }
示例#3
0
        public MainForm()
        {
            InitializeComponent();

            #region MultiLang
            BtnReport_BandpassTrend.Text = MultiLang.TrendOfMeasurements;
            BtnReport_PointTrend.Text    = MultiLang.TrendOfPoint;
            BtnReport_DayOfWeek.Text     = MultiLang.WeeklyComparison;
            BtnReport_Period.Text        = MultiLang.PeriodicComparison;
            BtnReport_Daily.Text         = MultiLang.Daily;
            BtnReport_Repair.Text        = MultiLang.MaintenanceTask;
            BtnReport_PeriodDays.Text    = MultiLang.PeriodDays;
            BtnReport_GeneralTrend.Text  = MultiLang.GenaralTrend;

            BtnConfig_BandpassTrend.Text = MultiLang.Configuration;
            BtnConfig_PointTrend.Text    = MultiLang.Configuration;
            BtnConfig_DayOfWeek.Text     = MultiLang.Configuration;
            BtnConfig_Period.Text        = MultiLang.Configuration;
            BtnConfig_Daily.Text         = MultiLang.Configuration;
            BtnConfig_Repair.Text        = MultiLang.Configuration;
            BtnConfig_PeriodDays.Text    = MultiLang.Configuration;
            BtnConfig_GeneralTrend.Text  = MultiLang.Configuration;

            BtnPreview_BandpassTrend.Text = MultiLang.Preview;
            BtnPreview_PointTrend.Text    = MultiLang.Preview;
            BtnPreview_DayOfWeek.Text     = MultiLang.Preview;
            BtnPreview_Period.Text        = MultiLang.Preview;
            BtnPreview_Daily.Text         = MultiLang.Preview;
            BtnPreview_Repair.Text        = MultiLang.Preview;
            BtnPreview_PeriodDays.Text    = MultiLang.Preview;
            BtnPreview_GeneralTrend.Text  = MultiLang.Preview;
            #endregion

            SQLRepository.Init();
            LogGenerator.CreateLogFile();
            CreatePreviewSample();
            DBConn           = new DBConnector();
            ExcelManager     = new ExcelIOManager();
            MultiBandConf    = new MultiMeasureConfiguration();
            MultiPointConf   = new MultiPointConfiguration();
            DayOfWeekConf    = new DayOfWeekConfiguration();
            PeriodConf       = new PeriodConfiguration();
            DailyConf        = new DailyConfiguration();
            RepairConf       = new RepairConfiguration();
            PeriodDaysConf   = new PeriodDaysConfiguration();
            GeneralTrendConf = new GeneralTrendConfiguration();


            PeriodDaysConfigDlg = new PeriodDaysDlg(PeriodDaysConf)
            {
                Owner = this
            };
            DailyConfDlg = new DailyConfigDlg(DailyConf)
            {
                Owner = this
            };
            MultiBandConfigDlg = new MultiMeasureConfigDlg(MultiBandConf)
            {
                Owner = this
            };
            MultiPointConfigDlg = new MultiPointConfigDlg(MultiPointConf)
            {
                Owner = this
            };
            DayOfWeekConfigDlg = new DayOfWeekConfigDlg(DayOfWeekConf)
            {
                Owner = this
            };
            PeriodConfigDlg = new PeriodConfigDlg(PeriodConf)
            {
                Owner = this
            };
            RepairConfigDlg = new RepairConfigDlg(RepairConf)
            {
                Owner = this
            };
            GeneralTrendConfigDlg = new GeneralConfigDlg(GeneralTrendConf)
            {
                Owner = this
            };
        }