Example #1
0
 public SuiteCommand(AbpNuGetIndexUrlService nuGetIndexUrlService, NuGetService nuGetService, ICmdHelper cmdHelper)
 {
     CmdHelper             = cmdHelper;
     _nuGetIndexUrlService = nuGetIndexUrlService;
     _nuGetService         = nuGetService;
     Logger = NullLogger <SuiteCommand> .Instance;
 }
        private void InitializeServiceLogging(NuGetService instance)
        {
            // Start logging this service's events to azure storage
            var serviceEventStream = new ObservableEventListener();

            foreach (var source in instance.GetEventSources())
            {
                serviceEventStream.EnableEvents(source, TraceLevel);
            }

            var mergedEvents = Observable.Merge(
                serviceEventStream,
                _platformEventStream.Where(evt => Equals(ServiceName.GetCurrent(), instance.ServiceName)));

            mergedEvents.LogToWindowsAzureTable(
                instanceName: instance.ServiceName.ToString(),
                connectionString: Config.Storage.Primary.GetConnectionString(),
                tableAddress: "NG" + instance.ServiceName.Name + "Trace");

            // Trace Http Requests
            var httpEventStream = new ObservableEventListener();

            httpEventStream.EnableEvents(HttpTraceEventSource.Log, EventLevel.LogAlways);
            httpEventStream
            .Where(e => Equals(ServiceName.GetCurrent(), instance.ServiceName))
            .LogToWindowsAzureTable(
                instanceName: instance.ServiceName.ToString(),
                connectionString: Config.Storage.Primary.GetConnectionString(),
                tableAddress: "NG" + instance.ServiceName.Name + "Http");
        }
Example #3
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);
                }
            }
        }
        private void timer_elapsed(object sender, ElapsedEventArgs e)
        {
            _timer.Stop();

            this.Log().Info(() => "Checking for submitted packages.");

            var submittedPackagesUri = NuGetService.get_service_endpoint_url(_configurationSettings.PackagesUrl, SERVICE_ENDPOINT);

            var service = new FeedContext_x0060_1(submittedPackagesUri);

            // this only returns 40 results at a time but at least we'll have something to start with
            //todo: This is going to only check where the flag automated validation is not true.
            IList <V2FeedPackage> submittedPackages = service.Packages.Where(p => p.PackageTestResultStatus == null || p.PackageTestResultStatus == "Pending" || p.PackageTestResultStatus == "Unknown").or_empty_list_if_null().ToList();

            this.Log().Info("Pulled {0} packages in submitted status for review.".format_with(submittedPackages.Count));

            foreach (var package in submittedPackages)
            {
                this.Log().Info("{0} found in submitted state.".format_with(package.Title));
                EventManager.publish(new SubmitPackageMessage(package.Id, package.Version));
            }

            this.Log().Info(() => "Finished checking for submitted packages.");

            _timer.Start();
        }
Example #5
0
        protected void BindPackageListGrid()
        {
            switch (this.CurrentViewMode)
            {
            case ViewMode.Installed:
                liInstalled.AddCssClass("active");
                liAvailable.RemoveCssClass("active");
                gPackageList.DataSource = InstalledPackages.Where(p => !p.Id.StartsWith(rockUpdatePackageIdPrefix) || p.Id != rockPackageId).ToList();
                break;

            case ViewMode.Available:
                liInstalled.RemoveCssClass("active");
                liAvailable.AddCssClass("active");
                gPackageList.DataSource = AvailablePackages.Where(p => !p.Id.StartsWith(rockUpdatePackageIdPrefix) || p.Id != rockPackageId).ToList();
                break;

            case ViewMode.Search:
                liInstalled.RemoveCssClass("active");
                liAvailable.RemoveCssClass("active");
                gPackageList.DataSource = NuGetService.GetLatestRemotePackages(txtSearch.Text, includeAllVersions: false).Where(p => !p.Id.StartsWith(rockUpdatePackageIdPrefix) || p.Id != rockPackageId).ToList();
                break;

            default:
                break;
            }

            gPackageList.DataBind();
        }
 public ServiceInstanceModel(NuGetService service, object description, object status) : this()
 {
     Name          = service.ServiceName.ToString();
     Service       = service.ServiceName.Name;
     LastHeartbeat = service.LastHeartbeat;
     Description   = description;
     Status        = status;
 }
