public static string WebRelogin(String strAPI, SessionVO check) { StringBuilder dataParam = new StringBuilder(); dataParam.Append("grant_type=password"); dataParam.Append("&username="******"&password="******"POST"; loginCheck.Accept = "application/json"; loginCheck.Headers.Add(HttpRequestHeader.Authorization, "Basic YW5iZGV2Y2VudGVyLWNsaWVudC13aXRoLXNlY3JldDpkZXZjZW50ZXI="); loginCheck.ContentType = "application/x-www-form-urlencoded"; Stream stDataParams = loginCheck.GetRequestStream(); stDataParams.Write(byteDataParams, 0, byteDataParams.Length); stDataParams.Close(); HttpWebResponse resLogin = (HttpWebResponse)loginCheck.GetResponse(); Stream stReadData = resLogin.GetResponseStream(); StreamReader srReadData = new StreamReader(stReadData, Encoding.Default); return(srReadData.ReadToEnd()); }
public async Task MarkSessionWithStartedAsync(SessionVO newSession) { if (!(await _sessionBusiness.FindBySessionReferenceTaskAsync(newSession.SessionReference) is SessionVO currentSession)) { await Clients.Caller.NotExistsThisSessionAsync("Nao existe uma sessao com esse nome!"); return; } if (currentSession.SessionStatus == SessionStatusEnum.InProgress) { await Clients.Caller.NotUpdatedSessionStatusAsync("A sessao ja está em andamento!"); return; } if (!(await _sessionBusiness.ChangeStatusSessionTaskAsync(newSession) is SessionVO updatedSession)) { await Clients.Caller.NotUpdatedSessionStatusAsync("Nao foi possível iniciar a sessao, tente novamente!"); return; } await Clients.Caller.UpdatedSessionStatusAsync(updatedSession, "Sessao iniciada com sucesso!"); await Clients.OthersInGroup(newSession.SessionReference).SessionStartedAsync(newSession, "A sessao foi iniciada com sucesso!"); }
public static void ReLogin(string strAPI, SessionVO check) { string tokenVal = WebRelogin(strAPI, check); TokenValue(tokenVal); SessionCheck(ANBTX.notConvertaccessTokenHold); }
public static String TokenSet(string tokenVal) { notConvertaccessTokenHold = tokenVal; accessTokenHold = Newtonsoft.Json.JsonConvert.SerializeObject(tokenVal); Console.WriteLine(" 값 체크 : " + notConvertaccessTokenHold); Console.WriteLine(" 값 체크 : " + accessTokenHold); session = ANBTX_JWT_module.SessionCheck(tokenVal); return(accessTokenHold); }
public async Task <SessionVO> ChangeStatusSessionTaskAsync(SessionVO newSession) { if (!(await _sessionRepository.FindBySessionReferenceTaskAsync(newSession.SessionReference) is SessionModel currentSession)) { return(null); } newSession.SessionDate = currentSession.SessionDate; return(_sessionConverter.Parse(await _sessionRepository.ChangeStatusSessionTaskAsync(currentSession, _sessionConverter.Parse(newSession)))); }
public async Task <SessionVO> AddSessionTaskAsync(SessionVO session) { if (!(_sessionConverter.Parse(session) is SessionModel sessionModel)) { return(null); } session.SessionDate = DateTime.Now; return(_sessionConverter.Parse(await _sessionRepository.AddTaskAsync(sessionModel))); }
public static SessionVO SessionCheck(string splitToken) { var check = splitToken.Split('.'); string partToConvert = check[1]; partToConvert = partToConvert.Replace('-', '+'); partToConvert = partToConvert.Replace('_', '/'); switch (partToConvert.Length % 4) { case 0: break; case 2: partToConvert += "=="; break; case 3: partToConvert += "="; break; } var partAsBytes = Convert.FromBase64String(partToConvert); Console.WriteLine(partAsBytes.ToString()); var partAsUTF8String = Encoding.UTF8.GetString(partAsBytes, 0, partAsBytes.Count()); Console.WriteLine(partAsUTF8String.ToString()); var jwt = JObject.Parse(partAsUTF8String); Console.WriteLine(jwt.ToString()); var session = new SessionVO(); session.loginEmailId = jwt.GetValue("user_name").ToString(); session.loginPassword = setSession.password.ToString() == null?session.loginPassword.ToString() : setSession.password.ToString(); session.loginJti = jwt.GetValue("jti").ToString(); session.loginAdmin = jwt.GetValue("authorities").ToString(); var gaga = ANBTX_Common.GetEmployee("/api/employee"); Console.WriteLine(gaga.Where(o => o.email != null && o.email.Equals("*****@*****.**")).Select(o => o.empNm).ToString()); //session.loginEmpId = gaga.Where(o => o.email == jwt.GetValue("user_name").ToString()).Select(o => o.empNm).; return(session); }
public async Task CreateSessionAsync(SessionVO newSession) { if (await _sessionBusiness.FindBySessionReferenceTaskAsync(newSession.SessionReference) is SessionVO) { await Clients.Caller.AlreadyExistsSessionAsync("Já existe uma sessao com este nome!"); return; } if (!(await _sessionBusiness.AddSessionTaskAsync(newSession) is SessionVO addedSession)) { await Clients.Caller.NotCreatedSessionAsync("Nao foi possível criar a sessao, tente novamente!"); return; } await Clients.Caller.CreatedSessionAsync(addedSession, "Sessao criada com sucesso!"); await Groups.AddToGroupAsync(Context.ConnectionId, addedSession.SessionReference); }
public async Task MarkSessionWithStartedAsync(SessionVO newSessionStatus) => await _connection.InvokeAsync(newSessionStatus);
//Invoke public async Task CreateSessionAsync(SessionVO newSession) { await ConnectAsync(); await _connection.InvokeAsync(newSession); }