Example #1
0
 public CampaignVM GetVMFromCampaign(Campaign campaign)
 {
     return new CampaignVM
     {
         Content = campaign.ContentTemplate,
         CreatedBy = campaign.CreatedBy,
         CreatedDate = campaign.CreatedDate,
         Id = campaign.Id,
         Name = campaign.Name,
         StatusDate = campaign.StatusDate,
         StatusId = campaign.StatusId,
         Subject = campaign.SubjectTemplate,
         TypeId = campaign.TypeId,
         RecipientField = campaign.RecipientField,
         FileName = campaign.FileName
     };
 }
Example #2
0
 private bool UpdateCampaignPercentage(Campaign campaign)
 {
     bool response = false;
     if (campaign.TypeId == (int)CampaignType.Email)
     {
         var emailList = campaignService.GetCampaignEmails(campaign.Id, MessageStatus.All);
         var sendEmails = emailList.Where(p => p.StatusId != (int)MessageStatus.New);
         if (emailList.Count() != 0 && sendEmails.Count() != 0)
         {
             campaign.PercentComplete = sendEmails.Count() / emailList.Count() * 100;
             if (campaign.PercentComplete == 100)
                 campaignService.UpdateCampaignStatus(campaign.Id, CampaignStatus.Completed);
             campaignService.UpdateCampaign(campaign);
             response = true;
         }
     }
     else
     {
         var smsList = campaignService.GetCampaignSmses(campaign.Id, MessageStatus.All);
         var sendSmses = smsList.Where(p => p.StatusId != (int)MessageStatus.New);
         if (smsList.Count() != 0 && sendSmses.Count() != 0)
         {
             campaign.PercentComplete = sendSmses.Count() / smsList.Count() * 100;
             if (campaign.PercentComplete == 100)
                 campaignService.UpdateCampaignStatus(campaign.Id, CampaignStatus.Completed);
             campaignService.UpdateCampaign(campaign);
             response = true;
         }
     }
     return response;
 }
Example #3
0
 private bool SendCampaign(Campaign campaign)
 {
     var user = new UserService().GetUser(campaign.CreatedBy);
     if (campaign != null && user != null)
     {
         if (campaign.StatusId == (int)CampaignStatus.Scheduled)
         {
             campaignService.UpdateCampaignStatus(campaign.Id, CampaignStatus.Progress);
         }
         if (campaign.TypeId == (int)CampaignType.Email)
         {
             if (emailCount < _emailBatchSize)
             {
                 var emailList = campaignService.GetCampaignEmails(campaign.Id, MessageStatus.New).Take(_emailBatchSize - emailCount).ToList();
                 SendEmails(user, emailList);
             }
         }
         else
         {
             if (smsCount < _smsBatchSize)
             {
                 var smsList = campaignService.GetCampaignSmses(campaign.Id, MessageStatus.New).Take(_smsBatchSize - smsCount);
                 SendSmes(user, smsList);
             }
         }
         UpdateCampaignPercentage(campaign);
         return true;
     }
     else
     {
         return false;
     }
 }
Example #4
0
 public bool UpdateCampaign(Campaign campaign)
 {
     unitOfWork.Begin();
     unitOfWork.Session.SaveOrUpdate(campaign);
     unitOfWork.Commit();
     return true;
 }
Example #5
0
        public int SaveCampaign(Campaign campaign)
        {
            unitOfWork.Begin();

            campaign.StatusId = (int)CampaignStatus.New;
            campaign.StatusDate = DateTime.Now;
            var campaignId = (int)unitOfWork.Session.Save(campaign);
            unitOfWork.Commit();
            return campaignId;
        }
Example #6
0
        public bool ReCreateCampaign(Campaign campaign,int oldTypeId)
        {
            try
            {

                if (oldTypeId == (int)CampaignType.Email)
                {
                    DeleteCampaignEmails(campaign.Id);
                }
                else
                {
                    DeleteCampaignSmses(campaign.Id);
                }
                campaign.StatusId = (int)CampaignStatus.New;
                campaign.StatusDate = DateTime.Now;
                UpdateCampaign(campaign);
                return true;
            }
            catch (Exception ex)
            {
                Elmah.ErrorSignal.FromCurrentContext().Raise(ex);
                return false;
            }
        }