Example #7
0
    public CliCommand(ICmdHelper cmdHelper, NuGetService nuGetService, AbpNuGetIndexUrlService nuGetIndexUrlService)
    {
        _cmdHelper            = cmdHelper;
        _nuGetService         = nuGetService;
        _nuGetIndexUrlService = nuGetIndexUrlService;

        Logger = NullLogger <CliCommand> .Instance;
    }
Example #8
0
        private static async Task WriteNuGetDownloadsAsync()
        {
            string     packageId      = "Microsoft.Bcl.AsyncInterfaces";
            Task <int> task           = NuGetService.GetAsync(packageId, true, default);
            int        totalDownloads = await task;

            Console.WriteLine($"NuGet package '{packageId}' has {totalDownloads} total downloads");
        }
Example #9
0
 public NugetSourceCodeStore(
     NuGetService nuGetService,
     NugetPackageCacheManager nugetPackageCacheManager,
     ICmdHelper cmdHelper)
 {
     _nuGetService             = nuGetService;
     _nugetPackageCacheManager = nugetPackageCacheManager;
     _cmdHelper = cmdHelper;
 }
        protected override void Starting(NuGetService instance)
        {
            if (Config.Storage.Primary != null)
            {
                InitializeServiceLogging(instance);
            }

            base.Starting(instance);
        }
Example #11
0
 public SuiteCommand(
     AbpNuGetIndexUrlService nuGetIndexUrlService,
     NuGetService nuGetService,
     ICmdHelper cmdHelper,
     CliHttpClientFactory cliHttpClientFactory)
 {
     CmdHelper             = cmdHelper;
     _nuGetIndexUrlService = nuGetIndexUrlService;
     _nuGetService         = nuGetService;
     _cliHttpClientFactory = cliHttpClientFactory;
     Logger = NullLogger <SuiteCommand> .Instance;
 }
Example #12
0
        public CliService(
            ICommandLineArgumentParser commandLineArgumentParser,
            ICommandSelector commandSelector,
            IServiceScopeFactory serviceScopeFactory,
            NuGetService nugetService)
        {
            CommandLineArgumentParser = commandLineArgumentParser;
            CommandSelector           = commandSelector;
            ServiceScopeFactory       = serviceScopeFactory;
            NuGetService = nugetService;

            Logger = NullLogger <CliService> .Instance;
        }
        private ServiceVersionInformation CreateVersionInfo(NuGetService service)
        {
            var asmName = service.GetType().Assembly.GetName();
            var asmInfo = service.GetType().GetAssemblyInfo();

            return(new ServiceVersionInformation()
            {
                Version = asmInfo.SemanticVersion,
                Branch = asmInfo.BuildBranch,
                Commit = asmInfo.BuildCommit,
                BuildDateUtc = asmInfo.BuildDate.UtcDateTime
            });
        }
        private void timer_elapsed(object sender, ElapsedEventArgs e)
        {
            _timer.Stop();

            this.Log().Info(() => "Checking for packages to validate.");

            try
            {
                var submittedPackagesUri = NuGetService.get_service_endpoint_url(_configurationSettings.PackagesUrl, SERVICE_ENDPOINT);

                // such a fun, dynamically generated name
                var service = new FeedContext_x0060_1(submittedPackagesUri)
                {
                    Timeout = 70
                };

                var cdnCacheTimeout = DateTime.UtcNow.AddMinutes(-31);
                // this only returns 30-40 results at a time but at least we'll have something to start with
                IQueryable <V2FeedPackage> packageQuery =
                    service.Packages.Where(
                        p => p.Created < cdnCacheTimeout &&
                        (p.PackageValidationResultStatus == null || p.PackageValidationResultStatus == "Pending" || p.PackageValidationResultStatus == "Unknown")
                        );

                // specifically reduce the call to 30 results so we get back results faster from Chocolatey.org
                IList <V2FeedPackage> packagesToValidate = packageQuery.Take(30).ToList();
                if (packagesToValidate.Count == 0)
                {
                    this.Log().Info("No packages to validate.");
                }
                else
                {
                    this.Log().Info("Pulled in {0} packages for validation.".format_with(packagesToValidate.Count));
                }

                foreach (var package in packagesToValidate.or_empty_list_if_null())
                {
                    this.Log().Info(() => "========== {0} v{1} ==========".format_with(package.Id, package.Version));
                    this.Log().Info("{0} v{1} found for review.".format_with(package.Title, package.Version));
                    EventManager.publish(new ValidatePackageMessage(package.Id, package.Version));
                }
            }
            catch (Exception ex)
            {
                Bootstrap.handle_exception(ex);
            }

            this.Log().Info(() => "Finished checking for packages to validate. Sleeping for {0} minute(s).".format_with(TIMER_INTERVAL / 60000));

            _timer.Start();
        }
        protected override void Starting(NuGetService instance)
        {
            foreach (var source in instance.GetEventSources())
            {
                EventListener.EnableEvents(source, EventLevel.Informational);
            }

            base.Starting(instance);

            foreach (var eventSource in instance.GetEventSources())
            {
                EventListener.EnableEvents(eventSource, EventLevel.LogAlways);
            }
        }
