예제 #1
0
        public override void InitializeSystem()
        {
            try
            {
                testRoku = new Roku("172.22.3.4", 8060, "Test Roku", CrestronEthernetHelper.GetEthernetParameter(CrestronEthernetHelper.ETHERNET_PARAMETER_TO_GET.GET_CURRENT_IP_ADDRESS, 0));
                testRoku.onResponseProcessed += new EventHandler <RokuEventArgs>(testRokue_onResponseProcessed);

                testPanel = new Ts1542(0x03, this);

                if (testPanel.Register() != eDeviceRegistrationUnRegistrationResponse.Success)
                {
                    ErrorLog.Notice("Error Registering Panel, Reason: {0}", testPanel.RegistrationFailureReason);
                }
                else
                {
                    testPanel.LoadSmartObjects(string.Format(@"{0}\Test UI.sgd", Directory.GetApplicationDirectory()));
                    testPanel.SigChange += new SigEventHandler(testPanel_SigChange);
                    foreach (var so in testPanel.SmartObjects)
                    {
                        so.Value.SigChange += new SmartObjectSigChangeEventHandler(Value_SigChange);
                    }
                }
            }
            catch (Exception e)
            {
                ErrorLog.Error("Error in InitializeSystem: {0}", e.Message);
            }
        }
예제 #2
0
        private static bool SetNetworkDnsServers(ControlSystemConfig.NetworkProperties config)
        {
            if (config != null & config.dnsServers != null)
            {
                //Get the local DNS servers
                string[] localDnsServers = CrestronEthernetHelper.GetEthernetParameter(CrestronEthernetHelper.ETHERNET_PARAMETER_TO_GET.GET_DNS_SERVER, config.adapterId).Split(',');

                if (localDnsServers.Length != config.dnsServers.Length)
                {
                    //There's definetly a change - we'll simply override the servers DNS recods
                    OverrideDnsServers(config, localDnsServers);
                    return(true);
                }
                else
                {
                    for (int i = 0; i < localDnsServers.Length; i++)
                    {
                        //If any of the records is differnet, simply override all and return true
                        if (String.Compare(localDnsServers[i], config.dnsServers[i], true) != 0)
                        {
                            OverrideDnsServers(config, localDnsServers);
                            return(true);
                        }
                    }
                }
            }
            return(false);
        }
예제 #3
0
파일: CloudLog.cs 프로젝트: uxav/lib2
        private static string Post(string method, object args)
        {
            var system = new
            {
                mac_address = CrestronEthernetHelper.GetEthernetParameter(
                    CrestronEthernetHelper.ETHERNET_PARAMETER_TO_GET.GET_MAC_ADDRESS,
                    CrestronEthernetHelper.GetAdapterdIdForSpecifiedAdapterType(EthernetAdapterType.EthernetLANAdapter)),
                ip_address = CrestronEthernetHelper.GetEthernetParameter(
                    CrestronEthernetHelper.ETHERNET_PARAMETER_TO_GET.GET_CURRENT_IP_ADDRESS,
                    CrestronEthernetHelper.GetAdapterdIdForSpecifiedAdapterType(EthernetAdapterType.EthernetLANAdapter)),
                host_name = CrestronEthernetHelper.GetEthernetParameter(
                    CrestronEthernetHelper.ETHERNET_PARAMETER_TO_GET.GET_HOSTNAME,
                    CrestronEthernetHelper.GetAdapterdIdForSpecifiedAdapterType(EthernetAdapterType.EthernetLANAdapter)),
                model    = InitialParametersClass.ControllerPromptName,
                version  = InitialParametersClass.FirmwareVersion,
                ram_free = SystemMonitor.RAMFree * 1000
            };

            var app = new
            {
                index                 = InitialParametersClass.ApplicationNumber,
                name                  = InitialParametersClass.ProgramIDTag,
                version               = _assembly.GetName().Version.ToString(),
                last_start_time       = _startupTime,
                build_date            = _programInfo["App Build Date"],
                programmer            = _programInfo["Programmer Name"],
                simpl_sharp_version   = _programInfo["SIMPLSharp Version"],
                include_4_dat_version = _programInfo["Include4.dat Version"]
            };

            var requestObject = new
            {
                method,
                @params     = args,
                project_key = _projectKey,
                system,
                app
            };

            var request = new HttpsClientRequest
            {
                RequestType   = RequestType.Post,
                ContentSource = ContentSource.ContentString,
                ContentString =
                    JsonConvert.SerializeObject(requestObject, Formatting.Indented, new IsoDateTimeConverter()),
                Header    = { ContentType = "application/json" },
                KeepAlive = false,
                Url       = new Crestron.SimplSharp.Net.Http.UrlParser(@"https://crestroncloudlogger.appspot.com/api")
            };

            using (var client = new HttpsClient {
                IncludeHeaders = false
            })
            {
                var response = client.Dispatch(request);
                CrestronConsole.PrintLine("Logger response: {0}", response.Code);
                CrestronConsole.PrintLine("Logger rx:\r\n{0}", response.ContentString);
                return(response.ContentString);
            }
        }
예제 #4
0
        public static short GetAdapterIdForAddress(this IPAddress address)
        {
            if (address == null)
            {
                throw new ArgumentNullException("address");
            }

            if (address.Equals(IPAddress.Broadcast) || address.Equals(IPAddress.Any) || address.Equals(IPAddress.Loopback) || address.Equals(IPAddress.None) || address.IsIPv4Multicast())
            {
                return(-1);
            }

            var numAdapters = InitialParametersClass.NumberOfEthernetInterfaces;

            for (short ix = 0; ix < numAdapters; ++ix)
            {
                var addr   = CrestronEthernetHelper.GetEthernetParameter(CrestronEthernetHelper.ETHERNET_PARAMETER_TO_GET.GET_CURRENT_IP_ADDRESS, ix);
                var mask   = CrestronEthernetHelper.GetEthernetParameter(CrestronEthernetHelper.ETHERNET_PARAMETER_TO_GET.GET_CURRENT_IP_MASK, ix);
                var ipAddr = IPAddress.Parse(addr);
                var ipMask = IPAddress.Parse(mask);

                if (address.IsInSameSubnet(ipAddr, ipMask))
                {
                    return(ix);
                }
            }

            return(CrestronEthernetHelper.GetAdapterdIdForSpecifiedAdapterType(EthernetAdapterType.EthernetLANAdapter));
        }
