Ejemplo n.º 1
0
        void recorder_ExecutionStop(object sender, EventArgs e)
        {
            SequenceRecorder recorder = (SequenceRecorder)sender;

            //Maybe we want a better way of doing this.
            //We need to get the tab to get the sequenceId because as of now the SequenceRecorder and AutomationEngine
            //are not aware the sequence itself, only the sequence steps.
            try
            {
                TabPage page = recorder.Parent as TabPage;
                if (page != null)
                {
                    Sequence sequence = (Sequence)page.Tag;
                    Dictionary <string, IStateVariable> persistedData = recorder.AutomationEngine.DataContext.GetPersistedVariables();
                    WebHawkAppContext.AutomationController.SetSequencePersistedData(sequence.SequenceId, persistedData);
                }
            }
            catch (Exception ex)
            {
                //Log / Do Something here...
            }

            if (recorder == zGetSequenceRecorder(tabControl1.SelectedTab))
            {
                toolStripButtonRun.Enabled  = true;
                toolStripButtonStop.Enabled = false;
            }
        }
Ejemplo n.º 2
0
        private void zDesignSequence(Sequence sequence)
        {
            if (sequence != null)
            {
                string sequenceTabKey = zGetSequenceTabKey(sequence);
                if (tabControl1.TabPages.ContainsKey(sequenceTabKey))
                {
                    tabControl1.SelectTab(sequenceTabKey);
                }
                else
                {
                    SequenceDetail sequenceDetail = WebHawkAppContext.AutomationController.GetSequenceDetail(sequence.SequenceId);

                    TabPageEx tpEditSequence = new TabPageEx(sequence.Name);
                    tpEditSequence.Name             = sequenceTabKey;
                    tpEditSequence.Tag              = sequence;
                    tpEditSequence.ContextMenuStrip = tabMenu;
                    SequenceRecorder recorder = new SequenceRecorder(sequenceDetail.SequenceSteps);
                    recorder.Dock = DockStyle.Fill;
                    tpEditSequence.Controls.Add(recorder);

                    recorder.SequenceChanged += recorder_SequenceChanged;
                    recorder.ExecutionStart  += recorder_ExecutionStart;
                    recorder.ExecutionStop   += recorder_ExecutionStop;

                    tabControl1.TabPages.Add(tpEditSequence);
                    tabControl1.SelectedTab = tpEditSequence;

                    recorder.ExecuteSequence(1);
                }
            }
        }
Ejemplo n.º 3
0
        void recorder_ExecutionStart(object sender, EventArgs e)
        {
            SequenceRecorder recorder = (SequenceRecorder)sender;

            //Maybe we want a better way of doing this.
            //We need to get the tab to get the sequenceId because as of now the SequenceRecorder and AutomationEngine
            //are not aware the sequence itself, only the sequence steps.
            try
            {
                //Only load persisted state variables if the sequence is executing from the beginning
                //to avoid messing up data conditions for resumed executions.
                if (recorder.AutomationEngine.CurrentPosition == 1)
                {
                    TabPage page = recorder.Parent as TabPage;
                    if (page != null)
                    {
                        Sequence sequence = (Sequence)page.Tag;
                        Dictionary <string, IStateVariable> persistedData = WebHawkAppContext.AutomationController.GetSequencePersistedData(sequence.SequenceId);
                        recorder.AutomationEngine.DataContext.LoadPersistedVariables(persistedData);
                    }
                }
            }
            catch (Exception ex)
            {
                //Log / Do Something here...
            }

            if (recorder == zGetSequenceRecorder(tabControl1.SelectedTab))
            {
                toolStripButtonRun.Enabled  = false;
                toolStripButtonStop.Enabled = true;
            }
        }
Ejemplo n.º 4
0
        private void zStopSequence(Sequence sequence)
        {
            SequenceRecorder recorder = zGetSequenceRecorder(sequence);

            if (recorder != null)
            {
                recorder.StopExecution();
            }
        }
Ejemplo n.º 5
0
        private void zRunSequence(Sequence sequence)
        {
            SequenceRecorder recorder = zGetSequenceRecorder(sequence);

            if (recorder != null)
            {
                recorder.ExecuteSequence();
            }
        }
Ejemplo n.º 6
0
        void recorder_SequenceChanged(object sender, EventArgs e)
        {
            SequenceRecorder recorder = (SequenceRecorder)sender;

            if (recorder == zGetSequenceRecorder(tabControl1.SelectedTab))
            {
                toolStripButtonSave.Enabled = true;
            }
        }
