Ejemplo n.º 1
0
        private void DoRefill()
        {
            if (txtTimecode.Text.Length != 7)
            {
                MessageBox.Show(null, "Mohon masukkan 7 digit timekode", "Maaf");
                return;
            }

            string code = Utils.Md5(txtTimecode.Text);

            RestController <MessageData> rcd;

            rcd = new RestController <MessageData>(Settings.RestController.ServerBase,
                                                   "ClientRefill", Settings.RestController.ResourcePrefix);
            // = null;

            //SessionInformation si = null;
            string parameter = "?data=" + code + "&src=" + _launcher.GetSessionInfo().Code;


            try
            {
                MessageData md = rcd.GetData(parameter);

                if (md != null)
                {
                    if (md.Text != "Ok")
                    {
                        MessageBox.Show(null, "Kode sudah tidak berlaku", "Maaf,");
                    }
                    else
                    {
                        MessageBox.Show(null, "Refill berhasil", "Selamat");
                    }
                }
                txtTimecode.Text = "";
                Hide();
            }
            catch (Exception exp)
            {
                MessageBox.Show(null, "Kode tidak berlaku", "Maaf,");
            }
        }
Ejemplo n.º 2
0
        private void LoadClientList()
        {
            RestController <ClientInformations> rclist;

            rclist = new RestController <ClientInformations>(Settings.RestController.ServerBase,
                                                             "stations", Settings.RestController.ResourcePrefix);
            ClientInformations clist = null;

            try
            {
                //string param = "?data=" + txtChat.Text;
                clist = rclist.GetData();
                if (clist != null)
                {
                    //for
                }
            }
            catch (Exception exp) {
                AddToList(txtChat.Text + " : " + exp.Message);
            }
        }
Ejemplo n.º 3
0
 private void txtChat_KeyDown(object sender, KeyEventArgs e)
 {
     if (e.KeyCode == Keys.Return)
     {
         RestController <MessageData> rcd;
         rcd = new RestController <MessageData>(Settings.RestController.ServerBase,
                                                "Chat", Settings.RestController.ResourcePrefix);
         MessageData md = null;
         try
         {
             string param = "?data=" + txtChat.Text;
             md = rcd.GetData(param);
             if (md != null)
             {
                 AddToList("@Nyong " + txtChat.Text);
             }
         }
         catch (Exception exp) {
             AddToList(txtChat.Text + " : " + exp.Message);
         }
         txtChat.Text = "";
     }
 }
Ejemplo n.º 4
0
        private void timerPush_Tick(object sender, EventArgs e)
        {
            _pushData = null;
            if (_rpd == null)
            {
                string resource = "TimecodePush";
                _rpd = new RestController <PushData>(Settings.RestController.ServerBase, resource, Settings.RestController.ResourcePrefix);
            }
            if (_sessionInformation != null && _rpd != null)
            {
                string parameter = "?data=" + _sessionInformation.Code;
                try
                {
                    _pushData = _rpd.GetData(parameter);
                }
                catch (Exception exp)
                {
                    DisplayBallonTips(exp.Message, 2000);
                }

                if (_pushData != null && _pushData.Duration != 0)
                {
                    string DurationText = Utils.DurationToText(_pushData.Duration);
                    DisplayBallonTips(DurationText, 3000);
                }
                //else if (_pushData.Duration <= 3)
                //{
                //    //Logout
                //    DoLogout();
                //}
            }
            if (_pushData == null)
            {
                //Logout
                DoLogout();
            }
        }
Ejemplo n.º 5
0
        private void DoLogout()
        {
            RestController <MessageData> rmd;
            MessageData md        = null;
            string      resource  = "ClientLogout";
            string      parameter = "?data=" + _sessionInformation.Code;

            rmd = new RestController <MessageData>(Settings.RestController.ServerBase, resource, Settings.RestController.ResourcePrefix);
            try
            {
                md = rmd.GetData(parameter);
            }
            catch (Exception exp)
            {
                DisplayBallonTips(exp.Message, 2000);
            }
            _sessionInformation = null;
            _pushData           = null;
            timerPush.Enabled   = false;
            _frmConfirm.Hide();
            ProcessMonitor.KillAll();
            Show();
            FullScreen();
        }
Ejemplo n.º 6
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++;
                    //}
                }
            }
        }