Example #16
0
        private static async Task Main(string[] args)
        {
            var settings = new ScoreCommand.Settings {
                PackageName = "Newtonsoft.Json", PackageVersion = "12.0.3"
            };
            var nuGetService   = new NuGetService();
            var packageContext = new PackageContext(settings);

            packageContext.NuspecReader = await nuGetService.GetNuspecFromPackage(packageContext);

            packageContext.PackageMetadata = await nuGetService.GetNuGetPackageMetadataFromPackage(packageContext);

            var scoreService = new ScoreService();
            var score        = await scoreService.ScorePackage(packageContext);

            ScoreDumper.DumpScore(score);
        }
        private async void OnGetDownloads(object sender, RoutedEventArgs e)
        {
            string     packageId = PackageId.Text;
            Task <int> task      = NuGetService.GetAsync(packageId, true, cts.Token);

            try
            {
                int totalDownloads = await task.ConfigureAwait(false);

                await this;
                TotalDownloads.Text = $"{totalDownloads}";
            }
            catch (OperationCanceledException ex)
            {
                await Dispatcher.BeginInvoke((Action)(() => TotalDownloads.Text = ex.Message));
            }
        }
Example #18
0
        private void ChangePackage(CommandEventArgs e, string packageId, string version)
        {
            IEnumerable <string> errors = Enumerable.Empty <string>();

            switch (e.CommandName.ToLower())
            {
            case "uninstall":
            {
                var package = NuGetService.SourceRepository.FindPackage(packageId, (version != null) ? SemanticVersion.Parse(version) : null, false, false);
                errors = NuGetService.UninstallPackage(package, true);
            }
            break;

            case "install":
            {
                var package = NuGetService.SourceRepository.FindPackage(packageId, (version != null) ? SemanticVersion.Parse(version) : null, false, false);
                if (package != null)
                {
                    errors = NuGetService.InstallPackage(package);
                    //IEnumerable<IPackage> packagesRequiringLicenseAcceptance = NuGetService.GetPackagesRequiringLicenseAcceptance(package);
                }
                break;
            }

            case "update":
            {
                var installed = NuGetService.GetInstalledPackage(packageId);
                try
                {
                    var update = NuGetService.GetUpdate(installed);
                    errors = NuGetService.UpdatePackage(update);
                }
                catch (InvalidOperationException ex)
                {
                    errors.Concat(new[] { string.Format("There is a problem with {0}: {1}", installed.Title, ex.Message) });
                }
            }
            break;
            }

            if (errors != null && errors.Count() > 0)
            {
                nbMessage.Visible = true;
                nbMessage.Text    = errors.Aggregate(new StringBuilder("<ul>"), (sb, s) => sb.AppendFormat("<li>{0}</li>", s)).Append("</ul>").ToString();
            }
        }
Example #19
0
    private async Task <SemanticVersion> GetLatestVersion(UpdateChannel updateChannel)
    {
        switch (updateChannel)
        {
        case UpdateChannel.Stable:
            return(await NuGetService.GetLatestVersionOrNullAsync("Volo.Abp.Cli"));

        case UpdateChannel.Prerelease:
            return(await NuGetService.GetLatestVersionOrNullAsync("Volo.Abp.Cli", includeReleaseCandidates : true));

        case UpdateChannel.Nightly:
            return(await NuGetService.GetLatestVersionOrNullAsync("Volo.Abp.Cli", includeNightly : true));

        default:
            return(default);
        }
    }
        public NuGetServiceRuntime(NuGetService service)
        {
            var instanceId = Interlocked.Increment(ref _nextId) - 1;

            ServiceInstanceId.Set(instanceId);


            Service       = service;
            TempDirectory = Path.Combine(Path.GetTempPath(), "NuGetServices", serviceName, instanceId.ToString());


            ServiceInstanceName = String.Format(
                CultureInfo.InvariantCulture,
                "{0}_{1}_{2}",
                Service.Host.HostInstanceName,
                Service.Name,
                ServiceInstanceId.Get());
        }
