Esempio n. 1
0
        /// <summary>
        /// Generate file report when print or send email.
        /// </summary>
        /// <param name="path"></param>
        /// <param name="model"></param>
        private void GenerateFile(string path, ResponseFileModel model)
        {
            Directory.CreateDirectory(path);
            string savePath = Path.Combine(path, model.FileName);

            File.WriteAllBytes(savePath, model.FileContent);
        }
Esempio n. 2
0
        /// <summary>
        /// Export evaluation summary stat to excel report.
        /// </summary>
        /// <param name="evaluationList">The evaluation collection.</param>
        /// <param name="summaryList">The summary evaluation collection.</param>
        /// <param name="model">The filter criteria value.</param>
        private ResponseFileModel ExportExcel(IEnumerable <Data.Pocos.Evaluation> evaluationList,
                                              IEnumerable <SummaryEvaluationViewModel> summaryList,
                                              EvaluationCompareReportRequestModel model)
        {
            var    result    = new ResponseFileModel();
            string sheetName = "รายงานเปรียบเทียบการประเมิน";

            using (var memoryStream = new MemoryStream())
            {
                IWorkbook workbook = new XSSFWorkbook();
                ISheet    sheet1   = workbook.CreateSheet(sheetName);

                sheet1.AddMergedRegion(new CellRangeAddress(2, 2, 0, 7));
                sheet1.AddMergedRegion(new CellRangeAddress(3, 3, 0, 3));

                int[] periodItemIds = this.GetPeriodByCriteria(model);
                int   rowIndex      = 2;

                this.GenerateTopicReport(workbook, sheet1, ref rowIndex, model);
                this.GenerateHeaderTable(workbook, sheet1, ref rowIndex);
                this.GeneratePeriodHeaderTable(workbook, sheet1, periodItemIds);
                this.GenerateContent(workbook, sheet1, rowIndex, periodItemIds, evaluationList, summaryList);

                workbook.Write(memoryStream);

                result.FileContent = memoryStream.ToArray();
                result.FileName    = $"EvaluationCompare_{DateTime.Now.ToString("yyyyMMddHHmmss")}.xlsx";
            }
            return(result);
        }
Esempio n. 3
0
        /// <summary>
        /// Get report file.
        /// </summary>
        /// <param name="path">The report file path.</param>
        /// <returns></returns>
        private ResponseFileModel GetFile(string path)
        {
            var result = new ResponseFileModel();

            string[] allfiles = Directory.GetFiles(path);
            foreach (var item in allfiles)
            {
                var fileByte = File.ReadAllBytes(item);
                result.FileName    = Path.GetFileName(item);
                result.FileContent = fileByte;
            }
            return(result);
        }
        /// <summary>
        /// Export evaluation summary stat to excel report.
        /// </summary>
        /// <param name="evaluationList">The evaluation collection.</param>
        /// <param name="summaryList">The summary evaluation collection.</param>
        /// <param name="model">The filter criteria value.</param>
        private ResponseFileModel ExportExcel(IEnumerable <Data.Pocos.Evaluation> evaluationList,
                                              IEnumerable <SummaryEvaluationViewModel> summaryList,
                                              VendorEvaluationStatusReportRequestModel model)
        {
            var    result    = new ResponseFileModel();
            string sheetName = "รายงานสถานะการประเมินผู้ขาย";

            using (var memoryStream = new MemoryStream())
            {
                IWorkbook workbook = new XSSFWorkbook();

                ISheet sheet1 = workbook.CreateSheet(sheetName);

                sheet1.AddMergedRegion(new CellRangeAddress(2, 2, 0, 7));
                sheet1.AddMergedRegion(new CellRangeAddress(3, 3, 0, 3));

                var periodItemList = _unitOfWork.GetRepository <PeriodItem>().GetCache();
                var empList        = _unitOfWork.GetRepository <Hremployee>().GetCache();
                int rowIndex       = 2;

                this.GenerateTopicReport(workbook, sheet1, ref rowIndex, model);

                foreach (var item in evaluationList)
                {
                    var summary    = summaryList.FirstOrDefault(x => x.Id == item.Id);
                    var periodItem = periodItemList.FirstOrDefault(x => x.Id == item.PeriodItemId.Value);
                    this.GenerateHeaderTable(workbook, sheet1, ref rowIndex);

                    //Merge header table.
                    sheet1.AddMergedRegion(new CellRangeAddress(rowIndex - 1, rowIndex, 0, 0));
                    sheet1.AddMergedRegion(new CellRangeAddress(rowIndex - 1, rowIndex, 1, 1));
                    sheet1.AddMergedRegion(new CellRangeAddress(rowIndex - 1, rowIndex, 2, 3));
                    sheet1.AddMergedRegion(new CellRangeAddress(rowIndex - 1, rowIndex, 4, 4));
                    sheet1.AddMergedRegion(new CellRangeAddress(rowIndex - 1, rowIndex, 5, 5));
                    sheet1.AddMergedRegion(new CellRangeAddress(rowIndex - 1, rowIndex, 6, 6));
                    sheet1.AddMergedRegion(new CellRangeAddress(rowIndex - 1, rowIndex, 7, 7));
                    sheet1.AddMergedRegion(new CellRangeAddress(rowIndex - 1, rowIndex, 8, 8));

                    this.GenerateContentTable(workbook, sheet1, summary, item, ref rowIndex, periodItem, empList);
                    rowIndex++;
                }

                workbook.Write(memoryStream);

                result.FileContent = memoryStream.ToArray();
                result.FileName    = $"EvaluationVendorStatus_{DateTime.Now.ToString("yyyyMMddHHmmss")}.xlsx";
            }
            return(result);
        }
        public DownloadProcessForm(ResponseFileModel entity, string floderpath)
        {
            InitializeComponent();

            _BGWorker.WorkerReportsProgress      = true;
            _BGWorker.WorkerSupportsCancellation = true;

            _BGWorker.DoWork             += _BGWorker_DoWork;
            _BGWorker.RunWorkerCompleted += _BGWorker_RunWorkerCompleted;
            _BGWorker.ProgressChanged    += _BGWorker_ProgressChanged;

            this.Shown += InstallProcessForm_Shown;

            _entity          = entity;
            _floderPath      = floderpath;
            this.label1.Text = "正在载入 " + entity.filename + "…";
            _log             = new Logging("log.txt");
        }
