コード例 #1
0
        public static EmailTemplate GetTemplateforAnchor(this IService <EmailTemplate> service, IssueManagementCommentLog item, string AnchorName, CSC csc)
        {
            string status = "";

            if (item.id_System_Name == "MyPidilite" || item.id_System_Name == "WSS Service Cell" || item.id_System_Name == "Dealer Feedback")
            {
                if (item.ID_Status != "" || item.ID_Status != null)
                {
                    if (item.ID_Status.ToLower() == "in progress")
                    {
                        status = "Open";
                    }
                    if (item.ID_Status.ToLower() == "completed")
                    {
                        status = "Closed";
                    }
                }
                return(new EmailTemplate("CWP - Comments update - by - " + item.RCB.Title)
                {
                    TemplateBody = "Dear " + AnchorName + "/Team, <br/> <br/> " +
                                   "Below is the comment added by " + item.RCB.Title + " for SR Number " + item.ID_Request +
                                   " - Please make relevant updates on your system for relevant action. <br/><br/>" +
                                   "Chapter Name:<b>: " + item.id_System_Name + " </b> <br/><br/> " +
                                   "Date and Time Stamp: <b>" + DateTime.Now + "</b><br/><br/>" +
                                   "Comments: <b>" + item.ID_Comments + "</b><br/><br/>" +
                                   "Status: <b>" + status + "</b> <br/><br/><br/><br/>" +
                                   "This is an auto generated mail, do not reply.  <br/><br/>"
                });
            }
            else if (item.id_System_Name == "Customer Service Cell")
            {
                if (item.ID_Status != "" || item.ID_Status != null)
                {
                    if (item.ID_Status.ToLower() == "in progress")
                    {
                        status = "Open";
                    }
                    if (item.ID_Status.ToLower() == "completed")
                    {
                        status = "Closed";
                    }
                }
                return(new EmailTemplate("CWP - Comments update - by - " + item.RCB.Title)
                {
                    TemplateBody = "Dear " + AnchorName + "/Team, <br/> <br/> " +
                                   "Below is the comment added by " + item.RCB.Title + " for SR Number " + item.ID_Request +
                                   " - Please make relevant updates on your system for relevant action. <br/><br/>" +
                                   "Chapter Name:<b>: " + item.id_System_Name + " </b> <br/><br/> " +
                                   "Date and Time Stamp: <b>" + DateTime.Now + "</b><br/><br/>" +
                                   "Comments: <b>" + item.ID_Comments + "</b><br/><br/>" +
                                   "Status: <b>" + status + "</b> <br/><br/>" +
                                   "Customer Mobile Number: <b>" + csc.ContactNo + "</b> <br/><br/>" +
                                   "Customer Email: <b>" + csc.ContactEmail + "</b> <br/><br/><br/><br/>" +
                                   "This is an auto generated mail, do not reply.  <br/><br/>"
                });
            }
            //else if (item.id_System_Name == "Dealer Feedback")
            //{
            //    return new EmailTemplate("CWP - Comments update - by - " + item.RCB.Title)
            //    {

            //        TemplateBody = "Dear " + AnchorName + "/Team, <br/> <br/> " +
            //        "Below is the comment added by " + item.RCB.Title + " for SR Number " + item.ID_Request +
            //        " - Please make relevant updates on your system for relevant action. <br/><br/>" +
            //        "Chapter Name:<b>: " + item.id_System_Name + " </b> <br/><br/> " +
            //        "Date and Time Stamp: <b>" + DateTime.Now + "</b><br/><br/>" +
            //        "Comments: <b>" + item.ID_Comments + "</b> <br/><br/><br/><br/>" +
            //        "This is an auto generated mail, do not reply.  <br/><br/>"
            //    };
            //}
            else
            {
                return(new EmailTemplate(""));
                //return new EmailTemplate("CWP - Comments update - by - " + item.RCB.Title)
                //{

                //    TemplateBody = "Dear " + AnchorName + "/Team, <br/> <br/> " +
                //    "Below is the comment added by " + item.RCB.Title + " for SR Number " + item.ID_Request +
                //    " - Please make relevant updates on your system for relevant action. <br/><br/>" +
                //    "Chapter Name:<b>: " + item.id_System_Name + " </b> <br/><br/> " +
                //    "Date and Time Stamp: <b>" + DateTime.Now + "</b><br/><br/>" +
                //    "Comments: <b>" + item.ID_Comments + "</b> <br/><br/><br/><br/>" +
                //    "This is an auto generated mail, do not reply.  <br/><br/>"

                //};
            }
            var query = new ListQuery <EmailTemplate>();

            query.PageSize    = 1;
            query.CurrentPage = 1;
            // query.AddParameter(new QueryParameter() { Name = "taskid", Value = TaskId.ToString() });
            return(service.GetByQuery(query).Items.FirstOrDefault());
        }
