예제 #1
0
        private async Task <CustomerInfo> GetDDUserInfoAsync(string identityId)
        {
            CustomerInfo customer = null;
            var          token    = await _ddHelper.GetAccessTokenAsync();

            var user = await _ddHelper.GetUserInfoAsync(token, identityId);

            if (user.errcode == "0")
            {
                customer = new CustomerInfo
                {
                    Avatar     = user.avatar,
                    Name       = user.name,
                    IdentityId = user.userid,
                    From       = "钉钉用户",
                    Email      = user.email,
                    Mobile     = user.mobile,
                    Position   = user.position
                };
                var departmentId = user.department?.FirstOrDefault();
                if (string.IsNullOrEmpty(departmentId) == false)
                {
                    var depart = await _ddHelper.GetDepartmentInfoByIdAsync(token, departmentId);

                    if (depart != null)
                    {
                        customer.Department = depart.Name;
                    }
                }
            }
            return(customer);
        }
예제 #2
0
        public async Task <IActionResult> GetDDConfig()
        {
            //获取Token
            var token = await _ddHelper.GetAccessTokenAsync();

            //HttpContext.Session.SetString("Token", _token);
            //获取部门
            //string _depart = DingTalkHelper.GetDepartmentsList(_token);
            //获取JsApiTicket
            var ticket = await _ddHelper.GetJsApiTicketAsync(token);

            //HttpContext.Session.SetString("Ticket", _ticket);
            //获取url
            string url = _configuration.GetValue("ReactClientUrl", "");//"http://" + HttpContext.Request.Host.ToString();
            //生成config信息
            var _ddconfig = await _ddHelper.GetDingdingConfigAsync(url, ticket);

            if (_ddconfig.Code == ResultModel.ResultCode.Success)
            {
                Dictionary <string, string> dic = _ddconfig.Data;

                if (dic != null)
                {
                    return(Ok(new { token, ticket, _ddConfig.CorpId, url, agentId = dic["agentId"], timeStamp = dic["timeStamp"], nonceStr = dic["nonceStr"], signature = dic["signature"] }));
                }
            }

            return(Ok());
        }