Exemplo n.º 1
0
        public ActionResult EditNewRoll(QuickEnrollment roll)
        {
            DSRCManagementSystemEntities1 db = new DSRCManagementSystemEntities1();
            //var Department = db.Master_Department.ToList();
            string ServerName     = AppValue.GetFromMailAddress("ServerName");
            var    DepartmentList = (from us in db.Departments

                                     select new
            {
                DepartmentId = us.DepartmentId,
                DepartmentName = us.DepartmentName
            }).OrderBy(o => o.DepartmentName).ToList();
            var GroupList = db.DepartmentGroups.Where(dg => dg.IsActive == true).Select(g => new
            {
                groupid   = g.GroupID,
                groupname = g.GroupName
            }).OrderBy(o => o.groupname).ToList();



            var EditQuickEnroll = db.QuickEnrolls.Where(q => q.QuickEnroll1 == roll.QuickEnroll).Select(r => r).FirstOrDefault();

            EditQuickEnroll.FirstName   = roll.FirstName;
            EditQuickEnroll.LastName    = roll.LastName;
            EditQuickEnroll.Address     = roll.Address;
            EditQuickEnroll.Location    = roll.Location;
            EditQuickEnroll.PhoneNumber = roll.PhoneNumber;
            //EditQuickEnroll.DateOfJoin = Convert.ToDateTime(roll.DateOfJoin);
            EditQuickEnroll.DateOfJoin = roll.DateOfJoin;
            EditQuickEnroll.BranchID   = roll.BranchName;
            EditQuickEnroll.GenderID   = roll.GenderID;
            EditQuickEnroll.RoleID     = (byte)roll.RollID;

            if (roll.DateOfBirth != DateTime.MinValue)
            {
                EditQuickEnroll.DateOfBirth = Convert.ToDateTime(roll.DateOfBirth);
            }
            // EditQuickEnroll.DateOfJoin = roll.DateOfJoin;
            // EditQuickEnroll.Experience = roll.Experience;
            EditQuickEnroll.PersonalMailAddress = roll.PersonalEmailAddress;

            EditQuickEnroll.DepartmentID = roll.DepartmentName;
            if (roll.DepartmentGroup != 0)
            {
                EditQuickEnroll.DepartmentGroup = roll.DepartmentGroup;
            }

            else
            {
                EditQuickEnroll.DepartmentGroup = null;
            }
            EditQuickEnroll.Comments   = roll.Comments;
            EditQuickEnroll.Experience = roll.Experience;


            db.SaveChanges();

            ViewBag.GroupID        = roll.DepartmentGroup;
            ViewBag.DepartmentId   = roll.DepartmentList;
            ViewBag.YearsList      = new SelectList(YearsList(), "YearId", "Year", roll.Experience);
            ViewBag.MonthList      = new SelectList(MonthsList(), "MonthId", "Month", roll.ExperienceMonth);
            ViewBag.GroupList      = new SelectList(GroupList, "ID", "GroupName", roll.DepartmentList);
            ViewBag.DepartmentList = new SelectList(DepartmentList, "ID", "DepartmentList", roll.DepartmentGroup);



            if (roll.QuickEnroll != null)
            {
                var check  = db.EmailTemplates.Where(x => x.TemplatePurpose == "EditEnroll").Select(o => o.EmailTemplateID).FirstOrDefault();
                var folder = db.EmailTemplates.Where(o => o.TemplatePurpose == "EditEnroll").Select(x => x.TemplatePath).FirstOrDefault();
                if ((check != null) && (check != 0))
                {
                    var objnewuser = (from p in db.EmailPurposes.Where(x => x.EmailPurposeName == "EditEnroll")
                                      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 date = Convert.ToString(roll.DateOfJoin);
                    string Date1 = null;
                    if (roll.DateOfJoin != null)
                    {
                        string   Date  = Convert.ToString(roll.DateOfJoin);
                        DateTime jdate = (Convert.ToDateTime(Date));
                        Date1 = jdate.ToString("dd-MM-yyyy");
                    }

                    string editdate            = DateTime.Now.ToString("dd-MM-yyyy");
                    var    company             = db.Master_ApplicationSettings.Where(x => x.AppKey == "Company Name").Select(o => o.AppValue).FirstOrDefault();
                    string TemplatePathnewuser = Server.MapPath(objnewuser.Template);
                    string EditEnrollhtml      = System.IO.File.ReadAllText(TemplatePathnewuser);

                    EditEnrollhtml = EditEnrollhtml.Replace("#Name", roll.FirstName + "  " + roll.LastName);
                    EditEnrollhtml = EditEnrollhtml.Replace("#JoiningDate", Date1);
                    EditEnrollhtml = EditEnrollhtml.Replace("#Experience", roll.Experience);
                    EditEnrollhtml = EditEnrollhtml.Replace("#Date", editdate);

                    EditEnrollhtml = EditEnrollhtml.Replace("#ServerName", ServerName);
                    EditEnrollhtml = EditEnrollhtml.Replace("#CompanyName", company);
                    if (objnewuser.To != "")
                    {
                        objnewuser.To = QuickEnrollController.GetUserEmailAddress(db, objnewuser.To);
                    }
                    if (objnewuser.CC != "")
                    {
                        objnewuser.BCC = QuickEnrollController.GetUserEmailAddress(db, objnewuser.CC);
                    }
                    if (objnewuser.BCC != "")
                    {
                        // objnewuser.BCC = QuickEnrollController.GetUserEmailAddress(db, objnewuser.BCC);
                    }

                    //var logo = db.Master_ApplicationSettings.Where(x => x.AppID == 7).Select(x => x).FirstOrDefault();
                    var logo = CommonLogic.getLogoPath();
                    // string ServerName = WebConfigurationManager.AppSettings["SeverName"];

                    int    userId      = int.Parse(Session["UserID"].ToString());
                    var    userdetails = db.Users.FirstOrDefault(o => o.UserID == userId);
                    string MailID      = userdetails.EmailAddress;

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

                        string EmailAddress = "";

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

                        EmailAddress = EmailAddress.Remove(EmailAddress.Length - 1);


                        Task.Factory.StartNew(() =>
                        {
                            // DsrcMailSystem.MailSender.SendMail(null, objnewuser.Subject + " - Test Mail Please Ignore", "", EditEnrollhtml + " - Testing Plaese ignore", "*****@*****.**", EmailAddress, Server.MapPath(logo.AppValue.ToString()));
                            DsrcMailSystem.MailSender.SendMail(null, objnewuser.Subject + " - Test Mail Please Ignore", "", EditEnrollhtml + " - Testing Plaese ignore", "*****@*****.**", EmailAddress, Server.MapPath(logo.ToString()));
                        });
                    }
                    else
                    {
                        Task.Factory.StartNew(() =>
                        {
                            // DsrcMailSystem.MailSender.SendMail(null, objnewuser.Subject, "", EditEnrollhtml, "*****@*****.**", MailID, Server.MapPath(logo.AppValue.ToString()));
                            DsrcMailSystem.MailSender.SendMail(null, objnewuser.Subject, "", EditEnrollhtml, "*****@*****.**", MailID, Server.MapPath(logo.ToString()));
                        });
                    }
                }

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

            return(Json("Success", JsonRequestBehavior.AllowGet));
        }
Exemplo n.º 2
0
        public ActionResult Delete(int Quickenrollid)
        {
            DSRCManagementSystemEntities1 db = new DSRCManagementSystemEntities1();
            string ServerName        = AppValue.GetFromMailAddress("ServerName");
            var    DeleteQuickEnroll = db.QuickEnrolls.Where(o => o.QuickEnroll1 == Quickenrollid).Select(o => o).FirstOrDefault();

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



            if (Quickenrollid != null)
            {
                var check  = db.EmailTemplates.Where(x => x.TemplatePurpose == "DeleteEnroll").Select(o => o.EmailTemplateID).FirstOrDefault();
                var folder = db.EmailTemplates.Where(o => o.TemplatePurpose == "DeleteEnroll").Select(x => x.TemplatePath).FirstOrDefault();
                if ((check != null) && (check != 0))
                {
                    var objnewuser = (from p in db.EmailPurposes.Where(x => x.EmailPurposeName == "DeleteEnroll")
                                      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 date = Convert.ToString(roll.DateOfJoin);

                    var Date1 = (from p in db.QuickEnrolls.Where(p => p.QuickEnroll1 == Quickenrollid)
                                 select(p.DateOfJoin)).FirstOrDefault();

                    var Name = (from p in db.QuickEnrolls.Where(p => p.QuickEnroll1 == Quickenrollid)
                                select(p.FirstName)).FirstOrDefault();

                    var Name1 = (from p in db.QuickEnrolls.Where(p => p.QuickEnroll1 == Quickenrollid)
                                 select(p.LastName)).FirstOrDefault();

                    var Exp = (from p in db.QuickEnrolls.Where(p => p.QuickEnroll1 == Quickenrollid)
                               select(p.Experience)).FirstOrDefault();

                    string   Exp1                = Convert.ToString(Exp);
                    DateTime endate              = (Convert.ToDateTime(Date1));
                    string   Date                = endate.ToString("dd-MM-yyyy");
                    string   Deldate             = DateTime.Now.ToString("dd-MM-yyyy");
                    var      company             = db.Master_ApplicationSettings.Where(x => x.AppKey == "Company Name").Select(o => o.AppValue).FirstOrDefault();
                    string   TemplatePathnewuser = Server.MapPath(objnewuser.Template);
                    string   DeleteEnrollhtml    = System.IO.File.ReadAllText(TemplatePathnewuser);

                    DeleteEnrollhtml = DeleteEnrollhtml.Replace("#Name", Name + "  " + Name1);
                    DeleteEnrollhtml = DeleteEnrollhtml.Replace("#JoiningDate", Date);
                    DeleteEnrollhtml = DeleteEnrollhtml.Replace("#Experience", Exp1);
                    DeleteEnrollhtml = DeleteEnrollhtml.Replace("#Date", Deldate);

                    DeleteEnrollhtml = DeleteEnrollhtml.Replace("#ServerName", ServerName);
                    DeleteEnrollhtml = DeleteEnrollhtml.Replace("#CompanyName", company);
                    if (objnewuser.To != "")
                    {
                        objnewuser.To = QuickEnrollController.GetUserEmailAddress(db, objnewuser.To);
                    }
                    if (objnewuser.CC != "")
                    {
                        objnewuser.BCC = QuickEnrollController.GetUserEmailAddress(db, objnewuser.CC);
                    }
                    if (objnewuser.BCC != "")
                    {
                        // objnewuser.BCC = QuickEnrollController.GetUserEmailAddress(db, objnewuser.BCC);
                    }

                    //var logo = db.Master_ApplicationSettings.Where(x => x.AppID == 7).Select(x => x).FirstOrDefault();
                    var logo = CommonLogic.getLogoPath();
                    //string ServerName = WebConfigurationManager.AppSettings["SeverName"];

                    int    userId      = int.Parse(Session["UserID"].ToString());
                    var    userdetails = db.Users.FirstOrDefault(o => o.UserID == userId);
                    string MailID      = userdetails.EmailAddress;

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

                        string EmailAddress = "";

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

                        EmailAddress = EmailAddress.Remove(EmailAddress.Length - 1);


                        Task.Factory.StartNew(() =>
                        {
                            // DsrcMailSystem.MailSender.SendMail(null, objnewuser.Subject + " - Test Mail Please Ignore", "", DeleteEnrollhtml + " - Testing Plaese ignore", "*****@*****.**", EmailAddress, Server.MapPath(logo.AppValue.ToString()));
                            DsrcMailSystem.MailSender.SendMail(null, objnewuser.Subject + " - Test Mail Please Ignore", "", DeleteEnrollhtml + " - Testing Plaese ignore", "*****@*****.**", EmailAddress, Server.MapPath(logo.ToString()));
                        });
                    }
                    else
                    {
                        Task.Factory.StartNew(() =>
                        {
                            // DsrcMailSystem.MailSender.SendMail(null, objnewuser.Subject, "", DeleteEnrollhtml, "*****@*****.**", MailID, Server.MapPath(logo.AppValue.ToString()));
                            DsrcMailSystem.MailSender.SendMail(null, objnewuser.Subject, "", DeleteEnrollhtml, "*****@*****.**", MailID, Server.MapPath(logo.ToString()));
                        });
                    }
                }

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


            return(Json("Success", JsonRequestBehavior.AllowGet));
        }
Exemplo n.º 3
0
        public ActionResult Nominate(string TrainingId, string UserId)
        {
            try
            {
                int User = Convert.ToInt32(Encrypter.Decode(UserId));
                // int User = 0;
                string ServerName = AppValue.GetFromMailAddress("ServerName");
                int    TId        = Convert.ToInt32(Encrypter.Decode(TrainingId));
                DSRCManagementSystemEntities1 obj = new DSRCManagementSystemEntities1();
                var instructor   = obj.Trainings.Where(x => x.TrainingId == TId && x.InstructorId == User).Select(o => o.InstructorId).FirstOrDefault();
                var Training     = obj.Trainings.Where(x => x.TrainingId == TId).Select(o => o).FirstOrDefault();
                var NomitionOne  = obj.TrainingNominations.Where(x => x.UserId == User && x.TrainingId == TId).Select(x => x).ToList();
                int NomineeCount = NomitionOne.Count();
                if (TId == 0)
                {
                    ViewBag.Null = "Null";
                }
                else if (instructor != null)
                {
                    ViewBag.Instructor = "Instructor";
                }
                else if (Training.NumberOfNominated == Training.SeatingCapacity + 2)
                {
                    ViewBag.NoSeat = "NoSeat";
                }
                else if (NomineeCount != 0)
                {
                    ViewBag.Already = "Already";
                }
                else
                {
                    //int userId = int.Parse(Session["UserID"].ToString());
                    var email = System.Web.HttpContext.Current.Application["UserName"].ToString();

                    DSRCManagementSystemEntities1 db = new DSRCManagementSystemEntities1();
                    var empid = db.Users.Where(x => x.UserID == User).Select(o => o.EmpID).FirstOrDefault();
                    //int? emp = Convert.ToInt32(empid);
                    DSRCManagementSystemEntities1 obf = new DSRCManagementSystemEntities1();
                    //var EMP = obf.Users.Where(x => x.UserID == userId).Select(o => o.EmpID).FirstOrDefault();


                    int k = TId;
                    DSRCManagementSystemEntities1 objdb = new DSRCManagementSystemEntities1();
                    //var id = db.Users.Where(x => x.UserID == userId).Select(o => o.EmpID).FirstOrDefault();
                    //int? value = Convert.ToInt32(id);
                    var empname = objdb.Users.Where(x => x.UserID == User).Select(o => o.FirstName + " " + o.LastName ?? "").FirstOrDefault();
                    //  context.Authors.Where(a => a.Books.Any(b => b.BookID == bookID)).ToList();
                    var val          = objdb.TrainingNominations.Where(x => x.UserId == User && x.TrainingId == k).Select(o => o.TrainingId).FirstOrDefault();
                    int?instructorid = db.Trainings.Where(x => x.InstructorId == User).Select(o => o.InstructorId).FirstOrDefault();
                    var technology   = objdb.Trainings.Where(x => x.TrainingId == k).Select(o => o.TechnologyId).FirstOrDefault();
                    var LevelId      = db.Trainings.Where(x => x.TrainingId == TId).Select(x => x.LevelId).FirstOrDefault();
                    int?InsID        = db.Trainings.Where(x => x.TrainingId == TId).Select(o => o.InstructorId).FirstOrDefault();


                    //var trainwidgets = db.TrainingWeightages.CreateObject();
                    //trainwidgets.Trainee = user;
                    //trainwidgets.Instructor = InsID;
                    //trainwidgets.LevelId = LevelId;
                    //db.TrainingWeightages.AddObject(trainwidgets);
                    //db.SaveChanges();

                    DSRCManagementSystem.TrainingNomination nom = new DSRCManagementSystem.TrainingNomination();
                    nom.TrainingId = TId;
                    //nom.EmpId = Convert.ToInt32(empid);
                    nom.EmpId          = empid;
                    nom.UserId         = User;
                    nom.EmpName        = empname;
                    nom.TechnologyId   = technology;
                    nom.EmailId        = email;
                    nom.NominationFlag = true;
                    nom.CompletionFlag = false;
                    nom.IsActive       = true;
                    objdb.AddToTrainingNominations(nom);
                    objdb.SaveChanges();


                    var Techref = db.Trainings.FirstOrDefault(o => o.TrainingId == k);

                    string   Tid   = k.ToString();
                    string   tname = Techref.TrainingName;
                    DateTime d1    = Convert.ToDateTime(Techref.ScheduledDate);
                    string   d     = d1.ToShortDateString();
                    string   stime = Techref.StartTime;
                    string   etime = Techref.EndTime;

                    string username = db.Users.Where(o => o.UserID == Techref.InstructorId).Select(o => o.FirstName + " " + (o.LastName ?? "")).FirstOrDefault();

                    var    userdetails = db.Users.FirstOrDefault(o => o.UserID == User);
                    string MailID      = userdetails.EmailAddress;


                    string EmpName = userdetails.FirstName + " " + userdetails.LastName ?? "";


                    //string mailMessage = MailBuilder.NominationConfirmation(EmpName, Tid, tname, d, stime, etime, username);
                    var check  = objdb.EmailTemplates.Where(x => x.TemplatePurpose == "Nomination Confirmation").Select(o => o.EmailTemplateID).FirstOrDefault();
                    var folder = objdb.EmailTemplates.Where(o => o.TemplatePurpose == "Nomination Confirmation").Select(x => x.TemplatePath).FirstOrDefault();
                    if ((check != null) && (check != 0))
                    {
                        var objNominationConfirmation = (from p in db.EmailPurposes.Where(x => x.EmailPurposeName == "Nomination Confirmation")
                                                         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    company = db.Master_ApplicationSettings.Where(x => x.AppKey == "Company Name").Select(o => o.AppValue).FirstOrDefault();
                        string TemplatePathNominationConfirmation = Server.MapPath(objNominationConfirmation.Template);
                        string htmlNominationConfirmation         = System.IO.File.ReadAllText(TemplatePathNominationConfirmation);
                        htmlNominationConfirmation = htmlNominationConfirmation.Replace("#Empname", EmpName);
                        htmlNominationConfirmation = htmlNominationConfirmation.Replace("#TrainingId", Tid);
                        htmlNominationConfirmation = htmlNominationConfirmation.Replace("#TrainingName", tname);
                        htmlNominationConfirmation = htmlNominationConfirmation.Replace("#ScheduledDate", d);
                        htmlNominationConfirmation = htmlNominationConfirmation.Replace("#start", stime);
                        htmlNominationConfirmation = htmlNominationConfirmation.Replace("#end", etime);
                        htmlNominationConfirmation = htmlNominationConfirmation.Replace("#Instructor", username);
                        htmlNominationConfirmation = htmlNominationConfirmation.Replace("#ServerName", ServerName);
                        htmlNominationConfirmation = htmlNominationConfirmation.Replace("#CompanyName", company);
                        //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);

                            Task.Factory.StartNew(() =>
                            {
                                //var logo = db.Master_ApplicationSettings.Where(x => x.AppID == 7).Select(x => x).FirstOrDefault();
                                //  DsrcMailSystem.MailSender.SendMail(null, objNominationConfirmation.Subject + " - Test Mail Please Ignore", null, htmlNominationConfirmation + " - Testing Plaese ignore", "*****@*****.**", EmailAddress, Server.MapPath(logo.AppValue.ToString()));
                                DsrcMailSystem.MailSender.SendMail(null, objNominationConfirmation.Subject + " - Test Mail Please Ignore", null, htmlNominationConfirmation + " - Testing Plaese ignore", "*****@*****.**", EmailAddress, Server.MapPath(logo.ToString()));
                            });
                        }
                        else
                        {
                            Task.Factory.StartNew(() =>
                            {
                                // var logo = db.Master_ApplicationSettings.Where(x => x.AppID == 7).Select(x => x).FirstOrDefault();
                                //  DsrcMailSystem.MailSender.SendMail(null, objNominationConfirmation.Subject, null, htmlNominationConfirmation, "*****@*****.**", MailID, Server.MapPath(logo.AppValue.ToString()));
                                DsrcMailSystem.MailSender.SendMail(null, objNominationConfirmation.Subject, null, htmlNominationConfirmation, "*****@*****.**", MailID, Server.MapPath(logo.ToString()));
                                //DsrcMailSystem.MailSender.LDSendMail(null, "L & D - Training Nomination Confirmation", null, mailMessage, "*****@*****.**", MailID, Server.MapPath("~/Content/Template/images/logo.png"));
                            });
                        }
                    }
                    else
                    {
                        //string ServerName = WebConfigurationManager.AppSettings["SeverName"];
                        ExceptionHandlingController.TemplateMissing("Nomination Confirmation", folder, ServerName);
                    }

                    //int k = Trainingid;

                    var value1 = obf.Trainings.Where(x => x.TrainingId == TId).Select(o => o).FirstOrDefault();
                    value1.Flag = false;
                    obf.SaveChanges();

                    var No_Of_Nominees_Ref = db.Trainings.FirstOrDefault(o => o.TrainingId == TId);

                    int?No_Of_Nominations = No_Of_Nominees_Ref.NumberOfNominated;
                    No_Of_Nominees_Ref.NumberOfNominated = No_Of_Nominations + 1;

                    db.SaveChanges();
                }
            }
            catch (Exception Ex)
            {
                string actionName     = this.ControllerContext.RouteData.Values["action"].ToString();
                string controllerName = this.ControllerContext.RouteData.Values["controller"].ToString();
                ExceptionHandlingController.ExceptionDetails(Ex, actionName, controllerName);
            }
            return(View());
        }
Exemplo n.º 4
0
        public ActionResult AddNewRoll(QuickEnrollment role)
        {
            DSRCManagementSystemEntities1 db = new DSRCManagementSystemEntities1();
            string ServerName = AppValue.GetFromMailAddress("ServerName");
            string exp        = "--";
            string Date       = null;
            string Date1      = null;
            //DateTime todate = (Convert.ToDateTime(role.DateOfJoin));  // added
            var AddRoles = db.QuickEnrolls.CreateObject();

            AddRoles.FirstName   = role.FirstName;
            AddRoles.LastName    = role.LastName;
            AddRoles.Address     = role.Address;
            AddRoles.Location    = role.Location;
            AddRoles.PhoneNumber = role.PhoneNumber;
            //if (role.DateOfBirth != DateTime.MinValue)
            //{
            //    AddRoles.DateOfBirth = Convert.ToDateTime(role.DateOfBirth);
            //}
            AddRoles.BranchID = role.BranchID;
            if (role.DateOfJoin != null)
            {
                AddRoles.DateOfJoin = Convert.ToDateTime(role.DateOfJoin);
                DateTime todate = (Convert.ToDateTime(role.DateOfJoin));
                Date = todate.ToString("dd-MM-yyyy");
            }
            if (role.DateOfEnquiry != null)
            {
                AddRoles.DateOfEnquiry = Convert.ToDateTime(role.DateOfEnquiry);
                DateTime endate = (Convert.ToDateTime(role.DateOfEnquiry));
                Date1 = endate.ToString("dd-MM-yyyy");
            }
            //added on 9/9
            if (role.Experience != "undefined.undefined")
            {
                exp = role.Experience;
            }
            else
            {
                exp = "0";
            }
            //ends
            AddRoles.Experience          = role.Experience;
            AddRoles.PersonalMailAddress = role.PersonalEmailAddress;
            AddRoles.DepartmentID        = role.DepartmentName;
            AddRoles.RoleID        = (byte)role.RollID;
            AddRoles.GenderID      = role.GenderID;
            AddRoles.DateOfEnquiry = role.DateOfEnquiry;
            if (role.DepartmentGroup != 0)
            {
                AddRoles.DepartmentGroup = role.DepartmentGroup;
            }
            AddRoles.Comments   = role.Comments;
            AddRoles.Experience = role.Experience;
            AddRoles.IsActive   = true;
            db.QuickEnrolls.AddObject(AddRoles);
            db.SaveChanges();

            if (role.QuickEnroll != null)
            {
                var checks = db.EmailTemplates.Where(x => x.TemplatePurpose == "AddEnroll").Select(o => o.EmailTemplateID).FirstOrDefault();
                var folder = db.EmailTemplates.Where(o => o.TemplatePurpose == "AddEnroll").Select(x => x.TemplatePath).FirstOrDefault();
                if ((checks != null) && (checks != 0))
                {
                    var objnewuser = (from p in db.EmailPurposes.Where(x => x.EmailPurposeName == "AddEnroll")
                                      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    company             = db.Master_ApplicationSettings.Where(x => x.AppKey == "Company Name").Select(o => o.AppValue).FirstOrDefault();
                    string TemplatePathnewuser = Server.MapPath(objnewuser.Template);
                    string AddEnrollhtml       = System.IO.File.ReadAllText(TemplatePathnewuser);

                    AddEnrollhtml = AddEnrollhtml.Replace("#Name", role.FirstName + "  " + role.LastName);
                    AddEnrollhtml = AddEnrollhtml.Replace("#JoiningDate", Date);
                    AddEnrollhtml = AddEnrollhtml.Replace("#Experience", exp); //role.Experience);
                    AddEnrollhtml = AddEnrollhtml.Replace("#Date", Date);

                    AddEnrollhtml = AddEnrollhtml.Replace("#ServerName", ServerName);
                    AddEnrollhtml = AddEnrollhtml.Replace("#CompanyName", company);
                    if (objnewuser.To != "")
                    {
                        objnewuser.To = QuickEnrollController.GetUserEmailAddress(db, objnewuser.To);
                    }
                    if (objnewuser.CC != "")
                    {
                        objnewuser.BCC = QuickEnrollController.GetUserEmailAddress(db, objnewuser.CC);
                    }
                    if (objnewuser.BCC != "")
                    {
                        // objnewuser.BCC = QuickEnrollController.GetUserEmailAddress(db, objnewuser.BCC);
                    }

                    // var logo = db.Master_ApplicationSettings.Where(x => x.AppID == 7).Select(x => x).FirstOrDefault();
                    var logo = CommonLogic.getLogoPath();
                    //string ServerName = WebConfigurationManager.AppSettings["SeverName"];

                    int    userId      = int.Parse(Session["UserID"].ToString());
                    var    userdetails = db.Users.FirstOrDefault(o => o.UserID == userId);
                    string MailID      = userdetails.EmailAddress;

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

                        string EmailAddress = "";

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

                        EmailAddress = EmailAddress.Remove(EmailAddress.Length - 1);


                        Task.Factory.StartNew(() =>
                        {
                            // DsrcMailSystem.MailSender.SendMail(null, objnewuser.Subject + " - Test Mail Please Ignore", "", AddEnrollhtml + " - Testing Plaese ignore", "*****@*****.**", EmailAddress, Server.MapPath(logo.AppValue.ToString()));
                            DsrcMailSystem.MailSender.SendMail(null, objnewuser.Subject + " - Test Mail Please Ignore", "", AddEnrollhtml + " - Testing Plaese ignore", "*****@*****.**", EmailAddress, Server.MapPath(logo.ToString()));
                        });
                    }
                    else
                    {
                        Task.Factory.StartNew(() =>
                        {
                            // DsrcMailSystem.MailSender.SendMail(null, objnewuser.Subject, "", AddEnrollhtml, "*****@*****.**", MailID, Server.MapPath(logo.AppValue.ToString()));
                            DsrcMailSystem.MailSender.SendMail(null, objnewuser.Subject, "", AddEnrollhtml, "*****@*****.**", MailID, Server.MapPath(logo.ToString()));
                        });
                    }
                }
                else
                {
                    // string ServerName = WebConfigurationManager.AppSettings["SeverName"];
                    ExceptionHandlingController.TemplateMissing("AddEnroll", folder, ServerName);
                }
            }
            return(Json("Success", JsonRequestBehavior.AllowGet));
        }
Exemplo n.º 5
0
        public ActionResult Add(DSRCManagementSystem.Models.Expenditure objmodel)
        {
            DSRCManagementSystemEntities1 objdb = new DSRCManagementSystemEntities1();
            string ServerName = AppValue.GetFromMailAddress("ServerName");

            DSRCManagementSystem.Expenditure obj = new DSRCManagementSystem.Expenditure();
            try
            {
                obj.ExpenseDescription = objmodel.ExpenseDescription.Trim();
                obj.ExpenseDate        = objmodel.ExpenseDate;
                obj.ExpenseAmount      = objmodel.ExpenseAmount;
                obj.CreatedAt          = Convert.ToDateTime(objmodel.ScheduleDate);
                obj.IsActive           = true;
                objdb.AddToExpenditures(obj);
                objdb.SaveChanges();


                var      ExpenseDes  = objmodel.ExpenseDescription.Trim();
                DateTime?Expensedate = objmodel.ExpenseDate;
                var      Expense     = objmodel.ExpenseAmount;
                int      userId      = int.Parse(Session["UserID"].ToString());
                var      createdby   = objdb.Users.Where(x => x.UserID == userId).Select(o => o.FirstName + " " + o.LastName).FirstOrDefault();
                var      FromEmailID = objdb.Users.Where(x => x.UserID == userId).Select(o => o.UserName).FirstOrDefault();
                var      Getmailid   = objdb.Users.Where(x => x.UserID == 1).Select(o => o.EmailAddress).FirstOrDefault();
                var      GetName     = objdb.Users.Where(x => x.UserID == 1).Select(o => o.FirstName + " " + o.LastName).FirstOrDefault();

                var objcom = objdb.Master_ApplicationSettings.Where(x => x.AppKey == "Company Name")
                             .Select(o => o.AppValue)
                             .FirstOrDefault();
                var check  = objdb.EmailTemplates.Where(x => x.TemplatePurpose == "Add Expense").Select(o => o.EmailTemplateID).FirstOrDefault();
                var folder = objdb.EmailTemplates.Where(x => x.TemplatePurpose == "Add Expense").Select(o => o.TemplatePath).FirstOrDefault();
                if ((check != null) && (check != 0))
                {
                    var obj1 = (from p in objdb.EmailPurposes.Where(x => x.EmailPurposeName == "Add Expense")
                                join q in objdb.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();

                    string TemplatePath = Server.MapPath(obj1.Template);
                    string html         = System.IO.File.ReadAllText(TemplatePath);

                    string Subject = "Expense Added on " + DateTime.Today.ToString("dd MMM yyyy");
                    obj1.Subject = " " + objcom + " Management Portal-New Expense Added";


                    html = html.Replace("#ExpenseDescription", ExpenseDes);
                    html = html.Replace("#Date", DateTime.Today.ToString("dd MMM yyyy"));
                    html = html.Replace("#ExpenseDate", Expensedate.ToString().Substring(0, 10));
                    html = html.Replace("#ExpenseAmount", Expense.ToString());
                    html = html.Replace("#CompanyName", objcom.ToString());
                    html = html.Replace("#ServerName", ServerName);
                    List <string> MailIds      = objdb.TestMailIDs.Select(o => o.MailAddress).ToList();
                    string        EmailAddress = "";

                    foreach (string mail in MailIds)
                    {
                        EmailAddress += mail + ",";
                    }
                    EmailAddress = EmailAddress.Remove(EmailAddress.Length - 1);
                    if (ServerName != "http://*****:*****@dsrc.co.in", EmailAddress, Server.MapPath(pathvalue.ToString()));
                        });
                    }
                    else
                    {
                        Task.Factory.StartNew(() =>
                        {
                            string pathvalue = CommonLogic.getLogoPath();
                            DsrcMailSystem.MailSender.TaskMail(null, Subject, html, "*****@*****.**", EmailAddress, Server.MapPath(pathvalue.ToString()));
                        });
                    }
                }
                else
                {
                    ExceptionHandlingController.TemplateMissing("Add Expense", folder, ServerName);
                }
            }

            catch (Exception Ex)
            {
                string actionName     = this.ControllerContext.RouteData.Values["action"].ToString();
                string controllerName = this.ControllerContext.RouteData.Values["controller"].ToString();
                ExceptionHandlingController.ExceptionDetails(Ex, actionName, controllerName);
            }

            return(Json(new { Result = "Success", URL = @Url.Action("AlertPopUp", "Popup") }, JsonRequestBehavior.AllowGet));
        }
