public void InsertOrUpdateShortMessageTemplate(ShortMessageTemplate shortMessageTemplate)
 {
     context.Entry(shortMessageTemplate).State = shortMessageTemplate.ShortMessageTemplateID == 0 ? EntityState.Added : EntityState.Modified;
     SaveChanges();
 }
 public void InsertOrUpdateShortMessageTemplateRepository(ShortMessageTemplate shortMessageTemplate)
 {
     shortMessageTemplate.CompanyID = this.companyID;
     shortMessageTemplateRepository.InsertOrUpdateShortMessageTemplate(shortMessageTemplate);
 }
示例#3
0
        /// <summary>
        /// 
        /// </summary>
        /// <param name="parentType">Module name</param>
        /// <param name="parentID">Module primary key</param>
        /// <param name="notificationType">1.Email 2.SMS 3.Call</param>
        /// <param name="toUser">Receiver</param>
        /// <param name="templateID">1.Activation Email 2.Task assignment</param>
        /// <param name="templateValues">List of values to be replaced</param>
        public static void Notify(string parentType, long parentID, int notificationType, string toUser, int templateID, IDictionary templateValues)
        {
            NotificationBL notificationBL = new NotificationBL();
            C3App.DAL.Notification notification = new C3App.DAL.Notification();
            notification.Status = 1;
            notification.ParentType = parentType;
            notification.ParentID = parentID;
            notification.CreatedBy = Convert.ToInt64(HttpContext.Current.Session["UserID"]);
            notification.CreatedTime = DateTime.Now;
            string body = String.Empty;
            long notificationID;
            switch (notificationType)
            {
                case 1:
                    notification.NotificationTypeID = 1;
                    notificationID = notificationBL.InsertNotification(notification);
                    Email email = new Email();
                    email.Subject = "System-generated Mail";
                    email.FromAddress = ConfigurationManager.AppSettings["FromEmail"].ToString();
                    email.FromName = "Panacea Systems Ltd";
                    email.ToAddress = toUser;
                    email.Status = true;
                    email.DateStart = DateTime.Now;
                    email.ParentType = parentType;
                    email.ParentID = parentID;
                    email.AssignedUserID = Convert.ToInt64(HttpContext.Current.Session["UserID"]);
                    email.NotificationID = notificationID;
                    email.CreatedBy = Convert.ToInt64(HttpContext.Current.Session["UserID"]);
                    email.CreatedTime = DateTime.Now;
                    EmailTemplateBL emailTemplateBL = new EmailTemplateBL();
                    EmailTemplate emailTemplate = new EmailTemplate();
                    emailTemplate = emailTemplateBL.GetEmailTemplateByID(templateID).FirstOrDefault();
                    body = emailTemplate.BodyHTML;

                    foreach (DictionaryEntry de in templateValues)
                    {
                        body = body.Replace(de.Key.ToString(), de.Value.ToString());
                    }

                    email.BodyHTML = body;
                    EmailBL emailBL = new EmailBL();
                    emailBL.InsertEmail(email);
                    SendEmail(toUser,emailTemplate.Subject, body);
                    break;
                case 2:
                    notification.NotificationTypeID = 2;
                    notificationID = notificationBL.InsertNotification(notification);
                    ShortMessage shortMessage = new ShortMessage();
                    shortMessage.FromNumber = "Panacea";
                    shortMessage.ToNumber = toUser;
                    shortMessage.Type = "General";
                    shortMessage.Status = 1;
                    shortMessage.ParentType = parentType;
                    shortMessage.ParentID = parentID;
                    shortMessage.NotificationID = notificationID;
                    shortMessage.CreatedBy = Convert.ToInt64(HttpContext.Current.Session["UserID"]);
                    shortMessage.CreatedTime = DateTime.Now;
                    ShortMessageTemplateBL shortMessageTemplateBL = new ShortMessageTemplateBL();
                    ShortMessageTemplate shortMessageTemplate = new ShortMessageTemplate();
                    shortMessageTemplate = shortMessageTemplateBL.GetShortMessageTemplateByID(templateID).FirstOrDefault();
                    body = shortMessageTemplate.Message;

                    foreach (DictionaryEntry de in templateValues)
                    {
                        body = body.Replace(de.Key.ToString(), de.Value.ToString());
                    }
                    shortMessage.Body = body;
                    ShortMessageBL shortMessageBL = new ShortMessageBL();
                    shortMessageBL.InsertOrUpdateShortMessage(shortMessage);
                    SendSMS(toUser, shortMessage.Body);
                    break;
                case 3:
                    notification.NotificationTypeID = 3;
                    break;
                default:
                    break;
            }
        }