Пример #1
0
 /// <summary>
 /// 注册自动化类型
 /// </summary>
 public void Register(IAutomation automation)
 {
     if (!_automationTable.Contains(automation.Guid))
     {
         _automationTable.Add(automation.Guid, automation.GetType());
     }
 }
        /// <summary>
        /// construct an ActionManager
        /// </summary>
        /// <param name="parent">the Automation object</param>
        public SeleniumActionManager(IAutomation parent, Browser browser)
            : base(parent)
        {
            switch (browser)
            {
                case Browser.Chrome:
                    {
                        OpenQA.Selenium.Chrome.ChromeDriverService service = OpenQA.Selenium.Chrome.ChromeDriverService.CreateDefaultService();
                        service.HideCommandPromptWindow = true;
                        WebDriver = new OpenQA.Selenium.Chrome.ChromeDriver(service, new OpenQA.Selenium.Chrome.ChromeOptions());
                        break;
                    }
                case Browser.FireFox:
                    WebDriver = new OpenQA.Selenium.Firefox.FirefoxDriver();
                    break;
                case Browser.Safari:
                    WebDriver = new OpenQA.Selenium.Safari.SafariDriver();
                    break;
                default:
                    WebDriver = new OpenQA.Selenium.IE.InternetExplorerDriver();
                    break;
            };
            WebDriver.Manage().Timeouts().ImplicitlyWait(WaitTime);

            RegisterAction(new ActionClick(WebDriver));
            RegisterAction(new ActionOpenURL(WebDriver));
            RegisterAction(new ActionRefresh(WebDriver));
            RegisterAction(new ActionGoBack(WebDriver));
            RegisterAction(new ActionEnter(WebDriver));

            RegisterAction(new ActionCheckControlProperty(WebDriver));
            RegisterAction(new ActionSet(WebDriver));
        }
Пример #3
0
 public void InitializeAutomation(IAutomation automationType, string Name, Sprite Icon)
 {
     this.Name.text         = Name;
     AutomationImage.sprite = Icon;
     //AutomationLogic automationLogic = gameObject.GetComponent<AutomationLogic>();
     //automationLogic.SetAutomationType(automationType);
 }
Пример #4
0
        public void Execute(IPCBIWindow mainWindowPCBI)
        {
            IStep step = mainWindowPCBI.GetCurrentStep();

            if (step == null)
            {
                return;
            }

            ICMPLayer layerCMPsTop = step.GetCMPLayer(true);

            //exisits the compnenent layer?
            if (layerCMPsTop == null)
            {
                return;
            }

            foreach (string layername in step.GetAllLayerNames())
            {
                List <ILayer> layers = new List <ILayer>();
                layers.Add(step.GetLayer(layername));
                SaveImageFromComponent(step, layers, FileLocation);
            }
            //something went wrong?
            string errorLog = IAutomation.GetErrorLog();

            if (errorLog.Length > 0)
            {
                System.Diagnostics.Debug.WriteLine(errorLog);
            }
        }
Пример #5
0
 public AutomationUnit(IAutomation automation, AutomationContext context, DelegateAutomationDone callback, object stateObject, AutomationUnit callingUnit)
 {
     _automation          = automation;
     _context             = context;
     _callback            = callback;
     _callbackStateObject = stateObject;
     _callingUnit         = callingUnit;
 }
Пример #6
0
        /// <summary>
        /// construct an ActionManager
        /// </summary>
        /// <param name="parent">the Automation object</param>
        public ActionManager(IAutomation parent)
        {
            Parent = parent;
            parent.ActionManagers.Add(this);
            Actions = new Dictionary <string, IAction>();

            WaitTime = new TimeSpan(0, 0, 30);
        }
Пример #7
0
        /// <summary>
        /// The contructor function of frmProgress
        /// </summary>
        /// <param name="title">The title of the form</param>
        /// <param name="automation">The automation component to use</param>
        /// <param name="tp">The type of output</param>
        public frmProgress(string title, IAutomation automation, OfficePlate.OutputModeType tp)
        {
            InitializeComponent();

            modetype = tp;
            ia = automation;
            td = new Thread(new ThreadStart(Begin));
        }
Пример #8
0
        /// <summary>
        /// construct an ActionManager
        /// </summary>
        /// <param name="parent">the Automation object</param>
        public ActionManager(IAutomation parent)
        {
            Parent = parent;
            parent.ActionManagers.Add(this);
            Actions = new Dictionary<string, IAction>();

            WaitTime = new TimeSpan(0, 0, 30);
        }
Пример #9
0
	protected void Page_Load(object sender, EventArgs e)
	{
		if (Session[WebConfig.SessionAutomation] != null)
		{
			_automation = Session[WebConfig.SessionAutomation] as IAutomation;
		}
        //隐藏错误提示
        LabelParameterInfo.Visible = false;
	}
Пример #10
0
        // TODO: Add const for setting name.
        public static void Enable(this IAutomation automation)
        {
            if (automation == null)
            {
                throw new ArgumentNullException(nameof(automation));
            }

            automation.Settings.SetValue("IsEnabled", true);
        }