Example #21
0
        public override async Task <int> ExecuteAsync(CommandContext context, Settings settings)
        {
            var nuGetService   = new NuGetService();
            var packageContext = new PackageContext(settings);

            //if packageContext does not have a version, we need to get latest version.
            //But let's make it required for now
            //then we can get the nuspec from the package.
            packageContext.NuspecReader = await nuGetService.GetNuspecFromPackage(packageContext);

            packageContext.PackageMetadata = await nuGetService.GetNuGetPackageMetadataFromPackage(packageContext);

            var scoreService = new ScoreService();
            var score        = await scoreService.ScorePackage(packageContext);

            ScoreDumper.DumpScore(score);
            //ScoreDumper.DumpSettings(settings);
            return(0);
        }
Example #22
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();
        }
Example #23
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();
        }
Example #24
0
 public VoloPackagesVersionUpdater(NuGetService nuGetService)
 {
     _nuGetService = nuGetService;
 }
Example #25
0
 public VoloNugetPackagesVersionUpdater(NuGetService nuGetService)
 {
     _nuGetService = nuGetService;
     Logger        = NullLogger <VoloNugetPackagesVersionUpdater> .Instance;
 }
Example #26
0
        private void timer_elapsed(object sender, ElapsedEventArgs e)
        {
            _timer.Stop();

            this.Log().Info(() => "Checking for packages to verify.");

            try
            {
                var submittedPackagesUri = NuGetService.get_service_endpoint_url(_configurationSettings.PackagesUrl, ServiceEndpoint);

                var lastPackage = string.Empty;

                //for (var i = 0; i < 10; i++)
                //{
                this.Log().Info(() => "Grabbing next available package for verification.");

                var service = new FeedContext_x0060_1(submittedPackagesUri)
                {
                    Timeout = 70
                };

                var cacheTimeout = DateTime.UtcNow.AddMinutes(-31);
                // this only returns 40 results at a time but at least we'll have something to start with
                IQueryable <V2FeedPackage> packageQuery =
                    service.Packages.Where(p => p.Created < cacheTimeout);

                if (AdditionalPackageSelectionFilters != null)
                {
                    packageQuery = AdditionalPackageSelectionFilters.Invoke(packageQuery);
                }

                //int total = packageQuery.Count();
                //packageQuery = packageQuery.Where(p => p.Id == "");

                packageQuery = packageQuery.OrderBy(p => p.Created);

                // let's specifically reduce the call to 30 results so we get back results faster from Chocolatey.org
                IList <V2FeedPackage> packagesToValidate = packageQuery.Take(30).ToList();

                if (packagesToValidate.Count == 0)
                {
                    this.Log().Info("No packages to verify.");
                    //break;
                }

                //remove the random for now, we'll just grab the top result
                //this.Log().Info("Pulled in {0} packages, picking one at random to verify.".format_with(packagesToValidate.Count));

                //var skip = new Random().Next(packagesToValidate.Count);
                //if (skip < 0) skip = 0;
                //packagesToValidate = packagesToValidate.Skip(skip).Take(1).ToList();

                //var package = packagesToValidate.FirstOrDefault();
                //if (package == null) continue;

                //var packageId = "{0}:{1}".format_with(package.Id, package.Version);
                //if (lastPackage == packageId)
                //{
                //    this.Log().Info("Already verified {0} v{1} recently.".format_with(package.Title, package.Version));
                //    continue;
                //}
                //lastPackage = packageId;

                //this.Log().Info("{0} v{1} found for review.".format_with(package.Title, package.Version));
                //EventManager.publish(new VerifyPackageMessage(package.Id, package.Version));

                foreach (var package in packagesToValidate.or_empty_list_if_null())
                {
                    this.Log().Info("{0} v{1} found for review.".format_with(package.Title, package.Version));
                    EventManager.publish(new VerifyPackageMessage(package.Id, package.Version));
                }
                // }
            }
            catch (Exception ex)
            {
                Bootstrap.handle_exception(ex);
            }

            this.Log().Info(() => "Finished checking for packages to verify. Sleeping for {0} minutes.".format_with(TIMER_INTERVAL / 60000));

            _timer.Start();
        }
