Beispiel #1
0
        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());
        }
Beispiel #2
0
        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!");
        }
Beispiel #3
0
        public static void ReLogin(string strAPI, SessionVO check)
        {
            string tokenVal = WebRelogin(strAPI, check);

            TokenValue(tokenVal);
            SessionCheck(ANBTX.notConvertaccessTokenHold);
        }
Beispiel #4
0
 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);
 }
Beispiel #5
0
        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))));
        }
Beispiel #6
0
        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)));
        }
Beispiel #7
0
        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);
        }
Beispiel #8
0
        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);
        }
Beispiel #9
0
 public async Task MarkSessionWithStartedAsync(SessionVO newSessionStatus) =>
 await _connection.InvokeAsync(newSessionStatus);
Beispiel #10
0
        //Invoke

        public async Task CreateSessionAsync(SessionVO newSession)
        {
            await ConnectAsync();

            await _connection.InvokeAsync(newSession);
        }