Пример #11
0
        public static bool IsEnabled(this IAutomation automation)
        {
            if (automation == null)
            {
                throw new ArgumentNullException(nameof(automation));
            }

            return(automation.Settings.GetBoolean("IsEnabled"));
        }
Пример #12
0
        public void RegisterAutomation(IAutomation automation)
        {
            lock (_automations)
            {
                _automations.Add(automation.Id, automation);
            }

            _automationService.AddAutomation(automation);
        }
Пример #13
0
        public void AddAutomation(IAutomation automation)
        {
            if (automation == null)
            {
                throw new ArgumentNullException(nameof(automation));
            }

            _automations.Add(automation.Id, automation);
        }
Пример #14
0
 void CurrentAutomation_Ended(IAutomation at)
 {
     //throw new NotImplementedException();
     if (System.Windows.Forms.MessageBox.Show("Testing Finish... ", "Confirm", MessageBoxButtons.OK, MessageBoxIcon.Information) == DialogResult.OK)
     {
         //LoadTreeView();
     }
     CurrentAutomation = null;
 }
Пример #15
0
 protected void Page_Load(object sender, EventArgs e)
 {
     if (Session[WebConfig.SessionAutomation] != null)
     {
         _automation = Session[WebConfig.SessionAutomation] as IAutomation;
     }
     //隐藏错误提示
     LabelParameterInfo.Visible = false;
 }
Пример #16
0
 private void ListAutomation()
 {
     Type[] automationTypes = AdminServer.TheInstance.AutomationManager.Automations;
     foreach (Type type in automationTypes)
     {
         IAutomation automation = Activator.CreateInstance(type) as IAutomation;
         DropDownListAutomation.Items.Add(new ListItem(automation.Name, automation.Guid));
     }
 }
Пример #17
0
        public void Execute(IPCBIWindow parentPCBIWindow)
        {
            if (parentPCBIWindow == null)
            {
                parentPCBIWindow = IAutomation.CreateNewPCBIWindow(true); return;
            }

            FormLayerDetails detailsOfActiveLayer = new FormLayerDetails();

            detailsOfActiveLayer.SetInfos(parentPCBIWindow);
            detailsOfActiveLayer.Show();
        }
Пример #18
0
        /// <summary>
        /// Initializes a new instance of the <see cref="Automa" /> class.
        /// </summary>
        /// <param name="connector">The connector.</param>
        /// <param name="automationFactory">The automation factory.</param>
        /// <param name="defaultTimeoutIsSeconds">The default timeout is seconds.</param>
        public Automa(AutomaContext connector, Func <IAutoma, IWebDriver, IAutomation> automationFactory, decimal defaultTimeoutIsSeconds = 30M)
        {
            // [http://stackoverflow.com/questions/33265701/protractor-allow-notifications-chrome-46]
            var chromeOptions = new ChromeOptions();

            chromeOptions.AddUserProfilePreference("profile.managed_default_content_settings.notifications", 1);
            _d = new ChromeDriver(AppDomain.CurrentDomain.BaseDirectory, chromeOptions);
            _d.Manage().Timeouts().ImplicitWait = TimeSpan.FromMinutes(5);
            _connector              = connector;
            _automation             = automationFactory(this, _d);
            DefaultTimeoutIsSeconds = defaultTimeoutIsSeconds;
        }
Пример #19
0
 //STOP
 private void buttonItem4_Click(object sender, EventArgs e)
 {
     if (CurrentAutomation != null)
     {
         buttonItem2.Enabled          = false;
         buttonItem16.Enabled         = false;
         buttonItem15.Enabled         = true;
         runToolStripMenuItem.Enabled = true;
         buttonItem4.Enabled          = false;
         CurrentAutomation.Interupt();
         CurrentAutomation = null;
     }
 }
Пример #20
0
        /// <summary>
        /// 执行自动化作业
        /// </summary>
        /// <remarks>作业上下文会在这个函数内部被复制,从而保证作业各自的上下文不会互相干扰,而只能对各自的后续作业产生影响</remarks>
        public void Do(IAutomation automation, AutomationContext context, DelegateAutomationDone callback, object stateObject, AutomationUnit callingUnit)
        {
            if (automation == null)
            {
                throw new ArgumentNullException("automation");
            }

            if (context == null)
            {
                throw new ArgumentNullException("context");
            }

            _toBeAddList.Add(new AutomationUnit(automation, (AutomationContext)context.Clone(), callback, stateObject, callingUnit));
        }
Пример #21
0
        public static JObject GetRawSettings(this ISettingsService settingsService, IAutomation automation)
        {
            if (settingsService == null)
            {
                throw new ArgumentNullException(nameof(settingsService));
            }
            if (automation == null)
            {
                throw new ArgumentNullException(nameof(automation));
            }

            var uri = SettingsUriGenerator.FromAutomation(automation.Id);

            return(settingsService.GetSettings(uri));
        }
Пример #22
0
    protected void DropDownListAutomation_SelectedIndexChanged(object sender, EventArgs e)
    {
        IAutomation automation = AdminServer.TheInstance.AutomationManager.Create(DropDownListAutomation.SelectedValue);

        LitearlAutomationDes.Text = automation.Description;
        PanelServer.Visible       = false;
        PanelFtpServer.Visible    = false;
        PanelServerGroup.Visible  = false;
        TextBoxParameter1.Text    = string.Empty;
        TextBoxParameter2.Text    = string.Empty;
        TextBoxParameter3.Text    = string.Empty;

        SetParameter(automation);
        ResetServerListAndButton();
    }
