Exemple #1
0
        public ActionResult Register(Models.ViewModels.RegisterViewModel model)
        {
            try
            {
                if (!ModelState.IsValid)
                {
                    //REGRESO as LA  VISTA
                    return(View(model));
                }

                UtilitiesChat.Models.WS.Reply oReply = new Reply();
                Models.Request.User           oUser  = new Models.Request.User();
                oUser.Name     = model.Name;
                oUser.City     = model.City;
                oUser.Email    = model.Email;
                oUser.Password = model.Password;

                RequestUtil oRequestUtil = new RequestUtil();
                oReply = oRequestUtil.Execute <Models.Request.User>(Constants.Url.REGISTER, "post", oUser);

                return(RedirectToAction("Index", "Home"));
            }
            catch (Exception ex)
            {
                throw;
            }
        }
Exemple #2
0
        public ActionResult Login(UserAccessViewModel model)
        {
            if (!ModelState.IsValid)
            {
                //REGRESO as LA  VISTA
                return(View(model));
            }

            Reply         oReply = new Reply();
            AccessRequest oAR    = new AccessRequest();

            oAR.Email    = model.Email;
            oAR.Password = UtilitiesChat.Tools.Encrypt.GetSHA256(model.Password);



            RequestUtil oRequestUtil = new RequestUtil();

            oReply = oRequestUtil.Execute <AccessRequest>(Constants.Url.ACESS, "post", oAR);
            JavaScriptSerializer js = new JavaScriptSerializer();

            UtilitiesChat.Models.WS.UserResponse oUserResponse = js.Deserialize <UtilitiesChat.Models.WS.UserResponse>(js.Serialize(oReply.data));
            if (oReply.result == 1)
            {
                Session["User"] = oUserResponse;
                return(RedirectToAction("Index", "Lobby"));
            }

            //mandar error
            ViewBag.error = "Datos Incorrectos";
            return(View(model));
        }
Exemple #3
0
        private void GetDataInit()
        {
            List <ListRoomResponse> lst = new List <ListRoomResponse>();

            //oUserSession

            SecurityRequest oSecurityRequest = new SecurityRequest();

            oSecurityRequest.AccessToken = Session.oUser.AccessToken;
            Reply       oReply       = new Reply();
            RequestUtil oRequestUtil = new RequestUtil();

            oReply = oRequestUtil.Execute <SecurityRequest>(Constants.Url.Rooms, "post", oSecurityRequest);
            JavaScriptSerializer js = new JavaScriptSerializer();

            lst = js.Deserialize <List <ListRoomResponse> >(js.Serialize(oReply.data));

            cboRooms.DataSource    = lst;
            cboRooms.DisplayMember = "Name";
            cboRooms.ValueMember   = "id";
            cboRooms.Refresh();

            //obtener mensajes del chat
            GetMessages();
        }
Exemple #4
0
        public ActionResult Login(UserAccessViewModel model)
        {
            if (!ModelState.IsValid)
            {
                return(View(model));
            }

            AccessRequest oAR = new AccessRequest();

            oAR.Email    = model.Email;
            oAR.Password = UtilitiesChat.Tools.Encrypt.GetSHA256(model.Password);

            RequestUtil oRequestUtil = new RequestUtil();

            UtilitiesChat.Models.WS.Reply oReply =
                oRequestUtil.Execute <AccessRequest>(Constants.Url.ACCESS, "Post", oAR);

            UtilitiesChat.Models.WS.UserResponse oUserResponse =
                JsonConvert.DeserializeObject <UtilitiesChat.Models.WS.UserResponse>(JsonConvert.SerializeObject(oReply.data));

            if (oReply.result == 1)
            {
                Session["User"] = oUserResponse;
                return(RedirectToAction("Index", "Lobby"));
            }

            ViewBag.error = "Datos incorrectos";

            return(View());
        }
        public ActionResult Register(RegisterViewModel model)
        {
            if (!ModelState.IsValid)
            {
                return(View(model));
            }
            User user = new User
            {
                NickName = model.NickName
            };

            RequestUtil request = new RequestUtil();

            Reply response     = request.Execute <User>(AppSettings.Url.REGISTER, "post", user);
            var   userResponse = JsonConvert.DeserializeObject <User>(JsonConvert.SerializeObject(response.Data));

            if (response.Result == 1)
            {
                Session["User"] = userResponse;

                return(RedirectToAction("Index", "Lobby"));
            }

            ViewBag.error = response.Message;

            return(View(model));
        }
Exemple #6
0
        public T Execute()
        {
            RequestUtil request = RequestUtil.NewInstance(Globals.TRADINGPOST_HOST, APIPath);

            request.SetMethod(APIMethod);

            foreach (KeyValuePair <string, string> parameter in APIParameters)
            {
                request.SetParameter(parameter.Key, parameter.Value);
            }

            SessionManager sm = SessionManager.GetInstance();
            Session        s  = (RequiresGameSession ? sm.GameSession : sm.Session);

            request.SetCookie("s", s.Key);

            T response = null;

            // don't let simultaneous requests happen
            lock (this)
            {
                TimeSpan span = DateTime.Now - m_LAST_EXEC;
                int      wait = MILLI_BETWEEN_EXEC.Value;
                if (span.TotalMilliseconds < wait)
                {
                    Thread.Sleep(wait - (int)span.TotalMilliseconds);
                }

                response = request.Execute <T>();

                m_LAST_EXEC = DateTime.Now;
            }

            return(response);
        }
