/// <summary>
        /// Assigns the global variable/object 'DeviceOptions' and returns a reference.
        /// </summary>
        /// <returns></returns>
        private DeviceOptions RequestDeviceOptions()
        {
            DeviceOptions  deviceOptions  = null;
            DeviceRequests deviceRequests = new DeviceRequests();
            long           deviceid       = GetDeviceID();
            long           userid         = GetUserID();
            long           companyid      = GetCompanyID();

            deviceOptions = deviceRequests.GetDeviceOptions(String.Format("{0};{1};{2}", deviceid, userid, companyid));

            // Assign global DeviceOptions
            this.DeviceOptions = deviceOptions;
            return(deviceOptions);
        }
Esempio n. 2
0
        public static DeviceOptions LoadDevice(string id, DeviceType type)
        {
            DeviceOptions device = Brick.Options.Devices.Find(t => t.Id.Equals(id, StringComparison.InvariantCultureIgnoreCase));

            if (device == null)
            {
                throw new ArgumentException("No device found for given id");
            }
            if (type != device.Type)
            {
                throw new ArgumentException("Device type is invalid");
            }
            return(device);
        }
 protected void ToString(List <string> toStringOutput)
 {
     toStringOutput.Add($"Id = {(Id == null ? "null" : Id == string.Empty ? "" : Id)}");
     toStringOutput.Add($"AmountMoney = {(AmountMoney == null ? "null" : AmountMoney.ToString())}");
     toStringOutput.Add($"ReferenceId = {(ReferenceId == null ? "null" : ReferenceId == string.Empty ? "" : ReferenceId)}");
     toStringOutput.Add($"Note = {(Note == null ? "null" : Note == string.Empty ? "" : Note)}");
     toStringOutput.Add($"DeviceOptions = {(DeviceOptions == null ? "null" : DeviceOptions.ToString())}");
     toStringOutput.Add($"DeadlineDuration = {(DeadlineDuration == null ? "null" : DeadlineDuration == string.Empty ? "" : DeadlineDuration)}");
     toStringOutput.Add($"Status = {(Status == null ? "null" : Status == string.Empty ? "" : Status)}");
     toStringOutput.Add($"CancelReason = {(CancelReason == null ? "null" : CancelReason.ToString())}");
     toStringOutput.Add($"PaymentIds = {(PaymentIds == null ? "null" : $"[{ string.Join(", ", PaymentIds)} ]")}");
     toStringOutput.Add($"CreatedAt = {(CreatedAt == null ? "null" : CreatedAt == string.Empty ? "" : CreatedAt)}");
     toStringOutput.Add($"UpdatedAt = {(UpdatedAt == null ? "null" : UpdatedAt == string.Empty ? "" : UpdatedAt)}");
 }
