Ejemplo n.º 1
0
        protected void gvPackageVersions_RowDataBound(object sender, GridViewRowEventArgs e)
        {
            if (e.Row.RowType == DataControlRowType.DataRow)
            {
                IPackage package = e.Row.DataItem as IPackage;
                if (package != null)
                {
                    Boolean            isExactPackageInstalled = NuGetService.IsPackageInstalled(package);
                    LinkButton         lbInstall      = e.Row.FindControl("lbInstall") as LinkButton;
                    LinkButton         lbUpdate       = e.Row.FindControl("lbUpdate") as LinkButton;
                    HtmlGenericControl iInstalledIcon = e.Row.FindControl("iInstalledIcon") as HtmlGenericControl;
                    if (e.Row.RowIndex == 0)
                    {
                        lbInstall.AddCssClass("btn-primary");
                    }

                    lbInstall.CommandArgument = lbUpdate.CommandArgument = e.Row.RowIndex.ToString();

                    // Don't show the install button if a version of this package is already installed
                    lbInstall.Visible = (!lbPackageUninstall.Visible);

                    // Show the update button if an older version of this package is already installed and the package is the latest version
                    lbUpdate.Visible = ((lbPackageUninstall.Visible && !isExactPackageInstalled) && package.IsLatestVersion);

                    iInstalledIcon.Visible = (isExactPackageInstalled);
                }
            }
        }
Ejemplo n.º 2
0
        private void ViewPackage(string packageId)
        {
            this.AddHistory("CurrentViewMode", this.CurrentViewMode.ToString(), null);
            pnlPackage.Visible     = true;
            pnlPackageList.Visible = false;

            IPackage package = NuGetService.SourceRepository.FindPackage(packageId, version: null, allowPrereleaseVersions: false, allowUnlisted: false);

            // TODO: change to "http://quarry.rockrms.com/Content/Images/Quarry/packageDefaultIcon-128x128.png";
            imgIcon.ImageUrl   = (package.IconUrl == null) ? "http://quarry.rockrms.com/Content/Images/packageDefaultIcon1.png" : package.IconUrl.ToString();
            lTitle.Text        = package.Title;
            lAuthors.Text      = string.Join(",", package.Authors);
            lDescription.Text  = package.Description;
            lTags.Text         = package.Tags;
            lDependencies.Text = (package.DependencySets.Count() == 0) ? "This plugin has no dependencies." : package.DependencySets.Flatten();

            lbPackageUninstall.CommandArgument = packageId;
            lbPackageUninstall.Visible         = NuGetService.IsPackageInstalled(package, anyVersion: true);
            gvPackageVersions.DataSource       = NuGetService.SourceRepository.FindPackagesById(package.Id).OrderByDescending(p => p.Version);
            gvPackageVersions.DataBind();
        }
Ejemplo n.º 3
0
        private void ViewPackage(string packageId)
        {
            pnlPackage.Visible     = true;
            pnlPackageList.Visible = false;

            IPackage package = NuGetService.SourceRepository.FindPackage(packageId, version: null, allowPrereleaseVersions: false, allowUnlisted: false);

            // TODO: change to "http://quarry.rockchms.com/Content/Images/Quarry/packageDefaultIcon-128x128.png";
            imgIcon.ImageUrl   = (package.IconUrl == null) ? "http://quarry.rockchms.com/Content/Images/packageDefaultIcon1.png" : package.IconUrl.ToString();
            lTitle.Text        = package.Title;
            lAuthors.Text      = string.Join(",", package.Authors);
            lDescription.Text  = package.Description;
            lTags.Text         = package.Tags;
            lDependencies.Text = (package.DependencySets.Count() == 0) ? "This plugin has no dependencies." :
                                 package.DependencySets.Aggregate(new StringBuilder("<ul>"), (sb, s) => sb.AppendFormat("<li>{0}</li>", s)).Append("</ul>").ToString();

            lbPackageUninstall.CommandArgument = packageId;
            lbPackageUninstall.Visible         = NuGetService.IsPackageInstalled(package, anyVersion: true);
            gvPackageVersions.DataSource       = NuGetService.SourceRepository.FindPackagesById(package.Id).OrderByDescending(p => p.Version);
            gvPackageVersions.DataBind();
        }
Ejemplo n.º 4
0
        /// <summary>
        /// Used to populate each item in the PackageList
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected void gPackageList_RowDataBound(object sender, GridViewRowEventArgs e)
        {
            IPackage package = e.Row.DataItem as IPackage;

            if (package != null)
            {
                Boolean isPackageInstalled = NuGetService.IsPackageInstalled(package, anyVersion: true);

                LinkButton lbCommand           = e.Row.FindControl("lbCommand") as LinkButton;
                LinkButton lbUpdate            = e.Row.FindControl("lbUpdate") as LinkButton;
                LinkButton lbView              = e.Row.FindControl("lbView") as LinkButton;
                HtmlAnchor link                = e.Row.FindControl("lProjectUrl") as HtmlAnchor;
                Literal    lblAuthors          = e.Row.FindControl("lblAuthors") as Literal;
                Literal    lblVersion          = e.Row.FindControl("lblVersion") as Literal;
                Literal    lblLatestVersion    = e.Row.FindControl("lblLatestVersion") as Literal;
                Literal    lblInstalledVersion = e.Row.FindControl("lblInstalledVersion") as Literal;

                if (package.IconUrl != null)
                {
                    Image imgIconUrl = e.Row.FindControl("imgIconUrl") as Image;
                    imgIconUrl.ImageUrl = package.IconUrl.ToString();;
                }

                lblAuthors.Text = string.Join(",", package.Authors);

                if (package.ProjectUrl != null)
                {
                    link.Visible = true;
                    link.HRef    = package.ProjectUrl.ToString();
                }
                else
                {
                    link.Visible = false;
                }

                lbUpdate.Visible = false;

                // If this package (not necessarily this version) is installed
                // show an uninstall button and/or an update button if a later version exists
                if (isPackageInstalled)
                {
                    IPackage theInstalledPackage = NuGetService.GetInstalledPackage(package.Id);
                    if (theInstalledPackage != null)
                    {
                        lblInstalledVersion.Visible = true;
                        lblInstalledVersion.Text   += theInstalledPackage.Version;

                        try
                        {
                            // Checking "IsLatestVersion" does not work because of what's discussed here:
                            // http://nuget.codeplex.com/discussions/279837
                            // if ( !installedPackage.IsLatestVersion )...
                            var latestPackage = NuGetService.GetUpdate(package);
                            if (latestPackage != null)
                            {
                                lbUpdate.Visible         = true;
                                lblLatestVersion.Visible = true;
                                lblLatestVersion.Text   += latestPackage.Version;
                            }
                        }
                        catch (InvalidOperationException ex)
                        {
                            Literal lblItemError = e.Row.FindControl("lblItemError") as Literal;
                            lblItemError.Text = string.Format("<p class='text-error'>We're having a problem... {0}</p>", ex.Message);
                        }
                    }

                    lbCommand.CommandName = "uninstall";
                    lbCommand.Text        = "<i class='fa fa-times'></i> &nbsp; Uninstall";
                    lbCommand.AddCssClass("btn-warning");
                }
                else
                {
                    lblVersion.Visible    = true;
                    lblVersion.Text      += package.Version;
                    lbCommand.CommandName = "Install";
                    lbCommand.Text        = "<i class='fa fa-download'></i> &nbsp; Install";
                }

                lbCommand.CommandArgument = lbUpdate.CommandArgument = lbView.CommandArgument = e.Row.RowIndex.ToString();
            }
        }