| | |
| | | using DBUtility; |
| | | using DAL; |
| | | using DBUtility; |
| | | using DLL; |
| | | using Newtonsoft.Json; |
| | | using Newtonsoft.Json.Linq; |
| | | using System; |
| | |
| | | using System.Linq; |
| | | using System.Net; |
| | | using System.Net.Http; |
| | | using System.Timers; |
| | | using System.Threading.Tasks; |
| | | using System.Web.Http; |
| | | using WebAPI.Models; |
| | | using System.Threading; |
| | | |
| | | namespace WebAPI.Controllers.SCGL |
| | | { |
| | |
| | | /// <returns></returns> |
| | | [Route("Sc_MESTransFerWorkBill/SaveGetMESTransFerWorkFrom")] |
| | | [HttpPost] |
| | | public object SaveGetMESTransFerWorkFrom([FromBody] JObject msg) |
| | | public object SaveGetMESTransFerWorkFromAsync([FromBody] JObject msg) |
| | | { |
| | | |
| | | var _value = msg["msg"].ToString(); |
| | |
| | | objJsonResult.data = 1; |
| | | return objJsonResult; |
| | | } |
| | | |
| | | |
| | | //string[] arrStr = oItem.HSendMan.Split(','); //发送人 |
| | | //arrStr = oItem.HReceiveMan.Split(','); //接收人 |
| | | string[] arrStr = oItem.HCopyMan.Split(','); //抄送人 |
| | |
| | | Models.ClsOA_ErrMsgBackBillSub2 sb = new Models.ClsOA_ErrMsgBackBillSub2(); |
| | | sb.HEntryID = i; |
| | | sb.HReceiveMan = arrStr[i - 1]; |
| | | if (arrStr[i-1].ToString() == oItem.HSendMan) |
| | | if (arrStr[i - 1].ToString() == oItem.HSendMan) |
| | | { |
| | | sb.HReadFlag = true; |
| | | } |
| | |
| | | } |
| | | } |
| | | } |
| | | SaveOA_ErrMsgBackBillSub(msg2);//第一次保存发送钉钉 |
| | | |
| | | } |
| | | else |
| | |
| | | #endregion |
| | | |
| | | #endregion |
| | | |
| | | #region 异常反馈单保存后,往子表里面去插入数据 |
| | | public object SaveOA_ErrMsgBackBillSub(string msg2) |
| | | { |
| | | msg2 = "[" + msg2.ToString() + "]"; |
| | | List<ClsOA_ErrMsgBackBillMain> mainList = Newtonsoft.Json.JsonConvert.DeserializeObject<List<ClsOA_ErrMsgBackBillMain>>(msg2); |
| | | |
| | | long HInterID = mainList[0].HInterID;//递入type得到的单据ID |
| | | string HReceiveMan = mainList[0].HReceiveMan;//接收人 |
| | | string HDescription = mainList[0].HDescription;//内容 |
| | | int HEntryID = 1; |
| | | |
| | | string sql = "insert into OA_ErrMsgBackBillSub2 values('" + HInterID + "','" + HEntryID + "','" + HReceiveMan + "','0')"; |
| | | oCN.RunProcReturn(sql, "OA_ErrMsgBackBillSub2"); |
| | | //直接发送钉钉消息 s |
| | | FistDingDingMesAsync(HReceiveMan, HDescription); |
| | | |
| | | objJsonResult.code = "0"; |
| | | objJsonResult.count = 0; |
| | | objJsonResult.Message = "插入成功,开始执行定时任务,钉钉发送消息"; |
| | | objJsonResult.data = 1; |
| | | return objJsonResult; |
| | | } |
| | | |
| | | /// <summary> |
| | | /// 异常反馈单第一次保存的时候进行发送消息 |
| | | /// </summary> |
| | | /// <param name="HReceiveMan"></param> |
| | | /// <param name="HDescription"></param> |
| | | public async void FistDingDingMesAsync(string HReceiveMan, string HDescription) |
| | | { |
| | | |
| | | ds = oCN.RunProcReturn("select * from Gy_Czygl where Czymc='" + HReceiveMan + "'", "Gy_Czygl"); |
| | | string DDUserID = ds.Tables[0].Rows[0]["DDUserID"].ToString(); //钉钉用户的id |
| | | Cls_DDMsg msg = new Cls_DDMsg(); |
| | | string appKey = "dingrsrzhdyn3mlaof95"; |
| | | string appSecret = "RAqH6YtZnPLCpDbuqfaYQkKkVtVdS0wqfC8I26X6qiS-8eoCJCNrzx3fubGND4Sq"; |
| | | //获取企业的access_token的值 |
| | | string response = msg.GetAccessToken(appKey, appSecret); |
| | | JObject responseJson = JObject.Parse(response); |
| | | // 获取access_token的值 |
| | | string accessToken = responseJson["accessToken"].ToString(); |
| | | //调用方法发送消息 |
| | | string agentId = "3118119317"; //企业内部小程序id |
| | | string deptIdList = "0"; // 空字符串表示不指定部门 |
| | | string toAllUser = "false"; |
| | | string message = HDescription;//异常反馈单的内容 |
| | | response = await msg.SendTextMessage(accessToken, agentId, DDUserID, deptIdList, toAllUser, message); |
| | | Console.WriteLine($"初始消息发送结果: {response}"); |
| | | } |
| | | |
| | | #endregion |
| | | } |
| | | } |