public ActionResult InitSupplyModule(string col, string name, int?pos) { if (DateTime.Now > new DateTime(2015, 5, 11)) { return(Content("Expired")); } IConnectionManager cm = new ConnectionManager(ConfigurationManager.ConnectionStrings["Gungnir"].ConnectionString); using (var conn = cm.OpenConnection()) { SqlParameter parcol = new SqlParameter("@col", col); SqlParameter parnam = new SqlParameter("@name", name); SqlParameter parpos = new SqlParameter("@pos", pos.HasValue ? pos.Value : 0); var sql = "insert into gungnir..tbl_advertise(adcolumnid,name,position,begindatetime,EndDateTime,Image,Url,ShowType,State,CreateDateTime,LastUpdateDateTime,Platform,FunctionID,TopPicture,AdType,ProductID) values(@col,@name,@pos,'2015-01-16', '2015-01-16','http://wxbanner.qiniudn.com/wxbanner_775615a0-127a-4123-a266-4053b6932d6c.png','http://huodong.tuhu.cn/by/details.html',0,1,'2015-01-16','2015-01-16',4,'cn.TuHu.Activity.AutomotiveProducts.AutomotiveProductsWebViewUI|cn.TuHu.Activity.WashShopUI','',0,'')"; var n = SqlHelper.ExecuteNonQuery(conn, CommandType.Text, sql, parcol, parnam, parpos); WebLog.LogInfo("Add Index Config: " + User.Identity.Name); return(Content("ok " + n.ToString())); } }
public ActionResult CreateCard(WeixinCardModel model, string command) { string resultstr = string.Empty; try { if (Request.QueryString["supplierId"] != null) { List <SupplierInfo> supplierInfoList = WeiXinCardManager.GetSupplierInfo(Convert.ToInt32(Request.QueryString["supplierId"])); if (supplierInfoList != null && supplierInfoList.FirstOrDefault() != null) { var supplier = supplierInfoList.First(); model.total_info.base_info.brand_name = supplier.brand_name; model.total_info.base_info.logo_url = supplier.logo_url; model.total_info.base_info.supplierId = supplier.pkid; } } TimeSpan startts = model.total_info.base_info.date_info.begin_time - new DateTime(1970, 1, 1); TimeSpan endts = model.total_info.base_info.date_info.end_time - new DateTime(1970, 1, 1); model.total_info.base_info.date_info.begin_timestamp = Convert.ToUInt64(startts.TotalSeconds); model.total_info.base_info.date_info.end_timestamp = Convert.ToUInt64(endts.TotalSeconds); if (command.Equals("Save/Update")) { int result = 0; string requestmodelstr = JsonConvert.SerializeObject(model, Newtonsoft.Json.Formatting.None, new JsonSerializerSettings { //DefaultValueHandling = DefaultValueHandling.Ignore, NullValueHandling = NullValueHandling.Ignore }); var log = requestmodelstr.Replace("{", "").Replace("}", ""); WebLog.LogInfo(log); if (string.IsNullOrWhiteSpace(model.card_id)) { result = WeiXinCardManager.SaveWeiXinCard(model); } else { result = WeiXinCardManager.UpdateWeiXinCard(model); } if (result > 0) { resultstr = "操作成功"; } } else if (command.Equals("Submit")) { string jsonrequststr = GetJsonStr(model); var loginfo = jsonrequststr.Replace("{", "").Replace("}", ""); WebLog.LogInfo(loginfo); AccessTokenModel tokenobj = GetAccess_tokenAsCache(); string token = string.Empty; if (tokenobj != null && !string.IsNullOrWhiteSpace(tokenobj.Access_token)) { token = tokenobj.Access_token; } var result = GetWeixinCardResponse("https://api.weixin.qq.com/card/create", token, jsonrequststr); JObject weixincardobj = JsonConvert.DeserializeObject(result) as JObject; if (weixincardobj != null && weixincardobj["errcode"] != null) //&&Convert.ToInt32(weixincardobj["errcode"])==0 && weixincardobj["card_id"] != null) { if (Convert.ToInt32(weixincardobj["errcode"]) == 0 && weixincardobj["card_id"] != null) { model.card_id = weixincardobj["card_id"].ToString(); WeiXinCardManager.SaveWeiXinCard(model); resultstr = "提交成功"; } else if (weixincardobj["errmsg"] != null) { resultstr = "提交失败,失败原因:" + weixincardobj["errmsg"].ToString(); } } } else if (command.Equals("Switch to CardList")) { return(RedirectToAction("CardList")); } } catch (Exception ex) { resultstr = ex.Message; } return(Json(resultstr, JsonRequestBehavior.AllowGet)); }