示例#1
0
        public static void Main(string[] args)
        {
            Stc.StartedList = new List <long>();

            Encryption.Key = new byte[] { 28, 14, 79, 24, 168, 2, 142, 10, 198, 6,
                                          89, 93, 115, 12, 253, 71, 62, 221, 55, 121, 38, 174, 6, 51, 168, 54, 2, 26, 228, 113, 32, 109 };
            Encryption.Vector = new byte[] { 195, 74, 41, 17, 219, 10, 64, 41, 81, 39, 209, 165, 4, 86, 236, 88 };

            Stc.ReadConfigs(); //Reads app.config file
            Business.Stc.ConnStr = Stc.ConnStr;

            // Dictionaries
            Business.Dictionary.DictionaryBusiness dictionaryBusiness = new Business.Dictionary.DictionaryBusiness();
            ResponseBo <List <DictionaryBo> >      responseDic        = dictionaryBusiness.GetList();

            Business.Stc.DicItemList = responseDic.Bo.Select(x => x.ToDicItem()).ToList();

            Business.Sys.SysBusiness sysBusiness = new Business.Sys.SysBusiness();
            Stc.SysSmsList = sysBusiness.GetSmsList().Bo;

            System.Timers.Timer tmSendSms = new System.Timers.Timer();
            tmSendSms.Interval = 5000;
            tmSendSms.Elapsed += tmSendSms_Elapsed;
            tmSendSms.Start();

            Console.ReadKey(true);
        }
示例#2
0
        public static void Main(string[] args)
        {
            //ReadOnlyCollection<TimeZoneInfo> timeZones = TimeZoneInfo.GetSystemTimeZones();
            //string naber = timeZones[10].ToString();

            IronPdf.License.LicenseKey = "IRONPDF-1EF01-118677-74BF79-A5392C3577-37E95A5C-NEx-1EF01";

            Stc.StartedList = new List <long>();

            Encryption.Key = new byte[] { 28, 14, 79, 24, 168, 2, 142, 10, 198, 6,
                                          89, 93, 115, 12, 253, 71, 62, 221, 55, 121, 38, 174, 6, 51, 168, 54, 2, 26, 228, 113, 32, 109 };
            Encryption.Vector = new byte[] { 195, 74, 41, 17, 219, 10, 64, 41, 81, 39, 209, 165, 4, 86, 236, 88 };

            Stc.ReadConfigs(); //Reads app.config file
            Business.Stc.ConnStr = Stc.ConnStr;

            //string reportService = Encryption.DecryptString("183070049171182237226106168064219126098169172105");
            //string remindService = Encryption.DecryptString("145014132246120143136238214020201124174180138135");
            //string notifyService = Encryption.DecryptString("067092194112154010003231169086207040039193099010");

            // Dictionaries
            Business.Dictionary.DictionaryBusiness dictionaryBusiness = new Business.Dictionary.DictionaryBusiness();
            ResponseBo <List <DictionaryBo> >      responseDic        = dictionaryBusiness.GetList();

            Business.Stc.DicItemList = responseDic.Bo.Select(x => x.ToDicItem()).ToList();

            Business.Sys.SysBusiness sysBusiness = new Business.Sys.SysBusiness();
            Stc.SysMailList = sysBusiness.GetMailList().Bo;

            System.Timers.Timer tmSendMail = new System.Timers.Timer();
            tmSendMail.Interval = 5000;
            tmSendMail.Elapsed += tmSendMail_Elapsed;
            tmSendMail.Start();

            System.Timers.Timer tmSchedule = new System.Timers.Timer();
            tmSchedule.Interval = 1000;
            tmSchedule.Elapsed += tmSchedule_Elapsed;
            tmSchedule.Start();

            Console.ReadKey(true);
        }
