Esempio n. 1
0
        public async Task <List <FacebookCredential> > FacebookCredentials(int userId)
        {
            List <FacebookCredential> credentials = new List <FacebookCredential>();
            string cmdStr = @"SELECT fb_credential_id, fb_username, fb_password FROM v_appuser_facebook WHERE appuser_id=@appuser_id order by fb_credential_id desc";

            await using MySqlCommand cmd = await db.CreateCommand(cmdStr);

            cmd.Parameters.Add(new MySqlParameter("appuser_id", userId));
            using MySqlDataReader odr = await cmd.ExecuteMySqlReaderAsync();

            while (await odr.ReadAsync())
            {
                var credential = new FacebookCredential
                {
                    Id       = await odr.ReadMySqlIntegerAsync("fb_credential_id"),
                    Username = await odr.ReadMySqlStringAsync("fb_username"),
                    Password = pwd.SimpleDecrypt(await odr.ReadMySqlStringAsync("fb_password"))
                };
                if (credential.Id > 0 && !credentials.Any(c => c.Id == credential.Id && c.Username == credential.Username))
                {
                    credentials.Add(credential);
                }
            }
            return(credentials);
        }
Esempio n. 2
0
        public async Task <AppUser> GetOne(string email)
        {
            AppUser appUser = null;
            string  cmdStr  = "SELECT appuser_id, email, title, firstname, lastname, disabled, active, role_name FROM v_appuser WHERE email=@email";

            await using MySqlCommand cmd = await db.CreateCommand(cmdStr);

            cmd.Parameters.Add(new MySqlParameter("email", email));
            using MySqlDataReader odr = await cmd.ExecuteMySqlReaderAsync();

            while (await odr.ReadAsync())
            {
                appUser = await ReadAppUserDataReaderAsync(odr);
            }
            return(appUser);
        }
Esempio n. 3
0
        public async Task <ScheduleJobDef> GetScheduleJobDef(int id, int userId)
        {
            ScheduleJobDef scheduleJobDef = new ScheduleJobDef();
            string         cmdStr         = ScheduleJobDefSelect + " WHERE id=@id AND appuser_id=@appuser_id";

            await using MySqlCommand cmd = await db.CreateCommand(cmdStr);

            cmd.Parameters.Add(new MySqlParameter("id", id));
            cmd.Parameters.Add(new MySqlParameter("appuser_id", userId));
            using var odr = await cmd.ExecuteMySqlReaderAsync();

            if (await odr.ReadAsync())
            {
                scheduleJobDef = await ReadScheduleJobDefAsync(odr);
            }
            return(scheduleJobDef);
        }
Esempio n. 4
0
        public async Task <List <ScheduleJobDef> > GetOpeningScheduleJobDefs()
        {
            List <ScheduleJobDef> defs = new List <ScheduleJobDef>();
            string cmdStr = OpeningScheduleJobDefSelect;

            await using MySqlCommand cmd = await db.CreateCommand(cmdStr);

            using var odr = await cmd.ExecuteMySqlReaderAsync();

            while (await odr.ReadAsync())
            {
                var scheduleJobDef = await ReadOpenScheduleJobDefAsync(odr);

                defs.Add(scheduleJobDef);
            }
            return(defs.ToList());
        }
Esempio n. 5
0
        public async Task <List <ScheduleJobDef> > GetScheduleJobDefs(int userId)
        {
            List <ScheduleJobDef> defs = new List <ScheduleJobDef>();
            string cmdStr = ScheduleJobDefSelect + " WHERE appuser_id=@appuser_id";

            await using MySqlCommand cmd = await db.CreateCommand(cmdStr);

            cmd.Parameters.Add(new MySqlParameter("appuser_id", userId));
            using var odr = await cmd.ExecuteMySqlReaderAsync();

            while (await odr.ReadAsync())
            {
                var scheduleJobDef = await ReadScheduleJobDefAsync(odr);

                defs.Add(scheduleJobDef);
            }
            return(defs.ToList());
        }
Esempio n. 6
0
        public async Task <List <FacebookFriend> > FacebookFriends(int userId)
        {
            var    friends = new List <FacebookFriend>();
            string cmdStr  = @"SELECT id, name, profile_link, active, disabled FROM friend WHERE appuser_id=@appuser_id";

            await using MySqlCommand cmd = await db.CreateCommand(cmdStr);

            cmd.Parameters.Add(new MySqlParameter("appuser_id", userId));
            using MySqlDataReader odr = await cmd.ExecuteMySqlReaderAsync();

            while (await odr.ReadAsync())
            {
                friends.Add(new FacebookFriend
                {
                    Id          = await odr.ReadMySqlIntegerAsync("id"),
                    Name        = await odr.ReadMySqlStringAsync("name"),
                    ProfileLink = await odr.ReadMySqlStringAsync("profile_link"),
                    Active      = await odr.ReadMySqlBooleanAsync("active"),
                    Disabled    = await odr.ReadMySqlBooleanAsync("disabled"),
                });
            }
            return(friends);
        }