Exemplo n.º 1
0
        protected override void OnStart(string[] args)
        {
            // TODO: Add code here to start your service.
            ParameterServices.Neologize();
            ThreadStart st = new ThreadStart(ResendThread);

            workerThread = new Thread(st);
            cmdStop      = false;
            workerThread.Start();
        }
Exemplo n.º 2
0
        public void UpdateParameter(DbParameter parameter)
        {
            #region Validate DbParameter
            Spring.Validation.ValidationErrors errors = new Spring.Validation.ValidationErrors();

            if (parameter.ParameterType.ToLower().Trim() == "integer")
            {
                try
                {
                    int typeDecimal = int.Parse(parameter.ParameterValue);
                }
                catch
                {
                    errors.AddError("Parameter.Error", new Spring.Validation.ErrorMessage("RequiredTypeInteger"));
                }
            }
            else if (parameter.ParameterType.ToLower().Trim() == "date")
            {
                try
                {
                    DateTime typeDate = DateTime.Parse(parameter.ParameterValue);
                }
                catch
                {
                    errors.AddError("Parameter.Error", new Spring.Validation.ErrorMessage("RequiredTypeDateTime"));
                }
            }

            if (!errors.IsEmpty)
            {
                throw new ServiceValidationException(errors);
            }
            #endregion

            SsDbDaoProvider.DbParameterDao.SaveOrUpdate(parameter);
            ParameterServices.Neologize();
        }
Exemplo n.º 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;
         }
     }
 }