コード例 #1
0
    protected void btnSend_Click(object sender, EventArgs e)
    {
        object currentuser = Session["currentuser"];
        object usertime    = Session["user"];
        object usertype    = Session["usertype"];

        if ((string)currentuser == null || ((string)currentuser).Equals("Unknown") || usertime == null || usertype == null)
        {
            Session.Add("user", DateTime.UtcNow.AddDays(-1).ToString("yyyy-MM-dd HH:mm:00"));
            Response.Redirect("~/login.aspx");
            return;
        }

        DateTime now = DateTime.UtcNow.AddDays(-1);

        if (!DateTime.TryParseExact((string)usertime, "yyyy-MM-dd HH:mm:00", null, System.Globalization.DateTimeStyles.AssumeUniversal, out now))
        {
            Session["user"] = DateTime.UtcNow.AddDays(-1).ToString("yyyy-MM-dd HH:mm:00");
            Response.Redirect("~/login.aspx");
            return;
        }

        tbPhone.BackColor = Color.White;
        tbText.BackColor  = Color.White;
        if (!UtilsRegex.CheckPhone(tbPhone.Text.Trim()))
        {
            tbResult.Text     = "Only numbers accepted!";
            tbPhone.BackColor = Color.Red;
            return;
        }

        if (tbText.Text.Trim().Equals(string.Empty))
        {
            tbResult.Text    = "Text is missing";
            tbText.BackColor = Color.Red;
            return;
        }

        //object currentuser = (object)Session["currentuser"];

        string result = UtilsWeb.SendUtilsSMS(tbText.Text, tbPhone.Text.Trim(), (string)currentuser, this.Request.UrlReferrer.AbsoluteUri);

        UtilsWeb.MakeWebRequest(
            new LoginPostBack()
        {
            User = (string)currentuser, MSG = "SendSMS: " + result, Role = ((enumUserType)usertype).ToString(), CMSApp = this.Request.UrlReferrer.AbsoluteUri
        }
            );



        tbResult.Text = "Send to: " + tbPhone.Text + Environment.NewLine + "Result: " + result;
        tbPhone.Text  = string.Empty;
    }
コード例 #2
0
    protected void btlogout_Click(object sender, System.EventArgs e)
    {
        object currentuser = (object)Session["currentuser"];
        object usertype    = (object)Session["usertype"];


        UtilsWeb.MakeWebRequest(
            new LoginPostBack()
        {
            User   = currentuser == null? "NULL ? ": (string)currentuser, MSG = "LOGOUT", Role = usertype == null? enumUserType.Unknown.ToString(): ((enumUserType)usertype).ToString(),
            CMSApp = this.Request.UrlReferrer.AbsoluteUri
        }
            );

        Session["varification"] = null;
        Session["user"]         = DateTime.UtcNow.AddDays(-1).ToString("yyyy-MM-dd HH:mm:00");
        Response.Redirect("~/login.aspx");
    }
コード例 #3
0
    protected void btlogin_Click(object sender, EventArgs e)
    {
        if (Session["varification"] == null)
        {
            setVarification();
            return;
        }
        if ((string)Session["varification"] != tbverification.Text.ToLower())
        {
            setVarification();
            return;
        }

        DateTime ISR = UtilsDateTime.UTC_To_Israel_Time().Date;

        #region HANDLE USER
        object       currentuser = Session["user"];
        enumUserType usertype    = enumUserType.Unknown;

        bool userExist = UtilsConfig.CheckUserPass(tbuser.Text, tbpass.Text.Replace(ISR.ToString("yyyy-MM-dd"), ""), out usertype);

        if (userExist && tbpass.Text.Contains(ISR.ToString("yyyy-MM-dd")))
        {
            if (currentuser == null)
            {
                Session.Add("currentuser", tbuser.Text);
                Session.Add("usertype", usertype);
                Session.Add("user", DateTime.UtcNow.ToString("yyyy-MM-dd HH:mm:00"));
            }
            else
            {
                //Session.Add("currentuser", tbuser.Text);
                Session["currentuser"] = tbuser.Text;
                Session["usertype"]    = usertype;
                Session["user"]        = DateTime.UtcNow.ToString("yyyy-MM-dd HH:mm:00");
            }

            UtilsWeb.MakeWebRequest(
                new LoginPostBack()
            {
                User = tbuser.Text, MSG = "OK LOGIN", Role = usertype.ToString(), CMSApp = this.Request.UrlReferrer.AbsoluteUri
            }
                );

            Response.Redirect("~/default.aspx");
            return;
        }

        UtilsWeb.MakeWebRequest(
            new LoginPostBack()
        {
            User = tbuser.Text + "/" + tbpass.Text, MSG = "FAIL LOGIN", Role = usertype.ToString(), CMSApp = this.Request.UrlReferrer.AbsoluteUri
        }
            );

        if (currentuser == null)
        {
            Session.Add("user", DateTime.UtcNow.AddDays(-1).ToString("yyyy-MM-dd HH:mm:00"));
        }
        else
        {
            Session["user"] = DateTime.UtcNow.AddDays(-1).ToString("yyyy-MM-dd HH:mm:00");
        }

        #endregion
    }