TrakHound User Account information
Ejemplo n.º 1
0
        /// <summary>
        /// Check the status (Update Id) for a list of devices
        /// </summary>
        /// <param name="userConfig">UserConfiguration object for the current user</param>
        /// <returns></returns>
        public static List<CheckInfo> Check(UserConfiguration userConfig)
        {
            Uri apiHost = ApiConfiguration.AuthenticationApiHost;

            string url = new Uri(apiHost, "devices/check/index.php").ToString();

            string format = "{0}?token={1}&sender_id={2}";

            string token = userConfig.SessionToken;
            string senderId = UserManagement.SenderId.Get();

            url = string.Format(format, url, token, senderId);

            string response = HTTP.GET(url);
            if (response != null)
            {
                bool success = ApiError.ProcessResponse(response, "Check Devices");
                if (success)
                {
                    if (response == "No Devices Found") return null;
                    else return JSON.ToType<List<CheckInfo>>(response);
                }
            }

            return null;
        }
Ejemplo n.º 2
0
        public static bool Send(UserConfiguration userConfig, List<BugInfo> bugInfos)
        {
            string json = JSON.FromList<BugInfo>(bugInfos);
            if (!string.IsNullOrEmpty(json))
            {
                Uri apiHost = ApiConfiguration.AuthenticationApiHost;

                string url = new Uri(apiHost, "bugs/send/index.php").ToString();

                var postDatas = new NameValueCollection();
                if (userConfig != null)
                {
                    postDatas["token"] = userConfig.SessionToken;
                    postDatas["sender_id"] = UserManagement.SenderId.Get();
                }

                postDatas["bugs"] = json;

                string response = HTTP.POST(url, postDatas);
                if (response != null)
                {
                    return ApiError.ProcessResponse(response, "Send Bug Report");
                }
            }

            return false;
        }
Ejemplo n.º 3
0
        public static UploadFileInfo[] Upload(UserConfiguration userConfig, HTTP.FileContentData[] fileContentDatas)
        {
            if (userConfig != null)
            {
                Uri apiHost = ApiConfiguration.AuthenticationApiHost;

                string url = new Uri(apiHost, "files/upload/index.php").ToString();

                var postDatas = new NameValueCollection();
                postDatas["token"] = userConfig.SessionToken;
                postDatas["sender_id"] = UserManagement.SenderId.Get();

                var httpInfo = new HTTP.HTTPInfo();
                httpInfo.Url = url;
                httpInfo.ContentData = HTTP.PostContentData.FromNamedValueCollection(postDatas);
                httpInfo.FileData = fileContentDatas;

                string response = HTTP.POST(httpInfo);
                if (response != null)
                {
                    bool success = ApiError.ProcessResponse(response, "Upload File");
                    if (success)
                    {
                        var uploadFileInfos = JSON.ToType<List<UploadFileInfo>>(response);
                        if (uploadFileInfos != null)
                        {
                            return uploadFileInfos.ToArray();
                        }
                    }
                }
            }

            return null;
        }
Ejemplo n.º 4
0
        // Example POST Data
        // -----------------------------------------------------
        // name = 'token'
        // value = Session Token
        // name = 'sender_id'
        // value = Sender ID
        // name = 'devices'
        // value =  [{
        //    
        //     "unique_id": "987654321",
        //     "data": [
        //        { "address": "/ClientEnabled", "value": "true", "" },
        //        { "address": "/ServerEnabled", "value": "true", "" },
        //        { "address": "/UniqueId", "value": "987654321", "" }
        //        ]
        //    },
        //    {
        //     "unique_id": "123456789",
        //     "data": [
        //        { "address": "/ClientEnabled", "value": "true", "" },
        //        { "address": "/ServerEnabled", "value": "true", "" },
        //        { "address": "/UniqueId", "value": "123456789", "" }
        //        ]
        // }]
        // -----------------------------------------------------
        public static bool Update(UserConfiguration userConfig, DeviceConfiguration deviceConfig)
        {
            bool result = false;

            if (userConfig != null)
            {
                var table = deviceConfig.ToTable();
                if (table != null)
                {
                    var infos = new List<DeviceInfo>();
                    infos.Add(new DeviceInfo(deviceConfig.UniqueId, table));

                    string json = JSON.FromObject(infos);
                    if (json != null)
                    {
                        Uri apiHost = ApiConfiguration.AuthenticationApiHost;

                        string url = new Uri(apiHost, "devices/update/index.php").ToString();

                        var postDatas = new NameValueCollection();
                        postDatas["token"] = userConfig.SessionToken;
                        postDatas["sender_id"] = UserManagement.SenderId.Get();
                        postDatas["devices"] = json;

                        string response = HTTP.POST(url, postDatas);
                        if (response != null)
                        {
                            result = ApiError.ProcessResponse(response, "Update Devices");
                        }
                    }
                }
            }

            return result;
        }
