Пример #1
0
        public MainWindow()
        {
            InitializeComponent();
            DataContext = this;

            ApiConfiguration.Set(ApiConfiguration.Read());
        }
Пример #2
0
        public void init()
        {
            UpdateUserSettings();

            // Set Animation Framerate
            Timeline.DesiredFrameRateProperty.OverrideMetadata(typeof(Timeline), new FrameworkPropertyMetadata {
                DefaultValue = DEFAULT_ANIMATION_FRAMERATE
            });

            Splash_Initialize();

            Splash_UpdateStatus("...Initializing", 10);

            FileLocations.CreateAllDirectories();

            ApiConfiguration.Set(ApiConfiguration.Read());

            InitializeComponent();
            DataContext = this;

            Application.Current.MainWindow = this;

            DeviceManager_DeviceList_Initialize();

            // Read Users and Login
            Splash_UpdateStatus("...Logging in User", 40);
            Users_Initialize();

            Splash_UpdateStatus("...Loading Plugins", 60);
            LoadPlugins();
            Pages.DeviceManager.EditPage.GetPluginPageInfos();

            Splash_UpdateStatus("...Finishing Up", 100);

            AddWelcomeMessage();
            CheckVersion();

            Splash_Close();

            ServerMonitor_Initialize();
        }
Пример #3
0
        public ProcessingServer()
        {
            // Insure all standard TrakHound directories are created
            FileLocations.CreateAllDirectories();

            // Read the API Configuration file
            ApiConfiguration.Set(ApiConfiguration.Read());

            // Read Server Plugins
            LoadServerPlugins();

            // Start User login file monitor
            var loginMonitor = new ServerCredentials.Monitor();

            loginMonitor.UserChanged += LoginMonitor_UserChanged;

            // Start API Configuration file monitor
            var apiMonitor = new ApiConfiguration.Monitor();

            apiMonitor.ApiConfigurationChanged += ApiMonitor_ApiConfigurationChanged;
        }
Пример #4
0
        private string ProcessRequest(HttpListenerContext context)
        {
            string result = null;

            try
            {
                string path = context.Request.Url.AbsolutePath;
                if (!string.IsNullOrEmpty(path) && path.Length > 1)
                {
                    // Remove beginning forward slash
                    path = path.Substring(1);

                    path = path.Substring("api/".Length);

                    // Split path by forward slashes
                    var paths = path.Split('/');
                    if (paths.Length > 1 && paths[0] != "/" && !string.IsNullOrEmpty(paths[0]))
                    {
                        switch (paths[0].ToLower())
                        {
                        case "data":

                            // Remove 'data' from path
                            path = path.Substring(paths[0].Length);

                            // Remove first forward slash
                            path = path.TrimStart('/');

                            // Process the Data Request and return response
                            if (context.Request.HttpMethod == "GET")
                            {
                                paths = path.Split('/');
                                if (paths.Length > 0)
                                {
                                    switch (paths[0].ToLower())
                                    {
                                    case "get": result = Data.Get(context.Request.Url.ToString()); break;
                                    }
                                }
                            }
                            else if (context.Request.HttpMethod == "POST")
                            {
                                paths = path.Split('/');
                                if (paths.Length > 0)
                                {
                                    switch (paths[0].ToLower())
                                    {
                                    case "update": result = Data.Update(context); break;
                                    }
                                }
                            }
                            else
                            {
                                result = "Incorrect REQUEST METHOD";
                            }

                            break;

                        case "devices":

                            // Remove 'data' from path
                            path = path.Substring(paths[0].Length);

                            // Remove first forward slash
                            path = path.TrimStart('/');

                            if (context.Request.HttpMethod == "GET")
                            {
                                paths = path.Split('/');
                                if (paths.Length > 0)
                                {
                                    switch (paths[0].ToLower())
                                    {
                                    case "list": result = Data.List(context.Request.Url.ToString()); break;
                                    }
                                }
                            }

                            break;

                        case "config":

                            var apiConfig = ApiConfiguration.Read();
                            if (apiConfig != null)
                            {
                                string json = JSON.FromObject(apiConfig);
                                if (json != null)
                                {
                                    result = json;
                                }
                                else
                                {
                                    result = "Error Reading API Configuration";
                                }
                            }

                            break;
                        }
                    }
                }
            }
            catch (Exception ex) { logger.Error(ex); }

            return(result);
        }