Ejemplo n.º 1
0
        private void ExecuteCommand()
        {
            // Set Flag
            _commandExecuteInProgress = true;

            // Temporary sould replaced by config

            /*RestClient restClient = new RestClient();
             */
            string serverBase = Settings.RestController.ServerBase;//"http://10.0.0.13/damarnet/api/";
            string resource = "", resourceSuffix = Settings.RestController.ResourcePrefix;

            if (_frmMode == FormMode.QueryServerInformation)
            {
                resource = "ServerInformation";
                ServerInformation srvInfo = null;
                RestController <ServerInformation> rsi;
                rsi = new RestController <ServerInformation>(serverBase, resource, resourceSuffix);

                try
                {
                    srvInfo = rsi.GetData();
                    _launcher.SetServerInfo(srvInfo);
                    _commandExecuteInProgress = false;
                    Hide();
                }
                catch (Exception exp)
                {
                    DialogResult result;
                    result = MessageBox.Show(exp.Message, "Error", MessageBoxButtons.RetryCancel);
                    //if (result == DialogResult.Retry)
                    //{
                    _commandExecuteInProgress = false;
                    _commandRetry++;
                    //}
                }
            }
            else if (_frmMode == FormMode.QueryClientInformation)
            {
                resource = "ClientInformation";
                ClientInformation clientInfo = null;
                RestController <ClientInformation> rsc;
                rsc = new RestController <ClientInformation>(serverBase, resource, resourceSuffix);

                try
                {
                    clientInfo = rsc.GetData();
                    _launcher.SetClientInfo(clientInfo);
                    _commandExecuteInProgress = false;
                    Hide();
                }
                catch (Exception exp)
                {
                    DialogResult result;
                    result = MessageBox.Show(exp.Message, "Error", MessageBoxButtons.RetryCancel);
                    //if (result == DialogResult.Retry)
                    //{
                    _commandExecuteInProgress = false;
                    _commandRetry++;
                    //}
                }
            }
            else if (_frmMode == FormMode.QuerySessionInformation)
            {
                resource = "SessionInformation";
                SessionInformation sessionInfo = null;
                RestController <SessionInformation> rss;
                rss = new RestController <SessionInformation>(serverBase, resource, resourceSuffix);

                try
                {
                    sessionInfo = rss.GetData();
                    _launcher.SetSessionInfo(sessionInfo);
                    _commandExecuteInProgress = false;
                    Hide();
                }
                catch (Exception exp)
                {
                    //DialogResult result;
                    Hide();
                    //string resource = "ClientLogin"
                    //RestController<SessionInformation> rss;
                    //rss = RestController<SessionInformation>(serverBase, resource, resourceSuffix);
                    _launcher.BringToFront();
                    _frmLogin = new FormLogin(this, rss);
                    _frmLogin.SetMode(FormLogin.FormMode.Timecode);
                    _frmLogin.ShowDialog();
                    sessionInfo = _frmLogin.GetSessionInfo();
                    _launcher.SetSessionInfo(sessionInfo);
                    //Show();
                    //result = MessageBox.Show(exp.Message, "Error", MessageBoxButtons.RetryCancel);
                    //if (result == DialogResult.Retry)
                    //{
                    _commandExecuteInProgress = false;
                    //_commandRetry++;
                    //}
                }
            }
        }
Ejemplo n.º 2
0
        private void ExecuteCommand()
        {
            // Set Flag
            _commandExecuteInProgress = true;

            // Temporary sould replaced by config
            /*RestClient restClient = new RestClient();
            */
            string serverBase = Settings.RestController.ServerBase;//"http://10.0.0.13/damarnet/api/";
            string resource = "", resourceSuffix = Settings.RestController.ResourcePrefix;

            if (_frmMode == FormMode.QueryServerInformation)
            {
                resource = "ServerInformation";
                ServerInformation srvInfo = null;
                RestController<ServerInformation> rsi;
                rsi = new RestController<ServerInformation>(serverBase, resource, resourceSuffix);

                try
                {
                    srvInfo = rsi.GetData();
                    _launcher.SetServerInfo(srvInfo);
                    _commandExecuteInProgress = false;
                    Hide();
                }
                catch (Exception exp)
                {
                    DialogResult result;
                    result = MessageBox.Show(exp.Message, "Error", MessageBoxButtons.RetryCancel);
                    //if (result == DialogResult.Retry)
                    //{
                        _commandExecuteInProgress = false;
                        _commandRetry++;
                    //}
                }

            }
            else if (_frmMode == FormMode.QueryClientInformation)
            {
                resource = "ClientInformation";
                ClientInformation clientInfo = null;
                RestController<ClientInformation> rsc;
                rsc = new RestController<ClientInformation>(serverBase, resource, resourceSuffix);

                try
                {
                    clientInfo = rsc.GetData();
                    _launcher.SetClientInfo(clientInfo);
                    _commandExecuteInProgress = false;
                    Hide();
                }
                catch (Exception exp)
                {
                    DialogResult result;
                    result = MessageBox.Show(exp.Message, "Error", MessageBoxButtons.RetryCancel);
                    //if (result == DialogResult.Retry)
                    //{
                    _commandExecuteInProgress = false;
                    _commandRetry++;
                    //}
                }
            }
            else if (_frmMode == FormMode.QuerySessionInformation)
            {
                resource = "SessionInformation";
                SessionInformation sessionInfo = null;
                RestController<SessionInformation> rss;
                rss = new RestController<SessionInformation>(serverBase, resource, resourceSuffix);

                try
                {
                    sessionInfo = rss.GetData();
                    _launcher.SetSessionInfo(sessionInfo);
                    _commandExecuteInProgress = false;
                    Hide();
                }
                catch (Exception exp)
                {
                    //DialogResult result;
                    Hide();
                    //string resource = "ClientLogin"
                    //RestController<SessionInformation> rss;
                    //rss = RestController<SessionInformation>(serverBase, resource, resourceSuffix);
                    _launcher.BringToFront();
                    _frmLogin = new FormLogin(this, rss);
                    _frmLogin.SetMode(FormLogin.FormMode.Timecode);
                    _frmLogin.ShowDialog();
                    sessionInfo = _frmLogin.GetSessionInfo();
                    _launcher.SetSessionInfo(sessionInfo);
                    //Show();
                    //result = MessageBox.Show(exp.Message, "Error", MessageBoxButtons.RetryCancel);
                    //if (result == DialogResult.Retry)
                    //{
                    _commandExecuteInProgress = false;
                    //_commandRetry++;
                    //}
                }
            }
        }