Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public static bool GuiHoSoGiamDinh(string content,ref string message)
- {
- ApiGuiHoSoGiamDinh apiGuiHoSoGiamDinh = new ApiGuiHoSoGiamDinh();
- var username = Setting.DataBaseSetting.WebService917UserName.Trim();
- var password = Setting.DataBaseSetting.WebService917Password.Trim();
- var token = GetToken(username, password);
- if (token == null)
- {
- message = $"Lỗi không xác thực được";
- return false;
- }
- apiGuiHoSoGiamDinh.token = token.access_token;
- apiGuiHoSoGiamDinh.id_token = token.id_token;
- apiGuiHoSoGiamDinh.username = username;
- apiGuiHoSoGiamDinh.password = Utilities.StringUtilities.CreateMD5(password);
- apiGuiHoSoGiamDinh.loaiHoSo = 3;
- apiGuiHoSoGiamDinh.maCSKCB = "01907";
- apiGuiHoSoGiamDinh.fileHS = Encoding.UTF8.GetBytes(content);
- using (var client = new HttpClient())
- {
- client.BaseAddress = new Uri(Setting.DataBaseSetting.WebService917Location);
- client.DefaultRequestHeaders.Accept.Clear();
- client.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json"));
- client.MaxResponseContentBufferSize = 2000005000;
- client.Timeout = new TimeSpan(1, 1, 1, 1);
- var javaScriptSerializer = new JavaScriptSerializer();
- javaScriptSerializer.MaxJsonLength = int.MaxValue;
- var response = client.PostAsync("api/egw/guiHoSoGiamDinh",
- new StringContent(javaScriptSerializer.Serialize(apiGuiHoSoGiamDinh), Encoding.UTF8,
- "application/json")).Result;
- if (!response.IsSuccessStatusCode) return false;
- var result = response.Content.ReadAsStringAsync().Result;
- var kqua = JsonConvert.DeserializeObject<KQGuiHoSoGiamDinh>(result);
- if (kqua.maKetQua == "200")
- {
- //message = $"Gửi kết quả thành công: Mã Giao Dịch - {kqua.maGiaoDich}";
- message = kqua.maGiaoDich;
- return true;
- }
- message = $"Gửi không thành công: Mã Lỗi {kqua.maKetQua}";
- return false;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement