Ejemplo n.º 1
0
        /// <summary>
        /// 免登数据返回接口
        /// </summary>
        public string BeginDDAutoLogin()
        {
            string nonceStr = "helloDD";//todo:随机

            ViewBag.NonceStr = nonceStr;
            string accessToken = DDApiService.Instance.GetAccessToken();

            ViewBag.AccessToken = accessToken;
            string ticket    = DDApiService.Instance.GetJsApiTicket(accessToken);
            long   timeStamp = DDHelper.GetTimeStamp();
            string url       = dtConfig.Url;
            string signature = DDApiService.Instance.GetSign(ticket, nonceStr, timeStamp, url);

            ViewBag.Url         = url;
            ViewBag.JsApiTicket = ticket;
            ViewBag.Signature   = signature;
            ViewBag.NonceStr    = nonceStr;
            ViewBag.TimeStamp   = timeStamp;
            ViewBag.CorpId      = DDApiService.Instance.CorpId;
            ViewBag.CorpSecret  = dtConfig.CorpSecret;
            ViewBag.AgentId     = DDApiService.Instance.AgentId;

            Dictionary <string, string> dic = new Dictionary <string, string>();

            dic.Add("Url", url);
            dic.Add("AgentId", DDApiService.Instance.AgentId);
            dic.Add("CorpId", DDApiService.Instance.CorpId);
            dic.Add("TimeStamp", timeStamp.ToString());
            dic.Add("NonceStr", nonceStr);
            dic.Add("Signature", signature);
            dic.Add("JsApiTicket", ticket);
            return(JsonConvert.SerializeObject(dic));
        }
Ejemplo n.º 2
0
        private void BeginDDAutoLogin()
        {
            string nonceStr = "helloDD";//todo:随机

            ViewBag.NonceStr = nonceStr;
            string accessToken = DDApiService.Instance.GetAccessToken();

            ViewBag.AccessToken = accessToken;
            string ticket    = DDApiService.Instance.GetJsApiTicket(accessToken);
            long   timeStamp = DDHelper.GetTimeStamp();
            string url       = Request.Url.ToString();
            string signature = DDApiService.Instance.GetSign(ticket, nonceStr, timeStamp, url);

            ViewBag.JsApiTicket = ticket;
            ViewBag.Signature   = signature;
            ViewBag.NonceStr    = nonceStr;
            ViewBag.TimeStamp   = timeStamp;
            ViewBag.CorpId      = DDApiService.Instance.CorpId;
            ViewBag.CorpSecret  = DDApiService.Instance.CorpSecret;
            ViewBag.AgentId     = DDApiService.Instance.AgentId;
        }
Ejemplo n.º 3
0
        //
        // GET: /DD/
        //public ActionResult GetUserInfo(string accessToken, string code, bool setCurrentUser = true)
        //{
        //    try
        //    {
        //        string userId = DingDingService.Instance.GetUserId(accessToken, code);
        //        string jsonString = DingDingService.Instance.GetUserDetailJson(accessToken, userId);
        //        UserDetailInfo userInfo = DingDingService.Instance.GetUserDetailFromJson(jsonString);
        //        if (setCurrentUser)
        //        {
        //            Session["AccessToken"] = accessToken;
        //            Session["CurrentUser"] = userInfo;
        //        }
        //        return Content(jsonString);
        //    }
        //    catch (Exception ex)
        //    {
        //        return Content(string.Format("{{'errcode': -1, 'errmsg':'{0}'}}", ex.Message));
        //    }
        //}


        // GET: /UserManager/
        public ActionResult Index()
        {
            string nonceStr = "HELLOWORK";//todo:随机

            ViewBag.NonceStr = nonceStr;
            string accessToken = DingDingService.GetAccessToken();

            ViewBag.AccessToken = accessToken;
            string ticket    = DingDingService.GetJsApiTicket(accessToken);
            long   timeStamp = DDHelper.GetTimeStamp();
            string url       = Request.Url.ToString();
            string signature = DingDingService.GetSign(ticket, nonceStr, timeStamp, url);

            ViewBag.JsApiTicket = ticket;
            ViewBag.Signature   = signature;
            ViewBag.NonceStr    = nonceStr;
            ViewBag.TimeStamp   = timeStamp;
            ViewBag.CorpId      = DDHelper.GetCorpId();
            ViewBag.CorpSecret  = DDHelper.CorpSecret();
            ViewBag.AgentId     = DDHelper.GetAgentId();
            return(View());
        }