Esempio n. 1
0
        void m_AutomationEngine_ExecutionComplete(object sender, ExecutionCompleteEventArgs e)
        {
            zRefreshVariables();
            m_Executing = false;
            ThreadingUtils.InvokeControlAction(this, ctl =>
            {
                zResumeRecording();
                zSelectAllStepElements();

                zOnExecutionStop(EventArgs.Empty);
            });
        }
Esempio n. 2
0
        void m_AutomationEngine_ExecutionComplete(object sender, ExecutionCompleteEventArgs e)
        {
            m_AutomationEngine.ExecutionComplete -= m_AutomationEngine_ExecutionComplete;

            ElementIdentifier containerIdentifier = null;

            if (m_GroupStepEditContext != null)
            {
                GroupStep groupStep = (GroupStep)m_GroupStepEditContext.Step;
                containerIdentifier = ((ElementSetIteration)groupStep.Iteration).ElementSetContainer;
            }

            ThreadingUtils.InvokeControlAction(this, ctl =>
            {
                zDetect(containerIdentifier);
            });
        }
Esempio n. 3
0
        void m_AutomationEngine_ExecutionComplete(object sender, ExecutionCompleteEventArgs e)
        {
            m_AutomationEngine.ExecutionComplete -= m_AutomationEngine_ExecutionComplete;

            GroupStep groupStep = (GroupStep)m_StepEditContext.Step;

            m_Pattern = groupStep.Steps.OfType <ElementStep>().Select(gvs => gvs.Element).ToList();

            ThreadingUtils.InvokeControlAction(this, ctl =>
            {
                if (m_ContainerIdentifier != null)
                {
                    zElementSelected();
                }
                zPreview();

                pbLoading.Visible   = false;
                EditorPanel.Visible = true;
            });
        }
Esempio n. 4
0
        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;
            }
        }
Esempio n. 5
0
 void automationEngine_ExecutionComplete(object sender, ExecutionCompleteEventArgs e)
 {
     m_ExecutionCompleteEventArgs = e;
     m_ExecutionWaitHandle.Set();
 }