Esempio n. 1
0
        public sesion LoginSistema(string laip, string username, string pass)
        {
            var result = new sesion();

            //resultList _area;
            // string token = GetToken(laip).activeToken;
            //string de url principal
            string urlPath   = "https://riews.reinfoempresa.com:8443";
            string SecretKey = "eyJhbGciOiJIUzUxMiJ9.eyJzdWIiOiJSZWN1cnNvcyBJbmZvcm3DoXRpY29zIEVtcHJlc2FyaWFsZXMsIFMuTC4iLCJpYXQiOjE1Nzc5NTgzNjYsImV4cCI6MTYwOTU4MDc2NywibmJmIjoxNTc3OTU4MzY2LCJpc3MiOiJhZHJpYW4iLCJlbnQiOiI0IiwiaW5zIjoiMSIsInVzYyI6IjMiLCJzbnUiOiI5OTk5LTg4ODgtMTEiLCJpcHMiOiJOVEV1TnpjdU1UTTNMakU0Tnc9PSIsImV4ZSI6IjExLjAuNSsxMC1wb3N0LVVidW50dS0wdWJ1bnR1MS4xMTguMDQiLCJsYW4iOiJzcGEiLCJqdGkiOiIwNTY0YzlmZS02NGI2LTRiNzAtYWZiZS04YmZhMDk1Y2U3NjkifQ.kkjBAlvDdNQrWC_8DCp5pEbMDBdHSBpRsmEZEKUm16bwn_45cktl3eudhOp7OxptqwgAt19prQowdKL3W3Zenw";

            //string de la url del método de llamada
            //https://riews.reinfoempresa.com:8443/RIEWS/webapi/PrivateServices/articles1
            string request2 = urlPath + "/RIEWS/webapi/PrivateServices/authenticationLogInW";
            string miuser   = System.Convert.ToBase64String(System.Text.Encoding.UTF8.GetBytes(username));
            string mipass   = System.Convert.ToBase64String(System.Text.Encoding.UTF8.GetBytes(pass));
            //creamos un webRequest con el tipo de método.
            WebRequest webRequest = WebRequest.Create(request2);

            //definimos el tipo de webrequest al que llamaremos
            webRequest.Method = "POST";
            //definimos content\
            webRequest.ContentType = "application/json; charset=utf-8";
            //cargamos los datos a enviar
            using (var streamWriter = new StreamWriter(webRequest.GetRequestStream()))
            {
                //$formData = array(
                //          "codeidentifier"    => (string)$nIdentifier,
                //          "cant"          => (string)$nCant,
                //          "long"      => (string)$nLong,
                //          "width"         => (string)$nWidth,
                //          "thick"         => (string)$nThick,
                //          "token"         => unserializeObj($_SESSION["_ObjSession"])->ActualToken,
                //          "ipbase64"  => $_SESSION["_IpAddressSession"]
                //         );

                string json = "{\"tokensite\":\"" + SecretKey + "\",\"ipbase64\":\"" + laip + "\",\"username\":\"" + miuser + "\",\"password\":\"" + mipass + "\",\"language\":\"SPA\"}";
                streamWriter.Write(json.ToString());
                //"  "
            }
            //obtenemos la respuesta del servidor
            var httpResponse = (HttpWebResponse)webRequest.GetResponse();

            //leemos la respuesta y la tratamos
            using (var streamReader = new StreamReader(httpResponse.GetResponseStream()))
            {
                var result2 = streamReader.ReadToEnd();
                //traducimos el resultado
                // result = JsonSerializer.Deserialize<DataCollectionSingle<producto>>(result2);
                result = JsonConvert.DeserializeObject <sesion>(result2);
            }
            //
            //if (_area == null)
            //{
            //    _area = new resultList();
            //    _area.result = new List<result>();
            //    _area.result[0].areaname = "vacia";
            //}

            return(result);
        }
