Exemplo n.º 1
0
        public JsonResult UploadImageFromWeixinJssdk(string serverId)
        {
            try
            {
                //Save new picture

                var tempFileName = DateTime.Now.ToString("yyyyMMddHHmmssfff") + ".jpg";
                var tempFilePath = Path.Combine(_appFolders.UploadImageFolder, tempFileName);
                _weiXinApi.DownImageFromWeixinServer(serverId, tempFilePath);
                string host = this.Request.Url.Scheme + "" + "://" + this.Request.Url.Authority.Replace(":80", "");

                using (var bmpImage = new Bitmap(tempFilePath))
                {
                    return(Json(new AjaxResponse(new { host = host, fileName = tempFileName, width = bmpImage.Width, height = bmpImage.Height })));
                }
            }
            catch (UserFriendlyException ex)
            {
                return(Json(new AjaxResponse(new ErrorInfo(ex.Message))));
            }
        }