using BP.DA; using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace BP.GPM.WeiXin { /// /// 部门列表 /// public class DeptList { #region 部门属性. /// /// 返回码 /// public int errcode { get; set; } /// /// 对返回码的文本描述内容 /// public string errmsg { get; set; } /// /// 部门列表数据 /// public List department { get; set; } #endregion 部门属性. public DeptList() { } /// /// 查询所有的部门 /// /// public int RetrieveAll() { string access_token = BP.GPM.WeiXin.WeiXinEntity.getAccessToken(); string url = "https://qyapi.weixin.qq.com/cgi-bin/department/list?access_token=" + access_token; //读取数据. string str = DataType.ReadURLContext(url, 9999, null); DeptList departMentList = BP.Tools.FormatToJson.ParseFromJson(str); if (departMentList.errcode != 0) throw new Exception("err@获得部门信息错误:code" + departMentList.errcode + ",Msg=" + departMentList.errmsg); this.errcode = departMentList.errcode; this.errmsg = departMentList.errmsg; this.department = departMentList.department; return this.department.Count; } } /// /// 部门信息 /// public class DeptEntity { #region 属性. /// /// 部门id /// public string id { get; set; } /// /// 部门名称 /// public string name { get; set; } /// /// 父亲部门id。根部门为1 /// public string parentid { get; set; } /// /// 在父部门中的次序值。order值小的排序靠前 /// public string order { get; set; } #endregion 属性. /// /// 构造函数 /// /// public DeptEntity(string id) { } } }