Ejemplo n.º 1
0
        /// <summary>获取加我好友请求信息</summary>
        /// <param name="doc"></param>
        /// <returns></returns>
        public string GetAcceptListPaging(XmlDocument doc)
        {
            StringBuilder outString = new StringBuilder();

            PagingHelper paging = PagingHelper.Create(XmlHelper.Fetch("paging", doc, "xml"), XmlHelper.Fetch("query", doc, "xml"));

            paging.Query.Variables["scence"]    = "QueryAcceptList";
            paging.Query.Variables["accountId"] = KernelContext.Current.User.Id;

            int rowCount = -1;

            DataTable table = this.service.GetAcceptListPaging(paging.RowIndex, paging.PageSize, paging.Query, out rowCount);

            paging.RowCount = rowCount;

            // outString.Append("{\"data\":" + AjaxUtil.Parse<AccountFriendInfo>(list) + ",");
            outString.Append("{\"data\":[");

            foreach (DataRow row in table.Rows)
            {
                IAccountInfo friend = MembershipUtil.GetAccount(row["FriendAccountId"].ToString());

                outString.Append("{");
                outString.Append("\"accountId\":\"" + row["AccountId"].ToString() + "\",");
                outString.Append("\"friendAccountId\":\"" + row["FriendAccountId"].ToString() + "\",");
                outString.Append("\"friendAccountName\":\"" + friend.Name + "\",");
                outString.Append("\"friendCertifiedAvatar\":\"" + friend.CertifiedAvatar + "\",");
                outString.Append("\"friendCertifiedAvatarView\":\"" + friend.CertifiedAvatarView + "\",");
                outString.Append("\"reason\":\"" + StringHelper.ToSafeJson(row["Reason"].ToString()) + "\",");
                outString.Append("\"status\":" + row["Status"].ToString() + ",");
                outString.Append("\"createdDateView\":\"" + ((DateTime)row["CreatedDate"]).ToString("yyyy-MM-dd") + "\"");
                outString.Append("},");
            }

            outString = StringHelper.TrimEnd(outString, ",");

            outString.Append("],");
            outString.Append("\"paging\":" + paging + ",");
            outString.Append("\"message\":{\"returnCode\":0,\"value\":\"查询成功。\"},");
            outString.Append("\"metaData\":{\"root\":\"data\",\"idProperty\":\"id\",\"totalProperty\":\"total\",\"successProperty\":\"success\",\"messageProperty\": \"message\"},");
            outString.Append("\"total\":" + paging.RowCount + ",");
            outString.Append("\"success\":1,");
            outString.Append("\"msg\":\"success\"}");

            return(outString.ToString());
        }
Ejemplo n.º 2
0
        /// <summary>获取实例化的授权对象</summary>
        /// <param name="corporationId">公司标识</param>
        /// <param name="authorizationScopeObjects">授权范围对象</param>
        /// <returns></returns>
        public IList <IAuthorizationObject> GetInstantiatedAuthorizationObjects(string corporationId, IList <MembershipAuthorizationScopeObject> authorizationScopeObjects)
        {
            IList <IAuthorizationObject> list = new List <IAuthorizationObject>();

            IList <IRoleInfo> roles = MembershipManagement.Instance.RoleService.FindAllByCorporationId(corporationId);

            foreach (MembershipAuthorizationScopeObject authorizationScope in authorizationScopeObjects)
            {
                switch (authorizationScope.AuthorizationObjectType)
                {
                // 通用岗位
                case "GeneralRole":

                    MembershipUtil.GetIntersectionRoles(MembershipManagement.Instance.RoleService.FindAllByGeneralRoleId(authorizationScope.AuthorizationObjectId), roles)
                    .ToList()
                    .ForEach(item => list.Add((IAuthorizationObject)item));

                    break;

                // 标准角色
                case "StandardRole":

                    MembershipUtil.GetIntersectionRoles(MembershipManagement.Instance.RoleService.FindAllByStandardRoleId(authorizationScope.AuthorizationObjectId), roles)
                    .ToList()
                    .ForEach(item => list.Add((IAuthorizationObject)item));

                    break;

                // 标准部门
                case "StandardOrganizationUnit":

                    MembershipUtil.GetIntersectionRoles(MembershipManagement.Instance.RoleService.FindAllByStandardOrganizationUnitId(authorizationScope.AuthorizationObjectId), roles)
                    .ToList()
                    .ForEach(item => list.Add((IAuthorizationObject)item));

                    break;

                default:
                    list.Add(authorizationScope.GetAuthorizationObject());
                    break;
                }
            }

            return(list);
        }