public static async Task<ChatContextVM> ListChatRooms(string uId) { UserGroupServiceProxy gsvc = new UserGroupServiceProxy(); var m = new ChatContextVM(); var cntx = Cntx; QueryExpresion qexpr = new QueryExpresion(); qexpr.OrderTks = new List<QToken>(new QToken[] { new QToken { TkName = "GroupName" } }); qexpr.FilterTks = new List<QToken>(new QToken[] { new QToken { TkName = "GroupTypeID == " + ApplicationContext.ChatGroupTypeID + " && ParentID is null" } }); m.TopRooms = new List<EntityAbs<UserGroup>>(); var roots = await gsvc.QueryDatabaseAsync(cntx, new UserGroupSet(), qexpr); foreach (var r in roots) { var top = await gsvc.LoadEntityFullHierarchyRecursAsync(cntx, r); if (top != null) m.TopRooms.Add(top); } UserGroupMemberServiceProxy uigsvc = new UserGroupMemberServiceProxy(); qexpr = new QueryExpresion(); qexpr.OrderTks = new List<QToken>(new QToken[] { new QToken { TkName = "UserID" } }); qexpr.FilterTks = new List<QToken>(new QToken[] { new QToken { TkName = "UserGroupRef.GroupTypeID == " + ApplicationContext.ChatGroupTypeID + " && UserID == \"" + uId + "\"" } }); var recs = await uigsvc.QueryDatabaseAsync(cntx, new UserGroupMemberSet(), qexpr); if (recs.Count() > 0) m.MemberIds = (from d in recs select d.UserGroupID).ToArray(); else m.MemberIds = new string[] { }; return m; }
public static async Task <ChatContextVM> ListChatRooms(string uId) { UserGroupServiceProxy gsvc = new UserGroupServiceProxy(); var m = new ChatContextVM(); var cntx = Cntx; QueryExpresion qexpr = new QueryExpresion(); qexpr.OrderTks = new List <QToken>(new QToken[] { new QToken { TkName = "GroupName" } }); qexpr.FilterTks = new List <QToken>(new QToken[] { new QToken { TkName = "GroupTypeID == " + ApplicationContext.ChatGroupTypeID + " && ParentID is null" } }); m.TopRooms = new List <EntityAbs <UserGroup> >(); var roots = await gsvc.QueryDatabaseAsync(cntx, new UserGroupSet(), qexpr); foreach (var r in roots) { var top = await gsvc.LoadEntityFullHierarchyRecursAsync(cntx, r); if (top != null) { m.TopRooms.Add(top); } } UserGroupMemberServiceProxy uigsvc = new UserGroupMemberServiceProxy(); qexpr = new QueryExpresion(); qexpr.OrderTks = new List <QToken>(new QToken[] { new QToken { TkName = "UserID" } }); qexpr.FilterTks = new List <QToken>(new QToken[] { new QToken { TkName = "UserGroupRef.GroupTypeID == " + ApplicationContext.ChatGroupTypeID + " && UserID == \"" + uId + "\"" } }); var recs = await uigsvc.QueryDatabaseAsync(cntx, new UserGroupMemberSet(), qexpr); if (recs.Count() > 0) { m.MemberIds = (from d in recs select d.UserGroupID).ToArray(); } else { m.MemberIds = new string[] { } }; return(m); }
public static async Task<UserGroup[]> UserGroupChatGroups(string userId) { var svc = new UserGroupServiceProxy(); var qexpr = new QueryExpresion(); // check this qexpr.OrderTks = new List<QToken>(new QToken[] { new QToken { TkName = "ID" }, new QToken { TkName = "asc" } }); qexpr.FilterTks = new List<QToken>(new QToken[] { new QToken { TkName = "GroupTypeID == " + ApplicationContext.ChatGroupTypeID + " && UserGroupMember.UserID == \"" + userId + "\"" } }); var gl = await svc.QueryDatabaseAsync(Cntx, new UserGroupSet(), qexpr); return gl == null ? null : (from d in gl select d).ToArray(); }
public static async Task <UserGroup[]> UserGroupChatGroups(string userId) { var svc = new UserGroupServiceProxy(); var qexpr = new QueryExpresion(); // check this qexpr.OrderTks = new List <QToken>(new QToken[] { new QToken { TkName = "ID" }, new QToken { TkName = "asc" } }); qexpr.FilterTks = new List <QToken>(new QToken[] { new QToken { TkName = "GroupTypeID == " + ApplicationContext.ChatGroupTypeID + " && UserGroupMember.UserID == \"" + userId + "\"" } }); var gl = await svc.QueryDatabaseAsync(Cntx, new UserGroupSet(), qexpr); return(gl == null ? null : (from d in gl select d).ToArray()); }