public static async Task <bool> Upload(string[] logLines, GameMetaData gameMetaData, GameStats game) { var log = string.Join(Environment.NewLine, logLines); var item = new UploaderItem(log.GetHashCode()); if (InProgress.Contains(item)) { Log.Info($"{item.Hash} already in progress. Waiting for it to complete..."); InProgress.Add(item); return(await item.Success); } InProgress.Add(item); Log.Info($"Uploading {item.Hash}..."); var success = false; try { success = await TryUpload(logLines, gameMetaData, game, true); } catch (Exception ex) { Log.Error(ex); Influx.OnGameUploadFailed(); } Log.Info($"{item.Hash} complete. Success={success}"); foreach (var waiting in InProgress.Where(x => x.Hash == item.Hash)) { waiting.Complete(success); } InProgress.RemoveAll(x => x.Hash == item.Hash); return(success); }
public static async Task<bool> Upload(string[] logLines, GameMetaData gameMetaData, GameStats game) { var log = string.Join(Environment.NewLine, logLines); var item = new UploaderItem(log.GetHashCode()); if(InProgress.Contains(item)) { Log.Info($"{item.Hash} already in progress. Waiting for it to complete..."); InProgress.Add(item); return await item.Success; } InProgress.Add(item); Log.Info($"Uploading {item.Hash}..."); var success = false; try { success = await TryUpload(logLines, gameMetaData, game, true); } catch(Exception ex) { Log.Error(ex); Influx.OnGameUploadFailed(); } Log.Info($"{item.Hash} complete. Success={success}"); foreach(var waiting in InProgress.Where(x => x.Hash == item.Hash)) waiting.Complete(success); InProgress.RemoveAll(x => x.Hash == item.Hash); return success; }
public async Task <UploadStatus> Upload(string[] logLines, UploadMetaData data) { var result = LogValidator.Validate(logLines); if (!result.IsValid) { UploadError?.Invoke(new UploadErrorEventArgs(0, data, result.Reason)); return(new UploadStatus(new InvalidLogException(result.Reason))); } var log = string.Join(Environment.NewLine, logLines); var item = new UploaderItem(log.GetHashCode()); if (_inProgress.Contains(item)) { Log.Debug($"{item.Hash} already in progress. Waiting for it to complete..."); _inProgress.Add(item); return(await item.Status); } _inProgress.Add(item); Log.Debug($"Uploading {item.Hash}..."); UploadStatus status; UploadInitiated?.Invoke(new UploadStatusChangedEventArgs(item.Hash, data)); try { status = await TryUpload(logLines, data); } catch (Exception ex) { Log.Error(ex); status = new UploadStatus(ex); } Log.Debug($"{item.Hash} complete. Success={status.Success}"); UploadComplete?.Invoke(new UploadCompleteEventArgs(item.Hash, data, status)); foreach (var waiting in _inProgress.Where(x => x.Hash == item.Hash)) { waiting.Complete(status); } _inProgress.RemoveAll(x => x.Hash == item.Hash); return(status); }
public bool Equals(UploaderItem obj) => obj.Hash == Hash;
private bool Equals(UploaderItem obj) => obj.Hash == Hash;