private void ServiceTimer_Tick(object sender, System.Timers.ElapsedEventArgs e) { try { this.timer.Stop(); Log("timer stopped"); try { int instances = 0; //Check for more then one instance of program running foreach (Process P in Process.GetProcessesByName("WaldenFaxService")) { instances++; } //Do not run more then one instance of program if (instances > 1) { return; } applicationPath = Process.GetCurrentProcess().MainModule.FileName .Replace("WaldenFaxProgram.exe", "") .Replace("WaldenFaxProgram.vshost.exe", ""); SendOutGoingFaxes(); sendMultiTechFax = new SendFaxMultitech(); sendMultiTechFax.GetFaxResults(ConfigurationValues.PathToProcessXMLFiles); } catch { } this.timer.Start(); Log("timer started"); } catch (Exception er) { this.timer.Start(); Log("timer started Error 6"); } }
public static void SendOutGoingFaxes() { string returnString = string.Empty; try { using (SqlConnection cn = new SqlConnection(ConfigurationValues.WaldenFaxConnection)) { cn.Open(); using (SqlCommand cm = cn.CreateCommand()) { cm.CommandText = "SELECT FaxName,FaxPath," + " RecipientName,FaxNumber,SendID,FaxPath" + " from FaxesSendServer" + " where FaxSent = 'N'" + "order by faxsent,createtime desc"; SqlDataReader dr = cm.ExecuteReader(); while (dr.Read()) { sendMultiTechFax = new SendFaxMultitech(); returnString = string.Empty; returnString = sendMultiTechFax.SendTheFax(dr.GetString(0), dr.GetString(1), dr.GetString(2), dr.GetString(3), dr.GetInt32(4).ToString(), ConfigurationValues.PathToProcessXMLFiles); if (returnString == "OK") { ExecuteInsertUpdateDelete( "update FaxesSendServer " + " set FaxSent = 'Y'" + " where SendID = " + dr.GetInt32(4).ToString()); } else { //Logging.Log(returnString); } } } } } catch (Exception er) { try { //Debug.WriteLine(er.Message); //Common.Log(er.Message); } catch (Exception mer) { // Common.Log(mer.Message); } } }