Ejemplo n.º 1
0
        private void SetupProject()
        {
            #region Memberbadge

            MemberPosts.Text = Project.Vendor.Member.ForumPosts.ToString();
            MemberKarma.Text = Project.Vendor.Member.ReputationCurrent.ToString();

            #endregion

            #region Standard Features

            ProjectName.Text = Project.Name;
            ProjectCreateDate.Text = String.Format("{0:D}", Project.CreateDate);
            ProjectCurrentVersion.Text = Project.CurrentVersion;
            VendorLink.Text = Project.Vendor.Member.Name;
            VendorLink.NavigateUrl = "/member/" + Project.Vendor.Member.Id;

            //description
            if (Project.Description.Contains('<'))
                ProjectDescrition.Text = uForum.Library.Xslt.ResolveLinks(Project.Description);
            else
                ProjectDescrition.Text = uForum.Library.Xslt.ResolveLinks(umbraco.library.ReplaceLineBreaks(Project.Description));

            #endregion

            #region Screenshots
            //screenshots
            if (Project.ScreenShots.Count() > 0)
            {
                ScreenshotRepeater.DataSource = Project.ScreenShots;
                ScreenshotRepeater.DataBind();
            }
            else
            {
                ScreenshotRepeater.Visible = false;
            }

            #endregion

            #region Resources

            //resources
            var resouceFormat = "<li><a href=\"{0}\">{1}</a></li>";

            if (!string.IsNullOrEmpty(Project.ProjectUrl))
                ProjectResources.Text += string.Format(resouceFormat, Project.ProjectUrl, "Project Website");

            if(!string.IsNullOrEmpty(Project.DemonstrationUrl))
                ProjectResources.Text += string.Format(resouceFormat, Project.DemonstrationUrl, "View a Demonstration");

            if (!string.IsNullOrEmpty(Project.SourceCodeUrl))
                ProjectResources.Text += string.Format(resouceFormat, Project.SourceCodeUrl, "Download Source Code");

            if (!string.IsNullOrEmpty(Project.SupportUrl))
                ProjectResources.Text += string.Format(resouceFormat, Project.SupportUrl, "Support &amp; Issues");

            if (!string.IsNullOrEmpty(Project.LicenseUrl))
                ProjectResources.Text += string.Format(resouceFormat, Project.LicenseUrl, "Read the License");

            #endregion

            #region Files
            //files

            var vendorProvider = (IVendorProvider)MarketplaceProviderManager.Providers["VendorProvider"];

            var files = Project.PackageFile.Where(x => !x.Archived).OrderByDescending(x => x.CreateDate).Select(x => new
            {
                Id = x.Id,
                Name = x.Name,
                FileType = x.FileType.FileTypeAsString(),
                Member = new Member(x.CreatedBy),
                UmbracoVersion = x.UmbVersion.ToVersionNameString(), //x.UmbVersion.Description,
                DotNetVersion = x.DotNetVersion,
                MediumTrust = (x.SupportsMediumTrust)?"Supports Medium Trust":"Full Trust Required",
                CreateDate = x.CreateDate.ToShortDateString()

            });

            if (files.Count() > 0)
            {
                ProjectFileRepeater.DataSource = files;
                ProjectFileRepeater.DataBind();
            }
            else
            {
                ProjectFileRepeater.Visible = false;
            }

            var hotFixes = Project.HotFixes.Where(x => !x.Archived).OrderByDescending(x => x.CreateDate).Select(x => new
            {
                Id = x.Id,
                Name = x.Name,
                FileType = x.FileType.FileTypeAsString(),
                Member = new Member(x.CreatedBy),
                UmbracoVersion = x.UmbVersion.ToVersionNameString(), //x.UmbVersion.Description,
                DotNetVersion = x.DotNetVersion,
                MediumTrust = (x.SupportsMediumTrust) ? "Supports Medium Trust" : "Full Trust Required",
                CreateDate = x.CreateDate.ToShortDateString()

            });

            if (hotFixes.Count() > 0)
            {
                HotFixRepeater.DataSource = hotFixes;
                HotFixRepeater.DataBind();
            }
            else
            {
                HotFixRepeater.Visible = false;
            }

            var sourceFiles = Project.SourceFile.Where(x => !x.Archived).OrderByDescending(x => x.CreateDate).Select(x => new
            {
                Id = x.Id,
                Name = x.Name,
                FileType = x.FileType.FileTypeAsString(),
                Member = new Member(x.CreatedBy),
                UmbracoVersion = x.UmbVersion.ToVersionNameString(), // "TBI",//x.UmbVersion.Description,
                DotNetVersion = x.DotNetVersion,
                MediumTrust = (x.SupportsMediumTrust) ? "Supports Medium Trust" : "Full Trust Required",
                CreateDate = x.CreateDate.ToShortDateString()

            });

            if (sourceFiles.Count() > 0)
            {
                SourceRepeater.DataSource = sourceFiles;
                SourceRepeater.DataBind();
            }
            else
            {
                SourceRepeater.Visible = false;
            }

            #endregion

            #region Documentation
            //Documenation

            var docs = Project.DocumentationFile.Where(x => !x.Archived).Select(x => new
            {
                Id = x.Id,
                Name = x.Name,
                FileType = x.FileType.FileTypeAsString(),
                CreateDate = x.CreateDate,
                Member = new Member(x.CreatedBy)
            });

            if (docs.Count() > 0)
            {
                ProjectDocRepeater.DataSource = docs;
                ProjectDocRepeater.DataBind();
            }
            else
            {
                ProjectDocRepeater.Visible = false;
            }

            #endregion

            #region Archive

            //Archived Files
            var archive = new List<IMediaFile>();

            var packageArchive = Project.PackageFile.Where(x => x.Archived);
            var docArchive = Project.DocumentationFile.Where(x => x.Archived);

            archive.AddRange(packageArchive);
            archive.AddRange(docArchive);

            if (archive.Count() > 0)
            {
                ArchiveRepeater.DataSource = archive.Select(x => new
                {
                    Id = x.Id,
                    Name = x.Name,
                    FileType = x.FileType.FileTypeAsString(),
                    Member = new Member(x.CreatedBy),
                    UmbracoVersion = x.UmbVersion.ToVersionString(), //x.UmbVersion.Description,
                    DotNetVersion = x.DotNetVersion,
                    MediumTrust = (x.SupportsMediumTrust) ? "Supports Medium Trust" : "Full Trust Required",
                    CreateDate = x.CreateDate.ToShortDateString()
                });

                ArchiveRepeater.DataBind();
            }
            else
            {
                ArchiveRepeater.Visible = false;
            }

            #endregion

            #region Sidebar

            //download box
            if (!string.IsNullOrEmpty(Project.CurrentReleaseFile))
            {
                //ProjectNameDownload.Text = Project.Name;
                //ProjectCurrentVersionDownload.Text = Project.CurrentVersion;

                var file = Project.PackageFile.Where(x => x.Id == Int32.Parse(Project.CurrentReleaseFile)).FirstOrDefault();
                if (file != null)
                {

                    var uVersions = UVersion.GetAllVersions();

                    using (var ctx = new MarketplaceDataContext())
                    {
                        var count = 0;
                        var verCount = 0;
                        var ct = "This project has been reported to be compatible with ";

                        foreach (var ver in uVersions)
                        {
                            var reports = ctx.DeliVersionCompatibilities.Where(x => x.version == ver.Name && x.projectId == Project.Id);

                            if (reports.Count() > 0)
                            {
                                float compats = reports.Where(x => x.isCompatible).Count();
                                float numReps = reports.Count();
                                var perc = Convert.ToInt32(((compats / numReps) * 100));

                                if (perc >= 80)
                                {
                                    verCount++;
                                    if (count < 2)
                                    {
                                        count++;
                                        ct += ver.Name + ", ";
                                    }
                                }
                            }

                        }

                        if (count == 0)
                            ct = "No compatible versions have been reported, be the first!";
                        else
                        {
                            if (verCount > 2)
                            {
                                ct += "and " + (verCount - 2) + " other versions.";
                            }
                            else
                                ct = ct.Trim().TrimEnd(',');
                        }
                        ProjectCompatitbleWithUmbraco.Text = ct;
                    }

                    // file.UmbVersion.Description;

                    ////////////////////////////////////////////////////////////////
                    // moved to versionCompatibilityReport.cshtml for AJAXifCation//
                    ////////////////////////////////////////////////////////////////

                    //var compatDetails = "This project is compatible with the following versions as reported by community members who have downloaded this package:<br/><br/>";

                    //var uVersions = UVersion.GetAllVersions();

                    //using (var ctx = new MarketplaceDataContext())
                    //{
                    //    foreach (var ver in uVersions)
                    //    {
                    //        var reports = ctx.DeliVersionCompatibilities.Where(x => x.version == ver.Name && x.projectId == Project.Id);

                    //        if (reports.Count() > 0)
                    //        {
                    //            float compats = reports.Where(x => x.isCompatible).Count();
                    //            float numReps = reports.Count();
                    //            var perc = Convert.ToInt32(((compats / numReps) * 100));

                    //            var smiley = "unhappy";

                    //            if (perc >= 95)
                    //                smiley = "joyous";
                    //            else if (perc < 95 && perc >= 80)
                    //                smiley = "happy";
                    //            else if (perc < 80 && perc >= 65)
                    //                smiley = "neutral";
                    //            else if (perc < 65 && perc >= 50)
                    //                smiley = "unhappy";
                    //            else
                    //                smiley = "superUnhappy";

                    //            compatDetails += "<span class=\"smiley " + smiley + "\">" + ver.Name + " (" + perc + "%)</span>";
                    //        }
                    //        else
                    //            compatDetails += "<span class=\"smiley untested\">" + ver.Name + " (untested)</span>";
                    //    }
                    //}

                    //compatDetails += "<br/>";

                    var compatDetails = string.Empty;
                    if (!string.IsNullOrEmpty(file.DotNetVersion))
                        compatDetails += "<strong>.NET Version:</strong>" + file.DotNetVersion + "<br/>";

                    compatDetails += "<strong>Supports Medium Trust:</strong>";
                    compatDetails += (file.SupportsMediumTrust) ? "Yes" : "No";
                    compatDetails += "<br/>";
                    ProjectCompatibileDetails.Text = compatDetails;

                }

            }
            else
            {
                HasReports.Visible = false;
                DownloadPanel.Visible = false;
            }

            //Commercial options
            if (Project.ListingType != ListingType.commercial)
            {
                CommercePanel.Visible = false;
            }
            else
            {
                var licenseProvider = (ILicenseProvider)MarketplaceProviderManager.Providers["LicenseProvider"];
                var licenses = licenseProvider.GetProjectLicenses(Project.ProjectGuid).Where(x => x.IsActive);
                ProjectPurchaseRepeater.DataSource = licenses;
                ProjectPurchaseRepeater.DataBind();
            }

            //Collab
            CollabPanel.Visible = Project.OpenForCollab;

            //package info panel

            //project contributors

            using (var ctx = new MarketplaceDataContext())
            {
                var contributors = ctx.projectContributors.Where(x => x.projectId == Project.Id)
                    .Select(x => new Member(x.memberId)).ToList();

                if (contributors.Count() > 0)
                {
                    ContribRepeater.DataSource = contributors;
                    ContribRepeater.DataBind();
                }
            }

            //Tags

            TagRepeater.DataSource = Project.Tags;
            TagRepeater.DataBind();

            if (TagEditPanel.Visible)
            {
                TagEditRepeater.DataSource = Project.Tags;
                TagEditRepeater.DataBind();

                string taglist = string.Empty;
                var tagProvider = ((IProjectTagProvider)MarketplaceProviderManager.Providers["TagProvider"]);
                var tags = tagProvider.GetAllTags();
                foreach (var t in tags)
                {
                    taglist += "\"" + t.Text + "\",";
                }

                TagStringArray.Text = taglist;
            }

            //Download Counter

            DownloadCount.Text = Project.Downloads.ToString();

            #endregion
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Check to see if member has reported on compatibility for a package regardless of version of the package
        /// </summary>
        /// <param name="memberId">The members Id</param>
        /// <param name="packageId">The package Id</param>
        /// <returns></returns>
        public static bool HasDownloaded(int memberId, int packageId)
        {
            using (var ctx = new MarketplaceDataContext())
            {
                var downs = ctx.projectDownloads.Where(x => x.memberId == memberId && x.projectId == packageId);
                if (downs.Count() > 0)
                    return true;
                return false;

            }
        }