public string RenderText()
        {
            switch (Eid)
            {
            case Eid.JOIN:
                return($"{Username} has joined the channel");

            case Eid.LEAVE:
                return($"{Username} has left the channel");

            case Eid.WHISPER:
                return($"From <{Username}>: {Text}");

            case Eid.TALK:
                return($"<{Username}>: {Text}");

            case Eid.CHANNEL:
                return($"Joined channel: {Text}");

            case Eid.INFO:
                return($"INFO: {Text}");

            case Eid.ERROR:
                return($"ERROR: {Text}");

            case Eid.EMOTE:
                return($"<{Username} {Text}>");

            default:
                return($"Unhandled EID: {Eid.ToString()} {Text}");
            }
        }
        public void Validate()
        {
            AddNotifications(new Contract()
                             .Requires()

                             .IsBetween(Title.Length0IfNullOrEmpty(), 2, 1024, "Title", Messages.V_IsBetween.ToFormat("Title", "2", "1024"))
                             .IsBetween(Eid.Length0IfNullOrEmpty(), 2, 128, "Eid", Messages.V_IsBetween.ToFormat("Eid", "2", "128"))

                             .IsNotNull(CourseId, "CourseId", Messages.V_IsNotNullOrEmpty.ToFormat("CourseId"))
                             );
        }
