コード例 #1
0
        /// <summary>
        /// Get transaction từ api admin
        /// Default: type = 1
        /// </summary>
        /// <param name="UriServer"></param>
        /// <param name="userName"></param>
        /// <param name="tid">timeStamp</param>
        /// <param name="hash">tid+userName</param>
        /// <returns></returns>
        public async System.Threading.Tasks.Task <string> SDKApiTransactionGetAsync(string UriServer, string userName)
        {
            var     timeStamp = CommonCalculate.GetTimeStamp();
            string  str       = timeStamp + "" + userName + "MLKEf6r6xQVTDK";//TID+userName+MLKEf6r6xQVTDK
            HashMD5 md5       = new HashMD5();
            string  strHash   = md5.MD5Hash(str);

            using (var client = new HttpClient())
            {
                client.BaseAddress = new Uri(UriServer);
                client.DefaultRequestHeaders.Accept.Clear();
                client.DefaultRequestHeaders.TryAddWithoutValidation("Content-Type", "application/json");
                HttpResponseMessage response = await client.GetAsync(UriServer + "?type=1&username=" + userName);

                if (response.IsSuccessStatusCode)
                {
                    return(response.Content.ReadAsStringAsync().Result);
                }
                return(null);
            }
        }
コード例 #2
0
        private void ButtonSubmit_Click(object sender, System.Windows.RoutedEventArgs e)
        {
            try
            {
                string tableName = MyAWSConfigs.AdminDBTableName;
                var    item      = Dynamodb.GetItem(myId, tableName);
                //Console.Write("my adminid<<<<<<<<<<<<<<<<<<", myId, ">>>>>>>>>>>>>>>>>>>");

                bool isPasswordEmpty    = string.IsNullOrEmpty(txtPassword.Password);
                bool isNewPasswordEmpty = string.IsNullOrEmpty(txtNewPassword.Password);
                bool isCPasswordEmpty   = string.IsNullOrEmpty(txtNewCPassword.Password);

                if (!isPasswordEmpty && !isNewPasswordEmpty && !isCPasswordEmpty)
                {
                    //check enetered and saved password hashes are same
                    if (HashMD5.MD5Hash(txtPassword.Password) == item["aPassword"])
                    {
                        Console.WriteLine("\n*** Executing UpdateMultipleAttributes() ***");
                        Console.WriteLine("\nUpdating multiple attributes....");
                        string partitionKey = myId;

                        Document doc = new Document();
                        doc["aId"] = partitionKey;
                        // List of attribute updates.
                        // The following replaces the existing authors list.
                        doc["aPassword"] = HashMD5.MD5Hash(txtNewPassword.Password);

                        // update password
                        Dynamodb.UpdateItem(doc, tableName);

                        //activity recorded
                        Models.ActivityLogs.Activity(Models.Components.AdminComponent, "User Changed Password");


                        Console.WriteLine("UpdateMultipleAttributes: Printing item after updates ...");
                        MessageBox.Show("Successfully Updated!");

                        this.Close();
                    }
                    else
                    {
                        //activity recorded
                        Models.ActivityLogs.Activity(Models.Components.AdminComponent, "Wrong Password for change Password");

                        MessageBox.Show("Message : Wrong Password!");
                    }
                }
                else
                {
                    MessageBox.Show("Message : Please fill all all the fields!!!");
                }
            }
            catch (AmazonDynamoDBException ex)
            {
                MessageBox.Show("Message : Server Error", ex.Message);
            }
            catch (Exception ex)
            {
                MessageBox.Show("Message : Unknown Error", ex.Message);
            }
            finally
            {
                Mouse.OverrideCursor = null;
            }
        }