Example #1
0
        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;
        }