示例#1
0
        /// <summary>
        /// Writing exception to log file  along with user id including form name in which the exception occured
        /// </summary>
        /// <param name="ex">exception</param>
        /// <param name="LogFilePath">File path</param>
        /// <param name="UserID">User ID</param>
        /// <param name="FormName">Form Name</param>
        /// <param name="ProjectName">Project Name</param>
        /// <param name="MethodName">Method Name</param>
        public static void WriteToLog(Exception ex, string LogFilePath, string UserID, string FormName, string ProjectName, string MethodName)
        {
            StreamWriter _sw = new StreamWriter(LogFilePath, true);

            try
            {
                EXCEPTION_UTILITY.FileExceedSize(LogFilePath);
                if (IfThreadAbort(ex))
                {
                    Random rand = new Random();
                    string ID   = Convert.ToString(rand.Next()) + "-" + string.Format("{0:ddMMyyyyHHmmss}", System.DateTime.Now);
                    _sw.WriteLine("Id: {0}", ID);
                    _sw.WriteLine("UserID: {0}", UserID);
                    _sw.WriteLine("Form Name: {0}", FormName);
                    _sw.WriteLine("project Name: {0}", ProjectName);
                    _sw.WriteLine("Method: {0}", MethodName);
                    _sw.WriteLine("Type: {0}", ex.GetType());
                    _sw.WriteLine("Source: {0}", ex.Source);
                    _sw.WriteLine("Message: {0}", ex.Message);
                    _sw.WriteLine("Stacktrace: {0}", ex.StackTrace);
                    _sw.WriteLine("Source: {0}", ex.Source);
                    _sw.WriteLine("------------------------------------------------------------------------------------");
                    _sw.WriteLine();
                }
            }
            finally
            {
                _sw.Close();
            }
        }
示例#2
0
 protected void btnChangePassword_Click(object sender, EventArgs e)
 {
     _daUser = new DA_User();
     _user   = new User();
     try
     {
         _user.UserCode = _member.UserCode;
         _user.Password = txtNewPassword.Text;
         if (txtNewPassword.Text != txtConfirmPassword.Text)
         {
             ClientScript.RegisterStartupScript(GetType(), "Change Password", "alert('Passwords are not Matching');", true);
             return;
         }
         if (_daUser.ChangeUserPassword(_user))
         {
             txtConfirmPassword.Text   = string.Empty;
             txtNewPassword.Text       = string.Empty;
             btnChangePassword.Enabled = false;
             ClientScript.RegisterStartupScript(GetType(), "Change Password", "alert('Password has been changed successfully');", true);
         }
         else
         {
             ClientScript.RegisterStartupScript(GetType(), "Change Password", "alert('Password change failed');", true);
         }
     }
     catch (Exception ex)
     {
         ClientScript.RegisterStartupScript(GetType(), "Rerequirement", "alert(" + Message.ErrorMessage + ");", true);
         EXCEPTION_UTILITY.WriteToLog(ex, GetLogFilePath(), _member.LoginId, "Requirement", "ETS", "LoadRequirements");
     }
 }
示例#3
0
        private void NotificationsLabel()
        {
            _daNotification = new DA_Notification();
            try
            {
                _lstNotification = _daNotification.getNotificationData(1);


                //for getting notifications
                var           notifications         = from m in _lstNotification where m.Type == 1 select m;
                StringBuilder _sbNotificationMarque = new StringBuilder();

                foreach (var eachnotification in notifications)
                {
                    _sbNotificationMarque.Append("<span style=\"color:red\">");
                    _sbNotificationMarque.Append("<b> NOTIFICATIONS :: </b> " + eachnotification.Description + " ");
                    _sbNotificationMarque.Append("</span>");
                }
                dvmarque.InnerHtml = _sbNotificationMarque.ToString();

                //for getting alerts
                var alerts = from m in _lstNotification where m.Type == 2 select m;

                foreach (var eachalert in alerts)
                {
                    _sbNotificationMarque.Append("<span style=\"color:green\">");
                    _sbNotificationMarque.Append("<b> ALERTS :: </b>" + eachalert.Description + " ");
                    _sbNotificationMarque.Append("</span>");
                }
                dvmarque.InnerHtml = _sbNotificationMarque.ToString();

                //for getting wishes
                var wishes = from m in _lstNotification where m.Type == 3 select m;

                foreach (var eachwish in wishes)
                {
                    _sbNotificationMarque.Append("<span style=\"color:blue\">");
                    _sbNotificationMarque.Append("<b> WISHES :: </b>" + eachwish.Description + " ");
                    _sbNotificationMarque.Append("</span>");
                }
                dvmarque.InnerHtml = _sbNotificationMarque.ToString();
            }
            catch (Exception Ex)
            {
                //ClientScript.RegisterStartupScript(GetType(), "DSR", "alert(" + Message.ErrorMessage + ");", true);
                EXCEPTION_UTILITY.WriteToLog(Ex, Server.MapPath(Convert.ToString(ConfigurationManager.AppSettings["logpath"])), "user", "Site.Master.cs", "ETS", "NotificatinoLable");
            }
        }
