public void PostFuelBurntRate(bool isvalid = true) { var requestString = JsonConvert.SerializeObject(fuelRequest); try { LogResult.Report(Log, "log_ForInfo", "Create Fuel Burnt rate: Starts"); string accessToken = AssetServiceConfig.GetValidUserAccessToken(); string response; SetCustomerUIDHeader(AssetServiceConfig.CustomerUID); if (isvalid) { response = RestClientUtil.DoHttpRequest(AssetServiceConfig.FuelBurnRateAPI, HeaderSettings.PutMethod, accessToken, HeaderSettings.JsonMediaType, requestString, HttpStatusCode.OK, HeaderSettings.BearerType, HeaderSettings.JsonMediaType, CustomHeaders); } else { response = RestClientUtil.DoInvalidHttpRequest(AssetServiceConfig.FuelBurnRateAPI, HeaderSettings.PutMethod, accessToken, HeaderSettings.JsonMediaType, requestString, HttpStatusCode.OK, HeaderSettings.BearerType, HeaderSettings.JsonMediaType, CustomHeaders); } fuelResponse = JsonConvert.DeserializeObject <FuelBurntRateResponse>(response); LogResult.Report(Log, "log_ForInfo", "Create Fuel Burnt rate: Ends"); } catch (Exception e) { LogResult.Report(Log, "log_ForError", "Exception Occured while creating fuel burnt rate " + e); throw new Exception("Exception Occured while creating creating fuel burnt rate \n"); } }
public void PostValidDeviceAssetDissociationRequestToService() { string requestString = JsonConvert.SerializeObject(DeviceAssetDissociationModel); try { string accessToken = AssetServiceConfig.GetValidUserAccessToken(); LogResult.Report(Log, "log_ForInfo", "Posting the request with Valid Values: " + requestString); ResponseString = RestClientUtil.DoHttpRequest(AssetServiceConfig.DeviceAssetDissociationEndpoint, HeaderSettings.PostMethod, accessToken, HeaderSettings.JsonMediaType, requestString, HttpStatusCode.OK, HeaderSettings.BearerType, HeaderSettings.JsonMediaType); } catch (Exception e) { LogResult.Report(Log, "log_ForError", "Got Error While Posting Data To DeviceAsset Dissociation Service", e); throw new Exception(e + " Got Error While Posting Data To DeviceAsset Dissociation Service"); } }
public void GetFuelBurntRate() { try { var requestString = JsonConvert.SerializeObject(assetUIDS); LogResult.Report(Log, "log_ForInfo", "Get Fuel Burnt rate: Starts"); string accessToken = AssetServiceConfig.GetValidUserAccessToken(); var response = RestClientUtil.DoHttpRequest(AssetServiceConfig.FuelBurnRateAPI, HeaderSettings.PostMethod, accessToken, HeaderSettings.JsonMediaType, requestString, HttpStatusCode.OK, HeaderSettings.BearerType, HeaderSettings.JsonMediaType, CustomHeaders); getFuelResponse = JsonConvert.DeserializeObject <FuelBurntRateResponse>(response); LogResult.Report(Log, "log_ForInfo", "Get Fuel Burnt rate: Ends"); } catch (Exception e) { LogResult.Report(Log, "log_ForError", "Exception Occured while getting fuel burnt rate " + e); throw new Exception("Exception Occured while getting fuel burnt rate \n"); } }
public void WhenIHitMakeCodeEndpoint() { try { string accessToken = AssetServiceConfig.GetValidUserAccessToken(); // public static string DoHttpRequest(string resourceUri, string httpMethod, //string mediaType, string payloadData, HttpStatusCode httpResponseCode) ResponseString = RestClientUtil.DoHttpRequestWithNoBody(AssetServiceConfig.MakeCodeEndpoint, HeaderSettings.GetMethod, accessToken, HeaderSettings.JsonMediaType, HttpStatusCode.OK); //DoHttpRequestWithNoBody(string resourceUri, string httpMethod, string authKey, string mediaType, HttpStatusCode httpResponseCode, string authKeyType = null, // string contentType = null, Dictionary<string, string> customHeaders = null) MakeCodeAPIResponse = JsonConvert.DeserializeObject <List <MakeCodeResponse> >(ResponseString); } catch (Exception e) { throw new Exception("Unable To Perform Get MakeCode", e); } }
public MakeCodeEndpointSteps() { AssetServiceConfig.SetupEnvironment(); }
public GetAssetSettingsSupport(Log4Net myLog) { AssetServiceConfig.SetupEnvironment(); MySqlConnectionString = AssetServiceConfig.MySqlConnection; Log = myLog; }
public void GetAssetDeviceList(string searchType = null, string pageNo = null, string pageSize = null) { createAssetEvent = AssetServiceSteps.assetServiceSupport.CreateAssetModel; string searchString = string.Empty; string requestType = string.Empty; if (searchType == "AssetSN") { searchString = createAssetEvent.SerialNumber; } else if (searchType == "AssetName") { searchString = createAssetEvent.AssetName; } else if (searchType == "DeviceSN") { searchString = CreateDeviceModel.DeviceSerialNumber; } else if (searchType == "AssetSNSorting" || searchType == "Valid") { searchString = validSearchString; } else if (searchType == "Wrong") { searchString = wrongSearchString; } else { searchString = searchType; } if (pageNo == "Valid") { pageNo = validPageNo; } else if (pageNo == "Invalid") { pageNo = invalidPageNo; requestType = "Invalid"; } else if (pageNo == "Wrong") { pageNo = wrongPageNo; } else if (pageNo == "0" || pageNo == "-1") { requestType = "Invalid"; } if (pageSize == "Valid") { pageSize = validPageSize; } else if (pageSize == "Invalid") { pageSize = invalidPageSize; requestType = "Invalid"; } else if (pageSize == "Wrong") { pageSize = wrongPageSize; } else if (pageSize == "0" || pageSize == "-1") { requestType = "Invalid"; } string parameters = string.Empty; if (searchString != null && pageNo == null && pageSize == null) { parameters = "?" + AssetServiceConfig.SearchString + "=" + searchString; } else if (searchString == null && pageNo != null && pageSize == null) { parameters = "?" + AssetServiceConfig.PageNo + "=" + pageNo; } else if (searchString == null && pageNo == null && pageSize != null) { parameters = "?" + AssetServiceConfig.PageSize + "=" + pageSize; } else if (searchString != null && pageNo != null && pageSize == null) { parameters = "?" + AssetServiceConfig.SearchString + "=" + searchString + "&" + AssetServiceConfig.PageNo + "=" + pageNo; } else if (searchString != null && pageNo == null && pageSize != null) { parameters = "?" + AssetServiceConfig.SearchString + "=" + searchString + "&" + AssetServiceConfig.PageSize + "=" + pageSize; } else if (searchString == null && pageNo != null && pageSize != null) { parameters = "?" + AssetServiceConfig.PageNo + "=" + pageNo + "&" + AssetServiceConfig.PageSize + "=" + pageSize; } else if (searchString != null && pageNo != null && pageSize != null) { parameters = "?" + AssetServiceConfig.SearchString + "=" + searchString + "&" + AssetServiceConfig.PageNo + "=" + pageNo + "&" + AssetServiceConfig.PageSize + "=" + pageSize; } else if (searchString == null && pageNo == null && pageSize == null) { parameters = ""; } try { string accessToken = AssetServiceConfig.GetValidUserAccessToken(); LogResult.Report(Log, "log_ForInfo", "Getting the AssetDetail Values:"); if (requestType == "Invalid") { ResponseString = RestClientUtil.DoInvalidHttpRequest(AssetServiceConfig.AssetSearchEndpoint + parameters, HeaderSettings.GetMethod, accessToken, HeaderSettings.JsonMediaType, null, HttpStatusCode.BadRequest, HeaderSettings.BearerType, HeaderSettings.JsonMediaType); } else { ResponseString = RestClientUtil.DoHttpRequest(AssetServiceConfig.AssetSearchEndpoint + parameters, HeaderSettings.GetMethod, accessToken, HeaderSettings.JsonMediaType, null, HttpStatusCode.OK, HeaderSettings.BearerType, HeaderSettings.JsonMediaType); } } catch (Exception e) { LogResult.Report(Log, "log_ForError", "Got Error While Getting Data from Asset Device Search Service", e); throw new Exception(e + " Got Error While Getting Data from Asset Device Search Service"); } }
public AssetDeviceSearchServiceSupport(Log4Net myLog) { AssetServiceConfig.SetupEnvironment(); Log = myLog; }
public AddProductivitySupport(Log4Net Log) { AssetServiceConfig.SetupEnvironment(); MySqlConnectionString = AssetServiceConfig.MySqlConnection; Log = myLog; }
public FuelBurnRateSupport() { AssetServiceConfig.SetupEnvironment(); MySqlConnectionString = AssetServiceConfig.MySqlConnection; }
public FuelBurntRateSupport(Log4Net myLog) { Log = myLog; AssetServiceConfig.SetupEnvironment(); }