Exemple #1
0
 public static void GetToken()
 {
     try
     {
         var timeStamp           = TimeStamp;
         var requestData         = string.Format("companyid={0}&timestamp={1}&key={2}", companyId, timeStamp, key);
         var sign                = (requestData).StringToMD5Hash().ToUpper();
         var requestData2        = string.Format("companyId={0}&timeStamp={1}", companyId, timeStamp);
         var requestDataWithSign = requestData2 + "&signature=" + sign;
         var res = HttpClientHelperCommon.Get(string.Format("{0}/AIOLogin?{1}", url, requestDataWithSign), null, false, 30);
         Token = JsonConvert.DeserializeObject <TokenACResponse>(res).data;
         Log.Info("Token: " + Token);
     }
     catch (Exception ex)
     {
         Log.Fatal(ex.Message + Environment.NewLine + ex.StackTrace);
         throw new Exception("获取Token异常");
     }
 }
Exemple #2
0
        public static void UploadFile()
        {
            try
            {
                var token_req            = TokenService.Token;
                var companyId_req        = Config.companyId;
                var key_req              = Config.key;
                var caseId               = UploadFileForm.docNo;
                var caseInfo             = "";
                var priorityNo           = "0";
                var timeStamp            = DateTime.Now.Ticks;
                var signature_before_cal = "token=" + token_req + "&" +
                                           "companyId=" + companyId_req + "&" +
                                           "caseId=" + caseId + "&" +
                                           "caseInfo=" + caseInfo + "&" +
                                           "priorityNo=" + priorityNo + "&" +
                                           "timeStamp=" + timeStamp + "&key=" + key_req;
                var signature = signature_before_cal.StringToMD5Hash().ToUpper();
                //暂时不处理
                string        _caseImagesPath = "";
                DirectoryInfo di     = new DirectoryInfo(_caseImagesPath);
                var           images = new List <string>();
                foreach (var item in di.GetFiles())
                {
                    images.Add(item.Name);
                }
                var postDataModel = new
                {
                    token      = token_req,
                    companyId  = companyId_req,
                    caseId     = caseId,
                    caseInfo   = caseInfo,
                    priorityNo = priorityNo,
                    images     = images,
                    timeStamp  = timeStamp,
                    signature  = signature
                };

                var postData = postDataModel.SerializeObject();

                var res = HttpClientHelperCommon.Post(Config.Url_upload, postData);

                //Log.Info("请求地址:" + url_upload + Environment.NewLine + JsonConvert.SerializeObject(postData));
                JObject obj = JObject.Parse(res);

                //Log.Info(obj["message"].ToString());

                if (obj["code"].ToString() == "0")
                {
                    // label2.Text = "赔案信息上传到安诚成功!";
                }
                else
                {
                    //label2.Text = obj["message"].ToString();
                }
            }
            catch (Exception ex)
            {
                //Log.Fatal(ex.Message + Environment.NewLine + ex.StackTrace);
            }
        }