Exemplo n.º 6
0
        public ActionResult UserFeedbacks(UserFeedback userFeedback)
        {
            try
            {
                if (ModelState.IsValid)
                {
                    DSRCManagementSystemEntities1 odb = new DSRCManagementSystemEntities1();
                    //  var logo = odb.Master_ApplicationSettings.Where(x => x.AppID == 7).Select(x => x).FirstOrDefault();
                    string ServerName = AppValue.GetFromMailAddress("ServerName");
                    int    userID     = Convert.ToInt32(Session["UserID"]);
                    string email      = Convert.ToString(Session["UserName"]);

                    string pathvalue = CommonLogic.getLogoPath();



                    //var logo = odb.Master_ApplicationSettings.Where(x => x.AppID == 7).Select(x => x).FirstOrDefault();
                    //string[] words;

                    //words = logo.AppValue.Split(new string[] { "../../" }, StringSplitOptions.None);

                    //string pathvalue = "~/" + words[1];



                    var obj = new UsersFeedback()
                    {
                        UserID       = userID,
                        Feedback     = userFeedback.Feedback,
                        FeedbackDate = DateTime.Now
                    };
                    db.UsersFeedbacks.AddObject(obj);
                    db.SaveChanges();


                    string MailMessage = MailBuilder.FeedBack(Session["FirstName"].ToString(), Session["LastName"].ToString(), userFeedback.Feedback.Replace(Environment.NewLine, "</br>"));

                    var check  = db.EmailTemplates.Where(x => x.TemplatePurpose == "Feedback").Select(o => o.EmailTemplateID).FirstOrDefault();
                    var folder = db.EmailTemplates.Where(o => o.TemplatePurpose == "Feedback").Select(x => x.TemplatePath).FirstOrDefault();
                    if ((check != null) && (check != 0))
                    {
                        var objFeedback = (from p in db.EmailPurposes.Where(x => x.EmailPurposeName == "Feedback")
                                           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();

                        string TemplatePathFeedback = Server.MapPath(objFeedback.Template);
                        var    company      = db.Master_ApplicationSettings.Where(x => x.AppKey == "Company Name").Select(o => o.AppValue).FirstOrDefault();
                        string htmlFeedback = System.IO.File.ReadAllText(TemplatePathFeedback);
                        htmlFeedback = htmlFeedback.Replace("#SenderName", Session["FirstName"].ToString() + " " + Session["LastName"].ToString());
                        htmlFeedback = htmlFeedback.Replace("#Comments", userFeedback.Feedback.Replace(Environment.NewLine, "</br>"));
                        htmlFeedback = htmlFeedback.Replace("#ServerName", ServerName);
                        htmlFeedback = htmlFeedback.Replace("#CompanyName", company);

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

                        if (ServerName != "http://*****:*****@dsrc.co.in");
                            //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);

                            string CCMailId  = "*****@*****.**";
                            string BCCMailId = "*****@*****.**";

                            Task.Factory.StartNew(() =>
                            {
                                DsrcMailSystem.MailSender.SendMailToALL(null, objFeedback.Subject + " - Test Mail Please Ignore", null, htmlFeedback + " - Testing Plaese ignore", "*****@*****.**", EmailAddress, CCMailId, BCCMailId, Server.MapPath(pathvalue.ToString()));
                            });
                        }
                        else
                        {
                            Task.Factory.StartNew(() =>
                            {
                                DsrcMailSystem.MailSender.SendMailToALL(null, objFeedback.Subject, "", htmlFeedback, "*****@*****.**", objFeedback.To, objFeedback.CC, objFeedback.BCC, Server.MapPath(pathvalue.ToString()));
                            });
                        }
                    }
                    else
                    {
                        // string ServerName = WebConfigurationManager.AppSettings["SeverName"];
                        ExceptionHandlingController.TemplateMissing("Feedback", folder, ServerName);
                    }
                    //DsrcMailSystem.MailSender.SendMail("", "Feedback", "", MailMessage, email, "*****@*****.**", Server.MapPath("~/Content/Template/images/logo.png")); });
                    //Task.Factory.StartNew(() => { DsrcMailSystem.MailSender.SendMail("", "Feedback", "", userFeedback.Feedback, email, "*****@*****.**", Server.MapPath("~/Content/Template/images/logo.png")); });
                    userFeedback.StatusMessage = "Success";
                }
                return(View(userFeedback));
            }
            catch (Exception Ex)
            {
                string actionName     = this.ControllerContext.RouteData.Values["action"].ToString();
                string controllerName = this.ControllerContext.RouteData.Values["controller"].ToString();
                ExceptionHandlingController.ExceptionDetails(Ex, actionName, controllerName);
            }
            return(View(userFeedback));
        }
