Пример #1
0
        /// <summary>
        /// 分页加载信息
        /// </summary>
        /// <param name="e"></param>
        void OnNextPage(PageData e)
        {
            int cnt = AtState.GetScalar <int>("select count(*) from Letter where otherid=@otherid and loginid=@loginid",
                                              new Dict
            {
                { "otherid", OtherID },
                { "loginid", Kit.UserID }
            });

            int start = cnt - (e.PageNo + 1) * e.PageSize;
            int limit = e.PageSize;

            if (start < 0)
            {
                limit = cnt - e.PageNo * e.PageSize;
            }

            Nl <Letter> data = new Nl <Letter>();
            var         ls   = AtState.Each <Letter>($"select * from Letter where otherid={OtherID} and loginid={Kit.UserID} order by stime limit {limit} offset {start}");

            foreach (var l in ls)
            {
                var photo = l.IsReceived ? _other.Photo : Kit.UserPhoto;
                if (string.IsNullOrEmpty(photo))
                {
                    photo = "photo/profilephoto.jpg";
                }
                l.Photo = photo;
                data.Add(l);
            }
            e.LoadPageData(data);
        }
Пример #2
0
        /// <summary>
        /// 获取用户可访问的菜单
        /// </summary>
        /// <returns></returns>
        static async Task <List <long> > GetAllUserMenus()
        {
            int cnt = AtState.GetScalar <int>("select count(*) from DataVersion where id='menu'");

            if (cnt == 0)
            {
                // 查询服务端
                Dict dt = await AtCm.GetMenus(Kit.UserID);

                // 记录版本号
                var ver = new DataVersion(ID: "menu", Ver: dt.Str("ver"));
                await AtState.Save(ver, false);

                // 清空旧数据
                AtState.Exec("delete from UserMenu");

                // 插入新数据
                var ls = (List <long>)dt["result"];
                if (ls != null && ls.Count > 0)
                {
                    List <Dict> dts = new List <Dict>();
                    foreach (var id in ls)
                    {
                        dts.Add(new Dict {
                            { "id", id }
                        });
                    }
                    AtState.BatchExec("insert into UserMenu (id) values (:id)", dts);
                }
                return(ls);
            }

            return(AtState.FirstCol <long>("select id from UserMenu"));
        }
Пример #3
0
        /// <summary>
        /// 显示聊天对话框
        /// </summary>
        /// <param name="p_otherID">对方ID</param>
        /// <param name="p_otherName">null时自动查询</param>
        public static void ShowDlg(long p_otherID, string p_otherName = null)
        {
            if (string.IsNullOrEmpty(p_otherName))
            {
                p_otherName = AtState.GetScalar <string>($"select name from ChatMember where id={p_otherID}");
                if (string.IsNullOrEmpty(p_otherName))
                {
                    p_otherName = p_otherID.ToString();
                }
            }

            Dlg dlg;

            if (Kit.IsPhoneUI)
            {
                dlg = new Dlg {
                    Title = p_otherName,
                };
            }
            else
            {
                dlg = new Dlg()
                {
                    IsPinned = true,
                    Height   = 500,
                    Width    = 400,
                    Title    = p_otherName,
                };
            }

            ChatDetail chat = new ChatDetail();

            chat.OtherID = p_otherID;
            dlg.Content  = chat;
            dlg.Show();
        }