Пример #1
0
        SerializeObject(SMSContainer objectToSerialize)
        {
            MemoryStream  stream = new MemoryStream();
            XmlSerializer xml    = new XmlSerializer(typeof(SMSContainer));

            xml.Serialize(stream, objectToSerialize);
            byte[] buffer = stream.GetBuffer();
            stream.Close();
            UTF8Encoding encoding  = new UTF8Encoding();
            string       slzString = encoding.GetString(buffer);

            return(slzString);
        }
Пример #2
0
        public bool Send(SMSDTO smsDTO, bool NotifySMS)
        {
            try
            {
                smsManager                  = new SMS();
                content                     = smsDTO.Content;
                date                        = DateTime.Now;
                smsManager.CONTENT          = content;
                smsManager.FROM             = SMSPhoneNumber;
                smsManager.TO               = smsDTO.To;
                smsManager.SMSGateWayServer = SMSGateWayServer;
                smsManager.SMSGateWayPort   = Utilities.Utilities.ParseInt(SMSGateWayPort);
                smsManager.REPORT           = SMSReport;
                smsManager.CHARGE           = SMSCharge;
                smsManager.ProxyUserName    = ProxyUserName;
                smsManager.ProxyPassword    = ProxyPassword;
                smsManager.TRANSID          = SMSTRANSID;
                smsManager.ProxyServer      = ProxyServer;
                smsManager.ProxyPort        = Utilities.Utilities.ParseInt(ProxyPort);
                smsManager.useProxy         = smsDTO.UseProxy;
                SMSContainer smsContainer = new SMSContainer();
                smsContainer.sms       = smsManager;
                smsContainer.NotifySMS = NotifySMS;
                SMSSerializer    serializer   = new SMSSerializer();
                string           serialObject = serializer.SerializeObject(smsContainer);
                SuEmailResending resending    = new SuEmailResending();
                resending.Creby        = UserAccount.UserID;
                resending.CreDate      = DateTime.Now;
                resending.emailtype    = "SMS+Notify";
                resending.lastsenddate = DateTime.Now.AddMinutes(ParameterServices.EmailPendingDuration * -1);
                resending.mailcontent  = serialObject;
                resending.retry        = 0;
                resending.sendto       = smsManager.TO;
                resending.status       = "New";
                resending.subject      = content;
                SuEmailResendingService.Save(resending);
                smsSendStatus = true;

                smsSendStatus = true;
            }
            catch (Exception ex)
            {
                smsSendStatus = false;
                SS.Standard.Utilities.Utilities.WriteLogs("SMSService : " + ex.Message.Replace("remote", "SMS remote"), "smslog", "Logs", "txt");
            }
            return(smsSendStatus);
        }
Пример #3
0
 static private void ResendThread()
 {
     while (cmdStop == false)
     {
         try
         {
             ParameterServices.Neologize();
             Log.WriteMsgLogs("Email Resending Process ...");
             Factory.CreateObject();
             Factory.SuEmailResendingQuery.DeleteSuccessItem();
             IList <SuEmailResending> ResendMails = Factory.SuEmailResendingQuery.FindAllEmailResending();
             EmailSerializer          serailer    = new EmailSerializer();
             SMSSerializer            smsserialer = new SMSSerializer();
             foreach (SuEmailResending item in ResendMails)
             {
                 bool success;
                 if (item.emailtype.Contains("SMS"))
                 {
                     success     = false;
                     item.status = "Retry";
                     try
                     {
                         SMSContainer sms = smsserialer.DeSerializeObject(item.mailcontent);
                         if (item.emailtype == "SMS")
                         {
                             success = Factory.SMSService.ReSend(sms.sms);
                         }
                         else if (item.emailtype == "SMS+Log")
                         {
                             success = Factory.SMSService.ReSend(sms.sms, sms.SMSLogid);
                         }
                         else if (item.emailtype == "SMS+Notify")
                         {
                             success = Factory.SMSService.ReSend(sms.sms, sms.NotifySMS);
                         }
                         if (success)
                         {
                             item.status = "Success";
                         }
                     }
                     catch (Exception e)
                     {
                         Log.WriteLogs(e);
                     }
                 }
                 else
                 {
                     try
                     {
                         EmailDTO email = serailer.DeSerializeObject(item.mailcontent);
                         email.Status = 2;
                         item.status  = "Retry";
                         if (IsEmptyMailList(email.MailSendTo))
                         {
                             AddMailSendTo sendto = new AddMailSendTo();
                             sendto.Email = SS.DB.Query.ParameterServices.AdminEmailAddress;
                             sendto.Name  = SS.DB.Query.ParameterServices.AdminName;
                             email.MailSendTo.Clear();
                             email.MailSendTo.Add(sendto);
                             email.Remark = "Send to email addresses is empty or invalid email format.";
                         }
                         email.IsMultipleReceiver = true;
                         success = Factory.EmailService.SendEmail(email);
                         if (success)
                         {
                             email.Status = 1;
                             item.status  = "Success";
                         }
                         //send completed then must keep log
                         AddEmailLog(email);
                     }
                     catch (Exception e)
                     {
                         Log.WriteLogs(e);
                     }
                 }
                 item.lastsenddate = DateTime.Now;
                 if (item.status == "Retry")
                 {
                     item.retry++;
                     if (item.retry > ParameterServices.MaxRetry)
                     {
                         item.status = "Fail";
                     }
                 }
                 Factory.SuEmailResendingService.Update(item);
             }
             Log.WriteMsgLogs("Finish");
             Thread.Sleep(SS.DB.Query.ParameterServices.EmailFlushingDuration * 60000);
         }
         catch (Exception e)
         {
             Log.WriteLogs(e);
             Thread.Sleep(SS.DB.Query.ParameterServices.EmailFlushingDuration * 60000);
             continue;
         }
     }
 }