Ejemplo n.º 1
0
        public void SaveCategory()
        {
            int    friendId          = ctx.PostInt("friendId");
            int    categoryId        = ctx.PostInt("categoryId");
            String friendDescription = strUtil.CutString(ctx.Post("friendDescription"), 250);

            if (categoryId <= 0)
            {
                echoError("请选择分类或创建新的分类");
                return;
            }

            friendService.UpdateCategory(ctx.owner.Id, friendId, categoryId, friendDescription);

            FriendCategory f = db.findById <FriendCategory>(categoryId);

            Dictionary <String, Object> dic = new Dictionary <string, object>();

            dic.Add("Id", f.Id);
            dic.Add("FriendId", friendId);
            dic.Add("Name", f.Name);
            dic.Add("Description", friendDescription);
            dic.Add("IsValid", true);

            echoJson(dic);
        }
Ejemplo n.º 2
0
        private void bindFriendList(DataPage <FriendShip> list, int userId)
        {
            IBlock            block   = getBlock("list");
            List <FriendShip> friends = list.Results;

            List <FriendCategory> cats = FriendCategory.GetByOwner(userId);

            foreach (FriendShip ship in friends)
            {
                if (ship.User == null || ship.Friend == null)
                {
                    continue;
                }

                User           friend;
                FriendCategory category;
                String         description;

                if (ship.User.Id == userId)
                {
                    friend      = ship.Friend;
                    category    = getCategory(cats, ship.CategoryId);
                    description = ship.Description;
                }
                else
                {
                    friend      = ship.User;
                    category    = getCategory(cats, ship.CategoryIdFriend);
                    description = ship.DescriptionFriend;
                }

                String HideClass = "";
                if (friend.Id <= 0)
                {
                    HideClass = "hide";
                }

                block.Set("m.HideClass", HideClass);

                block.Set("m.Id", friend.RealId);
                block.Set("m.Name", friend.Name);

                block.Set("m.FaceFull", friend.PicMedium);
                block.Set("m.UrlFull", toUser(friend));
                block.Set("m.DeleteUrl", to(Delete, friend.RealId));
                block.Set("m.DeleteFollowingLink", to(DeleteFollowing, friend.RealId));

                block.Set("m.CreateTime", friend.Created);
                block.Set("m.LastLoginTime", friend.LastLoginTime);

                block.Set("m.CategoryName", category == null ? lang("none") : category.Name);
                block.Set("m.CategoryId", category == null ? 0 : category.Id);

                block.Set("m.Description", description);

                block.Next();
            }
            set("page", list.PageBar);
        }
Ejemplo n.º 3
0
        private void bindFriends(DataPage <FriendShip> list)
        {
            bindFriendList(list, ctx.owner.Id);

            // 修改类别
            List <FriendCategory> categories = FriendCategory.GetByOwner(ctx.owner.Id);

            dropList("FriendCategory", categories, "Name=Id", 0);
            set("saveCategoryLink", to(SaveCategory));
            set("categoryLink", to(new FriendCategoryController().List));
        }
Ejemplo n.º 4
0
        public override void Layout()
        {
            set("f.AddLink", to(Add));
            set("categoryLink", to(new FriendCategoryController().List));
            set("allLink", to(List, 0));
            set("blacklistLink", to(new BlacklistController().Index));

            List <FriendCategory> categories = FriendCategory.GetByOwner(ctx.owner.Id);

            bindCategories(categories);
        }
Ejemplo n.º 5
0
        public void List(int categoryId)
        {
            DataPage <FriendShip> list = friendService.GetPageByCategory(ctx.owner.Id, categoryId, 20);

            bindFriendList(list, ctx.owner.Id);

            // 修改类别
            List <FriendCategory> categories = FriendCategory.GetByOwner(ctx.owner.Id);

            dropList("FriendCategory", categories, "Name=Id", 0);
            set("saveCategoryLink", to(SaveCategory));
            set("categoryLink", to(new FriendCategoryController().List));
        }
Ejemplo n.º 6
0
        /// <summary>
        ///     查询列表。
        /// </summary>
        /// <returns></returns>
        internal List <T> GetListOf <T>() where T : class, IListable
        {
            if (Status != ClientStatus.Active)
            {
                throw new InvalidOperationException("尚未登录,无法进行该操作");
            }
            List <T> tempData;

            if (_cache.GetCache <List <T> >().TryGetValue(out tempData))
            {
                Logger.Debug("加载了缓存的" + typeof(T).Name + "列表");
                return(tempData);
            }
            // 为了性能所以不使用reflection而采用硬编码
            List <T> result;

            switch (typeof(T).Name)
            {
            case "ChatHistory":
                result = (List <T>)(object) ChatHistory.GetList(this);
                break;

            case "Discussion":
                result = (List <T>)(object) Discussion.GetList(this);
                break;

            case "Friend":
                result = (List <T>)(object) Friend.GetList(this);
                break;

            case "FriendCategory":
                result = (List <T>)(object) FriendCategory.GetList(this);
                break;

            case "FriendStatus":
                result = (List <T>)(object) FriendStatus.GetList(this);
                break;

            case "Group":
                result = (List <T>)(object) Group.GetList(this);
                break;

            default:
                throw new ArgumentOutOfRangeException();
            }
            _cache.GetCache <List <T> >().SetValue(result);
            return(result);
        }
Ejemplo n.º 7
0
        public void SelectBox()
        {
            List <FriendShip> ulist = friendService.GetFriendsAll(ctx.owner.Id);

            set("friendAll", getUserNames(ulist));

            List <FriendCategory> categories = FriendCategory.GetByOwner(ctx.owner.Id);

            bindSelectCategories(categories, ulist);


            DataPage <User> friends = friendService.GetFriendsPage(ctx.owner.Id, 50);

            bindList("list", "f", friends.Results);
            set("page", friends.PageBar);
        }
Ejemplo n.º 8
0
        public override void Layout()
        {
            set("searchAction", to(Query));
            String friendName = getSearchName();

            set("qValue", friendName);


            set("f.AddLink", to(Add));
            set("categoryLink", to(new FriendCategoryController().List));
            set("allLink", to(List, 0));
            set("blacklistLink", to(new BlacklistController().Index));

            List <FriendCategory> categories = FriendCategory.GetByOwner(ctx.owner.Id);

            bindCategories(categories);
        }
Ejemplo n.º 9
0
        private List <FriendShip> getByCategory(List <FriendShip> ulist, FriendCategory c)
        {
            List <FriendShip> results = new List <FriendShip>();

            foreach (FriendShip ship in ulist)
            {
                if (ship.User.Id == ctx.owner.Id && ship.CategoryId == c.Id)
                {
                    results.Add(ship);
                }
                else if (ship.Friend.Id == ctx.owner.Id && ship.CategoryIdFriend == c.Id)
                {
                    results.Add(ship);
                }
            }

            return(results);
        }
Ejemplo n.º 10
0
 public FriendsViewModel(FriendCategory category)
 {
     FriendsGrouped = FriendProvider.GetFriends(TokenProvider.GetToken(), category.Type, Global.ZipCode, Global.Distance);
 }
Ejemplo n.º 11
0
 public FriendsPage(FriendCategory category)
 {
     InitializeComponent();
     BindingContext = new FriendsViewModel(category);
 }
Ejemplo n.º 12
0
 public FriendsViewModel(FriendCategory category)
 {
     FriendsGrouped = FriendProvider.GetFriends(TokenProvider.GetToken(), category.Type, 98052, 5);
 }