using System; using System.IO; using System.Net; using System.Text; using System.Web.Mvc; using WX.CRM.BLL.Wx; using WX.CRM.Common; using WX.CRM.IBLL.Ord; using WX.CRM.IBLL.RedisBL; using WX.CRM.Model.Entity; using WX.CRM.WebHelper.RedisFactory; namespace WX.CRM.WEB.Controllers { public class WebTestController : Controller { // // GET: /WebTest/ IReadOrWriteFromRedis redisBl; IORD_SALEMEMO ordBl; ValidationErrors errors = new ValidationErrors(); RedisFactory redisFactory = new RedisFactory(); public WebTestController(IReadOrWriteFromRedis _redisBl, IORD_SALEMEMO _ordBl) { redisBl = _redisBl; ordBl = _ordBl; } public ActionResult Index() { //ViewBag.startdate = System.DateTime.Now.ToString(); //ViewBag.result = System.Guid.NewGuid().ToString(); ////LogHelper.Error("start----------------------------------"); //var endtime=System.DateTime.Now.AddMinutes(2); //decimal c = 0; //threadTest(); ////do ////{ //// c++; //// threadTest(); ////} while (endtime >= System.DateTime.Now); //ViewBag.execount = c; //ViewBag.enddate = System.DateTime.Now.ToString(); //var _url = "http://192.168.1.68/goip_post_sms.html?username=root&password=root"; var _url = "http://localhost:10229/WebTest"; var para = "{\"type\":\"send-sms\",\"task_num\":1,\"tasks\":[{\"tid\":1,\"from\":\"1\",\"to\":\"13416115228\",\"sms\":\"测试短信\"}]}"; HttpWebRequest request = null; request = WebRequest.Create(_url) as HttpWebRequest; request.Method = "POST"; //request.ContentType = "application/json;charset=utf-8"; request.ContentType = "application/json"; //如果需要POST数据 if (!string.IsNullOrEmpty(para)) { byte[] data = Encoding.UTF8.GetBytes(para.ToString()); request.ContentLength = data.Length; using (Stream stream = request.GetRequestStream()) { stream.Write(data, 0, data.Length); } } using (HttpWebResponse response = (HttpWebResponse)request.GetResponse()) { StreamReader reader = new StreamReader(response.GetResponseStream(), Encoding.UTF8); string result = reader.ReadToEnd(); LogHelper.Info(result); } return View(); } [HttpPost] public JsonResult Index(string username, string password, string type) { var stream = Request.InputStream; stream.Position = 0; using (var streamReader = new StreamReader(stream, Encoding.UTF8)) { var result = streamReader.ReadToEndAsync().Result; stream.Position = 0; LogHelper.Info(result); } return Json(new { username, password, type }); } public JsonResult UnPayTest() { ValidationErrors errors = new ValidationErrors(); SzzyOrderResult result = new SzzyOrderResult(); WX_SZZYORDER_BL wx_SzzyOrder_BL = new WX_SZZYORDER_BL(); WX.CRM.BLL.Util.CACHE_BL cache_BL = new WX.CRM.BLL.Util.CACHE_BL(); var str = cache_BL.GetValue_Parameter(WX.CRM.Model.Enum.Parameter.WeiXIn_SzzyOrderUnPayDayInterval); int m = 1; int.TryParse(str, out m); var list = wx_SzzyOrder_BL.GetUnPayList(m); return Json(list, JsonRequestBehavior.AllowGet); } #region test void threadTest() { try { System.Threading.Thread t = new System.Threading.Thread(test); t.Start(); } catch { } } void test() { try { //CACHE_ORD_MEMO entity = new CACHE_ORD_MEMO(); //entity.MEMOID = 120042038921; //entity.CTIME = System.DateTime.Now; //entity.CALLTIME = System.DateTime.Now; //entity.RESID = "003710133142621438"; //customerbl.AddRedis_CacheOrdMemo(entity); ORD_SALEMEMO model = new ORD_SALEMEMO(); model.INNERUSERID = 10000; model.CTIME = DateTime.Now; model.STRCONTENT = "test"; model.RESID = "199613568558935523"; model.MEMOSTYLEID = 600006345; model.MEMOTYPEID = 902; model.MEMOSUBTYPEID = 9021; model.BUSINESSID = 1; bool result = ordBl.Create(ref errors, model); //List list = redisFactory.LoadMemo("199613568558935523",""); //GJS_CUSTOMER gjs_customerModel = redisFactory.GetInfo_Gjscustomer("045440707"); //gjs_customerModel.SALEUSERID = 600006167; //gjs_customerModel.TRADERUSERID = 600006166; //gjs_customerModel.MANAGERUSERID = 1209743559; //redisFactory.Add_Gjscustomer(gjs_customerModel); } catch (Exception ex) { LogHelper.Error("添加销售工单出错:" + ex.Message.ToString() + ex.StackTrace.ToString()); } } #endregion } }