public Task <T> PostAsync <T>(IRestRequest postRequest, CancellationToken cancellationToken) { SFRestRequest sfRequest = (SFRestRequest)postRequest; if (sfRequest.jsonBody is AuthnRequest) { AuthnResponse authnResponse = new AuthnResponse { data = new AuthnResponseData() { token = "session_token", masterToken = "master_token", authResponseSessionInfo = new SessionInfo(), nameValueParameter = new List <NameValueParameter>() }, success = true }; // login request return success return(Task.FromResult <T>((T)(object)authnResponse)); } CloseResponse closeResponse = new CloseResponse { message = "Session no longer exists. New login required to access the service.", data = null, code = SESSION_GONE, success = false }; return(Task.FromResult <T>((T)(object)closeResponse)); }
public CloseResponse Close() { if (_configured) { try { CloseResponse response = new CloseResponse(TransbankWrap.close()); if (response.Success) { return(response); } else { throw new TransbankCloseException("Close retured an error: " + response.ResponseMessage, response); } } catch (TransbankCloseException) { throw; } catch (Exception e) { throw new TransbankException("Unable to execute close in pos", e); } } else { throw new TransbankException("Port not Configured"); } }
public async Task <CloseResponse> Close(int id) { CloseResponse response = new CloseResponse(); using (var ctx = GetInstance()) { string query = "UPDATE Roulette SET State=-1 WHERE id=?"; using (var command = new SQLiteCommand(query, ctx)) { command.Parameters.Add(new SQLiteParameter("id", id)); command.ExecuteNonQuery(); } query = "SELECT Bet FROM Roulette WHERE id=?"; using (var command = new SQLiteCommand(query, ctx)) { command.Parameters.Add(new SQLiteParameter("id", id)); using (var reader = command.ExecuteReader()) { while (reader.Read()) { response.Bet = Convert.ToInt32(reader[0]); } } } } return(response); }
public void OnFailure(CloseResponse p0) { CloseResponse.Extras extras = p0.GetExtras(); BiometricSdkResult result = new BiometricSdkResult(extras.IdState, extras.StateName, false, string.Empty, string.Empty, string.Empty, extras.AdditionalProp1); this.biometricResultTask = result; }
public void OnSuccess(CloseResponse p0, int p1, string p2) { CloseResponse.Extras extras = p0.GetExtras(); bool succesful = extras.IdState == "2"; BiometricSdkResult result = new BiometricSdkResult(extras.IdState, extras.StateName, succesful, string.Empty, string.Empty, string.Empty, extras.AdditionalProp1); this.biometricResultTask = result; }
public void Close() { Msg reply = null; lock (mu) { cleanupOnClose(null); if (nc == null || nc.IsClosed()) { nc = null; return; } CloseRequest req = new CloseRequest { ClientID = clientID }; try { if (closeRequests != null) { reply = nc.Request(closeRequests, ProtocolSerializer.marshal(req)); } } catch (StanBadSubscriptionException) { // it's possible we never actually connected. return; } if (reply != null) { CloseResponse resp = new CloseResponse(); try { ProtocolSerializer.unmarshal(reply.Data, resp); } catch (Exception e) { throw new StanCloseRequestException(e); } if (!string.IsNullOrEmpty(resp.Error)) { throw new StanCloseRequestException(resp.Error); } } if (ncOwned) { nc.Close(); } nc = null; } }
private void CloseToolStripMenuItem_Click(object sender, EventArgs e) { try { CloseResponse response = POS.Instance.Close(); if (response.Success) { MessageBox.Show(response.ToString(), "Keys Loaded Successfully."); } } catch (TransbankException a) { MessageBox.Show(a.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
internal static SMBCommand GetCloseResponse(SMBHeader header, CloseRequest request, StateObject state) { string openedFilePath = state.GetOpenedFilePath(request.FID); if (openedFilePath == null) { header.Status = NTStatus.STATUS_SMB_BAD_FID; return(new ErrorResponse(CommandName.SMB_COM_CLOSE)); } state.RemoveOpenedFile(request.FID); CloseResponse response = new CloseResponse(); return(response); }
public CloseResponse close(CloseRequest req) { CloseResponse rsp = null; try { var strResp = this.InternalRequest(req, "close"); rsp = JsonConvert.DeserializeObject <CloseResponse>(strResp); } catch (JsonSerializationException e) { throw new Exception(e.Message); } return(rsp); }
public static SMB2Body CreateSMB2Body(byte[] vs, int offset, ESMB2Command eSMB2Command, SMB2HeaderFlags smb2HeaderFlags, NTStateType ntState) { SMB2Body sMB2Body = null; if (smb2HeaderFlags.HasFlag(SMB2HeaderFlags.ServerToRedir)) { if (ntState == NTStateType.Success || ntState == NTStateType.MoreProcessingRequired || ntState == NTStateType.LogonFailure) { switch (eSMB2Command) { case ESMB2Command.NEGOTIATE: sMB2Body = NegotiateResponse.Parser(vs, offset); break; case ESMB2Command.SESSION_SETUP: sMB2Body = SessionSetupResponse.Parser(vs, offset); break; case ESMB2Command.TREE_CONNECT: sMB2Body = TreeConnectResponse.Parser(vs, offset); break; case ESMB2Command.LOGOFF: case ESMB2Command.TREE_DISCONNECT: sMB2Body = LogoffAndTreeDisconnect.Parser(vs, offset); break; case ESMB2Command.CREATE: sMB2Body = CreateResponse.Parser(vs, offset); break; case ESMB2Command.CLOSE: sMB2Body = CloseResponse.Parser(vs, offset); break; case ESMB2Command.WRITE: sMB2Body = WriteResponse.Parser(vs, offset); break; case ESMB2Command.READ: sMB2Body = ReadResponse.Parser(vs, offset); break; case ESMB2Command.IOCTL: sMB2Body = IOCTLResponse.Parser(vs, offset); break; default: throw new Exception("UnKnow SMB2 Command"); } } else { sMB2Body = ErrorResponse.Parser(vs, offset); } } else { throw new NotImplementedException(); } return(sMB2Body); }
internal static SMB2Command GetCloseResponse(CloseRequest request, ISMBShare share, SMB2ConnectionState state) { SMB2Session session = state.GetSession(request.Header.SessionID); OpenFileObject openFile = session.GetOpenFileObject(request.FileId); if (openFile == null) { state.LogToServer(Severity.Verbose, "Close failed. Invalid FileId. (SessionID: {0}, TreeID: {1}, FileId: {2})", request.Header.SessionID, request.Header.TreeID, request.FileId.Volatile); return(new ErrorResponse(request.CommandName, NTStatus.STATUS_FILE_CLOSED)); } NTStatus closeStatus = share.FileStore.CloseFile(openFile.Handle); if (closeStatus != NTStatus.STATUS_SUCCESS) { state.LogToServer(Severity.Information, "Close: Closing '{0}{1}' failed. NTStatus: {2}. (SessionID: {3}, TreeID: {4}, FileId: {5})", share.Name, openFile.Path, closeStatus, request.Header.SessionID, request.Header.TreeID, request.FileId.Volatile); return(new ErrorResponse(request.CommandName, closeStatus)); } state.LogToServer(Severity.Information, "Close: Closed '{0}{1}'. (SessionID: {2}, TreeID: {3}, FileId: {4})", share.Name, openFile.Path, request.Header.SessionID, request.Header.TreeID, request.FileId.Volatile); session.RemoveOpenFile(request.FileId); CloseResponse response = new CloseResponse(); if (request.PostQueryAttributes) { FileNetworkOpenInformation fileInfo = NTFileStoreHelper.GetNetworkOpenInformation(share.FileStore, openFile.Path, session.SecurityContext); if (fileInfo != null) { response.CreationTime = fileInfo.CreationTime; response.LastAccessTime = fileInfo.LastAccessTime; response.LastWriteTime = fileInfo.LastWriteTime; response.ChangeTime = fileInfo.ChangeTime; response.AllocationSize = fileInfo.AllocationSize; response.EndofFile = fileInfo.EndOfFile; response.FileAttributes = fileInfo.FileAttributes; } } return(response); }
public async Task <BaseResponse <CloseResponse> > Close(int id) { try { CloseResponse response = await DbContex.Close(id); if (response.Bet == 0) { return new BaseResponse <CloseResponse> { Reponse = null, message = "Not exist roulette" } } ; return(new BaseResponse <CloseResponse> { Reponse = response }); } catch (Exception ex) { return(new BaseResponse <CloseResponse> { Reponse = null, message = "ERROR: " + ex.Message }); } }
public TransbankCloseException(string message, CloseResponse response) : base(message) { RegisterCloseResponse = response; }
public void Close() { Msg reply = null; lock (mu) { IConnection lnc = nc; nc = null; if (lnc == null) { return; } if (lnc.IsClosed()) { return; } if (ackSubscription != null) { ackSubscription.Unsubscribe(); ackSubscription = null; } if (hbSubscription != null) { hbSubscription.Unsubscribe(); hbSubscription = null; } CloseRequest req = new CloseRequest(); req.ClientID = this.clientID; try { if (this.closeRequests != null) { reply = lnc.Request(closeRequests, ProtocolSerializer.marshal(req)); } } catch (StanBadSubscriptionException) { // it's possible we never actually connected. return; } if (reply != null) { CloseResponse resp = new CloseResponse(); try { ProtocolSerializer.unmarshal(reply.Data, resp); } catch (Exception e) { throw new StanCloseRequestException(e); } if (!string.IsNullOrEmpty(resp.Error)) { throw new StanCloseRequestException(resp.Error); } } if (ncOwned && lnc != null) { lnc.Close(); } } }
public void Close() { Msg reply = null; lock (mu) { cleanupOnClose(null); if (nc == null || nc.IsClosed()) { nc = null; return; } CloseRequest req = new CloseRequest { ClientID = clientID }; try { if (closeRequests != null) { reply = nc.Request(closeRequests, ProtocolSerializer.marshal(req)); } } catch (StanBadSubscriptionException) { // it's possible we never actually connected. return; } catch (NATSReconnectBufferException) { // In order to maintain backward compatibility, we need to avoid throwing // this exception. The reply will be null, so we'll fall through // and gracefully close the streaming connection. The streaming server // will cleanup this client on its own. } if (reply != null) { CloseResponse resp = new CloseResponse(); try { ProtocolSerializer.unmarshal(reply.Data, resp); } catch (Exception e) { throw new StanCloseRequestException(e); } if (!string.IsNullOrEmpty(resp.Error)) { throw new StanCloseRequestException(resp.Error); } } if (ncOwned) { nc.Close(); } nc = null; } }