public HttpResponseMessage AddMultiple([FromBody] AddMultipleRequest request)
        {
            BaseViewModel viewModel = new BaseViewModel();

            if (request == null)
            {
                viewModel.BusinessStatus = -10000;
                viewModel.StatusMessage  = "参数为空";
                return(viewModel.ResponseToJson());
            }
            try
            {
                AddMultipleInput input = new AddMultipleInput
                {
                    BuId    = request.BuId,
                    UrlList = request.ImgList.FromJson <List <UrlAndType> >()
                };
                return(_pictureService.AddMultiple(input).ResponseToJson());
            }
            catch
            {
                viewModel.BusinessStatus = -10000;
                viewModel.StatusMessage  = "ImgList格式错误,格式要求:[{\"Url\":\" / 1900 / 01 / 01 / xx.jpg\",\"Type\":\"T01\"},{\"Url\":\" / 1900 / 01 / 01 / xx1.jpg\",\"Type\":\"T01\"}]";
            }
            return(viewModel.ResponseToJson());
        }
        public UploadMultipleViewModel UploadMultipleImg(UploadMultipleImgRequest request)
        {
            UploadMultipleViewModel viewModel = new UploadMultipleViewModel();

            try
            {
                //验证
                var validate = _uploadImgValidate.Validate(request);
                if (validate.BusinessStatus != 1)
                {
                    //参数校验失败,返回对应结果
                    viewModel.BusinessStatus = validate.BusinessStatus;
                    viewModel.StatusMessage  = validate.StatusMessage;
                    return(viewModel);
                }

                //上传逻辑
                bool isOk = true;
                List <UrlAndType> listImg = new List <UrlAndType>();
                List <UploadMultipleFileResult> listResult = new List <UploadMultipleFileResult>();
                //上传的图片
                List <BaseContect> dic = request.ListBaseContect;
                foreach (var item in dic)
                {
                    string upImgUrl = string.Empty;
                    //获取图片路径
                    if (item.IsUpload == 1)
                    {//无需上传
                        upImgUrl = item.StrBase;
                    }
                    else if (item.IsUpload == 0)
                    {//需要上传
                        string base64   = item.StrBase.Substring(item.StrBase.IndexOf(',') + 1);
                        byte[] data     = Convert.FromBase64String(base64);
                        var    versions = new Dictionary <string, string>();
                        versions.Add("_large", "maxwidth=600&maxheight=400&format=jpg");
                        var fileUploadModel = new FileUploadModel
                        {
                            FileName   = "xxxxx.jpg",
                            VersionKey = versions
                        };
                        //上传图片至服务器
                        var      dw      = new DynamicWebService();
                        object[] postArg = new object[2];
                        postArg[0] = fileUploadModel.ToJson();
                        postArg[1] = data;
                        var ret = dw.InvokeWebservice(
                            _imageUpload + "/fileuploadcenter.asmx", "BiHuManBu.ServerCenter.FileUploadCenter",
                            "FileUploadCenter", "ImageUpload", postArg);

                        UploadMultipleFileResult itemResult = ret.ToString().FromJson <UploadMultipleFileResult>();
                        //itemResult.Index = item.ImgId;//item.Key;
                        itemResult.ImgType = item.ImgType;
                        listResult.Add(itemResult);

                        if (itemResult.ResultCode == 0)
                        {
                            upImgUrl = itemResult.FilePath;
                        }
                        else
                        {
                            isOk = false;
                        }
                    }
                    //将图片Url保存到List中,存库
                    UrlAndType imgUrl = new UrlAndType
                    {
                        Url  = upImgUrl.Contains(_uploadImgUrl) ? upImgUrl : _uploadImgUrl + upImgUrl,
                        Type = item.ImgType
                    };
                    listImg.Add(imgUrl);
                }
                viewModel.ListResult = listResult;
                if (!isOk)
                {
                    viewModel.BusinessStatus = -10002;
                    viewModel.StatusMessage  = "某个图片上传失败,具体内容查看ListResult";
                }
                else
                {
                    var redisKey     = "UpImgTimes_" + request.BuId;
                    var times        = CacheProvider.Get <int?>(redisKey);
                    int alreadyTimes = times.HasValue ? times.Value : 0;
                    //修改redis中的上传次数
                    if (_upImgCount != 0)
                    {//如果=0,没有上传限制
                        _updateImgTimes.UpdateTimes(request.BuId, ++alreadyTimes);
                    }
                    AddMultipleInput input = new AddMultipleInput
                    {
                        BuId    = request.BuId,
                        UrlList = listImg,
                        Source  = request.Source
                    };
                    logInfo.Info("请求图片请求:" + input.ToJson());
                    var upImg = _pictureService.AddMultiple(input);
                    var re    = new UploadMultipleViewModel()
                    {
                        BusinessStatus = upImg.BusinessStatus,
                        StatusMessage  = upImg.StatusMessage,
                        UrlList        = listImg
                    };
                    return(re);
                }
            }
            catch (Exception ex)
            {
                viewModel.BusinessStatus = -10003;
                viewModel.StatusMessage  = "图片上传异常";
                logError.Info("获取报价单详情接口发生异常:" + ex.Source + "\n" + ex.StackTrace + "\n" + ex.Message + "\n" + ex.InnerException);
            }
            return(null);
        }