Пример #1
0
 public JsonResult Put(WX_QR_Code _t)
 {
     IWX_QR_CodeService service = WMFactory.WX_QR_Code;
     WX_QR_Code entity = service.GetById(_t.Id.ToString());
     entity = AutoMapper<WX_QR_Code, WX_QR_Code>.Convert(_t, entity);
     if (service.Update(entity))
         return Json(ResultMsg.Success("更新成功!"));
     else
         return Json(ResultMsg.Failure("更新失败,请您重试!"));
 }
Пример #2
0
 public JsonResult Post(WX_QR_Code _t)
 {
     if (WMFactory.WX_QR_Code.Insert(_t))
     {
         int iScene_id = _t.Scene_ID;
         string action_name = _t.Action_Name;
         string sceneJson = " { \"action_name\": \"" + action_name + "\", \"action_info\": {\"scene\": {\"scene_id\": " + iScene_id + "}}}";
         string sid = _t.AccountId.ToString();
         string url = ElegantWM.WeiXin.Common.Qr_limit_scene(sid, sceneJson, iScene_id);
         if (!string.IsNullOrEmpty(url))
         {
             return Json(ResultMsg.Success("新增成功!"));
         }
         else
         {
             return Json(ResultMsg.Failure("新增失败,请您重试!"));
         }
     }
     else
         return Json(ResultMsg.Failure("新增失败,请您重试!"));
 }
Пример #3
0
        /// <summary>
        /// 永久二维码
        /// </summary>
        /// <param name="sid"></param>
        /// <param name="mediaJson"></param> 
        /// <param name="path"></param>
        public static string Qr_limit_scene(string sid, string sceneJson, int iScene_id)
        {
            string url = "https://api.weixin.qq.com/cgi-bin/qrcode/create?access_token=" + GetTokenId(sid);
            string rst = HttpCrossDomain.Post(url, sceneJson);
            if (rst.Contains("errcode"))
            {
                throw new Exception(rst);
            }
            else
            {
                WxTicket ticket = JsonMapper.ToObject<WxTicket>(rst);
                url = "https://mp.weixin.qq.com/cgi-bin/showqrcode?ticket=" + ticket.ticket;

                Guid QRSid = Guid.Parse(sid);
                IEnumerable<WX_QR_Code> ScanCodes = WMFactory.WX_QR_Code.FindByConditions(null, f => f.AccountId == QRSid && f.Scene_ID == iScene_id, null);
                WX_QR_Code Scan = new WX_QR_Code();
                Scan = ScanCodes.FirstOrDefault();
                Scan.ModifyTime = System.DateTime.Now;
                Scan.Url = url;
                WMFactory.WX_QR_Code.Update(Scan);
                return url;
            }
        }