/// <summary> /// Calls vendor upload service with only a package as a parameter. IPackage is now legacy and is defined in TestLibrary /// </summary> /// <param name="package"></param> /// <returns></returns> public static Results CallUploadService(IPackage package) { string batch = File.ReadAllText(package.Document.Path); Results result = new Results(); using (var uploader = new ServiceReference1.ClaimImportServiceClient()) { uploader.InnerChannel.OperationTimeout = new TimeSpan(0, 10, 0); uploader.Open(); try { Stopwatch sw = new Stopwatch(); sw.Start(); result.claimResults = uploader.ImportClaim(package.Client.Username, package.Client.Password, Encoding.ASCII.GetBytes(batch)); sw.Stop(); result.timeToRespond = sw.Elapsed; result.client = package.Client; result.document = package.Document; result.whenUploaded = DateTime.Now; if (result.claimResults.Length < 1) //Vendor API often will only return a zero-length array when one might expect an error. This is to ensure we know when a zero-length array is returned { throw new NullReturnedValueException(); } result.noErrors = Results.CheckBatchForErrors(result.claimResults); } catch (FaultException e) { result.Exceptions.Add(e); result.thrownException = true; } catch (NullReturnedValueException e) { result.Exceptions.Add(e); result.thrownException = true; } catch (Exception e) { result.thrownException = true; result.Exceptions.Add(e); } } return(result); }
/// <summary> /// Uploads to the vendor API as configured in the Service Reference currently configured as: ServiceReference1 /// </summary> /// <param name="client"></param> /// <param name="document"></param> /// <returns>Object Results as defined in the VendorUploadService project </returns> public static Results CallUploadService(Client client, Document document) { string batch = File.ReadAllText(document.Path); Results result = new Results(); using (var uploader = new ServiceReference1.ClaimImportServiceClient()) { uploader.InnerChannel.OperationTimeout = new TimeSpan(0, 10, 0); uploader.Open(); try { Stopwatch sw = new Stopwatch(); sw.Start(); result.claimResults = uploader.ImportClaim(client.Username, client.Password, Encoding.ASCII.GetBytes(batch)); sw.Stop(); result.timeToRespond = sw.Elapsed; result.client = client; result.document = document; result.whenUploaded = DateTime.Now; if (result.claimResults.Length < 1) //need to compare this another way, doesn't come back as null { throw new NullReturnedValueException(); } result.noErrors = Results.CheckBatchForErrors(result.claimResults); } catch (FaultException e) { result.Exceptions.Add(e); result.thrownException = true; } catch (NullReturnedValueException e) { result.Exceptions.Add(e); result.thrownException = true; } catch (Exception e) { result.thrownException = true; result.Exceptions.Add(e); } } return(result); }