/// <summary>
        /// 视频消息文件的缩略图
        /// </summary>
        /// <returns></returns>
        public ActionResult MessageThumbFile()
        {
            FileDownloadQueueWithMediaIdResult args = RequestArgs <FileDownloadQueueWithMediaIdResult>();

            if (args == null)
            {
                return(RespondResult(false, "参数无效。"));
            }

            _messageManager.MessageThumbFile(args);

            return(RespondResult());
        }
        public void MessageThumbFile(FileDownloadQueueWithMediaIdResult args)
        {
            Guid messageId = Guid.Parse(args.Tag);

            SqlStructureBuild sqlBuild = new SqlStructureBuild();

            sqlBuild.Table = "Message";
            sqlBuild.Type  = SqlExpressionType.Update;
            sqlBuild.AddParameter("Id", messageId, true);
            sqlBuild.AddParameter("ThumbContentType", args.ContentType);
            sqlBuild.AddParameter("ThumbUrl", _fileService.FileServiceUri + args.OutputFile);
            sqlBuild.AddParameter("ThumbLength", args.FileLength);
            _dataBase.ExcuteSqlExpression(sqlBuild.GetSqlExpression());
        }
        private void Download(FileDownloadQueueEntity item)
        {
            _log.Write("下载队列中的文件", JsonConvert.SerializeObject(item), TraceEventType.Verbose);

            DomainContext domainContext = _fileDomainPool.GetDomainContext(item.Domain);

            if (domainContext == null)
            {
                item.Status     = FileDownloadQueueItemStatus.Done;
                item.Success    = false;
                item.Message    = "无效域";
                item.FinishTime = DateTime.Now;
                _dataBase.Update(item);
                return;
            }

            string targetDir = Path.Combine(_serverRootDir, "FileStore", item.Domain.ToString());

            if (Directory.Exists(targetDir) == false)
            {
                Directory.CreateDirectory(targetDir);
            }

            string accessToken = domainContext.AccessToken;

            HttpDownloadArgs downloadArgs = new HttpDownloadArgs();

            downloadArgs.Url = String.Format(
                "http://file.api.weixin.qq.com/cgi-bin/media/get?access_token={0}&media_id={1}",
                accessToken, item.MediaId);
            downloadArgs.TargetDir = targetDir;

            HttpDownloadResult downloadResult = _httpService.Download(downloadArgs);

            if (downloadResult.Success == false)
            {
                item.Status     = FileDownloadQueueItemStatus.Done;
                item.Success    = false;
                item.Message    = "下载失败:" + downloadResult.Message;
                item.FinishTime = DateTime.Now;
                _dataBase.Update(item);
                return;
            }

            item.Status      = FileDownloadQueueItemStatus.Done;
            item.Success     = downloadResult.Success;
            item.Message     = downloadResult.Message;
            item.OutputFile  = String.Format("FileStore/{0}/{1}", item.Domain, downloadResult.StoreFileName);
            item.ContentType = downloadResult.ContentType;
            item.FileLength  = (int)(downloadResult.FileLength / 1024);

            FileDownloadQueueWithMediaIdResult result = new FileDownloadQueueWithMediaIdResult();

            result.Success     = item.Success;
            result.Message     = item.Message;
            result.OutputFile  = item.OutputFile;
            result.ContentType = item.ContentType;
            result.Tag         = item.Tag;
            result.MediaId     = item.MediaId;
            result.FileLength  = item.FileLength;

            _log.Write("下载队列中的文件返回(WithMediaId)", JsonConvert.SerializeObject(result), TraceEventType.Verbose);

            //把下载结果POST到回调地址上
            HttpRequestArgs requestArgs = new HttpRequestArgs();

            requestArgs.Method  = "POST";
            requestArgs.Url     = item.CallbackUrl;
            requestArgs.Content = JsonConvert.SerializeObject(result);

            HttpRequestResult requestResult = _httpService.Request(requestArgs);

            if (requestResult.Success)
            {
                ApiResult callbackApiResult = JsonConvert.DeserializeObject <ApiResult>(requestResult.Content);
                if (callbackApiResult.Success == false)
                {
                    item.Status     = FileDownloadQueueItemStatus.Done;
                    item.Success    = false;
                    item.Message    = "回调失败:" + callbackApiResult.Message;
                    item.FinishTime = DateTime.Now;
                }
            }
            else
            {
                item.Status     = FileDownloadQueueItemStatus.Done;
                item.Success    = false;
                item.Message    = "回调失败:" + requestResult.Exception.Message;
                item.FinishTime = DateTime.Now;
            }

            _dataBase.Update(item);
        }