Exemple #1
0
        public static void SendMessage()
        {
            DataTable dt = new DataTable();

            using (Database db = new Database(GlobalVar.DBName))
            {
                db.Commands.Add(db.CreateCommand("usp_SMS_JatuhTempo"));
                dt = db.Commands[0].ExecuteDataTable();
            }

            if (dt.Rows.Count > 0)
            {
                string subject = MessageSetting.JTSubject;
                Guid   rowID   = LogTable.StartLog(subject.ToUpper());

                LogTableDetails logTableDetails = SendMessage(dt, rowID);

                LogTableDetailsProcess.AddLogDetails(logTableDetails);

                LogTable.EndLog(rowID);

                LogTableDetailsProcess.AddLogDetails(
                    BroadcastLog.SendEmail(rowID, subject, BroadcastLog.MailBodyBuilder(rowID, logTableDetails[logTableDetails.Count - 1].ProcessMessage).ToString())
                    , logTableDetails.Count);
            }
        }
Exemple #2
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);
        }