Ejemplo n.º 1
0
    protected void Page_Load(object sender, EventArgs e)
    {
        try
        {
            var valto = Request["forgotEmail"];
            //update this pwd in database and reidrect the user to login page and ask him to login with new password.
            MyDB db      = new MyDB();
            var  regcoll = db.GetBColl("registration");
            var  email   = Session["resetEmail"].ToString();

            IMongoQuery  q          = new QueryDocument("email", email);
            myEncryption enc        = new myEncryption();
            var          mdfhashpwd = enc.getMD5Hash(valto.ToString());
            IMongoUpdate u          = Update.Set("password", mdfhashpwd);

            regcoll.Update(q, u);
        }
        catch
        {
        }
    }
Ejemplo n.º 2
0
    protected void Page_Load(object sender, EventArgs e)
    {
        try
        {
            var valto = Request["forgotEmail"];
            //update this pwd in database and reidrect the user to login page and ask him to login with new password.
            MyDB db = new MyDB();
            var regcoll = db.GetBColl("registration");
            var email=Session["resetEmail"].ToString();

            IMongoQuery q = new QueryDocument("email",email);
            myEncryption enc=new myEncryption();
            var mdfhashpwd = enc.getMD5Hash(valto.ToString());
            IMongoUpdate u=Update.Set("password",mdfhashpwd);

            regcoll.Update(q,u);
        }
        catch
        {

        }
    }
