Пример #1
0
        /// <summary>
        /// 获取员工信息
        /// </summary>
        public string GetUserList(string pRequest)
        {
            var rp = pRequest.DeserializeJSONTo <APIRequest <GetUserListRP> >();//不需要参数
            //string userId = rp.UserID;
            //string customerId = rp.CustomerID;
            var pageSize           = rp.Parameters.PageSize;
            var pageIndex          = rp.Parameters.PageIndex;
            var loggingSessionInfo = new SessionManager().CurrentUserLoginInfo;
            InnerGroupNewsBLL bll  = new InnerGroupNewsBLL(loggingSessionInfo);
            var userService        = new cUserService(loggingSessionInfo);

            string PhoneList = "";

            if (!string.IsNullOrEmpty(rp.Parameters.PhoneList))
            {
                string[] phones  = rp.Parameters.PhoneList.Split(new char[] { ',' });
                string   propIds = "";
                foreach (var itemInfo in phones)//数组,更新数据
                {
                    if (!string.IsNullOrEmpty(itemInfo))
                    {
                        if (propIds != "")
                        {
                            propIds += ",";
                        }
                        propIds += "'" + itemInfo + "'";
                    }
                }
                PhoneList = propIds;
            }

            var rd = new GetUserListRD();
            var ds = userService.GetUserList(pageIndex ?? 1, pageSize ?? 15, rp.Parameters.OrderBy, rp.Parameters.OrderType, loggingSessionInfo.UserID, loggingSessionInfo.ClientID, PhoneList
                                             , rp.Parameters.UnitID);

            if (ds != null && ds.Tables.Count > 0 && ds.Tables[0].Rows.Count > 0)
            {
                rd.UserList   = DataTableToObject.ConvertToList <UserInfo>(ds.Tables[1]);//直接根据所需要的字段反序列化
                rd.TotalCount = ds.Tables[0].Rows.Count;
                rd.TotalPages = Convert.ToInt32(Math.Ceiling(Convert.ToDecimal(ds.Tables[0].Rows.Count * 1.00 / (pageSize ?? 15) * 1.00)));
            }

            var rsp = new SuccessResponse <IAPIResponseData>(rd);

            return(rsp.ToJSON());
        }