public UploadToScreenshots(Uri oneTrueHost, string apiKey, string sharedSecret) { if (string.IsNullOrEmpty(apiKey)) { throw new ArgumentNullException("apiKey"); } if (string.IsNullOrEmpty(sharedSecret)) { throw new ArgumentNullException("sharedSecret"); } if (oneTrueHost.AbsolutePath.Contains("/receiver/")) { throw new ArgumentException( "The OneTrueError URI should not contain the reporting area '/receiver/', but should point at the site root."); } if (!oneTrueHost.AbsolutePath.EndsWith("/")) { oneTrueHost = new Uri(oneTrueHost + "/"); } _reportUri = new Uri(oneTrueHost, "syscoreapi/screenshots/" + apiKey + "/"); _apiKey = apiKey; _sharedSecret = sharedSecret; _reportQueue = new UploadQueue <UploadToScreenshotsDTO>(TryUploadReportNow); _reportQueue.UploadFailed += OnUploadFailed; }
private async Task <bool> RunQueuedUserProfileUpdate(UploadQueue q) { var webAPIDataService = GetWebAPIDataService(Consts.AUTHORIZED); if (webAPIDataService == null) { Analytics.TrackEvent("FATAL: RunQueuedUserProfileUpdate webAPIDataService == null"); return(false); } var record = await _conn.Table <UserProfile>().Where(x => x.UserProfileId == q.RecordIdInt).FirstOrDefaultAsync(); if (record != null) { var result = await webAPIDataService.UpdateUserProfileAsync(record.ToDto()); if (result.IsSuccessStatusCode) { Debug.WriteLine($"Successfully Sent Queued User Record"); return(true); } else if (result.StatusCode == System.Net.HttpStatusCode.Conflict) { Analytics.TrackEvent($"Conflict Sending Queued User record {q.RecordIdInt}"); } Analytics.TrackEvent($"Error Sending Queued User record {q.RecordIdInt}"); return(false); } return(false); }
internal MParticle(Configuration configuration) { Configuration = new Configuration(configuration); _apiClient = new ApiClient(Configuration); _uploadQueue = new UploadQueue(this); _uploadQueue.StartUploadLoop(); }
public async Task QueueAsync(int recordId, QueueableObjects objName) { try { UploadQueue queue = new UploadQueue() { UploadQueueId = Guid.NewGuid(), RecordIdGuid = null, RecordIdInt = recordId, RecordIdStr = null, QueueableObject = objName.ToString(), DateQueued = DateTime.UtcNow, NumAttempts = 0, Success = false }; int count = await _conn.InsertOrReplaceAsync(queue); Debug.WriteLine($"Queued {recordId} of type {objName}"); } catch (Exception ex) { Crashes.TrackError(ex); Debug.WriteLine($"Error in {nameof(QueueAsync)}"); } }
/// <summary> /// Dispose pattern /// </summary> /// <param name="isDisposing">Invoked from the dispose method.</param> protected virtual void Dispose(bool isDisposing) { if (_reportQueue != null) { _reportQueue.Dispose(); _reportQueue = null; } }
public void should_invoke_Background_job() { var uploadIsInvoked = false; var sut = new UploadQueue <string>(x => uploadIsInvoked = true); sut.ActivateSync = true; sut.Add("hello"); sut.Wait(100); sut.TaskWasInvoked.Should().BeTrue(); }
public ContributionEditorDialogViewModel() { if (DesignMode.DesignModeEnabled || DesignMode.DesignMode2Enabled) { Types = DesignTimeHelpers.GenerateContributionTypes(); Visibilities = DesignTimeHelpers.GenerateVisibilities(); UploadQueue = DesignTimeHelpers.GenerateContributions(); SelectedContribution = UploadQueue.FirstOrDefault(); } RemoveAdditionalTechAreaCommand = new DelegateCommand <ContributionTechnologyModel>(RemoveAdditionalArea); }
private void Tallenna_Click(object sender, RoutedEventArgs e) { var tournament = (TrackableTournament)TournamentList.SelectedItem; if (tournament.Tracking && tournament.Name != tournament.Tournament.Name) { UploadEvent ev = new UploadEvent(() => _uploader.UploadName(tournament.Tournament.SanctionNumber, tournament.Name), tournament.Tournament.WithName(tournament.Name), UploadEvent.Type.Name, 0); UploadQueue.Enqueue(ev); tournament.Tournament = tournament.Tournament.WithName(tournament.Name); } }
private static (UploadQueue queue, Mocks mocks) GetFixture(Options options = null) { var mocks = new Mocks(options); mocks.UserService.Setup(m => m.GetGroup(It.IsAny <string>())) .Returns(Application.DefaultGroup); var queue = new UploadQueue( mocks.UserService.Object, mocks.OptionsMonitor); return(queue, mocks); }
public void should_throw_new_entries_if_queue_is_full() { var failed = false; var sut = new UploadQueue <string>(x => Thread.Sleep(100)); sut.MaxQueueSize = 1; sut.ActivateSync = true; sut.Add("hello"); sut.UploadFailed += (o, e) => failed = true; sut.Add("hello"); failed.Should().BeTrue(); }
public void should_invoke_directly_if_queue_is_empty() { var uploadIsInvoked = false; var directly = false; var sut = new UploadQueue <string>(x => uploadIsInvoked = true); sut.ActivateSync = true; sut.AddIfNotEmpty("hello", () => directly = true); sut.Wait(100); directly.Should().BeTrue("because queue is empty"); uploadIsInvoked.Should() .BeFalse( "because it should not be invoked if a task is supplied as an argument and the queue was empty."); }
public void should_throw_new_entries_if_queue_is_full() { var failed = false; var sut = new UploadQueue <string>(x => Task.Delay(1000).Wait()) { MaxQueueSize = 1, ActivateSync = true }; sut.Enqueue("hello"); sut.UploadFailed += (o, e) => failed = true; sut.Enqueue("hello"); failed.Should().BeTrue(); }
public UploadService( IUserService userService, ISoulseekClient soulseekClient, IOptionsMonitor <Options> optionsMonitor, IShareService shareService, IDbContextFactory <TransfersDbContext> contextFactory) { Users = userService; Client = soulseekClient; Shares = shareService; ContextFactory = contextFactory; OptionsMonitor = optionsMonitor; Governor = new UploadGovernor(userService, optionsMonitor); Queue = new UploadQueue(userService, optionsMonitor); }
public void should_not_invoke_Failed_report_if_upload_is_successful() { var sut = new UploadQueue <string>(x => { }) { ActivateSync = true, RetryInterval = TimeSpan.FromMilliseconds(10), MaxAttempts = 3 }; var failed = false; sut.UploadFailed += (sender, args) => failed = true; sut.Enqueue("hello"); sut.Wait(1000); failed.Should().BeFalse(); }
private void Poista_Click(object sender, RoutedEventArgs e) { var tournament = (TrackableTournament)TournamentList.SelectedItem; var confirm = MessageBox.Show( "Haluatko varmasti poistaa turnauksen " + tournament.Tournament.SanctionNumber + " " + tournament.Name + "?", "Oletko varma?", MessageBoxButton.YesNo); if (confirm == MessageBoxResult.Yes) { tournament.Tracking = false; tournament.TournamentUploaded = false; UploadEvent ev = new UploadEvent(() => _uploader.DeleteTournament(tournament.Tournament.SanctionNumber), tournament.Tournament, UploadEvent.Type.DeleteTournament, 0); UploadQueue.Enqueue(ev); } }
private static void AddFileToQueue(FileObject fileObject) { var file = new UploadQueue { FileID = fileObject.FileId, OriginalFileName = fileObject.FileName, FileLocation = fileObject.Uri, ContentType = "application/zip", //TODO: I should try and actually figure out what the ContentType is. ContentSize = fileObject.FileSize, UserKey = "61e8b5db-d076-44c3-914d-05e37cef4abd", UserIP = "0.0.0.0", UploadedDate = DateTime.Now, Processing = false }; UploadQueueController.AddItemToQueue(file); }
public void should_retry_if_upload_fails() { int attempts = 0; var sut = new UploadQueue <string>(x => { attempts++; throw new NotSupportedException("we need more power"); }); sut.ActivateSync = true; sut.RetryInterval = TimeSpan.FromMilliseconds(10); sut.Add("hello"); sut.Wait(1000); attempts.Should().BeGreaterThan(1); }
public AddContributionsViewModel() { if (DesignMode.DesignModeEnabled || DesignMode.DesignMode2Enabled) { Types = DesignTimeHelpers.GenerateContributionTypes(); Visibilities = DesignTimeHelpers.GenerateVisibilities(); UploadQueue = DesignTimeHelpers.GenerateContributions(); SelectedContribution = UploadQueue.FirstOrDefault(); return; } EditQueuedContributionCommand = new DelegateCommand <ContributionsModel>(async cont => await EditContribution(cont)); RemoveQueuedContributionCommand = new DelegateCommand <ContributionsModel>(async cont => await RemoveContribution(cont)); RemoveAdditionalTechAreaCommand = new DelegateCommand <ContributionTechnologyModel>(RemoveAdditionalArea); UploadQueue.CollectionChanged += UploadQueue_CollectionChanged; }
private void ProcessNextUploadFile() { try { var current = UploadQueue.FirstOrDefault(u => u.UploadStatus == FileUploadStatus.Queued); if (current == null) { return; } current.OnUploadCompleted += Current_OnUploadCompleted; current.StartUpload(); } catch (Exception ex) { MessageBox.Show(ex.ToString()); } }
public void should_not_invoke_directly_if_queue_got_items() { var uploadIsInvoked = false; var directly = false; var sut = new UploadQueue <string>(x => { uploadIsInvoked = true; Task.Delay(50).Wait(); }); sut.Enqueue("precondition"); sut.ActivateSync = true; sut.EnqueueIfNotEmpty("hello", () => directly = true); sut.Wait(10000); directly.Should().BeFalse("because there is an active worker"); uploadIsInvoked.Should() .BeTrue( "because it should be invoked even if a task is supplied as an argument when the queue is not empty"); }
public void should_throw_report_after_max_attempts() { int attempts = 0; var sut = new UploadQueue <string>(x => { attempts++; throw new NotSupportedException("we need more power"); }); sut.ActivateSync = true; sut.RetryInterval = TimeSpan.FromMilliseconds(10); sut.MaxAttempts = 3; bool failed = false; sut.UploadFailed += (sender, args) => failed = true; sut.Add("hello"); sut.Wait(1000); failed.Should().BeTrue(); }
public static void LogMessage(UploadQueue uploadQueue, MessageList message) { LogMessage(uploadQueue.FileID, uploadQueue.UserKey, message); }
//delete public static void RemoveItemFromQueue(UploadQueue queue) { EVSDatabase.Delete("UploadQueue", "UploadQueueID", queue); UpdateItemQueueStatus(); }
//create public static void AddItemToQueue(UploadQueue queue) { EVSDatabase.Insert("UploadQueue", "UploadQueueID", true, queue); UpdateItemQueueStatus(); }
private static void Process(UploadQueue itemToProcess) { var p = new Package(); var error = false; try { //Trace.WriteLine("Found an item to process", "Information"); Messages.LogMessage(itemToProcess, MessageList.Start); //move the file to local server storage var tempFile = FileHelpers.MoveBlobToTempStorage(itemToProcess.FileLocation); Messages.LogMessage(itemToProcess, MessageList.LocalStorage); //build a new 'package' object p.Path = tempFile; if (p.Messages == null) { p.Messages = new List <VerificationMessage>(); } //unzip the package var fz = new FastZip(); var shortpath = Environment.GetEnvironmentVariable("ShortRootPath") ?? Path.GetTempPath(); var tempPath = Path.Combine(shortpath, Guid.NewGuid().ToString()); //Trace.WriteLine("Package location: " + tempPath); Directory.CreateDirectory(tempPath); p.ExtractedPath = tempPath; try { using (var stm = new FileStream(p.Path, FileMode.Open)) { fz.ExtractZip(stm, tempPath, FastZip.Overwrite.Always, null, null, null, true, true); } } catch (Exception exc) { error = true; Trace.TraceError("Error while extracting file."); Trace.TraceError(exc.Message); if (exc.InnerException != null) { Trace.TraceError(exc.InnerException.Message); } p.Messages.Add(new VerificationMessage { Message = "Problem encountered while attempting to extract uploaded file.", MessageId = new Guid("9ac011fa-08dd-4e26-91ba-0af7d5daf482"), MessageType = MessageTypes.SystemError, Rule = "Extraction" }); goto Cleanup; } Messages.LogMessage(itemToProcess, MessageList.UnZipped); Messages.LogMessage(itemToProcess, MessageList.Processing); p.Messages.AddRange(new PackageExists().ApplyRule(p)); p.Messages.AddRange(new MinPackageSize().ApplyRule(p)); p.Messages.AddRange(new ManifestFileExists().ApplyRule(p)); p.Messages.AddRange(new ManifestIsXML().ApplyRule(p)); foreach (var manifest in p.DNNManifests) { p.Messages.AddRange(new CorrectTypeAndVersion().ApplyRule(p, manifest)); switch (manifest.ManifestType) { case ManifestTypes.Package: p.Messages.AddRange(new PackageNodeAndChildren().ApplyRule(p, manifest)); p.Messages.AddRange(new PackageOwner().ApplyRule(p, manifest)); p.Messages.AddRange(new AssemblyNode().ApplyRule(p, manifest)); p.Messages.AddRange(new AuthenticationSystemNode().ApplyRule(p, manifest)); p.Messages.AddRange(new DashboardControlNode().ApplyRule(p, manifest)); p.Messages.AddRange(new CleanupNode().ApplyRule(p, manifest)); p.Messages.AddRange(new ConfigNode().ApplyRule(p, manifest)); p.Messages.AddRange(new FileNode().ApplyRule(p, manifest)); p.Messages.AddRange(new ModuleNode().ApplyRule(p, manifest)); p.Messages.AddRange(new SkinNode().ApplyRule(p, manifest)); p.Messages.AddRange(new SkinObjectNode().ApplyRule(p, manifest)); p.Messages.AddRange(new ContainerNode().ApplyRule(p, manifest)); p.Messages.AddRange(new CoreLanguageNode().ApplyRule(p, manifest)); p.Messages.AddRange(new ExtensionLanguageNode().ApplyRule(p, manifest)); p.Messages.AddRange(new ResourceFileNode().ApplyRule(p, manifest)); p.Messages.AddRange(new ScriptNode().ApplyRule(p, manifest)); p.Messages.AddRange(new WidgetNode().ApplyRule(p, manifest)); break; case ManifestTypes.Module: p.Messages.AddRange(new FolderNodeAndChildren().ApplyRule(p, manifest)); p.Messages.AddRange(new FileNode().ApplyRule(p, manifest)); p.Messages.AddRange(new ModuleNode().ApplyRule(p, manifest)); p.Messages.AddRange(new ProcessScripts().ApplyRule(p, manifest)); break; } Messages.LogMessage(itemToProcess, MessageList.TwoWayFileChecker); //Trace.WriteLine("Running two-way file checker.", "Information"); p.Messages.AddRange(new TwoWayFileChecker().ApplyRule(p, manifest)); Messages.LogMessage(itemToProcess, MessageList.AssemblyChecker); //Trace.WriteLine("Running assembly checker.", "Information"); const string assemblyInfoFile = @"collection.xml"; p.MinDotNetVersion = ProcessAssembly.GetMinDotNetFramework(p.Assemblies).VersionName; p.MinDotNetNukeVersion = ProcessAssembly.GetMinDotNetNukeVersion(p.Assemblies, assemblyInfoFile).Name; Messages.LogMessage(itemToProcess, MessageList.SQLChecker); //Trace.WriteLine("Running SQL scanner.", "Information"); p.Messages.AddRange(new SQLTestRunner().ApplyRule(p, manifest)); } p.Messages.AddRange(new FileEncodingChecker().ApplyRule(p)); p.Messages.AddRange(new DependencyChecker().ApplyRule(p)); Messages.LogMessage(itemToProcess, MessageList.BuildingOutput); //Let's process the SQL output if there is any. if (p.SQLOutputPath != null) { var tempPathForZip = Path.Combine(Path.GetTempPath(), Guid.NewGuid().ToString()); Directory.CreateDirectory(tempPathForZip); var filename = itemToProcess.FileID + ".zip"; var destination = tempPathForZip + "\\" + filename; var zipInputStream = File.Create(destination); using (zipInputStream) { fz.CreateZip(zipInputStream, p.SQLOutputPath, true, "", ""); } var zipStream = File.Open(destination, FileMode.Open); using (zipStream) { var storageAccount = CloudStorageAccount.Parse(RoleEnvironment.GetConfigurationSettingValue(Constants.ConfigurationSectionKey)); var blobClient = storageAccount.CreateCloudBlobClient(); var container = blobClient.GetContainerReference(Constants.ContainerNameScripts); container.CreateIfNotExists(); var file = container.GetBlockBlobReference(filename); file.UploadFromStream(zipStream); } try { File.Delete(destination); } catch (Exception exc) { error = true; Trace.TraceError("Error while deleting temp SQL output files."); Trace.TraceError(exc.Message); if (exc.InnerException != null) { Trace.TraceError(exc.InnerException.Message); } } } //clean up Cleanup: try { File.Delete(tempFile); //remove the temp file from the server. DeleteDirectory(p.ExtractedPath); //remove the extracted folder from the server. if (p.SQLOutputPath != null) { DeleteDirectory(p.SQLOutputPath); } } catch (Exception exc) { error = true; Trace.TraceError("Error while deleting temp files."); Trace.TraceError(exc.Message); if (exc.InnerException != null) { Trace.TraceError(exc.InnerException.Message); } } } catch (Exception exc) { error = true; Trace.TraceError("Error while processing extension."); Trace.TraceError(exc.Message); Trace.TraceError(exc.StackTrace); if (exc.InnerException != null) { Trace.TraceError(exc.InnerException.Message); } } finally { UploadQueueController.RemoveItemFromQueue(itemToProcess); //remove the item from the queue. if (itemToProcess.UserKey != "44eb5af6-2205-488e-9985-f7204c268820") { FileHelpers.RemoveBlob(itemToProcess.FileLocation); //this will remove the file from blob storage. } var extension = new Extension(itemToProcess); ExtensionController.AddExtension(extension); ProcessResults(p, extension.ExtensionID, error); //report to the status service that this file has finished processing. Messages.LogMessage(itemToProcess, MessageList.Finish); } }
/// <summary> /// 29/01/2015 /// 1) Create update files list /// 2) Create queue upload list. Iterating file list foreach connection ( i can have multiple cloud storage ) /// 3) Start async upload. /// </summary> internal void BeginUpdatedFiles(int mode) { // ? -> Set IsEnabled = false on GUI to prevent change during upload ? var releasesPath = SquirrelOutputPath; if (!Directory.Exists(releasesPath)) { throw new Exception("Releases directory " + releasesPath + "not finded !"); } if (SelectedConnection == null) { throw new Exception("No selected upload location !"); } /* I tried picking file to update, by their LastWriteTime , but it doesn't works good. I don't know why. * * So i just pick these file by their name * */ var fileToUpdate = new List <string>() { "RELEASES", string.Format("{0}-{1}-delta.nupkg", AppId, Version), }; if (mode == 0) { fileToUpdate.Add(string.Format("Setup.exe")); // fileToUpdate.Add(string.Format("{0}-{1}-full.nupkg", AppId, Version)); } var updatedFiles = new List <FileInfo>(); foreach (var fp in fileToUpdate) { var ffp = releasesPath + fp; if (!File.Exists(ffp)) { continue; } updatedFiles.Add(new FileInfo(ffp)); } if (UploadQueue == null) { UploadQueue = new ObservableCollection <SingleFileUpload>(); } UploadQueue.Clear(); var WebConnections = new List <WebConnectionBase>() { SelectedConnection }; foreach (var connection in WebConnections) { foreach (var file in updatedFiles) { UploadQueue.Add(new SingleFileUpload() { Filename = Path.GetFileName(file.FullName), ConnectionName = connection.ConnectionName, FileSize = BytesToString(file.Length), Connection = connection, FullPath = file.FullName, }); } } if (!CheckInternetConnection.IsConnectedToInternet()) { throw new Exception("Internet Connection not available"); } ProcessNextUploadFile(); }
public override Task ExecutePostProcessingAsync() { foreach (var fileData in FileData) { var connectionString = RoleEnvironment.GetConfigurationSettingValue(Constants.ConfigurationSectionKey); var storageAccount = CloudStorageAccount.Parse(connectionString); var tableClient = storageAccount.CreateCloudTableClient(); var table = tableClient.GetTableReference("FileUpload"); var retrieveOperation = TableOperation.Retrieve <FileUpload>(_userId, _fileId); var retrievedResult = table.Execute(retrieveOperation); if (retrievedResult.Result != null) { var fileUpload = (FileUpload)retrievedResult.Result; var b64BlockId = Convert.ToBase64String(Encoding.UTF8.GetBytes(string.Format(CultureInfo.InvariantCulture, "{0:D4}", _blockId))); var stream = File.OpenRead(fileData.LocalFileName); fileUpload.BlockBlob.PutBlock(b64BlockId, stream, ""); fileUpload.UploadStatusMessage = "finished upload of block " + _blockId; if (_blockId == fileUpload.BlockCount) { ReturnValue.IsLastBlock = true; fileUpload.IsUploadCompleted = true; try { var blockList = Enumerable.Range(1, (int)fileUpload.BlockCount).ToList <int>().ConvertAll(rangeElement => Convert.ToBase64String(Encoding.UTF8.GetBytes(string.Format(CultureInfo.InvariantCulture, "{0:D4}", rangeElement)))); fileUpload.BlockBlob.PutBlockList(blockList); var duration = DateTime.Now - fileUpload.StartTime; float fileSizeInKb = fileUpload.FileSize / Constants.BytesPerKb; string fileSizeMessage = fileSizeInKb > Constants.BytesPerKb ? string.Concat((fileSizeInKb / Constants.BytesPerKb).ToString(CultureInfo.CurrentCulture), " MB") : string.Concat(fileSizeInKb.ToString(CultureInfo.CurrentCulture), " KB"); fileUpload.UploadStatusMessage = "Finished with file upload. total duration: " + duration + " total upload size: " + fileSizeMessage; //now that we are done with the upload, we can put the file in to the processer queue var file = new UploadQueue { FileID = fileUpload.FileId, OriginalFileName = fileUpload.FileName, FileLocation = fileUpload.BlockBlob.Uri.ToString(), ContentType = "application/zip", //TODO: I should try and actually figure out what the ContentType is. ContentSize = fileUpload.FileSize, UserKey = fileUpload.UserId, UserIP = fileUpload.UserIP, UploadedDate = fileUpload.StartTime, Processing = false }; EVSAppController.Controllers.UploadQueueController.AddItemToQueue(file); } catch (Exception exc) { ReturnValue.ErrorInOperation = true; fileUpload.UploadStatusMessage = "There was an error placing the final block list."; } } var updateOperation = TableOperation.Replace(fileUpload); table.Execute(updateOperation); ReturnValue.Message = fileUpload.UploadStatusMessage; } else { ReturnValue.ErrorInOperation = true; ReturnValue.Message = "File could not be located in FileUpload table."; } } return(base.ExecutePostProcessingAsync()); }
public static void LogMessage(UploadQueue uploadQueue, string message, int currentProgress, int overAllProgress, bool finished = false) { LogMessage(uploadQueue.FileID, uploadQueue.UserKey, message, currentProgress, overAllProgress, finished); }
public void CheckTournaments() { AddNewAndActiveTournaments(); foreach (TrackableTournament t in Tournaments.Where(t => t.Tracking)) { Tournament oldTournament = t.Tournament; Tournament newTournament = _reader.getTournament(t.Tournament.TournamentId).WithName(t.Name); t.Tournament = newTournament; Boolean uploadAll = false; if (!t.TournamentUploaded) { UploadEvent e = new UploadEvent(() => _uploader.UploadTournament(t), newTournament, UploadEvent.Type.Tournament, 0); UploadQueue.Enqueue(e); t.TournamentUploaded = true; uploadAll = true; } if (!oldTournament.Equals(newTournament) || uploadAll) { if (!oldTournament.Teams.SequenceEqual(newTournament.Teams) || !newTournament.Teams.IsEmpty && uploadAll) { UploadEvent e = new UploadEvent(() => _uploader.UploadTeams(newTournament.SanctionNumber, newTournament.Teams), newTournament, UploadEvent.Type.Teams, 0); UploadQueue.Enqueue(e); uploadAll = true; } if (!oldTournament.Seatings.SequenceEqual(newTournament.Seatings) || !newTournament.Seatings.IsEmpty && uploadAll) { UploadEvent e = new UploadEvent(() => _uploader.UploadSeatings(newTournament.SanctionNumber, newTournament.Seatings), newTournament, UploadEvent.Type.Seatings, 0); UploadQueue.Enqueue(e); } if (!oldTournament.Rounds.SequenceEqual(newTournament.Rounds) || !newTournament.Rounds.IsEmpty && uploadAll) { foreach (var round in oldTournament.Rounds.ZipAll(newTournament.Rounds, (r1, r2) => new { OldRound = r1, NewRound = r2 })) { if (round.NewRound == null) { UploadEvent e = new UploadEvent(() => _uploader.DeleteRound(newTournament.SanctionNumber, round.OldRound.Number), newTournament, UploadEvent.Type.Round, round.OldRound.Number); UploadQueue.Enqueue(e); } else { if (round.OldRound == null || round.NewRound == null || !round.OldRound.Pairings.SequenceEqual(round.NewRound.Pairings, new Pairing.PairingEqualityComparer()) || round.NewRound != null && uploadAll) { UploadEvent e = new UploadEvent(() => _uploader.UploadPairings(newTournament.SanctionNumber, round.NewRound.Number, round.NewRound.Playoff, round.NewRound.Pairings), newTournament, UploadEvent.Type.Pairings, round.NewRound.Number); UploadQueue.Enqueue(e); uploadAll = true; } if (round.OldRound == null || !round.OldRound.Pairings.Select(p => p.Result).SequenceEqual(round.NewRound.Pairings.Select(p => p.Result)) || round.NewRound != null && uploadAll) { UploadEvent e = new UploadEvent(() => _uploader.UploadResults(newTournament.SanctionNumber, round.NewRound.Number, round.NewRound.Pairings), newTournament, UploadEvent.Type.Results, round.NewRound.Number); UploadQueue.Enqueue(e); uploadAll = true; } } } } if (!oldTournament.Pods.SequenceEqual(newTournament.Pods) || !newTournament.Pods.IsEmpty && uploadAll) { UploadEvent e = new UploadEvent(() => _uploader.UploadPods(newTournament.SanctionNumber, newTournament.Pods), newTournament, UploadEvent.Type.Pods, 0); UploadQueue.Enqueue(e); } } } Thread.Sleep(5000); new CheckTournamentsDelegate(CheckTournaments).BeginInvoke(null, null); }