Ejemplo n.º 3
0
    protected void Page_Load(object sender, EventArgs e)
    {
        try
        {
            var          loginjson    = Request["reqdata"];
            BsonDocument t            = MongoDB.Bson.Serialization.BsonSerializer.Deserialize <BsonDocument>(loginjson);
            BsonValue    mymob        = t.GetElement("mobileno").Value;
            BsonValue    mypwd        = t.GetElement("password").Value;
            var          ordersession = Session["order"];

            myEncryption me         = new myEncryption();
            string       ss         = me.getMD5Hash(mypwd.ToString());
            MyDB         md         = new MyDB();
            var          col        = md.GetBColl("registration");
            var          temporders = md.GetBColl("temporders");
            //IMongoQuery forboth = Query.Or(Query.EQ("mobile", Convert.ToInt64(mymob)), Query.EQ("email", mymob.ToString()));
            BsonElement   bobjid   = null;
            BsonElement   bdedcol  = null;
            BsonElement   bname    = null;
            BsonElement   bmobile  = null;
            BsonElement   bpwd     = null;
            BsonElement   bstatus  = null;
            BsonElement   btype    = null;
            QueryDocument foremail = new QueryDocument("email", mymob.ToString());
            foreach (BsonDocument items in col.Find(foremail))
            {
                bobjid                = items.GetElement("_id");
                bdedcol               = items.GetElement("colname");
                bname                 = items.GetElement("name");
                bmobile               = items.GetElement("mobile");
                bpwd                  = items.GetElement("password");
                bstatus               = items.GetElement("status");
                btype                 = items.GetElement("type");
                Session["username"]   = bname.Value.ToString();
                Session["dedcolname"] = bdedcol.Value.ToString();
                goto hihi;
            }
            QueryDocument fordet = new QueryDocument("mobile", Convert.ToInt64(mymob));
            foreach (BsonDocument items in col.Find(fordet))
            {
                bobjid                = items.GetElement("_id");
                bdedcol               = items.GetElement("colname");
                bname                 = items.GetElement("name");
                bmobile               = items.GetElement("mobile");
                bpwd                  = items.GetElement("password");
                bstatus               = items.GetElement("status");
                btype                 = items.GetElement("type");
                Session["username"]   = bname.Value.ToString();
                Session["dedcolname"] = bdedcol.Value.ToString();
            }
hihi:
            Session["objid"]      = bobjid.Value.ToString();
            Session["typeofuser"] = btype.Value.ToString();

            if (bmobile != null)
            {
                if (ss == bpwd.Value)
                {
                    Session["mertouser"] = "******";
                    if (Session["typeofuser"] != null && Session["typeofuser"].ToString() == "merchant")
                    {
                        var         merchantreg = md.GetBColl("registration");
                        var         queryfor    = new QueryDocument("_id", ObjectId.Parse(bobjid.Value.ToString()));
                        BsonElement bstore      = null;
                        Session["dummycol"] = Session["dedcolname"] + "dummy";
                        foreach (var docss in merchantreg.Find(queryfor))
                        {
                            bstore = docss.GetElement("storename");
                            Session["storename"] = bstore.Value;
                        }
                        Response.Clear();
                        Response.CacheControl = "no-cache";
                        Response.ContentType  = "application/json";
                        Response.Write("105");   //Invalid Credentials
                        Response.End();
                    }

                    string       sessionforid   = Session["objid"].ToString();
                    var          queryregstatus = new QueryDocument("user", sessionforid);
                    BsonDocument bregstat       = new BsonDocument();
                    BsonElement  bs             = null;
                    foreach (BsonDocument bregs in temporders.Find(queryregstatus))
                    {
                        bs = bregs.GetElement("regtoship");
                    }
                    BsonDocument loginres = new BsonDocument();
                    //loginres.Add("type",btype.Value.ToString());
                    //loginres.Add("orderstatus", orderstatus);
                    loginres.Add("type", btype.Value);
                    //var ordervalue = Session["order"];
                    if (Session["order"] != null)
                    {
                        string ordervalue = Session["order"].ToString();
                        loginres.Add("orderstatus", ordervalue);
                    }
                    if (bs != null)
                    {
                        loginres.Add("registeredtoship", bs.Value);
                    }
                    if (bstatus.Value == 1)
                    {
                        Response.Clear();
                        Response.CacheControl = "no-cache";
                        Response.ContentType  = "application/json";
                        //Session["loggedin"] = "loggedin";
                        if (Session["pleaselogin"] != null)
                        {
                            Response.Write("100");  //new login
                        }
                        else
                        {
                            Response.Write(loginres.ToString());  //Valid User
                        }
                        Response.End();
                        //HttpContext.Current.ApplicationInstance.CompleteRequest();
                    }
                    else
                    {
                        Response.Clear();
                        Response.CacheControl = "no-cache";
                        Response.ContentType  = "application/json";
                        Response.Write("2");   //Didnt activate your link
                        Response.End();
                        //HttpContext.Current.ApplicationInstance.CompleteRequest();
                    }
                }
                else
                {
                    Response.Clear();
                    Response.CacheControl = "no-cache";
                    Response.ContentType  = "application/json";
                    Response.Write("0");   // no mobile INVALID PASSWORD LATEST
                    Response.End();
                }
            }
            else
            {
                Response.Clear();
                Response.CacheControl = "no-cache";
                Response.ContentType  = "application/json";
                Response.Write("7");   // no mobile INVALID PASSWORD LATEST
                Response.End();
                //HttpContext.Current.ApplicationInstance.CompleteRequest();
            }
        }
        catch (ThreadAbortException)
        {}
        catch (Exception e4)
        {
            Response.Clear();
            Response.CacheControl = "no-cache";
            Response.ContentType  = "application/json";
            Response.Write("exception");
            Response.End();
        }
    }