Пример #23
0
        //Конструктор класса AppViewModel
        public AppViewModel(IConfig config, IConfigManager configManager, IFileListener fileListener)
        {
            try
            {
                //инициализируем значения текущей конфигурации
                this.configManager = configManager;
                this.fileListener  = fileListener;
                this.config        = configManager.ReadConfig(config);

                //Инициализируем колекцию обрабатываемых данных
                Records = new ObservableCollection <IRecord>();

                //Инициализируем колекцию с перечнем обрабатываемх файлов
                ProcFiles = new ObservableCollection <IProcFile>();

                //Создаем екземпляр класса Automation
                automation = new Automation(this.fileListener, this.config, Records, ProcFiles);
            }
            catch
            {
                //Отлавливаем исключения и передаем их на верхний уровень обработки
                throw;
            }

            //Устанавливаем значения свойств
            //Инициализируем заполняя значениями массивы с перечнем допустимых для ввода значний
            //для листбоксов часы, минуты, секунды
            DataInit dataInit = new DataInit();

            HHDS = dataInit.HR;
            MSDS = dataInit.MS;
            //Устанавливаем начальные значения в листбоксах: часы, минуты, секунды,
            //заполняя их значениями из текущей конфигурации
            HHVal          = this.config.Interval.Hours;
            MMVal          = this.config.Interval.Minutes;
            SSVal          = this.config.Interval.Seconds;
            WorkDirectory  = this.config.WorkDir;
            ProcessingType = this.config.ProcessingType;
            //Задаем значение надписи на кнопке выбора типа обработки фалов в зависимости от значения свойства ProcessingType
            if (ProcessingType)
            {
                ProcessingTypeButtonContent = "Timer is tarted";
            }
            else
            {
                ProcessingTypeButtonContent = "File system watcher is started";
            }
        }
Пример #24
0
        /// <summary>
        /// construct an ActionManager
        /// </summary>
        /// <param name="parent">the Automation object</param>
        public UIAActionManager(IAutomation parent)
            : base(parent)
        {
            RegisterAction(new ActionClick());
            RegisterAction(new ActionEnter());
            RegisterAction(new ActionSet());
            RegisterAction(new ActionStartProgram());
            RegisterAction(new ActionCloseWindow());

            RegisterAction(new ActionCheckWindowProperty());
            RegisterAction(new ActionCheckWindowExist());
            RegisterAction(new ActionCheckControlProperty());
            RegisterAction(new ActionCheckControlExist());

            RegisterAction(new ActionSelectMenuItem());
        }
Пример #25
0
        /// <summary>
        /// construct an ActionManager
        /// </summary>
        /// <param name="parent">the Automation object</param>
        public UIAActionManager(IAutomation parent)
            : base(parent)
        {
            RegisterAction(new ActionClick());
            RegisterAction(new ActionEnter());
            RegisterAction(new ActionSet());
            RegisterAction(new ActionStartProgram());
            RegisterAction(new ActionCloseWindow());

            RegisterAction(new ActionCheckWindowProperty());
            RegisterAction(new ActionCheckWindowExist());
            RegisterAction(new ActionCheckControlProperty());
            RegisterAction(new ActionCheckControlExist());

            RegisterAction(new ActionSelectMenuItem());
        }
Пример #26
0
        public IAutomation RegisterAutomation(IAutomation a)
        {
            if (a == null)
            {
                throw new ArgumentNullException();
            }

            if (RegisteredAutomations.ContainsKey(a.Name))
            {
                throw new ArgumentException($"Canot register automation '{a.Name}' of type '{a.GetType()}'. It's already registered.");
            }

            RegisteredAutomations.Add(a.Name, a);

            LOGGER.Info($"Registered automation '{a.Name}' of type '{a.GetType()}'");

            return(a);
        }
 public void TryUpgradeAutomation(int automationId, IAutomation automation, UnityEvent automationUpgraded)
 {
     if (_playerData.Gold >= _automation.CurrentCost)
     {
         _playerData.Gold -= _automation.CurrentCost;
         automation.Upgrade(_automation, _automationsData);
         if (_automation.Level % 2000 == 0)
         {
             _playerData.BadgePoints += 1;
         }
         automationUpgraded?.Invoke();
         _automationOutput.AutomationUpgraded(_automation, _playerData.Gold >= _automation.CurrentCost);
     }
     else
     {
         _automationOutput.AutomationNotUpgraded();
     }
 }
