예제 #1
0
        public void RunUpdater()
        {
            _instance?.Invoke((MethodInvoker) delegate
            {
                _instance.btnPlay.Enabled = false;
            });

            LoginApiResponse resp = GetLoginAPIResponse(_instance?.txtUser.Text, _instance?.txtPass.Text);

            if (resp == null)
            {
                Log.Info("API response was null.");
                return;
            }

            Log.Info("Response Status info:");
            Log.Info("Status: " + resp.status);
            Log.Info("Reason: " + resp.reason);
            Log.Info("Additi: " + resp.additional);

            switch (resp.status)
            {
            case "true":
            {
                _instance?.Invoke((MethodInvoker) delegate
                    {
                        _instance.lblInfo.ForeColor = Color.Green;
                        _instance.lblInfo.Text      = resp.reason;
                    });
                UpdateFilesAndPlay();
                break;
            }

            case "false":
            {
                _instance?.Invoke((MethodInvoker) delegate
                    {
                        _instance.lblInfo.ForeColor = Color.Red;
                        _instance.lblInfo.Text      = resp.reason;
                        _instance.btnPlay.Enabled   = true;
                    });
                break;
            }

            case "critical":
            {
                _instance?.Invoke((MethodInvoker) delegate
                    {
                        _instance.lblInfo.ForeColor = Color.Red;
                        _instance.lblInfo.Text      = resp.additional;
                        _instance.btnPlay.Enabled   = true;
                    });
                break;
            }

            case "info":
            {
                _instance?.Invoke((MethodInvoker) delegate
                    {
                        _instance.lblInfo.ForeColor = Color.Orange;
                        _instance.lblInfo.Text      = resp.reason;
                        _instance.btnPlay.Enabled   = true;
                    });
                break;
            }

            default:
            {
                _instance.BeginInvoke((MethodInvoker) delegate
                    {
                        MessageBox.Show(_instance, "There was an error logging you in!", "Oops!");
                        _instance.lblInfo.ForeColor = Color.Red;
                        _instance.lblInfo.Text      = "Error";
                    });
                break;
            }
            }

            _instance?.Invoke((MethodInvoker) delegate
            {
                _instance.lblInfo.Visible = true;
                _instance.ActiveControl   = null;
            });
        }