Beispiel #1
0
        protected void ButtonRevertToLog_ServerClick(object sender, EventArgs e)
        {
            try
            {
                var politicianKey = LabelPoliticianKey.Text;
                var latestLogDate =
                    LogDataChange.GetSecondLatestProfileImageDate(politicianKey, out _);

                var logTime    = new DateTime(latestLogDate.Ticks);
                var loggedBlob = LatestLoggedImagePage.GetLoggedImageByDate(politicianKey, logTime);
                if (latestLogDate.IsDefaultDate() || loggedBlob == null || loggedBlob.Length == 0)
                {
                    Msg.Text = Fail("No log profile image for ID " + politicianKey + " was found.");
                }
                else
                {
                    var now = DateTime.UtcNow;
                    ImageManager.UpdatePoliticianProfileImages(politicianKey,
                                                               new MemoryStream(loggedBlob), now, out _);
                    CommonCacheInvalidation.ScheduleInvalidation("politicianimage", politicianKey);
                    LogImageChange(politicianKey, null, loggedBlob, now);
                    Msg.Text = Ok("The profile image for ID " + politicianKey +
                                  " was reverted to the most recent logged version.");
                }
            }
            catch (Exception ex)
            {
                HandleException(ex);
            }
        }
Beispiel #2
0
        protected void ButtonRevertToLog_ServerClick(object sender, EventArgs e)
        {
            try
            {
                var    politicianKey = LabelPoliticianKey.Text;
                string user;
                var    latestLogDate =
                    LogDataChange.GetSecondLatestProfileImageDate(politicianKey, out user);

                var logTime    = new DateTime(latestLogDate.Ticks);
                var loggedBlob = LatestLoggedImagePage.GetLoggedImageByDate(
                    politicianKey, logTime);
                if ((latestLogDate == DefaultDbDate) || (loggedBlob == null) ||
                    (loggedBlob.Length == 0))
                {
                    Msg.Text =
                        Fail("No log profile image for ID " + politicianKey + " was found.");
                }
                else
                {
                    var  now = DateTime.UtcNow;
                    Size originalSize;
                    ImageManager.UpdatePoliticianProfileImages(politicianKey,
                                                               new MemoryStream(loggedBlob), now, out originalSize);
                    CommonCacheInvalidation.ScheduleInvalidation("politicianimage",
                                                                 politicianKey);
                    LogPoliticiansImagesOriginal.Insert(politicianKey, loggedBlob, now,
                                                        UserSecurityClass, UserName, 0);
                    Msg.Text =
                        Ok("The profile image for ID " + politicianKey +
                           " was reverted to the most recent logged version.");
                }
            }
            catch (Exception ex)
            {
                HandleException(ex);
            }
        }
Beispiel #3
0
        private void SetImageUrls()
        {
            var politicianKey = LabelPoliticianKey.Text.Trim();

            var latestLogInfo = LogDataChange.GetTwoLatestProfileImageInfos(politicianKey);
            var date          = latestLogInfo.Count < 1
        ? PoliticiansImagesData.GetProfileOriginalDate(politicianKey, DefaultDbDate)
        : latestLogInfo[0].DateStamp;
            var dateTag = LocalDate.AsString(date, "M/D/YYYY h:mm:ss A");

            ProfileImageHeading.InnerHtml = latestLogInfo.Count < 1
        ? $"Newly-Uploaded Profile:<br />{dateTag}"
        : $"Newly-Uploaded Profile<br />({dateTag} by {latestLogInfo[0].UserName}):";

            byte[] loggedBlob = null;
            if (latestLogInfo.Count >= 2)
            {
                loggedBlob = LatestLoggedImagePage.GetLoggedImageByDate(politicianKey,
                                                                        new DateTime(latestLogInfo[1].DateStamp.Ticks));
            }
            //if (latestLogInfo.Count < 2)
            if (loggedBlob == null)
            {
                LoggedImage.Visible          = false;
                LoggedImageSize.Visible      = false;
                LoggedImageHeading.InnerHtml = "No logged profile available";
                LoggedImageHeading.Style.Add(HtmlTextWriterStyle.Color, "red");
                ButtonRevertToLog.Visible = false;
            }
            else
            {
                LoggedImage.Visible          = true;
                LoggedImageSize.Visible      = true;
                LoggedImageHeading.InnerHtml =
                    $"Most Recent Logged Profile<br/>({LocalDate.AsString(latestLogInfo[1].DateStamp, "M/D/YYYY h:mm:ss A")}" +
                    $" by {latestLogInfo[1].UserName}):";
                LoggedImageHeading.Style.Add(HtmlTextWriterStyle.Color, "black");
                ButtonRevertToLog.Visible = true;
                LoggedImage.ImageUrl      = "/master/latestloggedimage.aspx?id=" + politicianKey +
                                            "&ticks=" + latestLogInfo[1].DateStamp.Ticks;
                //var loggedBlob =
                //  LatestLoggedImagePage.GetLoggedImageByDate(politicianKey,
                //  new DateTime(latestLogInfo[1].DateStamp.Ticks));
                var loggedImage = Image.FromStream(new MemoryStream(loggedBlob));
                LoggedImageSize.InnerHtml = $"{loggedImage.Width}x{loggedImage.Height}";
            }

            OriginalImage.ImageUrl =
                InsertNoCacheIntoUrl(Url_Image_Politician_Original(politicianKey) +
                                     "&Def=1");

            var blob = ImageManager.GetPoliticianImage(politicianKey, "ProfileOriginal",
                                                       "ProfileOriginal", true);
            var image = Image.FromStream(new MemoryStream(blob));

            OriginalImageSize.InnerHtml = $"{image.Width}x{image.Height}";

            Image15.ImageUrl =
                InsertNoCacheIntoUrl(
                    Url_Image_Politician(politicianKey, ImageSize15Headshot) +
                    "&Def=1");

            Image20.ImageUrl =
                InsertNoCacheIntoUrl(
                    Url_Image_Politician(politicianKey, ImageSize20Headshot) +
                    "&Def=1");

            Image25.ImageUrl =
                InsertNoCacheIntoUrl(
                    Url_Image_Politician(politicianKey, ImageSize25Headshot) +
                    "&Def=1");

            Image35.ImageUrl =
                InsertNoCacheIntoUrl(
                    Url_Image_Politician(politicianKey, ImageSize35Headshot) +
                    "&Def=1");

            Image50.ImageUrl =
                InsertNoCacheIntoUrl(
                    Url_Image_Politician(politicianKey, ImageSize50Headshot) +
                    "&Def=1");

            Image75.ImageUrl =
                InsertNoCacheIntoUrl(
                    Url_Image_Politician(politicianKey, ImageSize75Headshot) +
                    "&Def=1");

            Image100.ImageUrl =
                InsertNoCacheIntoUrl(
                    Url_Image_Politician(politicianKey, ImageSize100Headshot) +
                    "&Def=1");

            Image200.ImageUrl =
                InsertNoCacheIntoUrl(
                    Url_Image_Politician(politicianKey, ImageSize200Profile) +
                    "&Def=1");

            Image300.ImageUrl =
                InsertNoCacheIntoUrl(
                    Url_Image_Politician(politicianKey, ImageSize300Profile) +
                    "&Def=1");
        }