Exemple #1
0
        /// <summary>
        /// 获取单个指定尺寸图片
        /// </summary>
        /// <param name="request"></param>
        /// <returns></returns>
        public object Post(FSScalePicFileRequest request)
        {
            int errCode = ImageFileRequestValid(request);

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

            AsyncFileDownloadResponse response = new AsyncFileDownloadResponse();

            try
            {
                IPictureFileService picSvr = new PictureFileService();
                response = picSvr.ScalePictureFile(request.file_guid, request.width, request.height);
            }
            catch(Exception e)
            {
                string err = string.Format("PictureServiceHost.FSScalePicFileRequest error = {0}, request = {1}", e.ToString(), JsonUtil<FSScalePicFileRequest>.ToJson(request));
                LogUtil.Error(err);
            }

            return response;
        }
Exemple #2
0
        /// <summary>
        /// 有效性校验
        /// </summary>
        /// <param name="request"></param>
        /// <returns></returns>
        private int ImageFileRequestValid(FSScalePicFileRequest request)
        {
            var errCode = (int)FS_ErrorCode.Request_Success;

            if (string.IsNullOrEmpty(request.file_guid) || request.width == 0 || request.height == 0)
            {
                LogUtil.Info("Error: request parameters are lost");
                errCode = (int)FS_ErrorCode.RequestParam_Err;
            }

            return errCode;
        }