Пример #28
0
    void LoadParameter(IAutomation automation)
    {
        switch ((int)automation.Parameter[0])
        {
        case 1:
            TextBoxParameter1.Text = automation.Parameter[1].ToString();
            break;

        case 2:
            TextBoxParameter1.Text = automation.Parameter[1].ToString();
            TextBoxParameter2.Text = automation.Parameter[2].ToString();
            break;

        case 3:
            TextBoxParameter1.Text = automation.Parameter[1].ToString();
            TextBoxParameter2.Text = automation.Parameter[2].ToString();

            //如果该任务的类型为“发邮件”
            if (automation.Guid == "{eca2ad62-0238-4996-82c0-852009463d94}")
            {
                string contentTypes = automation.Parameter[3] as string;
                foreach (ListItem item in MailContentTypeCheckBoxList.Items)
                {
                    if (contentTypes.Contains(item.Value))
                    {
                        item.Selected = true;
                    }
                    else
                    {
                        item.Selected = false;
                    }
                }
            }
            else
            {
                TextBoxParameter3.Text = automation.Parameter[3].ToString();
            }


            break;
        }
    }
Пример #29
0
        private void radButtonOK_Click(object sender, EventArgs e)
        {
            IAutomation      at = new Automation(new ExcelFileParser(), new ExcelReporter(new ExcelFileParser()), this.pathproject);
            UIAActionManager am = new UIAActionManager(at);

            currentAutomation = at;

            try
            {
                Script startScript = new Script(at.Parser.NewInstance);
                startScript.FileName = this.script;



                at.Name  = "Regression";
                at.Speed = 10;
                if (this.data != null && this.data.Length > 0)
                {
                    Data data = new Data(at.Parser.NewInstance);
                    data.FileName = this.data;

                    at.Data = data;
                }


                at.StartScript = startScript;
                at.Start();

                //----------------------------------

                at.Paused           += at_Paused;
                at.Resumed          += at_Resumed;
                at.Interupted       += at_Interupted;
                at.Ended            += at_Ended;
                at.ActionPerforming += at_ActionPerforming;
            }
            catch (Exception ex)
            {
                System.Windows.Forms.MessageBox.Show(ex.Message);
            }
        }
Пример #30
0
        private void Run()
        {
            buttonItem15.Enabled         = false;
            runToolStripMenuItem.Enabled = false;
            buttonItem16.Enabled         = true;
            buttonItem4.Enabled          = true;
            buttonItem2.Enabled          = false;
            Run f = new Run();

            f._txtScript.Text = treeViewproject.SelectedNode.Text;
            TreeNode currnode = treeViewproject.Nodes[0].Nodes[0];
            //List<DirectoryInfo> dirlist = Duyetthumuccon((String)currnode.Tag);
            List <string> dataList = Duyetfile((String)currnode.Tag);

            dataList.Insert(0, @"[None]");
            f._cboData.DataSource = dataList;
            f.CurrentProjectPath  = CurrentProjectPath;
            f.ShowDialog();
            CurrentAutomation        = f.CurrenrtAutomation;
            CurrentAutomation.Ended += CurrentAutomation_Ended;
        }
Пример #31
0
    private TreeNode CreateAutomationNode(IAutomation automation, string title, string path)
    {
        TreeNode node = new TreeNode();

        if (automation != null)
        {
            node.Text  = title + automation.ToString();
            node.Value = path;

            node.ChildNodes.Add(CreateAutomationNode(automation.Success, "success: ", "1"));

            node.ChildNodes.Add(CreateAutomationNode(automation.Failure, "failure: ", "0"));

            node.ChildNodes.Add(CreateAutomationNode(automation.Complete, "complete: ", "2"));
        }
        else
        {
            node.Text  = title + "--";
            node.Value = path;
        }

        return(node);
    }
Пример #32
0
        /// <summary>
        /// construct an ActionManager
        /// </summary>
        /// <param name="parent">the Automation object</param>
        public SeleniumActionManager(IAutomation parent, Browser browser)
            : base(parent)
        {
            switch (browser)
            {
            case Browser.Chrome:
            {
                OpenQA.Selenium.Chrome.ChromeDriverService service = OpenQA.Selenium.Chrome.ChromeDriverService.CreateDefaultService();
                service.HideCommandPromptWindow = true;
                WebDriver = new OpenQA.Selenium.Chrome.ChromeDriver(service, new OpenQA.Selenium.Chrome.ChromeOptions());
                break;
            }

            case Browser.FireFox:
                WebDriver = new OpenQA.Selenium.Firefox.FirefoxDriver();
                break;

            case Browser.Safari:
                WebDriver = new OpenQA.Selenium.Safari.SafariDriver();
                break;

            default:
                WebDriver = new OpenQA.Selenium.IE.InternetExplorerDriver();
                break;
            }
            ;
            WebDriver.Manage().Timeouts().ImplicitlyWait(WaitTime);

            RegisterAction(new ActionClick(WebDriver));
            RegisterAction(new ActionOpenURL(WebDriver));
            RegisterAction(new ActionRefresh(WebDriver));
            RegisterAction(new ActionGoBack(WebDriver));
            RegisterAction(new ActionEnter(WebDriver));

            RegisterAction(new ActionCheckControlProperty(WebDriver));
            RegisterAction(new ActionSet(WebDriver));
        }
Пример #33
0
		/// <summary>
		/// 执行自动化作业
		/// </summary>
		/// <remarks>简化版,内部自动生成上下文对象</remarks>
		public void Do(IAutomation automation)
		{
			Do(automation, new AutomationContext(), null, null, null);
		}
