private void GetFaxStatus() { if (lstJobIds.SelectedItem == null) { return; } Cursor.Current = Cursors.WaitCursor; Guid jobId = new Guid(lstJobIds.SelectedItem.ToString()); // // Initialize the web service // PolkaApi.SoapWebService webService = new Polka.Api.DemoApp.PolkaApi.SoapWebService(); webService.Url = this._SoapUrl; try { // // Call the Get Fax Status method // PolkaApi.ApiResultOfListOfJobStatusContainer result = webService.GetFaxStatus(txtUsername.Text, txtPassword.Text, new Guid(txtProductId.Text), new Guid[] { jobId }); // // Parse the results of the call // if ((result.Success == true) && (result.Result.Length > 0)) { StringBuilder sb = new StringBuilder(); PolkaApi.JobStatusContainer jobStatus = result.Result[0]; sb.AppendLine("Job"); sb.AppendLine("--Job Id: " + jobStatus.JobId.ToString()); sb.AppendLine("--Job State: " + jobStatus.JobState); sb.AppendLine("--Job Cost: " + jobStatus.JobEstimate.ToString()); sb.AppendLine("Call"); sb.AppendLine("--Phone Number: " + jobStatus.Calls[0].PhoneNumber); sb.AppendLine("--Call Result: " + jobStatus.Calls[0].CallResult); sb.AppendLine("--Job Pages: " + jobStatus.Calls[0].JobPages); sb.AppendLine("--Pages Sent: " + jobStatus.Calls[0].PagesSent); MessageBox.Show(sb.ToString(), "Job Result", MessageBoxButtons.OK, MessageBoxIcon.Information); } else { throw new Exception(result.ErrorString); } } catch (Exception ex) { MessageBox.Show(ex.Message, "Exception", MessageBoxButtons.OK, MessageBoxIcon.Error); } Cursor.Current = Cursors.Default; }
private void SendViaSoap() { Cursor.Current = Cursors.WaitCursor; PolkaApi.FaxQuality faxQuality = (PolkaApi.FaxQuality)(Enum.Parse(typeof(PolkaApi.FaxQuality), cmbFaxQuality.SelectedItem.ToString())); // // Create the object for the fax document // PolkaApi.FileContainer fileContainer = new Polka.Api.DemoApp.PolkaApi.FileContainer(); fileContainer.Filename = Path.GetFileName(txtFile.Text); fileContainer.FileContents = File.ReadAllBytes(txtFile.Text); fileContainer.ContentLength = fileContainer.FileContents.Length; // // Initialize the web servce // PolkaApi.SoapWebService webService = new Polka.Api.DemoApp.PolkaApi.SoapWebService(); webService.Url = this._SoapUrl; try { // // Submit the fax to the API // PolkaApi.ApiResultOfString result = webService.SendFax(txtUsername.Text, txtPassword.Text, new Guid(txtProductId.Text), txtJobName.Text, txtBillingCode.Text, txtHeader.Text, new string[] { txtPhoneNumber.Text }, new PolkaApi.FileContainer[] { fileContainer }, txtCSID.Text, faxQuality, dtpStartDateTime.Value, txtFeedbackEmail.Text); if (result.Success == true) { MessageBox.Show("Job Submitted Successfully!\r\n" + result.Result, "Job Submission", MessageBoxButtons.OK, MessageBoxIcon.Information); lstJobIds.Items.Add(result.Result); } else { MessageBox.Show("Job Submission Failed.\r\n" + result.ErrorString, "Job Submission", MessageBoxButtons.OK, MessageBoxIcon.Error); } } catch (Exception ex) { MessageBox.Show("Job Submission Failed.\r\n" + ex.Message, "Job Submission", MessageBoxButtons.OK, MessageBoxIcon.Error); } Cursor.Current = Cursors.Default; }