Ejemplo n.º 1
0
        public TaskScheduleModel CreateModel(ExecutionTypeElement element)
        {
            var type = element.Type;

            if (type == ExecutionTypes.Continuous)
            {
                var continuousElement = element as ContinuousElement;
                if (continuousElement == null)
                {
                    throw new InvalidCastException();
                }

                return(CreateContinousModel(continuousElement));
            }

            if (type == ExecutionTypes.Scheduled)
            {
                var scheduledElement = element as ScheduledElement;
                if (scheduledElement == null)
                {
                    throw new InvalidCastException();
                }

                return(CreateScheduleModel(scheduledElement));
            }

            return(CreateDefaultModel(element));
        }
Ejemplo n.º 2
0
        public void VisitExecutionOrder(ExecutionTypeElement item, XContainer container)
        {
            foreach (var element in container.Elements())
            {
                var name = element.Name.LocalName;

                ElementTypes type;
                if (!Enum.TryParse(name, out type))
                {
                    continue;
                }

                if (type != ElementTypes.Item)
                {
                    continue;
                }

                var order = new ExecutionTypeItemElement
                {
                    Id    = (string)element.Attribute("taskId"),
                    Order = (int)element.Attribute("order"),
                };

                if (item.ClientId.HasValue)
                {
                    order.Id = string.Format("client.{0}.{1}", item.ClientId, order.Id);
                }

                item.AddItem(order);
            }
        }
Ejemplo n.º 3
0
        public TaskScheduleModel CreateDefaultModel(ExecutionTypeElement element)
        {
            var model = new TaskScheduleContinuousModel
            {
                TaskId         = element.Id,
                IdlePeriod     = 15,
                IdlePeriodType = "minutes",
            };

            foreach (var subModel in element.ExecutionList)
            {
                model.AddScheduleItem(new TaskScheduleItemModel
                {
                    TaskId = subModel.Id,
                    Order  = subModel.Order,
                });
            }

            return(model);
        }