Ejemplo n.º 1
0
        private void InitializeData()
        {
            this.mySqlHandler = new MySQLHandler()
            {
                User     = DEFAULT_MYSQL_USER,
                Password = DEFAULT_MYSQL_PASSWORD,
                Server   = string.IsNullOrEmpty(this.IpAddress) ? DEFAULT_SERVER : this.IpAddress,
                Port     = DEFAULT_MYSQL_PORT,
                Database = string.IsNullOrEmpty(this.MySqlDatabase) ? DEFAULT_MYSQL_DATABASE : this.MySqlDatabase
            };

            if (AvailableHrbcApps == null)
            {
                AvailableHrbcApps = new List <HrbcApp>();
            }
            else if (AvailableHrbcApps != null && AvailableHrbcApps.Count > 0)
            {
                AvailableHrbcApps.Clear();
            }
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Logout
        /// </summary>
        public void Logout()
        {
            if (this.sshClient != null)
            {
                this.sshClient.Disconnect();
                this.sshClient.Dispose();
            }
            if (AvailableHrbcApps != null)
            {
                AvailableHrbcApps.Clear();
            }
            if (WhitelistedHrbcApps != null)
            {
                WhitelistedHrbcApps.Clear();
            }
            AvailableHrbcApps   = null;
            WhitelistedHrbcApps = null;

            isLoggedIn = false;
        }
Ejemplo n.º 3
0
        /// <summary>
        /// Read Available Apps using SQL Query
        /// </summary>
        public void ReadAppList(string filter = null)
        {
            InitializeData();

            string query = string.Empty;

            if (string.IsNullOrEmpty(filter))
            {
                query = "SELECT id, company_id, app_name, app_secret FROM oauth_application";
            }
            else
            {
                query = string.Format("SELECT id, company_id, app_name, app_secret FROM oauth_application WHERE app_name = '{0}'", filter);
            }

            try
            {
                List <Dictionary <string, object> > rows = mySqlHandler.ExecuteReaderQuery(query);
                foreach (Dictionary <string, object> row in rows)
                {
                    int    new_id         = row["id"] != System.DBNull.Value ? (int)row["id"] : -1;
                    int    new_company_id = row["company_id"] != System.DBNull.Value ? (int)row["company_id"] : -1;
                    string new_app_name   = row["app_name"] != System.DBNull.Value ? (string)row["app_name"] : string.Empty;
                    string new_app_secret = row["app_secret"] != System.DBNull.Value ? (string)row["app_secret"] : string.Empty;

                    HrbcApp newApp = new HrbcApp()
                    {
                        id         = new_id,
                        company_id = new_company_id > 0 ? new_company_id.ToString() : "NULL",
                        app_name   = new_app_name,
                        app_secret = new_app_secret
                    };
                    AvailableHrbcApps.Add(newApp);
                }
            }
            catch (MySql.Data.MySqlClient.MySqlException e)
            {
                Console.WriteLine("SQL Connection is not established properly yet.");
                Console.WriteLine(e.ToString());
            }
        }