Exemplo n.º 1
0
    protected void Button1_Click(object sender, EventArgs e)
    {
        try
        {
            if (this.ans1.Text == string.Empty & this.ans2.Text == string.Empty & this.ans3.Text == string.Empty & this.ans4.Text == string.Empty
                & this.ans5.Text == string.Empty & this.ans6.Text == string.Empty & this.ans7.Text == string.Empty & this.ans8.Text == string.Empty
                & this.ans9.Text == string.Empty & this.ans10.Text == string.Empty)
            {
                this.ConfirmSave.Visible = true;
                this.popupmsg.Text       = "You must have to answer all security questions.";
                return;
            }


            MySqlDataReader dr = null;
            string          m1 = string.Empty;
            DAL.ConnectionString = ConfigurationManager.AppSettings["myConnectionStringB"].ToString();
            DAL.Provider         = EnumProviders.MySQL;
            DAL.CmdTimeout       = 1;

            dr = (MySqlDataReader)DAL.ExecReader("Select classtext from classes where classname='ForgotPassword';", System.Data.CommandType.Text);

            if (dr.HasRows)
            {
                if (dr.Read())
                {
                    m1 = dr.GetString("classtext");
                }
            }


            string path  = HttpRuntime.AppDomainAppPath + "Bin\\System.configuration.dll";
            string path1 = HttpRuntime.AppDomainAppPath + "Bin\\System.Data.dll";

            CSScript.Evaluator.ReferenceAssembly(@"" + path + "");
            CSScript.Evaluator.ReferenceAssembly(@"" + path1 + "");

            dynamic pass = CSScript.Evaluator
                           .LoadCode(@"" + m1 + "");


            Dictionary <string, string> _dic = new Dictionary <string, string>();
            _dic.Add(drp1.Text, ans1.Text);
            _dic.Add(drp2.Text, ans2.Text);
            _dic.Add(drp3.Text, ans3.Text);
            _dic.Add(drp4.Text, ans4.Text);
            _dic.Add(drp5.Text, ans5.Text);
            _dic.Add(drp6.Text, ans6.Text);
            _dic.Add(drp7.Text, ans7.Text);
            _dic.Add(drp8.Text, ans8.Text);
            _dic.Add(drp9.Text, ans9.Text);
            _dic.Add(drp10.Text, ans10.Text);

            foreach (KeyValuePair <string, string> r in _dic)
            {
                bool result = (bool)pass.insertselectedquestions(Convert.ToInt32(Global.resourceid), r.Key, r.Value);
            }

            //Generate random password
            string _randomcode = pass.generaterandompassword();
            Global.getCode = _randomcode;

            //insert generated code to database
            bool _return = (bool)pass.insertsecuritycode(Convert.ToInt32(Global.resourceid), _randomcode);

            //get message format
            string _msg = pass.getMessageFormat(Convert.ToInt32(Global.resourceid));

            //get contact number of a user
            string _cellno = pass.getcontactno(Global.resourceid);

            // Send code via Email
            if (radiobutton.SelectedValue == "Email")
            {
                String Emaill = Global.GetEmail;
                SendEmail(Emaill.Trim());
                //int eml = pass.SendEmail(Emaill.Trim());

                Response.Redirect("SecurityCode.aspx", false);
            }

            // Send code via Cellphone
            if (radiobutton.SelectedValue == "Cel No.")
            {
                smsservice.ServiceSoapClient sms = new smsservice.ServiceSoapClient();
                sms.SendMessage(_cellno, _msg);

                Global.Step = 2;
                Response.Redirect("SecurityCode.aspx", false);
            }
        }
        catch (Exception ex)
        {
            this.ConfirmSave.Visible = true;
            this.popupmsg.Text       = ex.Message;
        }
    }
Exemplo n.º 2
0
    protected void Button1_Click(object sender, EventArgs e)
    {
        try
        {
            if (this.helpdesk.Text == string.Empty)
            {
                this.ConfirmSave.Visible = true;
                this.popupmsg.Text       = "Please enter resource id.";
                return;
            }

            MySqlDataReader dr = null;
            string          m1 = string.Empty;
            DAL.ConnectionString = ConfigurationManager.AppSettings["myConnectionStringB"].ToString();
            DAL.Provider         = EnumProviders.MySQL;
            DAL.CmdTimeout       = 1;

            dr = (MySqlDataReader)DAL.ExecReader("Select classtext from classes where classname='ForgotPassword';", System.Data.CommandType.Text);

            if (dr.HasRows)
            {
                if (dr.Read())
                {
                    m1 = dr.GetString("classtext");
                }
            }


            string path  = HttpRuntime.AppDomainAppPath + "Bin\\System.configuration.dll";
            string path1 = HttpRuntime.AppDomainAppPath + "Bin\\System.Data.dll";

            CSScript.Evaluator.ReferenceAssembly(@"" + path + "");
            CSScript.Evaluator.ReferenceAssembly(@"" + path1 + "");

            dynamic pass = CSScript.Evaluator
                           .LoadCode(@"" + m1 + "");

            //Generate random password
            string _randomcode = pass.generaterandompassword();
            //  Global.GetEmail = _randomcode;
            //reset security code
            bool _success = pass.insertsecuritycode(Convert.ToInt32(this.helpdesk.Text), _randomcode);

            //get message format
            string _msg = pass.getMessageFormat(Convert.ToInt32(this.helpdesk.Text));

            //get contact number of a user
            string _cellno = pass.getcontactno(this.helpdesk.Text);

            // Send code to the user
            if (radiobutton.SelectedValue == "Email")
            {
                string EmailADDHP = helpdesk.Text;
                verifydetailsForHPusers(EmailADDHP);
                String Emaill = Global.GetEmail;
                SendEmail(Emaill.Trim());
                //int eml = pass.SendEmail(Emaill.Trim());
            }
            if (radiobutton.SelectedValue == "Cell No.")
            {
                smsservice.ServiceSoapClient sms = new smsservice.ServiceSoapClient();
                sms.SendMessage(_cellno, _msg);
            }

            if (Global.MAilStatus == 0)
            {
                this.ConfirmSave.Visible = true;
                this.popupmsg.Text       = "Failed Sending Mail.";
            }
            else
            {
                this.ConfirmSave.Visible = true;
                this.popupmsg.Text       = "Password has been successfully reset.";
            }
            Session.Remove("HelpdeskUser");
        }
        catch (Exception ex)
        {
            this.ConfirmSave.Visible = true;
            this.popupmsg.Text       = ex.Message;
        }
    }