Example #1
0
        private HttpCookie userInfoCookie()
        {
            HttpCookie userCookie = new HttpCookie("userCookie");
            IvleUserInfo userInfo = new IvleUserInfo();

            userCookie.Values["username"] = userInfo.getUserName();
            userCookie.Values["userID"] = userInfo.getUserID();
            userCookie.Values["userEmail"] = userInfo.getUserEmail();
            userCookie.Expires = DateTime.Now.AddDays(1);
            //userCookie.Expires = DateTime.Now.AddSeconds(2);

            return userCookie;
        }
Example #2
0
        public void addFriendToSql()
        {
            HelperClasses.IvleUserInfo userInfo = new HelperClasses.IvleUserInfo();

            string url = HttpContext.Current.Request.RawUrl;

            string userName = userInfo.getUserName();
            string userID = userInfo.getUserID();
            string friendID = "";
            string friendName = "";
            if (url.IndexOf('?') > -1)
            {
                int idIndex = url.IndexOf("id=");
                int nameIndex = url.IndexOf("name=");

                friendID = url.Substring(idIndex + 3, 8);
                friendID = friendID.ToLower();
                friendName = url.Substring(nameIndex + 5);

                friendName = friendName.Replace("%20", " ");
                friendName = System.Threading.Thread.CurrentThread.CurrentCulture.TextInfo.ToTitleCase(friendName.ToLower());
                //Response.Redirect(Request.Url.AbsoluteUri);

                try
                {
                    Boolean notFriend = true;

                    SqlWrapper _SqlWrapper = new SqlWrapper(@"Server=tcp:yq6ulqknjf.database.windows.net,1433;Database=ModulesDB;User ID=rstyle@yq6ulqknjf;Password=Zxcv2345;Trusted_Connection=False;Encrypt=True;Connection Timeout=30;");
                    DataTable _DataTable = _SqlWrapper.executeQuery(@"SELECT friendID FROM friendList");
                    String htmlCode = String.Empty;

                    foreach (DataRow _DataRow in _DataTable.Rows)
                    {
                        if (_DataRow["friendID"].ToString() == friendID)
                        {
                            notFriend = false;
                            break;
                        }

                    }

                    if(friendID == userID)
                    {
                        notFriend = false;
                    }

                    if (notFriend == true)
                    {

                        SqlConnection conn = new SqlConnection();

                        conn.ConnectionString = @"Server=tcp:yq6ulqknjf.database.windows.net,1433;Database=ModulesDB;User ID=rstyle@yq6ulqknjf;Password=Zxcv2345;Trusted_Connection=False;Encrypt=True;Connection Timeout=30;";

                        conn.Open();

                        string insert = "INSERT into FriendList(userID,userName,friendID,friendName, isFriend, isAck, isAccepted) " + " VALUES ('" + userID + "', '" + userName + "', '" + friendID + "', '" + friendName + "','False','False','False')"
                            + "INSERT into FriendList(userID,userName,friendID,friendName, isFriend, isAck, isAccepted) " + " VALUES ('" + friendID + "', '" + friendName + "', '" + userID + "', '" + userName + "','False','False','False');";
                        SqlCommand cmd = new SqlCommand(insert, conn);

                        cmd.ExecuteNonQuery();

                        conn.Close();
                        Response.Redirect("Friend.aspx");
                    }
                }
                catch { }
            }
        }