Пример #1
0
        public virtual void CreateAnswerData(bool createResult = true)
        {
            Answer.Data = new List<ReportAnswerRecord>();
            Answer.Columns = new Dictionary<string, string>();
            Answer.Formats = new Dictionary<string, string>();

            if (createResult) {
                ReportAnswerRecord recordResult=new ReportAnswerRecord();
                recordResult.Header = "Итог";
                recordResult.DataStr = new Dictionary<string, double>();
                foreach (RecordTypeBase recordType in RecordTypes.Values) {
                    if (recordType.Visible) {
                        recordResult.DataStr.Add(recordType.ID, ResultData[recordType.ID]);
                    }
                }
                Answer.Data.Add(recordResult);
            }

            foreach (RecordTypeBase recordType in RecordTypes.Values) {
                if (recordType.Visible) {
                    if (!Answer.Columns.Keys.Contains(recordType.ID)) {
                        Answer.Columns.Add(recordType.ID, recordType.Title);
                        Answer.Formats.Add(recordType.ID, recordType.FormatDouble);
                    }
                }
            }

            foreach (DateTime date in Dates) {
                ReportAnswerRecord record=new ReportAnswerRecord();
                record.Header = GetCorrectedDateForTable(date).ToString(getDateFormat());
                record.DataStr = new Dictionary<string, double>();
                foreach (RecordTypeBase recordType in RecordTypes.Values) {
                    if (recordType.Visible) {
                        record.DataStr.Add(recordType.ID, Data[date][recordType.ID]);
                    }
                }
                Answer.Data.Add(record);
            }
        }
Пример #2
0
        public virtual void CreateAnswerData(bool createResult = true, List<Report> reportAddList = null)
        {
            Answer.Data = new List<ReportAnswerRecord>();
            Answer.Columns = new Dictionary<string, string>();
            Answer.Formats = new Dictionary<string, string>();

            if (createResult) {
                ReportAnswerRecord recordResult=new ReportAnswerRecord();
                recordResult.Header = "Итог";
                recordResult.DataStr = new Dictionary<string, double>();
                foreach (RecordTypeBase recordType in RecordTypes.Values) {
                    if (recordType.Visible) {
                        recordResult.DataStr.Add(recordType.ID, ResultData[recordType.ID]);
                        if (reportAddList != null) {
                            foreach (Report reportAdd in reportAddList) {
                                recordResult.DataStr.Add(recordType.ID + "_" + reportAdd.AddReportTitle, reportAdd.ResultData[recordType.ID]);
                            }
                        }
                    }
                }
                Answer.Data.Add(recordResult);
            }

            foreach (RecordTypeBase recordType in RecordTypes.Values) {
                if (recordType.Visible) {
                    if (!Answer.Columns.Keys.Contains(recordType.ID)) {
                        string title=reportAddList != null ? recordType.Title + " " + AddReportTitle : recordType.Title;
                        Answer.Columns.Add(recordType.ID, title);
                        Answer.Formats.Add(recordType.ID, recordType.FormatDouble);
                        if (reportAddList != null) {
                            foreach (Report reportAdd in reportAddList) {
                                Answer.Columns.Add(recordType.ID + "_" + reportAdd.AddReportTitle, recordType.Title + " " + reportAdd.AddReportTitle);
                                Answer.Formats.Add(recordType.ID + "_" + reportAdd.AddReportTitle, recordType.FormatDouble);
                            }
                        }
                    }
                }
            }

            foreach (DateTime date in Dates) {
                ReportAnswerRecord record=new ReportAnswerRecord();
                record.Header = GetCorrectedDateForTable(date).ToString(getDateFormat(reportAddList != null));
                record.DataStr = new Dictionary<string, double>();
                foreach (RecordTypeBase recordType in RecordTypes.Values) {
                    if (recordType.Visible) {
                        record.DataStr.Add(recordType.ID, Data[date][recordType.ID]);
                        if (reportAddList != null) {
                            foreach (Report reportAdd in reportAddList) {
                                try {
                                    int diffY = reportAdd.DateStart.Year - DateStart.Year;
                                    int diffM = reportAdd.DateStart.Month - DateStart.Month;
                                    int diffD = reportAdd.DateStart.Day - DateStart.Day;
                                    DateTime newDate=date.AddYears(diffY).AddMonths(diffM).AddDays(diffD);
                                    record.DataStr.Add(recordType.ID + "_" + reportAdd.AddReportTitle, reportAdd.Data[newDate][recordType.ID]);
                                } catch { }
                            }
                        }
                    }
                }
                Answer.Data.Add(record);
            }
        }