Ejemplo n.º 1
0
        public bool ExitProgram(
            string name)
        {
            try
            {
                bool result;
                logger.Info("ExitProgram {0}", name);

                if (!processes.ContainsKey(name))
                {
                    logger.Info("\tUnknown {0}", name);
                    return(false);
                }

                DesktopProcess process = processes[name];

                if (!process.Running)
                {
                    logger.Info("\tStopped {0}", name);
                    return(true);
                }

                result = process.Exit();
                logger.Info("\tExit {0} {1}", name, result ? "OK" : "Fail");


                DvbViewerMonitor.NothingToMonitor();
                return(result);
            }
            catch (System.Exception ex)
            {
                logger.Error(ex);
                return(false);
            }
        }
Ejemplo n.º 2
0
        public bool ExitAllPrograms()
        {
            try
            {
                bool result;
                logger.Info("ExitAllPrograms");

                foreach (var process in processes.Values)
                {
                    if (process.Running)
                    {
                        result = process.Exit();
                        logger.Info("\tExit {0} {1}", process.Name, result ? "OK" : "Fail");
                    }
                }

                DvbViewerMonitor.NothingToMonitor();

                return(true);
            }
            catch (System.Exception ex)
            {
                logger.Error(ex);
                return(false);
            }
        }
Ejemplo n.º 3
0
        static void Main()
        {
            Environment.CurrentDirectory = AppDomain.CurrentDomain.BaseDirectory;

            logger.Info("Avid Desktop Started");

            AppDomain.CurrentDomain.UnhandledException += new UnhandledExceptionEventHandler(CurrentDomain_UnhandledException);

            try
            {
#if USE_SKY_STB
                //  The Desktop tray app is also responsible for discovering the Sky STB service locations and recording them in the registry
                //  This is simply a convenient place to do this work with the necessary access rights
                logger.Info("SkyLocator.GetSkyServices");
                SkyLocator.GetSkyServices(ConfigurationManager.AppSettings["IpAddress"], logger);
#endif

                //  Run a background thread to monitor any DVBViewer player through its COM interface
                DvbViewerMonitor.StartMonitoring();

                var config = new HttpSelfHostConfiguration("http://localhost:89");

                config.Routes.MapHttpRoute(
                    "API Default", "api/{controller}/{action}/{id}",
                    new { id = RouteParameter.Optional });


                // Create a timer with a one minute interval.
                securityPollTimer = new System.Timers.Timer(60000);
                // Hook up the Elapsed event for the timer.
                securityPollTimer.Elapsed += OnSecurityPollTimerEvent;
                securityPollTimer.Enabled  = true;

                using (HttpSelfHostServer server = new HttpSelfHostServer(config))
                {
                    server.OpenAsync().Wait();
                    var applicationContext = new CustomApplicationContext();
                    Application.Run(applicationContext);
                    logger.Info("Avid Desktop Exit");
                    DvbViewerMonitor.NothingToMonitor();
                    securityPollTimer.Stop();
                }
            }
            catch (Exception ex)
            {
                logger.Fatal(ex);
                DvbViewerMonitor.NothingToMonitor();
            }
        }
Ejemplo n.º 4
0
        public bool LaunchProgram(
            string name,
            string args)
        {
            try
            {
                bool result;
                logger.Info("LaunchProgram {0} '{1}'", name, args == null ? "" : args);

                if (!processes.ContainsKey(name))
                {
                    logger.Info("\tUnknown {0}", name);
                    return(false);
                }

                DesktopProcess process = processes[name];

                //  If the process is already running and no new arguments are specified, simply bring it to the foreground
                //  Otherwise if it is already running with different arguments, exit the existing process instance
                if (process.Running)
                {
                    if (!String.IsNullOrEmpty(args))
                    {
                        result = process.Exit();
                        logger.Info("\tExit {0} {1}", name, result ? "OK" : "Fail");
                    }
                    else
                    {
                        result = process.Foreground();
                        logger.Info("\tForeground {0} {1}", name, result ? "OK" : "Fail");
                        return(result);
                    }
                }

                //  Stop all other desktop applications - only one will run at at a time
                foreach (var otherProcess in processes.Values)
                {
                    if (otherProcess.Name != name && otherProcess.Running)
                    {
                        DvbViewerMonitor.NothingToMonitor();
                        result = otherProcess.Exit();
                        logger.Info("\tExit {0} {1}", otherProcess.Name, result ? "OK" : "Fail");
                    }
                }

                result = process.Start(args);
                logger.Info("\tStart {0} {1}", name, result ? "OK" : "Fail");

                if (name == "TV")
                {
                    DvbViewerMonitor.StartMonitoring();
                }

                return(result);
            }
            catch (System.Exception ex)
            {
                logger.Error(ex);
                return(false);
            }
        }