Example #1
0
        static void Main(string[] args)
        {
            using (SqlConnection connection = new SqlConnection(@"Integrated Security=SSPI;Persist Security Info=False;Initial Catalog=friends;Data Source=.\sqlexpress2005"))
            {
                using (SqlCommand command = new SqlCommand("addFriends", connection) { CommandType = CommandType.StoredProcedure })
                {
                    friends f = new friends();
                    f.Items = new friendsFriend[]
                    {
                        new friendsFriend
                        {
                            firstname = "Julie",
                            lastname = "Truter"
                        },
                        new friendsFriend
                        {
                            firstname = "Roland",
                            lastname = "Cooper"
                        }
                    };

                    StringWriter sw = new StringWriter();
                    XmlSerializer xml = new XmlSerializer(typeof(friends));
                    xml.Serialize(sw, f);

                    connection.Open();
                    command.Parameters.Add("@friends", SqlDbType.Xml).Value = sw.ToString();
                    command.ExecuteNonQuery();
                }
            }
        }
Example #2
0
        //отображает список друзей
        public void LoadFriendsList()
        {
            listFriendsShow.Items.Clear();
            List <FriendUnit> list = MainWindow.vk1.GetFriendsList();

            for (int i = 0; i < list.Count; i++)
            {
                friends a1 = new friends(list[i].getIdFriend(), list[i].getFIOFriend());
                listFriendsShow.Items.Add(a1);
            }
        }
Example #3
0
        public int addFriend(string userId, friends friend)
        {
            int result = 0;

            friend.user_id = getUserIdByFriendId(friend.friend_id);
            if (!string.IsNullOrEmpty(friend.user_id))
            {
                result = _friendRespository.addFriend(userId, friend);
            }
            return(result);
        }
Example #4
0
        public int addFriend(string userId, friends friend)
        {
            using (IDbConnection con = Connection)
            {
                int rowId = 0;
                con.Open();
                var query = @"INSERT INTO friends(user_id, friend_id, nickname)
                            VALUES(@userId, @user_id, @nickname); " + "select LAST_INSERT_ID();";
                rowId = con.Execute(query, new { userId, friend.user_id, friend.nickname });

                return(rowId);
            }
        }
    protected void Repeater1_ItemCommand(object source, RepeaterCommandEventArgs e)
    {
        if (e.CommandName == "del")
        {
            using (var db = new CstwebEntities())
            {
                int     id  = Convert.ToInt32(e.CommandArgument);
                friends tea = db.friends.FirstOrDefault(a => a.id == id);

                db.friends.Remove(tea);

                db.SaveChanges();
                Response.Write("<script>alert('删除成功');window.location = 'friendslist.aspx';</script>");
            }
        }
    }
Example #6
0
        public ActionResult Mesajlar()
        {
            // arkadaşları listele
            // ve mesaj gönder
            string email = null;

            if (Session["mail"] == null)
            {
                email = Request.Cookies["mail"].Value;
            }
            else
            {
                email = Session["mail"].ToString();
            }

            GoodChatEntities7 entities7 = new GoodChatEntities7();
            var Context     = entities7.Account.Where(e => e.mail == email).FirstOrDefault();
            var ContextiD   = Context.user_id;
            var ContextName = Context.user_name;


            ViewBag.name = ContextName;


            Account account        = new Account();
            friends friends        = new friends();
            var     innerJoinQuery = (from Account in entities7.Account
                                      join sup in entities7.friends
                                      on account.user_id equals sup.Userid
                                      where account.user_id == ContextiD
                                      select new
            {
                proid = friends.fid,
            }).ToList();



            foreach (var item in innerJoinQuery)
            {
                ViewBag.friend = item.ToString();
                Response.Write(item.ToString());
            }


            return(View());
        }
        private void CreateFriend(friends friend)
        {
            // Create this friendship
            NameValueCollection requestArgs = new NameValueCollection
            {
                { "RequestMethod", "AddGeneric" },
                { "OwnerID", friend.PrincipalID },
                { "Type", "Friend" },
                { "Key", friend.Friend },
                { "Value", friend.Flags }
            };
            // TODO: Is friend.Offered used at all?

            OSDMap response = WebUtil.PostToService(m_userUrl, requestArgs);
            bool   success  = response["Success"].AsBoolean();

            if (!success)
            {
                Console.WriteLine("Failed to store friend " + friend.Friend + " for user " + friend.PrincipalID + ": " + response["Message"].AsString());
            }
        }
