Exemplo n.º 1
0
        public static TaskListWindowViewModel From(SmallerTaskList tasks, RunHistoryList history)
        {
            var jobs = tasks.Tasks
                .GroupJoin(history, 
                    o => o.Identifier, i => i.Identifier, 
                    (o, i) => new {Task = o, History = i})
                .SelectMany(io => io.History.DefaultIfEmpty(),
                    (o,i) => new {Task = o.Task, History=i})
                .Select(p => new Job
                {
                    Id = p.Task.Identifier,
                    Type = p.Task.GetType().Name,
                    RunDate = p.History == null ? null : (DateTime?)p.History.RunDate,
                    ScheduledDate = p.Task.ScheduledDate,
                    Result = Null(p.History).Result
                })
                .OrderBy(p => p.ScheduledDate);

            return new TaskListWindowViewModel
            {
                Things = jobs.ToArray()
            };
        }
Exemplo n.º 2
0
        private void SampleTask()
        {
            var tasks = new SmallerTaskList
                        {
                            Parameters = new List<Parameter>
                            {
                                new Parameter{Key = "ADMINISTRATOR", Value = "Andi"}
                            },
                            Tasks = new System.Collections.Generic.List<SmallerTaskBase>
                            {
                                new MailTask
                                {
                                    ScheduledDate = new DateTime(2016, 02, 10),
                                    Body = "Foo\r\nBar",
                                    Subject = "Bar",
                                    To = "*****@*****.**",
                                    Identifier = Guid.NewGuid().ToString()
                                }
                            }
                        };
                        var s = new System.Xml.Serialization.XmlSerializer(typeof (SmallerTaskList), new [] {typeof(SmallerTaskBase), typeof(MailTask)});
                        var m = new MemoryStream();
                        s.Serialize(m, tasks);

                        System.IO.File.WriteAllBytes("SampleTasks.xml", m.ToArray());
        }