Exemplo n.º 7
0
        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));
            }
        }
Exemplo n.º 8
0
        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));
        }
Exemplo n.º 9
0
        public ActionResult EditEvent(CalendarEventModel model)
        {
            string ServerName      = AppValue.GetFromMailAddress("ServerName");
            var    varUpdateEvents = objdb.CalenderEvents.Where(t => t.EventID == model.EventId).Select(e => e).FirstOrDefault();

            varUpdateEvents.EventName        = model.EventName;
            varUpdateEvents.EventDescription = model.EventDescription;
            varUpdateEvents.StartDate        = model.StartDate;
            varUpdateEvents.Enddate          = model.EndDate;
            varUpdateEvents.StartTime        = model.StartTime;
            varUpdateEvents.EndTime          = model.EndTime;
            varUpdateEvents.ColorCode        = model.ColorCode;
            objdb.SaveChanges();

            var dbEventUsers =
                objdb.CalendarEventUserMappings.Where(c => c.EventID == model.EventId).Select(ce => ce).ToList();
            List <int?> modelMemberList = new List <int?>();

            string[] members = model.Members.Split(',');
            for (int i = 0; i < members.Count(); i++)
            {
                modelMemberList.Add(Convert.ToInt32(members[i]));
            }
            var insertUser = modelMemberList.Where(u => dbEventUsers.All(r => r.UserId != u.Value));
            var deleteUser = dbEventUsers.Where(u => modelMemberList.All(r => r.Value != u.UserId));

            var useInsertUser = insertUser.Select(i => i.Value).ToList();
            var useDeleteUser = deleteUser.Select(d => d.UserId).ToList();

            foreach (var users in useInsertUser)
            {
                var varInsertUser = objdb.CalendarEventUserMappings.CreateObject();
                varInsertUser.EventID = model.EventId;
                varInsertUser.UserId  = users;
                objdb.CalendarEventUserMappings.AddObject(varInsertUser);
                objdb.SaveChanges();
            }
            foreach (var users in useDeleteUser)
            {
                var varDeleteUser =
                    objdb.CalendarEventUserMappings.Where(c => c.UserId == users && c.EventID == model.EventId).FirstOrDefault();
                objdb.CalendarEventUserMappings.DeleteObject(varDeleteUser);
                objdb.SaveChanges();
            }



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

            foreach (int item in modelMemberList)
            {
                var username = objdb.Users.Where(x => x.UserID == item).Select(o => o.UserName).FirstOrDefault();
                membersmailids.Add(username);
            }

            DSRCManagementSystemEntities1 db = new DSRCManagementSystemEntities1();

            var objcom = db.Master_ApplicationSettings.Where(x => x.AppKey == "Company Name").Select(o => o.AppValue).FirstOrDefault();

            string Title   = " " + objcom + "   calendar event  updated";
            string Subject = " event was updated on " + DateTime.Today.ToString("dd MMM yyyy");

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

            if ((check != null) && (check != 0))
            {
                var obj = (from p in db.EmailPurposes.Where(x => x.EmailPurposeName == "Edit Event")
                           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();


                string TemplatePath = Server.MapPath(obj.Template);
                string html         = System.IO.File.ReadAllText(TemplatePath);


                Title       = " " + objcom + "   calendar event updated";
                Subject     = " event  has changed , please refer the  below details";
                obj.Subject = " " + objcom + " Management Portal  event  Updated";
                html        = html.Replace("#Title", Title);
                html        = html.Replace("#Subject", Subject);
                html        = html.Replace("#EventName", model.EventName);
                html        = html.Replace("#EventDescription", model.EventDescription);
                html        = html.Replace("#StartDate", model.StartDate.ToString());
                html        = html.Replace("#EndDate", model.EndDate.ToString());
                html        = html.Replace("#CompanyName", objcom.ToString());


                html = html.Replace("#ServerName", ServerName);


                obj.To = MyCalendarController.GetUserEmailAddress(db, obj.To);
                obj.CC = MyCalendarController.GetUserEmailAddress(db, obj.CC);

                if (obj.BCC != "")
                {
                    obj.BCC = MyCalendarController.GetUserEmailAddress(db, obj.BCC);
                }
                //string ServerName1 = WebConfigurationManager.AppSettings["SeverName"];

                if (ServerName != "http://*****:*****@dsrc.co.in");
                    //MailIds.Add("*****@*****.**");
                    //MailIds.Add("*****@*****.**");
                    //MailIds.Add("*****@*****.**");
                    //MailIds.Add("*****@*****.**");
                    //MailIds.Add("*****@*****.**");
                    //MailIds.Add("*****@*****.**");
                    //foreach (var item in  membersmailids)
                    //{
                    //    MailIds.Add(item.ToString());
                    //}
                    string EmailAddress = "";

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

                    EmailAddress = EmailAddress.Remove(EmailAddress.Length - 1);

                    string CCMailId  = "*****@*****.**";
                    string BCCMailId = "*****@*****.**";


                    Task.Factory.StartNew(() =>
                    {
                        //var logo = db.Master_ApplicationSettings.Where(x => x.AppID == 7).Select(x => x).FirstOrDefault();

                        //string[] words;

                        //words = logo.AppValue.Split(new string[] { "../../" }, StringSplitOptions.None);

                        //string pathvalue = "~/" + words[1];
                        string pathvalue = CommonLogic.getLogoPath();
                        DsrcMailSystem.MailSender.SendMailToALL(null, obj.Subject + " - Test Mail Please Ignore", null, html + " - Testing Plaese ignore", "*****@*****.**", EmailAddress, CCMailId, BCCMailId, Server.MapPath(pathvalue.ToString()));
                    });
                }
                else
                {
                    Task.Factory.StartNew(() =>
                    {
                        //var logo = db.Master_ApplicationSettings.Where(x => x.AppID == 7).Select(x => x).FirstOrDefault();

                        //string[] words;

                        //words = logo.AppValue.Split(new string[] { "../../" }, StringSplitOptions.None);

                        //string pathvalue = "~/" + words[1];

                        string pathvalue = CommonLogic.getLogoPath();

                        DsrcMailSystem.MailSender.SendMailToALL(null, obj.Subject, "", html, "*****@*****.**", obj.To, obj.CC, obj.BCC, Server.MapPath(pathvalue.ToString()));
                    });
                }
            }

            else
            {
                // string ServerName = WebConfigurationManager.AppSettings["SeverName"];
                ExceptionHandlingController.TemplateMissing("Edit Event", folder, ServerName);
            }
            return(Json("Success", JsonRequestBehavior.AllowGet));
        }
Exemplo n.º 10
0
        public ActionResult DeleteEvent(int EventId)
        {
            DSRCManagementSystemEntities1 db = new DSRCManagementSystemEntities1();
            string ServerName     = AppValue.GetFromMailAddress("ServerName");
            var    varDeleteEvent = objdb.CalendarEventUserMappings.Where(ce => ce.EventID == EventId).Select(c => c.EventID).ToList();

            foreach (var events in varDeleteEvent)
            {
                var varDeleteAllEvent = objdb.CalendarEventUserMappings.Where(c => c.EventID == events).FirstOrDefault();
                objdb.CalendarEventUserMappings.DeleteObject(varDeleteAllEvent);
                objdb.SaveChanges();
            }


            var varCalenderEvents = objdb.CalenderEvents.Where(e => e.EventID == EventId).Select(e => e).FirstOrDefault();

            varCalenderEvents.IsActive = false;
            objdb.SaveChanges();


            var objcom = db.Master_ApplicationSettings.Where(x => x.AppKey == "Company Name").Select(o => o.AppValue).FirstOrDefault();

            string Title   = " " + objcom + "calendar event  deleted";
            string Subject = " event  was  canceled ";
            var    check   = db.EmailTemplates.Where(x => x.TemplatePurpose == "Delete Event").Select(o => o.EmailTemplateID).FirstOrDefault();
            var    folder  = db.EmailTemplates.Where(o => o.TemplatePurpose == "Delete Event").Select(x => x.TemplatePath).FirstOrDefault();

            if ((check != null) && (check != 0))
            {
                var obj = (from p in db.EmailPurposes.Where(x => x.EmailPurposeName == "Delete Event")
                           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();


                string TemplatePath = Server.MapPath(obj.Template);
                string html         = System.IO.File.ReadAllText(TemplatePath);


                Title       = " " + objcom + "   calendar event  deleted";
                Subject     = " event  has  been canceled,  please refer the below details";
                obj.Subject = " " + objcom + " Management Portal  event  Deleted";
                html        = html.Replace("#Title", Title);
                html        = html.Replace("#Subject", Subject);
                html        = html.Replace("#EventName", varCalenderEvents.EventName);
                html        = html.Replace("#EventDescription", varCalenderEvents.EventDescription);
                html        = html.Replace("#StartDate", varCalenderEvents.StartDate.ToString());
                html        = html.Replace("#EndDate", varCalenderEvents.Enddate.ToString());
                html        = html.Replace("#CompanyName", objcom.ToString());


                html = html.Replace("#ServerName", ServerName);


                obj.To = MyCalendarController.GetUserEmailAddress(db, obj.To);
                obj.CC = MyCalendarController.GetUserEmailAddress(db, obj.CC);

                if (obj.BCC != "")
                {
                    obj.BCC = MyCalendarController.GetUserEmailAddress(db, obj.BCC);
                }
                //  string ServerName1 = WebConfigurationManager.AppSettings["SeverName"];

                if (ServerName == "http://*****:*****@dsrc.co.in");
                    //MailIds.Add("*****@*****.**");
                    //MailIds.Add("*****@*****.**");
                    //MailIds.Add("*****@*****.**");
                    //MailIds.Add("*****@*****.**");
                    //MailIds.Add("*****@*****.**");
                    //MailIds.Add("*****@*****.**");
                    //foreach (var item in  membersmailids)
                    //{
                    //    MailIds.Add(item.ToString());
                    //}
                    string EmailAddress = "";

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

                    EmailAddress = EmailAddress.Remove(EmailAddress.Length - 1);

                    string CCMailId  = "*****@*****.**";
                    string BCCMailId = "*****@*****.**";


                    Task.Factory.StartNew(() =>
                    {
                        //var logo = db.Master_ApplicationSettings.Where(x => x.AppID == 7).Select(x => x).FirstOrDefault();

                        //string[] words;

                        //words = logo.AppValue.Split(new string[] { "../../" }, StringSplitOptions.None);

                        //string pathvalue = "~/" + words[1];

                        string pathvalue = CommonLogic.getLogoPath();

                        DsrcMailSystem.MailSender.SendMailToALL(null, obj.Subject + " - Test Mail Please Ignore", null, html + " - Testing Plaese ignore", "*****@*****.**", EmailAddress, CCMailId, BCCMailId, Server.MapPath(pathvalue.ToString()));
                    });
                }
                else
                {
                    Task.Factory.StartNew(() =>
                    {
                        //var logo = db.Master_ApplicationSettings.Where(x => x.AppID == 7).Select(x => x).FirstOrDefault();

                        //string[] words;

                        //words = logo.AppValue.Split(new string[] { "../../" }, StringSplitOptions.None);

                        //string pathvalue = "~/" + words[1];

                        string pathvalue = CommonLogic.getLogoPath();


                        DsrcMailSystem.MailSender.SendMailToALL(null, obj.Subject, "", html, "*****@*****.**", obj.To, obj.CC, obj.BCC, Server.MapPath(pathvalue.ToString()));
                    });
                }
            }
            else
            {
                //string ServerName = WebConfigurationManager.AppSettings["SeverName"];
                ExceptionHandlingController.TemplateMissing("Delete Event", folder, ServerName);
            }

            return(Json("Success", JsonRequestBehavior.AllowGet));
        }
