Example #1
0
        public Show(Job_Configuration configuration, Size showSize)
        {
            this.Configuration = configuration;

            //this.displayManagers = new List<ContentDisplayManager>();
            this.displays = new List<ContentDisplay>();

            CustomWindow window = new CustomWindow(this.Configuration.Layout);

            window.Generate();
            window.ApplySize(showSize);

            this.ContentWindow = window;

            /*switch (configuration.Layout)
            {
                case WindowLayout.SingleWindow:
                    this.ContentWindow = new SingleWindow();
                    break;
                case WindowLayout.DoubleWindowHorizontalSplitted:
                    this.ContentWindow = new DoubleWindowHorizontalSplittedWindow();
                    break;
                case WindowLayout.DoubleWindowVertikalSplitted:
                    this.ContentWindow = new PiPWindow(); // new DoubleWindowVerticalSplittedWindow();
                    break;
                default:
                    this.ContentWindow = new SingleWindow();
                    break;
            }*/
        }
        public static void SaveJobConfiguration(Job_Configuration configuration)
        {
            RCS_Job jobMessage = new RCS_Job(configuration, RemoteType.Client);
            byte[] bytes = Remote_Content_Show_MessageGenerator.GetMessageAsByte(jobMessage);

            try
            {
                File.WriteAllBytes(Path.Combine(GetWriteablePath(), SavedJobConfigurationFilename), bytes);
            }
            catch (Exception)
            {
                EventsManager.Log(Job_EventType.Error, configuration, "The job configuration could not be saved.");
            }
        }
        public async static void Log(Job_EventType logType, Job_Configuration concernedJob, string description)
        {
            List<LoggedEvent> loggedEvents = await GetLoggedEvents();

            LoggedEvent newloggedEvent = new LoggedEvent() { Type = logType, Description = description };
            newloggedEvent.Time = DateTime.Now;
            
            if (concernedJob != null)
            {
                LoggedJob newLoggedJob = new LoggedJob() { JobID = concernedJob.JobID };
                newLoggedJob.Name = concernedJob.Name;

                newloggedEvent.ConcernedJob = newLoggedJob;
            }
            else
            {
                LoggedJob emptyJob = new LoggedJob() { JobID = new Guid(), Name = "-" };

                newloggedEvent.ConcernedJob = emptyJob;
            }

            loggedEvents.Add(newloggedEvent);

            await semaphore.WaitAsync();

            try
            {
                // begin

                using (FileStream fs = new FileStream(Path.Combine(PersistenceManager.GetWriteablePath(), LoggedEventsFilename), FileMode.Create, FileAccess.Write))
                {
                    DataContractSerializer dcs = new DataContractSerializer(typeof(List<LoggedEvent>));

                    using (XmlDictionaryWriter writer = XmlDictionaryWriter.CreateTextWriter(fs, Encoding.UTF8))
                    {
                        writer.WriteStartDocument();
                        dcs.WriteObject(writer, loggedEvents);
                    }
                }

                // end
            }
            finally
            {
                semaphore.Release();
            }
        }
        public ContentDisplayManager(JobWindowList jobForWindow, List<Agent> availableAgents, Job_Configuration configuration)
        {
            this.jobForWindow = jobForWindow;
            this.configuration = configuration;

            this.workingAgents = new List<WorkingAgent>();
            this.agentSelectors = new Dictionary<Job, AgentSelector>();

            foreach (Job job in jobForWindow.Jobs)
            {
                AgentSelector selector = new AgentSelector(job, availableAgents);
                selector.OnAgentNotReachable += Selector_OnAgentNotReachable;

                this.agentSelectors[job] = selector;
            }

            this.Running = false;
        }
        private Job_Configuration GetTestConfiguration()
        {
            Job_Configuration config = new Job_Configuration();
            config.Name = "testconfig1";
            config.Layout = CustomWindow.GetTestLayout(); // WindowLayout.DoubleWindowVertikalSplitted;
            config.Agents.Add(new Agent() { IP = "10.101.100.30" });
            config.Agents.Add(new Agent() { IP = "10.101.100.22" });

            List<Job> jobs1 = new List<Job>();
            //jobs1.Add(new Job() { Duration = 30, OrderingNumber = 3, Resource = new FileResource() { Path = "http://www.w3schools.com/html/mov_bbb.mp4" } });
            jobs1.Add(new Job() { Duration = 30, OrderingNumber = 1, Resource = new FileResource() { Name = "test.pptx", Path = @"C:\Temp\test.pptx" } }); // @"\\floppy2.itgeo.fhwn.ac.at\PW_2_Team1\test\test1.pptx" } });
            //jobs1.Add(new Job() { Duration = 15, OrderingNumber = 2, Resource = new WebResource() { Path = "http://www.google.at" } });

            List<Job> jobs2 = new List<Job>();
            //jobs2.Add(new Job() { Duration = 15, OrderingNumber = 2, Resource = new WebResource() { Path = "http://www.fhwn.ac.at" } });
            jobs2.Add(new Job() { Duration = 30, OrderingNumber = 3, Resource = new FileResource() { Name = "excel.xlsx", Path = @"\\floppy2.itgeo.fhwn.ac.at\PW_2_Team1\test\test1.xlsx" } });
            //jobs2.Add(new Job() { Duration = 30, OrderingNumber = 1, Resource = new FileResource() { Path = "http://img.pr0gramm.com/2016/01/22/ef07ff94fd3236d1.jpg" } });
            //jobs2.Add(new Job() { Duration = 15, OrderingNumber = 1, Resource = new FileResource() { Local = true, Path = "jellyfish2d.jpg" } });

            config.JobLists.Add(1, new JobWindowList() { Looping = true, WindowLayoutNumber = 1, Jobs = jobs1 });
            config.JobLists.Add(2, new JobWindowList() { Looping = true, WindowLayoutNumber = 2, Jobs = jobs2 });

            return config;
        }
 public RCS_Job(Job_Configuration configuration, RemoteType remote) : base(remote)
 {
     this.Configuration = configuration;
 }
        private async void Admin_OnJobConfigurationReceived(Job_Configuration configuration)
        {
            PersistenceManager.SaveJobConfiguration(configuration);

            await this.Dispatcher.RunAsync(CoreDispatcherPriority.Normal, () =>
            {
                if (this.currentShow != null)
                {
                    this.currentShow.Cancel();
                    this.currentShow = null;

                    this.LayoutContainer.Children.Clear();                    
                }

                this.currentShow = new Show(configuration, new Size(rootGrid.ActualWidth, rootGrid.ActualHeight));

                this.LayoutContainer.Children.Add(this.currentShow.ContentWindow.GetRoot());

                this.currentShow.Start();
            });
        }