예제 #5
0
        /// <summary>
        /// Create a CodecSshClient
        /// </summary>
        internal CiscoSshClient(string address, int port, string username, string password)
        {
            _address  = address;
            _port     = port;
            _username = username;
            _password = password;
            CrestronEnvironment.ProgramStatusEventHandler += type =>
            {
                _programRunning = type != eProgramStatusEventType.Stopping;
                if (_programRunning)
                {
                    return;
                }

                _threadWait.Set();
                _reconnect = false;

                if (!Connected)
                {
                    return;
                }

                CloudLog.Info("Program stopping, Sending bye to {0} at {1}", GetType().Name, _address);
                Send("bye");
            };
            _heartbeatId =
                CrestronEthernetHelper.GetEthernetParameter(
                    CrestronEthernetHelper.ETHERNET_PARAMETER_TO_GET.GET_MAC_ADDRESS,
                    CrestronEthernetHelper.GetAdapterdIdForSpecifiedAdapterType(EthernetAdapterType.EthernetLANAdapter));
        }
예제 #6
0
        public FusionAssetBase Add(CrestronControlSystem controlSystem)
        {
            uint newId = 0;

            for (uint id = 1; id <= 249; id++)
            {
                if (!this.Fusion.Room.Fusion.FusionRoom.UserConfigurableAssetDetails.Contains(id))
                {
                    newId = id;
                    break;
                }
            }

            if (newId > 0)
            {
                this.Fusion.Room.Fusion.FusionRoom.AddAsset(eAssetType.StaticAsset, newId, controlSystem.ControllerPrompt,
                                                            "Control Processor", Guid.NewGuid().ToString());

                Assets[newId] = this.Fusion.Room.Fusion.FusionRoom.UserConfigurableAssetDetails[newId].Asset;

                ((FusionStaticAsset)Assets[newId]).AddSig(eSigType.String, 1, "IP Address", eSigIoMask.InputSigOnly);
                ((FusionStaticAsset)Assets[newId]).FusionGenericAssetSerialsAsset3.StringInput[1].StringValue
                    = CrestronEthernetHelper.GetEthernetParameter(CrestronEthernetHelper.ETHERNET_PARAMETER_TO_GET.GET_CURRENT_IP_ADDRESS,
                                                                  CrestronEthernetHelper.GetAdapterdIdForSpecifiedAdapterType(EthernetAdapterType.EthernetLANAdapter));

                return(Assets[newId]);
            }
            return(null);
        }
예제 #7
0
        private static bool SetNetworkIpInfo(ControlSystemConfig.NetworkProperties config)
        {
            bool reboot = false;

            if (config != null)
            {
                //Check to see if IP address needs to be updated
                if (String.Compare(config.staticIpAddress, CrestronEthernetHelper.GetEthernetParameter(CrestronEthernetHelper.ETHERNET_PARAMETER_TO_GET.GET_STATIC_IPADDRESS, config.adapterId)) != 0)
                {
                    reboot = CrestronEthernetHelper.SetEthernetParameter(CrestronEthernetHelper.ETHERNET_PARAMETER_TO_SET.SET_STATIC_IPADDRESS, config.adapterId, config.staticIpAddress);
                }

                //Check to see if Net mask address needs to be updated
                if (String.Compare(config.staticNetMask, CrestronEthernetHelper.GetEthernetParameter(CrestronEthernetHelper.ETHERNET_PARAMETER_TO_GET.GET_STATIC_IPMASK, config.adapterId)) != 0)
                {
                    reboot = CrestronEthernetHelper.SetEthernetParameter(CrestronEthernetHelper.ETHERNET_PARAMETER_TO_SET.SET_STATIC_IPMASK, config.adapterId, config.staticNetMask);
                }

                //Check to see if Def router needs to be updated
                if (String.Compare(config.staticNetMask, CrestronEthernetHelper.GetEthernetParameter(CrestronEthernetHelper.ETHERNET_PARAMETER_TO_GET.GET_STATIC_ROUTER, config.adapterId), true) != 0)
                {
                    reboot = CrestronEthernetHelper.SetEthernetParameter(CrestronEthernetHelper.ETHERNET_PARAMETER_TO_SET.SET_STATIC_DEFROUTER, config.adapterId, config.staticDefRouter);
                }
            }
            return(reboot);
        }
        // Monitor a random relay on the server control system.
        // This monitor can only subscribe to one relay at a time
        public void Monitor(string serverHostname)
        {
            try
            {
                if (monitor != null)
                {
                    CrestronConsole.ConsoleCommandResponse("Already subscribed: " + monitor + "\r\n");
                    return;
                }
                string myHostname = "";
                // adapterID 0 usually represents the outbound LAN port
                myHostname = CrestronEthernetHelper.GetEthernetParameter(CrestronEthernetHelper.ETHERNET_PARAMETER_TO_GET.GET_HOSTNAME, 0).ToLower();

                monitor = new RelayMonitor(myHostname);
                monitor.Subscribe(serverHostname);

                CrestronConsole.ConsoleCommandResponse("Now monitoring: " + monitor);
            }
            catch (Exception e)
            {
                if (monitor != null)
                {
                    monitor.Dispose();
                    monitor = null;
                }
                CrestronConsole.ConsoleCommandResponse("Could not start client: {0}\r\n", e.Message);
            }
            finally
            {
            }
        }
예제 #9
0
        void CheckStatus(object o)
        {
            try
            {
                bool commsOk = false;
                try
                {
                    //#if DEBUG
                    CrestronConsole.PrintLine("CiscoCodec Sending Heatbeat...");
                    //#endif
                    CommandArgs args = new CommandArgs();
                    args.Add("ID", CrestronEthernetHelper.GetEthernetParameter(CrestronEthernetHelper.ETHERNET_PARAMETER_TO_GET.GET_MAC_ADDRESS,
                                                                               CrestronEthernetHelper.GetAdapterdIdForSpecifiedAdapterType(this.FeedbackServer.AdapterForIPAddress)));
                    XDocument response = this.SendCommand("Peripherals/HeartBeat", args);
                    //#if DEBUG
                    try
                    {
                        if (response.Element("Command").Element("PeripheralsHeartBeatResult").Attribute("status").Value == "OK")
                        {
                            CrestronConsole.PrintLine("HeatBeat OK");
                        }
                        else
                        {
                            CrestronConsole.PrintLine("status = {0}", response.Element("Command").Element("PeripheralsHeartBeatResult").Attribute("status").Value);
                        }
                    }
                    catch (Exception e)
                    {
                        ErrorLog.Exception("Error reading result from Heartbeat Send", e);
                    }
                    //#endif

                    this.DeviceCommunicating = true;
                    commsOk = true;
                }
                catch (Exception e)
                {
                    ErrorLog.Error("Error checking in with CiscoCodec, {0}", e.Message);
                    CrestronConsole.PrintLine("Error Sending CiscoCodec Heartbeat ...");
                    CrestronConsole.PrintLine(e.StackTrace);
                    CrestronConsole.PrintLine("Stopping CheckStatus Timer and calling CiscoCodec.Initialize()...");
                    this.DeviceCommunicating = false;
                    _CheckStatusTimer.Stop();
                    _CheckStatusTimer.Dispose();
                    this.Initialize();
                }

                if (commsOk && !this.FeedbackServer.Registered)
                {
                    ErrorLog.Warn("The CiscoCodec was not registered for feedback on CheckStatusThread. Codec could have unregistered itself due to Post errors or connectivity problems");
                    this.Registerfeedback();
                }
            }
            catch (Exception e)
            {
                ErrorLog.Exception("Error occured in CiscoCodec.CheckStatus() timer callback", e);
            }
        }
