Ejemplo n.º 1
0
        public static LogTableDetail LogEnd(Guid processLogRowID, int rowsCount, int sentCount, int failedCount)
        {
            LogTableDetail logTableDetail = new LogTableDetail();

            logTableDetail.ProcessLogRowID = processLogRowID;
            logTableDetail.ProcessLocation = "AKHIR PROSES";
            logTableDetail.ProcessMessage  = "Jumlah Berhasil: " + sentCount.ToString() + "; Jumlah Gagal: " + failedCount.ToString() + "; Total: " + rowsCount.ToString();
            logTableDetail.ProcessStatus   = LogTableDetail.ProcessStatusDetailEnum.OK;
            logTableDetail.ProcessDate     = DateTime.Now;

            return(logTableDetail);
        }
Ejemplo n.º 2
0
        public static LogTableDetail LogStart(Guid processLogRowID, int rowsCount)
        {
            LogTableDetail logTableDetail = new LogTableDetail();

            logTableDetail.ProcessLogRowID = processLogRowID;
            logTableDetail.ProcessLocation = "AWAL PROSES";
            logTableDetail.ProcessMessage  = "Jumlah toko yang harus dikirimi SMS: " + rowsCount.ToString();
            logTableDetail.ProcessStatus   = LogTableDetail.ProcessStatusDetailEnum.OK;
            logTableDetail.ProcessDate     = DateTime.Now;

            return(logTableDetail);
        }
Ejemplo n.º 3
0
        private static LogTableDetail LogSendEmail(Guid processLogRowID, string mailSubject, string mailBody)
        {
            LogTableDetail logTableDetail = new LogTableDetail();

            logTableDetail.ProcessLogRowID = processLogRowID;
            logTableDetail.ProcessLocation = "KIRIM EMAIL";
            logTableDetail.ProcessMessage  = string.Empty;

            string attachmentFileName = string.Empty;

            try
            {
                attachmentFileName = AttachmentFileName(processLogRowID);
            }
            catch (Exception ex)
            {
                logTableDetail.ProcessMessage = ex.Message;
                logTableDetail.ProcessStatus  = LogTableDetail.ProcessStatusDetailEnum.Warning;
            }

            try
            {
                string body = string.Empty;
                if (attachmentFileName != string.Empty)
                {
                    body = mailBody + "\n" +
                           "Silahkan cek attachment untuk lebih detail-nya.";

                    logTableDetail.ProcessMessage = "Pengiriman log melalui email";
                    logTableDetail.ProcessStatus  = LogTableDetail.ProcessStatusDetailEnum.OK;
                }
                else
                {
                    body = mailBody + "\n" +
                           "Attachment tidak bisa di-generate. Silahkan cek menu Log Monitoring untuk lebih detail-nya.";

                    logTableDetail.ProcessMessage = "Gagal generate attachment. " + logTableDetail.ProcessMessage;
                    logTableDetail.ProcessStatus  = LogTableDetail.ProcessStatusDetailEnum.Warning;
                }

                LogMail logMail = new LogMail();
                logMail.SendMail(mailSubject, body, attachmentFileName);
            }
            catch (Exception ex)
            {
                logTableDetail.ProcessMessage = logTableDetail.ProcessMessage + "; " + ex.Message;
                logTableDetail.ProcessStatus  = LogTableDetail.ProcessStatusDetailEnum.Warning;
            }

            logTableDetail.ProcessDate = DateTime.Now;

            return(logTableDetail);
        }
Ejemplo n.º 4
0
        public static LogTableDetails SendEmail(Guid processLogRowID, string subject, string mailBody)
        {
            LogTableDetails logTableDetails = new LogTableDetails();

            LogTableDetail logTableDetail =
                LogSendEmail(processLogRowID,
                             subject,
                             mailBody);

            logTableDetails.Add(logTableDetail);

            return(logTableDetails);
        }
Ejemplo n.º 5
0
        public static LogTableDetail LogSend(Guid processLogRowID, string processLocation, string smsMessage,
                                             string processCategory, string sourceTable, string sourceID)
        {
            LogTableDetail logTableDetail = new LogTableDetail();

            logTableDetail.ProcessLogRowID = processLogRowID;
            logTableDetail.ProcessLocation = processLocation;
            logTableDetail.ProcessMessage  = smsMessage;
            logTableDetail.ProcessStatus   = LogTableDetail.ProcessStatusDetailEnum.OK;
            logTableDetail.ProcessDate     = DateTime.Now;
            logTableDetail.ProcessCategory = processCategory;
            logTableDetail.SourceTable     = sourceTable;
            logTableDetail.SourceID        = sourceID;

            return(logTableDetail);
        }
Ejemplo n.º 6
0
        public static LogTableDetail LogConnection(Guid processLogRowID, string processMessage, int failedCount)
        {
            LogTableDetail logTableDetail = new LogTableDetail();

            logTableDetail.ProcessLogRowID = processLogRowID;
            logTableDetail.ProcessLocation = "BUKA PORT";
            logTableDetail.ProcessMessage  = processMessage;
            if (failedCount == 0)
            {
                logTableDetail.ProcessStatus = LogTableDetail.ProcessStatusDetailEnum.OK;
            }
            else
            {
                logTableDetail.ProcessStatus = LogTableDetail.ProcessStatusDetailEnum.Fail;
            }
            logTableDetail.ProcessDate = DateTime.Now;

            return(logTableDetail);
        }