示例#4
0
        protected void ValidateUser()
        {
            try
            {
                beMember          = new User();
                beMember.LoginId  = ((TextBox)frmLogin.FindControl("UserName")).Text;
                beMember.Password = ((TextBox)frmLogin.FindControl("Password")).Text;
                DA_User daUser = new DA_User();
                if (((CheckBox)frmLogin.FindControl("RememberMe")).Checked)
                {
                    Response.Cookies["UserName"].Expires = DateTime.Now.AddDays(30);
                    Response.Cookies["Password"].Expires = DateTime.Now.AddDays(30);
                }
                else
                {
                    Response.Cookies["UserName"].Expires = DateTime.Now.AddDays(-1);
                    Response.Cookies["Password"].Expires = DateTime.Now.AddDays(-1);
                }
                Response.Cookies["UserName"].Value = ((TextBox)frmLogin.FindControl("UserName")).Text.Trim();
                Response.Cookies["Password"].Value = ((TextBox)frmLogin.FindControl("Password")).Text.Trim();

                beMember = daUser.CheckUserLogin(beMember);
                if (beMember != null)
                {
                    Session["user"] = beMember;
                    if (IsUserExistInShiftXML(beMember.UserCode.ToString()))
                    {
                        Response.Redirect("~/Account/DashBoard.aspx");
                    }
                    {
                        Response.Redirect("~/Shift.aspx");
                    }
                }
                else
                {
                    ClientScript.RegisterStartupScript(GetType(), "Invalid", "alert('Invalid credentials');", true);
                }
            }
            catch (Exception ex)
            {
                ClientScript.RegisterStartupScript(GetType(), "New Rerequirement", "alert('Error Occured. Contact IT Department');", true);
                EXCEPTION_UTILITY.WriteToLog(ex, GetLogFilePath(), beMember.LoginId, "Login", "ETS", "ValidateUser");
            }
        }
示例#5
0
        protected void lnkreset_Click(object sender, EventArgs e)
        {
            beMember = (User)Session["user"];
            string strResetPassword = GeneratePassword();

            try
            {
                //send mail
                string strFromMailid        = Convert.ToString(ConfigurationManager.AppSettings["infomailid"]);
                string strFromMailPassword  = Convert.ToString(ConfigurationManager.AppSettings["infomailpassword"]);
                string strDestinationMailID = txtPasswordMail.Text + "@goggery.com";
                string strSubject           = "ETS - Reset Password";
                string strDetails           = "Hi,  " + strResetPassword;

                CommonUtility.COMMON_UTILITY c = new CommonUtility.COMMON_UTILITY();
                c.SendMail(strFromMailid, strFromMailPassword, strDestinationMailID, strSubject, strDetails, 'T');

                ClientScript.RegisterStartupScript(this.GetType(), "Password Reset", "alert('Password has been reset and sent to given mail id');", true);
            }
            catch (Exception ex)
            {
                ClientScript.RegisterStartupScript(GetType(), "New Rerequirement", "alert('Error Occured. Contact IT Department');", true);
                EXCEPTION_UTILITY.WriteToLog(ex, GetLogFilePath(), beMember.LoginId, "Login", "ETS", "lnkreset_Click");
            }

            User u = new Model.User();

            u.Password       = strResetPassword;
            u.OfficialMailID = txtPasswordMail.Text + "@goggery.com";
            DA_User da = new DA_User();
            bool    i  = da.ResetPassword(u);

            if (i)
            {
                ClientScript.RegisterStartupScript(this.GetType(), "Password Reset", "alert('Password has been reset and sent to given mail id');", true);
                dforgetpassword.Visible = false;
            }
            else
            {
                ClientScript.RegisterStartupScript(this.GetType(), "Password Reset", "alert('Password not Resent');", true);
            }
        }