Ejemplo n.º 1
0
        //private void ConvertHeadshotImages(string key)
        //{
        //  var headshotOriginalBlob = PoliticiansImagesBlobs.GetHeadshotOriginal(key);
        //  if (headshotOriginalBlob != null)
        //  {
        //    MemoryStream memoryStream = new MemoryStream(headshotOriginalBlob);
        //    Image image = Image.FromStream(memoryStream);
        //    var newBlob100 = ImageManager.GetResizedImageBlobAsJpg(image, 100, 100);
        //    File.WriteAllBytes(@"c:\VoteImages\Headshot100\" + key + ".jpg", newBlob100);
        //    PoliticiansImagesBlobs.UpdateHeadshot100(newBlob100, key);
        //    var newBlob75 = ImageManager.GetResizedImageBlobAsJpg(image, 75, 75);
        //    File.WriteAllBytes(@"c:\VoteImages\Headshot75\" + key + ".jpg", newBlob75);
        //    PoliticiansImagesBlobs.UpdateHeadshot75(newBlob75, key);
        //    var newBlob50 = ImageManager.GetResizedImageBlobAsJpg(image, 50, 50);
        //    File.WriteAllBytes(@"c:\VoteImages\Headshot50\" + key + ".jpg", newBlob50);
        //    PoliticiansImagesBlobs.UpdateHeadshot50(newBlob50, key);
        //    var newBlob35 = ImageManager.GetResizedImageBlobAsJpg(image, 35, 35);
        //    File.WriteAllBytes(@"c:\VoteImages\Headshot35\" + key + ".jpg", newBlob35);
        //    PoliticiansImagesBlobs.UpdateHeadshot35(newBlob35, key);
        //    var newBlob25 = ImageManager.GetResizedImageBlobAsJpg(image, 25, 25);
        //    File.WriteAllBytes(@"c:\VoteImages\Headshot25\" + key + ".jpg", newBlob25);
        //    PoliticiansImagesBlobs.UpdateHeadshot25(newBlob25, key);
        //    var newBlob20 = ImageManager.GetResizedImageBlobAsJpg(image, 20, 20);
        //    File.WriteAllBytes(@"c:\VoteImages\Headshot20\" + key + ".jpg", newBlob20);
        //    PoliticiansImagesBlobs.UpdateHeadshot20(newBlob20, key);
        //    var newBlob15 = ImageManager.GetResizedImageBlobAsJpg(image, 15, 15);
        //    File.WriteAllBytes(@"c:\VoteImages\Headshot15\" + key + ".jpg", newBlob15);
        //    PoliticiansImagesBlobs.UpdateHeadshot15(newBlob15, key);
        //    AppendStatusText(key);
        //  }
        //  else
        //  {
        //    Byte[] headshotBlob;
        //    headshotBlob = PoliticiansImagesBlobs.GetHeadshot100(key);
        //    if (headshotBlob != null)
        //    {
        //      MemoryStream memoryStream = new MemoryStream(headshotBlob);
        //      Image image = Image.FromStream(memoryStream);
        //      var newBlob = ImageManager.GetResizedImageBlobAsJpg(image, 100, 100);
        //      File.WriteAllBytes(@"c:\VoteImages\Headshot100\" + key + ".jpg", newBlob);
        //      PoliticiansImagesBlobs.UpdateHeadshot100(newBlob, key);
        //    }
        //    headshotBlob = PoliticiansImagesBlobs.GetHeadshot75(key);
        //    if (headshotBlob != null)
        //    {
        //      MemoryStream memoryStream = new MemoryStream(headshotBlob);
        //      Image image = Image.FromStream(memoryStream);
        //      var newBlob = ImageManager.GetResizedImageBlobAsJpg(image, 75, 75);
        //      File.WriteAllBytes(@"c:\VoteImages\Headshot75\" + key + ".jpg", newBlob);
        //      PoliticiansImagesBlobs.UpdateHeadshot75(newBlob, key);
        //    }
        //    headshotBlob = PoliticiansImagesBlobs.GetHeadshot50(key);
        //    if (headshotBlob != null)
        //    {
        //      MemoryStream memoryStream = new MemoryStream(headshotBlob);
        //      Image image = Image.FromStream(memoryStream);
        //      var newBlob = ImageManager.GetResizedImageBlobAsJpg(image, 50, 50);
        //      File.WriteAllBytes(@"c:\VoteImages\Headshot50\" + key + ".jpg", newBlob);
        //      PoliticiansImagesBlobs.UpdateHeadshot50(newBlob, key);
        //    }
        //    headshotBlob = PoliticiansImagesBlobs.GetHeadshot35(key);
        //    if (headshotBlob != null)
        //    {
        //      MemoryStream memoryStream = new MemoryStream(headshotBlob);
        //      Image image = Image.FromStream(memoryStream);
        //      var newBlob = ImageManager.GetResizedImageBlobAsJpg(image, 35, 35);
        //      File.WriteAllBytes(@"c:\VoteImages\Headshot35\" + key + ".jpg", newBlob);
        //      PoliticiansImagesBlobs.UpdateHeadshot35(newBlob, key);
        //    }
        //    headshotBlob = PoliticiansImagesBlobs.GetHeadshot25(key);
        //    if (headshotBlob != null)
        //    {
        //      MemoryStream memoryStream = new MemoryStream(headshotBlob);
        //      Image image = Image.FromStream(memoryStream);
        //      var newBlob = ImageManager.GetResizedImageBlobAsJpg(image, 25, 25);
        //      File.WriteAllBytes(@"c:\VoteImages\Headshot25\" + key + ".jpg", newBlob);
        //      PoliticiansImagesBlobs.UpdateHeadshot25(newBlob, key);
        //    }
        //    headshotBlob = PoliticiansImagesBlobs.GetHeadshot20(key);
        //    if (headshotBlob != null)
        //    {
        //      MemoryStream memoryStream = new MemoryStream(headshotBlob);
        //      Image image = Image.FromStream(memoryStream);
        //      var newBlob = ImageManager.GetResizedImageBlobAsJpg(image, 20, 20);
        //      File.WriteAllBytes(@"c:\VoteImages\Headshot20\" + key + ".jpg", newBlob);
        //      PoliticiansImagesBlobs.UpdateHeadshot20(newBlob, key);
        //    }
        //    headshotBlob = PoliticiansImagesBlobs.GetHeadshot15(key);
        //    if (headshotBlob != null)
        //    {
        //      MemoryStream memoryStream = new MemoryStream(headshotBlob);
        //      Image image = Image.FromStream(memoryStream);
        //      var newBlob = ImageManager.GetResizedImageBlobAsJpg(image, 15, 15);
        //      File.WriteAllBytes(@"c:\VoteImages\Headshot15\" + key + ".jpg", newBlob);
        //      PoliticiansImagesBlobs.UpdateHeadshot15(newBlob, key);
        //    }
        //  }
        //}

        private void ConvertProfileImages(string key)
        {
            var profileOriginalBlob = PoliticiansImagesBlobs.GetProfileOriginal(key);

            if (profileOriginalBlob != null)
            {
                MemoryStream memoryStream = new MemoryStream(profileOriginalBlob);
                Image        image        = Image.FromStream(memoryStream);
                var          newBlob300   = ImageManager.GetResizedImageBlobAsJpg(image, 300, 400);
                File.WriteAllBytes(@"c:\VoteImages\Profile300\" + key + ".jpg", newBlob300);
                PoliticiansImagesBlobs.UpdateProfile300(newBlob300, key);
                var newBlob200 = ImageManager.GetResizedImageBlobAsJpg(image, 200, 275);
                File.WriteAllBytes(@"c:\VoteImages\Profile200\" + key + ".jpg", newBlob200);
                PoliticiansImagesBlobs.UpdateProfile200(newBlob200, key);
                AppendStatusText(key);
            }
            else
            {
                var profile300Blob = PoliticiansImagesBlobs.GetProfile300(key);
                if (profile300Blob != null)
                {
                    MemoryStream memoryStream = new MemoryStream(profile300Blob);
                    Image        image        = Image.FromStream(memoryStream);
                    var          newBlob300   = ImageManager.GetResizedImageBlobAsJpg(image, 300, 400);
                    File.WriteAllBytes(@"c:\VoteImages\Profile300\" + key + ".jpg", newBlob300);
                    PoliticiansImagesBlobs.UpdateProfile300(newBlob300, key);
                }
                var profile200Blob = PoliticiansImagesBlobs.GetProfile200(key);
                if (profile200Blob != null)
                {
                    MemoryStream memoryStream = new MemoryStream(profile200Blob);
                    Image        image        = Image.FromStream(memoryStream);
                    var          newBlob200   = ImageManager.GetResizedImageBlobAsJpg(image, 200, 275);
                    File.WriteAllBytes(@"c:\VoteImages\Profile200\" + key + ".jpg", newBlob200);
                    PoliticiansImagesBlobs.UpdateProfile200(newBlob200, key);
                }
            }
        }