상속: MonoBehaviour
예제 #1
0
        public MainPage()
        {
            this.InitializeComponent();

            //Set IoT Hub & Azure Storage connection string from container for app settings
            IoTHubConnTextBox.Text  = App.IOTHUBCONNSTRING;
            StorageConnTextBox.Text = App.STORAGECONNSTRING;
            if (App.IOTHUBCONNSTRING.Length > 0)
            {
                ListDevices();
                SettingsGrid.Visibility = Visibility.Collapsed;
            }

            //Set root MainPage for all User Controls
            DeviceInfo.SetMainPage(this);
            Applications.SetMainPage(this);
            WindowsTelemetry.SetMainPage(this);
            WindowsUpdate.SetMainPage(this);
            Reboot.SetMainPage(this);
            TimeSettings.SetMainPage(this);
            Certificates.SetMainPage(this);
            DiagnosticLogs.SetMainPage(this);
            FactoryReset.SetMainPage(this);
            Wifi.SetMainPage(this);
            DHA.SetMainPage(this);
        }
예제 #2
0
        private static void ProcessRequest(HttpListenerContext context)
        {
            switch (context.Request.HttpMethod.ToUpper())
            {
            case "PUNT37":

                if (Reboot.ForceReboot())
                {
                    context.Response.StatusCode        = 200;
                    context.Response.StatusDescription = "Rebooting";
                }
                else
                {
                    context.Response.StatusCode        = 500;
                    context.Response.StatusDescription = "Failure Rebooting";
                }
                context.Response.Close();
                break;

            case "GET":

                context.Response.StatusDescription = "Never Punt";
                context.Response.StatusCode        = 200;
                context.Response.Close();
                break;

            case "PUT":

                var body = new StreamReader(context.Request.InputStream).ReadToEnd();
                if (body.ToUpper() == "PUNT37")
                {
                    if (Reboot.ForceReboot())
                    {
                        context.Response.StatusCode        = 200;
                        context.Response.StatusDescription = "Rebooting";
                    }
                    else
                    {
                        context.Response.StatusCode        = 500;
                        context.Response.StatusDescription = "Failure Rebooting";
                    }
                }
                else
                {
                    context.Response.StatusDescription = "Body string not recognized -- Never Punt";
                    context.Response.StatusCode        = 400;
                }
                context.Response.Close();
                break;

            default:

                context.Response.StatusCode = 404;
                context.Response.Close();
                break;
            }
        }
예제 #3
0
        public HubConnector(string url, string hubName, string carName)
        {
            connection   = new HubConnection(url);
            proxy        = connection.CreateHubProxy(hubName);
            this.carName = carName;

            Console.WriteLine($"url: {url} hubname: {hubName} carname: {carName}");

            proxy.On <string>("SentConnectToClient", client =>
            {
                IsConnecting    = true;
                ConnectedClient = client;
                ConnectingToClient?.Invoke(client);
            });

            proxy.On("SentDisconnectFromClient", () =>
            {
                IsConnecting    = false;
                ConnectedClient = "";
                DisconnectingFromClient?.Invoke();
            });

            proxy.On <Command[]>("SentCommands", commands =>
            {
                if (IsConnecting)
                {
                    GetCommand?.Invoke(commands);
                }
            });

            proxy.On("AbortExcuting", () =>
            {
                AbortExcuting?.Invoke();
            });

            proxy.On("Shutdown", () =>
            {
                Shutdown?.Invoke();
            });

            proxy.On("Reboot", () =>
            {
                Reboot?.Invoke();
            });
        }
예제 #4
0
        public CommandManager()
        {
            Console.WriteLine("Registering commands...");

            #region Command registering
            Register(Echo.Name, Echo.Info, Echo.NeedsParam, () => Echo.Run(y.ToArray()));
            Register(Shutdown.Name, Shutdown.Info, Shutdown.NeedsParam, () => Shutdown.Run());
            Register(ShowCommands.Name, ShowCommands.Info, ShowCommands.NeedsParam, () => ShowCommands.Run());
            Register(Reboot.Name, Reboot.Info, Reboot.NeedsParam, () => Reboot.Run());
            Register(Clear.Name, Clear.Info, Clear.NeedsParam, () => Clear.Run());
            Register(Cd.Name, Cd.Info, Cd.NeedsParam, () => Cd.Run(y.ToArray()[0]));
            Register(Ls.Name, Ls.Info, Ls.NeedsParam, () => Ls.Run());
            Register(Cat.Name, Cat.Info, Cat.NeedsParam, () => Cat.Run(y.ToArray()[0]));
            Register(Edit.Name, Edit.Info, Edit.NeedsParam, () => Edit.Run(y.ToArray()[0]));
            Register(Lspci.Name, Lspci.Info, Lspci.NeedsParam, () => Lspci.Run());
            Register(CTime.Name, CTime.Info, CTime.NeedsParam, () => CTime.Run());
            Register(MD5.Name, MD5.Info, MD5.NeedsParam, () => MD5.Run(y.ToArray()[0]));
            Register(SHA256.Name, SHA256.Info, SHA256.NeedsParam, () => SHA256.Run(y.ToArray()[0]));
            Register(Snake.Name, Snake.Info, Snake.NeedsParam, () => Snake.Run());
            #endregion

            CustomConsole.WriteLineOK("Command Manager initialized");
        }
