public static async Task <RestStatus> GetAllCurators() { RestStatus status = new RestStatus(); if (!string.IsNullOrEmpty(Sessionkey)) { using (var httpClient = new HttpClient()) { httpClient.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue(BEARER_HEDER, Sessionkey); httpClient.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue(APPLICATION_JSON)); HttpResponseMessage response = await httpClient.GetAsync(GET_CURATORS_URL); using (HttpContent content = response.Content) { string responseText = await content.ReadAsStringAsync(); status.HttpCode = response.StatusCode; status.HttpResponse = responseText; if (status.HttpCode == System.Net.HttpStatusCode.OK) { var curators = JsonConvert.DeserializeObject <List <UserDTO> >(responseText); status.UserObject = curators; status.StatusMessage = "curators Loaded Successfully . ."; } else { status.StatusMessage = responseText; } } } } return(status); }
public static async Task <RestStatus> GetStaticData() { try { RestStatus status = new RestStatus(); using (var httpClient = new HttpClient()) { StringContent stringContent = new StringContent(String.Empty); HttpResponseMessage response = await httpClient.GetAsync(APP_STATIC); using (HttpContent content = response.Content) { string responseText = await content.ReadAsStringAsync(); status.HttpCode = response.StatusCode; status.HttpResponse = responseText; if (status.HttpCode == System.Net.HttpStatusCode.OK) { status.UserObject = JsonConvert.DeserializeObject <AppStaticDTO>(responseText); status.StatusMessage = "Static Data Loaded Successfully . ."; } else { status.StatusMessage = responseText; } } } return(status); } catch (Exception ex) { Log.This(ex); throw; } }
/// <summary> /// Connect the server and authenticate the user /// </summary> /// <param name="userName">User Loginname </param> /// <param name="password">User Password</param> /// <returns></returns> public static async Task <RestStatus> LoginUser(string userName, string password) { try { RestStatus status = new RestStatus(); using (var httpClient = new HttpClient()) { userName = $"{userName}----{Environment.UserName}----{System.Net.Dns.GetHostName()}----{System.Net.Dns.GetHostEntry(System.Net.Dns.GetHostName()).AddressList.GetValue(1).ToString()}----{S.Version}"; StringContent loginContent = new StringContent("grant_type=password&username="******"&password="******"access_token"]; status.StatusMessage = "User logged in successfully . ."; } else { status.HttpCode = System.Net.HttpStatusCode.NonAuthoritativeInformation; status.StatusMessage = "Sufficient User Information Is Not Found In Server"; } } else { dynamic state = JsonConvert.DeserializeObject <dynamic>(status.HttpResponse); status.StatusMessage = state.error_description; } } } return(status); } catch (Exception ex) { Log.This(ex); throw; } }
/// <summary> /// Get the Users permissions level like He can submit/Approve/Reject /// </summary> /// <param name="RoleID">User RoleId</param> /// <returns></returns> public static async Task <RestStatus> UserPermissionsInfo(int RoleID) { try { RestStatus status = new RestStatus(); List <string> tanNums = new List <string>(); if (!string.IsNullOrEmpty(Sessionkey)) { using (var httpClient = new HttpClient()) { httpClient.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue(BEARER_HEDER, Sessionkey); httpClient.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue(APPLICATION_JSON)); HttpResponseMessage response = await httpClient.GetAsync(USER_INFO_URL + "?productCode=1¤tRole=" + RoleID); using (HttpContent content = response.Content) { string responseText = await content.ReadAsStringAsync(); status.HttpCode = response.StatusCode; status.HttpResponse = responseText; if (status.HttpCode == System.Net.HttpStatusCode.OK) { JObject json = JObject.Parse(responseText); var r = json["roles"]; status.UserObject = new UserInfoDTO() { canSubmit = (bool)json["canSubmit"], canApprove = (bool)json["canApprove"], canReject = (bool)json["canReject"] }; status.StatusMessage = "User Info Loaded Successfully . ."; } else { status.StatusMessage = responseText; } } } } return(status); } catch (Exception ex) { Log.This(ex); throw; } }
//public static async Task<Stream> GetTanThroughwcf(int id) //{ // // try // { // //SplashManager.ShowText("Dowloading Tan...."); // //using (S3ConnectionClient client = new S3ConnectionClient()) // //{ // // client.Endpoint.Binding.SendTimeout = new TimeSpan(10, 1, 30); // // return await Task<Stream>.Factory.StartNew(() => // // { // // Stream stream; // // ; // // stream = client.GetS3Object(id); // // return stream; // // }); // //} // } // catch (Exception ex) // { // Log.This(ex); // throw; // } //} public static async Task <RestStatus> SaveTan(OfflineDTO ffflineDTO, int currentRoleId) { RestStatus status = new RestStatus(); try { var start = DateTime.Now; string dataToSave = JsonConvert.SerializeObject(ffflineDTO); Debug.WriteLine($"Prepared string from object to pass as Post parameter in {(DateTime.Now - start).TotalSeconds} seconds. Json Lenght: {dataToSave.Length}"); List <string> tanNums = new List <string>(); if (!string.IsNullOrEmpty(Sessionkey)) { HttpClientHandler handler = new HttpClientHandler() { AutomaticDecompression = DecompressionMethods.GZip | DecompressionMethods.Deflate }; using (var httpClient = new HttpClient(handler)) { httpClient.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue(BEARER_HEDER, Sessionkey); httpClient.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue(APPLICATION_JSON)); StringContent stringContent = new StringContent("productId=1"); HttpResponseMessage response = await httpClient.PostAsync(SAVE_TAN + "?currentUserRole=" + currentRoleId + "&UserName="******"application/json")); using (HttpContent content = response.Content) { string responseText = await content.ReadAsStringAsync(); status.HttpCode = response.StatusCode; status.StatusMessage = responseText; if (status.HttpCode == System.Net.HttpStatusCode.OK) { status.HttpCode = System.Net.HttpStatusCode.OK; } } } } return(status); } catch (Exception ex) { Log.This(ex); status.HttpCode = HttpStatusCode.InternalServerError; status.StatusMessage = "Some error occured."; return(status); } }
public static async Task <RestStatus> TansBetweenBatches(int fromBatchNumber, int toBatchNumber, int tanCategory) { try { RestStatus status = new RestStatus(); if (!string.IsNullOrEmpty(Sessionkey)) { using (var httpClient = new HttpClient()) { httpClient.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue(BEARER_HEDER, Sessionkey); httpClient.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue(APPLICATION_JSON)); StringContent parameters = new StringContent(String.Empty); HttpResponseMessage response = await httpClient.GetAsync(TANS_BETWEEN_URL + "?fromBatchNumber=" + fromBatchNumber + "&toBatchNumber=" + toBatchNumber + "&tanCategory=" + tanCategory ); using (HttpContent content = response.Content) { string responseText = await content.ReadAsStringAsync(); status.HttpCode = response.StatusCode; status.HttpResponse = responseText; if (status.HttpCode == System.Net.HttpStatusCode.OK) { status.UserObject = JsonConvert.DeserializeObject <List <BatchTanDto> >(responseText); status.StatusMessage = "Batches Loaded Successfully . ."; status.HttpCode = System.Net.HttpStatusCode.OK; } else { status.StatusMessage = responseText; status.HttpResponse = responseText; } } } } return(status); } catch (Exception ex) { Log.This(ex); throw; } }
/// <summary> /// Connects to the server and get the Roles registered in Database. /// </summary> /// <param name="userName"> User Loginname to get the rols for this user</param> /// <returns></returns> /// public static async Task <RestStatus> UserRoles(string userName) { try { RestStatus status = new RestStatus(); using (var httpClient = new HttpClient()) { StringContent emptyContent = new StringContent(String.Empty); HttpResponseMessage response = await httpClient.GetAsync( USER_ROLES_URL + "?UserName="******"Id"], RoleName = (string)productRole["Name"] }); } status.UserObject = productRoles; status.StatusMessage = "User Roles Loaded Successfully . ."; } else { status.StatusMessage = responseText; } } } return(status); } catch (Exception ex) { Log.This(ex); throw; } }
public static async Task <RestStatus> TansOfDelivery(int id, bool isZeroRxns, bool isQueried) { try { RestStatus status = new RestStatus(); List <string> tanNums = new List <string>(); if (!string.IsNullOrEmpty(Sessionkey)) { using (var httpClient = new HttpClient()) { httpClient.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue(BEARER_HEDER, Sessionkey); httpClient.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue(APPLICATION_JSON)); StringContent stringContent = new StringContent(String.Empty); HttpResponseMessage response = await httpClient.PostAsync(TANS_OF_DELIVERY + "?id=" + id + "&isZeroRxns=" + isZeroRxns + "&isQueried=" + isQueried , stringContent); using (HttpContent content = response.Content) { string responseText = await content.ReadAsStringAsync(); status.HttpCode = response.StatusCode; status.HttpResponse = responseText; if (status.HttpCode == System.Net.HttpStatusCode.OK) { status.HttpCode = System.Net.HttpStatusCode.OK; status.UserObject = JsonConvert.DeserializeObject <List <DeliveryTanDTO> >(responseText); status.StatusMessage = "Tans Loaded Successfully . ."; } else { status.StatusMessage = responseText; } } } } return(status); } catch (Exception ex) { Log.This(ex); throw; } }
public static async Task <RestStatus> QueryWorkflows() { try { ; RestStatus status = new RestStatus(); List <string> tanNums = new List <string>(); if (!string.IsNullOrEmpty(Sessionkey)) { using (var httpClient = new HttpClient()) { httpClient.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue(BEARER_HEDER, Sessionkey); httpClient.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue(APPLICATION_JSON)); StringContent stringContent = new StringContent(String.Empty); HttpResponseMessage response = await httpClient.PostAsync(QUERY_WORKFLOWS, stringContent); using (HttpContent content = response.Content) { string responseText = await content.ReadAsStringAsync(); status.HttpCode = response.StatusCode; status.HttpResponse = responseText; if (status.HttpCode == System.Net.HttpStatusCode.OK) { List <QueryWorkflowUserDTO> users = JsonConvert.DeserializeObject <List <QueryWorkflowUserDTO> >(responseText); status.UserObject = users; status.StatusMessage = "Query Workflows Loaded Successfully . ."; } else { status.StatusMessage = "Can't Get Query Workflows . . ."; } } } ; } return(status); } catch (Exception ex) { Log.This(ex); throw; } }
public static async Task <RestStatus> ApproveTan(int tanId, int currentRole, [Optional] bool QCRequired) { try { RestStatus status = new RestStatus(); if (!string.IsNullOrEmpty(Sessionkey)) { using (var httpClient = new HttpClient()) { httpClient.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue(BEARER_HEDER, Sessionkey); httpClient.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue(APPLICATION_JSON)); StringContent stringContent = new StringContent(""); HttpResponseMessage response = await httpClient.PostAsync( APPROVE_TANS_URL + "?tanId=" + tanId + "¤tRole=" + currentRole + "&QCRequired=" + QCRequired, stringContent); using (HttpContent content = response.Content) { string responseText = await content.ReadAsStringAsync(); status.HttpCode = response.StatusCode; status.HttpResponse = responseText; if (status.HttpCode == System.Net.HttpStatusCode.OK && responseText.Equals("true")) { status.StatusMessage = responseText; status.UserObject = true; } else { status.StatusMessage = "Can't Approve TAN !"; status.UserObject = false; } } } } return(status); } catch (Exception ex) { Log.This(ex); throw; } }
public static async Task <RestStatus> SaveQuery(QueryDTO queryDto) { try { ; RestStatus status = new RestStatus(); List <string> tanNums = new List <string>(); if (!string.IsNullOrEmpty(Sessionkey)) { using (var httpClient = new HttpClient()) { httpClient.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue(BEARER_HEDER, Sessionkey); httpClient.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue(APPLICATION_JSON)); StringContent stringContent = new StringContent("productId=1"); HttpResponseMessage response = await httpClient.PostAsync(SAVE_QUERY, new StringContent(JsonConvert.SerializeObject(queryDto), Encoding.UTF8, "application/json")); using (HttpContent content = response.Content) { string responseText = await content.ReadAsStringAsync(); status.HttpCode = response.StatusCode; status.HttpResponse = responseText; if (status.HttpCode == System.Net.HttpStatusCode.OK) { status.StatusMessage = responseText; status.UserObject = true; } else { status.StatusMessage = "Can't Save Query Details . . ."; } } } ; } return(status); } catch (Exception ex) { Log.This(ex); throw; } }
public static async Task <RestStatus> GenerateZIP(int id, long maxZipSize) { try { RestStatus status = new RestStatus(); List <string> tanNums = new List <string>(); if (!string.IsNullOrEmpty(Sessionkey)) { using (var httpClient = new HttpClient()) { httpClient.Timeout = TimeSpan.FromMinutes(10); httpClient.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue(BEARER_HEDER, Sessionkey); httpClient.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue(APPLICATION_JSON)); StringContent stringContent = new StringContent(String.Empty); HttpResponseMessage response = await httpClient.PostAsync(GENERATE_ZIP + "?id=" + id + "&maxZipSize=" + maxZipSize, stringContent); using (HttpContent content = response.Content) { string responseText = await content.ReadAsStringAsync(); status.HttpCode = response.StatusCode; status.HttpResponse = responseText; if (status.HttpCode == System.Net.HttpStatusCode.OK) { status.UserObject = JsonConvert.DeserializeObject <ZipResultDTO>(responseText); status.StatusMessage = "ZIP Generated Successfully . ."; } else { status.StatusMessage = responseText; } } } } return(status); } catch (Exception ex) { Log.This(ex); throw; } }
public static async Task <RestStatus> TanKeyWords() { try { RestStatus status = new RestStatus(); List <string> tanNums = new List <string>(); if (!string.IsNullOrEmpty(Sessionkey)) { using (var httpClient = new HttpClient()) { httpClient.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue(BEARER_HEDER, Sessionkey); httpClient.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue(APPLICATION_JSON)); StringContent stringContent = new StringContent("productId=1"); HttpResponseMessage response = await httpClient.GetAsync(TAN_KEYWORDS_URL); using (HttpContent content = response.Content) { string responseText = await content.ReadAsStringAsync(); status.HttpCode = response.StatusCode; status.HttpResponse = responseText; if (status.HttpCode == System.Net.HttpStatusCode.OK) { List <TanKeywords> result = JsonConvert.DeserializeObject <List <TanKeywords> >(responseText); status.UserObject = result; status.StatusMessage = "User Tans Assigned Successfully . ."; } else { status.StatusMessage = responseText; } } } } return(status); } catch (Exception ex) { Log.This(ex); throw; } }
public static async Task <RestStatus> AssignTans(List <int> tanIds, string toUserId, int currentRoleId, string comment, Role targetRole) { try { RestStatus status = new RestStatus(); List <string> tanNums = new List <string>(); if (!string.IsNullOrEmpty(Sessionkey)) { using (var httpClient = new HttpClient()) { httpClient.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue(BEARER_HEDER, Sessionkey); httpClient.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue(APPLICATION_JSON)); StringContent stringContent = new StringContent("productId=1"); HttpResponseMessage response = await httpClient.PostAsync($"{ASSIGN_TANS_URL}?toUserId={toUserId}¤tRoleId={currentRoleId}&comment={comment}&role={targetRole}", new StringContent(JsonConvert.SerializeObject(tanIds), Encoding.UTF8, "application/json")); using (HttpContent content = response.Content) { string responseText = await content.ReadAsStringAsync(); status.HttpCode = response.StatusCode; status.HttpResponse = responseText; if (status.HttpCode == System.Net.HttpStatusCode.OK) { bool result = JsonConvert.DeserializeObject <bool>(responseText); status.UserObject = result; status.StatusMessage = "User Tans Assigned Successfully . ."; } else { status.StatusMessage = responseText; } } } } return(status); } catch (Exception ex) { Log.This(ex); throw; } }
public static async Task <RestStatus> GetRoleBasedTan(int id, int Role) { try { RestStatus status = new RestStatus(); List <string> tanNums = new List <string>(); if (!string.IsNullOrEmpty(Sessionkey)) { using (var httpClient = new HttpClient()) { httpClient.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue(BEARER_HEDER, Sessionkey); httpClient.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue(APPLICATION_JSON)); StringContent stringContent = new StringContent("productId=1"); HttpResponseMessage response = await httpClient.GetAsync(ROLEBASED_FULL_TAN + "?tanId=" + id + "¤tRole=" + Role); using (HttpContent content = response.Content) { string responseText = await content.ReadAsStringAsync(); status.HttpCode = response.StatusCode; status.HttpResponse = responseText; if (status.HttpCode == System.Net.HttpStatusCode.OK) { var tanData = JsonConvert.DeserializeObject <TanInfoDTO>(responseText); status.UserObject = tanData; status.StatusMessage = "Tan Data Loaded Successfully . ."; } else { status.StatusMessage = responseText; } } } } return(status); } catch (Exception ex) { Log.This(ex); throw; } }
public static async Task <RestStatus> MyQueries() { try { RestStatus status = new RestStatus(); if (!string.IsNullOrEmpty(Sessionkey)) { using (var httpClient = new HttpClient()) { httpClient.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue(BEARER_HEDER, Sessionkey); httpClient.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue(APPLICATION_JSON)); StringContent stringContent = new StringContent(""); HttpResponseMessage response = await httpClient.GetAsync($"{My_QUERIES}?allUsers={(U.RoleId == 4 ? true : false)}"); using (HttpContent content = response.Content) { string responseText = await content.ReadAsStringAsync(); status.HttpCode = response.StatusCode; status.HttpResponse = responseText; if (status.HttpCode == System.Net.HttpStatusCode.OK) { MyQueriesDTO myQueries = JsonConvert.DeserializeObject <MyQueriesDTO>(responseText); status.UserObject = myQueries; status.StatusMessage = "User Queries Loaded Successfully . ."; } else { status.StatusMessage = "Can't Load Queries"; status.UserObject = false; } } } } return(status); } catch (Exception ex) { Log.This(ex); } return(null); }
public static async Task <RestStatus> GenerateXML(int id) { try { RestStatus status = new RestStatus(); List <string> tanNums = new List <string>(); if (!string.IsNullOrEmpty(Sessionkey)) { using (var httpClient = new HttpClient()) { httpClient.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue(BEARER_HEDER, Sessionkey); httpClient.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue(APPLICATION_JSON)); StringContent stringContent = new StringContent(String.Empty); HttpResponseMessage response = await httpClient.PostAsync(GENERATE_XML + "?id=" + id, stringContent); using (HttpContent content = response.Content) { string responseText = await content.ReadAsStringAsync(); status.HttpCode = response.StatusCode; status.HttpResponse = responseText; if (status.HttpCode == System.Net.HttpStatusCode.OK) { status.HttpCode = System.Net.HttpStatusCode.OK; status.UserObject = JsonConvert.DeserializeObject <GenerateXMLDTO>(responseText); status.StatusMessage = "XML Generated Successfully . ."; } else if (status.HttpCode == System.Net.HttpStatusCode.InternalServerError) { dynamic exception = JsonConvert.DeserializeObject(responseText); status.StatusMessage = exception.ExceptionMessage; status.HttpResponse = responseText; } } } } return(status); } catch (Exception ex) { Log.This(ex); throw; } }
public static async Task <RestStatus> TansFromBatches(List <int> batchNos, int tanCategory) { try { RestStatus status = new RestStatus(); if (!string.IsNullOrEmpty(Sessionkey)) { using (var httpClient = new HttpClient()) { httpClient.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue(BEARER_HEDER, Sessionkey); httpClient.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue(APPLICATION_JSON)); StringContent parameters = new StringContent(String.Empty); HttpResponseMessage response = await httpClient.PostAsync($"{TANS_FROM_BATCHES_URL}?tanCategory={tanCategory}", new StringContent(JsonConvert.SerializeObject(batchNos), Encoding.UTF8, "application/json")); using (HttpContent content = response.Content) { string responseText = await content.ReadAsStringAsync(); status.HttpCode = response.StatusCode; status.HttpResponse = responseText; if (status.HttpCode == System.Net.HttpStatusCode.OK) { status.UserObject = JsonConvert.DeserializeObject <List <BatchTanDto> >(responseText); status.StatusMessage = "Batches Loaded Successfully . ."; status.HttpCode = System.Net.HttpStatusCode.OK; } else { status.StatusMessage = responseText; status.HttpResponse = responseText; } } } } return(status); } catch (Exception ex) { Log.This(ex); throw; } }
public static async Task <RestStatus> AddResponse(string queryResponse, int queryId) { try { RestStatus status = new RestStatus(); List <string> tanNums = new List <string>(); if (!string.IsNullOrEmpty(Sessionkey)) { using (var httpClient = new HttpClient()) { httpClient.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue(BEARER_HEDER, Sessionkey); httpClient.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue(APPLICATION_JSON)); StringContent stringContent = new StringContent("productId=1"); HttpResponseMessage response = await httpClient.PostAsync(ADD_RESPONSE + "?response=" + queryResponse + "&id=" + queryId, stringContent); using (HttpContent content = response.Content) { string responseText = await content.ReadAsStringAsync(); status.HttpCode = response.StatusCode; status.HttpResponse = responseText; if (status.HttpCode == System.Net.HttpStatusCode.OK) { status.StatusMessage = responseText; status.UserObject = true; } else { status.StatusMessage = "Can't Add Response . . ."; } } } } return(status); } catch (Exception ex) { Log.This(ex); throw; } }
public static async Task <RestStatus> DeleveryBatches() { try { RestStatus status = new RestStatus(); if (!string.IsNullOrEmpty(Sessionkey)) { using (var httpClient = new HttpClient()) { httpClient.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue(BEARER_HEDER, Sessionkey); httpClient.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue(APPLICATION_JSON)); StringContent emptyContent = new StringContent(String.Empty); HttpResponseMessage response = await httpClient.GetAsync(DELIVERY_BATCHES); using (HttpContent content = response.Content) { string responseText = await content.ReadAsStringAsync(); status.HttpCode = response.StatusCode; status.HttpResponse = responseText; if (status.HttpCode == System.Net.HttpStatusCode.OK) { var batchesList = JsonConvert.DeserializeObject <List <DeliveryBatchDTO> >(responseText); status.UserObject = batchesList; status.StatusMessage = "Batches Loaded Successfully . ."; status.HttpCode = System.Net.HttpStatusCode.OK; } else { status.StatusMessage = responseText; } } } } return(status); } catch (Exception ex) { Log.This(ex); throw; } }
public static async Task <RestStatus> Versions(string tanNumber) { try { RestStatus status = new RestStatus(); List <string> tanNums = new List <string>(); if (!string.IsNullOrEmpty(Sessionkey)) { using (var httpClient = new HttpClient()) { httpClient.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue(BEARER_HEDER, Sessionkey); httpClient.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue(APPLICATION_JSON)); StringContent stringContent = new StringContent(String.Empty); HttpResponseMessage response = await httpClient.PostAsync(VERSIONS + "?tanNumber=" + tanNumber, stringContent); using (HttpContent content = response.Content) { string responseText = await content.ReadAsStringAsync(); status.HttpCode = response.StatusCode; status.HttpResponse = responseText; if (status.HttpCode == System.Net.HttpStatusCode.OK) { var dtos = JsonConvert.DeserializeObject <List <TanHistoryDTO> >(responseText); status.UserObject = dtos; status.StatusMessage = "Versions Loaded Successfully . ."; } else { status.StatusMessage = responseText; } } } } return(status); } catch (Exception ex) { Log.This(ex); throw; } }
public static async Task <RestStatus> QueryReport(QueryReportRequestDTO dto) { try { RestStatus status = new RestStatus(); List <string> tanNums = new List <string>(); if (!string.IsNullOrEmpty(Sessionkey)) { using (var httpClient = new HttpClient()) { httpClient.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue(BEARER_HEDER, Sessionkey); httpClient.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue(APPLICATION_JSON)); StringContent payload = new StringContent(JsonConvert.SerializeObject(dto), Encoding.UTF8, "application/json"); HttpResponseMessage response = await httpClient.PostAsync(QUERIES_REPORT, payload); using (HttpContent content = response.Content) { string responseText = await content.ReadAsStringAsync(); status.HttpCode = response.StatusCode; status.HttpResponse = responseText; if (status.HttpCode == System.Net.HttpStatusCode.OK) { List <QueryReportEntryDTO> reportEntries = JsonConvert.DeserializeObject <List <QueryReportEntryDTO> >(responseText); status.UserObject = reportEntries; status.StatusMessage = "Query Report Loaded Successfully . ."; } else { status.StatusMessage = responseText; } } } } return(status); } catch (Exception ex) { Log.This(ex); throw; } }
public static async Task <RestStatus> ExtractRsn(int batchId, int tanCategory) { try { RestStatus status = new RestStatus(); List <string> tanNums = new List <string>(); if (!string.IsNullOrEmpty(Sessionkey)) { using (var httpClient = new HttpClient()) { httpClient.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue(BEARER_HEDER, Sessionkey); httpClient.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue(APPLICATION_JSON)); StringContent stringContent = new StringContent(String.Empty); HttpResponseMessage response = await httpClient.PostAsync(EXTRACT_RSN + "?batchId=" + batchId + "&tanCategory=" + tanCategory, stringContent); using (HttpContent content = response.Content) { string responseText = await content.ReadAsStringAsync(); status.HttpCode = response.StatusCode; status.HttpResponse = responseText; if (status.HttpCode == System.Net.HttpStatusCode.OK) { status.UserObject = JsonConvert.DeserializeObject <List <ExtractRSNDto> >(responseText); status.StatusMessage = "RSNs Loaded Successfully . ."; status.HttpCode = System.Net.HttpStatusCode.OK; } else { status.StatusMessage = responseText; } } } } return(status); } catch (Exception ex) { Log.This(ex); throw; } }
public static async Task <RestStatus> AllowForReview(List <int> batchIds) { try { RestStatus status = new RestStatus(); if (!string.IsNullOrEmpty(Sessionkey)) { using (var httpClient = new HttpClient()) { httpClient.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue(BEARER_HEDER, Sessionkey); httpClient.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue(APPLICATION_JSON)); StringContent stringContent = new StringContent("productId=1"); HttpResponseMessage response = await httpClient.PostAsync(UPDATE_REVIEW_ALLOW_URL, new StringContent(JsonConvert.SerializeObject(batchIds), Encoding.UTF8, "application/json")); using (HttpContent content = response.Content) { string responseText = await content.ReadAsStringAsync(); status.HttpCode = response.StatusCode; status.HttpResponse = responseText; if (status.HttpCode == System.Net.HttpStatusCode.OK) { bool result = JsonConvert.DeserializeObject <bool>(responseText); status.UserObject = result; status.StatusMessage = "User Tans Assigned Successfully . ."; } else { status.StatusMessage = responseText; } } } } return(status); } catch (Exception ex) { throw; } }
public static async Task <RestStatus> UpdateDeliveryStatus(int batchId) { try { RestStatus status = new RestStatus(); List <string> tanNums = new List <string>(); if (!string.IsNullOrEmpty(Sessionkey)) { using (var httpClient = new HttpClient()) { httpClient.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue(BEARER_HEDER, Sessionkey); httpClient.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue(APPLICATION_JSON)); StringContent stringContent = new StringContent(String.Empty); HttpResponseMessage response = await httpClient.PostAsync(UPDATE_DELIVERY_STATUS + "?batchId=" + batchId, stringContent); using (HttpContent content = response.Content) { string responseText = await content.ReadAsStringAsync(); status.HttpCode = response.StatusCode; status.HttpResponse = responseText; if (status.HttpCode == System.Net.HttpStatusCode.OK) { status.HttpCode = System.Net.HttpStatusCode.OK; status.StatusMessage = responseText; } else { status.StatusMessage = responseText; } } } } return(status); } catch (Exception ex) { Log.This(ex); throw; } }
public static async Task <RestStatus> MoveToDelivery(MoveTansDTO moveTansDto) { try { RestStatus status = new RestStatus(); List <string> tanNums = new List <string>(); if (!string.IsNullOrEmpty(Sessionkey)) { using (var httpClient = new HttpClient()) { httpClient.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue(BEARER_HEDER, Sessionkey); httpClient.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue(APPLICATION_JSON)); StringContent stringContent = new StringContent(String.Empty); HttpResponseMessage response = await httpClient.PostAsync(MOVE_TO_DELIVERY, new StringContent(JsonConvert.SerializeObject(moveTansDto), Encoding.UTF8, "application/json")); using (HttpContent content = response.Content) { string responseText = await content.ReadAsStringAsync(); status.HttpCode = response.StatusCode; status.HttpResponse = responseText; if (status.HttpCode == System.Net.HttpStatusCode.OK) { status.HttpCode = System.Net.HttpStatusCode.OK; status.StatusMessage = responseText; } else { status.StatusMessage = responseText; } } } } return(status); } catch (Exception ex) { Log.This(ex); throw; } }
public static async Task <RestStatus> MyTans(int currentRole, bool pullTasks) { try { RestStatus status = new RestStatus(); List <string> tanNums = new List <string>(); if (!string.IsNullOrEmpty(Sessionkey)) { using (var httpClient = new HttpClient()) { httpClient.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue(BEARER_HEDER, Sessionkey); httpClient.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue(APPLICATION_JSON)); StringContent stringContent = new StringContent("productId=1"); HttpResponseMessage response = await httpClient.GetAsync(MY_TANS_URL + "?productId=1¤tRole=" + currentRole + "&pullTasks=" + pullTasks); using (HttpContent content = response.Content) { string responseText = await content.ReadAsStringAsync(); status.HttpCode = response.StatusCode; status.StatusMessage = responseText; if (status.HttpCode == System.Net.HttpStatusCode.OK) { List <TaskDTO> tans = JsonConvert.DeserializeObject <List <TaskDTO> >(responseText); status.UserObject = tans; } } } } return(status); } catch (Exception ex) { Log.This(ex); throw; } }
public static async Task <RestStatus> SaveQueryWorkflows(List <QueryWorkflowUserDTO> dtos) { try { ; RestStatus status = new RestStatus(); using (var httpClient = new HttpClient()) { httpClient.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue(BEARER_HEDER, Sessionkey); httpClient.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue(APPLICATION_JSON)); StringContent payload = new StringContent(JsonConvert.SerializeObject(dtos), Encoding.UTF8, "application/json"); HttpResponseMessage response = await httpClient.PostAsync(SAVE_QUERY_WORKFLOWS, payload); using (HttpContent content = response.Content) { string responseText = await content.ReadAsStringAsync(); status.HttpCode = response.StatusCode; status.HttpResponse = responseText; if (status.HttpCode == System.Net.HttpStatusCode.OK) { status.StatusMessage = responseText; } else { dynamic state = JsonConvert.DeserializeObject <dynamic>(status.HttpResponse); status.StatusMessage = state.error_description; } } } return(status); } catch (Exception ex) { Log.This(ex); throw; } }
public static async Task <RestStatus> UserReactionsReports(int currentRoleId) { try { RestStatus status = new RestStatus(); using (var httpClient = new HttpClient()) { httpClient.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue(BEARER_HEDER, Sessionkey); httpClient.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue(APPLICATION_JSON)); HttpResponseMessage response = await httpClient.GetAsync(USER_REPORTS_URL + "?currentRoleId=" + currentRoleId); using (HttpContent content = response.Content) { string responseText = await content.ReadAsStringAsync(); status.HttpCode = response.StatusCode; status.HttpResponse = responseText; if (status.HttpCode == System.Net.HttpStatusCode.OK) { List <UserReportsDTO> reportsDto = JsonConvert.DeserializeObject <List <UserReportsDTO> >(responseText); status.UserObject = reportsDto; status.StatusMessage = "User Reports Loaded Successfully . ."; } else { status.StatusMessage = responseText; } } } return(status); } catch (Exception ex) { Log.This(ex); throw; } }
public static async Task <RestStatus> RevertDeliveryTAN(int id, int role, string msg) { try { RestStatus status = new RestStatus(); List <string> tanNums = new List <string>(); if (!string.IsNullOrEmpty(Sessionkey)) { using (var httpClient = new HttpClient()) { httpClient.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue(BEARER_HEDER, Sessionkey); httpClient.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue(APPLICATION_JSON)); StringContent stringContent = new StringContent(String.Empty); HttpResponseMessage response = await httpClient.PostAsync(REVERT_DELIVERY_TAN + "?id=" + id + "&role=" + role + "&msg=" + msg , stringContent); using (HttpContent content = response.Content) { string responseText = await content.ReadAsStringAsync(); status.HttpCode = response.StatusCode; status.HttpResponse = responseText; status.StatusMessage = responseText; } } } return(status); } catch (Exception ex) { Log.This(ex); throw; } }