示例#3
0
        /// <inheritdoc />
        protected override void AddAttributesToRender(HtmlTextWriter writer)
        {
            if (Eid == 0)
            {
                throw new MissingRequiredAttribute("Eid", Eid);
            }

            writer.AddAttribute("eid", Eid.ToString(CultureInfo.InvariantCulture));

            base.AddAttributesToRender(writer);
        }
        public ActionResult Delete(int TrainingID)
        {
            DSRCManagementSystemEntities1 db    = new DSRCManagementSystemEntities1();
            ManageTrainingModel           model = new ManageTrainingModel();
            string ServerName = AppValue.GetFromMailAddress("ServerName");
            var    obj        = db.Trainings.Where(x => x.TrainingId == TrainingID).FirstOrDefault();

            obj.IsActive = false;
            obj.StatusId = 5;

            var val = db.TrainingNominations.Where(x => x.TrainingId == TrainingID).Select(o => o).ToList();

            foreach (var item in val)
            {
                item.IsActive = false;
                db.SaveChanges();
            }

            db.SaveChanges();

            var MailPurposeObj = db.TrainingMailPurposes.Where(x => x.TrainingId == TrainingID).FirstOrDefault();

            MailPurposeObj.IsActive = false;
            db.SaveChanges();

            string   Tid      = obj.TrainingId.ToString();
            string   tname    = obj.TrainingName;
            DateTime d1       = Convert.ToDateTime(obj.ScheduledDate);
            string   d        = d1.ToShortDateString();
            string   stime    = obj.StartTime;
            string   etime    = obj.EndTime;
            var      userref  = db.Users.FirstOrDefault(o => o.UserID == obj.InstructorId);
            string   username = userref.FirstName + userref.LastName;

            List <string> MailID = new List <string>();

            MailID.Add(userref.EmailAddress);

            var EmpIDList = db.TrainingNominations.Where(o => o.TrainingId == obj.TrainingId).Select(o => o.EmpId).ToList();

            foreach (string Eid in EmpIDList)
            {
                model.EmpID       = Eid.ToString();
                model.EmpID       = "0" + model.EmpID;
                model.MailAddress = db.Users.FirstOrDefault(o => o.EmpID == model.EmpID).EmailAddress;
                MailID.Add(model.MailAddress);
            }

            // string mailMessage = MailBuilder.TrainingScheduleCancelled(Tid, tname, d, stime, etime, username);

            var check  = db.EmailTemplates.Where(x => x.TemplatePurpose == "Training Schedule Cancelled").Select(o => o.EmailTemplateID).FirstOrDefault();
            var folder = db.EmailTemplates.Where(o => o.TemplatePurpose == "Training Schedule Cancelled").Select(x => x.TemplatePath).FirstOrDefault();

            if ((check != null) && (check != 0))
            {
                var objTrainingScheduleCancelled = (from p in db.EmailPurposes.Where(x => x.EmailPurposeName == "Training Schedule Cancelled")
                                                    join q in db.EmailTemplates on p.EmailTemplateID equals q.EmailTemplateID
                                                    select new DSRCManagementSystem.Models.Email
                {
                    To = p.To,
                    CC = p.CC,
                    BCC = p.BCC,
                    Subject = p.Subject,
                    Template = q.TemplatePath
                }).FirstOrDefault();
                var    objcom = db.Master_ApplicationSettings.Where(x => x.AppKey == "Company Name").Select(o => o.AppValue).FirstOrDefault();
                string TemplatePathTrainingScheduleCancelled = Server.MapPath(objTrainingScheduleCancelled.Template);
                string htmlTrainingScheduleCancelled         = System.IO.File.ReadAllText(TemplatePathTrainingScheduleCancelled);
                htmlTrainingScheduleCancelled = htmlTrainingScheduleCancelled.Replace("#TrainingId", Tid);
                htmlTrainingScheduleCancelled = htmlTrainingScheduleCancelled.Replace("#TrainingName", tname);
                htmlTrainingScheduleCancelled = htmlTrainingScheduleCancelled.Replace("#ScheduledDate", d);
                htmlTrainingScheduleCancelled = htmlTrainingScheduleCancelled.Replace("#start", stime);
                htmlTrainingScheduleCancelled = htmlTrainingScheduleCancelled.Replace("#end", etime);
                htmlTrainingScheduleCancelled = htmlTrainingScheduleCancelled.Replace("#Instructor", username);
                htmlTrainingScheduleCancelled = htmlTrainingScheduleCancelled.Replace("#ServerName", ServerName);
                htmlTrainingScheduleCancelled = htmlTrainingScheduleCancelled.Replace("#ComapanyName", objcom);
                //string ServerName = WebConfigurationManager.AppSettings["SeverName"];
                var logo = CommonLogic.getLogoPath();
                if (ServerName != "http://*****:*****@dsrc.co.in");
                    //MailIds.Add("*****@*****.**");
                    //MailIds.Add("*****@*****.**");
                    //MailIds.Add("*****@*****.**");
                    //MailIds.Add("*****@*****.**");
                    //MailIds.Add("*****@*****.**");
                    //MailIds.Add("*****@*****.**");

                    string EmailAddress = "";

                    foreach (string mail in MailIds)
                    {
                        EmailAddress += mail + ",";
                    }

                    EmailAddress = EmailAddress.Remove(EmailAddress.Length - 1);
                    //var logo = db.Master_ApplicationSettings.Where(x => x.AppID == 7).Select(x => x).FirstOrDefault();
                    // DsrcMailSystem.MailSender.SendMail(null, objTrainingScheduleCancelled.Subject + " - Test Mail Please Ignore", null, htmlTrainingScheduleCancelled + " - Testing Plaese ignore", "*****@*****.**", EmailAddress, Server.MapPath(logo.AppValue.ToString()));

                    DsrcMailSystem.MailSender.SendMail(null, objTrainingScheduleCancelled.Subject + " - Test Mail Please Ignore", null, htmlTrainingScheduleCancelled + " - Testing Plaese ignore", "*****@*****.**", EmailAddress, Server.MapPath(logo.ToString()));
                }
                else
                {
                    foreach (string mail in MailID)
                    {
                        //Task.Factory.StartNew(() =>
                        //{
                        //var logo = db.Master_ApplicationSettings.Where(x => x.AppID == 7).Select(x => x).FirstOrDefault();
                        // DsrcMailSystem.MailSender.SendMail(null, objTrainingScheduleCancelled.Subject, null, htmlTrainingScheduleCancelled, "*****@*****.**", mail, Server.MapPath(logo.AppValue.ToString()));
                        DsrcMailSystem.MailSender.SendMail(null, objTrainingScheduleCancelled.Subject, null, htmlTrainingScheduleCancelled, "*****@*****.**", mail, Server.MapPath(logo.ToString()));
                        //DsrcMailSystem.MailSender.LDSendMail(null, "L & D - Training Schedule Cancelled", null, mailMessage, "*****@*****.**", mail, Server.MapPath("~/Content/Template/images/logo.png"));

                        //  });
                    }
                }
            }
            else
            {
                //string ServerName = WebConfigurationManager.AppSettings["SeverName"];
                ExceptionHandlingController.TemplateMissing("Training Schedule Cancelled", folder, ServerName);
            }

            return(Json("Success", JsonRequestBehavior.AllowGet));
        }
        public ActionResult Edit(ManageTrainingModel model)
        {
            string ServerName = AppValue.GetFromMailAddress("ServerName");

            using (DSRCManagementSystemEntities1 db = new DSRCManagementSystemEntities1())
            {
                var obj_Comp = db.Trainings.FirstOrDefault(o => o.TrainingId == model.TrainingID);

                if (obj_Comp.ScheduledDate != model.ScheduledDate || obj_Comp.StartTime != model.Starttime || obj_Comp.EndTime != model.Endtime || obj_Comp.SeatingCapacity != model.SeatingCapacity)
                {
                    var Message = "";

                    LDCourse1Controller obj = new LDCourse1Controller();
                    int    ID      = Convert.ToInt32(model.TrainingID);
                    string dt      = model.ScheduledDate.ToString();
                    string time    = Convert.ToString(model.Starttime);
                    string endtime = Convert.ToString(model.Endtime);
                    var    message = obj.scheduletime(ID, dt, model.TrainingName, time, endtime);

                    Message = Convert.ToString(message.Data);

                    if (Message == "availabletime")
                    {
                        return(Json(Message, JsonRequestBehavior.AllowGet));
                    }

                    obj_Comp.SeatingCapacity = model.SeatingCapacity;
                    obj_Comp.ScheduledDate   = model.ScheduledDate;
                    obj_Comp.StartTime       = model.Starttime;
                    obj_Comp.EndTime         = model.Endtime;
                    obj_Comp.StatusId        = 7;

                    db.SaveChanges();

                    string   Tid      = obj_Comp.TrainingId.ToString();
                    string   tname    = obj_Comp.TrainingName;
                    DateTime d1       = Convert.ToDateTime(model.ScheduledDate);
                    string   d        = d1.ToShortDateString();
                    string   stime    = obj_Comp.StartTime;
                    string   etime    = obj_Comp.EndTime;
                    var      userref  = db.Users.FirstOrDefault(o => o.UserID == obj_Comp.InstructorId);
                    string   username = userref.FirstName + " " + (userref.LastName ?? "");

                    List <string> MailID = new List <string>();
                    MailID.Add(userref.EmailAddress);


                    var EmpIDList = db.TrainingNominations.Where(o => o.TrainingId == model.TrainingID).Select(o => o.EmpId).ToList();

                    //foreach (int Eid in EmpIDList)
                    foreach (string Eid in EmpIDList)
                    {
                        model.EmpID = Eid.ToString();

                        if (model.EmpID.Length == 4)
                        {
                            model.EmpID = "0" + model.EmpID;
                        }

                        model.MailAddress = db.Users.FirstOrDefault(o => o.EmpID == model.EmpID).EmailAddress ?? "";
                        MailID.Add(model.MailAddress);
                    }

                    //string mailMessage = MailBuilder.TrainingScheduleChangeNotification(Tid, tname, d, stime, etime, username);

                    var check  = db.EmailTemplates.Where(x => x.TemplatePurpose == "Training Schedule Change Notification").Select(o => o.EmailTemplateID).FirstOrDefault();
                    var folder = db.EmailTemplates.Where(o => o.TemplatePurpose == "Training Schedule Change Notification").Select(x => x.TemplatePath).FirstOrDefault();
                    if ((check != null) && (check != 0))
                    {
                        var objTrainingScheduleChangeNotification = (from p in db.EmailPurposes.Where(x => x.EmailPurposeName == "Training Schedule Change Notification")
                                                                     join q in db.EmailTemplates on p.EmailTemplateID equals q.EmailTemplateID
                                                                     select new DSRCManagementSystem.Models.Email
                        {
                            To = p.To,
                            CC = p.CC,
                            BCC = p.BCC,
                            Subject = p.Subject,
                            Template = q.TemplatePath
                        }).FirstOrDefault();
                        var    objcom = db.Master_ApplicationSettings.Where(x => x.AppKey == "Company Name").Select(o => o.AppValue).FirstOrDefault();
                        string TemplatePathTrainingScheduleChangeNotification = Server.MapPath(objTrainingScheduleChangeNotification.Template);
                        string htmlTrainingScheduleChangeNotification         = System.IO.File.ReadAllText(TemplatePathTrainingScheduleChangeNotification);
                        htmlTrainingScheduleChangeNotification = htmlTrainingScheduleChangeNotification.Replace("#TrainingId", Tid);
                        htmlTrainingScheduleChangeNotification = htmlTrainingScheduleChangeNotification.Replace("#TrainingName", tname);
                        htmlTrainingScheduleChangeNotification = htmlTrainingScheduleChangeNotification.Replace("#ScheduledDate", d);
                        htmlTrainingScheduleChangeNotification = htmlTrainingScheduleChangeNotification.Replace("#start", stime);
                        htmlTrainingScheduleChangeNotification = htmlTrainingScheduleChangeNotification.Replace("#end", etime);
                        htmlTrainingScheduleChangeNotification = htmlTrainingScheduleChangeNotification.Replace("#Instructor", username);
                        htmlTrainingScheduleChangeNotification = htmlTrainingScheduleChangeNotification.Replace("#CompanyName", objcom);
                        htmlTrainingScheduleChangeNotification = htmlTrainingScheduleChangeNotification.Replace("#ServerName", ServerName);

                        //string ServerName = WebConfigurationManager.AppSettings["SeverName"];

                        var logo = CommonLogic.getLogoPath();

                        if (ServerName != "http://*****:*****@dsrc.co.in");
                            //MailIds.Add("*****@*****.**");
                            //MailIds.Add("*****@*****.**");
                            //MailIds.Add("*****@*****.**");
                            //MailIds.Add("*****@*****.**");
                            //MailIds.Add("*****@*****.**");
                            //MailIds.Add("*****@*****.**");

                            string EmailAddress = "";

                            foreach (string mail in MailIds)
                            {
                                EmailAddress += mail + ",";
                            }

                            EmailAddress = EmailAddress.Remove(EmailAddress.Length - 1);
                            //var logo = db.Master_ApplicationSettings.Where(x => x.AppID == 7).Select(x => x).FirstOrDefault();
                            // DsrcMailSystem.MailSender.SendMail(null, objTrainingScheduleChangeNotification.Subject + " - Test Mail Please Ignore", null, htmlTrainingScheduleChangeNotification + " - Testing Plaese ignore", "*****@*****.**", EmailAddress, Server.MapPath(logo.AppValue.ToString()));
                            DsrcMailSystem.MailSender.SendMail(null, objTrainingScheduleChangeNotification.Subject + " - Test Mail Please Ignore", null, htmlTrainingScheduleChangeNotification + " - Testing Plaese ignore", "*****@*****.**", EmailAddress, Server.MapPath(logo.ToString()));
                        }
                        else
                        {
                            foreach (string mail in MailID)
                            {
                                //var logo = db.Master_ApplicationSettings.Where(x => x.AppID == 7).Select(x => x).FirstOrDefault();
                                //DsrcMailSystem.MailSender.SendMail(null, objTrainingScheduleChangeNotification.Subject, null, htmlTrainingScheduleChangeNotification, "*****@*****.**", mail, Server.MapPath(logo.AppValue.ToString()));
                                DsrcMailSystem.MailSender.SendMail(null, objTrainingScheduleChangeNotification.Subject, null, htmlTrainingScheduleChangeNotification, "*****@*****.**", mail, Server.MapPath(logo.ToString()));
                            }
                        }
                    }
                    else
                    {
                        //string ServerName = WebConfigurationManager.AppSettings["SeverName"];
                        ExceptionHandlingController.TemplateMissing("Training Schedule Change Notification", folder, ServerName);
                    }
                }
                return(Json("Success", JsonRequestBehavior.AllowGet));
            }
        }