Esempio n. 2
0
        public string GetToken(string laip)
        {
            sesion     sesion     = new sesion();
            string     urlPath    = "https://riews.reinfoempresa.com:8443";
            string     request2   = urlPath + "/RIEWS/webapi/PublicServices/authenticationDefaultW";
            string     SecretKey  = "eyJhbGciOiJIUzUxMiJ9.eyJzdWIiOiJSZWN1cnNvcyBJbmZvcm3DoXRpY29zIEVtcHJlc2FyaWFsZXMsIFMuTC4iLCJpYXQiOjE1Nzc5NTgzNjYsImV4cCI6MTYwOTU4MDc2NywibmJmIjoxNTc3OTU4MzY2LCJpc3MiOiJhZHJpYW4iLCJlbnQiOiI0IiwiaW5zIjoiMSIsInVzYyI6IjMiLCJzbnUiOiI5OTk5LTg4ODgtMTEiLCJpcHMiOiJOVEV1TnpjdU1UTTNMakU0Tnc9PSIsImV4ZSI6IjExLjAuNSsxMC1wb3N0LVVidW50dS0wdWJ1bnR1MS4xMTguMDQiLCJsYW4iOiJzcGEiLCJqdGkiOiIwNTY0YzlmZS02NGI2LTRiNzAtYWZiZS04YmZhMDk1Y2U3NjkifQ.kkjBAlvDdNQrWC_8DCp5pEbMDBdHSBpRsmEZEKUm16bwn_45cktl3eudhOp7OxptqwgAt19prQowdKL3W3Zenw";
            WebRequest webRequest = WebRequest.Create(request2);

            //definimos el tipo de webrequest al que llamaremos
            webRequest.Method = "POST";
            //definimos content
            webRequest.ContentType = "application/json; charset=utf-8";
            //cargamos los datos a enviar
            using (var streamWriter = new StreamWriter(webRequest.GetRequestStream()))
            {
                string json = "{\"tokensite\":\"" + SecretKey /*System.Convert.ToBase64String(System.Text.Encoding.UTF8.GetBytes()) */ + "\"" +
                              ",\"ipbase64\":\"" + laip + "\",\"language\":\"SPA\"}";
                streamWriter.Write(json);
            }
            var httpResponse = (HttpWebResponse)webRequest.GetResponse();

            using (var streamReader = new StreamReader(httpResponse.GetResponseStream()))
            {
                var resultado = streamReader.ReadToEnd();
                sesion = JsonConvert.DeserializeObject <sesion>(resultado);
            }
            return(sesion.activeToken);
        }
Esempio n. 3
0
        public sesion GetPin(string laip, string token, string user)
        {
            var result = new sesion();

            //resultList _area;
            // string token = GetToken(laip).activeToken;
            //string de url principal
            string urlPath = "https://riews.reinfoempresa.com:8443";
            string usuario = "";
            //string de la url del método de llamada
            string request2 = urlPath + "/RIEWS/webapi/PrivateServices/getMyPinW";
            //creamos un webRequest con el tipo de método.
            WebRequest webRequest = WebRequest.Create(request2);

            //definimos el tipo de webrequest al que llamaremos
            webRequest.Method = "POST";
            //definimos content\
            webRequest.ContentType = "application/json; charset=utf-8";
            //cargamos los datos a enviar
            using (var streamWriter = new StreamWriter(webRequest.GetRequestStream()))
            {
                //$formData = array(
                //          "codeidentifier"    => (string)$nIdentifier,
                //          "cant"          => (string)$nCant,
                //          "long"      => (string)$nLong,
                //          "width"         => (string)$nWidth,
                //          "thick"         => (string)$nThick,
                //          "token"         => unserializeObj($_SESSION["_ObjSession"])->ActualToken,
                //          "ipbase64"  => $_SESSION["_IpAddressSession"]
                //         );

                string json = "{\"token\":\"" + token + "\",\"ipbase64\":\"" + laip + "\",\"user\":\"" + usuario + "\"}";
                streamWriter.Write(json.ToString());
                //"  "
            }
            //obtenemos la respuesta del servidor
            var httpResponse = (HttpWebResponse)webRequest.GetResponse();

            //leemos la respuesta y la tratamos
            using (var streamReader = new StreamReader(httpResponse.GetResponseStream()))
            {
                var result2 = streamReader.ReadToEnd();
                //traducimos el resultado
                // result = JsonSerializer.Deserialize<DataCollectionSingle<producto>>(result2);
                result = JsonConvert.DeserializeObject <sesion>(result2);
            }
            //
            //if (_area == null)
            //{
            //    _area = new resultList();
            //    _area.result = new List<result>();
            //    _area.result[0].areaname = "vacia";
            //}

            return(result);
        }
