예제 #1
0
        public static Result BatchDelete(string param)
        {
            Result      model       = new Result();
            AccessToken accessToken = TokenHelp.GetAccessToken();
            string      url         = DingTalkUrlHelp.BatchDeleteEmployee(accessToken.Value);

            model = DingTalkHttpHelp <Result> .Post(url, param);

            return(model);
        }
예제 #2
0
        /// <summary>
        /// 新增
        /// </summary>
        /// <param name="param"></param>
        /// <returns></returns>
        public static DepartmentResult Create(DepartmentEntity model)
        {
            DepartmentResult resul       = new DepartmentResult();
            AccessToken      accessToken = TokenHelp.GetAccessToken();
            string           url         = DingTalkUrlHelp.CreateDepartment(accessToken.Value);

            resul = DingTalkHttpHelp <DepartmentResult> .Post(url, model.ToJson());

            return(resul);
        }
예제 #3
0
        public static Result Delete(string userid)
        {
            Result      model       = new Result();
            AccessToken accessToken = TokenHelp.GetAccessToken();
            string      url         = DingTalkUrlHelp.DeleteEmployee(accessToken.Value, userid);

            model = DingTalkHttpHelp <Result> .Get(url);

            return(model);
        }
예제 #4
0
        public static GetEmployee Get(string userid)
        {
            GetEmployee model       = new GetEmployee();
            AccessToken accessToken = TokenHelp.GetAccessToken();
            string      url         = DingTalkUrlHelp.GetEmployee(accessToken.Value, userid);

            model = DingTalkHttpHelp <GetEmployee> .Get(url);

            return(model);
        }
예제 #5
0
        /// <summary>
        /// 更新
        /// </summary>
        /// <param name="param"></param>
        /// <returns></returns>
        public static Result Update(string param)
        {
            Result      model       = new Result();
            AccessToken accessToken = TokenHelp.GetAccessToken();
            string      url         = DingTalkUrlHelp.UpdateDepartment(accessToken.Value);

            model = DingTalkHttpHelp <Result> .Post(url, param);

            return(model);
        }
예제 #6
0
        /// <summary>
        /// 获取部门详情
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>
        public static GetDepartment Get(string id)
        {
            AccessToken   accessToken = TokenHelp.GetAccessToken();
            string        url         = DingTalkUrlHelp.GetDepartment(accessToken.Value, id);
            GetDepartment model       = new GetDepartment();

            model = DingTalkHttpHelp <GetDepartment> .Get(url);

            return(model);
        }
예제 #7
0
        /// <summary>
        /// 获取管理员列表
        /// </summary>
        /// <returns></returns>
        public static Result GetByDepartmentIdForAdmin()
        {
            Result      model       = new Result();
            AccessToken accessToken = TokenHelp.GetAccessToken();
            string      url         = DingTalkUrlHelp.GetByDepartmentIdForAdmin(accessToken.Value);

            model = DingTalkHttpHelp <Result> .Get(url);

            return(model);
        }
예제 #8
0
        /// <summary>
        /// 获取部门成员(详情)
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>
        public static GetDepartmentForUserList GetByDepartmentIdForUserInfoList(string id)
        {
            GetDepartmentForUserList model = new GetDepartmentForUserList();
            AccessToken accessToken        = TokenHelp.GetAccessToken();
            string      url = DingTalkUrlHelp.GetByDepartmentIdForUserInfoList(accessToken.Value, id);

            model = DingTalkHttpHelp <GetDepartmentForUserList> .Get(url);

            return(model);
        }
예제 #9
0
        /// <summary>
        /// 获取部门成员
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>
        public static ByDepIdFroSimpleListResult GetByDepartmentIdForSimpleList(string id)
        {
            ByDepIdFroSimpleListResult model = new ByDepIdFroSimpleListResult();
            AccessToken accessToken          = TokenHelp.GetAccessToken();
            string      url = DingTalkUrlHelp.GetByDepartmentIdForSimpleList(accessToken.Value, id);

            model = DingTalkHttpHelp <ByDepIdFroSimpleListResult> .Get(url);

            return(model);
        }
예제 #10
0
        /// <summary>
        /// 根据部门名称获取钉钉中的部门信息
        /// </summary>
        /// <param name="name"></param>
        /// <returns></returns>
        public static Department GetByName(string name)
        {
            AccessToken       accessToken    = TokenHelp.GetAccessToken();
            GetDepartmentList DepartmentList = GetList();

            if (DepartmentList.errcode == 90002)
            {
                System.Threading.Thread.Sleep(1500);
                DepartmentList = GetList();
            }
            Department model = DepartmentList.department.Where(e => e.name.Equals(name)).ToList().FirstOrDefault();

            return(model);
        }
예제 #11
0
        public static Result Update(string param)
        {
            Result      model       = new Result();
            AccessToken accessToken = TokenHelp.GetAccessToken();
            string      url         = DingTalkUrlHelp.UpdateEmployee(accessToken.Value);

            model = DingTalkHttpHelp <Result> .Post(url, param);

            if (model.errmsg == "40014")
            {
                accessToken = TokenHelp.GetAccessToken();
                url         = DingTalkUrlHelp.UpdateEmployee(accessToken.Value);
                model       = DingTalkHttpHelp <Result> .Post(url, param);
            }
            return(model);
        }
예제 #12
0
        public static string RegisterDingTalkCallBack()
        {
            RegisterModel regModel            = new RegisterModel();
            AccessToken   token               = TokenHelp.GetAccessToken();
            string        RegisterCallBackUrl = DingTalkUrlHelp.GetRegisterCallBack(token.Value);

            regModel.call_back_tag = new List <string>()
            {
                "user_leave_org"
            };
            regModel.token   = "加解密需要用到的token,ISV(服务提供商)推荐使用注册套件时填写的token,普通企业可以随机填写";
            regModel.aes_key = "数据加密密钥。用于回调数据的加密,长度固定为43个字符,从a-z, A-Z, 0-9共62个字符中选取,您可以随机生成,ISV(服务提供商)推荐使用注册套件时填写的EncodingAESKey";
            regModel.url     = "钉钉中设置的接收事件回调的url";
            string res = HttpHelper.Post(RegisterCallBackUrl, JsonConvert.SerializeObject(regModel, Formatting.Indented), "application/json").Html;

            return(res);
        }