Ejemplo n.º 5
0
        public static bool Update(UserConfiguration userConfig, DeviceInfo deviceInfo)
        {
            var deviceInfos = new List<DeviceInfo>();
            deviceInfos.Add(deviceInfo);

            return Update(userConfig, deviceInfos);
        }
Ejemplo n.º 6
0
        // Example URL (GET)
        // -----------------------------------------------------
        // ../api/devices/list?token=01234&sender_id=56789   				  (List all devices for the user)
        // OR
        // ../api/devices/list?token=01234&sender_id=56789&unique_id=ABCDEFG   (List only the device with the specified 'unique_id')
        // -----------------------------------------------------
        // Example Post Data
        // -----------------------------------------------------
        // name = 'token'
        // value = 01234 (Session Token)
        // name = 'sender_id'
        // value = 56789 (Sender ID)
        // (Optional)
        // name = 'devices'
        // value =  [
        //    { "unique_id": "ABCDEFG" },
        //  { "unique_id": "HIJKLMN" }
        //    ]
        // -----------------------------------------------------
        /// <summary>
        /// List a single DeviceDescription
        /// </summary>
        /// <param name="userConfig">UserConfiguration object for the current user</param>
        /// <param name="deviceUniqueId">The Unique ID of the device to return</param>
        /// <returns></returns>
        public static DeviceDescription List(UserConfiguration userConfig, string deviceUniqueId, Uri apiHost)
        {
            if (!string.IsNullOrEmpty(deviceUniqueId))
            {
                string url = new Uri(apiHost, "devices/list/index.php").ToString();

                if (userConfig != null)
                {
                    string format = "{0}?token={1}&sender_id={2}&unique_id={3}";

                    string token = userConfig.SessionToken;
                    string senderId = UserManagement.SenderId.Get();

                    url = string.Format(format, url, token, senderId, deviceUniqueId);
                }

                string response = HTTP.GET(url);
                if (response != null)
                {
                    bool success = ApiError.ProcessResponse(response, "List Devices");
                    if (success)
                    {
                        var deviceInfos = JSON.ToType<List<Data.DeviceInfo>>(response);
                        if (deviceInfos != null && deviceInfos.Count > 0)
                        {
                            return new DeviceDescription(deviceInfos[0]);
                        }
                    }
                }
            }

            return null;
        }
Ejemplo n.º 7
0
        public static bool Remove(UserConfiguration userConfig, List<MessageInfo> messageInfos)
        {
            Uri apiHost = ApiConfiguration.AuthenticationApiHost;

            string url = new Uri(apiHost, "messages/remove/index.php").ToString();

            var postDatas = new NameValueCollection();
            postDatas["token"] = userConfig.SessionToken;
            postDatas["sender_id"] = UserManagement.SenderId.Get();

            if (messageInfos != null)
            {
                string json = JSON.FromList<MessageInfo>(messageInfos);
                if (!string.IsNullOrEmpty(json))
                {
                    postDatas["messages"] = json;
                }
            }

            string response = HTTP.POST(url, postDatas);
            if (response != null)
            {
                return ApiError.ProcessResponse(response, "Remove Messages");
            }

            return false;
        }
Ejemplo n.º 8
0
        // Example URL (GET)
        // -----------------------------------------------------
        // ../api/devices/check?token=01234&sender_id=56789   				  (Check all devices for the user)
        // OR
        // ../api/devices/check?token=01234&sender_id=56789&unique_id=ABCDEFG   (Check only the device with the specified 'unique_id')
        // -----------------------------------------------------
        // Example Post Data
        // -----------------------------------------------------
        // name = 'token'
        // value = 01234 (Session Token)
        // name = 'sender_id'
        // value = 56789 (Sender ID)
        // (Optional)
        // name = 'devices'
        // value =  [
        //    { "unique_id": "ABCDEFG" },
        //  { "unique_id": "HIJKLMN" }
        //    ]
        // -----------------------------------------------------
        /// <summary>
        /// Check the status (Update Id) of a single Device
        /// </summary>
        /// <param name="userConfig">UserConfiguration object for the current user</param>
        /// <param name="deviceUniqueId">The Unique ID of the device to return</param>
        /// <returns></returns>
        public static CheckInfo Check(UserConfiguration userConfig, string deviceUniqueId)
        {
            if (!string.IsNullOrEmpty(deviceUniqueId))
            {
                Uri apiHost = ApiConfiguration.AuthenticationApiHost;

                string url = new Uri(apiHost, "devices/check/index.php").ToString();

                string format = "{0}?token={1}&sender_id={2}{3}";

                string token = userConfig.SessionToken;
                string senderId = UserManagement.SenderId.Get();
                string uniqueId = "unique_id=" + deviceUniqueId;

                url = string.Format(format, url, token, senderId, uniqueId);

                string response = HTTP.GET(url);
                if (response != null)
                {
                    bool success = ApiError.ProcessResponse(response, "Check Device");
                }
            }

            return null;
        }
Ejemplo n.º 9
0
        public static UploadFileInfo[] Upload(UserConfiguration userConfig, HTTP.FileContentData fileContentData)
        {
            var fileContentDatas = new HTTP.FileContentData[1];
            fileContentDatas[0] = fileContentData;

            return Upload(userConfig, fileContentDatas);
        }
Ejemplo n.º 10
0
        public EditPage(UserConfiguration _userConfig, string _uniqueId)
        {
            InitializeComponent();
            DataContext = this;

            userConfig = _userConfig;
            uniqueId = _uniqueId;

            LoadDevice();

            LoadPages();
        }
Ejemplo n.º 11
0
        public static bool Update(UserConfiguration userConfig, DataTable table)
        {
            string uniqueId = DataTable_Functions.GetTableValue(table, "address", "/UniqueId", "value");
            if (!string.IsNullOrEmpty(uniqueId))
            {
                var deviceInfo = new DeviceInfo(uniqueId, table);

                return Update(userConfig, deviceInfo);
            }

            return false;
        }
Ejemplo n.º 12
0
 // Set Login File UserConfiguration
 private void Login(UserConfiguration userConfig)
 {
     if (userConfig != null)
     {
         var userInfo = ServerCredentials.Read();
         if (userInfo != null)
         {
             if (userInfo.Username != userConfig.Username || userInfo.Token != userConfig.Token)
             {
                 ServerCredentials.Create(userConfig);
             }
         }
         else ServerCredentials.Create(userConfig);
     }
     else ServerCredentials.Remove();
 }
Ejemplo n.º 13
0
            public static UserConfiguration Set(string token, string path)
            {
                UserConfiguration result = null;

                if (!string.IsNullOrEmpty(token))
                {
                    string url      = "https://www.feenux.com/trakhound/api/profile_image/set/index.php";
                    string senderId = SenderId.Get();

                    var postDatas = new NameValueCollection();
                    postDatas["token"]     = token;
                    postDatas["sender_id"] = SenderId.Get();
                }

                return(result);
            }
        public static bool Create(UserConfiguration userConfig)
        {
            bool result = false;

            string path = Path.Combine(FileLocations.TrakHound, SERVER_CREDENTIALS_FILENAME);

            Remove(path);

            if (userConfig != null)
            {
                var xml = CreateDocument(userConfig);
                WriteDocument(xml, path);
            }

            return(result);
        }
        public static bool Create(UserConfiguration userConfig)
        {
            bool result = false;

            string path = Path.Combine(FileLocations.TrakHound, SERVER_CREDENTIALS_FILENAME);

            Remove(path);

            if (userConfig != null)
            {
                var xml = CreateDocument(userConfig);
                WriteDocument(xml, path);
            }

            return result;
        }
Ejemplo n.º 16
0
        public static List<DeviceDescription> List(UserConfiguration userConfig, string[] deviceUniqueIds, Uri apiHost)
        {
            if (deviceUniqueIds != null && deviceUniqueIds.Length > 0)
            {
                string url = new Uri(apiHost, "devices/list/index.php").ToString();

                var getDeviceInfos = new List<GetDeviceInfo>();
                foreach (var deviceUniqueId in deviceUniqueIds) getDeviceInfos.Add(new GetDeviceInfo(deviceUniqueId));

                string json = JSON.FromObject(getDeviceInfos);
                if (json != null)
                {
                    var postDatas = new NameValueCollection();

                    if (userConfig != null)
                    {
                        postDatas["token"] = userConfig.SessionToken;
                        postDatas["sender_id"] = UserManagement.SenderId.Get();
                    }

                    postDatas["devices"] = json;

                    string response = HTTP.POST(url, postDatas);
                    if (response != null)
                    {
                        bool success = ApiError.ProcessResponse(response, "List Devices");
                        if (success)
                        {
                            var deviceInfos = JSON.ToType<List<Data.DeviceInfo>>(response);
                            if (deviceInfos != null)
                            {
                                var devices = new List<DeviceDescription>();

                                foreach (var deviceInfo in deviceInfos)
                                {
                                    devices.Add(new DeviceDescription(deviceInfo));
                                }

                                return devices;
                            }
                        }
                    }
                }
            }

            return null;
        }
Ejemplo n.º 17
0
        public static void Update(UserConfiguration userConfig, List<Data.DeviceInfo> deviceInfos)
        {
            if (ApiConfiguration.DataApiHost.ToString() != ApiConfiguration.LOCAL_API_HOST) // Remote
            {
                var json = Data.DeviceInfo.ListToJson(deviceInfos);
                if (json != null)
                {
                    var values = new NameValueCollection();
                    if (userConfig != null) values["token"] = userConfig.SessionToken;
                    values["sender_id"] = UserManagement.SenderId.Get();
                    values["devices"] = json;

                    string url = new Uri(ApiConfiguration.DataApiHost, "data/update/index.php").ToString();

                    var info = new SendDataInfo(url, values);
                    ThreadPool.QueueUserWorkItem(new WaitCallback(SendData), info);
                }
            }
            else // Local
            {
                var json = Data.DeviceInfo.ListToJson(deviceInfos);
                if (json != null)
                {
                    var values = new NameValueCollection();
                    values["devices"] = json;

                    string url = new Uri(ApiConfiguration.DataApiHost, "data/update/index.php").ToString();

                    // Send to local server
                    var info = new SendDataInfo(url, values);
                    ThreadPool.QueueUserWorkItem(new WaitCallback(SendData), info);

                    if (userConfig != null)
                    {
                        values["token"] = userConfig.SessionToken;
                        values["sender_id"] = UserManagement.SenderId.Get();

                        // Send to TrakHound Cloud (for Mobile App)
                        var cloudUri = new Uri(ApiConfiguration.CLOUD_API_HOST);
                        url = new Uri(cloudUri, "data/update/index.php").ToString();

                        var cloudInfo = new SendDataInfo(url, values);
                        ThreadPool.QueueUserWorkItem(new WaitCallback(SendData), cloudInfo);
                    }
                }
            }
        }