Example #8
0
    //获取听众
    protected void Unnamed1_Click(object sender, EventArgs e)
    {
        GetAccessToken(appKey, appSecret, tokenKey, tokenSecret, Session["Verify"].ToString());

        accessKey    = tokenKey;
        accessSecret = tokenSecret;

        OauthKey oauthKey = new OauthKey();

        oauthKey.customKey    = appKey;
        oauthKey.customSecret = appSecret;
        oauthKey.tokenKey     = accessKey;
        oauthKey.tokenSecret  = accessSecret;

        friends friends = new friends(oauthKey, "json");
        string  data    = friends.fanslist(10, 0);

        Audience weibo = YK.Common.JsonHelper.ParseFormByJson <Audience>(data);

        GridView1.DataSource = weibo.data.info;
        GridView1.DataBind();
    }
Example #9
0
 static void friend(friends name)
 {
     if (friends.Adil == name)
     {
         Console.WriteLine("\n Sergio Adil Dulobo");
     }
     else if (friends.Camoes == name)
     {
         Console.WriteLine("\n Manuel Camoes");
     }
     else if (friends.Edson == name)
     {
         Console.WriteLine("\n Edson Iranchadi");
     }
     else if (friends.Yula == name)
     {
         Console.WriteLine("\n Yula Guivala");
     }
     else
     {
         Console.WriteLine("\n Not recognised");
     }
 }
Example #10
0
        public void Handler132_type_124()
        {
            //³ƒ³,1³,5208175³ -> Al que acepta la peticion
            //„³|³,ID³,NOMBRE³,BOCATA³,PERSON³,COLOR_HEX³,AGE³,CIUDAD³,³,1³,ONLINE³,³ -> Al que ha mandado la peticion
            //³ƒ³,-2³,322268³ -> Lleno

            int     id_amigo = int.Parse(Message.getParameter());
            friends amigos   = new friends(id_amigo, mUser.id, 0);

            Environment.Game.bpad.aceptar_amigo(mUser.id, id_amigo);
            long session = Environment.sessions.GetSessionFromUser(id_amigo);

            if (session != -1)
            {
                Environment.sessions.GetSession(session).SendMessage("„³|³²" + mUser.id + "³²" + mUser.usuario + "³²" + mUser.bocadillo + "³²" + mUser.tipo_avatar + "³²" + mUser.colores_avatar + "³²" + mUser.edad + "³²" + mUser.ciudad + "³²³²1³²0³²³²");
            }

            userInfo nUser = Environment.Game.User.getUser(id_amigo);

            server message = new server("„³ƒ³²1");

            message.Append("³²" + nUser.id + "³²");
            SendMessage(message);
        }
