コード例 #1
0
        private void dgvLogDetail_CellFormatting(object sender, DataGridViewCellFormattingEventArgs e)
        {
            if (e.ColumnIndex == ProcessDetailStatus.Index && e.Value != null)
            {
                LogTableDetail.ProcessStatusDetailEnum processStatus = (LogTableDetail.ProcessStatusDetailEnum)e.Value;

                e.Value = LogTableDetailsProcess.StatusDesc(processStatus);

                switch (processStatus)
                {
                case LogTableDetail.ProcessStatusDetailEnum.Warning:
                    e.CellStyle.ForeColor = Color.Black;
                    e.CellStyle.BackColor = Color.Yellow;
                    break;

                case LogTableDetail.ProcessStatusDetailEnum.Error:
                    e.CellStyle.ForeColor = Color.White;
                    e.CellStyle.BackColor = Color.Red;
                    break;

                case LogTableDetail.ProcessStatusDetailEnum.Fail:
                    e.CellStyle.ForeColor = Color.White;
                    e.CellStyle.BackColor = Color.DarkRed;
                    break;

                default:
                    e.CellStyle.ForeColor = Color.Black;
                    e.CellStyle.BackColor = Color.White;
                    break;
                }
            }
        }
コード例 #2
0
        public static string StatusDesc(LogTableDetail.ProcessStatusDetailEnum processStatus)
        {
            string desc = string.Empty;

            switch (processStatus)
            {
            case LogTableDetail.ProcessStatusDetailEnum.OK:
                desc = "Sukses";
                break;

            case LogTableDetail.ProcessStatusDetailEnum.Warning:
                desc = "Warning";
                break;

            case LogTableDetail.ProcessStatusDetailEnum.Error:
                desc = "Error";
                break;

            case LogTableDetail.ProcessStatusDetailEnum.Fail:
                desc = "Gagal";
                break;
            }

            return(desc);
        }
コード例 #3
0
        private static ExcelWorksheet LogWorksheet(ExcelPackage ep, DataTable headerData, DataTable detailData)
        {
            ExcelWorksheet ws = ep.Workbook.Worksheets["Log"];

            #region Header
            ws.Cells[1, 1].Value = "LOG " + headerData.Rows[0]["ProcessName"].ToString();
            ws.Cells[3, 1].Value = "ID:";
            ws.Cells[4, 1].Value = "Tanggal:";
            ws.Cells[5, 1].Value = "Jam:";
            ws.Cells[6, 1].Value = "Status:";

            ws.Cells[3, 2].Value = ((Guid)headerData.Rows[0]["RowID"]).ToString().ToUpper();
            ws.Cells[4, 2].Value = ((DateTime)headerData.Rows[0]["StartDate"]).ToString("dd/MM/yyyy");
            ws.Cells[5, 2].Value = ((DateTime)headerData.Rows[0]["StartDate"]).ToString("HH:mm:ss") + " s/d " + ((DateTime)headerData.Rows[0]["EndDate"]).ToString("HH:mm:ss");
            ws.Cells[6, 2].Value = LogTable.StatusDesc((LogTable.ProcessStatusEnum)headerData.Rows[0]["ProcessStatus"]);
            #endregion

            #region Table header
            ws.Cells[7, 1].Value = "No.";
            ws.Cells[7, 2].Value = "Nama Proses";
            ws.Cells[7, 3].Value = "Pesan Proses";
            ws.Cells[7, 4].Value = "Status Proses";
            ws.Cells[7, 5].Value = "Tanggal Proses";

            ws.Column(1).Width = 8;
            #endregion

            #region Body
            int stDataRow  = 8;
            int rowCounter = 8;

            foreach (DataRow dr in detailData.Rows)
            {
                LogTableDetail.ProcessStatusDetailEnum processStatus = (LogTableDetail.ProcessStatusDetailEnum)dr["ProcessStatus"];

                ws.Cells[rowCounter, 1].Value = dr["ProcessSeqNo"];
                ws.Cells[rowCounter, 2].Value = dr["ProcessLocation"];
                ws.Cells[rowCounter, 3].Value = dr["ProcessMessage"];
                ws.Cells[rowCounter, 4].Value = LogTableDetailsProcess.StatusDesc(processStatus);
                ws.Cells[rowCounter, 5].Value = dr["ProcessDate"];

                switch (processStatus)
                {
                case LogTableDetail.ProcessStatusDetailEnum.Warning:
                    ws.Cells[rowCounter, 1, rowCounter, 5].Style.Fill.PatternType = ExcelFillStyle.Solid;
                    ws.Cells[rowCounter, 1, rowCounter, 5].Style.Fill.BackgroundColor.SetColor(Color.LightYellow);
                    break;

                case LogTableDetail.ProcessStatusDetailEnum.Error:
                    ws.Cells[rowCounter, 1, rowCounter, 5].Style.Fill.PatternType = ExcelFillStyle.Solid;
                    ws.Cells[rowCounter, 1, rowCounter, 5].Style.Fill.BackgroundColor.SetColor(Color.Red);
                    ws.Cells[rowCounter, 1, rowCounter, 5].Style.Font.Color.SetColor(Color.White);
                    break;

                case LogTableDetail.ProcessStatusDetailEnum.Fail:
                    ws.Cells[rowCounter, 1, rowCounter, 5].Style.Fill.PatternType = ExcelFillStyle.Solid;
                    ws.Cells[rowCounter, 1, rowCounter, 5].Style.Fill.BackgroundColor.SetColor(Color.DarkRed);
                    ws.Cells[rowCounter, 1, rowCounter, 5].Style.Font.Color.SetColor(Color.White);
                    break;
                }

                rowCounter++;
            }
            #endregion

            #region Format Cells
            #region Border
            ws.Cells[1, 1].Style.Font.Size              = 15;
            ws.Cells[7, 1, 7, 5].Style.Font.Bold        = true;
            ws.Cells[7, 1, 7, 5].Style.Fill.PatternType = ExcelFillStyle.Solid;
            ws.Cells[7, 1, 7, 5].Style.Fill.BackgroundColor.SetColor(Color.LightCyan);

            var border = ws.Cells[7, 1, rowCounter, 5].Style.Border;
            border.Bottom.Style            =
                border.Top.Style           =
                    border.Left.Style      =
                        border.Right.Style = ExcelBorderStyle.Thin;
            #endregion

            #region Number
            ws.Cells[stDataRow, 5, rowCounter, 5].Style.Numberformat.Format = "dd/MM/yyyy HH:mm:ss";
            #endregion
            #endregion

            #region Alignment
            ws.Cells[3, 1, 6, 1].Style.HorizontalAlignment = ExcelHorizontalAlignment.Right;
            ws.Cells[3, 1, 6, 1].Style.Font.Bold           = true;
            ws.Cells[7, 1, 7, 5].Style.HorizontalAlignment = ExcelHorizontalAlignment.Center;

            for (int i = 2; i <= 5; i++)
            {
                ws.Column(i).AutoFit();
            }
            #endregion

            #region Footer
            rowCounter++;
            ws.Cells[rowCounter, 1].Value           = "Generated by SMS Scheduler, " + DateTime.Now.ToString("dd/MM/yyyy hh:mm:ss");
            ws.Cells[rowCounter, 1].Style.Font.Size = 8;
            #endregion

            return(ws);
        }