コード例 #1
0
        /// <summary>
        /// get listing
        /// </summary>
        /// <param name="content"></param>
        /// <param name="optimized">if set performs less DB interactions to increase speed.</param>
        /// <param name="projectKarma"></param>
        /// <returns></returns>
        public IListingItem GetListing(IPublishedContent content, bool optimized = false, int projectKarma = -1)
        {
            if (content != null)
            {
                var listingItem = new ListingItem.ListingItem(
                    p => GetProjectDownloadCount(p),
                    p => projectKarma < 0 ? GetProjectKarma(p) : projectKarma
                    );

                listingItem.Id                      = content.Id;
                listingItem.NiceUrl                 = library.NiceUrl(listingItem.Id);
                listingItem.Name                    = content.Name;
                listingItem.Description             = content.GetPropertyValue <string>("description", "");
                listingItem.CurrentVersion          = content.GetPropertyValue <string>("version", "");
                listingItem.CurrentReleaseFile      = content.GetPropertyValue <string>("file", "");
                listingItem.DefaultScreenshot       = content.GetPropertyValue <string>("defaultScreenshotPath", "");
                listingItem.DevelopmentStatus       = content.GetPropertyValue <string>("status", "");
                listingItem.ListingType             = content.GetPropertyAsListingType("listingType");
                listingItem.GACode                  = content.GetPropertyValue <string>("gaCode", "");
                listingItem.CategoryId              = content.GetPropertyValue <int>("category");
                listingItem.Stable                  = content.GetPropertyValue <bool>("stable");
                listingItem.Live                    = content.GetPropertyValue <bool>("projectLive");
                listingItem.LicenseName             = content.GetPropertyValue <string>("licenseName", "");
                listingItem.LicenseUrl              = content.GetPropertyValue <string>("licenseUrl", "");
                listingItem.ProjectUrl              = content.GetPropertyValue <string>("websiteUrl", "");
                listingItem.SupportUrl              = content.GetPropertyValue <string>("supportUrl", "");
                listingItem.SourceCodeUrl           = content.GetPropertyValue <string>("sourceUrl", "");
                listingItem.DemonstrationUrl        = content.GetPropertyValue <string>("demoUrl", "");
                listingItem.OpenForCollab           = content.GetPropertyValue <bool>("openForCollab", false);
                listingItem.NotAPackage             = content.GetPropertyValue <bool>("notAPackage", false);
                listingItem.ProjectGuid             = new Guid(content.GetPropertyValue <string>("packageGuid"));
                listingItem.Approved                = content.GetPropertyValue <bool>("approved", false);
                listingItem.UmbracoVerionsSupported = content.GetPropertyValue <string>("compatibleVersions", "").Split(';');
                listingItem.NETVersionsSupported    = (content.GetPropertyValue <string>("dotNetVersion", "") != null) ? content.GetPropertyValue <string>("dotNetVersion", "").Split(';') : "".Split(';');
                listingItem.TrustLevelSupported     = content.GetPropertyAsTrustLevel("trustLevelSupported");
                listingItem.TermsAgreementDate      = content.GetPropertyValue <DateTime>("termsAgreementDate");
                listingItem.CreateDate              = content.CreateDate;
                listingItem.VendorId                = content.GetPropertyValue <int>("owner");
                listingItem.Logo                    = content.GetPropertyValue <string>("logo", "");
                listingItem.LicenseKey              = content.GetPropertyValue <string>("licenseKey", "");

                //this section was created to speed up loading operations and cut down on the number of database interactions
                if (optimized == false)
                {
                    listingItem.DocumentationFile = GetMediaForProjectByType(content.Id, FileType.docs);
                    listingItem.ScreenShots       = GetMediaForProjectByType(content.Id, FileType.screenshot);
                    listingItem.PackageFile       = GetMediaForProjectByType(content.Id, FileType.package);
                    listingItem.HotFixes          = GetMediaForProjectByType(content.Id, FileType.hotfix);
                    listingItem.SourceFile        = GetMediaForProjectByType(content.Id, FileType.source);
                }

                return(listingItem);
            }
            throw new NullReferenceException("Content is Null");
        }