예제 #10
0
        private static bool SetNetworkDomainName(ControlSystemConfig.NetworkProperties config)
        {
            if (config != null)
            {
                if (String.Compare(config.domainName, CrestronEthernetHelper.GetEthernetParameter(CrestronEthernetHelper.ETHERNET_PARAMETER_TO_GET.GET_DOMAIN_NAME, config.adapterId), true) != 0)
                {
                    return(CrestronEthernetHelper.SetEthernetParameter(CrestronEthernetHelper.ETHERNET_PARAMETER_TO_SET.SET_DOMAINNAME, config.adapterId, config.hostName));
                }
            }

            return(false);
        }
예제 #11
0
        public InfoConfig()
        {
            Name      = "";
            Date      = DateTime.Now;
            Type      = "";
            Version   = "";
            Comment   = "";
            HostName  = CrestronEthernetHelper.GetEthernetParameter(CrestronEthernetHelper.ETHERNET_PARAMETER_TO_GET.GET_HOSTNAME, 0);
            AppNumber = InitialParametersClass.ApplicationNumber;

            RuntimeInfo = new RuntimeInfo();
        }
예제 #12
0
 /// <summary>
 /// Gets either the custom URL, a local-to-processor URL, or null if it's a default logo
 /// </summary>
 public string GetUrl()
 {
     if (Type == "url")
     {
         return(Url);
     }
     if (Type == "system")
     {
         return(string.Format("http://{0}:8080/logo.png",
                              CrestronEthernetHelper.GetEthernetParameter(CrestronEthernetHelper.ETHERNET_PARAMETER_TO_GET.GET_CURRENT_IP_ADDRESS, 0)));
     }
     return(null);
 }
예제 #13
0
        //SSMono.IO.FileSystemWatcher ListWatcher;

        public DevicePresetsModel(string key, ISetTopBoxNumericKeypad setTopBox, string fileName)
            : base(key)
        {
            PulseTime      = 150;
            DigitSpacingMS = 150;

            try
            {
                // Grab the digit functions from the device
                // If any fail, the whole thing fails peacefully
                DialFunctions = new Dictionary <char, Action <bool> >(10)
                {
                    { '1', setTopBox.Digit1 },
                    { '2', setTopBox.Digit2 },
                    { '3', setTopBox.Digit3 },
                    { '4', setTopBox.Digit4 },
                    { '5', setTopBox.Digit5 },
                    { '6', setTopBox.Digit6 },
                    { '7', setTopBox.Digit7 },
                    { '8', setTopBox.Digit8 },
                    { '9', setTopBox.Digit9 },
                    { '0', setTopBox.Digit0 },
                    { '-', setTopBox.Dash }
                };
            }
            catch
            {
                Debug.Console(0, "DevicePresets '{0}', not attached to INumericKeypad device. Ignoring", key);
                DialFunctions = null;
                return;
            }

            EnterFunction = setTopBox.KeypadEnter;

            UseLocalImageStorage = true;

            ImagesLocalHostPrefix = "http://" + CrestronEthernetHelper.GetEthernetParameter(
                CrestronEthernetHelper.ETHERNET_PARAMETER_TO_GET.GET_CURRENT_IP_ADDRESS, 0);
            ImagesPathPrefix = @"/presets/images.zip/";
            ListPathPrefix   = @"/html/presets/lists/";

            SetFileName(fileName);

            //ListWatcher = new FileSystemWatcher(@"\HTML\presets\lists");
            //ListWatcher.NotifyFilter = NotifyFilters.LastWrite;
            //ListWatcher.EnableRaisingEvents = true;
            //ListWatcher.Changed += ListWatcher_Changed;
            InitSuccess = true;
        }
예제 #14
0
파일: TemplateEngine.cs 프로젝트: uxav/lib2
        public TemplateEngine(Assembly assembly, string resourcePath, string title, bool loggedIn)
        {
            _templateContents = GetResourceContents(assembly, resourcePath);

            while (Regex.IsMatch(_templateContents, @"{% extends ([\.\w]+) %}"))
            {
                var contents = _templateContents;

                var block = GetResourceContents(assembly, Regex.Match(_templateContents, @"{% extends ([\.\w]+) %}").Groups[1].Value);

                _templateContents = Regex.Replace(block, @"{{ block_content }}",
                                                  match => Regex.Replace(contents, @"{% extends ([\.\w]+) %}", string.Empty));
            }

            _context = new Dictionary <string, object>
            {
                { "page_title", title },
                { "processor_prompt", InitialParametersClass.ControllerPromptName },
                {
                    "processor_ip_address",
                    CrestronEthernetHelper.GetEthernetParameter(
                        CrestronEthernetHelper.ETHERNET_PARAMETER_TO_GET.GET_CURRENT_IP_ADDRESS,
                        CrestronEthernetHelper.GetAdapterdIdForSpecifiedAdapterType(
                            EthernetAdapterType.EthernetLANAdapter))
                },
                {
                    "processor_hostname",
                    CrestronEthernetHelper.GetEthernetParameter(
                        CrestronEthernetHelper.ETHERNET_PARAMETER_TO_GET.GET_HOSTNAME,
                        CrestronEthernetHelper.GetAdapterdIdForSpecifiedAdapterType(
                            EthernetAdapterType.EthernetLANAdapter)).ToUpper()
                },
                { "authentication_enabled", InitialParametersClass.IsAuthenticationEnabled },
                { "login_logout_button_name", loggedIn ? "Logout" : "Login" },
                { "login_logout_link", loggedIn ? "/logout" : "/login" }
            };

            var domain = CrestronEthernetHelper.GetEthernetParameter(
                CrestronEthernetHelper.ETHERNET_PARAMETER_TO_GET.GET_DOMAIN_NAME,
                CrestronEthernetHelper.GetAdapterdIdForSpecifiedAdapterType(
                    EthernetAdapterType.EthernetLANAdapter));

            domain = domain.Length > 0 ? domain : "local";
            _context.Add("processor_domain", domain);
            _context.Add("processor_fqdn", _context["processor_hostname"] + "." + domain);
            _context.Add("system_name", _context["processor_hostname"]);
        }
