Beispiel #1
0
        public ActionResult UserProfile()
        {
            string serverName = ConfigurationManager.AppSettings["ADServer"];
            string userName   = ConfigurationManager.AppSettings["ADUserName"];
            string password   = ConfigurationManager.AppSettings["ADPassword"];

            if (System.Web.HttpContext.Current.User.Identity.Name != "jbrennan")
            {
                return(RedirectToAction("Index", "Home"));
            }
            SecureString securePwd = null;

            if (password != null)
            {
                securePwd = new SecureString();
                foreach (char chr in password.ToCharArray())
                {
                    securePwd.AppendChar(chr);
                }
            }
            UserProfile usrProfile = new UserProfile();

            try
            {
                ActiveDirectory          adConnect = new ActiveDirectory(serverName, userName, securePwd);
                List <SearchResultEntry> results   = adConnect.GetEntriesBySAMAccountName(System.Web.HttpContext.Current.User.Identity.Name);
                if (results.Count > 0)
                {
                    User usr = new User(adConnect, results[0]);
                    usrProfile.FirstName      = usr.FirstName;
                    usrProfile.LastName       = usr.LastName;
                    usrProfile.Manager        = usr.Manager;
                    usrProfile.Department     = usr.Department;
                    usrProfile.Division       = usr.Division;
                    usrProfile.EmployeeId     = usr.EmployeeId;
                    usrProfile.EmployeeNumber = usr.EmployeeNumber;
                    usrProfile.PhoneNumber    = usr.PhoneNumber;
                    usrProfile.StreetAddress  = usr.StreetAddress;
                    usrProfile.Title          = usr.Title;
                    usrProfile.UserName       = usr.DisplayName;
                    usrProfile.Groups         = usr.Groups;
                }
            }
            catch
            {
                // unable to connect AD
                ModelState.AddModelError("", "Unable to connect AD!");
                var emailBody = "CARS AD Failure for user: "******"*****@*****.**", "*****@*****.**", emailBody);
            }
            return(View(usrProfile));
        }
        public ActionResult ForgetPassword([Bind(Include = "Email,Password")] UserLoginViewModel userLoginViewModel)
        {
            if (ModelState.IsValid)
            {
                Kullanicilar user = db.Kullanicilar.Where(x => x.Email == userLoginViewModel.Email).FirstOrDefault();

                if (user != null)
                {
                    string icerik     = string.Format($"Email:{user.Email}\nŞifre:{user.Sifre}");
                    bool   GonderdiMi = MailSendHelper.Gonder("Deprem Analiz Sistemi Şifre Hatırlatma", icerik, user.Email);
                    return(GonderdiMi ? Json(new { url = Url.Action("Index", "Depremler") }) : (ActionResult)PartialView("PasswordPartial"));
                }
                else
                {
                    return(PartialView("PasswordPartial"));
                }
            }
            else
            {
                return(PartialView("PasswordPartial"));
            }
        }
        public ActionResult Create([Bind(Include = "id,reporting_employee,job_ID,department_ID,component,problem_ID,severity_id," +
                                                   "rework_employee,expectedQuantity,calculated_cost,throwOutInitials,notes,corrective_action," +
                                                   "created_Date,pages,pressSections,proofsRequired,reworkCompleteLocation,SOMaterials,reworkProcess,reworkType,vendor,reportStatus")] Reports reports)
        {
            if (ModelState.IsValid)
            {
                if (reports.calculated_cost == null)
                {
                    reports.calculated_cost = 0;
                }

                int insertResults = TSProd.InsertCARSReport(
                    reports.job_ID
                    , reports.reporting_employee
                    , reports.department_ID
                    , reports.rework_employee
                    , reports.expectedQuantity
                    , reports.component
                    , reports.problem_ID
                    , reports.severity_id
                    , (reports.calculated_cost ?? 0)
                    , reports.throwOutInitials
                    //, reports.throwOutDate
                    , reports.notes
                    , reports.corrective_action
                    , reports.pages
                    , reports.pressSections
                    , reports.proofsRequired
                    , reports.reworkCompleteLocation
                    , reports.SOMaterials
                    , reports.reworkProcess // added 3-21-19 jb
                    , reports.reworkType    // added 3-21-19 jb
                    , reports.vendor        // added 3-21-19 jb
                    , reports.reportStatus  // added 3-21-19 jb
                    );

                if (insertResults > 0) // Successfully inserted report
                {
                    //db.Reports.Add(reports);
                    //db.SaveChanges();
                    //db.Entry(reports).GetDatabaseValues();

                    string departmentEmailList = "[email protected]; [email protected]";

                    departmentEmailList += ";" + TSProd.GetCSRandSalesEmailStringFromJobNumber(reports.job_ID);

                    if (TempData["tempChecked"] != null)
                    {
                        foreach (var dept in (IEnumerable <String>)TempData["tempChecked"])
                        {
                            TSProd.InsertDeparmentCheck(insertResults, Int32.Parse(dept.ToString()));
                            string departmentEmail = TSProd.GetDepartmentEmail(Int32.Parse(dept));
                            departmentEmailList += ";" + departmentEmail;
                        }
                    }

                    var targetURL = "https://cars.tshore.com/Reports/Details/" + insertResults;
                    var emailBody = "Issue submitted for job number: " + reports.job_ID + "<br />";
                    MailSendHelper.SendingDepartmentEmail(reports.reporting_employee, departmentEmailList, emailBody, targetURL, reports.job_ID);


                    return(RedirectToAction("Index", new { reports.reportStatus, reports.reworkType }));
                }
            }

            return(View(reports));
        }
