public void can_get_balance() { var interfax = new FaxClient(); var actual = interfax.Account.GetBalance().Result; Assert.IsTrue(actual > 0); }
public void can_unpack_and_load_supported_media_types() { _interfax = new FaxClient("unit-test-user", "unit-test-pass"); var types = _interfax.Documents.SupportedMediaTypes; Assert.IsNotNull(types); Assert.IsTrue(types.ContainsKey("pdf")); }
public void can_get_balance() { var _testPath = new Uri(Path.GetDirectoryName(Assembly.GetExecutingAssembly().CodeBase)).LocalPath; var interfax = new FaxClient(TestingConfig.username, TestingConfig.password); var actual = interfax.Account.GetBalance().Result; //Assert.IsTrue(actual > 0); Call is still be valid if account balance is zero. }
private void CreateClient() { var interfax = new FaxClient(); Assert.NotNull(interfax.Account); Assert.NotNull(interfax.Documents); Assert.NotNull(interfax.Inbound); Assert.NotNull(interfax.Outbound); }
public void can_instantiate_with_credentials() { var interfax = new FaxClient(Username, Password); Assert.NotNull(interfax.Account); Assert.NotNull(interfax.Documents); Assert.NotNull(interfax.Inbound); Assert.NotNull(interfax.Outbound); }
public void GetList_should_call_correct_uri_without_options() { _handler = new MockHttpMessageHandler { ExpectedContent = "[]", ExpectedUri = new Uri("https://rest.interfax.net/outbound/faxes") }; _interfax = new FaxClient("unit-test-user", "unit-test-pass", _handler); var actual = _interfax.Outbound.GetList().Result; Assert.IsTrue(_handler.ExpectedUriWasVisited()); }
public void GetForwardingEmails_should_call_correct_uri() { _handler = new MockHttpMessageHandler { ExpectedContent = "[]", ExpectedUri = new Uri("https://rest.interfax.net/inbound/faxes/1/emails") }; _interfax = new FaxClient("unit-test-user", "unit-test-pass", _handler); var actual = _interfax.Inbound.GetForwardingEmails(1).Result; Assert.That(_handler.ExpectedUriWasVisited()); }
public void GetFaxImageStream_should_call_correct_uri() { _handler = new MockHttpMessageHandler { ExpectedContent = "{}", ExpectedUri = new Uri("https://rest.interfax.net/outbound/faxes/1/image") }; _interfax = new FaxClient("unit-test-user", "unit-test-pass", _handler); var actual = _interfax.Outbound.GetFaxImageStream(1).Result; Assert.That(_handler.ExpectedUriWasVisited()); }
public void GetFaxRecord_should_call_correct_uri() { _handler = new MockHttpMessageHandler { ExpectedContent = "{}", ExpectedUri = new Uri("https://rest.interfax.net/inbound/faxes/1") }; _interfax = new FaxClient("unit-test-user", "unit-test-pass", _handler); var actual = _interfax.Inbound.GetFaxRecord(1).Result; Assert.IsTrue(_handler.ExpectedUriWasVisited()); }
public void GetCompleted_should_call_correct_uri() { _handler = new MockHttpMessageHandler { ExpectedHttpMethod = HttpMethod.Get, ExpectedContent = "", ExpectedUri = new Uri("https://rest.interfax.net/outbound/faxes/completed?ids=1,2,3") }; _interfax = new FaxClient("unit-test-user", "unit-test-pass", _handler); var response = _interfax.Outbound.GetCompleted(1, 2, 3).Result; Assert.IsTrue(_handler.ExpectedUriWasVisited()); }
public void MarkUnread_should_call_correct_uri() { _handler = new MockHttpMessageHandler { ExpectedHttpMethod = HttpMethod.Post, ExpectedContent = "", ExpectedUri = new Uri("https://rest.interfax.net/inbound/faxes/1/mark?unread=true") }; _interfax = new FaxClient("unit-test-user", "unit-test-pass", _handler); var response = _interfax.Inbound.MarkUnread(1).Result; Assert.That(_handler.ExpectedUriWasVisited()); }
public void CancelFax_should_call_correct_uri() { _handler = new MockHttpMessageHandler { ExpectedHttpMethod = HttpMethod.Post, ExpectedContent = "", ExpectedUri = new Uri("https://rest.interfax.net/outbound/faxes/1/cancel") }; _interfax = new FaxClient("unit-test-user", "unit-test-pass", _handler); var response = _interfax.Outbound.CancelFax(1).Result; Assert.IsTrue(_handler.ExpectedUriWasVisited()); }
public void should_call_correct_balance_uri() { const decimal expected = 1.23M; _handler = new MockHttpMessageHandler { ExpectedContent = expected.ToString(CultureInfo.InvariantCulture), ExpectedUri = new Uri("https://rest.interfax.net/accounts/self/ppcards/balance") }; _interfax = new FaxClient("unit-test-user", "unit-test-pass", _handler); var actual = _interfax.Account.GetBalance().Result; Assert.AreEqual(_handler.ExpectedUri, _handler.ActualUri); Assert.AreEqual(expected, actual); }
public void ResendFax_should_call_correct_uri_with_faxNumber() { _handler = new MockHttpMessageHandler { ExpectedHttpMethod = HttpMethod.Post, ExpectedContent = "", ExpectedLocationHeader = new Uri("https://rest.interfax.net/outbound/faxes/2"), ExpectedUri = new Uri("https://rest.interfax.net/outbound/faxes/1/resend?faxNumber=123456789") }; _interfax = new FaxClient("unit-test-user", "unit-test-pass", _handler); var faxId = _interfax.Outbound.ResendFax(1, "123456789").Result; Assert.AreEqual(2, faxId); Assert.IsTrue(_handler.ExpectedUriWasVisited()); }
public void ResendFax_returns_fax_id() { _handler = new MockHttpMessageHandler { ExpectedHttpMethod = HttpMethod.Post, ExpectedStatusCode = HttpStatusCode.Created, ExpectedLocationHeader = new Uri("https://rest.interfax.net/outbound/faxes/1"), ExpectedContent = "", ExpectedUri = new Uri("https://rest.interfax.net/outbound/faxes/1/resend?faxNumber=123456789") }; _interfax = new FaxClient("unit-test-user", "unit-test-pass", _handler); var faxId = _interfax.Outbound.ResendFax(1, "123456789").Result; Assert.AreEqual(1, faxId); Assert.IsTrue(_handler.ExpectedUriWasVisited()); }
public void GetList_should_call_correct_uri_with_options() { _handler = new MockHttpMessageHandler { ExpectedContent = "[]", ExpectedUri = new Uri("https://rest.interfax.net/outbound/documents?limit=10&offset=5") }; _interfax = new FaxClient("unit-test-user", "unit-test-pass", _handler); var actual = _interfax.Outbound.Documents.GetUploadSessions(new Documents.ListOptions { Limit = 10, Offset = 5 }).Result; Assert.IsTrue(_handler.ExpectedUriWasVisited()); }
public void can_build_fax_document() { _handler = new MockHttpMessageHandler { ExpectedContent = "[{'MediaType': 'application/pdf','FileType': 'pdf'}]", ExpectedUri = new Uri("https://rest.interfax.net/outbound/help/mediatype") }; _interfax = new FaxClient("unit-test-user", "unit-test-pass", _handler); var faxDocument = _interfax.Documents.BuildFaxDocument(_testPdf); Assert.IsNotNull(faxDocument); var fileDocument = faxDocument as FileDocument; Assert.IsNotNull(fileDocument); Assert.AreEqual(_testPdf, fileDocument.FilePath); Assert.AreEqual("application/pdf", fileDocument.MediaType); }
public void GetList_should_call_correct_uri_with_options() { _handler = new MockHttpMessageHandler { ExpectedContent = "[]", ExpectedUri = new Uri("https://rest.interfax.net/outbound/faxes?lastId=5&limit=10&sortOrder=asc&userId=unit-test-associate") }; _interfax = new FaxClient("unit-test-user", "unit-test-pass", _handler); var actual = _interfax.Outbound.GetList(new Outbound.ListOptions { Limit = 10, LastId = 5, SortOrder = ListSortOrder.Ascending, UserId = "unit-test-associate" }).Result; Assert.IsTrue(_handler.ExpectedUriWasVisited()); }
public void GetList_should_call_correct_uri_with_options() { _handler = new MockHttpMessageHandler { ExpectedContent = "[]", ExpectedUri = new Uri("https://rest.interfax.net/inbound/faxes?limit=10&lastId=5&unreadOnly=true&allUsers=true") }; _interfax = new FaxClient("unit-test-user", "unit-test-pass", _handler); var actual = _interfax.Inbound.GetList(new Inbound.ListOptions { Limit = 10, LastId = 5, UnreadOnly = true, AllUsers = true }).Result; Assert.That(_handler.ExpectedUriWasVisited()); }
public async Task SendInterFax() { // Update username/password in web.config to valid credentials first. Otherwise will throw 401:unauthorised var username = ConfigurationManager.AppSettings["INTERFAX_USERNAME"]; var password = ConfigurationManager.AppSettings["INTERFAX_PASSWORD"]; FaxClient fc = new FaxClient(username, password); string filePath = System.Web.HttpContext.Current.Server.MapPath("sample.pdf"); IFaxDocument ifd = fc.Documents.BuildFaxDocument(filePath); SendOptions so = new SendOptions(); so.FaxNumber = "+99999990"; so.PageHeader = "test"; try { var result = await fc.Outbound.SendFax(ifd, so); } catch (Exception ex) { throw ex; } }
public void should_create_HttpError_from_empty_error_response() { _handler = new MockHttpMessageHandler { ExpectedContent = "", ExpectedReasonPhrase = "Something was not found.", ExpectedContentType = "text/plain", ExpectedStatusCode = HttpStatusCode.NotFound, ExpectedUri = new Uri("https://rest.interfax.net/accounts/self/ppcards/balance") }; _interfax = new FaxClient("unit-test-user", "unit-test-pass", _handler); var exception = Assert.Throws <AggregateException>(() => { var balance = _interfax.Account.GetBalance().Result; }); Assert.AreEqual(1, exception.InnerExceptions.Count); var apiException = exception.InnerExceptions[0] as ApiException; Assert.NotNull(apiException); Assert.AreEqual((int)_handler.ExpectedStatusCode, apiException.Error.Code); Assert.AreEqual(_handler.ExpectedReasonPhrase, apiException.Error.Message); Assert.AreEqual("No content returned", apiException.Error.MoreInfo); }
public void Setup() { _interfax = new FaxClient(); }
public void Setup() { var httpClient = HttpClients.NewHttpClient(_testPath + TestingConfig.scotchCassettePath, TestingConfig.scotchMode); _interfax = new FaxClient(TestingConfig.username, TestingConfig.password, httpClient); }
public void Setup() { _interfax = new FaxClient(TestingConfig.username, TestingConfig.password); }
static private async Task SendFaxAsync2() { //pull in the config file string values string myDEVUserName = System.Configuration.ConfigurationSettings.AppSettings["DEV_Username"]; string myDEVPassword = System.Configuration.ConfigurationSettings.AppSettings["DEV_Password"]; string myPRODUserName = System.Configuration.ConfigurationSettings.AppSettings["PROD_Username"]; string myPRODPassword = System.Configuration.ConfigurationSettings.AppSettings["PROD_Password"]; string myPRODFlag = System.Configuration.ConfigurationSettings.AppSettings["IsPROD"]; string myGmailUsername = System.Configuration.ConfigurationSettings.AppSettings["GmailUsername"]; string myGmailPassword = System.Configuration.ConfigurationSettings.AppSettings["GmailPassword"]; string myGmailFromAddress = System.Configuration.ConfigurationSettings.AppSettings["GmailFromAddress"]; string myGmailWaitTime = System.Configuration.ConfigurationSettings.AppSettings["GmailWaitTime"]; string myFaxWaitTime = System.Configuration.ConfigurationSettings.AppSettings["FaxWaitTime"];; string myCurrentUsername = ""; string myCurrentPassword = ""; string myEmailSuccess = ""; string myRunTYpe = ""; string myEmailResult = ""; //create the log file StreamWriter myLog; if (!File.Exists("C:\\temp\\faxlog.txt")) { myLog = new StreamWriter("C:\\temp\\faxlog.txt"); } else { myLog = File.AppendText("C:\\temp\\faxlog.txt"); } //log the event myLog.WriteLine(ConsoleOutputHelper.OutputConsoleMessage("////-------------FAX PROCESS INITIATED------------\\\\")); Console.WriteLine(ConsoleOutputHelper.OutputConsoleMessage("The fax software PROD flag is currently set up " + myPRODFlag)); myLog.WriteLine(ConsoleOutputHelper.OutputConsoleMessage("The fax software PROD flag is currently set up " + myPRODFlag)); int totalCount = 0; int currentRecordNumber = 1; //Create the fax client with the user information if (myPRODFlag == "true") { Console.WriteLine(ConsoleOutputHelper.OutputConsoleMessage("******* SOFTWARE SET TO PRODUCTION MODE *******")); myLog.WriteLine(ConsoleOutputHelper.OutputConsoleMessage("******* SOFTWARE SET TO PRODUCTION MODE *******")); myCurrentUsername = myPRODUserName; myCurrentPassword = myPRODPassword; } else { Console.WriteLine(ConsoleOutputHelper.OutputConsoleMessage("******* SOFTWARE SET TO DEVELOPMENT MODE *******")); myLog.WriteLine(ConsoleOutputHelper.OutputConsoleMessage("******* SOFTWARE SET TO DEVELOPMENT MODE *******")); myCurrentUsername = myDEVUserName; myCurrentPassword = myDEVPassword; } //get the program run type configuration ConfigurationModel myConfigRunTypeModel = new ConfigurationModel(); myConfigRunTypeModel = DataProvider.Instance.GetRunTypeConfiguration(); //get the program run type configuration ConfigurationModel myConfigReportTypeModel = new ConfigurationModel(); myConfigReportTypeModel = DataProvider.Instance.GetReportTypeConfiguration(); Console.WriteLine(ConsoleOutputHelper.OutputConsoleMessage("******* PROGRAM RUN TYPE SET TO " + myConfigRunTypeModel.ConfigurationValue + "*******")); myLog.WriteLine(ConsoleOutputHelper.OutputConsoleMessage("******* PROGRAM RUN TYPE SET TO " + myConfigRunTypeModel.ConfigurationValue + "*******")); Console.WriteLine(ConsoleOutputHelper.OutputConsoleMessage("******* PROGRAM REPORT TYPE SET TO " + myConfigReportTypeModel.ConfigurationValue + "*******")); myLog.WriteLine(ConsoleOutputHelper.OutputConsoleMessage("******* PROGRAM REPORT TYPE SET TO " + myConfigReportTypeModel.ConfigurationValue + "*******")); try { //this is the DEV account login var interfax = new FaxClient(username: myCurrentUsername, password: myCurrentPassword); Console.WriteLine(ConsoleOutputHelper.OutputConsoleMessage("Initiating new Fax Client for user: "******"Initiating new Fax Client for user: "******"Requesting dataset for Fax Requests")); myLog.WriteLine(ConsoleOutputHelper.OutputConsoleMessage("Requesting dataset for Fax Requests")); //get the data List <FaxRequestQueryModel> myModel = new List <FaxRequestQueryModel>(); myModel = DataProvider.Instance.GetFaxRequest(); //get the total count for use in the loop totalCount = myModel.Count(); //log the event Console.WriteLine(ConsoleOutputHelper.OutputConsoleMessage("Dataset retrieved. There are " + totalCount + " record(s).")); myLog.WriteLine(ConsoleOutputHelper.OutputConsoleMessage("Dataset retrieved. There are " + totalCount + " record(s).")); //loop through the the entire resultset foreach (var faxRequest in myModel) { if (myConfigRunTypeModel.ConfigurationValue.ToLower() == "email") { if (!String.IsNullOrEmpty(faxRequest.Client_Email)) { //log the event Console.WriteLine(ConsoleOutputHelper.OutputConsoleMessage("Processing email records " + currentRecordNumber + " of " + totalCount)); myLog.WriteLine(ConsoleOutputHelper.OutputConsoleMessage("Processing email records " + currentRecordNumber + " of " + totalCount)); //send the email Console.WriteLine(ConsoleOutputHelper.OutputConsoleMessage("Attempting email record for address " + faxRequest.Client_Email)); myLog.WriteLine(ConsoleOutputHelper.OutputConsoleMessage("Attempting email record for address " + faxRequest.Client_Email)); myEmailSuccess = SendFaxConsole.SendMail.SendExchangeMail(faxRequest.Client_Email, faxRequest.Fax_File_Location, myGmailUsername, myGmailPassword, myGmailFromAddress, faxRequest.Fax_File_Location, faxRequest.Client_Name, myConfigReportTypeModel.ConfigurationValue); //log the event Console.WriteLine(ConsoleOutputHelper.OutputConsoleMessage("Processing email record for address " + faxRequest.Client_Email)); myLog.WriteLine(ConsoleOutputHelper.OutputConsoleMessage("Processing email record for address " + faxRequest.Client_Email)); } else { myEmailSuccess = "failure"; Console.WriteLine(ConsoleOutputHelper.OutputConsoleMessage("No Email found for " + faxRequest.Client_Name + ". No email will be sent.")); myLog.WriteLine(ConsoleOutputHelper.OutputConsoleMessage("No Email found for " + faxRequest.Client_Name + ". No email will be sent.")); } //increment the record number currentRecordNumber++; if (myEmailSuccess == "success") //Successful email { Console.WriteLine(ConsoleOutputHelper.OutputConsoleMessage("Processing...")); myLog.WriteLine(ConsoleOutputHelper.OutputConsoleMessage("Processing...")); Thread.Sleep(Convert.ToInt32(myGmailWaitTime)); //update the record in the model to success faxRequest.Fax_Status = "success"; //write to the audit file myEmailResult = DataProvider.Instance.InsertFaxRequestAuditRecord(faxRequest); myLog.WriteLine(ConsoleOutputHelper.OutputConsoleMessage("AUDIT PROCESS: Attempted to write to the audit file in success process.")); if (myEmailResult == "success") { myLog.WriteLine(ConsoleOutputHelper.OutputConsoleMessage("AUDIT PROCESS: Successful write to the audit file.")); //Delete the record from the transaction file myEmailResult = DataProvider.Instance.DeleteFaxRequest(faxRequest); if (myEmailResult == "success") { //log the event Console.WriteLine(ConsoleOutputHelper.OutputConsoleMessage("Email for Address " + faxRequest.Client_Email + " successfully sent!")); myLog.WriteLine(ConsoleOutputHelper.OutputConsoleMessage("Email for Address " + faxRequest.Client_Email + " successfully sent!")); } else { //log the event Console.WriteLine(ConsoleOutputHelper.OutputConsoleMessage(myEmailResult)); myLog.WriteLine(ConsoleOutputHelper.OutputConsoleMessage(myEmailResult)); //log the event Console.WriteLine(ConsoleOutputHelper.OutputConsoleMessage("Email for Address " + faxRequest.Client_Email + " successfully sent, but with audit issues. Please refer to the log for more details.")); myLog.WriteLine(ConsoleOutputHelper.OutputConsoleMessage("Email for Address " + faxRequest.Client_Email + " successfully sent, but with audit issues. Please refer to the log for more details.")); } } else { //log the event Console.WriteLine(ConsoleOutputHelper.OutputConsoleMessage(myEmailSuccess)); myLog.WriteLine(ConsoleOutputHelper.OutputConsoleMessage(myEmailSuccess)); } Debug.WriteLine("Email Sent!"); } else //Failure { //log the event Console.WriteLine(ConsoleOutputHelper.OutputConsoleMessage("Email for Address " + faxRequest.Client_Name + " Failed")); myLog.WriteLine(ConsoleOutputHelper.OutputConsoleMessage("Email for Address " + faxRequest.Client_Name + " Failed")); //update the record in the model to success faxRequest.Fax_Status = "failure"; //write to the aidut file myEmailResult = DataProvider.Instance.InsertFaxRequestAuditRecord(faxRequest); myLog.WriteLine(ConsoleOutputHelper.OutputConsoleMessage("AUDIT PROCESS: Attempted to write to the audit file in failure process.")); if (myEmailResult == "success") { myLog.WriteLine(ConsoleOutputHelper.OutputConsoleMessage("AUDIT PROCESS: Successful write to the audit file.")); //Delete the record from the transaction file myEmailResult = DataProvider.Instance.DeleteFaxRequest(faxRequest); if (myEmailResult == "success") { //log the event Console.WriteLine(ConsoleOutputHelper.OutputConsoleMessage("Email for Address " + faxRequest.Client_Name + " failed to send.")); myLog.WriteLine(ConsoleOutputHelper.OutputConsoleMessage("Email for Address " + faxRequest.Client_Name + " failed to send.")); } else { //log the event Console.WriteLine(ConsoleOutputHelper.OutputConsoleMessage(myEmailSuccess)); myLog.WriteLine(ConsoleOutputHelper.OutputConsoleMessage(myEmailSuccess)); } } else { //log the event Console.WriteLine(ConsoleOutputHelper.OutputConsoleMessage(myEmailSuccess)); myLog.WriteLine(ConsoleOutputHelper.OutputConsoleMessage(myEmailSuccess)); } //log the event myLog.WriteLine(ConsoleOutputHelper.OutputConsoleMessage($"Error: " + myEmailSuccess)); Debug.WriteLine($"Error: " + myEmailSuccess); } } else //this means that the runtype is either fax or both { //log the event Console.WriteLine(ConsoleOutputHelper.OutputConsoleMessage("Processing Fax records " + currentRecordNumber + " of " + totalCount)); myLog.WriteLine(ConsoleOutputHelper.OutputConsoleMessage("Processing Fax records " + currentRecordNumber + " of " + totalCount)); //Send the fax with options var faxId = await interfax.Outbound.SendFax( interfax.Documents.BuildFaxDocument(faxRequest.Fax_File_Location), new SendOptions { FaxNumber = faxRequest.Client_Fax_Number, ShouldScale = true, PageOrientation = PageOrientation.Landscape, PageSize = PageSize.Letter } ); if (myConfigRunTypeModel.ConfigurationValue.ToLower() == "both") { if (!String.IsNullOrEmpty(faxRequest.Client_Email)) { //send the email Console.WriteLine(ConsoleOutputHelper.OutputConsoleMessage("Attempting email record for address " + faxRequest.Client_Email)); myLog.WriteLine(ConsoleOutputHelper.OutputConsoleMessage("Attempting email record for address " + faxRequest.Client_Email)); myEmailSuccess = SendFaxConsole.SendMail.SendExchangeMail(faxRequest.Client_Email, faxRequest.Fax_File_Location, myGmailUsername, myGmailPassword, myGmailFromAddress, faxRequest.Fax_File_Location, faxRequest.Client_Name, myConfigReportTypeModel.ConfigurationValue); } else { myEmailSuccess = "failure"; Console.WriteLine(ConsoleOutputHelper.OutputConsoleMessage("No Email found for " + faxRequest.Client_Name + ". No email will be sent.")); myLog.WriteLine(ConsoleOutputHelper.OutputConsoleMessage("No Email found for " + faxRequest.Client_Name + ". No email will be sent.")); } if (myEmailSuccess == "success") //Successful email { Console.WriteLine(ConsoleOutputHelper.OutputConsoleMessage("Processing...")); myLog.WriteLine(ConsoleOutputHelper.OutputConsoleMessage("Processing...")); Thread.Sleep(Convert.ToInt32(myGmailWaitTime)); //update the record in the model to success faxRequest.Fax_Status = "success"; //write to the audit file myEmailResult = DataProvider.Instance.InsertFaxRequestAuditRecord(faxRequest); myLog.WriteLine(ConsoleOutputHelper.OutputConsoleMessage("AUDIT PROCESS: Attempted to write to the audit file in success process.")); if (myEmailResult == "success") { myLog.WriteLine(ConsoleOutputHelper.OutputConsoleMessage("AUDIT PROCESS: Successful write to the audit file.")); if (myEmailResult == "success") { //log the event Console.WriteLine(ConsoleOutputHelper.OutputConsoleMessage("Email for Address " + faxRequest.Client_Email + " successfully sent!")); myLog.WriteLine(ConsoleOutputHelper.OutputConsoleMessage("Email for Address " + faxRequest.Client_Email + " successfully sent!")); } else { //log the event Console.WriteLine(ConsoleOutputHelper.OutputConsoleMessage(myEmailResult)); myLog.WriteLine(ConsoleOutputHelper.OutputConsoleMessage(myEmailResult)); //log the event Console.WriteLine(ConsoleOutputHelper.OutputConsoleMessage("Email for Address " + faxRequest.Client_Email + " successfully sent, but with audit issues. Please refer to the log for more details.")); myLog.WriteLine(ConsoleOutputHelper.OutputConsoleMessage("Email for Address " + faxRequest.Client_Email + " successfully sent, but with audit issues. Please refer to the log for more details.")); } } else { //log the event Console.WriteLine(ConsoleOutputHelper.OutputConsoleMessage(myEmailSuccess)); myLog.WriteLine(ConsoleOutputHelper.OutputConsoleMessage(myEmailSuccess)); } Debug.WriteLine("Email Sent!"); } else //Failure { //log the event Console.WriteLine(ConsoleOutputHelper.OutputConsoleMessage("Email for Address " + faxRequest.Client_Name + " Failed")); myLog.WriteLine(ConsoleOutputHelper.OutputConsoleMessage("Email for Address " + faxRequest.Client_Name + " Failed")); //update the record in the model to success faxRequest.Fax_Status = "failure"; //write to the aidut file myEmailResult = DataProvider.Instance.InsertFaxRequestAuditRecord(faxRequest); myLog.WriteLine(ConsoleOutputHelper.OutputConsoleMessage("AUDIT PROCESS: Attempted to write to the audit file in failure process.")); if (myEmailResult == "success") { myLog.WriteLine(ConsoleOutputHelper.OutputConsoleMessage("AUDIT PROCESS: Successful write to the audit file.")); //Delete the record from the transaction file myEmailResult = DataProvider.Instance.DeleteFaxRequest(faxRequest); if (myEmailResult == "success") { //log the event Console.WriteLine(ConsoleOutputHelper.OutputConsoleMessage("Email for Address " + faxRequest.Client_Name + " failed to send.")); myLog.WriteLine(ConsoleOutputHelper.OutputConsoleMessage("Email for Address " + faxRequest.Client_Name + " failed to send.")); } else { //log the event Console.WriteLine(ConsoleOutputHelper.OutputConsoleMessage(myEmailSuccess)); myLog.WriteLine(ConsoleOutputHelper.OutputConsoleMessage(myEmailSuccess)); } } else { //log the event Console.WriteLine(ConsoleOutputHelper.OutputConsoleMessage(myEmailSuccess)); myLog.WriteLine(ConsoleOutputHelper.OutputConsoleMessage(myEmailSuccess)); } //log the event myLog.WriteLine(ConsoleOutputHelper.OutputConsoleMessage($"Error: " + myEmailSuccess)); Debug.WriteLine($"Error: " + myEmailSuccess); } } //log the event Console.WriteLine(ConsoleOutputHelper.OutputConsoleMessage("Processing Fax record for number " + faxRequest.Client_Fax_Number)); myLog.WriteLine(ConsoleOutputHelper.OutputConsoleMessage("Processing Fax record for number " + faxRequest.Client_Fax_Number)); //increment the record number currentRecordNumber++; string myResult = ""; // wait for the fax to be delivered successfully while (true) { // load the fax's status var fax = await interfax.Outbound.GetFaxRecord(faxId); // sleep if pending for 30 seconds if (fax.Status < 0) { Console.WriteLine(ConsoleOutputHelper.OutputConsoleMessage("Processing...")); myLog.WriteLine(ConsoleOutputHelper.OutputConsoleMessage("Processing...")); Thread.Sleep(Convert.ToInt32(myFaxWaitTime)); } else if (fax.Status == 0) //Successful Fax { //update the record in the model to success faxRequest.Fax_Status = "success"; //write to the audit file myResult = DataProvider.Instance.InsertFaxRequestAuditRecord(faxRequest); myLog.WriteLine(ConsoleOutputHelper.OutputConsoleMessage("AUDIT PROCESS: Attempted to write to the audit file in success process.")); if (myResult == "success") { myLog.WriteLine(ConsoleOutputHelper.OutputConsoleMessage("AUDIT PROCESS: Successful write to the audit file.")); //Delete the record from the transaction file myResult = DataProvider.Instance.DeleteFaxRequest(faxRequest); if (myResult == "success") { //log the event Console.WriteLine(ConsoleOutputHelper.OutputConsoleMessage("Fax for number " + faxRequest.Client_Fax_Number + " successfully sent!")); myLog.WriteLine(ConsoleOutputHelper.OutputConsoleMessage("Fax for number " + faxRequest.Client_Fax_Number + " successfully sent!")); } else { //log the event Console.WriteLine(ConsoleOutputHelper.OutputConsoleMessage(myResult)); myLog.WriteLine(ConsoleOutputHelper.OutputConsoleMessage(myResult)); //log the event Console.WriteLine(ConsoleOutputHelper.OutputConsoleMessage("Fax for number " + faxRequest.Client_Fax_Number + " successfully sent, but with audit issues. Please refer to the log for more details.")); myLog.WriteLine(ConsoleOutputHelper.OutputConsoleMessage("Fax for number " + faxRequest.Client_Fax_Number + " successfully sent, but with audit issues. Please refer to the log for more details.")); } } else { //log the event Console.WriteLine(ConsoleOutputHelper.OutputConsoleMessage(myResult)); myLog.WriteLine(ConsoleOutputHelper.OutputConsoleMessage(myResult)); } Debug.WriteLine("Fax Sent!"); break; } else //Failure { //log the event Console.WriteLine(ConsoleOutputHelper.OutputConsoleMessage("Fax for number " + faxRequest.Client_Fax_Number + " Failed")); myLog.WriteLine(ConsoleOutputHelper.OutputConsoleMessage("Fax for number " + faxRequest.Client_Fax_Number + " Failed")); //update the record in the model to success faxRequest.Fax_Status = "failure"; //write to the aidut file myResult = DataProvider.Instance.InsertFaxRequestAuditRecord(faxRequest); myLog.WriteLine(ConsoleOutputHelper.OutputConsoleMessage("AUDIT PROCESS: Attempted to write to the audit file in failure process.")); if (myResult == "success") { myLog.WriteLine(ConsoleOutputHelper.OutputConsoleMessage("AUDIT PROCESS: Successful write to the audit file.")); //Delete the record from the transaction file myResult = DataProvider.Instance.DeleteFaxRequest(faxRequest); if (myResult == "success") { //log the event Console.WriteLine(ConsoleOutputHelper.OutputConsoleMessage("Fax for number " + faxRequest.Client_Fax_Number + " failed to send.")); myLog.WriteLine(ConsoleOutputHelper.OutputConsoleMessage("Fax for number " + faxRequest.Client_Fax_Number + " failed to send.")); } else { //log the event Console.WriteLine(ConsoleOutputHelper.OutputConsoleMessage(myResult)); myLog.WriteLine(ConsoleOutputHelper.OutputConsoleMessage(myResult)); } } else { //log the event Console.WriteLine(ConsoleOutputHelper.OutputConsoleMessage(myResult)); myLog.WriteLine(ConsoleOutputHelper.OutputConsoleMessage(myResult)); } //log the event myLog.WriteLine(ConsoleOutputHelper.OutputConsoleMessage($"Error: {fax.Status}")); Debug.WriteLine($"Error: {fax.Status}"); break; } } } } Console.WriteLine(ConsoleOutputHelper.OutputConsoleMessage("Program Run Complete.")); myLog.WriteLine(ConsoleOutputHelper.OutputConsoleMessage("Program Run Complete.")); //close the stream myLog.Close(); } catch (Exception ex) { //log the event myLog.WriteLine(ConsoleOutputHelper.OutputConsoleMessage(ex.InnerException.ToString())); Debug.WriteLine(ex.InnerException); //close the stream myLog.Close(); } }