예제 #15
0
        public void Get()
        {
            try
            {
                var roomId = 1;

                var host =
                    CrestronEthernetHelper.GetEthernetParameter(
                        CrestronEthernetHelper.ETHERNET_PARAMETER_TO_GET.GET_CURRENT_IP_ADDRESS,
                        CrestronEthernetHelper.GetAdapterdIdForSpecifiedAdapterType(
                            EthernetAdapterType.EthernetLANAdapter));

                try
                {
                    roomId = int.Parse(Request.QueryString["room"]);
                }
                catch
                {
                    HandleNotFound();
                    return;
                }

                uint ipId = 4;
                try
                {
                    var controllers =
                        System.UIControllers.Where(
                            ui => ui is RoomUIController && ui.DefaultRoom != null && ui.DefaultRoom.Id == roomId).ToArray();
                    if (controllers.Any())
                    {
                        ipId = controllers.First().Device.ID;
                    }

                    Redirect(string.Format("/static/xpanel/Core3XPanel.html?host={0}&ipid={1}", host,
                                           ipId.ToString("X2")));
                }
                catch (Exception e)
                {
                    HandleError(e);
                }
            }
            catch (Exception e)
            {
                HandleError(e);
            }
        }
예제 #16
0
        private static bool SetNetworkWebServer(ControlSystemConfig.NetworkProperties config)
        {
            if (config != null & config.webServer != null)
            {
                //Webserver is off, but should be set to on
                if ((bool)config.webServer & CrestronEthernetHelper.GetEthernetParameter(CrestronEthernetHelper.ETHERNET_PARAMETER_TO_GET.GET_WEBSERVER_STATUS, config.adapterId) == "OFF")
                {
                    return(CrestronEthernetHelper.SetEthernetParameter(CrestronEthernetHelper.ETHERNET_PARAMETER_TO_SET.SET_WEBSERVER_STATE, config.adapterId, "ON"));
                }

                //Webserver is on, but should be set to off
                if (!(bool)config.webServer & CrestronEthernetHelper.GetEthernetParameter(CrestronEthernetHelper.ETHERNET_PARAMETER_TO_GET.GET_WEBSERVER_STATUS, config.adapterId) == "ON")
                {
                    return(CrestronEthernetHelper.SetEthernetParameter(CrestronEthernetHelper.ETHERNET_PARAMETER_TO_SET.SET_WEBSERVER_STATE, config.adapterId, "OFF"));
                }
            }
            return(false); //We didn't change anything
        }
예제 #17
0
        object systemStart(object userObject)
        {
            while (ServerIP.Length < 7)
            {
                ServerIP = CrestronEthernetHelper.GetEthernetParameter(CrestronEthernetHelper.ETHERNET_PARAMETER_TO_GET.GET_CURRENT_IP_ADDRESS, 0);
                CrestronConsole.PrintLine("ServerIP: Retry Until LAN Ready: {0}", ServerIP);
                Thread.Sleep(1000);
            }
            if (this.SupportsIROut)
            {
                IR1.LoadIRDriver("\\USER\\Samsung UE40J5100AK.ir");
                IR1.Register();
            }

            Xpan            = new Xpanel(0x03, this);
            Xpan.SigChange += new SigEventHandler(MyXPanSigChangeHandler);
            Xpan.Register();
            return(null);
        }
예제 #18
0
        private static bool SetNetworkDhcp(ControlSystemConfig.NetworkProperties config)
        {
            if (config != null)
            {
                //DHCP is currently off, but should be set to on
                if (config.dhcp & CrestronEthernetHelper.GetEthernetParameter(CrestronEthernetHelper.ETHERNET_PARAMETER_TO_GET.GET_CURRENT_DHCP_STATE, config.adapterId) == "OFF")
                {
                    return(CrestronEthernetHelper.SetEthernetParameter(CrestronEthernetHelper.ETHERNET_PARAMETER_TO_SET.SET_DHCP_STATE, config.adapterId, "ON"));
                }

                //DHCP is currently on, but should be set to off
                if (!config.dhcp & CrestronEthernetHelper.GetEthernetParameter(CrestronEthernetHelper.ETHERNET_PARAMETER_TO_GET.GET_CURRENT_DHCP_STATE, config.adapterId) == "ON")
                {
                    return(CrestronEthernetHelper.SetEthernetParameter(CrestronEthernetHelper.ETHERNET_PARAMETER_TO_SET.SET_DHCP_STATE, config.adapterId, "ON"));
                }
            }

            return(false); //We didn't change anything
        }
예제 #19
0
        internal void Start(int portNumber)
        {
            Port = portNumber;
            if (_listeningThread != null && _listeningThread.ThreadState == ThreadState.Running)
            {
                throw new Exception("Logger already running");
            }

            try
            {
                if (InitialParametersClass.NumberOfExternalEthernetInterfaces > 0)
                {
                    Logger.Log("Control system has external ethernet interfaces, will attempt to map port to internal IP");
                    var id = CrestronEthernetHelper.GetAdapterdIdForSpecifiedAdapterType(EthernetAdapterType.EthernetCSAdapter);
                    var controlSubnetIp = CrestronEthernetHelper.GetEthernetParameter(CrestronEthernetHelper.ETHERNET_PARAMETER_TO_GET.GET_CURRENT_IP_ADDRESS, id);
                    Logger.Log($"CS IP Address is: {controlSubnetIp}");
                    var result = CrestronEthernetHelper.AddPortForwarding((ushort)portNumber, (ushort)portNumber,
                                                                          controlSubnetIp, CrestronEthernetHelper.ePortMapTransport.TCP);
                    if (result == CrestronEthernetHelper.PortForwardingUserPatRetCodes.NoErr)
                    {
                        _csPortForwardIp = controlSubnetIp;
                        Logger.Log(
                            $"Port Fowarding result = {result}, forwarded TCP port {portNumber} to internal IP: {controlSubnetIp}");
                    }
                    else
                    {
                        Logger.Warn($"Could not create port forwarding for Logger, result = {result}");
                    }
                }
            }
            catch (Exception e)
            {
                Logger.Error(e);
            }

            _listeningThread = new Thread(ListenProcess)
            {
                Name = "LoggerRx" + InitialParametersClass.ApplicationNumber
            };
            _listeningThread.Start();
            Logger.Highlight($"Logger started console on port {portNumber}");
        }
