Пример #1
0
        public void LoadJob(string jobFileName)
        {
            this.Clear();

            //var xmlDoc = new XmlDocument();
            if (!File.Exists(jobFileName))
            {
                throw new FileNotFoundException();
            }

            var doc = new XmlDocument();

            doc.Load(jobFileName);

            //XPathDocument xPathDoc = new XPathDocument(jobFileName);
            //XPathNavigator nav = xPathDoc.CreateNavigator();
            var job = new CentipedeJob(jobFileName, doc)
            {
                FileName = jobFileName
            };

            //var it = nav.Select("//Actions/*");

            IEnumerable <XmlElement> it = doc.GetElementsByTagName("Actions")[0].ChildNodes.OfType <XmlElement>();

            foreach (XmlElement actionElement in it)
            {
                AddAction(job, Action.FromXml(actionElement, this));
            }

            this.Job = job;

            this.OnAfterLoad(EventArgs.Empty);
        }
Пример #2
0
        /// <summary>
        ///     Add action to the job queue.  By default, it is added as the last action in the job.
        /// </summary>
        /// <param name="job"></param>
        /// <param name="action">Action to add</param>
        /// <param name="index">(Optional) Index to add action at.  Defaults to end (-1).</param>
        public void AddAction(CentipedeJob job, IAction action, Int32 index = -1)
        {
            switch (index)
            {
            case -1: //at end
                if (job.Actions.Any())
                {
                    job.Actions.Last().Next = action;
                }
                job.Actions.Add(action);

                // index = this.Job.Actions.IndexOf(action);

                break;

            case 0: //first
                IAction oldFirst = job.Actions.FirstOrDefault();
                job.Actions.Insert(0, action);
                action.Next = oldFirst;
                break;

            default:
                IAction prevAction = job.Actions[index - 1];
                IAction nextAction = prevAction.Next;
                prevAction.Next = action;
                action.Next     = nextAction;
                job.Actions.Insert(index, action);
                break;
            }

            //index = this.Job.Actions.IndexOf(action);
            this.OnActionAdded(new ActionEventArgs
            {
                Action             = action,
                Index              = index,
                LoadedSuccessfully = !(action is MissingAction)
            });
        }
Пример #3
0
        public JobPropertyForm(ref CentipedeJob job)
        {
            Job = job;

            InitializeComponent();

            if (!String.IsNullOrEmpty(job.Name))
            {
                JobNameTextbox.Text = job.Name;
            }
            if (!String.IsNullOrEmpty(job.InfoUrl))
            {
                InfoUrlTextbox.Text = job.InfoUrl;
            }
            if (!String.IsNullOrEmpty(job.Author))
            {
                AuthorTextbox.Text = job.Author;
            }
            if (!String.IsNullOrEmpty(job.AuthorContact))
            {
                ContactTextbox.Text = job.AuthorContact;
            }
        }