Ejemplo n.º 18
0
        private static bool NotEqualTo(UserConfiguration c1, UserConfiguration c2)
        {
            if (!object.ReferenceEquals(c1, null) && object.ReferenceEquals(c2, null))
            {
                return(true);
            }
            if (object.ReferenceEquals(c1, null) && !object.ReferenceEquals(c2, null))
            {
                return(true);
            }
            if (object.ReferenceEquals(c1, null) && object.ReferenceEquals(c2, null))
            {
                return(false);
            }

            return(c1.Username != c2.Username || c1.SessionToken != c2.SessionToken);
        }
Ejemplo n.º 19
0
        // Example URL (GET)
        // -----------------------------------------------------
        // ../api/devices/get?token=01234&sender_id=56789   				  (Get all devices for the user)
        // OR
        // ../api/devices/get?token=01234&sender_id=56789&unique_id=ABCDEFG   (Get only the device with the specified 'unique_id')
        // -----------------------------------------------------
        // Example Post Data
        // -----------------------------------------------------
        // name = 'token'
        // value = 01234 (Session Token)
        // name = 'sender_id'
        // value = 56789 (Sender ID)
        // (Optional)
        // name = 'devices'
        // value =  [
        //    { "unique_id": "ABCDEFG" },
        //  { "unique_id": "HIJKLMN" }
        //    ]
        // -----------------------------------------------------
        /// <summary>
        /// Get a single DeviceConfiguration
        /// </summary>
        /// <param name="userConfig">UserConfiguration object for the current user</param>
        /// <param name="deviceUniqueId">The Unique ID of the device to return</param>
        /// <returns></returns>
        public static DeviceConfiguration Get(UserConfiguration userConfig, string deviceUniqueId)
        {
            if (!string.IsNullOrEmpty(deviceUniqueId))
            {
                Uri apiHost = ApiConfiguration.AuthenticationApiHost;

                string url = new Uri(apiHost, "devices/get/index.php").ToString();

                string format = "{0}?token={1}&sender_id={2}&unique_id={3}";

                string token = userConfig.SessionToken;
                string senderId = UserManagement.SenderId.Get();

                url = string.Format(format, url, token, senderId, deviceUniqueId);

                string response = HTTP.GET(url);
                if (response != null)
                {
                    bool success = ApiError.ProcessResponse(response, "Get Devices");
                    if (success)
                    {
                        var deviceInfos = JSON.ToType<List<DeviceInfo>>(response);
                        if (deviceInfos != null && deviceInfos.Count > 0)
                        {
                            var deviceInfo = deviceInfos[0];

                            var table = deviceInfo.ToTable();
                            if (table != null)
                            {
                                var xml = DeviceConfiguration.TableToXml(table);
                                if (xml != null)
                                {
                                    var deviceConfig = DeviceConfiguration.Read(xml);
                                    if (deviceConfig != null && !string.IsNullOrEmpty(deviceConfig.UniqueId))
                                    {
                                        return deviceConfig;
                                    }
                                }
                            }
                        }
                    }
                }
            }

            return null;
        }
Ejemplo n.º 20
0
        public static List<MessageInfo> Get(UserConfiguration userConfig, List<string> messageIds)
        {
            Uri apiHost = ApiConfiguration.AuthenticationApiHost;

            string url = new Uri(apiHost, "messages/get/index.php").ToString();

            string format = "{0}?token={1}&sender_id={2}{3}";

            string token = userConfig.SessionToken;
            string senderId = UserManagement.SenderId.Get();
            string devices = "";

            // List Message IDs to Get
            // If no Messages are listed then ALL Messages are retrieved
            if (messageIds != null)
            {
                string json = JSON.FromList<string>(messageIds);
                if (!string.IsNullOrEmpty(json))
                {
                    devices = "messages=" + json;
                }
            }

            url = string.Format(format, url, token, senderId, devices);

            var httpInfo = new HTTP.HTTPInfo();
            httpInfo.Url = url;
            httpInfo.MaxAttempts = 1;

            string response = HTTP.GET(httpInfo);
            if (response != null)
            {
                bool success = ApiError.ProcessResponse(response, "Get Messages");
                if (success)
                {
                    var messageInfos = JSON.ToType<List<MessageInfo>>(response);
                    if (messageInfos != null)
                    {
                        return messageInfos;
                    }
                }
            }

            return null;
        }