Exemplo n.º 11
0
        public ActionResult CreateEvent(CalendarEventModel model)
        {
            //var varCalenderEvents = objdb.CalenderEvents.CreateObject();
            //varCalenderEvents.EventName = model.EventName;
            //varCalenderEvents.EventDescription = model.EventDescription;
            //varCalenderEvents.StartDate = model.StartDate;
            //varCalenderEvents.Enddate = model.EndDate;
            //varCalenderEvents.StartTime = model.StartTime;
            //varCalenderEvents.EndTime = model.EndTime;
            //varCalenderEvents.ColorCode = model.ColorCode;
            //varCalenderEvents.CreatedBy = Convert.ToInt32(Session["UserID"]);
            //varCalenderEvents.CreatedDate = DateTime.Now;
            //varCalenderEvents.IsActive = true;
            //varCalenderEvents.Entypo = "entypo-network";
            //objdb.CalenderEvents.AddObject(varCalenderEvents);
            //objdb.SaveChanges();

            string   ServerName   = AppValue.GetFromMailAddress("ServerName");
            DateTime Assigneddate = Convert.ToDateTime(model.StartDate);
            int      EventTypeId  = Convert.ToInt32(model.RecurringID);
            DateTime Enddate      = new DateTime();

            //if (EventTypeId == 1)
            //{
            //    Enddate = Assigneddate;
            //}
            //if (EventTypeId == 2)
            //{

            //    Enddate = Assigneddate.AddDays(7);
            //}
            //if (EventTypeId == 3)
            //{

            //    Enddate = Assigneddate.AddDays(15);
            //}
            //if (EventTypeId == 4)
            //{

            //    Enddate = Assigneddate.AddDays(30);
            //}

            var daily        = MasterEnum.Recurring.Daily.GetHashCode();
            var Weekly       = MasterEnum.Recurring.Weekly.GetHashCode();
            var monthlyTwice = MasterEnum.Recurring.FifteenDaysOnce.GetHashCode();
            var Monthly      = MasterEnum.Recurring.Monthly.GetHashCode();



            var calendarDetails = objdb.CalendarYears.FirstOrDefault();
            var year            = DateTime.Now.Month <= calendarDetails.EndingMonth ? DateTime.Now.Year - 1 : DateTime.Now.Year;
            var calendarModel   = new DSRCManagementSystem.Models.Calendar().GetCalendarDetails(year, calendarDetails.StartingMonth ?? 1, calendarDetails.EndingMonth ?? 12);
            var end             = calendarModel.EndDate;



            if (model.RecurringID == Monthly)//Monthly
            {
                var monthly = new List <DateTime>();
                for (var dt = model.StartDate; dt <= model.EndDate; dt = dt.Value.AddMonths(1))
                {
                    monthly.Add(dt.Value);
                }



                foreach (var data in monthly)
                {
                    var varCalenderEvents = objdb.CalenderEvents.CreateObject();
                    var sdate             = data.Date.ToString("dd-MM-yyyy") + " " + "09:00:00";
                    var edate             = data.Date.ToString("dd-MM-yyyy") + " " + "18:00:00";
                    varCalenderEvents.EventName        = model.EventName;
                    varCalenderEvents.EventDescription = model.EventDescription;
                    varCalenderEvents.StartDate        = Convert.ToDateTime(sdate);
                    //varCalenderEvents.Enddate = Convert.ToDateTime(edate);
                    varCalenderEvents.Enddate         = model.EndDate;
                    varCalenderEvents.StartTime       = model.StartTime;
                    varCalenderEvents.EndTime         = model.EndTime;
                    varCalenderEvents.ColorCode       = model.ColorCode;
                    varCalenderEvents.CreatedBy       = Convert.ToInt32(Session["UserID"]);
                    varCalenderEvents.CreatedDate     = DateTime.Now;
                    varCalenderEvents.IsActive        = true;
                    varCalenderEvents.Entypo          = "entypo-network";
                    varCalenderEvents.RecurringTypeID = model.RecurringID;
                    objdb.CalenderEvents.AddObject(varCalenderEvents);
                    objdb.SaveChanges();



                    List <int?> memberlist = new List <int?>();
                    string[]    members    = model.Members.Split(',');
                    for (int i = 0; i < members.Count(); i++)
                    {
                        memberlist.Add(Convert.ToInt32(members[i]));
                    }

                    foreach (int mlist in memberlist)
                    {
                        var varCEUM = objdb.CalendarEventUserMappings.CreateObject();
                        varCEUM.EventID = varCalenderEvents.EventID;
                        varCEUM.UserId  = Convert.ToInt32(mlist);
                        objdb.CalendarEventUserMappings.AddObject(varCEUM);
                        objdb.SaveChanges();
                    }
                }
            }



            if (model.RecurringID == Weekly)//weekly
            {
                var weekly = new List <DateTime>();
                for (var dt = model.StartDate; dt <= model.EndDate; dt = dt.Value.AddDays(7))
                {
                    weekly.Add(dt.Value);
                }



                foreach (var dataweekly in weekly)
                {
                    var varCalenderEvents = objdb.CalenderEvents.CreateObject();
                    var sdate             = dataweekly.Date.ToString("dd-MM-yyyy") + " " + "09:00:00";
                    var edate             = dataweekly.Date.ToString("dd-MM-yyyy") + " " + "18:00:00";
                    varCalenderEvents.EventName        = model.EventName;
                    varCalenderEvents.EventDescription = model.EventDescription;
                    varCalenderEvents.StartDate        = Convert.ToDateTime(sdate);
                    //varCalenderEvents.Enddate = Convert.ToDateTime(edate);
                    varCalenderEvents.Enddate         = model.EndDate;
                    varCalenderEvents.StartTime       = model.StartTime;
                    varCalenderEvents.EndTime         = model.EndTime;
                    varCalenderEvents.ColorCode       = model.ColorCode;
                    varCalenderEvents.CreatedBy       = Convert.ToInt32(Session["UserID"]);
                    varCalenderEvents.CreatedDate     = DateTime.Now;
                    varCalenderEvents.IsActive        = true;
                    varCalenderEvents.Entypo          = "entypo-network";
                    varCalenderEvents.RecurringTypeID = model.RecurringID;
                    objdb.CalenderEvents.AddObject(varCalenderEvents);
                    objdb.SaveChanges();



                    List <int?> memberlist = new List <int?>();
                    string[]    members    = model.Members.Split(',');
                    for (int i = 0; i < members.Count(); i++)
                    {
                        memberlist.Add(Convert.ToInt32(members[i]));
                    }

                    foreach (int mlist in memberlist)
                    {
                        var varCEUM = objdb.CalendarEventUserMappings.CreateObject();
                        varCEUM.EventID = varCalenderEvents.EventID;
                        varCEUM.UserId  = Convert.ToInt32(mlist);
                        objdb.CalendarEventUserMappings.AddObject(varCEUM);
                        objdb.SaveChanges();
                    }
                }
            }


            if (model.RecurringID == monthlyTwice)
            {
                var monthlytwice = new List <DateTime>();
                for (var dt = model.StartDate; dt <= model.EndDate; dt = dt.Value.AddDays(15))
                {
                    monthlytwice.Add(dt.Value);
                }
                foreach (var datamonthlytwice in monthlytwice)
                {
                    var varCalenderEvents = objdb.CalenderEvents.CreateObject();
                    var sdate             = datamonthlytwice.Date.ToString("dd-MM-yyyy") + " " + "09:00:00";
                    var edate             = datamonthlytwice.Date.ToString("dd-MM-yyyy") + " " + "18:00:00";
                    varCalenderEvents.EventName        = model.EventName;
                    varCalenderEvents.EventDescription = model.EventDescription;
                    varCalenderEvents.StartDate        = Convert.ToDateTime(sdate);
                    //varCalenderEvents.Enddate = Convert.ToDateTime(edate);
                    varCalenderEvents.Enddate         = model.EndDate;
                    varCalenderEvents.StartTime       = model.StartTime;
                    varCalenderEvents.EndTime         = model.EndTime;
                    varCalenderEvents.ColorCode       = model.ColorCode;
                    varCalenderEvents.CreatedBy       = Convert.ToInt32(Session["UserID"]);
                    varCalenderEvents.CreatedDate     = DateTime.Now;
                    varCalenderEvents.IsActive        = true;
                    varCalenderEvents.Entypo          = "entypo-network";
                    varCalenderEvents.RecurringTypeID = model.RecurringID;
                    objdb.CalenderEvents.AddObject(varCalenderEvents);
                    objdb.SaveChanges();



                    List <int?> memberlist = new List <int?>();
                    string[]    members    = model.Members.Split(',');
                    for (int i = 0; i < members.Count(); i++)
                    {
                        memberlist.Add(Convert.ToInt32(members[i]));
                    }

                    foreach (int mlist in memberlist)
                    {
                        var varCEUM = objdb.CalendarEventUserMappings.CreateObject();
                        varCEUM.EventID = varCalenderEvents.EventID;
                        varCEUM.UserId  = Convert.ToInt32(mlist);
                        objdb.CalendarEventUserMappings.AddObject(varCEUM);
                        objdb.SaveChanges();
                    }
                }
            }



            if (model.RecurringID == daily)
            {
                var varCalenderEvents = objdb.CalenderEvents.CreateObject();
                varCalenderEvents.EventName        = model.EventName;
                varCalenderEvents.EventDescription = model.EventDescription;
                varCalenderEvents.StartDate        = model.StartDate;
                varCalenderEvents.Enddate          = model.EndDate;
                varCalenderEvents.StartTime        = model.StartTime;
                varCalenderEvents.EndTime          = model.EndTime;
                varCalenderEvents.ColorCode        = model.ColorCode;
                varCalenderEvents.CreatedBy        = Convert.ToInt32(Session["UserID"]);
                varCalenderEvents.CreatedDate      = DateTime.Now;
                varCalenderEvents.IsActive         = true;
                varCalenderEvents.Entypo           = "entypo-network";
                varCalenderEvents.RecurringTypeID  = model.RecurringID;
                objdb.CalenderEvents.AddObject(varCalenderEvents);
                objdb.SaveChanges();



                List <int?> memberlist = new List <int?>();
                string[]    members    = model.Members.Split(',');
                for (int i = 0; i < members.Count(); i++)
                {
                    memberlist.Add(Convert.ToInt32(members[i]));
                }

                foreach (int mlist in memberlist)
                {
                    var varCEUM = objdb.CalendarEventUserMappings.CreateObject();
                    varCEUM.EventID = varCalenderEvents.EventID;
                    varCEUM.UserId  = Convert.ToInt32(mlist);
                    objdb.CalendarEventUserMappings.AddObject(varCEUM);
                    objdb.SaveChanges();
                }
            }



            DSRCManagementSystemEntities1 db = new DSRCManagementSystemEntities1();

            var objcom =
                db.Master_ApplicationSettings.Where(x => x.AppKey == "Company Name")
                .Select(o => o.AppValue)
                .FirstOrDefault();

            string Title   = " " + objcom + "   calendar event  created";
            string Subject = " event was created on " + DateTime.Today.ToString("dd MMM yyyy");

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

            if ((check != null) && (check != 0))
            {
                var obj = (from p in db.EmailPurposes.Where(x => x.EmailPurposeName == "Create Event")
                           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();

                string TemplatePath = Server.MapPath(obj.Template);
                string html         = System.IO.File.ReadAllText(TemplatePath);


                Title       = " " + objcom + "   calendar event Created";
                Subject     = " event was created on " + DateTime.Today.ToString("dd MMM yyyy");
                obj.Subject = " " + objcom + " Management Portal-new  event  Created";



                html = html.Replace("#Title", Title);
                html = html.Replace("#Subject", Subject);
                html = html.Replace("#EventName", model.EventName);
                html = html.Replace("#EventDescription", model.EventDescription);
                html = html.Replace("#StartDate", model.StartDate.ToString());
                html = html.Replace("#EndDate", model.EndDate.ToString());
                html = html.Replace("#CompanyName", objcom.ToString());


                html = html.Replace("#ServerName", ServerName);


                obj.To = MyCalendarController.GetUserEmailAddress(db, obj.To);
                obj.CC = MyCalendarController.GetUserEmailAddress(db, obj.CC);
                if (obj.BCC != "")
                {
                    obj.BCC = MyCalendarController.GetUserEmailAddress(db, obj.BCC);
                }


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

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

                    //foreach (var item in membersemail)
                    //{
                    //    MailIds.Add(item.ToString());
                    //}


                    string EmailAddress = "";

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

                    EmailAddress = EmailAddress.Remove(EmailAddress.Length - 1);

                    string CCMailId  = "*****@*****.**";
                    string BCCMailId = "*****@*****.**";


                    Task.Factory.StartNew(() =>
                    {
                        //var logo =
                        //    db.Master_ApplicationSettings.Where(x => x.AppID == 7).Select(x => x).FirstOrDefault();

                        //string[] words;

                        //words = logo.AppValue.Split(new string[] { "../../" }, StringSplitOptions.None);

                        //string pathvalue = "~/" + words[1];
                        string pathvalue = CommonLogic.getLogoPath();
                        DsrcMailSystem.MailSender.SendMailToALL(null, obj.Subject + " - Test Mail Please Ignore", null,
                                                                html + " - Testing Plaese ignore", "*****@*****.**", EmailAddress, CCMailId, BCCMailId,
                                                                Server.MapPath(pathvalue.ToString()));
                    });
                }
                else
                {
                    Task.Factory.StartNew(() =>
                    {
                        //var logo =
                        //    db.Master_ApplicationSettings.Where(x => x.AppID == 7).Select(x => x).FirstOrDefault();

                        //string[] words;

                        //words = logo.AppValue.Split(new string[] { "../../" }, StringSplitOptions.None);

                        //string pathvalue = "~/" + words[1];
                        string pathvalue = CommonLogic.getLogoPath();

                        DsrcMailSystem.MailSender.SendMailToALL(null, obj.Subject, "", html, "*****@*****.**", obj.To,
                                                                obj.CC, obj.BCC, Server.MapPath(pathvalue.ToString()));
                    });
                }
            }
            else
            {
                //string ServerName = WebConfigurationManager.AppSettings["SeverName"];
                ExceptionHandlingController.TemplateMissing("Create Event", folder, ServerName);
            }
            return(Json("Success", JsonRequestBehavior.AllowGet));
        }