Exemple #7
0
        public ActionResult Messages(int id)
        {
            GetSession();

            List <MessagesResponse> lst = new List <MessagesResponse>();

            MessagesRequest oMessagesRequest = new MessagesRequest();

            oMessagesRequest.AccessToken = oUserSession.AccessToken;
            oMessagesRequest.IdRoom      = id;

            RequestUtil oRequestUtil = new RequestUtil();

            UtilitiesChat.Models.WS.Reply oReply =
                oRequestUtil.Execute <MessagesRequest>(Constants.Url.MESSAGES, "post", oMessagesRequest);

            lst =
                JsonConvert.DeserializeObject <List <MessagesResponse> >(JsonConvert.SerializeObject(oReply.data));

            lst = lst.OrderBy(d => d.DateCreated).ToList();

            ViewBag.idRoom = id;

            return(View(lst));
        }
Exemple #8
0
        private void button1_Click(object sender, EventArgs e)
        {
            if (txtUser.Text.Equals("") || txtPass.Text.Equals(""))
            {
                MessageBox.Show("Los dos campos son obligatorios");
                return;
            }

            Reply         oReply = new Reply();
            AccessRequest oAR    = new AccessRequest();

            oAR.Email    = txtUser.Text.Trim();
            oAR.Password = UtilitiesChat.Tools.Encrypt.GetSHA256(txtPass.Text.Trim());



            RequestUtil oRequestUtil = new RequestUtil();

            oReply = oRequestUtil.Execute <AccessRequest>(Constants.Url.ACESS, "post", oAR);
            JavaScriptSerializer js = new JavaScriptSerializer();

            if (oReply.result == 1)
            {
                Business.Session.oUser = js.Deserialize <UtilitiesChat.Models.WS.UserResponse>(js.Serialize(oReply.data));

                this.Close();

                MessageBox.Show("Inicio sesion");
            }
            else
            {
                MessageBox.Show(oReply.message);
            }
        }
Exemple #9
0
        public ActionResult Index()
        {
            RequestUtil request = new RequestUtil();

            List <Room> rooms = new List <Room>();

            Reply response = request.Execute <Reply>(AppSettings.Url.ROOMS, "get", null);

            rooms = JsonConvert.DeserializeObject <List <Room> >(JsonConvert.SerializeObject(response.Data));

            ViewBag.error = response.Message;

            return(View(rooms));
        }
        public ActionResult Index()
        {
            this.GetSession();

            List <ListContadoresResponse> list = new List <ListContadoresResponse>();
            SecurityRequest oSecurityRequest   = new SecurityRequest();

            oSecurityRequest.Token = oUserSession.accessToken;

            RequestUtil oRequestUtil = new RequestUtil();
            Reply       oR           = oRequestUtil.Execute <SecurityRequest>(Constants.Url.CONTADORES, "post", oSecurityRequest);

            list = JsonConvert.DeserializeObject <List <ListContadoresResponse> >(JsonConvert.SerializeObject(oR.data));


            return(View(list));
        }
Exemple #11
0
        public ActionResult Register(RegisterViewModel model)
        {
            if (!ModelState.IsValid)
            {
                return(View(model));
            }
            Models.Request.User oUser = new Models.Request.User();
            oUser.Name     = model.Name;
            oUser.Email    = model.Email;
            oUser.City     = model.City;
            oUser.Password = model.Password;

            RequestUtil oRequestUtil = new RequestUtil();

            Reply oReply = oRequestUtil.Execute <Models.Request.User>(Constants.Url.REGISTER, "post", oUser);

            return(View());
        }
Exemple #12
0
        // GET: Lobby
        public ActionResult Index()
        {
            GetSession();

            List <ListRoomsResponse> lst = new List <ListRoomsResponse>();

            SecurityRequest oSecurityRequest = new SecurityRequest();

            oSecurityRequest.AccessToken = oUserSession.AccessToken;

            RequestUtil oRequestUtil = new RequestUtil();

            Reply oReply = oRequestUtil.Execute <SecurityRequest>(Constants.Url.ROOMS, "post", oSecurityRequest);

            lst = JsonConvert.DeserializeObject <List <ListRoomsResponse> >(JsonConvert.SerializeObject(oReply.data));

            return(View(lst));
        }
