public object Any(CloseSession request) { var response = Global.RequestsProcessor.Any(request); TransferHeader(request, response); return(response); }
public ResponseBase Any(CloseSession request) { _logger.Log(EErrorType.Info, " ****** Call start: CloseSession"); CloseSessionResponse response = new CloseSessionResponse(); try { _logger.Log(EErrorType.Info, string.Format("Closing Session: {0}", request.SessionToken)); Interfaces.DAL.SessionInfo sinfo = new Interfaces.DAL.SessionInfo(); sinfo.SessionEnd = DateTime.UtcNow; sinfo.SessionId = request.SessionToken; _dal.CloseSession(sinfo); response.Success = true; } catch (Exception ex) { _logger.Log(ex); response.Success = false; response.Errors.Add(new Error() { Code = EErrorCodes.GeneralError, Type = EErrorType.Error, Message = string.Format("Unexpected error: {0}", ex.Message) }); } _logger.Log(EErrorType.Info, " ****** Call end: CloseSession"); return(response); }
public async Task CloseSession() { // Arrange var sessionCount = await _context.SessionCounts.SingleAsync(); sessionCount.NumClose = 0; sessionCount.NumOpen = 1; await _context.Sessions.AddAsync(_existingSession); await _context.SaveChangesAsync(); var handler = new Service.Handlers.CloseSessionHandler(_context, _mapper); var message = new CloseSession { SessionId = _existingSession.Id }; // Act await handler.Handle(message, new TestsMessageHandlerContext()); // Assert var refreshedContext = Common.GetDbContext(_connectionString); var session = await refreshedContext.Sessions.SingleAsync(); sessionCount = await refreshedContext.SessionCounts.SingleAsync(); Assert.Equal(message.SessionId, session.Id); Assert.Equal(0, session.Status); Assert.Equal(0, sessionCount.NumOpen); Assert.Equal(1, sessionCount.NumClose); }
void Start() { if (instance == default(CloseSession)) { instance = this; DontDestroyOnLoad(gameObject); } else { Destroy(this); } }
public void CloseSession_Sussess(string name) { RunInitSql(name, "ConnectionStringAccounts"); CloseSession request = PrepareRequest <CloseSession>(name); CloseSessionResponse response = Post <CloseSession, CloseSessionResponse>("CloseSession", request); RunFinalizeSql(name, "ConnectionStringAccounts"); Assert.AreEqual(response.Success, true, "Session was not closed"); Assert.IsEmpty(response.Errors, "Errors are not empty"); }
protected void CloseSession(string url) { // Initializing session using (var accountClient = new JsonServiceClient(url)) { CloseSession reqInit = new CloseSession(); reqInit.RequestID = System.Guid.NewGuid().ToString(); reqInit.SessionToken = SessionToken; CloseSessionResponse resClose = accountClient.Post <CloseSessionResponse>("CloseSession", reqInit); if (resClose.Success) { SessionToken = null; } else { throw new Exception(string.Format("CloseSession call error:{0}", resClose.Errors[0].Code)); } } }
public void GetSessionInfo_Closed(string name) { RunInitSql(name, "ConnectionStringAccounts"); // 1. initializing the session InitSession initReq = new InitSession() { AccountKey = ConfigurationManager.AppSettings["AccountKey"], RequestID = "D3770630-9532-457D-8EBB-DBF99F6A23D3", SessionToken = null }; InitSessionResponse initResp = Post <InitSession, InitSessionResponse>("InitSession", initReq); string sessionToken = initResp.SessionToken; // 2. closing session CloseSession closeReq = new CloseSession() { SessionToken = sessionToken }; CloseSessionResponse closeRes = Post <CloseSession, CloseSessionResponse>("CloseSession", closeReq); // 3. getting session information GetSessionInfo getSesionInfo = PrepareRequest <GetSessionInfo>(name); getSesionInfo.SessionToken = sessionToken; GetSessionInfoResponse sessionInfo = Post <GetSessionInfo, GetSessionInfoResponse>("GetSessionInfo", getSesionInfo); RunFinalizeSql(name, "ConnectionStringAccounts"); Assert.AreEqual(sessionInfo.Success, true, "Session was not found"); Assert.AreNotEqual(sessionInfo.Payload.SessionStart, DateTime.MinValue, "SessionStart time was not provided"); Assert.AreNotEqual(sessionInfo.Payload.SessionEnd, DateTime.MinValue, "SessionEnd time was not provided"); Assert.IsNotEmpty(sessionInfo.Errors, "Errors are empty"); Assert.AreEqual(sessionInfo.Errors[0].Type, EErrorType.Warning, "Warning of closed session is expected"); Assert.AreEqual(sessionInfo.Errors[0].Code, EErrorCodes.SessionClosed, "Invalid code returned"); }
public async Task <IActionResult> Close(Guid id) { var session = await this._countingStringsRepository.GetByIdAsync(id); if (session == null) { return(BadRequest(new { Detail = "Session not recognized" })); } if (session.Status == 0) { return(BadRequest(new { Detail = "Session is already closed" })); } var closeSessionCommand = new CloseSession { SessionId = session.Id, }; await this._messageSession.Send(closeSessionCommand); return(NoContent()); }
public EErrorCodes CloseSession() { EErrorCodes result = EErrorCodes.GeneralError; try { if (SessionToken != null) { CloseSession reqInit = new CloseSession(); reqInit.RequestID = System.Guid.NewGuid().ToString(); reqInit.SessionToken = SessionToken; CloseSessionResponse resInit = Post <CloseSession, CloseSessionResponse>("/api/accounts/CloseSession", reqInit); if (resInit.Success) { SessionToken = null; result = EErrorCodes.Success; } else { result = resInit.Errors[0].Code; } } else { result = EErrorCodes.Success; } } catch (Exception ex) { _lastError = ex; result = EErrorCodes.GeneralError; } return(result); }
public CloseSessionResponse PostCloseSession(CloseSession request) { var response = Post <CloseSession, CloseSessionResponse>("CloseSession", request); return(response); }