Esempio n. 4
0
        public ActionResult UpdateDeviceOptions(
            [FromQuery, Required] string?id,
            [FromBody, Required] DeviceOptions deviceOptions)
        {
            var existingDeviceOptions = _deviceManager.GetDeviceOptions(id);

            if (existingDeviceOptions == null)
            {
                return(NotFound());
            }

            _deviceManager.UpdateDeviceOptions(id, deviceOptions);
            return(NoContent());
        }
        /// <summary>
        /// Refresh UI data from the web
        /// Initializes MattimonWebDataRequestBackgroundWorker and MattimonWebDataRequestTimer
        /// </summary>
        /// <param name="interval"></param>
        private void InitializeMattimonWebDataRequestWorker()
        {
            if (mRequestWorkerInit)
            {
                return;
            }
            ///
            /// MattimonWebDataRequestBackgroundWorker
            ///
            MattimonWebDataRequestBackgroundWorker = new BackgroundWorker();
            ///
            /// DoWork Handler
            ///
            MattimonWebDataRequestBackgroundWorker.DoWork += (s, e) =>
            {
                if (Program.MattimonWebApiReplies())
                {
                    object[] data = new object[2];
                    data[0]  = RequestDeviceOptions();
                    data[1]  = RequestVersion();
                    e.Result = data;
                }
            };
            ///
            /// RunWorkerCompleted Handler
            ///
            MattimonWebDataRequestBackgroundWorker.RunWorkerCompleted += (s, e) =>
            {
                if (e.Error != null)
                {
                    MessageBox.Show("An error occurred while attempted to refresh user data from the server." +
                                    "\n\nError details:\n" + e.Error.Message + (e.Error.InnerException != null ? "\n\n"
                                                                                + e.Error.InnerException.Message : ""),
                                    "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    Close();
                    Application.Exit();
                }

                // Parse the requested data
                object[]      data          = e.Result as object[];
                DeviceOptions deviceOptions = data[0] as DeviceOptions;
                String        version       = data[1] as String;

                // Set data on the UI
                UpdateGUIUserSettings(deviceOptions, version);
            };

            mRequestWorkerInit = true;
        }
Esempio n. 6
0
        /// <summary>
        /// Adds all required services and controllers for <b>Devices</b> feature.
        /// </summary>
        /// <param name="builder">An interface for configuring MVC services.</param>
        /// <param name="configure">Configuration used for <b>Devices</b> feature.</param>
        public static IMvcBuilder AddDevices(this IMvcBuilder builder, Action <DeviceOptions> configure = null)
        {
            var services = builder.Services;
            var options  = new DeviceOptions {
                Services = services
            };

            configure?.Invoke(options);
            options.Services = null;
            services.AddPushNotificationServiceNoop();
            services.TryAddTransient <IPlatformEventService, PlatformEventService>();
            builder.ConfigureApplicationPartManager(x => x.FeatureProviders.Add(new DevicesFeatureProvider()));
            builder.AddFluentValidation(options => options.RegisterValidatorsFromAssemblyContaining <DevicesFeatureProvider>());
            return(builder);
        }
Esempio n. 7
0
        public static NodeInfo UpdateTo(NodeInfo nodeInfo, DeviceOptions deviceOptions, byte generic, byte specific)
        {
            var ret         = nodeInfo;
            var capabuility = nodeInfo.Capability;
            var security    = nodeInfo.Security;

            if (deviceOptions.HasFlag(DeviceOptions.Listening))
            {
                capabuility |= 0x80;
            }
            else
            {
                capabuility &= 0x7F;
            }

            if (deviceOptions.HasFlag(DeviceOptions.OptionalFunctionality))
            {
                security |= 0x80;
            }
            else
            {
                security &= 0x7F;
            }

            if (deviceOptions.HasFlag(DeviceOptions.FreqListeningMode1000ms))
            {
                security |= 0x40;
            }
            else
            {
                security &= 0xBF;
            }

            if (deviceOptions.HasFlag(DeviceOptions.FreqListeningMode250ms))
            {
                security |= 0x20;
            }
            else
            {
                security &= 0xDF;
            }

            ret.Capability = capabuility;
            ret.Security   = security;
            ret.Generic    = generic;
            ret.Specific   = specific;
            return(ret);
        }
Esempio n. 8
0
 public MediaServer (string udn, string friendlyName, string manufacturer, string modelName, DeviceOptions options, ConnectionManager connectionManager, LocalContentDirectory contentDirectory)
 {
     if (connectionManager == null) throw new ArgumentNullException ("connnectionManager");
     if (contentDirectory == null) throw new ArgumentNullException ("contentDirectory");
     
     if (options == null) {
         options = new DeviceOptions ();
     }
     
     this.content_directory = contentDirectory;
     
     var connectionManagerService = new Service<ConnectionManager> (ConnectionManager.ServiceType, "urn:upnp-org:serviceId:ConnectionManager", connectionManager);
     var contentDirectoryService = new Service<LocalContentDirectory> (ContentDirectory.ServiceType, "urn:upnp-org:serviceId:ContentDirectory", contentDirectory);
     options.Services = Combine (new Service[] { connectionManagerService, contentDirectoryService }, options.Services);
     server = new Server (new Root (DeviceType, udn, friendlyName, manufacturer, modelName, options));
 }
        private void DoWorkCompleted(object sender, RunWorkerCompletedEventArgs e)
        {
            if (e.Error != null)
            {
                GUI.BitscoreForms.BitscoreMessageBox.Show(this, e.Error.ToString(), "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                Close();
                Application.Exit();
                return;
            }

            UserAuthentication ua      = (UserAuthentication)((object[])e.Result)[0];
            DeviceOptions      options = (DeviceOptions)((object[])e.Result)[1];
            string             version = ((object[])e.Result)[2] as string;

            UpdateGUIUserSettings(ua, options, version);
            Show();
        }
        /// <summary>
        /// Updates the device options and assigns the global variable/object Device Options and
        /// returns a reference.
        /// </summary>
        /// <param name="deviceOptions"></param>
        /// <returns></returns>
        private DeviceOptions UpdateDeviceOptions(DeviceOptions deviceOptions)
        {
            /* deviceOptions = procedure to update device options here */
            DeviceRequests deviceRequests = new DeviceRequests();

            return(this.DeviceOptions = deviceRequests.PostDeviceOptions(new Device
            {
                MonitorSql = deviceOptions.MonitorSql ? 1 : 0,
                MonitorEventLog = deviceOptions.MonitorEventLog,
                NotificationEmails = deviceOptions.NotificationEmails,
                NotifyHealth = deviceOptions.NotifyHealth,
                NotifyStatus = deviceOptions.NotifyStatus,
                AgentReportInterval = deviceOptions.ReportingInterval,
                Device_Id = GetDeviceID(),
                Company_Id = GetCompanyID(),
                User_Id = GetUserID()
            }));
        }
Esempio n. 11
0
        public Form2(Form1 form1, UserAuthentication userAuthentication, DeviceOptions deviceOptions) : base()
        {
            InitializeComponent();

            Form1 = form1;
            UserAuthentication = userAuthentication;
            DeviceOptions      = deviceOptions;

            btnCancel.Click    += btnCancel_Click;
            btnPrevious.Click  += btnPrevious_Click;
            btnPrevious.Enabled = true;
            btnNext.Click      += btnNext_Click;
            txtPath.Text        = Static.Constants.ApplicationDirectoryPath;
            SetText(label1,
                    "The installer will install " + Static.ExecutingAssemblyAttributes.AssemblyProduct +
                    " to the following folder.\nTo install in this folder, click \"Next\"." +
                    " To install to a different folder, click \"Browse\".");
        }
        /// <summary>
        ///
        /// </summary>
        /// <param name="options"></param>
        /// <param name="version"></param>
        private void UpdateGUIUserSettings(DeviceOptions options)
        {
            // Aside Menu
            btnMenu_SqlSrv.Visible = options.MonitorSql;
            // End

            // Settings page
            chk_settings_enableEmail.Checked           = options.NotificationEmails;
            chk_settings_enabeEvtLogMonitoring.Checked = options.MonitorEventLog > 0;
            chk_settings_enableSQLFeature.Checked      = options.MonitorSql;
            chk_settings_notifyStatus.Checked          = options.NotifyStatus;
            chk_settings_notifyHealth.Checked          = options.NotifyHealth;
            cbo_settings_reportInterval.SelectedItem   = (int)MattimonAgentLibrary.Tools.TimeSpanUtil.ConvertMillisecondsToMinutes(DeviceOptions.ReportingInterval);
            btn_settings_refreshSettings.Enabled       = true;
            // End

            // Status Strip
            lblStatus.Text = "Ready";
            // End
        }
Esempio n. 13
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="form2"></param>
        /// <param name="installPath"></param>
        public Form3(Form2 form2, String installPath, UserAuthentication userAuthentication, DeviceOptions options)
        {
            InitializeComponent();

            Form2              = form2;
            InstallPath        = installPath;
            UserAuthentication = userAuthentication;
            DeviceOptions      = options;

            btnCancel.Click    += BtnCancel_Click;
            btnPrevious.Click  += btnPrevious_Click;
            btnPrevious.Enabled = true;
            btnNext.Click      += btnNext_Click;

            SetText(this, base.Text + " (" + userAuthentication.Company_Name + ")");

            SetText(label1,
                    "The installer is ready to install " + Static.ExecutingAssemblyAttributes.AssemblyProduct + " on your computer.\n\n" +
                    "Click \"Next\" to start the installation.");
        }
Esempio n. 14
0
        private static async Task MainAsync()
        {
            var options = new DeviceOptions
            {
                MeasurementSecondsInterval = 1m
            };

            var devices = new List <IDevice>();

            for (var i = 0; i < 1000; i++)
            {
                devices.Add(DeviceFactory.Create(options));
            }

            // set event handler
            foreach (var device in devices.AsParallel())
            {
                device.TemperaturaMeasurement += Device_TemperaturaMeasurement;
            }

            var starts = devices.Select(c => c.On());
            await Task.WhenAll(starts);
        }
Esempio n. 15
0
        public MediaServer(string udn, string friendlyName, string manufacturer, string modelName, DeviceOptions options, ConnectionManager connectionManager, LocalContentDirectory contentDirectory)
        {
            if (connectionManager == null)
            {
                throw new ArgumentNullException("connnectionManager");
            }
            if (contentDirectory == null)
            {
                throw new ArgumentNullException("contentDirectory");
            }

            if (options == null)
            {
                options = new DeviceOptions();
            }

            this.content_directory = contentDirectory;

            var connectionManagerService = new Service <ConnectionManager> (ConnectionManager.ServiceType, "urn:upnp-org:serviceId:ConnectionManager", connectionManager);
            var contentDirectoryService  = new Service <LocalContentDirectory> (ContentDirectory.ServiceType, "urn:upnp-org:serviceId:ContentDirectory", contentDirectory);

            options.Services = Combine(new Service[] { connectionManagerService, contentDirectoryService }, options.Services);
            server           = new Server(new Root(DeviceType, udn, friendlyName, manufacturer, modelName, options));
        }
Esempio n. 16
0
        private void FetchDeviceOptions()
        {
            try
            {
                DeviceRequests requests      = new DeviceRequests();
                DeviceOptions  deviceOptions = requests.GetDeviceOptions(
                    String.Format("{0};{1};{2}", fetchedDeviceId, fetchedUserId, fetchedCompanyId));

                this.fetchedSQLMonitoring = deviceOptions.MonitorSql;

                if (deviceOptions.Exception != null)
                {
                    worker.CancelAsyncClose();
                    MessageBox.Show(this, deviceOptions.Exception.ToString(), "FetchDeviceOptions Exception", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    return;
                }
                if (deviceOptions.MySqlExceptionMessage != null)
                {
                    worker.CancelAsyncClose();
                    MessageBox.Show(deviceOptions.MySqlExceptionMessage, "Server Error (SQL)", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    return;
                }
                if (deviceOptions.HttpRequestException != null)
                {
                    worker.CancelAsyncClose();
                    MessageBox.Show(deviceOptions.MySqlExceptionMessage, "Http Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    return;
                }

                srvFetchedDeviceOptions = deviceOptions;
            }
            catch (Exception ex)
            {
                MessageBox.Show(this, ex.ToString(), "Error");
            }
        }
        public override int GetHashCode()
        {
            int hashCode = -1408597552;

            if (Id != null)
            {
                hashCode += Id.GetHashCode();
            }

            if (AmountMoney != null)
            {
                hashCode += AmountMoney.GetHashCode();
            }

            if (ReferenceId != null)
            {
                hashCode += ReferenceId.GetHashCode();
            }

            if (Note != null)
            {
                hashCode += Note.GetHashCode();
            }

            if (DeviceOptions != null)
            {
                hashCode += DeviceOptions.GetHashCode();
            }

            if (DeadlineDuration != null)
            {
                hashCode += DeadlineDuration.GetHashCode();
            }

            if (Status != null)
            {
                hashCode += Status.GetHashCode();
            }

            if (CancelReason != null)
            {
                hashCode += CancelReason.GetHashCode();
            }

            if (PaymentIds != null)
            {
                hashCode += PaymentIds.GetHashCode();
            }

            if (CreatedAt != null)
            {
                hashCode += CreatedAt.GetHashCode();
            }

            if (UpdatedAt != null)
            {
                hashCode += UpdatedAt.GetHashCode();
            }

            return(hashCode);
        }
Esempio n. 18
0
        private void DoWorkUpdateDeviceOptions(object sender, DoWorkEventArgs e)
        {
            if (debug_DoWorkUpdateDeviceOptions)
            {
                worker.CancelAsyncClose();
                MessageBox.Show("Will post device options for:\n" +
                                "device_id:     " + fetchedDeviceId + "\n" +
                                "user_id:       " + fetchedUserId + "\n" +
                                "company_id:    " + fetchedCompanyId
                                ); return;
            }



            DeviceOptions  tmp            = null;
            DeviceRequests deviceRequests = new DeviceRequests();

            using (new WaitCursor())
            {
                int port = cboAvailablePorts.SelectedIndex == 0 ? 0 : Convert.ToInt32(cboAvailablePorts.SelectedItem);

                tmp = deviceRequests.PostDeviceOptions(
                    new Device
                {
                    /* keys */
                    Device_Id  = fetchedDeviceId,
                    User_Id    = fetchedUserId,
                    Company_Id = fetchedCompanyId,
                    /* end keys */

                    /* options */
                    Port                = port,
                    UseAgent            = rdoMattiAgentYes.Checked,
                    MonitorSql          = rdoMattiAgentNo.Checked ? 0 : (chkMonitorSQL.Checked ? 1 : 0),
                    AgentReportInterval = selectedIntervalRadioButton,
                    NotificationEmails  = rdoNotifEmailsYes.Checked
                                          /* end options */
                }
                    );
            }
            worker.CancelAsyncClose();

            if (tmp.HttpStatusCode != System.Net.HttpStatusCode.OK)
            {
                MessageBox.Show(this, "We couldn't proccess your request at this time.\nThe application needs to close.\nPlease, re-run the program and try again.",
                                "Error (" + (int)tmp.HttpStatusCode + ")",
                                MessageBoxButtons.OK, MessageBoxIcon.Error);
                Application.Exit();
                return;
            }
            if (tmp.MySqlExceptionMessage != null)
            {
                MessageBox.Show(this, "We couldn't proccess your request at this time. " +
                                "Please, let us know about this error.\n\n" + tmp.MySqlExceptionMessage,
                                "Internal Server Error (MySQL)", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }
            if (tmp.Exception != null)
            {
                MessageBox.Show(this, "We couldn't proccess your request at this time. " +
                                "Please, let us know about this error.\n\n" + tmp.Exception.Message + "\n\n" +
                                tmp.Exception.StackTrace, "Error (" + tmp.Exception.Source + ")",
                                MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }

            if (tmp.RequestSuccess)
            {
                if (!tmp.UseAgent)
                {
                    using (new WaitCursor())
                    {
                        // We stop the service if settings are applied succesfully
                        // and the user selected "default mattimon service"
                        // (if the service is already running).
                        // Note: btnStopResume and btnRestart are enabled or disabled accordingly in RunThread()
                        StopMattimonAgentService();
                    }
                }
                else
                {
                    // Starts only if its stopped
                    StartMattimonAgentService();
                }

                // Show or hide sql monitor group box
                grpboxSQLSrv.Visible = tmp.MonitorSql;


                ///MessageBox.Show("Selected reporting interval is now " + selectedIntervalRadioButton);
                ///
                // Save the interval in the local database
                this.GetLocalDatabase().SetReportingInterval(selectedIntervalRadioButton);

                // Assign the new options to the fetchedDeviceOptions
                srvFetchedDeviceOptions = tmp;
                fetchedIntervals        = srvFetchedDeviceOptions.ReportingInterval;
                AutoEnableApplyButton();
                MessageBox.Show(this, "Your options have been received and applied", "Information", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
        }
Esempio n. 19
0
 public DummyRoot (DeviceType type, string udn, string friendlyName, string manufacturer, string modelName, DeviceOptions options)
     : base (type, udn, friendlyName, manufacturer, modelName, options)
 {
 }
Esempio n. 20
0
 /// <summary>
 /// Adds an Azure specific implementation of <see cref="IPushNotificationService"/> for sending push notifications.
 /// </summary>
 /// <param name="deviceOptions">Options used to configure <b>Devices</b> feature.</param>
 /// <param name="configure">Configure the available options for push notifications. Null to use defaults.</param>
 public static void UsePushNotificationsServiceAzure(this DeviceOptions deviceOptions, Action <IServiceProvider, PushNotificationAzureOptions> configure = null) =>
 deviceOptions.Services.AddPushNotificationServiceAzure(configure);
        private static Boolean PostDevice(MattimonSQLite.SQLiteClientDatabase db, out string errorMessage)
        {
            MattimonAgentLibrary.WMI.WMIProvider provider = new MattimonAgentLibrary.WMI.WMIProvider();
            Device device = new Device(); DeviceOptions deviceOptions = new DeviceOptions();
            /// If Operating System string contains 'server', we'll suppose that the device is a server
            /// Otherwise, we'll suppose that the device is a workstation.
            Boolean isServer = provider.GetOperatingSystemString().ToLower().Contains("server");
            /// Device type id should match psm_device_types primary key
            /// '2' means Server and '3' means Workstation, according to the Mattimon database on server.
            int definedDeviceTypeId = isServer ? 2 : 3;

            //device.Port = 80;  // Port should not be defined in this context---the user should select an active port from his own machine using MattimonAgentApplication.
            device.BIOSSerialNumber            = provider.GetBIOSSerialNumber();
            device.Company_Id                  = db.GetCompanyId();
            device.ComputerName                = provider.GetComputerName();
            device.IpAddress                   = provider.GetIPAddress();
            device.MacAddress                  = provider.GetMacAddress();
            device.Model                       = provider.GetModel();
            device.OperatingSystem             = provider.GetOperatingSystemString();
            device.OperatingSystemSerialNumber = provider.GetOSSerialNumber();
            device.User_Id                     = db.GetUserId();
            device.Device_Type_Id              = definedDeviceTypeId;
            device.AgentReportInterval         = db.GetReportingInterval();
            device.MonitorSql                  = 0;

            DeviceRequests requests = new DeviceRequests();

            device = requests.CreateDeviceEntry(device);

            Boolean postDeviceSuccess =
                device.Exception == null &&
                device.HttpRequestException == null &&
                device.MySqlExceptionMessage == null &&
                device.Device_Id > 0;

            if (postDeviceSuccess)
            {
                errorMessage = "";

                db.UpdateDeviceID(device.Device_Id);
            }
            else
            {
                errorMessage = "We could not receive your device due to the following errors.\n\n";

                if (device.HttpRequestException != null)
                {
                    errorMessage += device.HttpRequestException.Message + "\n\n" +
                                    device.HttpRequestException.StackTrace;
                }
                else if (device.Exception != null)
                {
                    errorMessage += device.Exception.Message + "\n\n" +
                                    device.Exception.StackTrace;
                }
                else if (device.MySqlExceptionMessage != null)
                {
                    errorMessage += device.MySqlExceptionMessage;
                }
                else
                {
                    errorMessage = "An unhandled error has occurred.";
                }
            }
            return(postDeviceSuccess);
        }
Esempio n. 22
0
 public DummyRoot(DeviceType type, string udn, string friendlyName, string manufacturer, string modelName, DeviceOptions options)
     : base(type, udn, friendlyName, manufacturer, modelName, options)
 {
 }
Esempio n. 23
0
        public void UpdateDeviceOptions(string deviceId, DeviceOptions options)
        {
            _authRepo.UpdateDeviceOptions(deviceId, options);

            DeviceOptionsUpdated?.Invoke(this, new GenericEventArgs <Tuple <string, DeviceOptions> >(new Tuple <string, DeviceOptions>(deviceId, options)));
        }
        /// <summary>
        /// Initializes MattimonWebDataUpdateBackgroundWorker that will be posting settings / data on the server
        /// </summary>
        private void InitializeMattimonWebDataUpdateWorker()
        {
            if (!mUpdateWorkerInit)
            {
                MattimonWebDataUpdateBackgroundWorker         = new BackgroundWorker();
                MattimonWebDataUpdateBackgroundWorker.DoWork += (s, e) =>
                {
                    e.Result = UpdateDeviceOptions(this.DeviceOptions);
                };
                MattimonWebDataUpdateBackgroundWorker.RunWorkerCompleted += (s, e) =>
                {
                    btn_settings_postSettings.Enabled = true;

                    if (e.Error != null)
                    {
                        // reset the switch!
                        dvcopt_agentIntervalChanged = false;

                        GUI.BitscoreForms.BitscoreMessageBox.Show(this,
                                                                  "An error occurred while attempting to post on the server.\n\nError details:\n\n" +
                                                                  e.Error.Message + "\n" + e.Error.StackTrace +
                                                                  (e.Error.InnerException != null ? "\n\nInner Exception:\n\n" + e.Error.InnerException.Message + "\n" + e.Error.InnerException.StackTrace:"")
                                                                  , "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                        Close();
                        return;
                    }

                    if (e.Result != null && e.Result is DeviceOptions options)
                    {
                        if (options.HttpRequestException != null)
                        {
                            // reset the switch!
                            dvcopt_agentIntervalChanged = false;


                            //GUI.BitscoreForms.BitscoreMessageBox.Show
                            MessageBox.Show(this,
                                            "An error occurred while attempting to post on the server.\n\nError details:\n\n" +
                                            options.HttpRequestException.Message + "\n" + options.HttpRequestException.StackTrace +
                                            (options.HttpRequestException.InnerException != null ? "\n\nInner Exception:\n\n" + options.HttpRequestException.InnerException.Message + "\n" + options.HttpRequestException.InnerException.StackTrace : "")
                                            , "Http Request Exception", MessageBoxButtons.OK, MessageBoxIcon.Error);
                            Close();
                            return;
                        }
                        if (options.Exception != null)
                        {
                            // reset the switch!
                            dvcopt_agentIntervalChanged = false;

                            //GUI.BitscoreForms.BitscoreMessageBox.Show(this,
                            MessageBox.Show(this,
                                            "An error occurred while attempting to post on the server.\n\nError details:\n\n" +
                                            options.Exception.Message + "\n" + options.Exception.StackTrace +
                                            (options.Exception.InnerException != null ? "\n\nInner Exception:\n\n" + options.Exception.InnerException.Message + "\n" + options.Exception.InnerException.StackTrace : "")
                                            , "Exception", MessageBoxButtons.OK, MessageBoxIcon.Error);
                            Close();
                            return;
                        }
                        if (options.MySqlExceptionMessage != null)
                        {
                            // reset the switch!
                            dvcopt_agentIntervalChanged = false;

                            GUI.BitscoreForms.BitscoreMessageBox.Show(this,
                                                                      "An error occurred while attempting to post on the server due to a database error.\n\nError details:n\n" + options.MySqlExceptionMessage,
                                                                      "Server Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                            Close();
                            return;
                        }

                        // If the interval was changed, restart the Agent Service.
                        if (dvcopt_agentIntervalChanged)
                        {
                            try
                            {
                                MyServiceController.StopService("MattimonAgentService");
                                if (MyServiceController.GetServiceStatus("MattimonAgentService") != MyServiceController.ServiceState.Running)
                                {
                                    MyServiceController.StartService("MattimonAgentService");
                                }
                            }
                            catch (Exception svcRestartError)
                            {
                                GUI.BitscoreForms.BitscoreMessageBox.Show(this,
                                                                          ExceptionHelper.GetFormatedExceptionMessage(svcRestartError),
                                                                          "Service Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                            }

                            // and reset the switch!
                            dvcopt_agentIntervalChanged = false;
                        }

                        // Assign global Device Options
                        this.DeviceOptions = options;

                        // Refresh the form to make sure the data were actually posted
                        Btn_settings_refreshSettings_Click(btn_settings_refreshSettings, EventArgs.Empty);

                        GUI.BitscoreForms.BitscoreMessageBox.Show(this,
                                                                  "Your settings have been succesfully posted on the server.", Text, MessageBoxButtons.OK, MessageBoxIcon.None);
                    }
                };
                mUpdateWorkerInit = true;
            }
        }