예제 #20
0
        /// <summary>
        /// Read local network propertis of the control system and saves them to the config file
        /// </summary>
        private void SyncDeviceNetworkProperties()
        {
            short adapterId = CrestronEthernetHelper.GetAdapterdIdForSpecifiedAdapterType(EthernetAdapterType.EthernetLANAdapter);

            //Mac Address
            _deviceConfig.networkProperties.macAddress = CrestronEthernetHelper.GetEthernetParameter(CrestronEthernetHelper.ETHERNET_PARAMETER_TO_GET.GET_MAC_ADDRESS, adapterId);

            //DHCP
            _deviceConfig.networkProperties.dhcp = (CrestronEthernetHelper.GetEthernetParameter(
                                                        CrestronEthernetHelper.ETHERNET_PARAMETER_TO_GET.GET_CURRENT_DHCP_STATE, adapterId).Equals("ON", StringComparison.OrdinalIgnoreCase)) ? true : false;

            //Webserver status
            _deviceConfig.networkProperties.webServer = (CrestronEthernetHelper.GetEthernetParameter(
                                                             CrestronEthernetHelper.ETHERNET_PARAMETER_TO_GET.GET_WEBSERVER_STATUS, adapterId).Equals("ON", StringComparison.OrdinalIgnoreCase)) ? true : false;

            //Static IP Info
            _deviceConfig.networkProperties.staticIpAddress = CrestronEthernetHelper.GetEthernetParameter(CrestronEthernetHelper.ETHERNET_PARAMETER_TO_GET.GET_STATIC_IPADDRESS, adapterId);
            _deviceConfig.networkProperties.staticNetMask   = CrestronEthernetHelper.GetEthernetParameter(CrestronEthernetHelper.ETHERNET_PARAMETER_TO_GET.GET_STATIC_IPMASK, adapterId);
            _deviceConfig.networkProperties.staticDefRouter = CrestronEthernetHelper.GetEthernetParameter(CrestronEthernetHelper.ETHERNET_PARAMETER_TO_GET.GET_STATIC_ROUTER, adapterId);

            //HostName
            _deviceConfig.networkProperties.hostName = CrestronEthernetHelper.GetEthernetParameter(CrestronEthernetHelper.ETHERNET_PARAMETER_TO_GET.GET_HOSTNAME, adapterId);

            //Domain Name
            _deviceConfig.networkProperties.domainName = CrestronEthernetHelper.GetEthernetParameter(CrestronEthernetHelper.ETHERNET_PARAMETER_TO_GET.GET_DOMAIN_NAME, adapterId);

            //DNS Servers
            _deviceConfig.networkProperties.dnsServers =
                CrestronEthernetHelper.GetEthernetParameter(CrestronEthernetHelper.ETHERNET_PARAMETER_TO_GET.GET_DNS_SERVER, adapterId).Split(',');

            //DNS server comes in the following format - x.x.x.x (static/DHCP) - Since we force the data to be in ipv4, we remove the (static/DHCP) section
            int i;

            foreach (string ds in _deviceConfig.networkProperties.dnsServers)
            {
                i = ds.IndexOf('(');
                if (i > 0)
                {
                    ds.Substring(0, i).Trim();
                }
            }
        }
        /// <summary>
        /// Method to handle the processor's ethernet adapter events.
        /// </summary>
        /// <param name="ethernetEventArgs">Information about the event being raised.</param>
        void CrestronEnvironment_EthernetEventHandler(EthernetEventArgs ethernetEventArgs)
        {
            // only process the main ehternet adapter's events
            if (ethernetEventArgs.EthernetAdapter != EthernetAdapterType.EthernetLANAdapter)
            {
                return;
            }

            // determine what type of event has been raised
            switch (ethernetEventArgs.EthernetEventType)
            {
            case eEthernetEventType.LinkUp:
                // get the processor's ip address
                var enetInfo = CrestronEthernetHelper.GetEthernetParameter(CrestronEthernetHelper.ETHERNET_PARAMETER_TO_GET.GET_CURRENT_IP_ADDRESS, 0);

                break;

            case eEthernetEventType.LinkDown:
            default:
                break;
            }
        }
예제 #22
0
        public override void InitializeSystem()
        {
            try
            {
                myServer = new HttpCwsServer("/api");
                myServer.ReceivedRequestEvent += new HttpCwsRequestEventHandler(myServerReceivedRequestEvent);
                myServer.Routes.Add(new HttpCwsRoute("ver")
                {
                    Name = "shversion"
                });
                myServer.Register();

                CrestronConsole.SendControlSystemCommand("progcomments:1", ref cmdResponse);
                CrestronConsole.SendControlSystemCommand("ver", ref versionResponse);

                var adapterId = CrestronEthernetHelper.GetAdapterdIdForSpecifiedAdapterType(EthernetAdapterType.EthernetLANAdapter);
                macAddress = CrestronEthernetHelper.GetEthernetParameter(CrestronEthernetHelper.ETHERNET_PARAMETER_TO_GET.GET_MAC_ADDRESS, adapterId);
            }
            catch (Exception e)
            {
                ErrorLog.Error("Error in InitializeSystem: {0}", e.Message);
            }
        }
예제 #23
0
        /// <summary>
        /// Gets the current control subnet info
        /// </summary>
        public void GetControlSubnetInfo()
        {
            OnBoolChange(true, 0, SystemInfoConstants.BusyBoolChange);

            var adapter = new ControlSubnetInfo();

            try
            {
                // get cs adapter id
                var adapterId = CrestronEthernetHelper.GetAdapterdIdForSpecifiedAdapterType(EthernetAdapterType.EthernetCSAdapter);
                if (!adapterId.Equals(EthernetAdapterType.EthernetUnknownAdapter))
                {
                    adapter.Enabled           = 1;
                    adapter.IsInAutomaticMode = (ushort)(CrestronEthernetHelper.IsControlSubnetInAutomaticMode ? 1 : 0);
                    adapter.MacAddress        = CrestronEthernetHelper.GetEthernetParameter(CrestronEthernetHelper.ETHERNET_PARAMETER_TO_GET.GET_MAC_ADDRESS, adapterId);
                    adapter.IpAddress         = CrestronEthernetHelper.GetEthernetParameter(CrestronEthernetHelper.ETHERNET_PARAMETER_TO_GET.GET_CURRENT_IP_ADDRESS, adapterId);
                    adapter.Subnet            = CrestronEthernetHelper.GetEthernetParameter(CrestronEthernetHelper.ETHERNET_PARAMETER_TO_GET.GET_CURRENT_IP_MASK, adapterId);
                    adapter.RouterPrefix      = CrestronEthernetHelper.GetEthernetParameter(CrestronEthernetHelper.ETHERNET_PARAMETER_TO_GET.GET_CONTROL_SUBNET_ROUTER_PREFIX, adapterId);
                }
            }
            catch (Exception e)
            {
                adapter.Enabled           = 0;
                adapter.IsInAutomaticMode = 0;
                adapter.MacAddress        = "NA";
                adapter.IpAddress         = "NA";
                adapter.Subnet            = "NA";
                adapter.RouterPrefix      = "NA";

                var msg = string.Format("GetControlSubnetInfo failed: {0}", e.Message);
                CrestronConsole.PrintLine(msg);
                //ErrorLog.Error(msg);
            }

            OnControlSubnetInfoChange(adapter, 0, SystemInfoConstants.ControlSubnetConfigChange);
            OnBoolChange(false, 0, SystemInfoConstants.BusyBoolChange);
        }