コード例 #2
0
        /// <summary>
        /// get listing
        /// </summary>
        /// <param name="content"></param>
        /// <param name="optimized">if set performs less DB interactions to increase speed.</param>
        /// <param name="projectKarma"></param>
        /// <returns></returns>
        public IListingItem GetListing(IPublishedContent content, bool optimized = false, int projectKarma = -1)
        {
            if (content != null)
            {
                var listingItem = new ListingItem.ListingItem(
                    p => GetProjectDownloadCount(p),
                    p => projectKarma < 0 ? GetProjectKarma(p) : projectKarma
                    );

                listingItem.Id = content.Id;
                listingItem.NiceUrl = library.NiceUrl(listingItem.Id);
                listingItem.Name = content.Name;
                listingItem.Description = content.GetPropertyValue<string>("description", "");
                listingItem.CurrentVersion = content.GetPropertyValue<string>("version", "");
                listingItem.CurrentReleaseFile = content.GetPropertyValue<string>("file", "");
                listingItem.DefaultScreenshot = content.GetPropertyValue<string>("defaultScreenshotPath", "");
                listingItem.DevelopmentStatus = content.GetPropertyValue<string>("status", "");
                listingItem.ListingType = content.GetPropertyAsListingType("listingType");
                listingItem.GACode = content.GetPropertyValue<string>("gaCode", "");
                listingItem.CategoryId = content.GetPropertyValue<int>("category");
                listingItem.Stable = content.GetPropertyValue<bool>("stable");
                listingItem.Live = content.GetPropertyValue<bool>("projectLive");
                listingItem.LicenseName = content.GetPropertyValue<string>("licenseName", "");
                listingItem.LicenseUrl = content.GetPropertyValue<string>("licenseUrl", "");
                listingItem.ProjectUrl = content.GetPropertyValue<string>("websiteUrl", "");
                listingItem.SupportUrl = content.GetPropertyValue<string>("supportUrl", "");
                listingItem.SourceCodeUrl = content.GetPropertyValue<string>("sourceUrl", "");
                listingItem.DemonstrationUrl = content.GetPropertyValue<string>("demoUrl", "");
                listingItem.OpenForCollab = content.GetPropertyValue<bool>("openForCollab", false);
                listingItem.NotAPackage = content.GetPropertyValue<bool>("notAPackage", false);
                listingItem.ProjectGuid = new Guid(content.GetPropertyValue<string>("packageGuid"));
                listingItem.Approved = content.GetPropertyValue<bool>("approved", false);
                listingItem.UmbracoVerionsSupported = content.GetPropertyValue<string>("compatibleVersions", "").Split(';');
                listingItem.NETVersionsSupported = (content.GetPropertyValue<string>("dotNetVersion", "") != null) ? content.GetPropertyValue<string>("dotNetVersion", "").Split(';') : "".Split(';');
                listingItem.TrustLevelSupported = content.GetPropertyAsTrustLevel("trustLevelSupported");
                listingItem.TermsAgreementDate = content.GetPropertyValue<DateTime>("termsAgreementDate");
                listingItem.CreateDate = content.CreateDate;
                listingItem.VendorId = content.GetPropertyValue<int>("owner");
                listingItem.Logo = content.GetPropertyValue<string>("logo", "");
                listingItem.LicenseKey = content.GetPropertyValue<string>("licenseKey", "");

                //this section was created to speed up loading operations and cut down on the number of database interactions
                if (optimized == false)
                {
                    listingItem.DocumentationFile = GetMediaForProjectByType(content.Id, FileType.docs);
                    listingItem.ScreenShots = GetMediaForProjectByType(content.Id, FileType.screenshot);
                    listingItem.PackageFile = GetMediaForProjectByType(content.Id, FileType.package);
                    listingItem.HotFixes = GetMediaForProjectByType(content.Id, FileType.hotfix);
                    listingItem.SourceFile = GetMediaForProjectByType(content.Id, FileType.source);
                }

                return listingItem;
            }
            throw new NullReferenceException("Content is Null");
        }