示例#1
0
        void Application_Error(object sender, EventArgs e)
        {
            string ip = CommonStuff.GetLocalIPAddress(); // Request.ServerVariables["HTTP_X_FORWARDED_FOR"];

            Exception objErr = Server.GetLastError().GetBaseException();

            string objErrMgs = objErr.StackTrace;

            string err = "Error Date : " + DateTime.Now.ToString() + " , Error in: " + Request.Url.ToString() + " , Error Message:" + objErr.Message.ToString() + " ipaddress : " + ip;


            string path = HttpContext.Current.Server.MapPath("~/Logs/ErrorLog_GlobalErrors.txt");

            using (System.IO.StreamWriter sw = new System.IO.StreamWriter(path, true))
            {
                sw.WriteLine(err + objErrMgs);
                sw.WriteLine(objErr.StackTrace);
                sw.Close();
            }

            CommonStuff.SendEmail("*****@*****.**", "Error in DotNetIsEasy.com", objErr.Message.ToString() + "<br />IP: " + ip + "<br /><br />" + objErr.StackTrace);
            Server.ClearError();

            Response.Write(objErr.Message.ToString());
        }
示例#2
0
 private void SaveWallpaper(object sender, EventArgs e)
 {
     LoaderGrid.Visibility = Visibility.Visible;
     ((ApplicationBarIconButton)ApplicationBar.Buttons[0]).IsEnabled = false;
     Scheduler.Dispatcher.Schedule(() => { CommonStuff.SaveToMediaLibrary(new WriteableBitmap(wallpaper), DateTime.Now.ToString() + ".jpg"); }, TimeSpan.FromSeconds(.1));
     MessageBox.Show("Saved");
     LoaderGrid.Visibility = Visibility.Collapsed;
     ((ApplicationBarIconButton)ApplicationBar.Buttons[0]).IsEnabled = true;
 }
        public ActionResult ResendEmail(LoginViewModel model)
        {
            UserMaster user = UserMaster.GetUserByEmail(model.Email, con);

            if (user == null)
            {
                ModelState.AddModelError("", "Invalid login attempt.");
                return(View(model));
            }

            CommonStuff.SendEmail(model.Email, "Welcome to DotNetIsEasy.com", CommonStuff.getEmailVerificationBody(user.email, user.emailvalidationToken));
            return(RedirectToAction("Login", "Account"));
            //return View();
        }
        public ActionResult CreateUser(CreateUserViewModel model, string returnUrl)
        {
            if (!ModelState.IsValid)
            {
                return(View(model));
            }
            if (model.Password != model.ConfirmPassword)
            {
                ModelState.AddModelError("", "password and Confirm password doesnot match");
                return(View(model));
            }

            UserMaster user = UserMaster.GetUserByEmail(model.EmailAddress, con);

            if (user != null)
            {
                ModelState.AddModelError("", "Email already Registered");
                return(View(model));
            }

            string strp = UserMaster.EncryptString(model.Password);

            UserMaster new_user = new UserMaster();

            new_user.cid             = Convert.ToInt32(Session["cid"]);
            new_user.email           = model.EmailAddress;
            new_user.display_name    = model.DisplayName;
            new_user.hashed_password = strp;
            new_user.mobile_number   = model.Mobile;
            new_user.created_by_uid  = Convert.ToInt32(Session["uid"]);

            int i = UserMaster.CreateUser(new_user, con);

            if (i > 0)
            {
                user = UserMaster.GetUserByEmail(model.EmailAddress, con);
                CommonStuff.SendEmail(user.email, "Welcome to DotNetIsEasy.com", CommonStuff.getEmailVerificationBody(user.email, user.emailvalidationToken));

                //user = UserMaster.Login(model.EmailAddress, model.Password, con);

                //Session["uid"] = user.uid;
                //Session["DisplayName"] = user.display_name;
                //Session["cid"] = user.cid;
                return(RedirectToAction("Success", "Account"));
            }
            else
            {
                return(View(model));
            }
        }
        public ActionResult ForgotPassword(LoginViewModel model)
        {
            UserMaster user = UserMaster.GetUserByEmail(model.Email, con);

            if (user == null)
            {
                ModelState.AddModelError("", "Email is not registered with us.");
                return(View(model));
            }

            string rnd = CommonStuff.GetRandomString(30);

            UserMaster.GeneratePasswordToken(model.Email, rnd, con);
            CommonStuff.SendEmail(model.Email, "Reset your password", CommonStuff.getEmailPasswordReset(user.email, rnd));
            return(RedirectToAction("Success", "Account", new { msg = "A password reset link has been send on your email id.  Please check your spam folder if not deliver in inbox" }));
            //return View();
        }
        public ActionResult Login(LoginViewModel model, string returnUrl)
        {
            if (!ModelState.IsValid)
            {
                return(View(model));
            }
            Logger.log.Info("Login: emailId=" + model.Email + ",IP=" + CommonStuff.GetLocalIPAddress());
            // This doesn't count login failures towards account lockout
            // To enable password failures to trigger account lockout, change to shouldLockout: true
            //var result = await SignInManager.PasswordSignInAsync(model.Email, model.Password, model.RememberMe, shouldLockout: false);

            UserMaster user = UserMaster.Login(model.Email, model.Password, con);

            string strp = UserMaster.EncryptString(model.Password);

            //UserLoginInfo user1 = new UserMaster();

            if (user == null)
            {
                ModelState.AddModelError("", "Invalid login attempt.");
                ViewBag.ReturnUrl = returnUrl;
                return(View(model));
            }

            if (user.emailvalidation == 0)
            {
                ModelState.AddModelError("ValidateEmail", "Please Validate your Email First");
                ViewBag.ReturnUrl = returnUrl;
                return(View(model));
            }

            switch (user.user_status)
            {
            case UserStatus.Disabled:
                return(RedirectToLocal(returnUrl + "&Disabled"));

            case UserStatus.Suspended:
                return(RedirectToLocal(returnUrl + "&Suspended"));

            case UserStatus.LoggedIn:
                return(RedirectToLocal(returnUrl + "&LoggedIn"));

            //return RedirectToAction("SendCode", new { ReturnUrl = returnUrl, RememberMe = model.RememberMe });
            case UserStatus.Active:
            {
                if (strp == user.hashed_password)
                {
                    Session["uid"]         = user.uid;
                    Session["DisplayName"] = user.display_name;
                    Session["cid"]         = user.cid;
                    if (string.IsNullOrEmpty(returnUrl))
                    {
                        return(RedirectToAction("PostArtical", "Artical"));
                    }
                    else
                    {
                        return(Redirect(returnUrl));
                    }
                }
                else
                {
                    ModelState.AddModelError("", "Invalid login attempt.");
                    return(View(model));
                }
            }

            default:
                ModelState.AddModelError("", "Invalid login attempt.");
                return(View(model));
            }

            return(View(model));
        }