SHARE
TWEET

Untitled

a guest Jun 8th, 2017 83 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1.         public static bool GuiHoSoGiamDinh(string content,ref string message)
  2.         {
  3.             ApiGuiHoSoGiamDinh apiGuiHoSoGiamDinh = new ApiGuiHoSoGiamDinh();
  4.             var username = Setting.DataBaseSetting.WebService917UserName.Trim();
  5.             var password = Setting.DataBaseSetting.WebService917Password.Trim();
  6.             var token = GetToken(username, password);
  7.             if (token == null)
  8.             {
  9.                 message = $"Lỗi không xác thực được";
  10.                 return false;
  11.             }
  12.  
  13.             apiGuiHoSoGiamDinh.token = token.access_token;
  14.             apiGuiHoSoGiamDinh.id_token = token.id_token;
  15.             apiGuiHoSoGiamDinh.username = username;
  16.             apiGuiHoSoGiamDinh.password = Utilities.StringUtilities.CreateMD5(password);
  17.             apiGuiHoSoGiamDinh.loaiHoSo = 3;
  18.             apiGuiHoSoGiamDinh.maCSKCB = "01907";
  19.             apiGuiHoSoGiamDinh.fileHS = Encoding.UTF8.GetBytes(content);
  20.            
  21.             using (var client = new HttpClient())
  22.             {
  23.                 client.BaseAddress = new Uri(Setting.DataBaseSetting.WebService917Location);
  24.                 client.DefaultRequestHeaders.Accept.Clear();
  25.                 client.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json"));
  26.                 client.MaxResponseContentBufferSize = 2000005000;
  27.                 client.Timeout = new TimeSpan(1, 1, 1, 1);
  28.                 var javaScriptSerializer = new JavaScriptSerializer();
  29.                 javaScriptSerializer.MaxJsonLength = int.MaxValue;
  30.                 var response = client.PostAsync("api/egw/guiHoSoGiamDinh",
  31.                     new StringContent(javaScriptSerializer.Serialize(apiGuiHoSoGiamDinh), Encoding.UTF8,
  32.                     "application/json")).Result;
  33.                 if (!response.IsSuccessStatusCode) return false;
  34.                 var result = response.Content.ReadAsStringAsync().Result;
  35.                 var kqua = JsonConvert.DeserializeObject<KQGuiHoSoGiamDinh>(result);
  36.                 if (kqua.maKetQua == "200")
  37.                 {
  38.                     //message =  $"Gửi kết quả thành công: Mã Giao Dịch - {kqua.maGiaoDich}";
  39.                     message =  kqua.maGiaoDich;
  40.                     return true;
  41.                 }
  42.                 message = $"Gửi không thành công: Mã Lỗi {kqua.maKetQua}";
  43.                 return false;
  44.             }
  45.         }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top