Example #11
0
    protected void BtnSubmit_Click(object sender, EventArgs e)
    {
        if (Txtname.Text.Trim() == "")
        {
            Response.Write("<script>alert('姓名不能为空')</script>");
        }
        else if (TxtMail.Text.Trim() == "")
        {
            Response.Write("<script>alert('邮箱不能为空')</script>");
        }
        else if (TxtWork.Text.Trim() == "")
        {
            Response.Write("<script>alert('工作单位不能为空')</script>");
        }

        else if (TxtBirth.Text.Trim() == "")
        {
            Response.Write("<script>alert('出生年月不能为空')</script>");
        }
        else if (TxtPhone.Text.Trim() == "")
        {
            Response.Write("<script>alert('联系电话不能为空')</script>");
        }

        else
        {
            using (var db = new CstwebEntities())
            {
                try
                {
                    if (teaid == 0)
                    {
                        var tea = new friends();
                        tea.fname = Txtname.Text.Trim();
                        tea.email = TxtMail.Text.Trim();
                        tea.photo = ImgIco.ImageUrl.ToString();
                        tea.phone = TxtPhone.Text.Trim();
                        int sex = Convert.ToInt32(DdlSex.SelectedValue);
                        tea.sex       = sex;
                        tea.birth     = TxtBirth.Text.Trim();
                        tea.workplace = TxtWork.Text.Trim();

                        string tempstr = Server.HtmlDecode(myEditor.InnerHtml);
                        if (tempstr != "")
                        {
                            tea.ect = tempstr;
                        }
                        db.friends.Add(tea);
                        db.SaveChanges();

                        Response.Write("<script language=javascript>alert('添加成功');window.location = 'friendslist.aspx';</script>");
                    }
                    else
                    {
                        friends tea = db.friends.First <friends>(a => a.id == teaid);
                        tea.fname = Txtname.Text.Trim();
                        tea.email = TxtMail.Text.Trim();
                        tea.photo = ImgIco.ImageUrl.ToString();
                        tea.phone = TxtPhone.Text.Trim();
                        int sex = Convert.ToInt32(DdlSex.SelectedValue);
                        tea.sex       = sex;
                        tea.birth     = TxtBirth.Text.Trim();
                        tea.workplace = TxtWork.Text.Trim();

                        string tempstr = Server.HtmlDecode(myEditor.InnerHtml);
                        if (tempstr != "")
                        {
                            tea.ect = tempstr;
                        }

                        db.SaveChanges();
                        Response.Write("<script language=javascript>alert('修改成功');window.location = 'friendslist.aspx';</script>");
                    }
                }
                catch
                {
                    Response.Write("<script>alert('失败')</script>");
                }
            }
        }
    }
    protected void BtnSubmit_Click(object sender, EventArgs e)
    {
        if (Txtname.Text.Trim() == "") Response.Write("<script>alert('姓名不能为空')</script>");
        else if (TxtMail.Text.Trim() == "") Response.Write("<script>alert('邮箱不能为空')</script>");
        else if (TxtWork.Text.Trim() == "") Response.Write("<script>alert('工作单位不能为空')</script>");
        
        else if (TxtBirth.Text.Trim() == "") Response.Write("<script>alert('出生年月不能为空')</script>");
        else if (TxtPhone.Text.Trim() == "") Response.Write("<script>alert('联系电话不能为空')</script>");
      
        else
            using (var db = new CstwebEntities())
            {
                try
                {
                    if (teaid == 0)
                    {
                        var tea = new friends();
                        tea.fname = Txtname.Text.Trim();
                        tea.email = TxtMail.Text.Trim();
                        tea.photo = ImgIco.ImageUrl.ToString();
                        tea.phone = TxtPhone.Text.Trim();
                        int sex = Convert.ToInt32(DdlSex.SelectedValue);
                        tea.sex = sex;
                        tea.birth = TxtBirth.Text.Trim();
                        tea.workplace = TxtWork.Text.Trim();
                        
                        string tempstr = Server.HtmlDecode(myEditor.InnerHtml);
                        if (tempstr != "") tea.ect = tempstr;
                        db.friends.Add(tea);
                        db.SaveChanges();
                        
                        Response.Write("<script language=javascript>alert('添加成功');window.location = 'friendslist.aspx';</script>");

                    }
                    else
                    {
                        friends tea = db.friends.First<friends>(a => a.id == teaid);
                        tea.fname = Txtname.Text.Trim();
                        tea.email = TxtMail.Text.Trim();
                        tea.photo = ImgIco.ImageUrl.ToString();
                        tea.phone = TxtPhone.Text.Trim();
                        int sex = Convert.ToInt32(DdlSex.SelectedValue);
                        tea.sex = sex;
                        tea.birth = TxtBirth.Text.Trim();
                        tea.workplace = TxtWork.Text.Trim();
                        
                        string tempstr = Server.HtmlDecode(myEditor.InnerHtml);
                        if (tempstr != "") tea.ect = tempstr;

                        db.SaveChanges();
                        Response.Write("<script language=javascript>alert('修改成功');window.location = 'friendslist.aspx';</script>");
                    }


                }
                catch
                {
                    Response.Write("<script>alert('失败')</script>");
                }

            }
    }
        public IHttpActionResult AddFriend(mytarget ta)
        {
            string  target = ta.target;
            results res    = new results();

            using (var db = new oucfreetalkEntities())
            {
                var dlist = (from it in db.students
                             where it.id == target
                             select it).ToList();
                if (dlist.Count == 0)
                {
                    res.result = 4;
                    return(Ok(res));
                }
            }

            string userid = "";

            try
            {
                userid = HttpContext.Current.Session["sid"].ToString();
                if (userid == "")
                {
                    res.result = 0;
                    return(Ok(res));
                }
            }
            catch
            {
                res.result = 0;
                return(Ok(res));
            }//未登录

            if (userid == target)
            {
                res.result = 5;//同名错误
                return(Ok(res));
            }

            try
            {
                using (var db = new oucfreetalkEntities())
                {
                    var search = (from it in db.friends
                                  where it.focus == userid && it.befocus == target
                                  select it).ToList();
                    if (search.Count != 0)
                    {
                        res.result = 2;//已存在
                        return(Ok(res));
                    }
                    else
                    {
                        friends fd = new friends();
                        fd.focus      = userid;
                        fd.befocus    = target;
                        fd.createtime = DateTime.Now;
                        db.friends.Add(fd);
                        if (db.SaveChanges() == 0)
                        {
                            res.result = 3;//失败
                            return(Ok(res));
                        }
                        else
                        {
                            res.result = 1;//成功
                            return(Ok(res));
                        }
                    }
                }
            }
            catch
            {
                res.result = 3;//服务器错误
                return(Ok(res));
            }
        }