Beispiel #1
0
        /// <summary>
        /// 图片及寄语页面
        /// </summary>
        /// <returns></returns>
        public ActionResult Chartlet()
        {
            try
            {
                var config = WXUtil.GetJsSdkConfig();
                ViewBag.JsSdkConfig = config;
            }
            catch (Exception ex)
            {
                LogHelper.Error(ex);
            }

            return(View());
        }
        public mChartlet.Chartlet GenerateChartlet(string serverID, string msg, string signName)
        {
            try
            {
                if (string.IsNullOrEmpty(serverID))
                {
                    return(null);
                }
                using (EFContext context = new EFContext())
                {
                    var charlet = new mChartlet.Chartlet
                    {
                        ServerIDWX = serverID,
                        MsgText    = msg,
                        SignName   = signName,
                    };

                    // 从微信服务器下载图片
                    var oriImgPath = WXUtil.DownloadFile(serverID, ".jpg");
                    if (oriImgPath == null)
                    {
                        return(null);
                    }
                    charlet.OriginalImgPath = oriImgPath;

                    // 生成图片
                    var suc = DrawChartlet(charlet);
                    if (!suc)
                    {
                        return(null);
                    }

                    charlet.CreateDate = DateTime.Now;
                    context.Chartlets.Add(charlet);
                    context.SaveChanges();

                    return(charlet);
                }
            }
            catch (Exception ex)
            {
                LogHelper.Error(ex);
                return(null);
            }
        }
        public ActionResult AuthWX()
        {
            var msg = WXUtil.GetReplyMsg();

            return(Content(msg));
        }