private void runFlow(ActionFlow flow) { try { foreach (ActionImplementation ai in flow.Actions) { ai.PrepareRun(); } //find start and run ActionStart startAction = (from a in flow.Actions where a is ActionStart select a).FirstOrDefault() as ActionStart; List <Core.Data.Geocache> gcList = startAction.PrepareFlow(); DateTime nextUpdate = DateTime.Now.AddSeconds(1); int index = 0; bool canceled = false; using (Utils.ProgressBlock prog = new Utils.ProgressBlock("ActionBuilder", "Executing", gcList.Count, 0, true)) { foreach (Core.Data.Geocache gc in gcList) { startAction.Run(gc); index++; if (DateTime.Now >= nextUpdate) { if (!prog.Update("Executing", gcList.Count, index)) { canceled = true; break; } nextUpdate = DateTime.Now.AddSeconds(1); } } } if (!canceled) { //wrap up foreach (ActionImplementation ai in flow.Actions) { ai.FinalizeRun(); } } } catch (Exception e) { Core.ApplicationData.Instance.Logger.AddLog(this, e); } }
private void RunActionFlow(ActionFlow flow, bool notifyDone) { try { using (Utils.FrameworkDataUpdater upd = new Utils.FrameworkDataUpdater(Core)) { //flows can call eachother, initialize them all foreach (ActionFlow af in _actionFlows) { foreach (ActionImplementation ai in af.Actions) { ai.PrepareRun(); } } //find start and run ActionStart startAction = (from a in flow.Actions where a is ActionStart select a).FirstOrDefault() as ActionStart; if (notifyDone) { //first start startAction.PrepareFlow(); } foreach (Framework.Data.Geocache gc in Core.Geocaches) { startAction.Run(gc); } //wrap up foreach (ActionFlow af in _actionFlows) { foreach (ActionImplementation ai in af.Actions) { ai.FinalizeRun(); } } } if (notifyDone && PluginSettings.Instance.ShowFlowCompletedMessage) { using (ExecutionCompletedForm dlg = new ExecutionCompletedForm()) { dlg.ShowDialog(); } } } catch (Exception ex) { MessageBox.Show(ex.Message); } }