예제 #24
0
        public bool RequestTask(string siteId, long taskId, string roomName)
        {
            try
            {
                short adapter =
                    CrestronEthernetHelper.GetAdapterdIdForSpecifiedAdapterType(EthernetAdapterType.EthernetLANAdapter);
                string systemId =
                    CrestronEthernetHelper.GetEthernetParameter(
                        CrestronEthernetHelper.ETHERNET_PARAMETER_TO_GET.GET_MAC_ADDRESS, adapter);
                string ipAddress =
                    CrestronEthernetHelper.GetEthernetParameter(
                        CrestronEthernetHelper.ETHERNET_PARAMETER_TO_GET.GET_CURRENT_IP_ADDRESS, adapter);

                var jsonData = JsonConvert.SerializeObject(new
                {
                    api_key           = _apiKey,
                    site_id           = siteId,
                    system_id         = systemId,
                    system_ip_address = ipAddress,
                    room_name         = roomName,
                    task_id           = taskId
                }, Formatting.Indented);

                JObject result = JObject.Parse(Post("sendmail", jsonData));

                CrestronConsole.PrintLine("\r\n{0}", result);

                return(result["status"].Value <string>() == "200 OK");
            }
            catch (Exception e)
            {
                CloudLog.Error("AssistanceClient.RequestTask(taskId = {0}, roomName = {1}) Error, {2}",
                               taskId, roomName, e.Message);
                return(false);
            }
        }
 public void StartServer(string args)
 {
     try
     {
         if (this.SupportsRelay)
         {
             if (RegisterRelays())
             {
                 string hostname = "";
                 // adapterID 0 usually represents the outbound LAN port
                 hostname = CrestronEthernetHelper.GetEthernetParameter(CrestronEthernetHelper.ETHERNET_PARAMETER_TO_GET.GET_HOSTNAME, 0).ToLower();
                 if (serv != null)
                 {
                     serv.Dispose();
                 }
                 serv = new RestfulRelayServer(RelayPorts, hostname);
                 CrestronConsole.ConsoleCommandResponse("Now serving REST API rooted at http://" + hostname + "/cws/api for the control system's " +
                                                        NumberOfRelayPorts + " relay ports.");
             }
             else
             {
                 CrestronConsole.ConsoleCommandResponse("Could not start server: unable to register all relays");
             }
         }
         else
         {
             CrestronConsole.ConsoleCommandResponse("This control system does not support relays, so the Relay API could not be created");
         }
     }
     catch (Exception e)
     {
         CrestronConsole.ConsoleCommandResponse("Error in startserver user command: " + e.Message);
     }
     finally {
     }
 }
예제 #26
0
 private string getLocalIP()
 {
     return(CrestronEthernetHelper.GetEthernetParameter(CrestronEthernetHelper.ETHERNET_PARAMETER_TO_GET.GET_CURRENT_IP_ADDRESS,
                                                        CrestronEthernetHelper.GetAdapterdIdForSpecifiedAdapterType(EthernetAdapterType.EthernetLANAdapter)));
 }
예제 #27
0
        object CiscoCodecRegisterProcess(object threadObject)
        {
            while (!programStopping)
            {
                try
                {
                    if (this.HttpClient.StartSession().Length > 0)
                    {
                        ErrorLog.Notice("Codec has connected and received a session id");
                    }
                    else
                    {
                        ErrorLog.Warn("Codec has connected but did not receive session id");
                    }

                    break;
                }
                catch (Exception e)
                {
                    ErrorLog.Warn("Could not start session with Cisco codec, {0}", e.Message);
                }

                CrestronConsole.PrintLine("Waiting for codec connection... will retry in 30 seconds");
                ErrorLog.Warn("Waiting for codec connection... will retry in 30 seconds");

                CrestronEnvironment.AllowOtherAppsToRun();
                Thread.Sleep(30000);
            }

            try
            {
                CrestronConsole.PrintLine("Connecting ControlSystem to codec and registering...");

                CommandArgs args = new CommandArgs();
                args.Add("HardwareInfo", ControlSystem.ControllerPrompt);
                args.Add("ID",
                         CrestronEthernetHelper.GetEthernetParameter(
                             CrestronEthernetHelper.ETHERNET_PARAMETER_TO_GET.GET_MAC_ADDRESS,
                             CrestronEthernetHelper.GetAdapterdIdForSpecifiedAdapterType(
                                 FeedbackServer.AdapterForIPAddress)));
                args.Add("Name", "Crestron Control System");
                args.Add("NetworkAddress",
                         CrestronEthernetHelper.GetEthernetParameter(
                             CrestronEthernetHelper.ETHERNET_PARAMETER_TO_GET.GET_CURRENT_IP_ADDRESS,
                             CrestronEthernetHelper.GetAdapterdIdForSpecifiedAdapterType(
                                 FeedbackServer.AdapterForIPAddress)));
                args.Add("SerialNumber", "Unknown");
                args.Add("Type", "ControlSystem");
                var assembly = Assembly.GetExecutingAssembly().GetName();
                args.Add("SoftwareInfo", assembly.Name + " " + assembly.Version);
                XDocument response = SendCommand("Peripherals/Connect", args);

                CrestronConsole.PrintLine("Codec registration {0}",
                                          response.Element("Command").Element("PeripheralsConnectResult").Attribute("status").Value == "OK");
            }
            catch (Exception e)
            {
                ErrorLog.Exception("Error trying to register control system with Cisco Codec", e);
            }

            try
            {
                CrestronConsole.PrintLine("Registering for HttpFeedback...");
                this.Registerfeedback();
            }
            catch (Exception e)
            {
                ErrorLog.Exception("Error trying to register feedback notifications with Cisco Codec", e);
            }

            try
            {
                CrestronConsole.PrintLine("Getting call status...");
                this.Calls.Update();
            }
            catch (Exception e)
            {
                ErrorLog.Exception("Error trying to update calls status with Cisco Codec", e);
            }

            try
            {
                if (this.HasConnected != null)
                {
                    this.HasConnected(this);
                }
            }
            catch (Exception e)
            {
                ErrorLog.Exception("Error calling CiscoCodec.HasConnected thread", e);
            }

            try
            {
                CrestronConsole.PrintLine("Creating timer to periodically check the codec connection every 60 seconds");
                _CheckStatusTimer = new CTimer(CheckStatus, null, 60000, 60000);
            }
            catch (Exception e)
            {
                CrestronConsole.PrintLine("Error crating CiscoCodec CheckStatus Timer", e.Message);
                ErrorLog.Error("Error creating CiscoCodec CheckStatus Timer", e.Message);
            }

            this.DeviceCommunicating = true;

            return(null);
        }
