public WebHawkAppContext(bool startMinimized) { //Initialize Controller & Scheduler zCheckIEBrowserMode(); //Instantiate m_MainForm here. This sets the SynchronizationContext.Current value needed to start the scheduler. //When the scheduler is split out of this executable process (to a service or agent application), we won't need to worry about this. m_MainForm = new frmMain(); this.MainForm = m_MainForm; string connectionString = ConfigurationManager.ConnectionStrings["WebHawkDb"].ConnectionString; AutomationController = new AutomationController(connectionString); SettingsController = new SettingsController(connectionString); SchedulingController = new scheduling.SchedulingController(connectionString); Scheduler = new scheduling.Scheduler(connectionString, new ThreadSynchronizer()); Scheduler.Start(); //Set up tray icon m_Notify = new NotifyIcon(); m_Notify.Icon = (System.Drawing.Icon)Properties.Resources.ResourceManager.GetObject("Icon1"); m_Notify.Text = "Double-click to open."; m_Notify.MouseDoubleClick += new MouseEventHandler(m_Notify_MouseDoubleClick); m_Notify.Visible = true; //Show frmMain if (startMinimized) { m_MainForm.WindowState = FormWindowState.Minimized; } else { m_MainForm.Show(); } }
IEnumerator UpdateCoroutine(int automationIndex) { while (true) { automation = AutomationsController.instance.automations[automationIndex]; UpdatePopup(); yield return(new WaitForEndOfFrame()); if (Input.GetKey(KeyCode.Escape)) { Close(); } } }
// Adding automation method public void AddAutomation(Automation automation) { if (automations.FindIndex(x => x.automationData.id.Equals(automation.id)) > -1) { automations.Find(x => x.automationData.id.Equals(automation.id)).automationData = automation; return; } AutomationController automationController = Instantiate(automationPrefab, this.transform).GetComponent <AutomationController>(); automationController.automationData = automation; automations.Add(automationController); automationController.name = automation.nick; automationController.transform.position = new Vector3(automation.position.x, 2, automation.position.z); automationController.GetComponent <CircleLineRenderer>().CreatePoints(16, AppConstants.Object1Range / 6f, 0.1f); automationController.GetComponent <SphereCollider>().enabled = true; }
static void Main(string[] args) { String resourceFolderPath = System.IO.Path.Combine(System.IO.Directory.GetCurrentDirectory(), "Resources"); AutomationController aut = new AutomationController(); aut.Initialize(resourceFolderPath); IWebDriver driver = WebDriverMaster.GetWebDriver(null); driver.Navigate().GoToUrl("https://www.metric-conversions.org/"); System.Threading.Thread.Sleep(3000); if (null != driver) { driver.Quit(); } }
public void Automation(AutomationController controller, string name) { foreach (Automation auto in automations.automation) { string tmpString = ""; if (auto.automationName.Length > 20) { tmpString = auto.automationName.Substring(0, 20); } else { tmpString = auto.automationName; } if (name == tmpString) { if (controller == AutomationController.Start) { if (timers[auto.threadIndex] != null && !auto.running && !timers[auto.threadIndex].Enabled) { timers[auto.threadIndex].Enabled = true; auto.running = true; } } else { if (timers[auto.threadIndex] != null && auto.running && timers[auto.threadIndex].Enabled) { timers[auto.threadIndex].Enabled = false; auto.running = false; } } break; } } }
public void Execute(IJobExecutionContext context) { ThreadSynchronizer threadSynchronizer = null; frmAutomation frmAutomation = null; try { m_JobKey = context.JobDetail.Key; m_Logger.InfoFormat("ExecuteSequenceJob {0} executing at {1}.", m_JobKey, DateTime.Now.ToString("r")); string connectionString = (string)context.MergedJobDataMap["connectionString"]; AutomationController automationController = new AutomationController(connectionString); SchedulingController schedulingController = new SchedulingController(connectionString); long scheduledTaskId = (long)context.MergedJobDataMap["scheduledTaskId"]; ScheduledTask scheduledTask = schedulingController.GetScheduledTask(scheduledTaskId, DeletedInclusion.All); SequenceDetail sequenceDetail = automationController.GetSequenceDetail(scheduledTask.TaskSequence.SequenceId); threadSynchronizer = (ThreadSynchronizer)context.MergedJobDataMap["threadSynchronizer"]; threadSynchronizer.RunOnSynchronizedThread(() => frmAutomation = new frmAutomation(), true); using (AutomationEngine automationEngine = new AutomationEngine(frmAutomation.Browser)) { automationEngine.SetSequence(sequenceDetail.SequenceSteps); Dictionary <string, IStateVariable> persistedData = automationController.GetSequencePersistedData(sequenceDetail.Sequence.SequenceId); automationEngine.DataContext.LoadPersistedVariables(persistedData); automationEngine.ExecutionComplete += automationEngine_ExecutionComplete; using (m_ExecutionWaitHandle = new AutoResetEvent(false)) { automationEngine.ExecuteSequence(); if (!m_ExecutionWaitHandle.WaitOne(scheduledTask.RunDurationLimit.HasValue ? scheduledTask.RunDurationLimit.Value : TimeSpan.FromMilliseconds(-1))) { throw new TimeoutException( String.Format("Scheduled sequence execution timed out because it reached the specified Run Duration Limit of {0}.", scheduledTask.RunDurationLimit)); } } automationEngine.ExecutionComplete -= automationEngine_ExecutionComplete; persistedData = automationEngine.DataContext.GetPersistedVariables(); automationController.SetSequencePersistedData(sequenceDetail.Sequence.SequenceId, persistedData); } ExecuteSequenceJobResult result = new ExecuteSequenceJobResult( zGetScheduledTaskStatusFromExecutionState(m_ExecutionCompleteEventArgs.RunResult), ""); //TODO: get error from ExecutionCompleteEventArgs context.Result = result; } catch (Exception ex) { JobExecutionException jobEx = new JobExecutionException(ex, false); throw jobEx; } finally { //Clean up try { if (frmAutomation != null) { threadSynchronizer.RunOnSynchronizedThread(() => frmAutomation.Dispose(), true); } } catch (Exception ex) { if (m_Logger != null) { m_Logger.ErrorFormat("Cleanup failed for ExecuteSequenceJob {0}: {1}", m_JobKey, ex.Message); } } //Dereference global variables m_Logger = null; m_JobKey = null; m_ExecutionCompleteEventArgs = null; m_ExecutionWaitHandle = null; } }