Ejemplo n.º 7
0
        public static LogTableDetail LogSend(Guid processLogRowID, string processLocation, string smsMessage,
                                             string errMessage, string processCategory, string sourceTable, string sourceID)
        {
            LogTableDetail logTableDetail = new LogTableDetail();

            logTableDetail.ProcessLogRowID = processLogRowID;
            logTableDetail.ProcessLocation = processLocation;
            if (errMessage == string.Empty)
            {
                logTableDetail.ProcessMessage = "Gagal kirim SMS.";
            }
            else
            {
                logTableDetail.ProcessMessage = errMessage;
            }
            logTableDetail.ProcessStatus   = LogTableDetail.ProcessStatusDetailEnum.Error;
            logTableDetail.ProcessDate     = DateTime.Now;
            logTableDetail.ProcessCategory = processCategory;
            logTableDetail.SourceTable     = sourceTable;
            logTableDetail.SourceID        = sourceID;

            return(logTableDetail);
        }
Ejemplo n.º 8
0
        private static LogTableDetails SendMessage(DataTable dt, Guid processLogRowID)
        {
            const string sourceTable = "Toko";

            int rowsCount = dt.Rows.Count;

            LogTableDetails logTableDetails = new LogTableDetails();

            LogTableDetail logTableDetail = BroadcastLog.LogStart(processLogRowID, rowsCount);

            logTableDetails.Add(logTableDetail);

            SerialPort    port             = new SerialPort();
            SMS           sms              = new SMS();
            ShortMessages objShortMessages = new ShortMessages();

            int sentCount   = 0;
            int failedCount = 0;

            try
            {
                int responseTimeout = MessageSetting.ResponseTimeout;

                port = sms.OpenPort(MessageSetting.PortName);

                logTableDetails.Add(BroadcastLog.LogConnection(processLogRowID, "Akses " + port.PortName, failedCount));

                string allMessageSet = MessageSetting.JTMsg;
                string praMessageSet = MessageSetting.PraJTMsg;
                string posMessageSet = MessageSetting.PosJTMsg;

                foreach (DataRow dr in dt.Rows)
                {
                    string kodeToko   = Tools.isNull(dr["KodeToko"], string.Empty).ToString();
                    string toko       = Tools.isNull(dr["NamaToko"], string.Empty).ToString();
                    string willID     = Tools.isNull(dr["WilID"], string.Empty).ToString();
                    string hp         = Tools.isNull(dr["HP"], string.Empty).ToString();
                    string kategori   = Tools.isNull(dr["Kategori"], string.Empty).ToString();
                    string praHari    = Tools.isNull(dr["<PraHari>"], string.Empty).ToString();
                    string posHari    = Tools.isNull(dr["<PosHari>"], string.Empty).ToString();
                    string praRpSisa  = Tools.isNull(dr["<PraRpSisa>"], string.Empty).ToString();
                    string posRpSisa  = Tools.isNull(dr["<PosRpSisa>"], string.Empty).ToString();
                    string kontakNoHP = Tools.isNull(dr["<KontakNoHP>"], string.Empty).ToString();
                    if (hp != string.Empty)
                    {
                        string processLocation = "SMS HP: " + hp + ", Toko: " + toko + ", IdWil: " + willID + ", Kode Toko: " + kodeToko;

                        string message = string.Empty;

                        switch (kategori.ToUpper())
                        {
                        case "ALL":
                            message = MessageSetting.ParseMsg(allMessageSet, dt.Columns, dr);
                            break;

                        case "PRA":
                            message = MessageSetting.ParseMsg(praMessageSet, dt.Columns, dr);
                            break;

                        case "POS":
                            message = MessageSetting.ParseMsg(posMessageSet, dt.Columns, dr);
                            break;

                        default:
                            break;
                        }

                        try
                        {
                            if (sms.SendMsg(port, hp, message, responseTimeout))
                            {
                                sentCount++;
                                logTableDetails.Add(BroadcastLog.LogSend(processLogRowID, processLocation, message, kategori, sourceTable, kodeToko));
                            }
                            else
                            {
                                failedCount++;
                                logTableDetails.Add(BroadcastLog.LogSend(processLogRowID, processLocation, message, string.Empty, kategori, sourceTable, kodeToko));
                            }
                        }
                        catch (Exception ex)
                        {
                            failedCount++;
                            logTableDetails.Add(BroadcastLog.LogSend(processLogRowID, processLocation, message, ex.Message, kategori, sourceTable, kodeToko));
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                failedCount = rowsCount;

                logTableDetails.Add(BroadcastLog.LogConnection(processLogRowID, ex.Message, failedCount));
            }

            sms.ClosePort(port);

            logTableDetails.Add(BroadcastLog.LogEnd(processLogRowID, rowsCount, sentCount, failedCount));

            return(logTableDetails);
        }