Ejemplo n.º 4
0
    protected void Page_Load(object sender, EventArgs e)
    {
        try
        {
            var loginjson = Request["reqdata"];
            BsonDocument t = MongoDB.Bson.Serialization.BsonSerializer.Deserialize<BsonDocument>(loginjson);
            BsonValue mymob = t.GetElement("mobileno").Value;
            BsonValue mypwd = t.GetElement("password").Value;
            var ordersession = Session["order"];

            myEncryption me = new myEncryption();
            string ss = me.getMD5Hash(mypwd.ToString());
            MyDB md = new MyDB();
            var col = md.GetBColl("registration");
            var temporders = md.GetBColl("temporders");
            //IMongoQuery forboth = Query.Or(Query.EQ("mobile", Convert.ToInt64(mymob)), Query.EQ("email", mymob.ToString()));
            BsonElement bobjid = null;
            BsonElement bdedcol = null;
            BsonElement bname = null;
            BsonElement bmobile = null;
            BsonElement bpwd = null;
            BsonElement bstatus = null;
            BsonElement btype = null;
            QueryDocument foremail = new QueryDocument("email", mymob.ToString());
            foreach (BsonDocument items in col.Find(foremail))
            {
                bobjid = items.GetElement("_id");
                bdedcol = items.GetElement("colname");
                bname = items.GetElement("name");
                bmobile = items.GetElement("mobile");
                bpwd = items.GetElement("password");
                bstatus = items.GetElement("status");
                btype = items.GetElement("type");
                Session["username"] = bname.Value.ToString();
                Session["dedcolname"] = bdedcol.Value.ToString();
                goto hihi;
            }
            QueryDocument fordet = new QueryDocument("mobile", Convert.ToInt64(mymob));
            foreach (BsonDocument items in col.Find(fordet))
            {
                bobjid = items.GetElement("_id");
                bdedcol = items.GetElement("colname");
                bname = items.GetElement("name");
                bmobile = items.GetElement("mobile");
                bpwd = items.GetElement("password");
                bstatus = items.GetElement("status");
                btype = items.GetElement("type");
                Session["username"] = bname.Value.ToString();
                Session["dedcolname"] = bdedcol.Value.ToString();
            }
        hihi:
            Session["objid"] = bobjid.Value.ToString();
            Session["typeofuser"] = btype.Value.ToString();

            if (bmobile != null)
            {
                if (ss == bpwd.Value)
                {
                    Session["mertouser"] = "******";
                    if (Session["typeofuser"] != null && Session["typeofuser"].ToString() == "merchant")
                    {
                        var merchantreg = md.GetBColl("registration");
                        var queryfor = new QueryDocument("_id", ObjectId.Parse(bobjid.Value.ToString()));
                        BsonElement bstore = null;
                        Session["dummycol"] = Session["dedcolname"] + "dummy";
                        foreach (var docss in merchantreg.Find(queryfor))
                        {
                            bstore = docss.GetElement("storename");
                            Session["storename"] = bstore.Value;
                        }
                        Response.Clear();
                        Response.CacheControl = "no-cache";
                        Response.ContentType = "application/json";
                        Response.Write("105");   //Invalid Credentials
                        Response.End();
                    }

                    string sessionforid = Session["objid"].ToString();
                    var queryregstatus = new QueryDocument("user", sessionforid);
                    BsonDocument bregstat = new BsonDocument();
                    BsonElement bs = null;
                    foreach (BsonDocument bregs in temporders.Find(queryregstatus))
                    {
                        bs = bregs.GetElement("regtoship");
                    }
                    BsonDocument loginres = new BsonDocument();
                    //loginres.Add("type",btype.Value.ToString());
                    //loginres.Add("orderstatus", orderstatus);
                    loginres.Add("type", btype.Value);
                    //var ordervalue = Session["order"];
                    if (Session["order"] != null)
                    {
                        string ordervalue = Session["order"].ToString();
                        loginres.Add("orderstatus", ordervalue);
                    }
                    if (bs != null)
                    {
                        loginres.Add("registeredtoship", bs.Value);
                    }
                    if (bstatus.Value == 1)
                    {

                        Response.Clear();
                        Response.CacheControl = "no-cache";
                        Response.ContentType = "application/json";
                        //Session["loggedin"] = "loggedin";
                        if (Session["pleaselogin"] != null)
                        {
                            Response.Write("100");  //new login
                        }
                        else
                        {
                            Response.Write(loginres.ToString());  //Valid User
                        }
                        Response.End();
                        //HttpContext.Current.ApplicationInstance.CompleteRequest();
                    }
                    else
                    {
                        Response.Clear();
                        Response.CacheControl = "no-cache";
                        Response.ContentType = "application/json";
                        Response.Write("2");   //Didnt activate your link
                        Response.End();
                        //HttpContext.Current.ApplicationInstance.CompleteRequest();
                    }
                }
                else
                {
                    Response.Clear();
                    Response.CacheControl = "no-cache";
                    Response.ContentType = "application/json";
                    Response.Write("0");   // no mobile INVALID PASSWORD LATEST
                    Response.End();
                }
            }
            else
            {
                Response.Clear();
                Response.CacheControl = "no-cache";
                Response.ContentType = "application/json";
                Response.Write("7");   // no mobile INVALID PASSWORD LATEST
                Response.End();
                //HttpContext.Current.ApplicationInstance.CompleteRequest();
            }
        }
        catch(ThreadAbortException)
        {}
        catch(Exception e4)
        {
            Response.Clear();
            Response.CacheControl = "no-cache";
            Response.ContentType = "application/json";
            Response.Write("exception");
            Response.End();
        }
    }