Exemplo n.º 12
0
        public ActionResult Form(CompletedTraining objcom, List <int> Attendess, List <int> Unattendess) //, List<string> LAttendess, List<string> LUnattendess)
        {
            try
            {
                string ServerName = AppValue.GetFromMailAddress("ServerName");
                DSRCManagementSystemEntities1 objdb = new DSRCManagementSystemEntities1();
                int count  = Attendess.Count();
                int count1 = Unattendess.Count();
                DSRCManagementSystem.TrainingCompletion obj = new DSRCManagementSystem.TrainingCompletion();

                List <string> MailIds   = new List <string>();
                List <string> Unmailids = new List <string>();

                int?userid       = int.Parse(Session["UserID"].ToString());
                int?instructorid = objdb.Trainings.Where(x => x.TrainingId == objcom.TrainingId).Select(o => o.InstructorId).FirstOrDefault();
                int?trainingid   = objcom.TrainingId;
                //  var nominee = Null;


                Session["Instructorid"] = instructorid;

                int?level = objdb.Trainings.Where(x => x.InstructorId == instructorid).Select(o => o.LevelId).FirstOrDefault();

                var value = objdb.TrainingWeightages.Where(x => x.LevelId == level).Select(o => o.Trainee).FirstOrDefault();

                string Feedbacksenton = DateTime.Now.ToShortDateString();

                var nominee1 = objdb.TrainingNominations.Where(x => x.TrainingId == trainingid).Select(o => o).ToList();
                nominee1.ForEach(o => o.CompletionFlag = false);
                objdb.SaveChanges();

                foreach (int Eid in Attendess)
                {
                    // var EId1 = Convert.ToString(Eid);
                    //    var EmpID ="";

                    //        if (EId1.Length == 1)
                    //        {
                    //                EmpID = "0000" + EId1;
                    //        }
                    //       if (EId1.Length == 2)
                    //        {
                    //                EmpID = "000" + EId1;
                    //        }
                    //       if (EId1.Length == 3)
                    //        {
                    //                EmpID = "00" + EId1;
                    //        }
                    //      if (EId1.Length == 4)
                    //        {
                    //                EmpID = "0" + EId1;
                    //        }
                    //      if (EId1.Length == 5)
                    //        {
                    //                EmpID =  EId1;
                    //        }
                    //if (EId1.Length == 1)
                    //  {
                    //          EmpID = "0000" + EId1;
                    //  }
                    // if (EId1.Length == 1)
                    //  {
                    //          EmpID = "0000" + EId1;
                    //  }
                    // var nominee = objdb.TrainingNominations.Where(x => x.TrainingId == trainingid && x.EmpId == EmpID).Select(o => o).FirstOrDefault();
                    if (Eid != 0)
                    {
                        var nominee = objdb.TrainingNominations.Where(x => x.TrainingId == trainingid && x.UserId == Eid).Select(o => o).FirstOrDefault();

                        if (value != null)
                        {
                            nominee.Score = Convert.ToInt32(value);
                            objdb.SaveChanges();
                        }

                        //  string EMPID = Convert.ToString(Eid);

                        //if (EMPID.Length == 4)
                        //{
                        //    EMPID = "0" + EMPID;
                        //}

                        //var user = objdb.Users.FirstOrDefault(o => o.EmpID == ).UserID;

                        //  var user = objdb.Users.Where(x => x.EmpID == EmpID).Select(x => x.UserID).FirstOrDefault();

                        var user = objdb.Users.Where(x => x.UserID == Eid).Select(x => x.UserID).FirstOrDefault();



                        // To avoid duplicate trainingID and UserID combination in training feedback calculation.
                        var CheckUser = objdb.TrainingFeedBackCalcs.FirstOrDefault(o => o.TrainingId == nominee.TrainingId && o.UserId == user);

                        if (CheckUser == null)
                        {
                            var RequestToFeedback = new TrainingFeedBackCalc
                            {
                                TrainingId          = nominee.TrainingId,
                                UserId              = user,
                                ChoiceTopic         = 0,
                                PgmRelevance        = 0,
                                ContentAmt          = 0,
                                AdequacyLearning    = 0,
                                AdequacyPreparation = 0,
                                ExampleDemo         = 0,
                                ContentPresented    = 0,
                                TimeMaintanence     = 0,
                                FacultyQuality      = 0,
                                PgmUseful           = false,
                                LearntInPgm         = "Not given yet",
                                Comments            = "Not given yet",
                                FeedBackSentOn      = Convert.ToDateTime(Feedbacksenton),
                                Flag = false
                            };
                            objdb.TrainingFeedBackCalcs.AddObject(RequestToFeedback);
                            objdb.SaveChanges();
                        }
                    }
                    else
                    {
                    }
                }

                foreach (int UEid in Unattendess)
                {
                    //if (UEid != 0)
                    //{
                    //    var EmpID = Convert.ToString(UEid);

                    //    if (EmpID.Length == 1)
                    //    {
                    //        EmpID = "0000" + EmpID;
                    //    }
                    //    if (EmpID.Length == 2)
                    //    {
                    //        EmpID = "000" + EmpID;
                    //    }
                    //    if (EmpID.Length == 3)
                    //    {
                    //        EmpID = "00" + EmpID;
                    //    }
                    //    if (EmpID.Length == 4)
                    //    {
                    //        EmpID = "0" + EmpID;
                    //    }
                    //if (EmpID.Length == 5)
                    //{
                    //    EmpID = EmpID;
                    //}
                    //var nominee2 = objdb.TrainingNominations.Where(x => x.TrainingId == trainingid && x.EmpId == UEid).Select(o => o).FirstOrDefault();
                    if (UEid != 0)
                    {
                        if (value != null)
                        {
                            var nominee2 = objdb.TrainingNominations.Where(x => x.TrainingId == trainingid && x.UserId == UEid).Select(o => o).FirstOrDefault();
                            nominee2.Score = -(Convert.ToInt32(value));
                            objdb.SaveChanges();
                        }

                        //}


                        int id = Convert.ToInt32(trainingid);

                        var RequestToFeedbackAgg = new TrainingFeedbackAggregate
                        {
                            TrainingId       = id,
                            TopicRating      = 0,
                            RelevanceRating  = 0,
                            CntAmtRating     = 0,
                            LearnRating      = 0,
                            PrepareRating    = 0,
                            EgDemoRating     = 0,
                            CntPresentRating = 0,
                            TimeRating       = 0,
                            QualityRating    = 0,
                            ContentRating    = 0,
                            PresentRating    = 0,
                            FacultyQRating   = 0,
                            OverAllRating    = 0,
                            No_Of_Attendees  = 0
                        };

                        objdb.TrainingFeedbackAggregates.AddObject(RequestToFeedbackAgg);
                        objdb.SaveChanges();
                    }
                }

                /******In trainings after submitting completed the status is changed as Feedback pending not as completed.
                 * dont change this status will effect on worklist mand Manage training*********/
                var valuefed = objdb.Trainings.Where(x => x.TrainingId == trainingid).Select(o => o).FirstOrDefault();
                valuefed.StatusId = 3;
                objdb.SaveChanges();

                string temp = "";

                foreach (var num in Attendess)
                {
                    temp += num + ",";
                }
                string temp1 = "";
                foreach (var num1 in Unattendess)
                {
                    temp1 += num1 + ",";
                }

                int u = Attendess.Count();
                int v = Unattendess.Count();

                DSRCManagementSystem.TrainingCompletion com = new DSRCManagementSystem.TrainingCompletion();
                com.TrainingId   = objcom.TrainingId;
                com.TrainingName = objcom.Name;
                com.Date         = DateTime.Now;
                com.Attendece    = obj.Attendece;
                if (objcom.upload == null)
                {
                    com.Material = "";
                    objdb.SaveChanges();
                }
                else
                {
                    com.Material = objcom.upload;
                    objdb.SaveChanges();
                }
                com.Count    = u;
                com.IsActive = false;
                objdb.AddToTrainingCompletions(com);
                objdb.SaveChanges();

                int empid;

                for (int i = 0; i < count; i++)
                {
                    //empid = Convert.ToString(Attendess[i]);
                    // empid = "0" + empid;

                    // var Mail = objdb.Users.Where(x => x.EmpID == empid).Select(o => o.EmailAddress).FirstOrDefault();
                    empid = Attendess[i];
                    var Mail = objdb.Users.Where(x => x.UserID == empid).Select(o => o.EmailAddress).FirstOrDefault();

                    MailIds.Add(Mail);
                }

                for (int j = 0; j < count1; j++)
                {
                    empid = Unattendess[j];

                    // if (empid.Length == 4)
                    //  empid = "0" + empid;

                    // var Mail = objdb.Users.Where(x => x.EmpID == empid).Select(o => o.EmailAddress).FirstOrDefault();
                    var Mail = objdb.Users.Where(x => x.UserID == empid).Select(o => o.EmailAddress).FirstOrDefault();

                    Unmailids.Add(Mail);
                }
                int k = MailIds.Count();
                int l = Unmailids.Count();

                var TrainingDetails = objdb.Trainings.FirstOrDefault(o => o.TrainingId == trainingid);

                string Instructor = objdb.Users.Where(o => o.UserID == instructorid).Select(o => o.FirstName + " " + (o.LastName ?? "")).FirstOrDefault();

                string completion = objcom.upload;

                System.Web.HttpContext.Current.Application["Training"] = trainingid.ToString();

                int c = Convert.ToInt32(System.Web.HttpContext.Current.Application["Training"]);

                DateTime?d1 = objdb.Trainings.FirstOrDefault(o => o.TrainingId == trainingid).ScheduledDate;
                DateTime d2 = Convert.ToDateTime(d1);
                string   d  = d2.ToShortDateString();
                // string ServerName = WebConfigurationManager.AppSettings["SeverName"];
                var logo = CommonLogic.getLogoPath();

                if (Unmailids == null) // addedd on 10.10
                {
                    var check  = objdb.EmailTemplates.Where(x => x.TemplatePurpose == "Training Absentees").Select(o => o.EmailTemplateID).FirstOrDefault();
                    var folder = objdb.EmailTemplates.Where(o => o.TemplatePurpose == "Training Absentees").Select(x => x.TemplatePath).FirstOrDefault();
                    if ((check != null) && (check != 0))
                    {
                        var objUnAttendees = (from p in objdb.EmailPurposes.Where(x => x.EmailPurposeName == "Training Absentees")
                                              join q in objdb.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    company = objdb.Master_ApplicationSettings.Where(x => x.AppKey == "Company Name").Select(o => o.AppValue).FirstOrDefault();
                        string TemplatePathUnAttendees = Server.MapPath(objUnAttendees.Template);
                        string htmlUnAttendees         = System.IO.File.ReadAllText(TemplatePathUnAttendees);
                        htmlUnAttendees = htmlUnAttendees.Replace("#TrainingId", trainingid.ToString());
                        htmlUnAttendees = htmlUnAttendees.Replace("#TrainingName", TrainingDetails.TrainingName);
                        htmlUnAttendees = htmlUnAttendees.Replace("#ScheduledDate", d);
                        htmlUnAttendees = htmlUnAttendees.Replace("#start", TrainingDetails.StartTime);
                        htmlUnAttendees = htmlUnAttendees.Replace("#end", TrainingDetails.EndTime);
                        htmlUnAttendees = htmlUnAttendees.Replace("#Instructor", Instructor);
                        htmlUnAttendees = htmlUnAttendees.Replace("#ServerName", ServerName);
                        htmlUnAttendees = htmlUnAttendees.Replace("#CompanyName", company);



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

                            //string EmailAddress = "";

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

                            //EmailAddress = EmailAddress.Remove(EmailAddress.Length - 1);
                            // var logo = objdb.Master_ApplicationSettings.Where(x => x.AppID == 7).Select(x => x).FirstOrDefault();



                            // DsrcMailSystem.MailSender.LD(null, objUnAttendees.Subject + " - Test Mail Please Ignore", null, htmlUnAttendees + " - Testing Plaese ignore", "*****@*****.**", MailIdss, "Test-L&[email protected]", "*****@*****.**", Server.MapPath(logo.AppValue.ToString()));
                            DsrcMailSystem.MailSender.LD(null, objUnAttendees.Subject + " - Test Mail Please Ignore", null, htmlUnAttendees + " - Testing Plaese ignore", "*****@*****.**", MailIdss, "Test-L&[email protected]", "*****@*****.**", Server.MapPath(logo.ToString()));
                        }
                        else
                        {
                            //var logo = objdb.Master_ApplicationSettings.Where(x => x.AppID == 7).Select(x => x).FirstOrDefault();

                            // DsrcMailSystem.MailSender.LD(null, objUnAttendees.Subject, null, htmlUnAttendees, "*****@*****.**", Unmailids, "L&[email protected]", "*****@*****.**", Server.MapPath(logo.AppValue.ToString()));
                            DsrcMailSystem.MailSender.LD(null, objUnAttendees.Subject, null, htmlUnAttendees, "*****@*****.**", Unmailids, "L&[email protected]", "*****@*****.**", Server.MapPath(logo.ToString()));
                        }
                    }
                    else
                    {
                        ExceptionHandlingController.TemplateMissing("Training Absentees", folder, ServerName);
                    }
                } // addede on 10/10

                var checks  = objdb.EmailTemplates.Where(x => x.TemplatePurpose == "Completion").Select(o => o.EmailTemplateID).FirstOrDefault();
                var folders = objdb.EmailTemplates.Where(o => o.TemplatePurpose == "Completion").Select(x => x.TemplatePath).FirstOrDefault();
                if ((checks != null) && (checks != 0))
                {
                    var objCompletion = (from p in objdb.EmailPurposes.Where(x => x.EmailPurposeName == "Completion")
                                         join q in objdb.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    objcompany             = objdb.Master_ApplicationSettings.Where(x => x.AppKey == "Company Name").Select(o => o.AppValue).FirstOrDefault();
                    string TemplatePathCompletion = Server.MapPath(objCompletion.Template);
                    string htmlCompletion         = System.IO.File.ReadAllText(TemplatePathCompletion);
                    htmlCompletion = htmlCompletion.Replace("#trainingname", objcom.Name);
                    htmlCompletion = htmlCompletion.Replace("#scheduleddate", d);
                    htmlCompletion = htmlCompletion.Replace("#ServerName", ServerName);
                    htmlCompletion = htmlCompletion.Replace("#CompanyName", objcompany);


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

                        //string EmailAddress = "";

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

                        //EmailAddress = EmailAddress.Remove(EmailAddress.Length - 1);
                        //var logo = objdb.Master_ApplicationSettings.Where(x => x.AppID == 7).Select(x => x).FirstOrDefault();
                        // DsrcMailSystem.MailSender.LD(null, objCompletion.Subject + " - Test Mail Please Ignore", null, htmlCompletion + " - Testing Plaese ignore", "*****@*****.**", MailIds , "Test-L&[email protected]", "*****@*****.**", Server.MapPath(logo.AppValue.ToString()));
                        DsrcMailSystem.MailSender.LD(null, objCompletion.Subject + " - Test Mail Please Ignore", null, htmlCompletion + " - Testing Plaese ignore", "*****@*****.**", Mailidss, "Test-L&[email protected]", "*****@*****.**", Server.MapPath(logo.ToString()));
                    }
                    else
                    {
                        //var logo = objdb.Master_ApplicationSettings.Where(x => x.AppID == 7).Select(x => x).FirstOrDefault();
                        // DsrcMailSystem.MailSender.LD(null, objCompletion.Subject, null, htmlCompletion, "*****@*****.**", MailIds, "L&[email protected]", "*****@*****.**", Server.MapPath(logo.AppValue.ToString()));
                        DsrcMailSystem.MailSender.LD(null, objCompletion.Subject, null, htmlCompletion, "*****@*****.**", MailIds, "L&[email protected]", "*****@*****.**", Server.MapPath(logo.ToString()));
                    }
                }
                else
                {
                    ExceptionHandlingController.TemplateMissing("Completion", folders, ServerName);
                }
            }
            catch (Exception Ex)
            {
                string actionName     = this.ControllerContext.RouteData.Values["action"].ToString();
                string controllerName = this.ControllerContext.RouteData.Values["controller"].ToString();
                ExceptionHandlingController.ExceptionDetails(Ex, actionName, controllerName);
            }
            return(Json(new { Result = "Success" }, JsonRequestBehavior.AllowGet));
        }
