예제 #1
0
        /// <summary>
        /// Gets the candidate blobs for cleaning up.
        /// </summary>
        /// <param name="container">The cloud blob container.</param>
        /// <param name="searchPattern">The search pattern of a BLOB name.</param>
        /// <returns></returns>
        protected ICollection <ICloudBlob> GetCandidateBlobs(CloudBlobContainer container, string searchPattern)
        {
            Assert.ArgumentNotNull(container, "container");
            Assert.ArgumentNotNull(searchPattern, "searchPattern");

            var blobList = LogStorageManager.ListBlobs(container, searchPattern);

            Log.Info($"Scheduling.BlobsCleanupAgent: The '{container.Name}' cloud blob container includes '{blobList.Count()}' blobs that match the '{searchPattern}' search pattern.", this);

            var candidateBlobList = new List <ICloudBlob>();

            foreach (ICloudBlob blob in blobList)
            {
                if (blob != null)
                {
                    DateTime utcMaxTime = this.GetBlobLastModifiedDate(blob).Add(this.maxAge);

                    if (DateTime.UtcNow > utcMaxTime)
                    {
                        candidateBlobList.Add(blob);
                    }
                }
            }

            if (candidateBlobList.Any())
            {
                Log.Info($"Scheduling.BlobsCleanupAgent: The '{container.Name}' cloud blob container includes '{candidateBlobList.Count()}' out-to-date blobs that match the '{searchPattern}' search pattern.", this);
            }

            return(candidateBlobList);
        }
        /// <summary>
        /// Raises the load event.
        /// </summary>
        /// <param name="e">
        /// The <see cref="System.EventArgs"/> instance containing the event data.
        /// </param>
        /// <remarks>
        /// This method notifies the server control that it should perform actions common to each HTTP
        /// request for the page it is associated with, such as setting up a database query. At this
        /// stage in the page lifecycle, server controls in the hierarchy are created and initialized,
        /// view state is restored, and form controls reflect client-side data. Use the IsPostBack
        /// property to determine whether the page is being loaded in response to a client postback,
        /// or if it is being loaded and accessed for the first time.
        /// </remarks>
        protected override void OnLoad([NotNull] EventArgs e)
        {
            Assert.ArgumentNotNull(e, "e");

            this.CheckSecurity();

            base.OnLoad(e);

            if (Context.ClientPage.IsEvent)
            {
                return;
            }

            var urlHandle = UrlHandle.Get();

            var icon = urlHandle["ic"];

            if (!string.IsNullOrEmpty(icon))
            {
                this.Dialog["Icon"] = icon;
            }

            var header = WebUtil.SafeEncode(urlHandle["he"]);

            if (header.Length > 0)
            {
                this.Dialog["Header"] = header;
            }

            var text = WebUtil.SafeEncode(urlHandle["txt"]);

            if (text.Length > 0)
            {
                this.Dialog["Text"] = text;
            }

            var button = WebUtil.SafeEncode(urlHandle["btn"]);

            if (button.Length > 0)
            {
                this.Dialog["OKButton"] = button;
            }

            var filter    = urlHandle["flt"];
            var blobsList = LogStorageManager.ListBlobs(filter);

            foreach (var blob in blobsList)
            {
                var item = new ListviewItem();
                this.FileLister.Controls.Add(item);
                item.ID     = Control.GetUniqueID("I");
                item.Header = blob.Uri.Segments.Last();
                item.Icon   = "Applications/16x16/document.png";
                item.ServerProperties["Blob"] = blob.Name;
                item.ColumnValues["size"]     = MainUtil.FormatSize(blob.Properties.Length);
                item.ColumnValues["modified"] = blob.Properties.LastModified.HasValue ? blob.Properties.LastModified.Value.LocalDateTime : DateTime.Now;
            }
        }