Beispiel #4
0
        public ActionResult Login(LoginViewModel model, string returnUrl)
        {
            string serverName = ConfigurationManager.AppSettings["ADServer"];

            if (ModelState.IsValid)
            {
                SecureString securePwd = null;
                if (model.Password != null)
                {
                    securePwd = new SecureString();
                    foreach (char chr in model.Password.ToCharArray())
                    {
                        securePwd.AppendChar(chr);
                    }
                }
                try
                {
                    //Check user credentials
                    ActiveDirectory adVerifyUser = new ActiveDirectory(serverName, model.UserName, securePwd);

                    FormsAuthentication.SetAuthCookie(model.UserName, model.RememberMe);
                    List <SearchResultEntry> results = adVerifyUser.GetEntriesBySAMAccountName(model.UserName);
                    UserProfile usrLoginProfile      = new UserProfile();
                    if (results.Count > 0)
                    {
                        User adusr = new User(adVerifyUser, results[0]);
                        usrLoginProfile.UserName = adusr.DisplayName;
                        //usrLoginProfile.Groups = adusr.Groups;
                        Session["adFullUserName"] = usrLoginProfile.UserName;
                        HttpCookie carsCookie = new HttpCookie("carsCookie");
                        carsCookie.Value   = usrLoginProfile.UserName;
                        carsCookie.Expires = DateTime.Now.AddHours(8);
                        Response.SetCookie(carsCookie);
                        //Response.Flush();
                    }
                    UserPermissions userPermissions = new UserPermissions();

                    if (CheckUserInGroup("APP_CARS_Admin", model.UserName))
                    {
                        Session["canDeleteEntry"]         = userPermissions.canDeleteEntry = true;
                        Session["canSeeCorrectiveAction"] = userPermissions.canSeeCorrectiveAction = true;
                        Session["canSeeEmployee"]         = userPermissions.canSeeEmployee = true;
                        Session["canEditEntry"]           = userPermissions.canEditEntry = true;
                    }
                    else
                    {
                        Session["canDeleteEntry"]         = userPermissions.canDeleteEntry = false;
                        Session["canSeeCorrectiveAction"] = userPermissions.canSeeCorrectiveAction = false;
                        Session["canSeeEmployee"]         = userPermissions.canSeeEmployee = false;
                        Session["canEditEntry"]           = userPermissions.canEditEntry = true;
                    }

                    return(RedirectToLocal(returnUrl));
                }
                catch
                {
                    // If we got this far, something failed, redisplay form
                    ModelState.AddModelError("", "The user name or password provided is incorrect.");
                    var emailBody = "CARS Login Failure for user: "******"*****@*****.**", "*****@*****.**", emailBody);
                }
            }

            return(View(model));
        }