Exemplo n.º 13
0
        public ActionResult Nomination(Nomination nominee)
        {
            DSRCManagementSystemEntities1 db = new DSRCManagementSystemEntities1();
            int    userId     = int.Parse(Session["UserID"].ToString());
            string ServerName = AppValue.GetFromMailAddress("ServerName");

            try
            {
                var Techref       = db.Trainings.FirstOrDefault(o => o.TrainingId == nominee.TrainingID);
                var Supervisorref = db.UserReportings.FirstOrDefault(o => o.UserID == userId);
                nominee.SupervisorId = Supervisorref.ReportingUserID.ToString();
                var SupervisorDetails = db.Users.FirstOrDefault(o => o.UserID == Supervisorref.ReportingUserID);
                nominee.SupervisorName = SupervisorDetails.FirstName;
                nominee.Email          = SupervisorDetails.EmailAddress;
                nominee.ContactNo      = SupervisorDetails.ContactNo.ToString();

                var ReqToNominate = new TrainingNomination()
                {
                    TrainingId     = nominee.TrainingID,
                    TechnologyId   = Techref.TechnologyId,
                    EmpId          = nominee.EmpId,
                    EmpName        = nominee.EmpName,
                    UserId         = userId,
                    SupervisorId   = nominee.SupervisorId,
                    SupervisorName = nominee.SupervisorName,
                    EmailId        = nominee.Email,
                    MobileNo       = nominee.ContactNo,
                    NominationFlag = true,
                    CompletionFlag = true,
                    IsActive       = true
                };

                db.TrainingNominations.AddObject(ReqToNominate);
                db.SaveChanges();

                var No_Of_Nominees_Ref = db.Trainings.FirstOrDefault(o => o.TrainingId == nominee.TrainingID);

                int?No_Of_Nominations = No_Of_Nominees_Ref.NumberOfNominated;
                No_Of_Nominees_Ref.NumberOfNominated = No_Of_Nominations + 1;

                db.SaveChanges();

                string   Tid   = Techref.TrainingId.ToString();
                string   tname = Techref.TrainingName;
                DateTime d1    = Convert.ToDateTime(Techref.ScheduledDate);
                string   d     = d1.ToShortDateString();
                string   stime = Techref.StartTime;
                string   etime = Techref.EndTime;

                string username = db.Users.Where(o => o.UserID == Techref.InstructorId).Select(o => o.FirstName + " " + (o.LastName ?? "")).FirstOrDefault();

                var    userdetails = db.Users.FirstOrDefault(o => o.UserID == userId);
                string MailID      = userdetails.EmailAddress;

                nominee.EmpName = userdetails.FirstName + " " + userdetails.LastName ?? "";



                //string mailMessage = MailBuilder.NominationConfirmation(nominee.EmpName, Tid, tname, d, stime, etime, username);
                var check  = db.EmailTemplates.Where(x => x.TemplatePurpose == "Nomination Confirmation").Select(o => o.EmailTemplateID).FirstOrDefault();
                var folder = db.EmailTemplates.Where(o => o.TemplatePurpose == "Nomination Confirmation").Select(x => x.TemplatePath).FirstOrDefault();
                if ((check != null) && (check != 0))
                {
                    var objNominationConfirmation = (from p in db.EmailPurposes.Where(x => x.EmailPurposeName == "Nomination Confirmation")
                                                     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    company = db.Master_ApplicationSettings.Where(x => x.AppKey == "Company Name").Select(o => o.AppValue).FirstOrDefault();
                    string TemplatePathNominationConfirmation = Server.MapPath(objNominationConfirmation.Template);
                    string htmlNominationConfirmation         = System.IO.File.ReadAllText(TemplatePathNominationConfirmation);
                    htmlNominationConfirmation = htmlNominationConfirmation.Replace("#Empname", nominee.EmpName);
                    htmlNominationConfirmation = htmlNominationConfirmation.Replace("#TrainingId", Tid);
                    htmlNominationConfirmation = htmlNominationConfirmation.Replace("#TrainingName", tname);
                    htmlNominationConfirmation = htmlNominationConfirmation.Replace("#ScheduledDate", d);
                    htmlNominationConfirmation = htmlNominationConfirmation.Replace("#start", stime);
                    htmlNominationConfirmation = htmlNominationConfirmation.Replace("#end", etime);
                    htmlNominationConfirmation = htmlNominationConfirmation.Replace("#Instructor", username);
                    htmlNominationConfirmation = htmlNominationConfirmation.Replace("#ServerName", ServerName);
                    htmlNominationConfirmation = htmlNominationConfirmation.Replace("#CompanyName", company);
                    // 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);


                        Task.Factory.StartNew(() =>
                        {
                            //var logo = db.Master_ApplicationSettings.Where(x => x.AppID == 7).Select(x => x).FirstOrDefault();
                            //  DsrcMailSystem.MailSender.SendMail(null, objNominationConfirmation.Subject + " - Test", null, htmlNominationConfirmation + " - Testing Plaese ignore", "*****@*****.**", EmailAddress, Server.MapPath(logo.AppValue.ToString()));
                            DsrcMailSystem.MailSender.SendMail(null, objNominationConfirmation.Subject + " - Test", null, htmlNominationConfirmation + " - Testing Plaese ignore", "*****@*****.**", EmailAddress, Server.MapPath(logo.ToString()));
                        });
                    }
                    else
                    {
                        Task.Factory.StartNew(() =>
                        {
                            // var logo = db.Master_ApplicationSettings.Where(x => x.AppID == 7).Select(x => x).FirstOrDefault();
                            // DsrcMailSystem.MailSender.SendMail(null, objNominationConfirmation.Subject, null, htmlNominationConfirmation, "*****@*****.**", MailID, Server.MapPath(logo.AppValue.ToString()));
                            DsrcMailSystem.MailSender.SendMail(null, objNominationConfirmation.Subject, null, htmlNominationConfirmation, "*****@*****.**", MailID, Server.MapPath(logo.ToString()));
                            //DsrcMailSystem.MailSender.LDSendMail(null, "L & D - Training Nomination Confirmation", null, mailMessage, "*****@*****.**", MailID, Server.MapPath("~/Content/Template/images/logo.png"));
                        });
                    }
                }
                else
                {
                    // string ServerName = WebConfigurationManager.AppSettings["SeverName"];
                    ExceptionHandlingController.TemplateMissing("Nomination Confirmation", folder, ServerName);
                }
            }
            catch (Exception Ex)
            {
                string actionName     = this.ControllerContext.RouteData.Values["action"].ToString();
                string controllerName = this.ControllerContext.RouteData.Values["controller"].ToString();
                ExceptionHandlingController.ExceptionDetails(Ex, actionName, controllerName);
            }

            return(Json("success", JsonRequestBehavior.AllowGet));
        }