示例#3
0
        public void Send(NotificationEMailListBo eMailBo)
        {
            if (Stc.StartedList.Count(x => x == eMailBo.Id) > 0)
            {
                return;
            }

            //if (eMailBo.ReceiverList.Count(x => x.Receiver != "*****@*****.**") > 0) return;
            Stc.StartedList.Add(eMailBo.Id);
            SaveLog(eMailBo, Enums.EMailLogEvents.xStarted, null);
            Stc.sayi = 1;

            try
            {
                Business.Sys.SysBusiness sysBusiness = new Business.Sys.SysBusiness();
                SysMailBo sysMailBo = Stc.SysMailList.FirstOrDefault(x => x.Id == sysBusiness.GetSysMailId(eMailBo.SubjectTypeId));

                //string displayName = "Elmasium - " + Business.Stc.GetDicValue(sysMailBo.DisplayName, eMailBo.LanguageId);
                //if (eMailBo.SubjectTypeId == Enums.EMailSubjectTypes.xWelcome)
                //    displayName = Business.Stc.GetDicValue("xWelcomeElmasium", eMailBo.LanguageId);

                eMailBo.Content = Business.Stc.DictionaryProcessText(eMailBo.Content, eMailBo.LanguageId);

                MailMessage mail = new MailMessage();
                mail.From       = new MailAddress(eMailBo.Sender, eMailBo.SenderDisplayName);
                mail.Body       = eMailBo.Content;
                mail.IsBodyHtml = eMailBo.IsContentHtml;
                mail.Subject    = eMailBo.Subject;

                foreach (NotificationEMailReceiverListBo item in eMailBo.ReceiverList)
                {
                    switch (item.ReceiverTypeId)
                    {
                    case Enums.EMailReceiverTypes.To:
                        mail.To.Add(new MailAddress(item.Receiver));
                        break;

                    case Enums.EMailReceiverTypes.Cc:
                        mail.CC.Add(new MailAddress(item.Receiver));
                        break;

                    case Enums.EMailReceiverTypes.Bcc:
                        mail.Bcc.Add(new MailAddress(item.Receiver));
                        break;

                    default:
                        mail.To.Add(new MailAddress(item.Receiver));
                        break;
                    }
                }

                if (eMailBo.AttachList != null && eMailBo.AttachList.Count() > 0)
                {
                    string outputPath = null;

                    foreach (NotificationEMailAttachListBo item in eMailBo.AttachList)
                    {
                        outputPath   = Path.Combine(Stc.PdfFileDirectory, item.UniqueId.ToString().ToUpper() + ".pdf");
                        item.HtmlRaw = Business.Stc.DictionaryProcessText(item.HtmlRaw, eMailBo.LanguageId);

                        SaveAttach(item, outputPath);

                        Attachment attachment = new Attachment(outputPath);
                        attachment.Name = item.PseudoFileName;

                        mail.Attachments.Add(attachment);
                    }

                    SaveLog(eMailBo, Enums.EMailLogEvents.xAttachFilesSavedSuccess, null);
                }

                SmtpClient smtp = new SmtpClient
                {
                    Host                  = sysMailBo.Host,
                    Port                  = sysMailBo.Port,
                    EnableSsl             = sysMailBo.Ssl,
                    DeliveryMethod        = SmtpDeliveryMethod.Network,
                    UseDefaultCredentials = false,
                    Credentials           = new NetworkCredential(mail.From.Address, sysMailBo.Password)
                };

                smtp.SendCompleted += (s, e) =>
                {
                    mail.Dispose();
                    smtp.Dispose();

                    ResponseBo exResponseBo = null;
                    if (e.Error != null)
                    {
                        exResponseBo = SaveExLog(e.Error, this.GetType(), MethodBase.GetCurrentMethod().Name);
                    }

                    SaveLog(eMailBo, Enums.EMailLogEvents.xTransactionSuccessful, exResponseBo?.ReturnedId);

                    SaveSent(eMailBo, true);
                };

                smtp.SendAsync(mail, null);
            }
            catch (Exception ex)
            {
                ResponseBo exResponseBo = SaveExLog(ex, this.GetType(), MethodBase.GetCurrentMethod().Name);

                SaveLog(eMailBo, Enums.EMailLogEvents.xUnexpectedErrorOccurred, exResponseBo.ReturnedId);
                SaveSent(eMailBo, false);
            }
        }
示例#4
0
        public void Send(NotificationSmsListBo smsBo)
        {
            if (Stc.StartedList.Count(x => x == smsBo.Id) > 0)
            {
                return;
            }

            //if (smsBo.ReceiverList.Count(x => x.Receiver != "*****@*****.**") > 0) return;
            Stc.StartedList.Add(smsBo.Id);
            SaveLog(smsBo, Enums.SmsLogEvents.xStarted, null, null, true);


            try
            {
                Business.Sys.SysBusiness sysBusiness = new Business.Sys.SysBusiness();
                SysSmsBo sysSmsBo = Stc.SysSmsList.FirstOrDefault(x => x.Id == 0);

                //string displayName = "Elmasium - " + Business.Stc.GetDicValue(sysSmsBo.DisplayName, smsBo.LanguageId);
                //if (smsBo.SubjectTypeId == Enums.EMailSubjectTypes.xWelcome)
                //    displayName = Business.Stc.GetDicValue("xWelcomeElmasium", smsBo.LanguageId);

                smsBo.TextMessage = Business.Stc.DictionaryProcessText(smsBo.TextMessage, smsBo.LanguageId);

                ISmsService smsService = null;
                if (sysSmsBo.Id == 0)
                {
                    smsService = new OutService.NetgsmService();
                }

                smsService.UrlAddress    = sysSmsBo.UrlAddress;
                smsService.OtpUrlAddress = sysSmsBo.OtpUrlAddress;

                smsService.Username = sysSmsBo.Username;
                smsService.Password = sysSmsBo.Password;

                smsService.CompanyName = sysSmsBo.CompanyName;

                smsService.Caption     = smsBo.Caption;
                smsService.TextMessage = smsBo.TextMessage;

                smsService.IsSupportTr = true;

                smsService.PhoneNumberList = new List <string>();
                foreach (NotificationSmsReceiverListBo item in smsBo.ReceiverList)
                {
                    smsService.PhoneNumberList.Add("0" + item.Receiver);
                }

                ServiceReturnBo returnBo = smsService.Send();

                SaveLog(smsBo, Enums.SmsLogEvents.xTransactionSuccessful, null, returnBo.ReturnValue, returnBo.IsSuccess);

                SaveSent(smsBo, true);
            }
            catch (Exception ex)
            {
                ResponseBo exResponseBo = SaveExLog(ex, this.GetType(), MethodBase.GetCurrentMethod().Name);

                SaveLog(smsBo, Enums.SmsLogEvents.xUnexpectedErrorOccurred, exResponseBo.ReturnedId, null, true);
                SaveSent(smsBo, false);
            }
        }