Esempio n. 4
0
        public void ordenarBotones(sesion sesionLogeo)
        {
            sesionActual = sesionLogeo;
            if (sesionActual.rol.rol_nombre.ToUpper() == "ADMINISTRADOR") //ADMINISTRADOR
            {
                btn_f6_registrarAgenda.Location      = new Point(16, 99);
                btn_f8_regLlegada.Location           = new Point(16, 156);
                btn_f11_generarEstadisticas.Location = new Point(16, 214);
                btn_f12_comprarBono.Location         = new Point(16, 268);
                pnlIzq.Visible             = true;
                pnlDer.Visible             = true;
                pnlIzq.Location            = new Point(11, 89);
                pnlIzq.Height              = 229;
                pnlIzq.Width               = 179;
                lbl_menuPrincipal.Location = new Point(300, -1);
                this.Height = 360;
                this.Width  = 876;
            }

            if (sesionActual.rol.rol_nombre.ToUpper() == "PROFESIONAL") //PROFESIONAL
            {
                btn_f5_cancelarAtencion.Location = new Point(112, 101);
                btn_f9_regResultado.Location     = new Point(112, 158);
                btn_f10_generarReceta.Location   = new Point(112, 216);
                lbl_menuPrincipal.Location       = new Point(28, -1);
                pnlIzq.Visible  = true;
                pnlIzq.Location = new Point(104, 89);
                pnlIzq.Width    = 179;
                pnlIzq.Height   = 179;
                this.Height     = 328;
                this.Width      = 399;
            }

            if (sesionActual.rol.rol_nombre.ToUpper() == "AFILIADO") //AFILIADO
            {
                btn_f5_cancelarAtencion.Location = new Point(112, 101);
                btn_f7_pedirTurno.Location       = new Point(112, 158);
                btn_f12_comprarBono.Location     = new Point(112, 216);
                lbl_menuPrincipal.Location       = new Point(28, -1);
                pnlIzq.Visible  = true;
                pnlIzq.Location = new Point(104, 89);
                pnlIzq.Width    = 179;
                pnlIzq.Height   = 179;
                this.Height     = 328;
                this.Width      = 399;
            }
            lblBienvenida.Text    = sesionActual.WelcomeMessage;
            lblBienvenida.Visible = true;
            this.CenterToScreen();
        }
        public IViewComponentResult Invoke()
        {
            //var categories = _categoryRepository.Query().Where(x => !x.IsDeleted && x.IncludeInMenu).ToList();

            //var categoryMenuItems = new List<CategoryMenuItem>();

            //var topCategories = categories.Where(x => !x.ParentId.HasValue).OrderByDescending(x => x.DisplayOrder);

            //foreach (var category in topCategories)
            //{
            //    var categoryMenuItem = Map(category);
            //    categoryMenuItems.Add(categoryMenuItem);
            //}
            //return View(this.GetViewPath(), categoryMenuItems);

            // cambios

            DataCollection <area> a = new DataCollection <area>();

            string ip = System.Convert.ToBase64String(System.Text.Encoding.UTF8.GetBytes(HttpContext.Features.Get <IHttpConnectionFeature>()?.RemoteIpAddress?.ToString()));

            _sesion = GetToken(ip, _sesion);
            if (_sesion != null)
            {
                HttpContext.Session.Set("id", System.Text.Encoding.UTF8.GetBytes(_sesion.activeToken));
            }
            ISession sesion1 = HttpContext.Session;

            if (_sesion != null && _sesion.explained.ToString() != "Session NOT authorized")
            {
                a = areas(ip, sesion1.GetString("id")).Result;
            }

            var categoryMenuItems2 = new List <CategoryMenuItem>();

            foreach (area ar in a.result)
            {
                var cmi = Map(ar);
                categoryMenuItems2.Add(cmi);
            }
            return(View(this.GetViewPath(), categoryMenuItems2));

            //   fin cambios
        }
Esempio n. 6
0
        public IHttpActionResult Login(usuario usuario)
        {
            string  result = AES256.encryptPassword(usuario.password);
            usuario user   = db.usuarios.FirstOrDefault(u => u.correo == usuario.correo && u.password == result);

            if (user == null)
            {
                return(NotFound());
            }
            user.rol = db.rols.Find(user.id_rol);
            db.Entry(user.rol).Collection(p => p.permisos).Load();
            sesion sesion = new sesion();

            sesion.fecha      = DateTime.Now;
            sesion.id_usuario = user.id_usuario;
            db.sesions.Add(sesion);
            Bitacora.getInstance().addBitacora(BitacoraActions.SIGN_IN, user.id_usuario);
            db.SaveChanges();
            return(Ok(user));
        }
Esempio n. 7
0
 partial void Deletesesion(sesion instance);
Esempio n. 8
0
 partial void Updatesesion(sesion instance);
Esempio n. 9
0
 partial void Insertsesion(sesion instance);