Ejemplo n.º 21
0
        /// <summary>
        /// Remove all of the user's devices
        /// </summary>
        /// <param name="userConfig">UserConfiguration object for the current user</param>
        /// <returns></returns>
        public static bool Remove(UserConfiguration userConfig)
        {
            if (userConfig != null)
            {
                Uri apiHost = ApiConfiguration.AuthenticationApiHost;

                string url = new Uri(apiHost, "devices/remove/index.php").ToString();

                var postDatas = new NameValueCollection();
                postDatas["token"] = userConfig.SessionToken;
                postDatas["sender_id"] = UserManagement.SenderId.Get();

                string response = HTTP.POST(url, postDatas);
                if (response != null)
                {
                    return ApiError.ProcessResponse(response, "Remove Devices");
                }
            }

            return false;
        }
        private static XmlDocument CreateDocument(UserConfiguration userConfig)
        {
            var result = new XmlDocument();

            XmlNode docNode = result.CreateXmlDeclaration("1.0", "UTF-8", null);
            result.AppendChild(docNode);

            XmlNode root = result.CreateElement("ServerCredentials");
            result.AppendChild(root);

            // Username
            XmlNode username = result.CreateElement("Username");
            username.InnerText = userConfig.Username;
            root.AppendChild(username);

            // Token
            XmlNode token = result.CreateElement("Token");
            token.InnerText = userConfig.Token;
            root.AppendChild(token);

            return result;
        }
Ejemplo n.º 23
0
        /// <summary>
        /// User Login using Remember Token
        /// </summary>
        public static UserConfiguration TokenLogin(string token, string note = "")
        {
            UserConfiguration result = null;

            if (token != null && token.Length > 0)
            {
                string senderId = SenderId.Get();

                string url = new Uri(ApiConfiguration.AuthenticationApiHost, "users/login/?token=" + token + "&sender_id=" + senderId + "&note=" + note).ToString();

                string response = HTTP.GET(url);
                if (response != null)
                {
                    var success = ApiError.ProcessResponse(response, "User Token Login");
                    if (success)
                    {
                        result = UserConfiguration.Get(response);
                    }
                }
            }

            return(result);
        }
Ejemplo n.º 24
0
        public static bool Update(UserConfiguration userConfig, List<DeviceInfo> deviceInfos)
        {
            var json = Data.DeviceInfo.ListToJson(deviceInfos);
            if (!string.IsNullOrEmpty(json))
            {
                Uri apiHost = ApiConfiguration.DataApiHost;

                string url = new Uri(apiHost, "data/update/index.php").ToString();

                var postDatas = new NameValueCollection();
                postDatas["token"] = userConfig.SessionToken;
                postDatas["sender_id"] = UserManagement.SenderId.Get();
                postDatas["devices"] = json;

                string response = HTTP.POST(url, postDatas);
                if (response != null)
                {
                    return ApiError.ProcessResponse(response, "Update Device Data");
                }
            }

            return false;
        }
Ejemplo n.º 25
0
        // Update GUI after login using separate thread
        void Login_Finished(UserConfiguration userConfig)
        {
            if (first && userConfig == null) UpdateUser(null);
            CurrentUser = userConfig;

            UserLoadingText = null;
            UserLoading = false;

            LoginPassword = null;

            if (userConfig != null)
            {
                LoginUsername = null;
                UserLoginError = false;
            }
            else
            {
                UserLoginError = true;
                IsPasswordFocused = true;
            }

            first = false;
        }
