private void InitAccount(string loginName, string password)
        {
            LoginName = loginName;
            Password = password;

            if (Account == null)
                Account = GetTopMSAccount();
        }
 /// <summary>
 /// Login with Azure account
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void btnLogin_Click(object sender, RoutedEventArgs e)
 {
     if (String.IsNullOrEmpty(txtClientID.Text.Trim()) || String.IsNullOrEmpty(txtClientSecret.Password.Trim()))
     {
         MessageBox.Show("Please Enter Your Client ID or Client Secret.", "Warning", MessageBoxButton.OK, MessageBoxImage.Warning);
     }
     else
     {
         MSAccount account = new MSAccount();
         account.ClientId = txtClientID.Text;
         account.ClientSecret = txtClientSecret.Password;
         TranslatorServiceClient.Account = account;
         Start(false, "", "");
     }
 }
Example #3
0
        /// <summary>
        /// Get All Active MS Accounts
        /// </summary>
        /// <returns>MS Accounts List</returns>
        public List<MSAccount> GetMSAccounts()
        {
            List<MSAccount> list = new List<MSAccount>();
            string sql = "SELECT * FROM MSTranslatorAccounts WHERE IsActive=1";
            try
            {
                MSAccount account;
                SqlDataReader sdr = SQLHelper.ExecuteDataReader(connnectionString, CommandType.Text, sql, null);
                if (sdr == null)
                    return null;

                while (sdr.Read())
                {
                    account = new MSAccount();
                    account.AccountID = Convert.ToInt32(sdr["AccountID"]);
                    account.Name = sdr["Name"].ToString();
                    account.Owner = sdr["Owner"].ToString();
                    account.ClientId = sdr["ClientId"].ToString();
                    account.ClientSecret = sdr["ClientSecret"].ToString();
                    account.IsActive = Convert.ToBoolean(sdr["IsActive"]);
                    account.CurrentCount = Convert.ToInt32(sdr["CurrentCount"]);
                    account.MaxAllowedCount = Convert.ToInt32(sdr["MaxAllowedCount"]);
                    account.NextCounterReset = Convert.ToDateTime(sdr["NextCounterReset"]);
                    list.Add(account);
                }
                return list;
            }
            catch (SqlException ex)
            {
                list = null;
                throw ex;
            }
        }