public static async Task Run(TimerInfo myTimer, IAsyncCollector <IndexPackageRequest> processPackageQueue, TextWriter log)
        {
            var table = new PackageTable();
            var mutex = new AzureLock(Config.CreateCloudBlobClient().GetContainerReference("locks").GetBlockBlobReference("nugetwalker"));

            using (await mutex.LockAsync())
            {
                // Parse the entire catalog, until the bookmark.
                var actions = await InspectCatalogAsync(table, log);

                log.WriteLine("Done examining catalog; found: " + actions.PackagesToProcess.Count);

                // In catalog order (oldest page to newest page), place all the messages in the queue and then update the table entries.
                foreach (var group in actions.PackagesToProcess.GroupBy(x => x.Page).OrderBy(x => x.Key))
                {
                    foreach (var action in group)
                    {
                        await processPackageQueue.AddAsync(new IndexPackageRequest
                        {
                            PackageId      = action.LowercasePackageId,
                            PackageVersion = action.PackageVersion.ToString(),
                        });
                    }
                    await processPackageQueue.FlushAsync();

                    foreach (var action in group)
                    {
                        await table.SetVersionAsync(action.LowercasePackageId, action.PackageVersion, action.CommitId);
                    }
                }
            }
        }
Пример #2
0
        private static async Task MainAsync()
        {
            await Task.WhenAll(CreateIndexAsync(),
                               CreateQueueAsync(Config.ProcessPackageQueueName),
                               PackageTable.InitializeAsync());

            //PopulateTestPackages();
        }
Пример #3
0
 public AzureStorageFeed(string feedName, CloudTable table, CloudBlobContainer container, AzureQueryCache <PackageName> queryCache)
 {
     this.feedName    = feedName;
     this.table       = table;
     this.container   = container;
     this.queryCache  = queryCache;
     packageTable     = new PackageTable(table);
     packageContainer = new PackageBlobContainer(container);
     symbolContainer  = new SymbolBlobContainer(container);
     sourceContainer  = new SourceBlobContainer(container);
 }
Пример #4
0
 public AzurePackageStorageItem(
     AzureStorageFeed feed,
     PackageTable table, PackageBlobContainer container, string userName,
     PackageState packageState, PackageName packageName)
 {
     this.feed         = feed;
     this.table        = table;
     this.container    = container;
     this.userName     = userName;
     this.packageState = packageState;
     this.packageName  = packageName;
 }
Пример #5
0
        // GET: CarReservations/Create
        public ActionResult FormRenter(int?id, int days, int rentType, int meals, int fuel, int pkg)
        {
            DateTime today = DateTime.Now;

            today = TimeZoneInfo.ConvertTimeBySystemTimeZoneId(today, TimeZoneInfo.Local.Id, "Singapore Standard Time");

            int          Authorize      = HttpContext.User.Identity.Name == "" ? 0 : 1;
            PackageTable PackageSummary = carRsv.getPackageSummary((int)id, days, rentType, meals, fuel, pkg, Authorize);

            CarReservation reservation = new CarReservation();

            reservation.DtTrx        = today;
            reservation.DtStart      = today.AddDays(2).ToString();
            reservation.DtEnd        = today.AddDays(4).ToString();
            reservation.JobRefNo     = 0;
            reservation.SelfDrive    = 0; //with driver = 0, self drive = 1;
            reservation.EstHrPerDay  = 10;
            reservation.EstKmTravel  = 100;
            reservation.Destinations = db.CarRatePackages.Find(pkg).Description;
            reservation.UseFor       = db.CarRatePackages.Find(pkg).Description;
            reservation.BaseRate     = PackageSummary.Rate.ToString();

            //get previous id
            CarReservation lastId = db.CarReservations.ToList().OrderByDescending(c => c.Id).LastOrDefault();

            CarRatePackage selfDrive = db.CarRatePackages.Find(1);

            ViewBag.CarUnitId = new SelectList(db.CarUnits, "Id", "Description", id);
            //get last reservation id
            ViewBag.RsvId = lastId != null ?  lastId.Id + 1 : 1;
            ViewBag.id    = id;
            ViewBag.fuel  = fuel;
            ViewBag.meals = meals;
            ViewBag.pkgId = pkg;

            ViewBag.DtStart = today.AddDays(2);
            ViewBag.DtEnd   = today.AddDays(3);

            //except self drive package
            ViewBag.PackagesDesc = db.CarRatePackages.Find(pkg).Description;

            return(View(reservation));
        }