Пример #34
0
 static void at_Interupted(IAutomation at)
 {
     //throw new NotImplementedException();
     Console.WriteLine("Automation stopped. Error: " + at.ErrorMessage);
 }
Пример #35
0
    void SetParameter(IAutomation automation)
    {
        ButtonServerIdSelect.Visible      = false;
        ButtonFtpServerIdSelect.Visible   = false;
        ButtonServerGroupIdSelect.Visible = false;
        switch ((int)automation.Parameter[0])
        {
        case 0:
            PanelParameterOut.Visible = false;
            break;

        case 1:
            PanelParameterOut.Visible = true;
            if (automation.ParameterDes[0].Equals(StringDef.ServerId))
            {
                ButtonServerIdSelect.Visible = true;
            }
            TextBoxParameter1.Visible = true;
            LabelParameter1.Text      = automation.ParameterDes[0];
            LabelParameter1.Visible   = true;
            TextBoxParameter2.Visible = false;
            LabelParameter2.Visible   = false;
            TextBoxParameter3.Visible = false;
            LabelParameter3.Visible   = false;

            MailContentTypeCheckBoxList.Visible = false;

            break;

        case 2:
            PanelParameterOut.Visible = true;

            TextBoxParameter1.Visible = true;
            if (automation.ParameterDes[0].Equals(StringDef.ServerId))
            {
                ButtonServerIdSelect.Visible = true;
            }
            if (automation.Guid == "{2A034C09-D437-4b6a-8338-B76AA8F5D543}")
            {
                ButtonFtpServerIdSelect.Visible = true;
            }
            LabelParameter1.Text    = automation.ParameterDes[0];
            LabelParameter1.Visible = true;

            if (automation.ParameterDes[1].Equals(StringDef.ServerGroupId))
            {
                ButtonServerGroupIdSelect.Visible = true;
            }
            TextBoxParameter2.Visible = true;
            LabelParameter2.Text      = automation.ParameterDes[1];
            LabelParameter2.Visible   = true;
            TextBoxParameter3.Visible = false;
            LabelParameter3.Visible   = false;

            MailContentTypeCheckBoxList.Visible = false;

            break;

        case 3:
            //如果该任务的类型为“发邮件”
            if (automation.Guid == "{eca2ad62-0238-4996-82c0-852009463d94}")
            {
                PanelParameterOut.Visible = true;
                if (automation.ParameterDes[0].Equals(StringDef.ServerId))
                {
                    ButtonServerIdSelect.Visible = true;
                }
                TextBoxParameter1.Visible = true;
                LabelParameter1.Visible   = true;
                LabelParameter1.Text      = automation.ParameterDes[0];

                if (automation.ParameterDes[1].Equals(StringDef.ServerGroupId))
                {
                    ButtonServerGroupIdSelect.Visible = true;
                }
                TextBoxParameter2.Visible           = true;
                LabelParameter2.Visible             = true;
                LabelParameter2.Text                = automation.ParameterDes[1];
                PanelParameterOut.Visible           = true;
                TextBoxParameter3.Visible           = false;
                MailContentTypeCheckBoxList.Visible = true;
                LabelParameter3.Text                = automation.ParameterDes[2];
                LabelParameter3.Visible             = true;
            }
            else
            {
                PanelParameterOut.Visible = true;
                if (automation.ParameterDes[0].Equals(StringDef.ServerId))
                {
                    ButtonServerIdSelect.Visible = true;
                }
                TextBoxParameter1.Visible = true;
                LabelParameter1.Visible   = true;
                LabelParameter1.Text      = automation.ParameterDes[0];

                if (automation.ParameterDes[1].Equals(StringDef.ServerGroupId))
                {
                    ButtonServerGroupIdSelect.Visible = true;
                }
                TextBoxParameter2.Visible = true;
                LabelParameter2.Visible   = true;
                LabelParameter2.Text      = automation.ParameterDes[1];
                PanelParameterOut.Visible = true;
                TextBoxParameter3.Visible = false;
                LabelParameter3.Text      = automation.ParameterDes[2];
                LabelParameter3.Visible   = false;
            }

            break;
        }
    }
Пример #36
0
		/// <summary>
		/// 执行自动化作业
		/// </summary>
		/// <remarks>简化版,免回调</remarks>
		public void Do(IAutomation automation, AutomationContext context)
		{
			Do(automation, context, null, null, null);
		}
Пример #37
0
 private void Run()
 {
     buttonItem15.Enabled = false;
          runToolStripMenuItem.Enabled = false;
          buttonItem16.Enabled = true;
          buttonItem4.Enabled = true;
          buttonItem2.Enabled = false;
          Run f = new Run();
          f._txtScript.Text = treeViewproject.SelectedNode.Text;
          TreeNode currnode = treeViewproject.Nodes[0].Nodes[0];
          //List<DirectoryInfo> dirlist = Duyetthumuccon((String)currnode.Tag);
          List<string> dataList = Duyetfile((String)currnode.Tag);
          dataList.Insert(0, @"[None]");
          f._cboData.DataSource = dataList;
          f.CurrentProjectPath = CurrentProjectPath;
          f.ShowDialog();
          CurrentAutomation = f.CurrenrtAutomation;
          CurrentAutomation.Ended += CurrentAutomation_Ended;
 }
