예제 #1
0
파일: frmSGMLogin.cs 프로젝트: tuanly/SGM
        private void btnLogin_Click(object sender, EventArgs e)
        {
            // validate user input
            if (ValidateLoginCode() == false)
                return;

            // request server
            string GASSTORE_ID = txtLoginCode.Text;
            string GASSTORE_MACADDRESS = GetMacAddress();
            Task<String> task = SGM_WaitingIdicator.WaitingForm.waitingFrm.progressReporter.RegisterTask(
            () => {
                return service.SGMSaleGas_ValidateGasStoreLogin(GASSTORE_ID, GASSTORE_MACADDRESS);
            });
            SGM_WaitingIdicator.WaitingForm.waitingFrm.progressReporter.RegisterContinuation(task, () =>
            {
                String stResponse = task.Result as String;
                DataTransfer dataResponse = JSonHelper.ConvertJSonToObject(stResponse);
                if (dataResponse.ResponseCode == DataTransfer.RESPONSE_CODE_SUCCESS)
                {
                    this.Hide();
                    if (Program.ReaderPort != null)
                        Program.ReaderPort.DataReceived -= serialDatahandler;

                    frmSGMUpdateStore frm = new frmSGMUpdateStore(dataResponse.ResponseDataGasStoreDTO);
                    frm.ShowDialog();
                    this.Close();
                }
                else
                    frmMsg.ShowMsg(SGMText.SGM_ERROR, dataResponse.ResponseErrorMsg, SGMMessageType.SGM_MESSAGE_TYPE_ERROR);
            }, SynchronizationContext.Current);
        }
예제 #2
0
파일: frmSGMLogin.cs 프로젝트: tuanly/SGM
        private void btnLogin_Click(object sender, EventArgs e)
        {
            // validate user input
            if (ValidateLoginCode() == false)
            {
                return;
            }

            // request server
            string        GASSTORE_ID         = txtLoginCode.Text;
            string        GASSTORE_MACADDRESS = GetMacAddress();
            Task <String> task = SGM_WaitingIdicator.WaitingForm.waitingFrm.progressReporter.RegisterTask(
                () => {
                return(service.SGMSaleGas_ValidateGasStoreLogin(GASSTORE_ID, GASSTORE_MACADDRESS));
            });

            SGM_WaitingIdicator.WaitingForm.waitingFrm.progressReporter.RegisterContinuation(task, () =>
            {
                String stResponse         = task.Result as String;
                DataTransfer dataResponse = JSonHelper.ConvertJSonToObject(stResponse);
                if (dataResponse.ResponseCode == DataTransfer.RESPONSE_CODE_SUCCESS)
                {
                    this.Hide();
                    if (Program.ReaderPort != null)
                    {
                        Program.ReaderPort.DataReceived -= serialDatahandler;
                    }

                    frmSGMUpdateStore frm = new frmSGMUpdateStore(dataResponse.ResponseDataGasStoreDTO);
                    frm.ShowDialog();
                    this.Close();
                }
                else
                {
                    frmMsg.ShowMsg(SGMText.SGM_ERROR, dataResponse.ResponseErrorMsg, SGMMessageType.SGM_MESSAGE_TYPE_ERROR);
                }
            }, SynchronizationContext.Current);
        }