Пример #1
0
        /// <summary>
        /// Gets all the Users and their information (limited by 200)
        /// </summary>
        /// <returns></returns>
        private async Task<List<User>> GetAllUsersAsync()
        {
            MySqlDataReader reader = this.Query("SELECT * FROM gk_user ORDER BY username ASC LIMIT 0,200");
            List<User> Users = new List<User>();

            while (await reader.ReadAsync())
            {
                User user = new User();
                user.username = reader.GetString("username");
                try 
                {
                    user.comment = reader.GetString("comment");
                }
                catch { }
                user.debt = reader.GetDouble("debt");
                user.ID = reader.GetInt32("ID");
                user.state = reader.GetString("state");
                
                Users.Add(user);
            }

            reader.Close();
            this.Close();
            return Users;
        }
Пример #2
0
        /// <summary>
        /// Gets the Sum of products bought in the system since the provided Keydate (form: yyyy-mm-dd)
        /// </summary>
        public async Task<List<User>> GetDebtSinceKeyDateAsync(String keydate, string deviceID)
        {
            await CheckDeviceRights(deviceID, DeviceRights.FULL);

            MySqlDataReader reader = this.Query("SELECT *,SUM(price) FROM gk_accounting WHERE gk_accounting.date>=\"" + keydate + "\" GROUP BY user LIMIT 0,200");

            List<User> list = new List<User>();

            while (await reader.ReadAsync())
            {
                User user = new User();

                user.debt = reader.GetDouble("SUM(price)");
                user.username = reader.GetString("user");

                list.Add(user);

            }
            reader.Close();
            this.Close();
            return list;
        }
Пример #3
0
        /// <summary>
        /// returns a List representing the (200) active users,  and their data
        /// </summary>
        public async Task<List<User>> GetActiveUsersAsync(string deviceID)
        {
            await CheckDeviceRights(deviceID, DeviceRights.READ);

            MySqlDataReader reader = this.Query("SELECT * FROM gk_user WHERE gk_user.state='active' ORDER BY username ASC LIMIT 0,200");
            List<User> Users = new List<User>();

            while (await reader.ReadAsync())
            {
                User user = new User();
                user.username = reader.GetString("username");
                try
                {
                    user.comment = reader.GetString("comment");
                }
                catch { }
                user.debt = reader.GetDouble("debt");
                user.ID = reader.GetInt32("ID");
                user.state = reader.GetString("state");

                Users.Add(user);
            }

            reader.Close();
            this.Close();
            return Users;
        }