public ExecuteResult ExecuteTracesInCSV(EventCSV csv, int displayProgressForEach = 0) { ExecuteResult ret = new ExecuteResult(); int percentFeedback = displayProgressForEach; int percent = 0; List <string> uniqueTraces = csv.Events.Select(e => e.TraceID).Distinct().ToList(); for (int i = 0; i < uniqueTraces.Count; i++) { string traceid = uniqueTraces[i]; List <Event> trace = csv.Events.Where(e => e.TraceID == traceid).OrderBy(e => e.Date).ToList(); bool accepted = true; foreach (Event ev in trace) { if (!ExecuteEvent(ev)) { ret.FailedIDs.Add(traceid); accepted = false; break; } } //If any activity remains pending after execution, fail the trace foreach (Activity activity in Activities.Values) { if (activity.IsEnabled && activity.IsIncluded && activity.IsPending) { ret.FailedIDs.Add(traceid); accepted = false; break; } } if (accepted) { ret.SuccessIDs.Add(traceid); } this.Recover(true); percent = (int)(((float)i + 1) / ((float)uniqueTraces.Count) * 100); if (displayProgressForEach > 0 && percent >= percentFeedback) { percentFeedback += displayProgressForEach; LogProgress?.Invoke(this, new ProgressArgs(percent)); } } return(ret); }
public Specific_Philadelphia_PA_USA(string workfolder) { lp = new LogProgress(workfolder); }
public Specific_Austin_TX_USA(string logDirectory) { lp = new LogProgress(logDirectory); }
private async Task RunAsync(CancellationToken cancellationToken) { var logger = LogManager.GetCurrentClassLogger(); logger.Info("Starting service..."); var logProgress = new LogProgress(logger); var appConfiguration = new AppConfiguration(); appConfiguration.LoadConfigFile(); if (appConfiguration.GogsAccessToken == null && appConfiguration.EnableGogsAccessTokenGeneration) { var gogsAccessTokenGenerator = new GogsAccessTokenGenerator(appConfiguration); var gogsAccessTokens = await gogsAccessTokenGenerator.CreateOrGetAccessTokensAsync(); if (gogsAccessTokens.Any()) { appConfiguration.GogsAccessToken = gogsAccessTokens.First().Sha1; } } // Force a minimum wait interval (we probably don't want this thing running constantly) var syncInterval = appConfiguration.SyncInterval; if (syncInterval.TotalMinutes < 1) { syncInterval = TimeSpan.FromMinutes(1); } var synchronizer = new GroupSynchronizer(appConfiguration); while (!cancellationToken.IsCancellationRequested) { // If we have a min/max time, then we'll wait for a valid time period. var waitTime = TimeUtils.CalculateWaitTime(DateTime.Now.TimeOfDay, appConfiguration.MinimumTimeOfDay, appConfiguration.MaximumTimeOfDay); if (waitTime.HasValue) { await Task.Delay(waitTime.Value, cancellationToken); } try { logger.Info("Starting sync..."); await synchronizer.SynchronizeAsync(progress : logProgress, cancellationToken : cancellationToken); logger.Info("Sync completed successfully."); await Task.Delay(syncInterval, cancellationToken : cancellationToken); } catch (OperationCanceledException) { logger.Info("Sync canceled."); } catch (Exception ex) { logger.Error(ex, $"Sync failed."); await Task.Delay(syncInterval, cancellationToken : cancellationToken); } } }