Beispiel #1
0
        private async Task _getUserInRoleAsync(CallContext cctx, EntityAbs <Role> ra, List <string> usersinrole)
        {
            UserServiceProxy usvc  = new UserServiceProxy();
            QueryExpresion   qexpr = new QueryExpresion();

            qexpr.OrderTks = new List <QToken>(new QToken[] { new QToken {
                                                                  TkName = "Username"
                                                              } });
            qexpr.FilterTks = new List <QToken>(new QToken[] {
                new QToken {
                    TkName = "UsersInRole."
                },
                new QToken {
                    TkName = "RoleID"
                },
                new QToken {
                    TkName = "=="
                },
                new QToken {
                    TkName = "" + ra.DataBehind.ID + ""
                }
            });
            var users = await usvc.QueryDatabaseAsync(cctx, new UserSet(), qexpr);

            foreach (User u in users)
            {
                usersinrole.Add(u.Username);
            }
            if (ra.ChildEntities != null)
            {
                foreach (var c in ra.ChildEntities)
                {
                    await _getUserInRoleAsync(cctx, c, usersinrole);
                }
            }
        }
        public static async Task <dynamic> LoadRoomSummary(string hubId, string id)
        {
            UserGroupServiceProxy gsvc = new UserGroupServiceProxy();
            var    cntx  = Cntx;
            string descr = await gsvc.LoadEntityGroupDescriptionAsync(cntx, id);

            MemberCallbackServiceProxy mcbsvc = new MemberCallbackServiceProxy();
            var  qexpr = getConnectedGroupMemberFilter(hubId, id);
            long cnt   = await mcbsvc.QueryEntityCountAsync(cntx, new MemberCallbackSet(), qexpr);

            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 = "UserGroupID == \"" + id + "\" && SubscribedTo is not null && SubscribedTo == true"
                }
            });
            long scnt = await uigsvc.QueryEntityCountAsync(cntx, new UserGroupMemberSet(), qexpr);

            qexpr          = new QueryExpresion();
            qexpr.OrderTks = new List <QToken>(new QToken[] {
                new QToken {
                    TkName = "Username"
                }
            });
            qexpr.FilterTks = new List <QToken>(new QToken[] {
                new QToken {
                    TkName = "UsersInRole_UserID.RoleRef.UserGroupAdminRole.GroupID == \"" + id + "\""
                }
            });
            UserServiceProxy usvc = new UserServiceProxy();
            var admins            = await usvc.QueryDatabaseAsync(cntx, new UserSet(), qexpr);

            List <dynamic> ladms = new List <dynamic>();

            if (admins.Count() > 0)
            {
                RoleServiceProxy rsvc = new RoleServiceProxy();
                foreach (var u in admins)
                {
                    qexpr          = new QueryExpresion();
                    qexpr.OrderTks = new List <QToken>(new QToken[] {
                        new QToken {
                            TkName = "ID"
                        }
                    });
                    qexpr.FilterTks = new List <QToken>(new QToken[] {
                        new QToken {
                            TkName = "UserGroupAdminRole.GroupID == \"" + id + "\" && UsersInRole.UserID == \"" + u.ID + "\""
                        }
                    });
                    var role = (await rsvc.QueryDatabaseAsync(cntx, new RoleSet(), qexpr)).First();
                    ladms.Add(new { id = u.ID, name = u.Username, role = role.DisplayName });
                }
            }
            dynamic r = new { descr = descr, active = cnt, subscribers = scnt, admins = ladms };

            return(r);
        }
 public static async Task<dynamic> LoadRoomSummary(string hubId, string id)
 {
     UserGroupServiceProxy gsvc = new UserGroupServiceProxy();
     var cntx = Cntx;
     string descr = await gsvc.LoadEntityGroupDescriptionAsync(cntx, id);
     MemberCallbackServiceProxy mcbsvc = new MemberCallbackServiceProxy();
     var qexpr = getConnectedGroupMemberFilter(hubId, id);
     long cnt = await mcbsvc.QueryEntityCountAsync(cntx, new MemberCallbackSet(), qexpr);
     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 = "UserGroupID == \"" + id + "\" && SubscribedTo is not null && SubscribedTo == true"  }
     });
     long scnt = await uigsvc.QueryEntityCountAsync(cntx, new UserGroupMemberSet(), qexpr);
     qexpr = new QueryExpresion();
     qexpr.OrderTks = new List<QToken>(new QToken[] { 
         new QToken { TkName = "Username" }
     });
     qexpr.FilterTks = new List<QToken>(new QToken[] { 
         new QToken { TkName = "UsersInRole_UserID.RoleRef.UserGroupAdminRole.GroupID == \"" + id + "\"" }
     });
     UserServiceProxy usvc = new UserServiceProxy();
     var admins = await usvc.QueryDatabaseAsync(cntx, new UserSet(), qexpr);
     List<dynamic> ladms = new List<dynamic>();
     if (admins.Count() > 0)
     {
         RoleServiceProxy rsvc = new RoleServiceProxy();
         foreach (var u in admins)
         {
             qexpr = new QueryExpresion();
             qexpr.OrderTks = new List<QToken>(new QToken[] { 
                 new QToken { TkName = "ID" }
             });
             qexpr.FilterTks = new List<QToken>(new QToken[] { 
                 new QToken { TkName = "UserGroupAdminRole.GroupID == \"" + id + "\" && UsersInRole.UserID == \"" + u.ID + "\"" }
             });
             var role = (await rsvc.QueryDatabaseAsync(cntx, new RoleSet(), qexpr)).First();
             ladms.Add(new { id = u.ID, name = u.Username, role = role.DisplayName });
         }
     }
     dynamic r = new { descr = descr, active = cnt, subscribers = scnt, admins = ladms };
     return r;
 }