Ejemplo n.º 26
0
        public void Login(ServerCredentials.LoginData loginData)
        {
            UserConfiguration userConfig = null;

            if (loginData != null )
            {
                while (loginData != null && userConfig == null)
                {
                    userConfig = UserManagement.TokenLogin(loginData.Token);
                    if (userConfig == null)
                    {
                        Logger.Log(String_Functions.UppercaseFirst(loginData.Username) + " Failed to Login... Retrying in 5 seconds");

                        Thread.Sleep(5000);

                        loginData = ServerCredentials.Read();
                    }
                }

                if (userConfig != null) Logger.Log(String_Functions.UppercaseFirst(userConfig.Username) + " Logged in Successfully");
            }

            CurrentUser = userConfig;
        }
Ejemplo n.º 27
0
        public Page(DeviceDescription device, Data.DeviceInfo deviceInfo, UserConfiguration userConfig)
        {
            InitializeComponent();
            root.DataContext = this;

            UserConfiguration = userConfig;

            Device = device;

            // Active Hour Segments
            ActiveHourDatas = new List<HourData>();
            for (var x = 0; x < 24; x++) ActiveHourDatas.Add(new HourData(x, x + 1));

            // Idle Hour Segments
            IdleHourDatas = new List<HourData>();
            for (var x = 0; x < 24; x++) IdleHourDatas.Add(new HourData(x, x + 1));

            // Alert Hour Segments
            AlertHourDatas = new List<HourData>();
            for (var x = 0; x < 24; x++) AlertHourDatas.Add(new HourData(x, x + 1));

            // Oee Hour Segments
            OeeHourDatas = new List<HourData>();
            for (var x = 0; x < 24; x++) OeeHourDatas.Add(new HourData(x, x + 1));

            // Availability Hour Segments
            AvailabilityHourDatas = new List<HourData>();
            for (var x = 0; x < 24; x++) AvailabilityHourDatas.Add(new HourData(x, x + 1));

            // Performance Hour Segments
            PerformanceHourDatas = new List<HourData>();
            for (var x = 0; x < 24; x++) PerformanceHourDatas.Add(new HourData(x, x + 1));

            // Quality Hour Segments
            QualityHourDatas = new List<HourData>();
            for (var x = 0; x < 24; x++) QualityHourDatas.Add(new HourData(x, x + 1));

            // Parts Count Hour Segments
            PartCountHourDatas = new List<HourData>();
            for (var x = 0; x < 24; x++) PartCountHourDatas.Add(new HourData(x, x + 1));

            // Initialize Device Status Pie Chart
            DeviceStatusPieChartData.Clear();
            DeviceStatusPieChartData.Add(new PieChartData("Active"));
            DeviceStatusPieChartData.Add(new PieChartData("Idle"));
            DeviceStatusPieChartData.Add(new PieChartData("Alert"));

            if (deviceInfo != null)
            {
                UpdateDeviceInfo(deviceInfo.Status);
                UpdateDeviceInfo(deviceInfo.Controller);
                UpdateDeviceInfo(deviceInfo.Oee);
                UpdateDeviceInfo(deviceInfo.Timers);
                UpdateDeviceInfo(deviceInfo.Hours);
            }

            Loading = false;
        }
Ejemplo n.º 28
0
 void accountpage_UserChanged(UserConfiguration userConfig)
 {
     CurrentUser = userConfig;
 }
Ejemplo n.º 29
0
 void SendCurrentUserChanged(UserConfiguration userConfig)
 {
     CurrentUserChanged?.Invoke(userConfig);
 }
Ejemplo n.º 30
0
 public void Logout()
 {
     Stop();
     CurrentUser = null;
 }
Ejemplo n.º 31
0
        public void Login(UserConfiguration userConfig)
        {
            CurrentUser = userConfig;

            if (userConfig != null) Logger.Log(String_Functions.UppercaseFirst(userConfig.Username) + " Logged in Successfully");
        }