Пример #38
0
 void CurrentAutomation_Ended(IAutomation at)
 {
     //throw new NotImplementedException();
      if (System.Windows.Forms.MessageBox.Show("Testing Finish... ", "Confirm", MessageBoxButtons.OK, MessageBoxIcon.Information) == DialogResult.OK)
      {
          //LoadTreeView();
      }
      CurrentAutomation = null;
 }
Пример #39
0
		void NotifyWaitUnit(IAutomation automation, AutomationUnit callingUnit)
		{
			if (callingUnit != null)
			{
				int index = _waitForCompleteList.IndexOf(callingUnit);
                if (index >= 0 && index < _waitForCompleteList.Count)
				{
					AutomationUnit waitUnit = _waitForCompleteList[index] as AutomationUnit;
					IAutomation waitAutomation = waitUnit.Automation;
					if (waitAutomation.Success == automation)
					{
						waitAutomation.Success = null;
					}
					else if (waitAutomation.Failure == automation)
					{
						waitAutomation.Failure = null;
					}
					else if (waitAutomation.Complete == automation)
					{
						waitAutomation.Complete = null;
					}

                    switch (waitAutomation.Result)
                    {
                        case AutomationResult.Success:
                            if (waitAutomation.Success == null && waitAutomation.Complete == null)
                            {
                                if (waitUnit.Callback != null)
                                {
                                    waitUnit.Callback.Invoke(waitUnit.CallbackStateObject);
                                }

                                if (waitUnit.CallingUnit != null)
                                {
                                    NotifyWaitUnit(waitAutomation, waitUnit.CallingUnit);
                                }

                                _waitForCompleteList.Remove(waitUnit);
                            }
                            break;
                        case AutomationResult.Failure:
                            if (waitAutomation.Failure == null && waitAutomation.Complete == null)
                            {
                                if (waitUnit.Callback != null)
                                {
                                    waitUnit.Callback.Invoke(waitUnit.CallbackStateObject);
                                }

                                if (waitUnit.CallingUnit != null)
                                {
                                    NotifyWaitUnit(waitAutomation, waitUnit.CallingUnit);
                                }

                                _waitForCompleteList.Remove(waitUnit);
                            }
                            break;
                    }
					
				}
			}
		}
Пример #40
0
        /// <summary>
        /// 修改任务
        /// </summary>        
        public bool EditTask(int taskId, int step, IAutomation automation, GameServer[] servers, string name, string comment)
        {
            using (IBlazeDatabase db = DbFactory.GetDatabase())
            {
                try
                {
                    BatchTask task = this.GetBatchTask(taskId);
                    if (task == null)
                    {
                        return false;
                    }

                    db.BeginTrans();

                    SecurityManager sm = AdminServer.TheInstance.SecurityManager;
                    FSEyeObject taskObject = sm.Get(taskId);
                    taskObject.Name = name;
                    taskObject.Comment = comment;
                    sm.Set(taskObject, db);

                    StringBuilder serverIdText = new StringBuilder();
                    foreach (GameServer server in servers)
                    {
                        serverIdText.Append(server.Id);
                        serverIdText.Append(',');
                    }

                    IBlazeTable batchTaskTable = db.GetTable(TableString.BatchTaskTableName);
                    DataSet batchTaskDataSet = new DataSet();
                    batchTaskTable.Get(batchTaskDataSet);
                    DataTable taskTable = batchTaskDataSet.Tables[TableString.BatchTaskTableName];
                    DataRow[] taskRows = taskTable.Select(string.Concat(TableString.BatchTaskId, "=", taskId));
                    if (taskRows != null && taskRows.Length > 0)
                    {
                        taskRows[0][TableString.BatchTaskStep] = step;
                        taskRows[0][TableString.BatchTaskAutomation] = AdminServer.TheInstance.AutomationManager.Save(automation);
                        taskRows[0][TableString.BatchTaskServerIds] = SystemConfig.Current.DefaultEncoding.GetBytes(serverIdText.Length == 0 ? string.Empty : serverIdText.ToString(0, serverIdText.Length - 1));
                        batchTaskTable.Set(taskTable);
                    }

                    //修改内存中数据
                    task.Step = step;
                    task.Automation = automation;
                    task.ClearServers();
                    foreach (GameServer server in servers)
                    {
                        task.AddServer(server.Id);
                    }

                    db.CommitTrans();
                    return true;
                }
                catch (Exception)
                {
                    if (db != null)
                        db.RollbackTrans();
                    return false;
                }
            }
        }
 public void AddAutomation(IAutomation automation)
 {
     _automations.AddOrUpdate(automation.Id, automation);
 }