예제 #5
0
 public void RebootTest()
 {
     Reboot request = new Reboot();
     var    result  = JsonConvert.DeserializeObject <KodiJSON.System.Response.RebootResponse>(ExecuteTest.GetResponse(request));
 }
        public void selectCommand(int command, List <RaspberryPi> pis)
        {
            Command c;

            switch (command)
            {
            case 1:
                foreach (RaspberryPi pi in pis)
                {
                    c = new Status(pi);
                    Task task = new Task(c);
                    threadPool.addTask(task);
                }
                break;

            case 2:
                foreach (RaspberryPi pi in pis)
                {
                    c = new Reboot(pi);
                    Task task = new Task(c);
                    threadPool.addTask(task);
                }
                break;

            case 3:
                foreach (RaspberryPi pi in pis)
                {
                    c = new Update(pi);
                    // Send to tasks pool, then issueCommand
                    Task task = new Task(c);
                    threadPool.addTask(task);
                }
                break;

            case 4:
                foreach (RaspberryPi pi in pis)
                {
                    Console.WriteLine();
                    Console.WriteLine(@"Note: paths in Windows use backslashes for example: S:\ENS\Labs\Raspberry Pi");
                    Console.WriteLine("       paths in Linux use forward slashes for example: /home/pi/scripts/start.py\n");
                    Console.WriteLine("Please type the full path to the file you would like to transfer.");
                    string local = Console.ReadLine();
                    Console.WriteLine("Please type the full path to where you would like the file transferred to.");
                    string remote = Console.ReadLine();
                    c = new Transfer(pi, local, remote);
                    Task task = new Task(c);
                    threadPool.addTask(task);
                }
                break;

            case 5:
                foreach (RaspberryPi pi in pis)
                {
                    Console.WriteLine("Which package would you like to install? Please make sure it is the correct linux package name");
                    string package = Console.ReadLine();
                    c = new Install(pi, package);
                    Task task = new Task(c);
                    threadPool.addTask(task);
                }
                break;

            case 6:
                foreach (RaspberryPi pi in pis)
                {
                    c = new Setup(pi);
                    Task task = new Task(c);
                    threadPool.addTask(task);
                }
                break;

            case 7:

                foreach (RaspberryPi pi in pis)
                {
                    c = new OpenShell(pi.getHostname());
                    Task task = new Task(c);
                    threadPool.addTask(task);
                }
                break;
            }
        }