Ejemplo n.º 7
0
        private bool zCloseSequence(TabPage page, bool suppressSaveDialog = false)
        {
            if (page != null && page != tpSequences && page != tpScheduledTasks)
            {
                SequenceRecorder recorder = zGetSequenceRecorder(page);
                if (!suppressSaveDialog)
                {
                    Sequence sequence = (Sequence)page.Tag;
                    if (recorder.IsDirty)
                    {
                        DialogResult result = MessageBox.Show(
                            String.Format("Save changes to \"{0}\"?", sequence.Name),
                            "Save",
                            MessageBoxButtons.YesNoCancel,
                            MessageBoxIcon.Question,
                            MessageBoxDefaultButton.Button1);
                        switch (result)
                        {
                        case DialogResult.Yes:
                            if (!zSaveSequence(sequence))
                            {
                                return(false);
                            }
                            break;

                        case DialogResult.Cancel:
                            return(false);
                        }
                    }
                }
                if (recorder != null)
                {
                    recorder.SequenceChanged -= recorder_SequenceChanged;
                    recorder.ExecutionStart  -= recorder_ExecutionStart;
                    recorder.ExecutionStop   -= recorder_ExecutionStop;
                }
                page.ContextMenuStrip = null;

                int tabIndex = tabControl1.TabPages.IndexOf(page);
                tabControl1.TabPages.RemoveAt(tabIndex);
                page.Dispose();

                tabIndex = tabIndex < tabControl1.TabCount
                    ? tabIndex
                    : tabControl1.TabCount > 2
                        ? tabControl1.TabCount - 1
                        : 0;

                tabControl1.SelectedIndex = tabIndex;
                return(true);
            }
            return(false);
        }
Ejemplo n.º 8
0
        private bool zSaveSequence(Sequence sequence)
        {
            if (sequence != null)
            {
                SequenceRecorder recorder = zGetSequenceRecorder(sequence);

                SequenceDetail sequenceDetail = new SequenceDetail(sequence, recorder.SequenceSteps);
                WebHawkAppContext.AutomationController.SaveSequence(sequenceDetail);
                recorder.ResetIsDirtyFlag();

                if (recorder == zGetSequenceRecorder(tabControl1.SelectedTab))
                {
                    toolStripButtonSave.Enabled = false;
                }
                zRefreshSequences();
                return(true);
            }
            return(false);
        }
Ejemplo n.º 9
0
        private void zGetXML(Sequence sequence)
        {
            SequenceRecorder recorder = zGetSequenceRecorder(sequence);

            if (recorder != null && recorder.AutomationEngine != null && recorder.AutomationEngine.DataContext != null)
            {
                SaveFileDialog dlg = new SaveFileDialog();
                dlg.Filter   = "XML Files (*.xml)|*.xml";
                dlg.FileName = String.Format("{0}.xml", sequence.Name);
                if (dlg.ShowDialog() == DialogResult.OK)
                {
                    string xml = recorder.AutomationEngine.DataContext.ToXml();
                    File.WriteAllText(dlg.FileName, xml);
                    MessageBox.Show(String.Format("XML from sequence \"{0}\" successfully saved to \"{1}\".", sequence.Name, dlg.FileName),
                                    "Saved",
                                    MessageBoxButtons.OK,
                                    MessageBoxIcon.Information);
                }
            }
        }
Ejemplo n.º 10
0
 private void tabControl1_SelectedIndexChanged(object sender, EventArgs e)
 {
     if (tabControl1.SelectedTab == tpSequences || tabControl1.SelectedTab == tpScheduledTasks)
     {
         toolStripButtonRun.Enabled    = false;
         toolStripButtonStop.Enabled   = false;
         toolStripButtonXML.Enabled    = false;
         toolStripButtonXSLT.Enabled   = false;
         toolStripButtonSave.Enabled   = false;
         toolStripButtonDelete.Enabled = false;
     }
     else
     {
         SequenceRecorder recorder = zGetSequenceRecorder(tabControl1.SelectedTab);
         toolStripButtonRun.Enabled    = !recorder.IsExecuting;
         toolStripButtonStop.Enabled   = recorder.IsExecuting;
         toolStripButtonXML.Enabled    = true;
         toolStripButtonXSLT.Enabled   = true;
         toolStripButtonSave.Enabled   = recorder.IsDirty;
         toolStripButtonDelete.Enabled = true;
     }
 }