public override IResponseMessage OnTextRequest(IRequestMessage requestMessage) { var biz = new JsonMessage { touser = requestMessage.FromUserName, msgtype = "text", agentid = requestMessage.AgentID.ToString(), text = new JsonMessageInnerType.textcontent { content = requestMessage.Content }, safe = 0 }; var error = JsonSend.SendQyMessage(postModel.CorpId, postModel.Secret, XLH.SerializeJsonToString(biz), Encoding.UTF8); Debug.WriteLine(error); ResponseMessage.CreateFromRequestMessage(requestMessage, QY.Enums.ResponseType.Text); return(null); }
public override IResponseMessage OnEventRequest(IRequestMessage RequestMessage) { if (RequestMessage.Event == "click") { if (RequestMessage.EventKey == "最近出库") { var dict1 = new Dictionary <string, string>(); var query1 = "SELECT TOP 3A.客户 as 单位,A.送货单号 as 单号,A.业务描述 as 类型, A.送货日期 as 日期 FROM 发货 A ORDER BY A.送货日期 DESC, A.客户编号 ASC"; var query2 = @"SELECT A.送货单号 as 单号,B.编号,B.描述,B.PCS,B.工艺,B.木种 FROM (SELECT TOP 3 * FROM 发货 A ORDER BY A.送货日期 DESC, A.客户编号 ASC) A INNER JOIN 发货_DETAIL AS B ON A.ExcelServerRCID = B.ExcelServerRCID ORDER BY A.送货日期 DESC ,A.客户编号 ASC ,B.编号 ASC"; var constr = "server=www.skyflag.com,6019;database=pinhua;uid=sa;pwd=benny0922"; var reader1 = SqlHelper.ExecuteReader(constr, CommandType.Text, query1); var reader2 = SqlHelper.ExecuteReader(constr, CommandType.Text, query2); while (reader1.Read()) { for (var i = 0; i != reader1.FieldCount; i++) { var sKey = reader1["单号"].ToString(); if (!dict1.ContainsKey(sKey)) { dict1.Add(sKey, reader1.GetName(i) + ":" + reader1[i].ToString() + "\n"); } else { dict1[sKey] += reader1.GetName(i) + ":" + reader1[i].ToString() + "\n"; } } dict1[reader1["单号"].ToString()] += "━━━━━━━━━━━\n"; } while (reader2.Read()) { var sKey = reader2["单号"].ToString(); if (dict1.ContainsKey(sKey)) { dict1[sKey] += "◆" + "\n"; for (var i = 1; i != reader2.FieldCount; i++) { dict1[sKey] += reader2.GetName(i) + ":" + reader2[i].ToString() + "\n"; } } } foreach (string s in dict1.Keys) { var biz = new JsonMessage { touser = RequestMessage.FromUserName, msgtype = "text", agentid = RequestMessage.AgentID.ToString(), text = new JsonMessageInnerType.textcontent { content = dict1[s] }, safe = 0 }; var error = JsonSend.SendQyMessage(postModel.CorpId, postModel.Secret, XLH.SerializeJsonToString(biz), Encoding.UTF8); Debug.Write(error); } } } return(null); }