Exemplo n.º 14
0
        public ActionResult Skills(skilllist model, FormCollection formData)
        {
            DSRCManagementSystemEntities1 db = new DSRCManagementSystemEntities1();

            DsrcMailSystem.MailSender AppValue = new DsrcMailSystem.MailSender();
            int UserId = (int)Session["UserId"];

            List <string> Technology     = new List <string>();
            List <string> Specialization = new List <string>();
            List <string> Lastused       = new List <string>();
            List <string> Experience     = new List <string>();
            int           t = 0;
            int?          s = 0;

            string ServerName = AppValue.GetFromMailAddress("ServerName");

            var objcompany = db.Master_ApplicationSettings.Where(x => x.AppKey == "Company Name").Select(o => o.AppValue).FirstOrDefault();


            for (int i = 0; i < model.skilllists.Count; i++)
            {
                var LDobj = db.Skills.CreateObject();
                if (model.skilllists[i].Id != 0)
                {
                    try
                    {
                        LDobj.Technology = model.skilllists[i].Id;
                        t = model.skilllists[i].Id;
                        var Techname = db.SkillsTechnologies.Where(o => o.SkillId == t).Select(o => o.SkillName).FirstOrDefault();
                        Technology.Add(Convert.ToString(Techname));

                        LDobj.Specialization = model.skilllists[i].SpecificationId;
                        s = model.skilllists[i].SpecificationId;
                        var SpecializationName = db.SkillsSpecifications.Where(o => o.SpecificationId == s).Select(o => o.Specification).FirstOrDefault();
                        Specialization.Add(Convert.ToString(SpecializationName));

                        LDobj.Level    = model.skilllists[i].LevelId;
                        LDobj.Date     = Convert.ToDateTime(model.skilllists[i].DateAssessed);
                        LDobj.LastUsed = model.skilllists[i].yearid;
                        Lastused.Add(Convert.ToString(model.skilllists[i].yearid));

                        LDobj.UserId    = Convert.ToInt32(Session["UserID"]);
                        LDobj.Primary   = Convert.ToBoolean(model.skilllists[i].Primary);
                        LDobj.Secondary = Convert.ToBoolean(model.skilllists[i].Secondary);

                        LDobj.experiance = model.skilllists[i].experiance.Trim();
                        Experience.Add(Convert.ToString(model.skilllists[i].experiance));
                        LDobj.Isactive   = true;
                        LDobj.status     = 2;
                        LDobj.ApprovedBy = model.skilllists[i].ApprovedBy;
                        db.Skills.AddObject(LDobj);
                        db.SaveChanges();
                    }
                    catch (Exception)
                    {
                    }
                }
                TempData["Success"] = "Skill details Saved Successfully";
            }

            var LevelList = db.Master_TrainingLevel.ToList();

            var TechList = db.SkillsTechnologies.ToList();

            var yearlist = db.Master_years.ToList();
            var specList = db.SkillsSpecifications.ToList();

            skilllist     sk     = new skilllist();
            List <Skills> skl    = new List <Skills>();
            Skills        lModel = new Skills();

            List <SelectListItem> LevelList1 = new List <SelectListItem>();
            List <SelectListItem> TechList1  = new List <SelectListItem>();
            List <SelectListItem> yearlist11 = new List <SelectListItem>();
            List <SelectListItem> specList1  = new List <SelectListItem>();

            foreach (var list in specList)
            {
                specList1.Add(new SelectListItem {
                    Text = list.Specification, Value = Convert.ToString(list.SpecificationId)
                });
            }
            lModel.speciIdList = specList1;

            foreach (var list in LevelList)
            {
                LevelList1.Add(new SelectListItem {
                    Text = list.LevelName, Value = Convert.ToString(list.LevelId)
                });
            }
            lModel.LevelIDList = LevelList1;

            foreach (var list in TechList)
            {
                TechList1.Add(new SelectListItem {
                    Text = list.SkillName, Value = Convert.ToString(list.SkillId)
                });
            }
            lModel.TechIDList = TechList1;

            foreach (var list in yearlist)
            {
                //yearlist11.Add(new SelectListItem { Text = list.year1.ToString(), Value = Convert.ToString(list.ID) });
                yearlist11.Add(new SelectListItem {
                    Text = list.year.ToString(), Value = Convert.ToString(list.ID)
                });
            }
            lModel.yearidlist = yearlist11;

            for (int i = 0; i < 1; i++)
            {
                Skills lm = new Skills();
                lm.SpecificationId = 0;
                lm.LevelId         = 0;
                lm.Id           = 0;
                lm.DateAssessed = null;
                lm.LastUsed     = 0;
                lm.Primary      = false;
                lm.Secondary    = false;
                skl.Add(lm);
            }

            sk.skilllists = skl;
            sk.SKL        = lModel;

            var skillid        = db.Skills.Where(o => o.UserId == UserId && o.Technology == t && o.Specialization == s).Select(o => o.Id).FirstOrDefault();
            var empname        = db.Users.Where(o => o.UserID == UserId).Select(o => o.FirstName + " " + ((o.LastName).Length > 0? o.LastName:" ")).FirstOrDefault();
            var reporting      = db.Skills.Where(o => o.UserId == UserId && o.Technology == t && o.Specialization == s).Select(o => o.ApprovedBy).FirstOrDefault();
            int reportingid    = (int)reporting;
            var reportingname  = db.Users.Where(o => o.UserID == reportingid).Select(o => o.FirstName + " " + ((o.LastName).Length > 0 ? o.LastName : " ")).FirstOrDefault();
            var reportingemail = db.Users.Where(o => o.UserID == reportingid).Select(o => o.EmailAddress).FirstOrDefault();
            var checks         = db.EmailTemplates.Where(x => x.TemplatePurpose == "Skill Added").Select(o => o.EmailTemplateID).FirstOrDefault();
            var folder         = db.EmailTemplates.Where(o => o.TemplatePurpose == "Skill Added").Select(x => x.TemplatePath).FirstOrDefault();

            if ((checks != null) && (checks != 0))
            {
                var objRequest = (from p in db.EmailPurposes.Where(x => x.EmailPurposeName == "Skill Added")
                                  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    company      = db.Master_ApplicationSettings.Where(x => x.AppKey == "Company Name").Select(o => o.AppValue).FirstOrDefault();
                string TemplatePath = Server.MapPath(objRequest.Template);
                string html         = System.IO.File.ReadAllText(TemplatePath);
                string Title        = " Following Skills were Added by " + " " + empname + " " + "for Approval";
                html = html.Replace("#Title", Title);
                html = html.Replace("#Technology", Technology[0]);
                html = html.Replace("#Specialization", Specialization[0]);
                html = html.Replace("#LastUsed", Lastused[0]);
                html = html.Replace("#Experience", Experience[0]);
                html = html.Replace("#RequestedId", Convert.ToString(skillid));
                html = html.Replace("#ReportingPersonName", Convert.ToString(reportingname));
                html = html.Replace("#ServerName", ServerName);
                html = html.Replace("#CompanyName", objcompany);
                html = html.Replace("#ReqUser", empname);


                var logo = CommonLogic.getLogoPath();

                if (ServerName != "http://*****:*****@dsrc.co.in", EmailAddress, Server.MapPath(logo.ToString()));
                    });
                }
                //else
                //{
                //    Task.Factory.StartNew(() =>
                //    {

                //        DsrcMailSystem.MailSender.SendMail(null, objRequest.Subject, null, html, "*****@*****.**", Convert.ToString(reportingemail), Server.MapPath(logo.ToString()));
                //    });
                //}
            }
            else
            {
                ExceptionHandlingController.TemplateMissing("Skill Added", folder, ServerName);
            }



            return(RedirectToAction("Skills", sk));
        }
Exemplo n.º 15
0
        public ActionResult Delete(int Id)
        {
            DSRCManagementSystemEntities1 objdb = new DSRCManagementSystemEntities1();
            string ServerName = AppValue.GetFromMailAddress("ServerName");

            try
            {
                var value  = objdb.Incomes.Where(x => x.IncomeID == Id).Select(o => o).FirstOrDefault();
                var objcom = objdb.Master_ApplicationSettings.Where(x => x.AppKey == "Company Name")
                             .Select(o => o.AppValue)
                             .FirstOrDefault();

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

                var IncomeDes  = objdb.Incomes.Where(x => x.IncomeID == Id).Select(o => o.IncomeDescription).FirstOrDefault();
                var Incomedate = objdb.Incomes.Where(x => x.IncomeID == Id).Select(o => o.IncomeDate).FirstOrDefault();
                var Income     = objdb.Incomes.Where(x => x.IncomeID == Id).Select(o => o.IncomeAmount).FirstOrDefault();


                if (value != null)
                {
                    value.IsActive = false;
                    objdb.SaveChanges();

                    var check  = objdb.EmailTemplates.Where(x => x.TemplatePurpose == "Delete Income").Select(o => o.EmailTemplateID).FirstOrDefault();
                    var folder = objdb.EmailTemplates.Where(o => o.TemplatePurpose == "Delete Income").Select(x => x.TemplatePath).FirstOrDefault();
                    if ((check != null) && (check != 0))
                    {
                        var obj1 = (from p in objdb.EmailPurposes.Where(x => x.EmailPurposeName == "Delete Income")
                                    join q in objdb.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();

                        string TemplatePath = Server.MapPath(obj1.Template);
                        string html         = System.IO.File.ReadAllText(TemplatePath);

                        //string Title = " " + objcom + "   calendar event Created";
                        string Subject = "Income Deleted on " + DateTime.Today.ToString("dd MMM yyyy");
                        obj1.Subject = " " + objcom + " Management Portal-New Income Edited";


                        html = html.Replace("#IncomeDescription", IncomeDes);
                        html = html.Replace("#Date", DateTime.Today.ToString("dd MMM yyyy"));
                        html = html.Replace("#IncomeDate", Incomedate.ToString().Substring(0, 10));
                        html = html.Replace("#IncomeAmount", Income.ToString());
                        html = html.Replace("#CompanyName", objcom.ToString());
                        html = html.Replace("#ServerName", ServerName);
                        List <string> MailIds      = objdb.TestMailIDs.Select(o => o.MailAddress).ToList();
                        string        EmailAddress = "";

                        foreach (string mail in MailIds)
                        {
                            EmailAddress += mail + ",";
                        }
                        EmailAddress = EmailAddress.Remove(EmailAddress.Length - 1);
                        if (ServerName != "http://*****:*****@dsrc.co.in", EmailAddress, Server.MapPath(pathvalue.ToString()));
                            });
                        }
                        else
                        {
                            Task.Factory.StartNew(() =>
                            {
                                string pathvalue = CommonLogic.getLogoPath();
                                DsrcMailSystem.MailSender.TaskMail(null, Subject, html, "*****@*****.**", EmailAddress, Server.MapPath(pathvalue.ToString()));
                            });
                        }
                    }
                    else
                    {
                        ExceptionHandlingController.TemplateMissing("Delete Income", folder, ServerName);
                    }
                }
            }
            catch (Exception Ex)
            {
                string actionName     = this.ControllerContext.RouteData.Values["action"].ToString();
                string controllerName = this.ControllerContext.RouteData.Values["controller"].ToString();
                ExceptionHandlingController.ExceptionDetails(Ex, actionName, controllerName);
            }
            return(Json(new { Result = "Success", URL = @Url.Action("AlertPopUp", "Popup") }, JsonRequestBehavior.AllowGet));
        }