示例#1
0
        public bool UploadInspect(List <RequestUserInspectResultDTO> inspects)
        {
            var config      = SysConfigRepository.Get <Inspect>();
            var storeConfig = SysConfigRepository.Get <IMGStore>();
            var apiConfig   = SysConfigRepository.Get <Common.Config.Consultation>();

            System.Collections.Generic.SortedList <string, string> list = new SortedList <string, string>();
            list.Add("appid", config.AppId);
            list.Add("appkey", config.AppKey);
            list.Add("noncestr", Guid.NewGuid().ToString("N"));
            string sign = WebAPIHelper.GetSign(list);

            list.Remove("appkey");
            list.Add("sign", sign);

            try
            {
                inspects.ForEach(x =>
                {
                    string param = JsonHelper.ToJson(new
                    {
                        fileId      = x.InspectResultID,
                        filePath    = storeConfig.UrlPrefix.TrimEnd('/') + "/" + x.FileUploadName.TrimStart('/'),
                        callBackUrl = apiConfig.ConsultationApiUrl.TrimEnd('/') + "/UploadInspectCallback"
                    });

                    string result = WebAPIHelper.HttpPost(config.UploadFileUrl, param, list);

                    var obj = JsonHelper.FromJson <dynamic>(result);
                    if (obj.error_code != 100)
                    {
                        LogHelper.DefaultLogger.Error(string.Format("影像上传接口:{0},参数:{1},调用异常:{2}",
                                                                    config.UploadFileUrl, param, obj.message));
                    }
                });

                return(true);
            }
            catch (Exception e)
            {
                LogHelper.DefaultLogger.Error(e.Message, e);
                return(false);
            }
        }