Пример #6
0
        public ActionResult FormSummary(int carId, int days, int rentType, int meals, int fuel, int pkg)
        {
            int isAuthorize = HttpContext.User.Identity.Name == "" ? 0 : 1;

            fuel  = fuel == 0 ? 0 : 1;
            meals = meals == 0 ? 0 : 1;
            PackageTable PackageSummary = carRsv.getPackageSummary(carId, days, rentType, meals, fuel, pkg, isAuthorize);

            ViewBag.carId       = carId;
            ViewBag.carDesc     = db.CarUnits.Find(carId).Description;
            ViewBag.days        = days;
            ViewBag.RentType    = rentType;
            ViewBag.RentTypeTxt = getRentType(rentType);
            ViewBag.meals       = meals;
            ViewBag.fuel        = fuel;
            ViewBag.pkg         = pkg;

            ViewBag.Unit = db.CarUnits.Find(carId).Description;

            return(View("FormSummary", PackageSummary));
        }
Пример #7
0
 // Use this for initialization
 void Start()
 {
     packageTableCom = GameObject.Find("PackageTable").GetComponent <PackageTable>();
 }
Пример #8
0
	// Use this for initialization
	void Start () {
		packageTableCom = GameObject.Find("PackageTable").GetComponent<PackageTable>();
	}
        private static async Task <Results> InspectCatalogAsync(PackageTable table, TextWriter log)
        {
            var ignoredDueToPlatform = new List <PackageEntryBase>();
            var result = new Results();
            var index  = await ServiceIndex.CreateAsync();

            var catalog = await index.GetCatalogAsync();

            var bookmarkFound = false;

            // Catalog page 1532 contains the first library that supported netstandard: csharp2colorized 1.0.0-beta1
            for (int i = catalog.Items.Count - 1; i >= 1532; --i)
            {
                var page = await catalog.Items[i].GetCatalogPageAsync();
                foreach (var pageItem in page.Items)
                {
                    // Parse the version.
                    NuGetVersion version;
                    if (!NuGetVersion.TryParse(pageItem.Version, out version))
                    {
                        log.WriteLine("Unable to parse version: " + pageItem.Id + " " + pageItem.Version);
                        continue;
                    }

                    // Generate the key (id + prerelease flag).
                    var lowercasePackageId = pageItem.Id.ToLowerInvariant();
                    var key = lowercasePackageId + (version.IsPrerelease ? "1" : "0");

                    // Check to see if we have a newer in-memory entry already processed for this key.
                    var resultExisting = result.PackagesToProcess.FirstOrDefault(x => x.Key == key);
                    if (resultExisting != null && version <= resultExisting.PackageVersion)
                    {
                        log.WriteLine("Already going to process " + resultExisting.PackageVersion + ": " + pageItem.Id + " " + pageItem.Version);
                        continue;
                    }

                    // Check to see if we have a newer in-memory ignored entry already processed for this key.
                    var ignoredExisting = ignoredDueToPlatform.FirstOrDefault(x => x.Key == key);
                    if (ignoredExisting != null && version <= ignoredExisting.PackageVersion)
                    {
                        log.WriteLine("Already ignored due to platform: " + pageItem.Id + " " + pageItem.Version);
                        continue;
                    }

                    // Look up the existing table entry, if any.
                    var existing = await table.TryGetVersionCommitAsync(pageItem.Id, pageItem.Version);

                    // If the existing table entry is this same exact commit, then we're done.
                    if (existing != null && string.Equals(existing.CommitId, pageItem.CommitId, StringComparison.InvariantCultureIgnoreCase))
                    {
                        log.WriteLine("Already processed: " + pageItem.Id + " " + pageItem.Version + " at " + pageItem.CommitId);
                        bookmarkFound = true;
                        continue;
                    }

                    // If the existing table entry is newer than this one, then skip this one.
                    //  (This can only happen if NuGet packages are published out of order. Which *does* seem to happen!)
                    if (existing?.Version != null && version <= NuGetVersion.Parse(existing.Version))
                    {
                        log.WriteLine("Ignoring due to existing version " + existing.Version + ": " + pageItem.Id + " " + pageItem.Version);
                        continue;
                    }

                    // Ensure the package supports netstandard.
                    var package = await pageItem.GetPackageAsync();

                    var frameworks = package.Metadata().GetSupportedFrameworksWithRef().ToArray();
                    if (!frameworks.Any(x => new FrameworkName(x.DotNetFrameworkName).IsNetStandard()))
                    {
                        log.WriteLine("Ignoring due to platform: " + pageItem.Id + " " + pageItem.Version);
                        if (ignoredExisting != null)
                        {
                            ignoredExisting.PackageVersion = version;
                        }
                        else
                        {
                            ignoredDueToPlatform.Add(new PackageEntryBase(lowercasePackageId, version));
                        }
                        continue;
                    }

                    // Add a process request.
                    log.WriteLine("Will process: " + pageItem.Id + " " + pageItem.Version);
                    result.PackagesToProcess.Add(new PackageEntry(i, pageItem.CommitId, lowercasePackageId, version));
                }

                if (bookmarkFound)
                {
                    return(result);
                }
            }
            return(result);
        }