Пример #42
0
    void SetParameter(IAutomation automation)
    {
        ButtonServerIdSelect.Visible = false;
        ButtonFtpServerIdSelect.Visible = false;
        ButtonServerGroupIdSelect.Visible = false;
        switch ((int)automation.Parameter[0])
        {
            case 0:
                PanelParameterOut.Visible = false;
                break;
            case 1:
                PanelParameterOut.Visible = true;
                if (automation.ParameterDes[0].Equals(StringDef.ServerId))
                    ButtonServerIdSelect.Visible = true;
                TextBoxParameter1.Visible = true;
                LabelParameter1.Text = automation.ParameterDes[0];
                LabelParameter1.Visible = true;
                TextBoxParameter2.Visible = false;
                LabelParameter2.Visible = false;
                TextBoxParameter3.Visible = false;
                LabelParameter3.Visible = false;

                MailContentTypeCheckBoxList.Visible = false;

                break;
            case 2:
                PanelParameterOut.Visible = true;

                TextBoxParameter1.Visible = true;
                if (automation.ParameterDes[0].Equals(StringDef.ServerId))
                    ButtonServerIdSelect.Visible = true;
                if (automation.Guid == "{2A034C09-D437-4b6a-8338-B76AA8F5D543}")
                    ButtonFtpServerIdSelect.Visible = true;
                LabelParameter1.Text = automation.ParameterDes[0];
                LabelParameter1.Visible = true;

                if (automation.ParameterDes[1].Equals(StringDef.ServerGroupId))
                    ButtonServerGroupIdSelect.Visible = true;
                TextBoxParameter2.Visible = true;
                LabelParameter2.Text = automation.ParameterDes[1];
                LabelParameter2.Visible = true;
                TextBoxParameter3.Visible = false;
                LabelParameter3.Visible = false;

                MailContentTypeCheckBoxList.Visible = false;

                break;
            case 3:
                //如果该任务的类型为“发邮件”
                if (automation.Guid == "{eca2ad62-0238-4996-82c0-852009463d94}")
                {
                    PanelParameterOut.Visible = true;
                    if (automation.ParameterDes[0].Equals(StringDef.ServerId))
                        ButtonServerIdSelect.Visible = true;
                    TextBoxParameter1.Visible = true;
                    LabelParameter1.Visible = true;
                    LabelParameter1.Text = automation.ParameterDes[0];

                    if (automation.ParameterDes[1].Equals(StringDef.ServerGroupId))
                        ButtonServerGroupIdSelect.Visible = true;
                    TextBoxParameter2.Visible = true;
                    LabelParameter2.Visible = true;
                    LabelParameter2.Text = automation.ParameterDes[1];
                    PanelParameterOut.Visible = true;
                    TextBoxParameter3.Visible = false;
                    MailContentTypeCheckBoxList.Visible = true;
                    LabelParameter3.Text = automation.ParameterDes[2];
                    LabelParameter3.Visible = true;
                }
                else
                {
                    PanelParameterOut.Visible = true;
                    if (automation.ParameterDes[0].Equals(StringDef.ServerId))
                        ButtonServerIdSelect.Visible = true;
                    TextBoxParameter1.Visible = true;
                    LabelParameter1.Visible = true;
                    LabelParameter1.Text = automation.ParameterDes[0];

                    if (automation.ParameterDes[1].Equals(StringDef.ServerGroupId))
                        ButtonServerGroupIdSelect.Visible = true;
                    TextBoxParameter2.Visible = true;
                    LabelParameter2.Visible = true;
                    LabelParameter2.Text = automation.ParameterDes[1];
                    PanelParameterOut.Visible = true;
                    TextBoxParameter3.Visible = false;
                    LabelParameter3.Text = automation.ParameterDes[2];
                    LabelParameter3.Visible = false;
                }

                break;
        }
    }
Пример #43
0
		/// <summary>
		/// 注册自动化类型
		/// </summary>
		public void Register(IAutomation automation)
		{
			if (!_automationTable.Contains(automation.Guid))
			{
				_automationTable.Add(automation.Guid, automation.GetType());
			}
		}
Пример #44
0
		/// <summary>
		/// 保存自动化作业对象
		/// </summary>
		public byte[] Save(IAutomation automation)
		{
			if (automation == null)
				return null;

			BinaryWriter writer = null;
			try
			{
				writer = new BinaryWriter(new MemoryStream());

				byte[] guidBytes = Encoding.Default.GetBytes(automation.Guid);
				writer.Write(guidBytes.Length);
				writer.Write(guidBytes, 0, guidBytes.Length);

                //################################
                StringBuilder paramBuilder = new StringBuilder();
                foreach (object obj in automation.Parameter)
                {
                    paramBuilder.Append(obj);
                    //if (obj.GetType() == typeof(int))
                    //{
                    //    paramBuilder.Append((int)obj);
                    //}
                    //else if (obj.GetType() == typeof(string))
                    //{
                    //    paramBuilder.Append(obj as string);
                    //}
                    //else if(obj.GetType() == typeof(long))
                    //{
                    //    paramBuilder.Append((long)obj);
                    //}
                    paramBuilder.Append(',');
                }
                string param = paramBuilder.ToString(0,paramBuilder.Length-1);
                //################################
                //string param = automation.Parameter;
				if (param != null)
				{
                    byte[] paramBytes = SystemConfig.Current.DefaultEncoding.GetBytes(param);
					writer.Write(paramBytes.Length);
					writer.Write(paramBytes, 0, paramBytes.Length);
				}
				else
				{
					writer.Write(0);
				}

				if (automation.Complete != null)
				{
					byte[] completeBytes = Save(automation.Complete);
					writer.Write(completeBytes.Length);
					writer.Write(completeBytes, 0, completeBytes.Length);
				}
				else
				{
					writer.Write(0);
				}

				if (automation.Success != null)
				{
					byte[] successBytes = Save(automation.Success);
					writer.Write(successBytes.Length);
					writer.Write(successBytes, 0, successBytes.Length);
				}
				else
				{
					writer.Write(0);
				}

				if (automation.Failure != null)
				{
					byte[] failureBytes = Save(automation.Failure);
					writer.Write(failureBytes.Length);
					writer.Write(failureBytes, 0, failureBytes.Length);
				}
				else
				{
					writer.Write(0);
				}

				byte[] returnBytes = (writer.BaseStream as MemoryStream).ToArray();

				return returnBytes;
			}
			catch (Exception)
			{
			}
			finally
			{
				if (writer != null)
					writer.Close();
			}

			return null;
		}
