Exemple #1
0
 public static void ExportPublisherHistories2PdfFile(InforHistoryExportingOption option, IList<InforHistory> histories, string filePath)
 {
     throw new System.Exception();
 }
        private void btn_export_Click(object sender, EventArgs e)
        {
            var isDatePeriodEnabled = dtp_start_date.Enabled && dtp_end_date.Enabled;

            if (isDatePeriodEnabled && dtp_start_date.Value > dtp_end_date.Value)
            {
                MessageBox.Show("开始时间大于结束时间,不能查询。");
                return;
            }

            var tmp = Convert.ToInt32(cmb_publisher.SelectedValue);
            var publisherId = tmp == _all_publisher_presentation ? null : (int?)tmp;
            var keywords = "";
            var startDate = dtp_start_date.Value;
            var startTime = !isDatePeriodEnabled ? null : (DateTime?)new DateTime(startDate.Year, startDate.Month, startDate.Day, 0, 0, 0);
            var endDate = dtp_end_date.Value;
            var endTime = !isDatePeriodEnabled ? null : (DateTime?)new DateTime(endDate.Year, endDate.Month, endDate.Day, 23, 59, 59);
            var totalCount = 0;
            var histories = _bizInfoMedia.GetInforHistories(publisherId, keywords, startTime, endTime, null, 999999, 1, out totalCount);

            if (histories == null || histories.Count == 0)
            {
                MessageBox.Show(string.Format("发布者:{0}在规定时间段内无任务动态,不能导出。", cmb_publisher.SelectedText));
                return;
            }

            var folderPath = ConfigurationManager.AppSettings["path-publisher-history-export-folder"];
            var publisherName = publisherId == null ? cmb_publisher_group.Text : cmb_publisher.SelectedText;
            var fileName = !isDatePeriodEnabled ? string.Format("分组--{0}.pdf", publisherName) : string.Format("{0}--{1}-{2}.pdf", publisherName, startDate.ToString("yyyyMMdd"), endDate.ToString("yyyyMMdd"));
            var filePath = Path.Combine(folderPath, fileName);
            var option = new InforHistoryExportingOption()
            {
                PublisherName = publisherName,
                StartTime = startTime,
                EndTime = endTime,
                TotalCount = histories.Count
            };

            GeneralHelper.ExportPublisherHistories2PdfFile(option, histories, filePath);
        }