private void JobSubmitRequestFax_Click_1(object sender, EventArgs e) { //JobSubmitRequest Fax // setup Authentication objects EMsgAPI_Demo.EMsgAPI_JobSubmit_200907.Authentication EMAuthentication = new EMsgAPI_Demo.EMsgAPI_JobSubmit_200907.Authentication(); EMsgAPI_Demo.EMsgAPI_JobSubmit_200907.XDDSAuthType XDDSAuth = new EMsgAPI_Demo.EMsgAPI_JobSubmit_200907.XDDSAuthType(); // init Authentication objects XDDSAuth.Password = txtAccessCode.Text; XDDSAuth.RequesterID = txtUserId.Text; EMAuthentication.XDDSAuth = XDDSAuth; // Setup MessageObject EMsgAPI_Demo.EMsgAPI_JobSubmit_200907.MessageType[] JS_Message = new EMsgAPI_Demo.EMsgAPI_JobSubmit_200907.MessageType[1]; JS_Message[0] = new EMsgAPI_Demo.EMsgAPI_JobSubmit_200907.MessageType(); // Setup JobOptions - CREF, Billing Code, FAX EMsgAPI_Demo.EMsgAPI_JobSubmit_200907.JobOptionsType JS_JobOptions = new EMsgAPI_Demo.EMsgAPI_JobSubmit_200907.JobOptionsType(); EMsgAPI_Demo.EMsgAPI_JobSubmit_200907.EncodableStringType JS_CRef = new EMsgAPI_Demo.EMsgAPI_JobSubmit_200907.EncodableStringType(); EMsgAPI_Demo.EMsgAPI_JobSubmit_200907.EncodableStringType JS_BCode = new EMsgAPI_Demo.EMsgAPI_JobSubmit_200907.EncodableStringType(); EMsgAPI_Demo.EMsgAPI_JobSubmit_200907.FaxOptionsType JS_FaxOptions = new EMsgAPI_Demo.EMsgAPI_JobSubmit_200907.FaxOptionsType(); // Set Start and End Time //DateTime StartDateValue = new DateTime(dateTimePicker1.Value.Year, dateTimePicker1.Value.Month, dateTimePicker1.Value.Day, dateTimePicker1.Value.Hour, dateTimePicker1.Value.Minute, 0, dateTimePicker1.Value.Kind); //DateTime EndDateValue = new DateTime(dateTimePicker2.Value.Year, dateTimePicker2.Value.Month, dateTimePicker2.Value.Day, dateTimePicker2.Value.Hour, dateTimePicker2.Value.Minute, 0, dateTimePicker2.Value.Kind); DateTime StartDateValue = new DateTime(); StartDateValue = DateTime.Now.AddHours(1); DateTime EndDateValue = new DateTime(); EndDateValue = DateTime.Now.AddHours(2); EMsgAPI_Demo.EMsgAPI_JobSubmit_200907.DeliveryType ScheduledDelivery = new EMsgAPI_Demo.EMsgAPI_JobSubmit_200907.DeliveryType(); ScheduledDelivery.Schedule = EMsgAPI_Demo.EMsgAPI_JobSubmit_200907.ScheduleType.scheduled; ScheduledDelivery.ScheduleSpecified = true; ScheduledDelivery.StartTimeSpecified = true; ScheduledDelivery.StopTimeSpecified = true; ScheduledDelivery.StartTime = StartDateValue; ScheduledDelivery.StopTime = EndDateValue; //JS_JobOptions.Delivery = ScheduledDelivery; // set CREF and Billing Code if (txtBC.Text.Length > 0) { JS_BCode.Value = txtBC.Text; JS_JobOptions.BillingCode = JS_BCode; } // BC if (txtCRef.Text.Length > 0) { JS_CRef.Value = txtCRef.Text; JS_JobOptions.CustomerReference = JS_CRef; } // CRef // Set FaxOptions JS_FaxOptions.FaxMode = EMsgAPI_Demo.EMsgAPI_JobSubmit_200907.FaxModeType.fine; JS_FaxOptions.FaxModeSpecified = true; // Set Retry Algo JS_FaxOptions.DeliveryRetryPattern = "11"; //EMsgAPI_Demo.EMsgAPI_JobSubmit_200907.FaxCoversheetOptionType CoverSheet = new EMsgAPI_Demo.EMsgAPI_JobSubmit_200907.FaxCoversheetOptionType(); //CoverSheet.UseCoversheet = EMsgAPI_Demo.EMsgAPI_JobSubmit_200907.YesNo.yes; //JS_FaxOptions.FaxCoversheet = CoverSheet; //// Setup BannerFX options //EMsgAPI_Demo.EMsgAPI_JobSubmit_200907.FaxBannerFxOptionType Banner = new EMsgAPI_Demo.EMsgAPI_JobSubmit_200907.FaxBannerFxOptionType(); //Banner.BannerFxName = "pilot"; //Banner.BannerFxOnCoverSpecified = false; //Banner.BannerFxPlacement = EMsgAPI_Demo.EMsgAPI_JobSubmit_200907.FaxBannerFxPlacementType.outside; //Banner.BannerFxPlacementSpecified = true; //JS_FaxOptions.BannerFX = Banner; //// Set PilotLine EMsgAPI_Demo.EMsgAPI_JobSubmit_200907.FaxPilotlineOptionType PilotLine = new EMsgAPI_Demo.EMsgAPI_JobSubmit_200907.FaxPilotlineOptionType(); switch (txtPilotLine.Text) { case "1": PilotLine.PilotlineStyle = EMsgAPI_Demo.EMsgAPI_JobSubmit_200907.PilotlineStyleType.type1; break; case "2": PilotLine.PilotlineStyle = EMsgAPI_Demo.EMsgAPI_JobSubmit_200907.PilotlineStyleType.type2; break; case "3": PilotLine.PilotlineStyle = EMsgAPI_Demo.EMsgAPI_JobSubmit_200907.PilotlineStyleType.type3; break; case "4": PilotLine.PilotlineStyle = EMsgAPI_Demo.EMsgAPI_JobSubmit_200907.PilotlineStyleType.type4; break; case "5": PilotLine.PilotlineStyle = EMsgAPI_Demo.EMsgAPI_JobSubmit_200907.PilotlineStyleType.type5; break; case "6": PilotLine.PilotlineStyle = EMsgAPI_Demo.EMsgAPI_JobSubmit_200907.PilotlineStyleType.type6; break; case "7": PilotLine.PilotlineStyle = EMsgAPI_Demo.EMsgAPI_JobSubmit_200907.PilotlineStyleType.type7; break; case "8": PilotLine.PilotlineStyle = EMsgAPI_Demo.EMsgAPI_JobSubmit_200907.PilotlineStyleType.type8; break; default: PilotLine.PilotlineStyle = EMsgAPI_Demo.EMsgAPI_JobSubmit_200907.PilotlineStyleType.none; break; } PilotLine.PilotlineStyleSpecified = true; PilotLine.PilotlineText = "PILOTLINETEXT"; //JS_FaxOptions.Pilotline = PilotLine; //// Set Orientation //JS_FaxOptions.PageOrientation = EMsgAPI_Demo.EMsgAPI_JobSubmit_200907.PageOrientationType.landscape; //JS_FaxOptions.PageOrientationSpecified = true; // Set JobOptions as FaxOptions JS_JobOptions.FaxOptions = JS_FaxOptions; // Set Message Object JS_Message[0].JobOptions = JS_JobOptions; // Free Objects JS_JobOptions = null; JS_FaxOptions = null; JS_CRef = null; JS_BCode = null; // Setup Documents EMsgAPI_Demo.EMsgAPI_JobSubmit_200907.DocumentType[] JS_Documents = new EMsgAPI_Demo.EMsgAPI_JobSubmit_200907.DocumentType[2]; JS_Documents[0] = new EMsgAPI_Demo.EMsgAPI_JobSubmit_200907.DocumentType(); // Setup reusable variables for the document EMsgAPI_Demo.EMsgAPI_JobSubmit_200907.DocDataType DocData = new EMsgAPI_Demo.EMsgAPI_JobSubmit_200907.DocDataType(); string File; //// Setup Document 1 - PDF //File = ReadAndEncodedFile(txtPDFDoc.Text); //DocData.format = EMsgAPI_Demo.EMsgAPI_JobSubmit_200907.DocEncodingFormat.base64; //DocData.Value = File; //JS_Documents[0].Item = DocData; //JS_Documents[0].Filename = "PDF_File.pdf"; //JS_Documents[0].DocType = "PDF"; //JS_Documents[0].ItemElementName = EMsgAPI_Demo.EMsgAPI_JobSubmit_200907.ItemChoiceType1.DocData; //JS_Documents[0].@ref = "Doc1"; //DocData = null; // Setup Document 2 - WORD DocData = new EMsgAPI_Demo.EMsgAPI_JobSubmit_200907.DocDataType(); File = ReadAndEncodedFile(txtWordDoc.Text, true); DocData.format = EMsgAPI_Demo.EMsgAPI_JobSubmit_200907.DocEncodingFormat.base64; DocData.Value = File; JS_Documents[0].Item = DocData; EMsgAPI_Demo.EMsgAPI_JobSubmit_200907.EncodableStringType myFileName = new EMsgAPI_Demo.EMsgAPI_JobSubmit_200907.EncodableStringType(); myFileName.Value = "Word_File.doc"; JS_Documents[0].Filename = myFileName; JS_Documents[0].DocType = "MSW"; JS_Documents[0].ItemElementName = EMsgAPI_Demo.EMsgAPI_JobSubmit_200907.ItemChoiceType.DocData; JS_Documents[0].@ref = "Doc1"; DocData = null; //// Setup Document 3 - Text //DocData = new EMsgAPI_Demo.EMsgAPI_JobSubmit_200907.DocDataType(); ////File = ReadAndEncodedFile(txtWordDoc.Text, true); //DocData.format = EMsgAPI_Demo.EMsgAPI_JobSubmit_200907.DocEncodingFormat.text; //DocData.Value = "This is a test document"; //JS_Documents[0].Item = DocData; //JS_Documents[0].Filename = "text.txt"; //JS_Documents[0].DocType = "text"; //JS_Documents[0].ItemElementName = EMsgAPI_Demo.EMsgAPI_JobSubmit_200907.ItemChoiceType.DocData; //JS_Documents[0].@ref = "Doc1"; //DocData = null; if (UseCSVList.Checked == true) { // Setup Document 3 - CSV List DocData = new EMsgAPI_Demo.EMsgAPI_JobSubmit_200907.DocDataType(); File = ReadAndEncodedFile(txtCSVList.Text, true); DocData.format = EMsgAPI_Demo.EMsgAPI_JobSubmit_200907.DocEncodingFormat.base64; DocData.Value = File; JS_Documents[1] = new EMsgAPI_Demo.EMsgAPI_JobSubmit_200907.DocumentType(); JS_Documents[1].Item = DocData; myFileName.Value = "CSVList.csv"; JS_Documents[1].Filename = myFileName; JS_Documents[1].DocType = "text"; JS_Documents[1].ItemElementName = EMsgAPI_Demo.EMsgAPI_JobSubmit_200907.ItemChoiceType.DocData; JS_Documents[1].@ref = "CSVList1"; DocData = null; } // (UseCSVList.Checked == true) // Setup Content EMsgAPI_Demo.EMsgAPI_JobSubmit_200907.ContentPartType[] JS_Content = new EMsgAPI_Demo.EMsgAPI_JobSubmit_200907.ContentPartType[1]; JS_Content[0] = new EMsgAPI_Demo.EMsgAPI_JobSubmit_200907.ContentPartType(); //JS_Content[1] = new EMsgAPI_Demo.EMsgAPI_JobSubmit_200907.ContentPartType(); // Setup references to documents JS_Content[0].Item = "Doc1"; JS_Content[0].Treatment = EMsgAPI_Demo.EMsgAPI_JobSubmit_200907.TreatmentType.body; JS_Content[0].TreatmentSpecified = true; //JS_Content[1].Item = "WordDoc1"; //JS_Content[1].Treatment = EMsgAPI_Demo.EMsgAPI_JobSubmit_200907.TreatmentType.attachment; //JS_Content[1].TreatmentSpecified = true; if (UseCSVList.Checked == true) // Pass in a CSV List with Job Submit { // Setup table for list // List was loaded in document section must be added as a Table in Content Section EMsgAPI_Demo.EMsgAPI_JobSubmit_200907.TableType[] CSVList_Table = new EMsgAPI_Demo.EMsgAPI_JobSubmit_200907.TableType[1]; CSVList_Table[0] = new EMsgAPI_Demo.EMsgAPI_JobSubmit_200907.TableType(); CSVList_Table[0].Item = "CSVList1"; CSVList_Table[0].@ref = "CSVList_Table1"; JS_Message[0].Destinations = CSVList_Table; CSVList_Table = null; } else // Use a previously stored list { // Setup List Object EMsgAPI_Demo.EMsgAPI_JobSubmit_200907.ListType[] lists = new EMsgAPI_Demo.EMsgAPI_JobSubmit_200907.ListType[1]; lists[0] = new EMsgAPI_Demo.EMsgAPI_JobSubmit_200907.ListType(); lists[0].ownershipLevel = EMsgAPI_Demo.EMsgAPI_JobSubmit_200907.OwnershipLevelType.customer; lists[0].ownershipLevelSpecified = true; lists[0].Name = txtStoredList.Text; // Name of stored list lists[0].@ref = "Stored Fax List"; JS_Message[0].Destinations = lists; lists = null; } JS_Message[0].Contents = JS_Content; JS_Message[0].MessageId = System.Environment.MachineName + DateTime.Now; JS_Content = null; // Everything is Setup Prepare to Launch Job // setup EMsgAPI object - EM EMsgAPI_Demo.EMsgAPI_JobSubmit_200907.XOA EM = new EMsgAPI_Demo.EMsgAPI_JobSubmit_200907.XOA(); // Setup Request and JobSubmitRequest object EMsgAPI_Demo.EMsgAPI_JobSubmit_200907.Request Request = new EMsgAPI_Demo.EMsgAPI_JobSubmit_200907.Request(); EMsgAPI_Demo.EMsgAPI_JobSubmit_200907.Response Response = new EMsgAPI_Demo.EMsgAPI_JobSubmit_200907.Response(); EMsgAPI_Demo.EMsgAPI_JobSubmit_200907.JobSubmitRequest JS_Request = new EMsgAPI_Demo.EMsgAPI_JobSubmit_200907.JobSubmitRequest(); EMsgAPI_Demo.EMsgAPI_JobSubmit_200907.JobSubmitResult JS_Result = new EMsgAPI_Demo.EMsgAPI_JobSubmit_200907.JobSubmitResult(); // Setup Proxy server and EMsgAPIConnect URL for posting data Set_Server_and_Proxy(EM); // Setup Reqeust Object if (cmbServer.Text.Contains("Async")) { Request.SenderKey = "http://www.bdrsoftware.com/Service1.asmx"; } // Setup Reqeust Object Request.ReceiverKey = EM.Url; Request.Authentication = EMAuthentication; Request.ResultRequired = EMsgAPI_Demo.EMsgAPI_JobSubmit_200907.RequiredType.yes; Request.ResponseRequiredSpecified = true; Request.RequestID = "RequestID"; JS_Request.SubmitId = "SubmitId"; // Assign Reqeust and Response objects to EM Object EM.RequestValue = Request; EM.ResponseValue = Response; JS_Request.Message = JS_Message; JS_Request.DocumentSet = JS_Documents; try { if (cmbServer.Text.Contains("Async")) { EM.JobSubmit(JS_Request); JS_Result = null; } else JS_Result = EM.JobSubmit(JS_Request); } catch (Exception ex) { System.Console.WriteLine(ex.Message); System.Console.Read(); return; } if (JS_Result != null) { if (JS_Result.Status.StatusCode != null) { string JobNumber; JobNumber = JS_Result.MessageResult[0].JobId.XDN + ":" + JS_Result.MessageResult[0].JobId.MRN; txtJobNumber.Text = JobNumber; } } }