示例#1
0
        /// <summary>
        /// 同步获取多张比列缩放图片
        /// </summary>
        /// <param name="request"></param>
        /// <returns></returns>
        public object Post(FSScalePicFileListRequest request)
        {
            int errCode = ImageFilesValid(request);

            if (errCode != (int)FS_ErrorCode.Request_Success)
            {
                return new ScalePicFileListModel {
                    ret = errCode,
                    message = ErrorCodeDic.GetInstance().CodeMessage(errCode),
                    picUrls = null
                };
            }

            var response = new ScalePicFileListModel();
            try
            {
                IPictureFileService picSvr = new PictureFileService();
                response = picSvr.ScalePictureFile(request.file_guid, JsonUtil<List<string>>.FromJosn(request.sizes));
            }
            catch (Exception e)
            {
                string err = string.Format("PictureServiceHost.FSScalePicFileListRequest error = {0}, request = {1}", e.ToString(), JsonUtil<FSScalePicFileListRequest>.ToJson(request));
                LogUtil.Error(err);
            }

            return response;
        }
示例#2
0
        private static int ImageFilesValid(FSScalePicFileListRequest request)
        {
            var errCode = (int)FS_ErrorCode.Request_Success;
            var sizes = request.sizes;

            if(string.IsNullOrEmpty(sizes))
            {
                LogUtil.Info("request parameters are lost");
                errCode = (int)FS_ErrorCode.RequestParam_Err;
            }

            var sizeModel = JsonUtil<List<string>>.FromJosn(sizes);
            if (sizeModel == null || sizeModel.Count == 0)
            {
                LogUtil.Info("request parameters are lost");
                errCode = (int)FS_ErrorCode.RequestParam_Err;
            }
            if (sizeModel != null && sizeModel.Count >= 5)
            {
                LogUtil.Info("request fileSize are too much");
                errCode = (int)FS_ErrorCode.RequestParam_Err;
            }

            foreach (var str in sizeModel)
            {
                if (!str.Contains("_"))
                {
                    errCode = (int)FS_ErrorCode.RequestParam_Err;
                    LogUtil.Info("request parameters are lost");
                    break;
                }
                if (str.Split('_').Length <= 2) continue;
                errCode = (int)FS_ErrorCode.RequestParam_Err;
                LogUtil.Info("request parameters are lost");
                break;
            }

            return errCode;
        }