예제 #1
0
        public void Notify(string userID, String ToID, String Body, String Subject)
        {
            CompanyProfileRepository _cp = new CompanyProfileRepository();
            CompanyProfile           cp  = _cp.GetCompanyProfile(userID);

            if (cp != null)
            {
                System.Net.Mail.MailMessage mail = new System.Net.Mail.MailMessage();
                NetworkCredential           cred = new NetworkCredential(cp.Email, cp.SMTPPassword);
                mail.To.Add(ToID.TrimEnd(",".ToCharArray()).TrimEnd(";".ToCharArray()));
                mail.Subject    = Subject;
                mail.From       = new MailAddress(cp.Email.ToString());
                mail.Body       = Body;
                mail.IsBodyHtml = true;
                string     client = cp.SMTPServer.ToString();
                SmtpClient smtp   = new SmtpClient(client);
                smtp.UseDefaultCredentials = false;
                smtp.EnableSsl             = Convert.ToBoolean(cp.SSL);
                smtp.Credentials           = cred;
                try
                {
                    smtp.Send(mail);
                }
                catch (Exception ex) { }
            }
        }
예제 #2
0
        public ActionResult About()
        {
            CompanyProfileRepository _cp = new CompanyProfileRepository();
            CompanyProfile           cp  = _cp.GetCompanyProfile(User);

            if (cp != null)
            {
                ViewBag.AboutCompany = cp.AboutCompany;
            }
            return(View());
        }
예제 #3
0
        public ActionResult Home2(string RegistrationEntity, string TokenId, bool?isThirdParty)
        {
            if (!string.IsNullOrEmpty(RegistrationEntity) && (Request.UrlReferrer == null || (Request.UrlReferrer != null && Request.UrlReferrer.AbsolutePath.EndsWith("/Account/Login"))))
            {
                ViewBag.RegistrationEntity = RegistrationEntity;
                ViewBag.UserId             = TokenId;
                return(View());
            }

            bool isItemZero = true;
            // var roles = ((CustomPrincipal)User).GetRoles();
            var    roles = User.userroles;
            var    MultipleRoleSelection = CommonFunction.Instance.MultipleRoleSelection();
            string AppUrl = System.Configuration.ConfigurationManager.AppSettings["AppUrl"];

            //ApplicationContext db = new ApplicationContext(User);
            if (User.MultiTenantLoginSelected.Count == 0)
            {
                var MainEntityList = db.T_Facilitys.OrderBy(p => p.DisplayValue).ToList();
                MainEntityList.Insert(0, new T_Facility {
                    Id = -1, DisplayValue = "All", m_DisplayValue = "All"
                });
                ViewBag.SelectedMainEntityValue = MainEntityList;
                ViewBag.SelectedMainEntity      = new SelectList(MainEntityList, "ID", "DisplayValue");
            }
            if (roles.Count() > 1 && Request.Cookies[AppUrl + "CurrentRole"] == null)
            {
                ViewBag.PageRoles = roles.ToList();
                return(View());
            }
            else
            {
                if (roles.Count() > 0)
                {
                    var user         = new UserDefinePagesRoleContext();
                    var userpagelist = user.UserDefinePagesRoles;
                    var role         = roles.ToArray()[0];
                    var userpage     = userpagelist.FirstOrDefault(u => u.RoleName == role);
                    if (userpage != null)
                    {
                        isItemZero          = false;
                        ViewBag.PageContent = (new UserDefinePagesContext()).UserDefinePagess.FirstOrDefault(p => p.Id == userpage.PageId).PageContent.Replace("Root_App_Path", GetBaseUrl());
                    }
                }
                else
                {
                    ViewBag.PageContent = "<br/><a href=\"javascript:document.getElementById('logoutForm').submit()\" class=\"btn btn-primary btn-sm\">You are not assigned to an application role, please contact application administrator.</a>";
                }
            }

            var lstFavoriteItem = db.FavoriteItems.Where(p => p.LastUpdatedByUser == User.Name);

            if (lstFavoriteItem.Count() > 0)
            {
                ViewBag.FavoriteItem  = lstFavoriteItem;
                ViewBag.FavoriteCount = lstFavoriteItem.Count();
            }
            if (isItemZero || (ViewBag.PageRoles == null && ViewBag.PageContent == null))
            {
                ViewBag.T_LicensesCount        = db.T_Licensess.Count();
                ViewBag.T_PositionCount        = db.T_Positions.Count();
                ViewBag.T_EmployeeCount        = db.T_Employees.Count();
                ViewBag.T_DrugAlcoholTestCount = db.T_DrugAlcoholTests.Count();
                ViewBag.T_JobAssignmentCount   = db.T_JobAssignments.Count();
                ViewBag.T_EmployeeInjuryCount  = db.T_EmployeeInjurys.Count();
                ViewBag.T_BackgroundCheckCount = db.T_BackgroundChecks.Count();
                CompanyProfileRepository _cp = new CompanyProfileRepository();
                CompanyProfile           cp  = _cp.GetCompanyProfile(User);
                if (cp != null)
                {
                    ViewBag.AboutCompany = cp.AboutCompany;
                }
            }

            ApplicationDbContext userdb = new ApplicationDbContext();
            var userinfo = userdb.Users.FirstOrDefault(p => p.UserName == User.Name);

            ViewBag.UserName  = userinfo != null ? userinfo.FirstName + " " + userinfo.LastName : "";
            ViewBag.Useremail = userinfo != null ? userinfo.Email : "";
            if (userinfo != null)
            {
                var lastlogin = userdb.LoginAttempts.Where(p => p.UserId == userinfo.Id).OrderByDescending(p => p.Id).ToList();
                ViewBag.LastLoggedIn = lastlogin.Count() > 1 ? lastlogin[1].Date.ToString() : "";
                if (!User.IsAdmin)
                {
                    //enforce password policy on first login
                    var  appSettings    = db.AppSettings;
                    bool securitypolicy = appSettings.Where(p => p.Key == "ApplySecurityPolicy").FirstOrDefault().Value.ToLower() == "yes" ? true : false;
                    if (securitypolicy)
                    {
                        bool enforcePwdPolicy = appSettings.Where(p => p.Key == "EnforceChangePassword").FirstOrDefault().Value.ToLower() == "yes" ? true : false;
                        if (enforcePwdPolicy)
                        {
                            var pwdhistorycount = userdb.PasswordHistorys.Where(p => p.UserId == userinfo.Id).Count();
                            if (pwdhistorycount == 0)
                            {
                                return(RedirectToAction("Manage", "Account"));
                            }
                        }
                    }
                }
            }
            ViewBag.LoginRoles = roles;
            return(View());
        }