public string GetReportFax(string userName, string password, string faxID) { string status = string.Empty; switch (Configuration.Config.Environment()) { case Configuration.TIMEnvironment.Development: case Configuration.TIMEnvironment.Demo: case Configuration.TIMEnvironment.Test: Array values = System.Enum.GetValues(typeof(FaxResult)); Random random = new Random(); int randomValueCustom = GetRandomValue(values); FaxResult randomStatus = (FaxResult)values.GetValue(randomValueCustom); status = randomStatus.ToString(); break; case Configuration.TIMEnvironment.Production: { Faxolution201203Client client = new Faxolution201203Client(); reportRequest report = new reportRequest(); report.username = userName; report.password = password; report.jobId = faxID; reportResponse reportResponse = client.getFaxReport(report); status = reportResponse.faxRecipient[0].status; } break; default: break; } return(status); }
protected override void OnIncomingCall(Call call) { AnswerResult resultAnswer = call.Answer(); if (!resultAnswer.Successful) { // The call was not answered successfully, stop the consumer and bail out Completed.Set(); Stop(); return; } TaskCompletionSource <bool> eventing = new TaskCompletionSource <bool>(); call.OnFaxError += (a, c, e, p) => { Logger.LogError("Actual fax receive had an error"); eventing.SetResult(true); }; call.OnFaxFinished += (a, c, e, p) => { var settings = p.Fax.ParametersAs <CallingEventParams.FaxParams.FaxSettings.FinishedSettings>(); if (settings.Success) { Successful = true; } else { Logger.LogError("Actual fax receive had an issue: {0}", settings.ResultText); } eventing.SetResult(true); }; FaxResult receiveResult = call.FaxReceive(); if (!receiveResult.Successful) { Successful = false; Logger.LogError("Receive fax was unsuccessful"); eventing.SetResult(true); } else { eventing.Task.Wait(); if (!Successful) { Logger.LogError("Fax receive did not give a successful finished event"); } } Completed.Set(); }
// This is executed in a new thread each time, so it is safe to use blocking calls protected override void Ready() { DialResult resultDial = Client.Calling.DialPhone(ToNumber, FromNumber); if (!resultDial.Successful) { Logger.LogError("Call was not answered"); Completed.Set(); return; } Call call = resultDial.Call; TaskCompletionSource <bool> eventing = new TaskCompletionSource <bool>(); call.OnFaxError += (a, c, e, p) => { Logger.LogError("Actual fax send had an error"); eventing.SetResult(true); }; call.OnFaxFinished += (a, c, e, p) => { var settings = p.Fax.ParametersAs <CallingEventParams.FaxParams.FaxSettings.FinishedSettings>(); if (settings.Success) { Successful = true; } else { Logger.LogError("Actual fax delivery had an issue: {0}", settings.ResultText); } eventing.SetResult(true); }; FaxResult sendResult = call.FaxSend(Document); if (!sendResult.Successful) { Successful = false; Logger.LogError("Send fax was unsuccessful"); } else { eventing.Task.Wait(); if (!Successful) { Logger.LogError("Fax send did not give a successful finished event"); } } Completed.Set(); }
// This is executed in a new thread each time, so it is safe to use blocking calls protected override void Ready() { DialResult resultDial = Client.Calling.DialPhone(ToNumber, FromNumber); if (!resultDial.Successful) { Logger.LogError("Call was not answered"); return; } Call call = resultDial.Call; FaxResult sendResult = call.FaxSend(Document); if (!sendResult.Successful) { Successful = false; Logger.LogError("Send fax was unsuccessful"); } }