Пример #1
0
        protected void btnSync_Click(object sender, EventArgs e)
        {
            CloudSvc.CloudService pxy = new CloudSvc.CloudService();
            Account objAccount        = (Account)Session["Account"];

            Byte[] byteArray = SerializeData(objAccount);

            lblSyncStatus.Text = pxy.UpdateAccount(byteArray, objAccount.UserID, objAccount.UserLoginID, objAccount.UserPassword);
        }
        protected void Session_End(object sender, EventArgs e)
        {
            CloudSvc.CloudService pxy = new CloudSvc.CloudService();

            // Update the DB with serialized Account object
            Account objAccount = (Account)Session["Account"];
            //objAccount.UserEmail = ((Account)Session["Account"]).UserEmail;//get user ID from session object
            //objAccount.UserPassword = ((Account)Session["Account"]).UserPassword;

            DataSet objDS = new DataSet();

            //objDS.Tables.Add(dt);

            objDS = pxy.GetUserByLoginIDandPass(objAccount.UserLoginID, objAccount.UserPassword);

            //String strPlaceHolder = pxy.UpdateAccount(objAccount, objAccount.UserID, objAccount.UserEmail, objAccount.UserPassword);
        }
Пример #3
0
        // Check with database to see if credentials are correct
        public bool CheckCredentials()
        {
            DataSet objDS = new DataSet();

            CloudSvc.CloudService pxy = new CloudSvc.CloudService();

            try
            {
                objDS = pxy.GetUserByLoginIDandPass(txtEmail.Text, txtPassword.Text);

                // Check if returned DataSet is empty
                if (objDS.Tables[0].Rows.Count == 0)
                    return false;
                else
                {
                    // If serialized column is empty, then store info, else load into Account object
                    if (objDS.Tables[0].Rows[0]["Account"] == DBNull.Value)
                    {
                        objAccount.UserID = Convert.ToInt32(objDS.Tables[0].Rows[0]["UserID"]);

                        // Serialize data for database input and display status
                        //lblStatus.Text = pxy.UpdateAccount(objDS, objAccount.UserID, txtEmail.Text, txtPassword.Text);
                    }
                    else
                    {
                        Byte[] byteArray = (Byte[])objDS.Tables[0].Rows[0]["Account"];

                        objAccount = DeserializeAccount(byteArray);

                        objAccount.UserRole = objDS.Tables[0].Rows[0]["RoleDescription"].ToString();
                        objAccount.UserPassword = objGM.DecryptPassword(objDS.Tables[0].Rows[0]["HashedPassword"].ToString());
                        objAccount.UserEmail = objDS.Tables[0].Rows[0]["LoginID"].ToString();
                        objAccount.UserID = Convert.ToInt32(objDS.Tables[0].Rows[0]["UserID"]);
                        objAccount.StorageUsed = Convert.ToInt32(objDS.Tables[0].Rows[0]["StorageUsed"]);
                        objAccount.StorageCapacity = Convert.ToInt32(objDS.Tables[0].Rows[0]["StorageCapacity"]);
                    }

                    // User entered correct login information
                    return true;
                }
            }
            catch (Exception e)
            {
                return false;
            }
        }