Esempio n. 6
0
        /// <summary>
        /// Export vendor evaluation report
        /// </summary>
        /// <param name="id">The evaluation identity.</param>
        /// <returns></returns>
        public ResponseFileModel EvaluationExportReport(int id)
        {
            var    response = new ResponseFileModel();
            string path     = this.GetReportDirectory("VendorEvaluationReport", id.ToString());

            if (this.ExistReport(path))
            {
                response = this.GetFile(path);
            }
            else
            {
                var reportData = this.GenerateDataReport(id);
                response = _reportService.CallVendorEvaluationReport(reportData);
                this.GenerateFile(path, response);
                this.UpdateStatusPrintFlag(id);
            }
            return(response);
        }
        /// <summary>
        /// Export evaluation summary stat to excel report.
        /// </summary>
        /// <param name="evaluationList">The evaluation collection.</param>
        /// <param name="summaryList">The summary evaluation collection.</param>
        /// <param name="model">The filter criteria value.</param>
        private ResponseFileModel ExportExcel(IEnumerable <Data.Pocos.Evaluation> evaluationList,
                                              IEnumerable <SummaryEvaluationViewModel> summaryList,
                                              InvestigateEvaluationReportRequestModel model)
        {
            var    result       = new ResponseFileModel();
            int    maxCountUser = summaryList.Select(x => x.UserLists.Count).Max();
            string sheetName    = "รายงานตรวจสอบสถานะการประเมิน";

            using (var memoryStream = new MemoryStream())
            {
                IWorkbook workbook = new XSSFWorkbook();

                ISheet sheet1 = workbook.CreateSheet(sheetName);

                sheet1.AddMergedRegion(new CellRangeAddress(2, 2, 0, 7));
                sheet1.AddMergedRegion(new CellRangeAddress(3, 3, 0, 3));
                sheet1.AddMergedRegion(new CellRangeAddress(5, 6, 0, 0));
                sheet1.AddMergedRegion(new CellRangeAddress(5, 6, 1, 1));
                sheet1.AddMergedRegion(new CellRangeAddress(5, 6, 2, 3));
                sheet1.AddMergedRegion(new CellRangeAddress(5, 6, 4, 4));
                sheet1.AddMergedRegion(new CellRangeAddress(5, 6, 5, 5));
                sheet1.AddMergedRegion(new CellRangeAddress(5, 6, 6, 6));
                sheet1.AddMergedRegion(new CellRangeAddress(5, 6, 7, 7));
                sheet1.AddMergedRegion(new CellRangeAddress(5, 6, 8, 8));
                sheet1.AddMergedRegion(new CellRangeAddress(5, 6, 9, 9));

                int rowIndex        = 2;
                int cellHeaderIndex = this.GenerateHeaderTable(workbook, sheet1, ref rowIndex, maxCountUser, model);
                this.GenerateContentTable(workbook, sheet1, summaryList, evaluationList, rowIndex, cellHeaderIndex);

                workbook.Write(memoryStream);

                result.FileContent = memoryStream.ToArray();
                result.FileName    = $"InvestigateEvaluation_{DateTime.Now.ToString("yyyyMMddHHmmss")}.xlsx";
            }
            return(result);
        }