protected void btnMigrateImages_Click(object sender, EventArgs e)
        {
            int cBytesDone = 0;
            int cFilesDone = 0;

            if (!int.TryParse(txtLimitMB.Text, out int cMBytesLimit))
            {
                cMBytesLimit = 100;
            }

            int cBytesLimit = cMBytesLimit * 1024 * 1024;

            if (!int.TryParse(txtLimitFiles.Text, out int cFilesLimit))
            {
                cFilesLimit = 100;
            }

            Dictionary <string, MFBImageCollection> images = MFBImageInfo.FromDB(CurrentSource, true);

            List <string> lstKeys = images.Keys.ToList();

            if (CurrentSource == MFBImageInfoBase.ImageClass.Aircraft || CurrentSource == MFBImageInfoBase.ImageClass.Flight)
            {
                lstKeys.Sort((sz1, sz2) => { return(Convert.ToInt32(sz2, CultureInfo.InvariantCulture) - Convert.ToInt32(sz1, CultureInfo.InvariantCulture)); });
            }
            else
            {
                lstKeys.Sort();
            }

            // ImageDict
            foreach (string szKey in lstKeys)
            {
                if (cBytesDone > cBytesLimit || cFilesDone >= cFilesLimit)
                {
                    break;
                }
                AWSImageManagerAdmin im = new AWSImageManagerAdmin();
                foreach (MFBImageInfo mfbii in images[szKey])
                {
                    int cBytes = im.ADMINMigrateToS3(mfbii);
                    if (cBytes >= 0)  // migration occured
                    {
                        cBytesDone += cBytes;
                        cFilesDone++;
                    }

                    if (cBytesDone > cBytesLimit || cFilesDone >= cFilesLimit)
                    {
                        break;
                    }
                }
            }

            lblMigrateResults.Text = String.Format(CultureInfo.CurrentCulture, Resources.Admin.MigrateImagesTemplate, cFilesDone, cBytesDone);
        }
Exemple #2
0
    protected void btnMigrateImages_Click(object sender, EventArgs e)
    {
        Int32 cBytesDone   = 0;
        Int32 cFilesDone   = 0;
        Int32 cMBytesLimit = 100;
        Int32 cFilesLimit  = 100;

        if (!Int32.TryParse(txtLimitMB.Text, out cMBytesLimit))
        {
            cMBytesLimit = 100;
        }

        Int32 cBytesLimit = cMBytesLimit * 1024 * 1024;

        if (!Int32.TryParse(txtLimitFiles.Text, out cFilesLimit))
        {
            cFilesLimit = 100;
        }

        Dictionary <string, List <MFBImageInfo> > images = ImageDictionary;

        foreach (string szKey in SortedKeys)
        {
            if (cBytesDone > cBytesLimit || cFilesDone >= cFilesLimit)
            {
                break;
            }
            AWSImageManagerAdmin im = new AWSImageManagerAdmin();
            foreach (MFBImageInfo mfbii in images[szKey])
            {
                Int32 cBytes = im.ADMINMigrateToS3(mfbii);
                if (cBytes >= 0)  // migration occured
                {
                    cBytesDone += cBytes;
                    cFilesDone++;
                }

                if (cBytesDone > cBytesLimit || cFilesDone >= cFilesLimit)
                {
                    break;
                }
            }
        }

        lblMigrateResults.Text = String.Format(CultureInfo.CurrentCulture, Resources.Admin.MigrateImagesTemplate, cFilesDone, cBytesDone);
    }
Exemple #3
0
        protected void DeleteS3Orphans()
        {
            Response.Clear();
            Response.Write(String.Format(CultureInfo.InvariantCulture, "<html><head><link href=\"{0}\" rel=\"stylesheet\" type=\"text/css\" /></head><body><p>", VirtualPathUtility.ToAbsolute("~/Public/stylesheet.css")));

            // Get a list of all of the images in the DB for this category:
            UpdateProgress(1, 0, String.Format(CultureInfo.CurrentCulture, "Getting images for {0} from S3", CurrentSource.ToString()));

            bool fIsLiveSite = Branding.CurrentBrand.MatchesHost(Request.Url.Host);
            bool fIsPreview  = !String.IsNullOrEmpty(Request["preview"]);

            AWSImageManagerAdmin.ADMINDeleteS3Orphans(CurrentSource,
                                                      (cFiles, cBytesTotal, cOrphans, cBytesToFree) =>
                                                      { UpdateProgress(4, 100, String.Format(CultureInfo.CurrentCulture, "{0} orphaned files ({1:#,##0} bytes) found out of {2} files ({3:#,##0} bytes).", cOrphans, cBytesToFree, cFiles, cBytesTotal)); },
                                                      () => { UpdateProgress(2, 0, "S3 Enumeration done, getting files from DB"); },
                                                      (szKey, percent) =>
            {
                UpdateProgress(3, percent, String.Format(CultureInfo.CurrentCulture, "{0}: {1}", fIsPreview ? "PREVIEW" : (fIsLiveSite ? "ACTUAL" : "NOT LIVE SITE"), szKey));
                return(!fIsPreview && fIsLiveSite);
            });

            Response.Write("</p></body></html>");
            Response.End();
        }
 protected void btnDeleteS3Debug_Click(object sender, EventArgs e)
 {
     AWSImageManagerAdmin.ADMINCleanUpDebug();
 }