Пример #45
0
    void LoadParameter(IAutomation automation)
    {
        switch ((int)automation.Parameter[0])
        {
            case 1:
                TextBoxParameter1.Text = automation.Parameter[1].ToString();
                break;
            case 2:
                TextBoxParameter1.Text = automation.Parameter[1].ToString();
                TextBoxParameter2.Text = automation.Parameter[2].ToString();
                break;
            case 3:
                TextBoxParameter1.Text = automation.Parameter[1].ToString();
                TextBoxParameter2.Text = automation.Parameter[2].ToString();

                //如果该任务的类型为“发邮件”
                if (automation.Guid == "{eca2ad62-0238-4996-82c0-852009463d94}")
                {                    
                    string contentTypes = automation.Parameter[3] as string;
                    foreach (ListItem item in MailContentTypeCheckBoxList.Items)
                    {
                        if (contentTypes.Contains(item.Value))
                        {
                            item.Selected = true;
                        }
                        else
                        {
                            item.Selected = false;
                        }
                    }
                }
                else
                {
                    TextBoxParameter3.Text = automation.Parameter[3].ToString();
                }


                break;
        }
    }
Пример #46
0
			public AutomationUnit(IAutomation automation, AutomationContext context, DelegateAutomationDone callback, object stateObject, AutomationUnit callingUnit)
			{
				_automation = automation;
				_context = context;
				_callback = callback;
				_callbackStateObject = stateObject;
				_callingUnit = callingUnit;
			}
Пример #47
0
 //STOP
 private void buttonItem4_Click(object sender, EventArgs e)
 {
     if (CurrentAutomation != null)
      {
          buttonItem2.Enabled = false;
          buttonItem16.Enabled = false;
          buttonItem15.Enabled = true;
          runToolStripMenuItem.Enabled = true;
          buttonItem4.Enabled = false;
          CurrentAutomation.Interupt();
          CurrentAutomation = null;
      }
 }
Пример #48
0
		/// <summary>
		/// 执行自动化作业
		/// </summary>
		/// <remarks>作业上下文会在这个函数内部被复制,从而保证作业各自的上下文不会互相干扰,而只能对各自的后续作业产生影响</remarks>
		public void Do(IAutomation automation, AutomationContext context, DelegateAutomationDone callback, object stateObject, AutomationUnit callingUnit)
		{
			if (automation == null)
			{
				throw new ArgumentNullException("automation");
			}

			if (context == null)
			{
				throw new ArgumentNullException("context");
			}

			_toBeAddList.Add(new AutomationUnit(automation, (AutomationContext)context.Clone(), callback, stateObject, callingUnit));
		}
Пример #49
0
	private TreeNode CreateAutomationNode(IAutomation automation, string title, string path)
	{
		TreeNode node = new TreeNode();

		if (automation != null)
		{
			node.Text = title + automation.ToString();
			node.Value = path;
						
			node.ChildNodes.Add(CreateAutomationNode(automation.Success, "success: ", "1"));
			
			node.ChildNodes.Add(CreateAutomationNode(automation.Failure, "failure: ", "0"));
			
			node.ChildNodes.Add(CreateAutomationNode(automation.Complete, "complete: ", "2"));			
		}
		else
		{
			node.Text = title + "--";
			node.Value = path;
		}

		return node;
	}
Пример #50
0
		/// <summary>
		/// 执行自动化作业
		/// </summary>
		/// <remarks>简化版,免回调</remarks>
		public void Do(IAutomation automation, AutomationContext context, DelegateAutomationDone callback, object stateObject)
		{
			Do(automation, context, callback, stateObject, null);
		}
Пример #51
0
		/// <summary>
		/// 执行自动化作业
		/// </summary>
		/// <remarks>简化版,免回调</remarks>
		public void Do(IAutomation automation, AutomationContext context, AutomationUnit callingUnit)
		{
			Do(automation, context, null, null, callingUnit);
		}
Пример #52
0
 public void AddAutomation(IAutomation automation)
 {
     _automations.AddUnique(automation.Id, automation);
     Controller.AddAutomation(automation);
 }
Пример #53
0
 static void at_Resumed(IAutomation at)
 {
     //throw new NotImplementedException();
     Console.WriteLine("Automation resumed");
 }