コード例 #2
0
        public DbActionResult <IssueManagementCommentLog> Post(IssueManagementCommentLog items)
        {
            var    result     = new DbActionResult <IssueManagementCommentLog>();
            bool   EFlag      = false;
            string EmailTo    = "";
            string AncEmail   = "";
            string EmailCC    = "";
            string AnchorName = "";

            try
            {
                var data = items;

                string[] emailRegex = { "-", "<", ">", ";", "'" };
                for (var i = 0; i < emailRegex.Length; i++)
                {
                    if (data.ID_Comments != null)
                    {
                        data.ID_Comments = data.ID_Comments.Replace(emailRegex[i], " ");
                    }
                }

                var csc = new CSC();
                using (var dbcontext = new Teckraft.Data.Sql.InitiativeHubFinalEntities())
                {
                    //var chap = dbcontext.ChapterMasters.FirstOrDefault(it => it.ChapterNameFromSystem == data.id_System_Name && it.EmailFlag == true);
                    //if (chap != null)
                    //{
                    //    data.id_System_Name = chap.ChapterNameFromSystem;
                    //    EFlag = chap.EmailFlag.Value;
                    //    EmailTo = chap.EmailTo;
                    //}

                    var chap1 = dbcontext.ChapterMasters.FirstOrDefault(it => it.ChapterNameFromSystem == data.id_System_Name);
                    if (chap1 != null)
                    {
                        if (chap1.ChapterNameFromSystem == "Dealer Feedback" || chap1.ChapterNameFromSystem == "WSS Service Cell" || chap1.ChapterNameFromSystem == "MyPidilite" || chap1.ChapterNameFromSystem == "Customer Service Cell")
                        {
                            var em = dbcontext.ChapterMasters.FirstOrDefault(o => o.ChapterNameFromSystem == data.id_System_Name);
                            EmailCC  = em.EmailCC;
                            AncEmail = em.EmailTo;
                        }
                        else
                        {
                            string AncData = dbcontext.ChapterOwnerMappings.FirstOrDefault(it => it.ChapterId == chap1.Id).ChapterOwner.ToString();
                            AncEmail = dbcontext.UserDetails.FirstOrDefault(p => p.UserName == AncData).Email.ToString();
                        }
                        //for getting Anchor Name
                        var q = (from pd in dbcontext.ChapterOwnerMappings
                                 join od in dbcontext.UserDetails on pd.ChapterOwner equals od.UserName
                                 where pd.ChapterId == chap1.Id
                                 select new
                        {
                            od.Title,
                        }).FirstOrDefault();
                        if (q != null)
                        {
                            AnchorName = q.Title;
                        }
                    }


                    if (items.id_System_Name == "Customer Service Cell")
                    {
                        var cs = dbcontext.GetCSCDataBYRequestNo(items.ID_Request).FirstOrDefault();
                        csc.ContactEmail = cs.ContactEmail;
                        csc.ContactNo    = cs.contactNo;
                    }
                }

                data.RCB = _userservice.GetCurrentUser();
                data     = IssueService.Add(data);
                //if (EFlag == true) {
                //    if (data.EmailFlag == true && EmailTo != null) {
                //        var tmplt1 = templateService.GetTemplateforComments(data);
                //       // emailService.SendEmail(tmplt1, "*****@*****.**", EmailTo, "", "");
                //        emailService.SendEmail(tmplt1, "*****@*****.**", EmailTo, "*****@*****.**", "");
                //    }
                //}



                var tmplt1 = templateService.GetTemplateforAnchor(data, AnchorName, csc);
                //emailService.SendEmail(tmplt1, "[email protected] ", "*****@*****.**","", "");
                if (tmplt1.Subject != "")
                {
                    //emailService.SendEmail(tmplt1, "[email protected] ", "*****@*****.**", "", "");
                    emailService.SendEmail(tmplt1, "[email protected] ", AncEmail, EmailCC, "");
                }

                result.Success = true;
                result.Message = "Comments added successfully";
            }
            catch (Exception ex)
            {
                result.Success   = false;
                result.Message   = "Unable to Save Record!";
                result.Exception = ex;
            }

            return(result);
        }
コード例 #3
0
        public static EmailTemplate GetTemplateforComments(this IService <EmailTemplate> service, IssueManagementCommentLog item)
        {
            return(new EmailTemplate("Update From Issue Dashboard")
            {
                TemplateBody = "Dear Team, <br/> <br/>  This is kind informtion that, Request number " + item.ID_Request + ", for " + item.id_System_Name +
                               " comments updated by " + item.RCBEmpName + " on " + DateTime.Now + ". <br/><br/> " +
                               "Latest Comments - " + item.ID_Comments + " <br/> <br/> " +
                               "Status - " + item.ID_Status + " <br/> <br/>" +
                               "Update in your system accordingly. <br/><br/> " +
                               "This is an auto generated mail, do not reply.  <br/><br/>" +
                               "Regards"
            });

            var query = new ListQuery <EmailTemplate>();

            query.PageSize    = 1;
            query.CurrentPage = 1;
            // query.AddParameter(new QueryParameter() { Name = "taskid", Value = TaskId.ToString() });
            return(service.GetByQuery(query).Items.FirstOrDefault());
        }