public ActionResult Test3() { string media_id = ""; AutoResponse item = wcApi.AutoResponseBLL.GetContentbyQuestion("劳动节"); string _token = CommonBLL.GetAccess_token(); var bgpath = AppDomain.CurrentDomain.BaseDirectory + item.RoomImgPath; bgpath = Server.MapPath(item.RoomImgPath); if (item.type == "image") { var x = MediaBLL.UploadMultimedia(_token, "image", bgpath); media_id = x; } ///获取临时素材 string path = HttpContext.Server.MapPath("~/img/"); MediaBLL.GetMultimedia(_token, media_id, path); FileStream fs = new FileStream(bgpath, FileMode.Open); byte[] data = new byte[fs.Length]; fs.Read(data, 0, data.Length); fs.Close(); fs.Dispose(); var x1 = MediaBLL.UploadMultimedia(_token, "image", "aa.jpg", data); media_id = x1; MediaBLL.GetMultimedia(_token, media_id, path); return(Content(media_id)); }
/// <summary> /// 测试函数 /// </summary> /// <returns></returns> public ActionResult Test() { /// hui_open id "oVWwA044l4_gH37FSmlyqvF04LX0" /// feng_open_id "oVWwA0x8AB3fkTdokUxBflTkVIZk" string openid = "oVWwA044l4_gH37FSmlyqvF04LX0"; string token = CommonBLL.GetAccess_token(); UserInfo user = UserBLL.GetUserDetail(token, openid); UserInfo us = UserBLL.GetUserInfo(user.openid); if (us != null) { us.count = us.count + 1; UserBLL.ModifyUsers(us); } else { UserBLL.SaveUsers(user); } //DataSet ds = DbHelperSQL.Query("select * from UserInfo where openid='" + openid + "'"); //if (ds.Tables[0].Rows.Count > 0) //{ // UserBLL.UpdateUser(new UserInfo() { openid = openid, count = int.Parse(ds.Tables[0].Rows[0]["count"].ToString()) + 1 }); //} //else //{ // UserBLL.AddUser(new UserInfo() { openid = openid,count=0}); //} ///头像流 string touxiangUrl = user.headimgurl; Stream mstouxiang = UserBLL.GetTouxiang(touxiangUrl); ///二维码流 string ticket = QrcodeBLL.Get_QR_STR_SCENE_Qrcode(token, openid); Stream mserweima = QrcodeBLL.GetQrcodeStream(ticket); ///背景图片流 var bgpath = AppDomain.CurrentDomain.BaseDirectory + "\\img\\" + "backGroudImd.jpg"; FileStream fs = new FileStream(bgpath, FileMode.Open); byte[] data = new byte[fs.Length]; fs.Read(data, 0, data.Length); fs.Close(); fs.Dispose(); MemoryStream ms = new MemoryStream(data); ///合成图片 var outsteam = ImgCom.ImgCommon.AddWaterPic(ms, mstouxiang, mserweima, "张辉", "测试内容就是这样"); ///上传图片 string media_id = MediaBLL.UploadMultimedia(token, "image", "hui.jpg", outsteam); ///获取临时素材 string path = HttpContext.Server.MapPath("~/img/"); MediaBLL.GetMultimedia(token, media_id, path); return(Content(media_id)); }