Exemple #13
0
        public ActionResult Register(ChatWeb.Models.ViewModels.RegisterViewModel model)
        {
            //Valida si algun DataAnnotation ingresado no se cumple
            if (!ModelState.IsValid)
            {
                return(View(model));
            }
            Models.Request.User oUser = new Models.Request.User();
            oUser.Name     = model.Name;
            oUser.City     = model.City;
            oUser.Email    = model.Email;
            oUser.Password = model.Password;

            RequestUtil oRequestUtil = new RequestUtil();

            UtilitiesChat.Models.WS.Reply oReply = oRequestUtil.Execute <Models.Request.User>(Constants.Url.REGISTER, "post", oUser);

            return(View());
        }
Exemple #14
0
        // GET: Lobby
        public ActionResult Index()
        {
            GetSession();
            List <ListRoomResponse> lst = new List <ListRoomResponse>();

            //oUserSession

            SecurityRequest oSecurityRequest = new SecurityRequest();

            oSecurityRequest.AccessToken = oUserSession.AccessToken;
            Reply       oReply       = new Reply();
            RequestUtil oRequestUtil = new RequestUtil();

            oReply = oRequestUtil.Execute <SecurityRequest>(Constants.Url.Rooms, "post", oSecurityRequest);
            JavaScriptSerializer js = new JavaScriptSerializer();

            lst = js.Deserialize <List <ListRoomResponse> >(js.Serialize(oReply.data));

            return(View(lst));
        }
Exemple #15
0
        public ActionResult Messages(int id, int?idUser)
        {
            List <MessageResponse> messages = new List <MessageResponse>();

            MessageRequest messageRequest = new MessageRequest();

            messageRequest.IdRoom = id;
            messageRequest.IdUser = idUser ?? 0;

            RequestUtil request = new RequestUtil();
            Reply       reply   = request.Execute <MessageRequest>(AppSettings.Url.MESSAGES, "post", messageRequest);

            messages = JsonConvert.DeserializeObject <List <MessageResponse> >(JsonConvert.SerializeObject(reply.Data));

            messages = messages.OrderBy(d => d.DateCreated).ToList();

            ViewBag.idRoom = id;

            return(View(messages));
        }
Exemple #16
0
        private void GetMessages()
        {
            int idRoom = 0;

            //posYFinal = 10;
            panelMessages.Controls.Clear();
            lastPanel = null;
            try
            {
                idRoom = (int)cboRooms.SelectedValue;
            }
            catch (Exception ex)
            {
                // throw;
            }


            if (idRoom > 0)
            {
                List <MessagesResponse> lst = new List <MessagesResponse>();

                MessagesRequest oMessagesRequest = new MessagesRequest();
                oMessagesRequest.AccessToken = Business.Session.oUser.AccessToken;
                oMessagesRequest.idRoom      = idRoom;

                Reply oReply = new Reply();

                RequestUtil oRequestUtil = new RequestUtil();

                oReply = oRequestUtil.Execute <SecurityRequest>(Constants.Url.Messages, "post", oMessagesRequest);
                JavaScriptSerializer js = new JavaScriptSerializer();
                lst = js.Deserialize <List <MessagesResponse> >(js.Serialize(oReply.data));
                lst = lst.OrderBy(d => d.DateCreated).ToList();


                foreach (MessagesResponse oMessage in lst)
                {
                    AddMessage(oMessage);
                }
            }
        }
Exemple #17
0
        // GET: Chat
        public ActionResult Messages(int id)
        {
            GetSession();
            List <MessagesResponse> lst = new List <MessagesResponse>();

            MessagesRequest oMessagesRequest = new MessagesRequest();

            oMessagesRequest.AccessToken = oUserSession.AccessToken;
            oMessagesRequest.idRoom      = id;

            Reply oReply = new Reply();

            RequestUtil oRequestUtil = new RequestUtil();

            oReply = oRequestUtil.Execute <SecurityRequest>(Constants.Url.Messages, "post", oMessagesRequest);
            JavaScriptSerializer js = new JavaScriptSerializer();

            lst            = js.Deserialize <List <MessagesResponse> >(js.Serialize(oReply.data));
            lst            = lst.OrderBy(d => d.DateCreated).ToList();
            ViewBag.IdRoom = id;
            return(View(lst));
        }
Exemple #18
0
        public MainWindow()
        {
            InitializeComponent();

            string         html;
            SessionManager sm = SessionManager.GetInstance();

            sm.Email    = ""; // set email before running
            sm.Password = ""; // set password before running

            RequestUtil request = RequestUtil.NewInstance("https://leaderboards.guildwars2.com", "/en/na/achievements/guild/Guíld%20Of%20Dívíne%20Soldíers");

            request.SetMethod(Method.GET);
            request.SetCookie("s", sm.Session.Key);
            IRestResponse r = request.Execute();

            html = r.Content;

            List <user> l = ParseUserPage(html);

            TextArea.FontFamily = new FontFamily("Courier New");
            TextArea.Text       = string.Format("{0,-20} | {1,-6} | {2,-20} | {3}\n{4}", "User", "AP", "World", "Last Earned AP",
                                                string.Join("\n", l.Select(u => string.Format("{0,-20} | {1,6} | {2,-20} | {3}", u.account, u.ap, u.world, u.lastapgain))));
        }