예제 #28
0
        /// <summary>
        /// Determines whether the specified <see cref="System.Net.IPAddress"/> represents
        /// a local IP address.
        /// </summary>
        /// <returns>
        /// <c>true</c> if <paramref name="address"/> represents a local IP address;
        /// otherwise, <c>false</c>.
        /// <remarks>
        /// This local means NOT REMOTE for the current host.
        /// </remarks>
        /// </returns>
        /// <param name="address">
        /// A <see cref="System.Net.IPAddress"/> to test.
        /// </param>
        /// <param name="adapter">adapter number to test against</param>
        public static bool IsLocal(this IPAddress address, short adapter)
#endif
        {
            if (address == null)
            {
                return(false);
            }

            if (address.Equals(IPAddress.Any))
            {
                return(true);
            }

            if (address.Equals(IPAddress.Loopback))
            {
                return(true);
            }

#if SSHARP
#else
            if (Socket.OSSupportsIPv6)
#endif
            {
                if (address.Equals(IPAddress.IPv6Any))
                {
                    return(true);
                }

                if (address.Equals(IPAddress.IPv6Loopback))
                {
                    return(true);
                }
            }

#if SSHARP
            if (adapter == -1)
            {
                var numAdapters = InitialParametersClass.NumberOfEthernetInterfaces;
                for (short ix = 0; ix < numAdapters; ++ix)
                {
                    var addr   = CrestronEthernetHelper.GetEthernetParameter(CrestronEthernetHelper.ETHERNET_PARAMETER_TO_GET.GET_CURRENT_IP_ADDRESS, ix);
                    var ipAddr = IPAddress.Parse(addr);
                    if (address.Equals(ipAddr))
                    {
                        return(true);
                    }
                }
            }
            else
            {
                var addr   = CrestronEthernetHelper.GetEthernetParameter(CrestronEthernetHelper.ETHERNET_PARAMETER_TO_GET.GET_CURRENT_IP_ADDRESS, adapter);
                var ipAddr = IPAddress.Parse(addr);
                if (address.Equals(ipAddr))
                {
                    return(true);
                }
            }
#else
            var host  = Dns.GetHostName();
            var addrs = Dns.GetHostAddresses(host);
            foreach (var addr in addrs)
            {
                if (address.Equals(addr))
                {
                    return(true);
                }
            }
#endif

            return(false);
        }
예제 #29
0
            public EthernetStatusFeedbacks(short adapterIndex)
            {
                Debug.Console(2, "Ethernet Information for interface {0}", adapterIndex);
                Debug.Console(2, "Adapter Index: {1} Hostname: {0}", CrestronEthernetHelper.GetEthernetParameter(
                                  CrestronEthernetHelper.ETHERNET_PARAMETER_TO_GET.GET_HOSTNAME, adapterIndex), adapterIndex);
                Debug.Console(2, "Adapter Index: {1} Current IP Address: {0}", CrestronEthernetHelper.GetEthernetParameter(
                                  CrestronEthernetHelper.ETHERNET_PARAMETER_TO_GET.GET_CURRENT_IP_ADDRESS, adapterIndex), adapterIndex);
                Debug.Console(2, "Adapter Index: {1} Current Subnet Mask: {0}", CrestronEthernetHelper.GetEthernetParameter(
                                  CrestronEthernetHelper.ETHERNET_PARAMETER_TO_GET.GET_CURRENT_IP_MASK, adapterIndex), adapterIndex);
                Debug.Console(2, "Adapter Index: {1} Current Router: {0}", CrestronEthernetHelper.GetEthernetParameter(
                                  CrestronEthernetHelper.ETHERNET_PARAMETER_TO_GET.GET_CURRENT_ROUTER, adapterIndex), adapterIndex);
                Debug.Console(2, "Adapter Index: {1} Static IP Address: {0}", CrestronEthernetHelper.GetEthernetParameter(
                                  CrestronEthernetHelper.ETHERNET_PARAMETER_TO_GET.GET_STATIC_IPADDRESS, adapterIndex), adapterIndex);
                Debug.Console(2, "Adapter Index: {1} Static Subnet Mask: {0}", CrestronEthernetHelper.GetEthernetParameter(
                                  CrestronEthernetHelper.ETHERNET_PARAMETER_TO_GET.GET_STATIC_IPMASK, adapterIndex), adapterIndex);
                Debug.Console(2, "Adapter Index: {1} Static Router: {0}", CrestronEthernetHelper.GetEthernetParameter(
                                  CrestronEthernetHelper.ETHERNET_PARAMETER_TO_GET.GET_STATIC_ROUTER, adapterIndex), adapterIndex);
                Debug.Console(2, "Adapter Index: {1} DNS Servers: {0}", CrestronEthernetHelper.GetEthernetParameter(
                                  CrestronEthernetHelper.ETHERNET_PARAMETER_TO_GET.GET_DNS_SERVER, adapterIndex), adapterIndex);
                Debug.Console(2, "Adapter Index: {1} DHCP State: {0}", CrestronEthernetHelper.GetEthernetParameter(
                                  CrestronEthernetHelper.ETHERNET_PARAMETER_TO_GET.GET_CURRENT_DHCP_STATE, adapterIndex), adapterIndex);
                Debug.Console(2, "Adapter Index: {1} Domain Name: {0}", CrestronEthernetHelper.GetEthernetParameter(
                                  CrestronEthernetHelper.ETHERNET_PARAMETER_TO_GET.GET_DOMAIN_NAME, adapterIndex), adapterIndex);
                Debug.Console(2, "Adapter Index: {1} MAC Address: {0}", CrestronEthernetHelper.GetEthernetParameter(
                                  CrestronEthernetHelper.ETHERNET_PARAMETER_TO_GET.GET_MAC_ADDRESS, adapterIndex), adapterIndex);
                HostNameFeedback =
                    new StringFeedback(
                        () =>
                        CrestronEthernetHelper.GetEthernetParameter(
                            CrestronEthernetHelper.ETHERNET_PARAMETER_TO_GET.GET_HOSTNAME, adapterIndex));

                CurrentIpAddressFeedback =
                    new StringFeedback(
                        () =>
                        CrestronEthernetHelper.GetEthernetParameter(
                            CrestronEthernetHelper.ETHERNET_PARAMETER_TO_GET.GET_CURRENT_IP_ADDRESS, adapterIndex));
                CurrentDefaultGatewayFeedback =
                    new StringFeedback(
                        () =>
                        CrestronEthernetHelper.GetEthernetParameter(
                            CrestronEthernetHelper.ETHERNET_PARAMETER_TO_GET.GET_CURRENT_ROUTER, adapterIndex));
                CurrentSubnetMaskFeedback =
                    new StringFeedback(
                        () =>
                        CrestronEthernetHelper.GetEthernetParameter(
                            CrestronEthernetHelper.ETHERNET_PARAMETER_TO_GET.GET_CURRENT_IP_MASK, adapterIndex));
                StaticIpAddressFeedback =
                    new StringFeedback(
                        () =>
                        CrestronEthernetHelper.GetEthernetParameter(
                            CrestronEthernetHelper.ETHERNET_PARAMETER_TO_GET.GET_CURRENT_IP_ADDRESS, adapterIndex));
                StaticDefaultGatewayFeedback =
                    new StringFeedback(
                        () =>
                        CrestronEthernetHelper.GetEthernetParameter(
                            CrestronEthernetHelper.ETHERNET_PARAMETER_TO_GET.GET_CURRENT_ROUTER, adapterIndex));
                StaticSubnetMaskFeedback =
                    new StringFeedback(
                        () =>
                        CrestronEthernetHelper.GetEthernetParameter(
                            CrestronEthernetHelper.ETHERNET_PARAMETER_TO_GET.GET_CURRENT_IP_MASK, adapterIndex));
                DomainFeedback =
                    new StringFeedback(
                        () =>
                        CrestronEthernetHelper.GetEthernetParameter(
                            CrestronEthernetHelper.ETHERNET_PARAMETER_TO_GET.GET_DOMAIN_NAME, adapterIndex));
                DnsServerFeedback =
                    new StringFeedback(
                        () =>
                        CrestronEthernetHelper.GetEthernetParameter(
                            CrestronEthernetHelper.ETHERNET_PARAMETER_TO_GET.GET_DNS_SERVER, adapterIndex));
                MacAddressFeedback =
                    new StringFeedback(
                        () =>
                        CrestronEthernetHelper.GetEthernetParameter(
                            CrestronEthernetHelper.ETHERNET_PARAMETER_TO_GET.GET_MAC_ADDRESS, adapterIndex));

                DhcpStatusFeedback = new StringFeedback(
                    () =>
                    CrestronEthernetHelper.GetEthernetParameter(
                        CrestronEthernetHelper.ETHERNET_PARAMETER_TO_GET.GET_CURRENT_DHCP_STATE, adapterIndex));
            }
