Esempio n. 1
0
        public static List <LoggedImageInfo> GetTwoLatestProfileImageInfos(
            string politicianKey)
        {
            var cmdText = "SELECT DateStamp,UserName FROM LogDataChange" +
                          " WHERE TableName='PoliticiansImagesBlobs' AND ColumnName='ProfileOriginal'" +
                          " AND KeyValues=@PoliticianKey ORDER BY DateStamp DESC";

            cmdText = VoteDb.InjectSqlLimit(cmdText, 2);
            var cmd = VoteLogDb.GetCommand(cmdText, -1);

            VoteLogDb.AddCommandParameter(cmd, "PoliticianKey", politicianKey);
            var list = FillTable(cmd, LogDataChangeTable.ColumnSet.DateAndUser)
                       .Select(
                row =>
                new LoggedImageInfo
            {
                DateStamp = row.DateStamp,
                UserName  = row.UserName
            })
                       .ToList();

            list.AddRange(LogPoliticiansImagesOriginal.GetTwoLatestImageDateAndUsers(
                              politicianKey)
                          .Select(
                              row =>
                              new LoggedImageInfo
            {
                DateStamp = row.ProfileOriginalDate,
                UserName  = row.UserName
            }));
            return(list.OrderByDescending(o => o.DateStamp)
                   .Take(2)
                   .ToList());
        }
Esempio n. 2
0
        public static DateTime GetSecondLatestProfileImageDate(string politicianKey,
                                                               out string userName)
        {
            var cmdText = "SELECT DateStamp,UserName FROM LogDataChange" +
                          " WHERE TableName='PoliticiansImagesBlobs' AND ColumnName='ProfileOriginal'" +
                          " AND KeyValues=@PoliticianKey ORDER BY DateStamp DESC";

            cmdText = VoteDb.InjectSqlLimit(cmdText, 2);
            var cmd = VoteLogDb.GetCommand(cmdText, -1);

            VoteLogDb.AddCommandParameter(cmd, "PoliticianKey", politicianKey);
            var list = FillTable(cmd, LogDataChangeTable.ColumnSet.DateAndUser)
                       .Select(row => new { row.DateStamp, row.UserName })
                       .ToList();

            list.AddRange(LogPoliticiansImagesOriginal.GetTwoLatestImageDateAndUsers(
                              politicianKey)
                          .Select(row => new { DateStamp = row.ProfileOriginalDate, row.UserName }));
            if (list.Count < 2)
            {
                userName = string.Empty;
                return(VoteDb.DateTimeMin);
            }
            var item = list.OrderByDescending(o => o.DateStamp)
                       .Skip(1)
                       .First();

            userName = item.UserName;
            return(item.DateStamp);
        }