public void DeleteForm(string keyValue) { var id = Convert.ToInt64(keyValue); WxText wxText = wxTextRepository.Get(id); wxText.DeletedMark = true; wxText.DeletionTime = DateTime.Now; wxTextRepository.Update(wxText); }
public WxTextOutputDto GetForm(string keyValue) { var id = Convert.ToInt64(keyValue); WxTextOutputDto wxTextOutputDto = new WxTextOutputDto(); WxText wxText = wxTextRepository.Get(id); AutoMapper.Mapper.Map <WxText, WxTextOutputDto>(wxText, wxTextOutputDto); return(wxTextOutputDto); }
public void SubmitForm(WxTextInputDto wxTextInputDto, string keyValue) { string appId = WxOperatorProvider.Provider.GetCurrent().AppId; WxText wxText = new WxText(); if (!string.IsNullOrEmpty(keyValue)) { var id = Convert.ToInt64(keyValue); wxText = wxTextRepository.Get(id); AutoMapper.Mapper.Map <WxTextInputDto, WxText>(wxTextInputDto, wxText); wxText.LastModificationTime = DateTime.Now; wxTextRepository.Update(wxText); } else { AutoMapper.Mapper.Map <WxTextInputDto, WxText>(wxTextInputDto, wxText); wxText.Id = IdWorkerHelper.GenId64(); wxText.AppId = appId; wxText.DeletedMark = false; wxText.CreationTime = DateTime.Now; wxText.CreatorUserId = 1; wxTextRepository.Add(wxText); } }
public string ScanWX() { { string result = ""; string postString = string.Empty; if (Request.HttpMethod.ToUpper() == "POST") { using (Stream stream = System.Web.HttpContext.Current.Request.InputStream) { Byte[] postBytes = new Byte[stream.Length]; stream.Read(postBytes, 0, (Int32)stream.Length); postString = Encoding.UTF8.GetString(postBytes); //postBytes = CommonTool.Base64Decoder.GetDecoded(postString); CommonTool.WriteLog.Write("postString: " + postString); if (!string.IsNullOrEmpty(postString)) { string SendToWx = string.Empty; Dictionary <string, string> dic = CommonTool.JsonHelper.GetParms2(postString); CommonTool.WriteLog.Write("content === " + dic["content"]); byte[] aryData = new Base64Decoder().GetDecoded(dic["content"]); string DE_content = Encoding.UTF8.GetString(aryData); int index = DE_content.IndexOf('{'); DE_content = DE_content.Substring(index); CommonTool.WriteLog.Write("DE_content === " + DE_content); Dictionary <string, string> dic2 = CommonTool.JsonHelper.GetParms2(DE_content); string device_id = dic["device_id"]; string device_type = dic["device_type"]; string msg_id = dic["msg_id"]; string msg_type = dic["msg_type"]; string open_id = dic["open_id"]; string session_id = dic["session_id"]; string bat = dic2["bat"]; string hrs = dic2["hrs"]; string step = dic2["step"]; string lslt = dic2["lslt"]; string dslt = dic2["dslt"]; string btmp = dic2["btmp"]; string hbld = dic2["hbld"]; string lbld = dic2["lbld"]; string oxyg = dic2["oxyg"]; string atmp = dic2["atmp"]; Device dev = new Device(); bool flag = dev.saveDeviceInfo(device_id, device_type, msg_id, msg_type, open_id, session_id, bat, hrs, step, lslt, dslt, btmp, hbld, lbld, oxyg, atmp); if (flag) { User user = new User(); user.AddUser(device_id, open_id); } //这里写方法解析Xml XmlDocument xml = new XmlDocument(); xml.LoadXml(postString); XmlElement xmlElement = xml.DocumentElement; //这里进行判断MsgType switch (xmlElement.SelectSingleNode("//MsgType").InnerText) { case "text": XmlNode content = xmlElement.SelectSingleNode("//Content"); CommonTool.WriteLog.Write("content: " + xmlElement.SelectSingleNode("//Content").InnerText); SendToWx = WxText.GetWxTextXml(postString); break; } if (!string.IsNullOrEmpty(SendToWx)) { System.Web.HttpContext.Current.Response.Write(SendToWx); System.Web.HttpContext.Current.Response.End(); } else { result = "回传数据为空"; CommonTool.WriteLog.Write(result); } } else { result = "微信推送的数据为:" + postString; CommonTool.WriteLog.Write(result); } } } else if (Request.HttpMethod.ToUpper() == "GET") { string token = "qweasdzxc";//从配置文件获取Token if (string.IsNullOrEmpty(token)) { result = string.Format("微信Token配置项没有配置!"); CommonTool.WriteLog.Write(result); } string echoString = System.Web.HttpContext.Current.Request.QueryString["echoStr"]; string signature = System.Web.HttpContext.Current.Request.QueryString["signature"]; string timestamp = System.Web.HttpContext.Current.Request.QueryString["timestamp"]; string nonce = System.Web.HttpContext.Current.Request.QueryString["nonce"]; if (CheckSignature(token, signature, timestamp, nonce)) { if (!string.IsNullOrEmpty(echoString)) { System.Web.HttpContext.Current.Response.Write(echoString); System.Web.HttpContext.Current.Response.End(); result = string.Format("微信Token配置成功,你已成为开发者!"); CommonTool.WriteLog.Write(result + "\t\nechoString:" + echoString + " " + signature + " " + timestamp + " " + nonce); return(echoString); } } } result = string.Format("页面被访问,没有请求数据!"); CommonTool.WriteLog.Write(result); return(result); } }