Ejemplo n.º 32
0
        public void GetSentData(EventData data)
        {
            if (data != null && data.Id == "USER_LOGIN")
            {
                if (data.Data01.GetType() == typeof(UserConfiguration))
                {
                    _userConfiguration = (UserConfiguration)data.Data01;
                }
            }

            if (data != null && data.Id == "USER_LOGOUT")
            {
                _userConfiguration = null;
            }

            if (data != null && data.Id == "STATUS_STATUS" && data.Data02 != null && data.Data02.GetType() == typeof(Data.StatusInfo))
            {
                Dispatcher.BeginInvoke(new Action(() =>
                {
                    string uniqueId = data.Data01.ToString();
                    if (Device != null && Device.UniqueId == uniqueId)
                    {
                        var info = (Data.StatusInfo)data.Data02;

                        UpdateDeviceInfo(info);
                    }
                }), System.Windows.Threading.DispatcherPriority.Background, new object[] { });
            }

            if (data != null && data.Id == "STATUS_CONTROLLER" && data.Data02 != null && data.Data02.GetType() == typeof(Data.ControllerInfo))
            {
                Dispatcher.BeginInvoke(new Action(() =>
                {
                    string uniqueId = data.Data01.ToString();
                    if (Device != null && Device.UniqueId == uniqueId)
                    {
                        var info = (Data.ControllerInfo)data.Data02;

                        UpdateDeviceInfo(info);
                    }
                }), System.Windows.Threading.DispatcherPriority.Background, new object[] { });
            }

            if (data != null && data.Id == "STATUS_HOURS" && data.Data02 != null && data.Data02.GetType() == typeof(List<Data.HourInfo>))
            {
                Dispatcher.BeginInvoke(new Action(() =>
                {
                    string uniqueId = data.Data01.ToString();
                    if (Device != null && Device.UniqueId == uniqueId)
                    {
                        var info = (List<Data.HourInfo>)data.Data02;

                        UpdateDeviceInfo(info);
                    }
                }), System.Windows.Threading.DispatcherPriority.Background, new object[] { });
            }

            if (data != null && data.Id == "STATUS_TIMERS" && data.Data02 != null && data.Data02.GetType() == typeof(Data.TimersInfo))
            {
                Dispatcher.BeginInvoke(new Action(() =>
                {
                    string uniqueId = data.Data01.ToString();
                    if (Device != null && Device.UniqueId == uniqueId)
                    {
                        var info = (Data.TimersInfo)data.Data02;

                        UpdateDeviceInfo(info);
                    }
                }), System.Windows.Threading.DispatcherPriority.Background, new object[] { });
            }

            if (data != null && data.Id == "STATUS_OEE" && data.Data02 != null && data.Data02.GetType() == typeof(TrakHound.API.Data.OeeInfo))
            {
                Dispatcher.BeginInvoke(new Action(() =>
                {
                    string uniqueId = data.Data01.ToString();
                    if (Device != null && Device.UniqueId == uniqueId)
                    {
                        var info = (Data.OeeInfo)data.Data02;

                        UpdateDeviceInfo(info);
                    }
                }), System.Windows.Threading.DispatcherPriority.DataBind, new object[] { });
            }
        }
Ejemplo n.º 33
0
 void UpdateLoggedInChanged(EventData data)
 {
     if (data != null)
     {
         if (data.Id == "USER_LOGIN")
         {
             if (data.Data01 != null) currentUser = (UserConfiguration)data.Data01;
         }
         else if (data.Id == "USER_LOGOUT")
         {
             currentUser = null;
         }
     }
 }
        private static bool NotEqualTo(UserConfiguration c1, UserConfiguration c2)
        {
            if (!object.ReferenceEquals(c1, null) && object.ReferenceEquals(c2, null)) return true;
            if (object.ReferenceEquals(c1, null) && !object.ReferenceEquals(c2, null)) return true;
            if (object.ReferenceEquals(c1, null) && object.ReferenceEquals(c2, null)) return false;

            return c1.Username != c2.Username || c1.SessionToken != c2.SessionToken;
        }