Example #27
0
 public SuiteCommand(AbpNuGetIndexUrlService nuGetIndexUrlService, NuGetService nuGetService)
 {
     _nuGetIndexUrlService = nuGetIndexUrlService;
     _nuGetService         = nuGetService;
     Logger = NullLogger <SuiteCommand> .Instance;
 }
 public VoloNugetPackagesVersionUpdater(NuGetService nuGetService, MyGetPackageListFinder myGetPackageListFinder)
 {
     _nuGetService           = nuGetService;
     _myGetPackageListFinder = myGetPackageListFinder;
     Logger = NullLogger <VoloNugetPackagesVersionUpdater> .Instance;
 }
Example #29
0
        private void timer_elapsed(object sender, ElapsedEventArgs e)
        {
            _timer.Stop();

            this.Log().Info(() => "Checking for packages to cleanup (remind/reject).");

            try
            {
                var submittedPackagesUri = NuGetService.get_service_endpoint_url(_configurationSettings.PackagesUrl, SERVICE_ENDPOINT);

                // such a fun, dynamically generated name
                var service = new FeedContext_x0060_1(submittedPackagesUri)
                {
                    Timeout = 70
                };

                var twentyDaysAgo = DateTime.UtcNow.AddDays(-20);

                // this only returns 30-40 results at a time but at least we'll have something to start with

                //this is not a perfect check but will capture most of the items that need cleaned up.
                IQueryable <V2FeedPackage> packageQuery =
                    service.Packages.Where(
                        p => p.Created < twentyDaysAgo &&
                        p.PackageStatus == "Submitted" &&
                        p.PackageSubmittedStatus == "Waiting" &&
                        (p.PackageCleanupResultDate == null) &&
                        ((p.PackageReviewedDate != null && p.PackageReviewedDate < twentyDaysAgo)
                         ||
                         (p.PackageReviewedDate == null && p.PackageTestResultStatusDate < twentyDaysAgo)
                        )
                        );

                //int totalCount = packageQuery.Count();

                // specifically reduce the call to 30 results so we get back results faster from Chocolatey.org
                IList <V2FeedPackage> packages = packageQuery.Take(30).ToList();
                if (packages.Count == 0)
                {
                    this.Log().Info("No packages to remind.");
                }
                else
                {
                    this.Log().Info("Pulled in {0} packages for reminders.".format_with(packages.Count));
                }

                foreach (var package in packages.or_empty_list_if_null())
                {
                    this.Log().Info(() => "========== {0} v{1} ==========".format_with(package.Id, package.Version));
                    this.Log().Info("{0} v{1} found for review.".format_with(package.Title, package.Version));
                    EventManager.publish(new ReminderPackageMessage(package.Id, package.Version));
                }

                var fifteenDaysAgo = DateTime.UtcNow.AddDays(-15);
                IQueryable <V2FeedPackage> packageQueryForReject =
                    service.Packages.Where(
                        p => p.PackageCleanupResultDate < fifteenDaysAgo &&
                        p.PackageStatus == "Submitted" &&
                        p.PackageSubmittedStatus == "Waiting"
                        );

                // specifically reduce the call to 30 results so we get back results faster from Chocolatey.org
                IList <V2FeedPackage> packagesForReject = packageQueryForReject.Take(30).ToList();
                if (packagesForReject.Count == 0)
                {
                    this.Log().Info("No packages to reject.");
                }
                else
                {
                    this.Log().Info("Pulled in {0} packages for rejection.".format_with(packages.Count));
                }

                foreach (var package in packagesForReject.or_empty_list_if_null())
                {
                    this.Log().Info(() => "========== {0} v{1} ==========".format_with(package.Id, package.Version));
                    this.Log().Info("{0} v{1} found for review.".format_with(package.Title, package.Version));
                    EventManager.publish(new RejectPackageMessage(package.Id, package.Version));
                }
            }
            catch (Exception ex)
            {
                Bootstrap.handle_exception(ex);
            }

            this.Log().Info(() => "Finished checking for packages to cleanup. Sleeping for {0} minute(s).".format_with(TIMER_INTERVAL / 60000));

            _timer.Start();
        }
Example #30
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();
            }
        }