Exemple #1
0
        public void Troubleshoot_general_report()
        {
            Debug.Listeners.Add(new ConsoleTraceListener());
            QueryCatcher.Catch("Inforoom.ReportSystem.Helpers");
            uint id          = 144;
            var  cn          = "server=sql.analit.net;user=;password=;default command timeout=0;Allow user variables=true;database=usersettings";
            var  dataAdapter = new MySqlDataAdapter("", cn);

            dataAdapter.SelectCommand.CommandText = @"
select
  *
from
  reports.Reports r,
  reports.reporttypes rt
where
	r.GeneralReportCode = ?reportcode
and rt.ReportTypeCode = r.ReportTypeCode";
            dataAdapter.SelectCommand.Parameters.AddWithValue("?reportcode", id);
            var res = new DataTable();

            dataAdapter.Fill(res);

            using (var connection = new MySqlConnection(cn)) {
                connection.Open();
                foreach (DataRow drGReport in res.Rows)
                {
                    if (Convert.ToBoolean(drGReport[BaseReportColumns.colEnabled]))
                    {
                        //Создаем отчеты и добавляем их в список отчетов
                        var reportcode = (ulong)drGReport[BaseReportColumns.colReportCode];
                        Console.WriteLine("Отчет {0}", reportcode);
                        var prop = GeneralReport.LoadProperties(connection, reportcode);

                        var bs = (BaseReport)Activator.CreateInstance(
                            GetReportTypeByName(drGReport[BaseReportColumns.colReportClassName].ToString()),
                            new object[] {
                            connection,
                            prop
                        });
                        bs.Session       = session.SessionFactory.OpenSession(connection);
                        bs.ReportCaption = "rep";
                        bs.Write(Path.GetFullPath("test.xls"));
                    }
                }
            }
        }