예제 #7
0
        private void ThreadLaunch(Timeline timeline, TimelineHandler handler)
        {
            try
            {
                _log.Trace($"Attempting new thread for: {handler.HandlerType}");

                Thread    t         = null;
                ThreadJob threadJob = new ThreadJob
                {
                    Id      = Guid.NewGuid().ToString(),
                    Handler = handler
                };

                switch (handler.HandlerType)
                {
                case HandlerType.NpcSystem:
                    NpcSystem npc = new NpcSystem(handler);
                    break;

                case HandlerType.Command:
                    t = new Thread(() =>
                    {
                        Cmd o = new Cmd(handler);
                    })
                    {
                        IsBackground = true,
                        Name         = threadJob.Id
                    };
                    t.Start();

                    threadJob.ProcessName = ProcessManager.ProcessNames.Command;

                    break;

                case HandlerType.Word:
                    _log.Trace("Launching thread for word");
                    if (_isWordInstalled)
                    {
                        var pids = ProcessManager.GetPids(ProcessManager.ProcessNames.Word).ToList();
                        if (pids.Count > timeline.TimeLineHandlers.Count(o => o.HandlerType == HandlerType.Word))
                        {
                            return;
                        }

                        t = new Thread(() =>
                        {
                            WordHandler o = new WordHandler(timeline, handler);
                        })
                        {
                            IsBackground = true,
                            Name         = threadJob.Id
                        };
                        t.Start();

                        threadJob.ProcessName = ProcessManager.ProcessNames.Word;
                    }
                    break;

                case HandlerType.Excel:
                    _log.Trace("Launching thread for excel");
                    if (_isExcelInstalled)
                    {
                        var pids = ProcessManager.GetPids(ProcessManager.ProcessNames.Excel).ToList();
                        if (pids.Count > timeline.TimeLineHandlers.Count(o => o.HandlerType == HandlerType.Excel))
                        {
                            return;
                        }

                        t = new Thread(() =>
                        {
                            ExcelHandler o = new ExcelHandler(timeline, handler);
                        })
                        {
                            IsBackground = true,
                            Name         = threadJob.Id
                        };
                        t.Start();

                        threadJob.ProcessName = ProcessManager.ProcessNames.Excel;
                    }
                    break;

                case HandlerType.Clicks:
                    _log.Trace("Launching thread to handle clicks");
                    t = new Thread(() =>
                    {
                        Clicks o = new Clicks(handler);
                    })
                    {
                        IsBackground = true,
                        Name         = threadJob.Id
                    };
                    t.Start();
                    break;

                case HandlerType.Reboot:
                    _log.Trace("Launching thread to handle reboot");
                    t = new Thread(() =>
                    {
                        Reboot o = new Reboot(handler);
                    })
                    {
                        IsBackground = true,
                        Name         = threadJob.Id
                    };
                    t.Start();
                    break;

                case HandlerType.PowerPoint:
                    _log.Trace("Launching thread for powerpoint");
                    if (_isPowerPointInstalled)
                    {
                        var pids = ProcessManager.GetPids(ProcessManager.ProcessNames.PowerPoint).ToList();
                        if (pids.Count > timeline.TimeLineHandlers.Count(o => o.HandlerType == HandlerType.PowerPoint))
                        {
                            return;
                        }

                        t = new Thread(() =>
                        {
                            PowerPointHandler o = new PowerPointHandler(timeline, handler);
                        })
                        {
                            IsBackground = true,
                            Name         = threadJob.Id
                        };
                        t.Start();

                        threadJob.ProcessName = ProcessManager.ProcessNames.PowerPoint;
                    }
                    break;

                case HandlerType.Outlook:
                    _log.Trace("Launching thread for outlook - note we're not checking if outlook installed, just going for it");
                    //if (this.IsOutlookInstalled)
                    //{
                    t = new Thread(() =>
                    {
                        Outlook o = new Outlook(handler);
                    })
                    {
                        IsBackground = true,
                        Name         = threadJob.Id
                    };
                    t.Start();

                    threadJob.ProcessName = ProcessManager.ProcessNames.Outlook;
                    //}

                    break;

                case HandlerType.BrowserIE:
                    //IE demands COM apartmentstate be STA so diff thread creation required
                    t = new Thread(() =>
                    {
                        BrowserIE o = new BrowserIE(handler);
                    });
                    t.SetApartmentState(ApartmentState.STA);
                    t.IsBackground = true;
                    t.Name         = threadJob.Id;
                    t.Start();

                    break;

                case HandlerType.Notepad:
                    //TODO
                    t = new Thread(() =>
                    {
                        Notepad o = new Notepad(handler);
                    })
                    {
                        IsBackground = true,
                        Name         = threadJob.Id
                    };
                    t.Start();

                    break;

                case HandlerType.BrowserChrome:
                    t = new Thread(() =>
                    {
                        BrowserChrome o = new BrowserChrome(handler);
                    })
                    {
                        IsBackground = true,
                        Name         = threadJob.Id
                    };
                    t.Start();

                    threadJob.ProcessName = ProcessManager.ProcessNames.Chrome;

                    break;

                case HandlerType.BrowserFirefox:
                    t = new Thread(() =>
                    {
                        BrowserFirefox o = new BrowserFirefox(handler);
                    })
                    {
                        IsBackground = true,
                        Name         = threadJob.Id
                    };
                    t.Start();

                    threadJob.ProcessName = ProcessManager.ProcessNames.Firefox;

                    break;

                case HandlerType.Watcher:
                    t = new Thread(() =>
                    {
                        Watcher o = new Watcher(handler);
                    })
                    {
                        IsBackground = true,
                        Name         = threadJob.Id
                    };
                    t.Start();

                    //threadJob.ProcessName = ProcessManager.ProcessNames.Watcher;

                    break;
                }

                if (threadJob.ProcessName != null)
                {
                    _threadJobs.Add(threadJob);
                }

                if (t != null)
                {
                    _threads.Add(t);
                }
            }
            catch (Exception e)
            {
                _log.Error(e);
            }
        }