Ejemplo n.º 5
0
    protected void Page_Load(object sender, EventArgs e)
    {
        try
        {
            var tempOrders = Session["order"];
            var json = Request["reqdata"];
            BsonDocument p = MongoDB.Bson.Serialization.BsonSerializer.Deserialize<BsonDocument>(json);
            BsonValue typeofuser = p.GetElement("type").Value;
            BsonValue stname = p.GetElement("sn").Value;
            BsonValue Name = p.GetElement("Name").Value;
            BsonValue Mobile = p.GetElement("mobileNo").Value;
            BsonValue Email = p.GetElement("email").Value;
            BsonValue Password = p.GetElement("passWord").Value;
            BsonValue Address = p.GetElement("address").Value;
            BsonValue State = p.GetElement("state").Value;
            BsonValue City = p.GetElement("city").Value;
            BsonValue Pincode = p.GetElement("pincode").Value;
            string dedcolname = Name + Mobile.ToString();
            MyDB md = new MyDB();
            var registration = md.GetBColl("registration");

            myEncryption me = new myEncryption();
            string PASSWORD = me.getMD5Hash(Password.ToString());
            BsonDocument document = new BsonDocument();
            document.Add("name", Name);
            document.Add("mobile", Convert.ToInt64(Mobile));
            document.Add("email", Email);
            document.Add("password", PASSWORD);
            document.Add("address", Address);
            document.Add("state", State);
            document.Add("city", City);
            document.Add("pincode", Pincode);
            document.Add("status", 0);
            document.Add("type", typeofuser);
            document.Add("storename", stname);
            document.Add("colname", dedcolname);
            registration.Insert(document);
            registration.Save(document);
            BsonElement bid = document.GetElement("_id");

                    string ActivationUrl = Server.HtmlEncode("http://118.139.160.32/sivanstreet.com/activateusers.aspx");
                    SmtpClient sc = new SmtpClient();
                    sc.Credentials = new NetworkCredential("*****@*****.**", "9885139782"); //from address and password
                    sc.Port = 587;
                    sc.Host = "smtp.gmail.com";
                    sc.EnableSsl = true;

                    MailMessage mm = new MailMessage();
                    mm.From = new MailAddress("*****@*****.**", "Confirmation", System.Text.Encoding.UTF8);
                    mm.To.Add(Email.ToString());
            mm.IsBodyHtml = true;
                    mm.Subject = "Confirmation";
                    mm.Body = "Welcome to SivanStreet<br/>" + "Hi " + Name +"<br/>Please <a href=" + ActivationUrl + ">click here to Activate your Account</a> <br/>\nEnjoy Shopping in SivanStreet :)<br/><br/>With Regards,<br/>SivanStreet.com.";
                    mm.DeliveryNotificationOptions = DeliveryNotificationOptions.OnFailure;
                    sc.Send(mm);

           if (tempOrders != null)
            {
                string ordersend = "[" + tempOrders + "]";
                var res = MongoDB.Bson.Serialization.BsonSerializer.Deserialize<BsonArray>(ordersend.ToString());
                var temporder = md.GetBColl("temporders");
                BsonDocument btemp = new BsonDocument();
                btemp.Add("regtoship", "yes");
                btemp.Add("user", bid.Value.ToString());
                btemp.Add("order", res);
                temporder.Insert(btemp);
                temporder.Save(btemp);
            }
        }
        catch (ThreadAbortException ee) { }
        catch (Exception eee)
        {
            Response.Clear();
            Response.CacheControl = "no-cache";
            Response.ContentType = "application/json";
            Response.Write("exception"+eee.Message);  //Valid User
            Response.End();
        }
    }
