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); }
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); }