예제 #30
0
        public void Get()
        {
            if (RequireLogin(true))
            {
                return;
            }

            try
            {
                var ms        = new MemoryStream();
                var appNumber = InitialParametersClass.ApplicationNumber;
                var commands  = new[]
                {
                    "hostname",
                    "mycrestron",
                    "showlicense",
                    "osd",
                    "uptime",
                    "ver -v",
                    "ver all",
                    "uptime",
                    "time",
                    "timezone",
                    "sntp",
                    "showhw",
                    "ipconfig /all",
                    "progregister",
                    "progcomments:1",
                    "progcomments:2",
                    "progcomments:3",
                    "progcomments:4",
                    "progcomments:5",
                    "progcomments:6",
                    "progcomments:7",
                    "progcomments:8",
                    "progcomments:9",
                    "progcomments:10",
                    "proguptime:1",
                    "proguptime:2",
                    "proguptime:3",
                    "proguptime:4",
                    "proguptime:5",
                    "proguptime:6",
                    "proguptime:7",
                    "proguptime:8",
                    "proguptime:9",
                    "proguptime:10",
                    "ssptasks:1",
                    "ssptasks:2",
                    "ssptasks:3",
                    "ssptasks:4",
                    "ssptasks:5",
                    "ssptasks:6",
                    "ssptasks:7",
                    "ssptasks:8",
                    "ssptasks:9",
                    "ssptasks:10",
                    "appstat -p:" + appNumber,
                    "taskstat",
                    "ramfree",
                    "cpuload",
                    "cpuload",
                    "cpuload",
                    "showportmap -all",
                    "ramfree",
                    "showdiskinfo",
                    "ethwdog",
                    "iptable -p:all -t",
                    "who",
                    "netstat",
                    "threadpoolinfo",
                    "autodiscover query tableformat",
                    "reportcresnet",
                };
                using (var zip = new ZipFile())
                {
                    var directory = new DirectoryInfo(@"\NVRAM");
                    foreach (var file in directory.GetFiles())
                    {
                        zip.AddFile(file.FullName, @"\NVRAM Root");
                    }

                    directory = new DirectoryInfo(SystemBase.AppStoragePath);
                    foreach (var file in directory.GetFiles())
                    {
                        zip.AddFile(file.FullName,
                                    string.Format("\\NVRAM for App {0}", InitialParametersClass.ApplicationNumber.ToString("D2")));
                    }

                    var diagnosticsData = new StringWriter();
                    foreach (var message in System.StatusMessages)
                    {
                        diagnosticsData.WriteLine("{0}: {2} {1}", message.MessageLevel, message.MessageString,
                                                  message.SourceDeviceName);
                    }
                    zip.AddEntry("diagnostics.txt", diagnosticsData.ToString());

                    directory = new DirectoryInfo(@"/Sys/PLog/CurrentBoot");
                    foreach (var file in directory.GetFiles())
                    {
                        zip.AddFile(file.FullName, @"\CurrentBootLogs");
                    }

                    directory = new DirectoryInfo(@"/Sys/PLog/PreviousBoot");
                    foreach (var file in directory.GetFiles())
                    {
                        zip.AddFile(file.FullName, @"\PreviousBootLogs");
                    }

                    var statusData = new MemoryStream();
                    var sw         = new StreamWriter(statusData);
                    foreach (var command in commands)
                    {
                        sw.WriteLine("Console Cmd: {0}", command);
                        var response = string.Empty;
                        CrestronConsole.SendControlSystemCommand(command, ref response);
                        sw.WriteLine(response);
                    }
                    statusData.Position = 0;
                    zip.AddEntry(@"processor_status.txt", statusData);

                    zip.Save(ms);
                }
                Request.Response.Header.ContentType = MimeMapping.GetMimeMapping(".zip");
                Request.Response.ContentSource      = ContentSource.ContentStream;
                var hostname =
                    CrestronEthernetHelper.GetEthernetParameter(
                        CrestronEthernetHelper.ETHERNET_PARAMETER_TO_GET.GET_HOSTNAME,
                        CrestronEthernetHelper.GetAdapterdIdForSpecifiedAdapterType(
                            EthernetAdapterType.EthernetLANAdapter));
                Request.Response.Header.AddHeader(new HttpHeader("content-disposition",
                                                                 string.Format("attachment; filename=processor_report_{0}_{1}.zip",
                                                                               hostname, DateTime.Now.ToString("yyyyMMddTHHmmss"))));
                ms.Position = 0;
                Request.Response.ContentStream = ms;
                Request.Response.CloseStream   = true;
            }
            catch (Exception e)
            {
                HandleError(e);
            }
        }