Ejemplo n.º 6
0
    protected void Page_Load(object sender, EventArgs e)
    {
        try
        {
            var          tempOrders   = Session["order"];
            var          json         = Request["reqdata"];
            BsonDocument p            = MongoDB.Bson.Serialization.BsonSerializer.Deserialize <BsonDocument>(json);
            BsonValue    typeofuser   = p.GetElement("type").Value;
            BsonValue    stname       = p.GetElement("sn").Value;
            BsonValue    Name         = p.GetElement("Name").Value;
            BsonValue    Mobile       = p.GetElement("mobileNo").Value;
            BsonValue    Email        = p.GetElement("email").Value;
            BsonValue    Password     = p.GetElement("passWord").Value;
            BsonValue    Address      = p.GetElement("address").Value;
            BsonValue    State        = p.GetElement("state").Value;
            BsonValue    City         = p.GetElement("city").Value;
            BsonValue    Pincode      = p.GetElement("pincode").Value;
            string       dedcolname   = Name + Mobile.ToString();
            MyDB         md           = new MyDB();
            var          registration = md.GetBColl("registration");

            myEncryption me       = new myEncryption();
            string       PASSWORD = me.getMD5Hash(Password.ToString());
            BsonDocument document = new BsonDocument();
            document.Add("name", Name);
            document.Add("mobile", Convert.ToInt64(Mobile));
            document.Add("email", Email);
            document.Add("password", PASSWORD);
            document.Add("address", Address);
            document.Add("state", State);
            document.Add("city", City);
            document.Add("pincode", Pincode);
            document.Add("status", 0);
            document.Add("type", typeofuser);
            document.Add("storename", stname);
            document.Add("colname", dedcolname);
            registration.Insert(document);
            registration.Save(document);
            BsonElement bid = document.GetElement("_id");


            string     ActivationUrl = Server.HtmlEncode("http://118.139.160.32/sivanstreet.com/activateusers.aspx");
            SmtpClient sc            = new SmtpClient();
            sc.Credentials = new NetworkCredential("*****@*****.**", "9885139782");         //from address and password
            sc.Port        = 587;
            sc.Host        = "smtp.gmail.com";
            sc.EnableSsl   = true;

            MailMessage mm = new MailMessage();
            mm.From = new MailAddress("*****@*****.**", "Confirmation", System.Text.Encoding.UTF8);
            mm.To.Add(Email.ToString());
            mm.IsBodyHtml = true;
            mm.Subject    = "Confirmation";
            mm.Body       = "Welcome to SivanStreet<br/>" + "Hi " + Name + "<br/>Please <a href=" + ActivationUrl + ">click here to Activate your Account</a> <br/>\nEnjoy Shopping in SivanStreet :)<br/><br/>With Regards,<br/>SivanStreet.com.";
            mm.DeliveryNotificationOptions = DeliveryNotificationOptions.OnFailure;
            sc.Send(mm);

            if (tempOrders != null)
            {
                string       ordersend = "[" + tempOrders + "]";
                var          res       = MongoDB.Bson.Serialization.BsonSerializer.Deserialize <BsonArray>(ordersend.ToString());
                var          temporder = md.GetBColl("temporders");
                BsonDocument btemp     = new BsonDocument();
                btemp.Add("regtoship", "yes");
                btemp.Add("user", bid.Value.ToString());
                btemp.Add("order", res);
                temporder.Insert(btemp);
                temporder.Save(btemp);
            }
        }
        catch (ThreadAbortException ee) { }
        catch (Exception eee)
        {
            Response.Clear();
            Response.CacheControl = "no-cache";
            Response.ContentType  = "application/json";
            Response.Write("exception" + eee.Message);  //Valid User
            Response.End();
        }
    }