/// <summary> /// 钉钉登录 /// </summary> /// <param name="code"></param> /// <returns></returns> public IHttpActionResult DdLogin([FromBody] dynamic code) { try { DdOperator ddoper = DdOperator.GetDdApi(); UserProvider uProvider = new UserProvider(ddoper); UserOper uOper = new UserOper(); var uDdId = uProvider.GetDdIdByCode((string)code.code); User _user = uOper.GetUserByDdId(uDdId); if (_user != null) { ///再次登录更新cookie信息 _user = uOper.UpDateLoginInfo(_user); } ///首次登录 else { //取得用户信息 _user = uProvider.GetUserInfo(uDdId); ///首次登录,在数据库登录新用户 uOper.AddUser(_user); //将用户加入默认用户组 new UrOper().AddDefalutUR(_user); } SessionManage.CurrentUser = _user; return(Ok(LoginHelp.ReturnUser(_user))); } catch (Exception e) { return(BadRequest(e.Message)); } }
public IHttpActionResult SubmitProof(dynamic proof) { User u = SessionManage.CurrentUser; string proofOrderId = (string)proof.ProofOrderId; ProofOrderOper poo = new ProofOrderOper(u); ProofOrder po = poo.GetProof(proofOrderId); if (po.ProofStatus == ProofStatus.草拟 || po.ProofStatus == ProofStatus.退回) { NewApprove na = new NewApprove(DdOperator.GetDdApi()) { User = u, ProcessCode = Config.GetSampleConfig().ProofProcessCode }; var ApproveItems = ProofOrderApprove.ToApprove(po); string DdApprovalCode = na.SendApprove(ApproveItems); if (DdApprovalCode != "") { poo.SetApprove(po, DdApprovalCode); poo.SaveChange(); } } return(Ok(po)); }
public IHttpActionResult DdCallBack(dynamic e) { //接收回调事件 string encrypt = (string)e.encrypt; var request = HttpContext.Current.Request; string signature = request["signature"]; string timestamp = request["timestamp"]; string nonce = request["nonce"]; DdEncrypt de = new DdEncrypt(DdOperator.GetDdApi()); //解密加调事件 string re = de.DecryptMsg(encrypt, signature, timestamp, nonce); //处理回调事件 Task.Run(() => { //事件为审批回调,启用异步处理 dynamic robj = JsonHelper.ToObj(re); DdCallBackSysOper.GetOper().DdCallBack(robj); }); //返回加密成功标志给钉钉 var obj = de.EncryptMsg("success"); return(Ok(obj)); }
static void Main(string[] args) { IDdOper ddOper = DdOperator.GetDdApi(); ddOper.CorpId = "ding99dd341fc99a25eb"; ddOper.CorpSecret = "szdxoAP2Wp2knwzsDcsDYvd_qLAjvx0YANa1RH4hOU-O8VxENo5hYE5glb_CsQg0"; ddOper.AgentID = "132907517"; ApproveOper ao = new ApproveOper(ddOper); var re = ao.GetApprove("7b8ec3ef-f5c3-4ec8-8482-4e7210f7db50"); re.FormComponentValues.ForEach(p => { if (p.Name == "评分") { int Rating = 3; if (p.Value != null) { if (p.Value.IndexOf('1') > 0) { Rating = 1; } else if (p.Value.IndexOf('2') > 0) { Rating = 2; } else if (p.Value.IndexOf('3') > 0) { Rating = 3; } else if (p.Value.IndexOf('4') > 0) { Rating = 4; } else if (p.Value.IndexOf('5') > 0) { Rating = 5; } } ; int i = Rating; } if (p.Name == "样衣图片") { var list = JsonHelper.JsonToList <string>(p.Value); var url = list[0]; string name = url.Substring(url.LastIndexOf('/') + 1); var f = HttpHelper.DownloadData(list[0]); File.WriteAllBytes("d:\\p1.jpg", f); Console.Write("down finsh"); } }); Console.Write("ok"); }
public object UpUserDataByDd() { var ddoper = DdOperator.GetDdApi(); SyncFromDd.SyncUserDept(ddoper); SyncFromDd.SyncUserRole(ddoper); return(Ok()); }
public object GetDdSign(dynamic Url) { var url = (string)Url.url; var ddoper = DdOperator.GetDdApi(); var agentId = ddoper.AgentID; var corpId = ddoper.CorpId; var nonceStr = CommonHelper.randNonce(); var timestamp = ddoper.TimeStamp(); var signature = ddoper.GetSignature(nonceStr, timestamp, url); return(Ok(new { agentId, corpId, nonceStr, timestamp, signature, url })); }
public IHttpActionResult FinshProof(string id) { User u = SessionManage.CurrentUser; ProofOrderOper poo = new ProofOrderOper(u); var result = poo.FinshProof(id); if (result != null) { //发送交样申请 string ddid = result.ProofApplyUserDdId; User applyUser = SampleDataOper.DataQuery.GetSingle <User>(p => p.DdId == ddid); NewApprove na = new NewApprove(DdOperator.GetDdApi()) { User = applyUser, ProcessCode = Config.GetSampleConfig().FinshProofProcessCode }; List <ApproveItem> items = new List <ApproveItem>() { new ApproveItem() { Name = "单号", Value = result.ProofOrderId }, new ApproveItem() { Name = "款号", Value = result.ProofStyle.ClientNo }, new ApproveItem() { Name = "客户", Value = result.ProofStyle.ClentName }, new ApproveItem { Name = "打样部门", Value = "打样中心" }, }; string DdApprovalCode = na.SendApprove(items); if (DdApprovalCode != "") { poo.SetFinshApprove(result, DdApprovalCode); poo.SaveChange(); return(Ok()); } ; } return(BadRequest("订单号错误。")); }
public static void DdApi() { IDdOper ddOper = DdOperator.GetDdApi(); ddOper.CorpId = "ding99dd341fc99a25eb"; ddOper.CorpSecret = "szdxoAP2Wp2knwzsDcsDYvd_qLAjvx0YANa1RH4hOU-O8VxENo5hYE5glb_CsQg0"; ddOper.AgentID = "132907517"; var dck = new DdCallbackOper(ddOper); //var dre = dck.DeleteRegister(); //var regre = dck.SendRegister(); var re = dck.GetRegister(); Console.ReadLine(); }
protected void Application_Start() { GlobalConfiguration.Configure(WebApiConfig.Register); GlobalConfiguration.Configuration.Formatters.XmlFormatter.SupportedMediaTypes.Clear(); //钉钉初始化 DdOperator ddOper = DdOperator.GetDdApi(); ddOper.CorpId = ConfigurationManager.AppSettings["CorpId"]; ddOper.CorpSecret = ConfigurationManager.AppSettings["CorpSecret"]; ddOper.AgentID = ConfigurationManager.AppSettings["AgentID"]; var dbso = DdCallBackSysOper.GetOper(); dbso.SysPath = HttpContext.Current.Server.MapPath("~"); Task.Factory.StartNew(() => { ddOper.SetDept(new DeptOper().GetDepts()); }); Task.Run(async delegate { await Task.Delay(5000); //注册回调 DdCallbackOper dcb = new DdCallbackOper(ddOper); dcb.CallBackUrl = Config.GetSampleConfig().CallBackUrl; dcb.RegisterCallBack(); //处理历吏回调 bool hasMore = false; do { var re = dcb.GetFailCallBack(); re.FailedList.ForEach(p => { dynamic robj = JsonHelper.ToObj(p.BpmsInstanceChange); dbso.DdCallBack(robj.bpmsCallBackData); }); hasMore = re.HasMore; } while (hasMore); }); }
public void DdCallBack(dynamic obj) { if (obj.EventType == "bpms_task_change" || obj.EventType == "bpms_instance_change") { //钉钉样衣申请回调 if (obj.processCode == ProofProcessCode && obj.type == "finish") { ProofOrderApprove Poa = new ProofOrderApprove(); string pid = obj.processInstanceId; if (obj.result == "agree") { //同意 Poa.AgreeApprove(pid); } else { //拒绝 Poa.RefuseApprove(pid); } } //钉钉样衣交样回调 if (obj.processCode == FinshProofProcessCode && obj.type == "finish") { ProofOrderFinsh Pof = new ProofOrderFinsh(DdOperator.GetDdApi()); Pof.SysPath = SysPath; string pid = obj.processInstanceId; if (obj.result == "agree") { //同意 Pof.AgreeFinsh(pid); } else { //拒绝 Pof.RefuseFinsh(pid); } } } }