public Prikaz20Report(DateTime date) { this.Date = date; List<string> need=new List<string>(); need.Add(ReportMainRecords.P_SP.ID); need.Add(PiramidaRecords.P_GES.Key); need.Add(PiramidaRecords.P_GA1_Otd.Key); need.Add(PiramidaRecords.P_GA2_Otd.Key); need.Add(PiramidaRecords.P_GA3_Otd.Key); need.Add(PiramidaRecords.P_GA4_Otd.Key); need.Add(PiramidaRecords.P_GA5_Otd.Key); need.Add(PiramidaRecords.P_GA6_Otd.Key); need.Add(PiramidaRecords.P_GA7_Otd.Key); need.Add(PiramidaRecords.P_GA8_Otd.Key); need.Add(PiramidaRecords.P_GA9_Otd.Key); need.Add(PiramidaRecords.P_GA10_Otd.Key); need.Add(ReportLinesRecords.P_VL110_Saldo.ID); need.Add(ReportLinesRecords.P_VL220_Saldo.ID); need.Add(ReportLinesRecords.P_VL500_Saldo.ID); need.Add(ReportLinesRecords.P_KL6_Saldo.ID); ReportDay=new FullReport(date.Date, date.Date.AddDays(1), IntervalReportEnum.halfHour); ReportDay.InitNeedData(need); ReportMonth = new FullReport(new DateTime(Date.Year,Date.Month,1).Date, Date.Date.AddDays(1), IntervalReportEnum.halfHour); ReportMonth.InitNeedData(need); ReportDay.ReadData(); ReportMonth.ReadData(); }
public ReportAnswer GetFullReport(List<string> selectedData, DateTime dateStart, DateTime dateEnd, ReportTypeEnum ReportType) { try { Logger.Info(String.Format("Получение отчета {0} - {1} [{2}]",dateStart,dateEnd,ReportType)); FullReport report=new FullReport(dateStart, dateEnd, Report.GetInterval(ReportType)); report.InitNeedData(selectedData); report.ReadData(); report.CreateAnswerData(); report.CreateChart(); Logger.Info("Отчет сформирован: "+report.Answer.Data.Count()); return report.Answer; } catch (Exception e) { Logger.Error("Ошибка при получении отчета " + e.ToString()); return null; } }
public static void WriteTemp(DateTime dateStart, DateTime dateEnd) { Logger.Info(String.Format("{0} - {1}", dateStart, dateEnd)); FullReport report=new FullReport(dateStart.Date, dateEnd.Date, IntervalReportEnum.day); List<string> need=new List<string>(); need.Add(PiramidaRecords.Water_Temp.Key); report.InitNeedData(need); report.ReadData(); List<string> insertsStrings=new List<string>(); List<string> dates=new List<string>(); foreach (DateTime date in report.Dates) { insertsStrings.Add(String.Format(DBClass.InsertInfoFormat,26,1,373,report[date,PiramidaRecords.Water_Temp.Key],2, date.ToString(DBClass.DateFormat), DateTime.Now.ToString(DBClass.DateFormat), DBSettings.getSeason(date))); dates.Add(String.Format("'{0}'",date.ToString(DBClass.DateFormat))); } List<string>ins=new List<string>(); string delStr=String.Format("DELETE FROM DATA WHERE OBJECT=1 AND OBJTYPE=2 AND PARNUMBER=26 and item=373 and DATA_DATE IN ({0})", String.Join(",", dates)); SqlConnection con = PiramidaAccess.getConnection("P3000"); con.Open(); SqlTransaction transact=con.BeginTransaction(); if (dates.Count > 0) { DBClass.Run(delStr, transact); DBClass.AddData(insertsStrings, DBClass.InsertIntoHeader, transact); try { transact.Commit(); } catch (Exception e) { Logger.Info(e.ToString()); } finally { try { transact.Connection.Close(); } catch { } } } }