// save a list (ArrayList) of contacts public static void save_phonebook_items(string book, ArrayList contacts) { Phonebook p; StreamWriter outfile; p = get_book_from_name(book); if (p.Type == "gfax") { // TODO error reporting try { outfile = File.CreateText(p.Path); } catch (Exception e) { Console.WriteLine("save_phonebook_items - Exception in phonebook.cs {0}", e); return; } outfile.WriteLine("#Gfax phone book"); IEnumerator enu = contacts.GetEnumerator(); while (enu.MoveNext()) { GfaxContact c = new GfaxContact(); c = (GfaxContact)enu.Current; outfile.WriteLine("{0}:{1}:{2}", c.PhoneNumber, c.ContactPerson, c.Organization); } outfile.Close(); } }
public static ArrayList get_contacts(Phonebook p) { string buf = null; string[] sa; //char[] ca = {':',':',':'}; delete me ArrayList records = new ArrayList(); StreamReader fp = null; // TODO add popup message if (p.Type == "gfax") { fp = open_phonebook(p); if (fp == null) { Console.WriteLine(Catalog.GetString("Can't open file : {0}"), p.Path); return(records); } while ((buf = fp.ReadLine()) != null) { buf.Trim(); if (buf[0] == '#') { continue; } else { sa = buf.Split(':'); GfaxContact contact = new GfaxContact(); contact.PhoneNumber = sa[0]; contact.ContactPerson = sa[1]; contact.Organization = sa[2]; records.Add(contact); } } fp.Close(); } if (p.Type == "evolution") { EdsPhoneBooks eds = new EdsPhoneBooks(); ArrayList ebooks = new ArrayList(); ebooks = eds.GetPhoneBooks(); IEnumerator enu = ebooks.GetEnumerator(); while (enu.MoveNext()) { if ((string)enu.Current == p.Name) { records = eds.GetContacts((string)enu.Current); } } } return(records); }
private void on_PhonebookComboBox_changed(object o, EventArgs args) { ArrayList contacts = null; Phonebook p; // get the first book in the list and load the liststore if (myPhoneBooks.Length > 0) { string[] list = new string[myPhoneBooks.Length]; if (myPhoneBooks != null) { // populate the list int i = 0; foreach (Phonebook pb in myPhoneBooks) { list[i++] = pb.Name; } } p = Phonetools.get_book_from_name(list[PhonebookComboBox.Active]); if (p == null) { return; } // Clear the list_store ItemStore.Clear(); contacts = Phonetools.get_contacts(p); if (contacts != null) { IEnumerator enu = contacts.GetEnumerator(); while (enu.MoveNext()) { GfaxContact c = new GfaxContact(); c = (GfaxContact)enu.Current; ItemView.AddTextToRow(c.Organization, c.PhoneNumber, c.ContactPerson); } if (p.Type == "evolution") { pbIsReadOnly = true; EditPhbCompanyEntry.Sensitive = false; EditPhbNumberEntry.Sensitive = false; EditPhbNameEntry.Sensitive = false; } else { pbIsReadOnly = false; EditPhbCompanyEntry.Sensitive = true; EditPhbNumberEntry.Sensitive = true; EditPhbNameEntry.Sensitive = true; eventsEnabled = true; } } } }
public ArrayList GetContacts(string bookName) { string contact_fax = null; ArrayList ebooks = new ArrayList(); ArrayList records = new ArrayList(); SourceList slist = new SourceList ("/apps/evolution/addressbook/sources"); if (slist != null) { SList group_list = slist.Groups; foreach (SourceGroup group in group_list) { //Only get phone books on this machine. if (group.Name == "On This Computer") { SList src_list = group.Sources; foreach (Evolution.Source src in src_list) { if (src.Name == bookName) { //Book bk = Book.NewSystemAddressbook (); Book bk = new Book(src); bk.Open (true); BookQuery q = BookQuery.AnyFieldContains (""); Contact[] contactlist = bk.GetContacts (q); //Console.WriteLine ("Contact count (range) : {0}", contactlist.Length); if (contactlist != null) { foreach (Contact comp in contactlist) { contact_fax = null; if (comp.BusinessFax != null && comp.BusinessFax != String.Empty) { contact_fax = comp.BusinessFax; } else if (comp.OtherFax != null && comp.OtherFax != String.Empty) { contact_fax = comp.OtherFax; } else if (comp.HomeFax != null && comp.HomeFax != String.Empty) { contact_fax = comp.HomeFax; } if (contact_fax != null) { GfaxContact gc = new GfaxContact(); //Console.WriteLine ("Id: {0}", comp.Id); gc.PhoneNumber = contact_fax; gc.ContactPerson = comp.FullName; gc.Organization = comp.Org; records.Add(gc); } } } } } } } } return records; }
private void on_ok_button_clicked(object o, EventArgs args) { ArrayList lsdest = new ArrayList(); ArrayList bsdest = new ArrayList(); ArrayList contacts = new ArrayList(); lsdest = ls.GetSelections(ALL_COLUMNS); // if there are indiviual entries don't do entire phonebooks if (lsdest.Count > 0) { IEnumerator enu = lsdest.GetEnumerator(); while (enu.MoveNext()) { GfaxContact c = new GfaxContact(); c.Organization = (string)enu.Current; enu.MoveNext(); c.PhoneNumber = (string)enu.Current; enu.MoveNext(); c.ContactPerson = (string)enu.Current; gfax.Destinations.Add(c); } } else { bsdest = bs.GetSelections(COLUMN_0); if (bsdest.Count > 0) { IEnumerator enu = bsdest.GetEnumerator(); while (enu.MoveNext()) { foreach (Phonebook p in myPhoneBooks) { if (p.Name == (string)enu.Current) { contacts = Phonetools.get_contacts(p); } } // add contacts to global desinations if (contacts.Count > 0) { IEnumerator enuc = contacts.GetEnumerator(); while (enuc.MoveNext()) { gfax.Destinations.Add((GfaxContact)enuc.Current); } } } } } phbd.Destroy(); }
private void on_SaveCloseButton_clicked(object o, EventArgs args) { ArrayList rows; ArrayList contacts = new ArrayList(); string book; if (myPhoneBooks.Length > 0) { string[] list = new string[myPhoneBooks.Length]; if (myPhoneBooks != null) { // populate the list int i = 0; foreach (Phonebook pb in myPhoneBooks) { list[i++] = pb.Name; } } book = list[PhonebookComboBox.Active]; // just get all items and save SaveCloseButton.Sensitive = false; //eventsEnabled = false; EditPhbCompanyEntry.Text = ""; EditPhbNumberEntry.Text = ""; EditPhbNameEntry.Text = ""; rows = ItemView.GetAllRows(); IEnumerator enu = rows.GetEnumerator(); while (enu.MoveNext()) { GfaxContact c = new GfaxContact(); c.Organization = ((string[])enu.Current)[0]; c.PhoneNumber = ((string[])enu.Current)[1]; c.ContactPerson = ((string[])enu.Current)[2]; contacts.Add(c); } Phonetools.save_phonebook_items(book, contacts); //EditPhbList.Selection.UnselectAll(); } PhbookWindow.Destroy(); Application.Quit(); }
// loads the phone book into list_store private void load_phone_book(Phonebook p) { ArrayList contacts = null; // Clear the list_store list_store.Clear(); contacts = Phonetools.get_contacts(p); if (contacts == null) { return; } IEnumerator enu = contacts.GetEnumerator(); while (enu.MoveNext()) { GfaxContact c = new GfaxContact(); c = (GfaxContact)enu.Current; ls.AddTextToRow(c.Organization, c.PhoneNumber, c.ContactPerson); } }
// save a list (ArrayList) of contacts public static void save_phonebook_items(string book, ArrayList contacts) { Phonebook p; StreamWriter outfile; p = get_book_from_name(book); if (p.Type == "gfax") { // TODO error reporting try { outfile = File.CreateText(p.Path); } catch (Exception e) { Console.WriteLine("save_phonebook_items - Exception in phonebook.cs {0}", e); return; } outfile.WriteLine("#Gfax phone book"); IEnumerator enu = contacts.GetEnumerator(); while ( enu.MoveNext() ) { GfaxContact c = new GfaxContact(); c = (GfaxContact)enu.Current; outfile.WriteLine("{0}:{1}:{2}",c.PhoneNumber,c.ContactPerson,c.Organization); } outfile.Close(); } }
public static ArrayList get_contacts(Phonebook p) { string buf = null; string[] sa; //char[] ca = {':',':',':'}; delete me ArrayList records = new ArrayList(); StreamReader fp = null; // TODO add popup message if ( p.Type == "gfax" ) { fp = open_phonebook(p); if (fp == null) { Console.WriteLine(Catalog.GetString("Can't open file : {0}"), p.Path); return records; } while ( (buf = fp.ReadLine()) != null ) { buf.Trim(); if (buf[0] == '#') continue; else { sa = buf.Split(':'); GfaxContact contact = new GfaxContact(); contact.PhoneNumber = sa[0]; contact.ContactPerson = sa[1]; contact.Organization = sa[2]; records.Add(contact); } } fp.Close(); } if ( p.Type == "evolution" ) { EdsPhoneBooks eds = new EdsPhoneBooks(); ArrayList ebooks = new ArrayList(); ebooks = eds.GetPhoneBooks(); IEnumerator enu = ebooks.GetEnumerator(); while ( enu.MoveNext() ) { if ((string)enu.Current == p.Name) { records = eds.GetContacts((string)enu.Current); } } } return records; }
private void on_SaveCloseButton_clicked(object o, EventArgs args) { ArrayList rows; ArrayList contacts = new ArrayList(); string book; if ( myPhoneBooks.Length > 0) { string[] list = new string[myPhoneBooks.Length]; if ( myPhoneBooks != null ) { // populate the list int i = 0; foreach (Phonebook pb in myPhoneBooks) list[i++] = pb.Name; } book = list[PhonebookComboBox.Active]; // just get all items and save SaveCloseButton.Sensitive = false; //eventsEnabled = false; EditPhbCompanyEntry.Text = ""; EditPhbNumberEntry.Text = ""; EditPhbNameEntry.Text = ""; rows = ItemView.GetAllRows(); IEnumerator enu = rows.GetEnumerator(); while ( enu.MoveNext() ) { GfaxContact c = new GfaxContact(); c.Organization = ((string[])enu.Current)[0]; c.PhoneNumber = ((string[])enu.Current)[1]; c.ContactPerson = ((string[])enu.Current)[2]; contacts.Add(c); } Phonetools.save_phonebook_items(book, contacts); //EditPhbList.Selection.UnselectAll(); } PhbookWindow.Destroy(); Application.Quit (); }
private void on_PhonebookComboBox_changed(object o, EventArgs args) { ArrayList contacts = null; Phonebook p; // get the first book in the list and load the liststore if ( myPhoneBooks.Length > 0) { string[] list = new string[myPhoneBooks.Length]; if ( myPhoneBooks != null ) { // populate the list int i = 0; foreach (Phonebook pb in myPhoneBooks) { list[i++] = pb.Name; } } p = Phonetools.get_book_from_name(list[PhonebookComboBox.Active]); if (p == null) return; // Clear the list_store ItemStore.Clear(); contacts = Phonetools.get_contacts(p); if (contacts != null) { IEnumerator enu = contacts.GetEnumerator(); while ( enu.MoveNext() ) { GfaxContact c = new GfaxContact(); c = (GfaxContact)enu.Current; ItemView.AddTextToRow(c.Organization, c.PhoneNumber, c.ContactPerson); } if (p.Type == "evolution") { pbIsReadOnly = true; EditPhbCompanyEntry.Sensitive = false; EditPhbNumberEntry.Sensitive = false; EditPhbNameEntry.Sensitive = false; } else { pbIsReadOnly = false; EditPhbCompanyEntry.Sensitive = true; EditPhbNumberEntry.Sensitive = true; EditPhbNameEntry.Sensitive = true; eventsEnabled = true; } } } }
private void on_ok_button_clicked(object o, EventArgs args) { ArrayList lsdest = new ArrayList(); ArrayList bsdest = new ArrayList(); ArrayList contacts = new ArrayList(); lsdest = ls.GetSelections(ALL_COLUMNS); // if there are indiviual entries don't do entire phonebooks if (lsdest.Count > 0) { IEnumerator enu = lsdest.GetEnumerator(); while ( enu.MoveNext() ) { GfaxContact c = new GfaxContact(); c.Organization = (string)enu.Current; enu.MoveNext(); c.PhoneNumber = (string)enu.Current; enu.MoveNext(); c.ContactPerson = (string)enu.Current; gfax.Destinations.Add(c); } } else { bsdest = bs.GetSelections(COLUMN_0); if ( bsdest.Count > 0 ) { IEnumerator enu = bsdest.GetEnumerator(); while ( enu.MoveNext() ) { foreach (Phonebook p in myPhoneBooks) if (p.Name == (string)enu.Current) contacts = Phonetools.get_contacts(p); // add contacts to global desinations if (contacts.Count > 0) { IEnumerator enuc = contacts.GetEnumerator(); while ( enuc.MoveNext() ) gfax.Destinations.Add((GfaxContact)enuc.Current); } } } } phbd.Destroy(); }
// loads the phone book into list_store private void load_phone_book(Phonebook p) { ArrayList contacts = null; // Clear the list_store list_store.Clear(); contacts = Phonetools.get_contacts(p); if (contacts == null) return; IEnumerator enu = contacts.GetEnumerator(); while ( enu.MoveNext() ) { GfaxContact c = new GfaxContact(); c = (GfaxContact)enu.Current; ls.AddTextToRow(c.Organization, c.PhoneNumber, c.ContactPerson); } }
// Method send(string directory, contact) // // Sequence to send a file is: public void send(string directory, GfaxContact contact) { StreamWriter outfile; int pages; string emailAddress = Settings.EmailAddress; string emailNotify = "none"; // Get advanced options if (gfax.fromSendWizard) { if (gfax.sendWizardEmailNotify) { emailNotify = "done"; emailAddress = gfax.sendWizardEmailAddress; } } else { if (Settings.EmailNotify) emailNotify = "done"; } //2004/03/09 18.01.51 // Format time to send DateTime st = DateTime.Now; string tts = String.Format("{0}/{1:00}/{2:00} {3:00}.{4:00}.00", st.Year, st.Month, st.Day, st.Hour, st.Minute); // get next jobid if ( Settings.EfaxNextJobid > 998 ) Settings.EfaxNextJobid = 1; else Settings.EfaxNextJobid++; // open directory and count files, that will be the number of pages. pages = Directory.GetFiles(directory).Length; // build filename Random rand = new Random(); string rand_file = rand.Next().ToString(); string tfname = String.Format("{0}/C_{1}.{2}",gfax.SpoolDirectory, contact.PhoneNumber, rand_file); // TODO error stuff //Open new status file try { outfile = File.CreateText(tfname); } catch (Exception e) { Console.WriteLine("[Efax.send] Exception: {0}", e); return; } outfile.Write("Jobid="); outfile.WriteLine(Settings.EfaxNextJobid); outfile.Write("JobDirectory="); outfile.WriteLine(directory); outfile.Write("PhoneNumber="); outfile.WriteLine(contact.PhoneNumber); outfile.Write("Status="); outfile.WriteLine("P"); outfile.Write("Owner="); outfile.WriteLine(Environment.GetEnvironmentVariable("USERNAME")); outfile.Write("Pages="); outfile.WriteLine(pages.ToString()); outfile.Write("Dials="); outfile.WriteLine(0); outfile.Write("Sendat="); outfile.WriteLine(tts); outfile.Write("Notification="); outfile.WriteLine(emailNotify); outfile.Write("Email="); outfile.WriteLine(emailAddress); outfile.Write("ErrorMessage="); outfile.WriteLine(""); outfile.Close(); // jobid might need to be Convert.ToInt32 }
// When finished gfax.Destinations will contain a list of contacts // of Phonebook.Contact type. private void on_SendfaxButton_clicked(object o, EventArgs args) { Gtk.TreeIter iter = new Gtk.TreeIter(); ArrayList rows = new ArrayList(); if (includeFilename == "do_filename") { filename = FilenameEntry.Text; } if (!File.Exists(filename)) { MessageDialog md; md = new MessageDialog(null, DialogFlags.DestroyWithParent, MessageType.Info, ButtonsType.Ok, Catalog.GetString( @" The file you have entered does not exist. Please check the name and try again.") ); md.Run(); md.Destroy(); return; } // clear all the distinations, it's a little wierd yup gfax.Destinations.Clear(); // Get the first row. ItemStore.GetIterFirst(out iter); try { if ((bool)ItemStore.GetValue(iter, 0)) // if send is true (toggle set) { GfaxContact c = new GfaxContact(); c.PhoneNumber = (string)ItemStore.GetValue(iter, 1); // number c.Organization = (string)ItemStore.GetValue(iter, 2); // organization c.ContactPerson = (string)ItemStore.GetValue(iter, 3); // contact rows.Add(c); } } catch (Exception e) { Console.WriteLine("[guitools.on_faxsendbutton_clicked] Exception: {0}", e); MessageDialog md; md = new MessageDialog( null, DialogFlags.DestroyWithParent, MessageType.Info, ButtonsType.Ok, Catalog.GetString( @" You have not entered a facsimile number! Please enter a number and press the <i><b>Enter</b></i> key or click the <i><b>Phone Book</b></i> button to select numbers or entire phone books.") ); md.Run(); md.Destroy(); return; } // get the rest of the rows while (ItemStore.IterNext(ref iter)) { try { if ((bool)ItemStore.GetValue(iter, 0)) // if send is true (toggle set) { GfaxContact c = new GfaxContact(); c.PhoneNumber = (string)ItemStore.GetValue(iter, 1); // number c.Organization = (string)ItemStore.GetValue(iter, 2); // organization c.ContactPerson = (string)ItemStore.GetValue(iter, 3); // contact rows.Add(c); } } catch (Exception e) { Console.WriteLine("[guitools.onfaxsendbutton_clicked] Exception: {0}", e); } } if (SendCheckbutton.Active) { gfax.timeToSend = DateTime.UtcNow; } else { // Convert to UTC for Hylafax gfax.timeToSend = (SendDateedit.Time).ToUniversalTime(); } gfax.Destinations = rows; //get the fine resolution status gfax.sendWizardResolution = ResolutionCheckbutton.Active; //get the email flag and email address gfax.sendWizardEmailNotify = EmailCheckbutton.Active; gfax.sendWizardEmailAddress = EmailEntry.Text; if (gfax.Destinations.Count > 0) { dosend = true; // yes send the fax } //((Gtk.Window) gxml["NewFaxDialog"]).Hide(); NewFaxDialog.Hide(); Application.Quit(); }
public ArrayList GetContacts(string bookName) { string contact_fax = null; ArrayList ebooks = new ArrayList(); ArrayList records = new ArrayList(); SourceList slist = new SourceList("/apps/evolution/addressbook/sources"); if (slist != null) { SList group_list = slist.Groups; foreach (SourceGroup group in group_list) { //Only get phone books on this machine. if (group.Name == "On This Computer") { SList src_list = group.Sources; foreach (Evolution.Source src in src_list) { if (src.Name == bookName) { //Book bk = Book.NewSystemAddressbook (); Book bk = new Book(src); bk.Open(true); BookQuery q = BookQuery.AnyFieldContains(""); Contact[] contactlist = bk.GetContacts(q); //Console.WriteLine ("Contact count (range) : {0}", contactlist.Length); if (contactlist != null) { foreach (Contact comp in contactlist) { contact_fax = null; if (comp.BusinessFax != null && comp.BusinessFax != String.Empty) { contact_fax = comp.BusinessFax; } else if (comp.OtherFax != null && comp.OtherFax != String.Empty) { contact_fax = comp.OtherFax; } else if (comp.HomeFax != null && comp.HomeFax != String.Empty) { contact_fax = comp.HomeFax; } if (contact_fax != null) { GfaxContact gc = new GfaxContact(); //Console.WriteLine ("Id: {0}", comp.Id); gc.PhoneNumber = contact_fax; gc.ContactPerson = comp.FullName; gc.Organization = comp.Org; records.Add(gc); } } } } } } } } return(records); }
// Method send(string filename_on_server, Contact contact) // // Sequence to send a file is: // a) job_new [job_new] // b) set all job parms [job_parm_set] // c) submit the job [submit_job] // format send time - should be as such: // yyyymmddhhmm //-> JPARM SENDTIME 200403100509 //213 SENDTIME set to 20040310050900. public void send(string remote_fname, GfaxContact contact) { if (Settings.Faxtracing == true) { Console.WriteLine("Hylafax.send] top of method..."); } string emailAddress = Settings.EmailAddress; if (Settings.Faxtracing == true) { Console.WriteLine("Hylafax.send] email address {0}", emailAddress); } string resolution = "98"; string emailNotify = "none"; if (Settings.Faxtracing == true) { Console.WriteLine("[Hylafax.send] gfax.timeToSend : {0}", gfax.timeToSend); Console.WriteLine("[Hylafax.send] Remote file name is : {0}", remote_fname); } // if this is sent from GfaxSend wizard if (gfax.fromSendWizard) { if (gfax.sendWizardResolution) resolution = "196"; if (gfax.sendWizardEmailNotify) { emailNotify = "done"; emailAddress = gfax.sendWizardEmailAddress; } } else { if (Settings.EmailNotify) emailNotify = "done"; if (Settings.HiResolution) resolution = "196"; } // Format time to send - timezone is in UTC format. string tts = String.Format("{0}{1:00}{2:00}{3:00}{4:00}", gfax.timeToSend.Year, gfax.timeToSend.Month, gfax.timeToSend.Day, gfax.timeToSend.Hour, gfax.timeToSend.Minute); string jid = job_new(); //TODO try catch exception here //#item[1] is the name #item[2] is the company job_param_set("FROMUSER", Environment.UserName); job_param_set("LASTTIME", "000259"); job_param_set("SENDTIME", tts); job_param_set("MAXDIALS", "12"); job_param_set("MAXTRIES", "3"); job_param_set("SCHEDPRI", "127"); job_param_set("DIALSTRING", contact.PhoneNumber); job_param_set("NOTIFYADDR", emailAddress); job_param_set("VRES", resolution); job_param_set("PAGEWIDTH", "215"); job_param_set("PAGELENGTH", "279"); job_param_set("NOTIFY", emailNotify); //can be "none" or "done" job_param_set("PAGECHOP", "default"); job_param_set("CHOPTHRESHOLD", "3"); job_param_set("DOCUMENT", remote_fname); job_submit(); }
public static void sendfax(string fname) { string remote_fname; if (Settings.Faxtracing == true) { Console.WriteLine("[Fax.sendfax] File name is : {0}", fname); } if (Settings.TransmitAgent == "hylafax") { Hylafax hfaxsf = new Hylafax(); // hylafax actually stores the file to the server hfaxsf.connect(); remote_fname = hfaxsf.send_init(fname); // if "Cancel" button pressed on progess bar if (remote_fname == "cancelled") { return; } if (Settings.Faxtracing == true) { if (Settings.TransmitAgent == "hylafax") { Console.WriteLine("[Fax.sendfax] Remote file name is : {0}", remote_fname); } } //System.Threading.Thread.Sleep(2000); IEnumerator enu = gfax.Destinations.GetEnumerator(); if (Settings.Faxtracing == true) { if (Settings.TransmitAgent == "hylafax") { Console.WriteLine("[Fax.sendfax] Destinations has a count of : {0}", gfax.Destinations.Count); } } while (enu.MoveNext()) { // TODO try catch exception here GfaxContact c = (GfaxContact)enu.Current; if (Settings.Faxtracing == true) { if (Settings.TransmitAgent == "hylafax") { Console.WriteLine("[Fax.sendfax] In while loop contact is -----> {0}", c.PhoneNumber); } } hfaxsf.send(remote_fname, c); if (Settings.Faxtracing == true) { if (Settings.TransmitAgent == "hylafax") { Console.WriteLine("[Fax.sendfax] In while loop bottom... "); } } //System.Threading.Thread.Sleep(1000); // open the log and log out going fax to server // Date Time PhoneNumber Organization ContactPerson // log file is in ~/.etc/gfax //if (Settings.LogEnabled) //log_it((GfaxContact)enu.Current); } if (Settings.Faxtracing == true) { if (Settings.TransmitAgent == "hylafax") { Console.WriteLine("[Fax.sendfax] End of send contact loop..."); } } hfaxsf = null; } //Efax transport if (Settings.TransmitAgent == "efax") { // Convert the file with ghostscript string directory = gfax.efax.send_init(fname); if (directory == "cancelled") { return; } IEnumerator enu = gfax.Destinations.GetEnumerator(); while (enu.MoveNext()) { gfax.efax.send(directory, (GfaxContact)enu.Current); if (Settings.LogEnabled) { log_it((GfaxContact)enu.Current); } } } }
public static void log_it(GfaxContact contact) { }
// Method send(string filename_on_server, Contact contact) // // Sequence to send a file is: // a) job_new [job_new] // b) set all job parms [job_parm_set] // c) submit the job [submit_job] // format send time - should be as such: // yyyymmddhhmm //-> JPARM SENDTIME 200403100509 //213 SENDTIME set to 20040310050900. public void send(string remote_fname, GfaxContact contact) { if (Settings.Faxtracing == true) { Console.WriteLine("Hylafax.send] top of method..."); } string emailAddress = Settings.EmailAddress; if (Settings.Faxtracing == true) { Console.WriteLine("Hylafax.send] email address {0}", emailAddress); } string resolution = "98"; string emailNotify = "none"; if (Settings.Faxtracing == true) { Console.WriteLine("[Hylafax.send] gfax.timeToSend : {0}", gfax.timeToSend); Console.WriteLine("[Hylafax.send] Remote file name is : {0}", remote_fname); } // if this is sent from GfaxSend wizard if (gfax.fromSendWizard) { if (gfax.sendWizardResolution) { resolution = "196"; } if (gfax.sendWizardEmailNotify) { emailNotify = "done"; emailAddress = gfax.sendWizardEmailAddress; } } else { if (Settings.EmailNotify) { emailNotify = "done"; } if (Settings.HiResolution) { resolution = "196"; } } // Format time to send - timezone is in UTC format. string tts = String.Format("{0}{1:00}{2:00}{3:00}{4:00}", gfax.timeToSend.Year, gfax.timeToSend.Month, gfax.timeToSend.Day, gfax.timeToSend.Hour, gfax.timeToSend.Minute); string jid = job_new(); //TODO try catch exception here //#item[1] is the name #item[2] is the company job_param_set("FROMUSER", Environment.UserName); job_param_set("LASTTIME", "000259"); job_param_set("SENDTIME", tts); job_param_set("MAXDIALS", "12"); job_param_set("MAXTRIES", "3"); job_param_set("SCHEDPRI", "127"); job_param_set("DIALSTRING", contact.PhoneNumber); job_param_set("NOTIFYADDR", emailAddress); job_param_set("VRES", resolution); job_param_set("PAGEWIDTH", "215"); job_param_set("PAGELENGTH", "279"); job_param_set("NOTIFY", emailNotify); //can be "none" or "done" job_param_set("PAGECHOP", "default"); job_param_set("CHOPTHRESHOLD", "3"); job_param_set("DOCUMENT", remote_fname); job_submit(); }
// Method send(string directory, contact) // // Sequence to send a file is: public void send(string directory, GfaxContact contact) { StreamWriter outfile; int pages; string emailAddress = Settings.EmailAddress; string emailNotify = "none"; // Get advanced options if (gfax.fromSendWizard) { if (gfax.sendWizardEmailNotify) { emailNotify = "done"; emailAddress = gfax.sendWizardEmailAddress; } } else { if (Settings.EmailNotify) { emailNotify = "done"; } } //2004/03/09 18.01.51 // Format time to send DateTime st = DateTime.Now; string tts = String.Format("{0}/{1:00}/{2:00} {3:00}.{4:00}.00", st.Year, st.Month, st.Day, st.Hour, st.Minute); // get next jobid if (Settings.EfaxNextJobid > 998) { Settings.EfaxNextJobid = 1; } else { Settings.EfaxNextJobid++; } // open directory and count files, that will be the number of pages. pages = Directory.GetFiles(directory).Length; // build filename Random rand = new Random(); string rand_file = rand.Next().ToString(); string tfname = String.Format("{0}/C_{1}.{2}", gfax.SpoolDirectory, contact.PhoneNumber, rand_file); // TODO error stuff //Open new status file try { outfile = File.CreateText(tfname); } catch (Exception e) { Console.WriteLine("[Efax.send] Exception: {0}", e); return; } outfile.Write("Jobid="); outfile.WriteLine(Settings.EfaxNextJobid); outfile.Write("JobDirectory="); outfile.WriteLine(directory); outfile.Write("PhoneNumber="); outfile.WriteLine(contact.PhoneNumber); outfile.Write("Status="); outfile.WriteLine("P"); outfile.Write("Owner="); outfile.WriteLine(Environment.GetEnvironmentVariable("USERNAME")); outfile.Write("Pages="); outfile.WriteLine(pages.ToString()); outfile.Write("Dials="); outfile.WriteLine(0); outfile.Write("Sendat="); outfile.WriteLine(tts); outfile.Write("Notification="); outfile.WriteLine(emailNotify); outfile.Write("Email="); outfile.WriteLine(emailAddress); outfile.Write("ErrorMessage="); outfile.WriteLine(""); outfile.Close(); // jobid might need to be Convert.ToInt32 }
// When finished gfax.Destinations will contain a list of contacts // of Phonebook.Contact type. private void on_SendfaxButton_clicked(object o, EventArgs args) { Gtk.TreeIter iter = new Gtk.TreeIter(); ArrayList rows = new ArrayList(); if (includeFilename == "do_filename") filename = FilenameEntry.Text; if (!File.Exists(filename)) { MessageDialog md; md = new MessageDialog (null, DialogFlags.DestroyWithParent, MessageType.Info, ButtonsType.Ok, Catalog.GetString( @" The file you have entered does not exist. Please check the name and try again.") ); md.Run (); md.Destroy(); return; } // clear all the distinations, it's a little wierd yup gfax.Destinations.Clear(); // Get the first row. ItemStore.GetIterFirst(out iter); try { if ( (bool)ItemStore.GetValue(iter, 0) ) { // if send is true (toggle set) GfaxContact c = new GfaxContact(); c.PhoneNumber = (string)ItemStore.GetValue(iter, 1); // number c.Organization = (string)ItemStore.GetValue(iter, 2); // organization c.ContactPerson = (string)ItemStore.GetValue(iter, 3); // contact rows.Add(c); } } catch (Exception e) { Console.WriteLine("[guitools.on_faxsendbutton_clicked] Exception: {0}", e); MessageDialog md; md = new MessageDialog ( null, DialogFlags.DestroyWithParent, MessageType.Info, ButtonsType.Ok, Catalog.GetString( @" You have not entered a facsimile number! Please enter a number and press the <i><b>Enter</b></i> key or click the <i><b>Phone Book</b></i> button to select numbers or entire phone books.") ); md.Run (); md.Destroy(); return; } // get the rest of the rows while (ItemStore.IterNext(ref iter)) { try { if ( (bool)ItemStore.GetValue(iter, 0) ) { // if send is true (toggle set) GfaxContact c = new GfaxContact(); c.PhoneNumber = (string)ItemStore.GetValue(iter, 1); // number c.Organization = (string)ItemStore.GetValue(iter, 2); // organization c.ContactPerson = (string)ItemStore.GetValue(iter, 3); // contact rows.Add(c); } } catch (Exception e) { Console.WriteLine("[guitools.onfaxsendbutton_clicked] Exception: {0}", e); } } if (SendCheckbutton.Active) { gfax.timeToSend = DateTime.UtcNow; } else { // Convert to UTC for Hylafax gfax.timeToSend = (SendDateedit.Time).ToUniversalTime(); } gfax.Destinations = rows; //get the fine resolution status gfax.sendWizardResolution = ResolutionCheckbutton.Active; //get the email flag and email address gfax.sendWizardEmailNotify = EmailCheckbutton.Active; gfax.sendWizardEmailAddress = EmailEntry.Text; if ( gfax.Destinations.Count > 0 ) dosend = true; // yes send the fax //((Gtk.Window) gxml["NewFaxDialog"]).Hide(); NewFaxDialog.Hide(); Application.Quit(); }