public SpoolerResult StartSession(string spooler_app_and_path, string working_dir, string spooler_arguments, int start_delay) { Trace.WriteLine("SpoolerClient2.StartSession"); MyDebugLogger.Add("SpoolerClient::StartSession", "Starting", DebugLogger.LogType.Secondary); SpoolerResult spoolerResult = SpoolerResult.Fail_Connect; try { var spoolerConnection = new RemoteSpoolerConnection(spooler_app_and_path, working_dir, spooler_arguments); MyDebugLogger.Add("SpoolerClient::StartSession", "Remote Connection Object Created", DebugLogger.LogType.Secondary); spoolerConnection.StartUpDelay = start_delay; spoolerConnection.UseNoSpoolerMode = __use_no_spooler_mode; spoolerConnection.XMLProcessor = new OnReceiveXMLFromSpooler(ProcessXMLFromServer); spoolerConnection.StartUp(42345); MyDebugLogger.Add("SpoolerClient::StartSession", "Socket Client Initialized", DebugLogger.LogType.Secondary); spooler_connection = spoolerConnection; spoolerResult = InitialConnect(); Trace.WriteLine(string.Format("SpoolerClient2.StartSession Completed {0}", spoolerResult)); MyDebugLogger.Add("SpoolerClient::StartSession", "Connected to Spooler", DebugLogger.LogType.Secondary); } catch (Exception ex) { ErrorLogger.LogException("Exception in SpoolerClient2.StartSession " + ex.Message, ex); spooler_connection = null; CloseSession(); } if (spooler_connection != null) { StartThreads(); } MyDebugLogger.Add("SpoolerClient::StartSession", "SpoolerClient threads created", DebugLogger.LogType.Secondary); return(spoolerResult); }
public void CloseSession() { MyDebugLogger.Add("SpoolerClient::CloseSession", "Closing Session", DebugLogger.LogType.Secondary); threadsAborted.Value = true; MyDebugLogger.Add("SpoolerClient::CloseSession", "Stopping Threads", DebugLogger.LogType.Secondary); processing_thread = null; message_thread = null; if (spooler_connection != null) { spooler_connection.ShutdownConnection(); MyDebugLogger.Add("SpoolerClient::CloseSession", "Connection Shutdown", DebugLogger.LogType.Secondary); } if (connected_printers != null) { connected_printers.Clear(); } if (new_connected_printers != null) { new_connected_printers.Clear(); } spooler_connection = null; MyDebugLogger.Add("SpoolerClient::CloseSession", "Data Cleared", DebugLogger.LogType.Secondary); }
public SpoolerResult StartInternalSpoolerSession() { Trace.WriteLine("SpoolerClient2.StartSession"); MyDebugLogger.Add("SpoolerClientInternal::StartSession", "Starting", DebugLogger.LogType.Secondary); SpoolerResult spoolerResult = SpoolerResult.Fail_Connect; try { var spoolerConnection = new InternalSpoolerConnection { XMLProcessor = new OnReceiveXMLFromSpooler((this).ProcessXMLFromServer) }; if (!spoolerConnection.StartServer(42345)) { return(SpoolerResult.Fail_Connect); } spoolerConnection.OnReceivedSpoolerShutdownMessage = new EventHandler <EventArgs>(ReceivedSpoolerShutdownMessage); spoolerConnection.OnReceivedSpoolerShowMessage = new EventHandler <EventArgs>(ReceivedSpoolerShowMessage); spoolerConnection.OnReceivedSpoolerHideMessage = new EventHandler <EventArgs>(ReceivedSpoolerHideMessage); spooler_connection = spoolerConnection; spoolerResult = InitialConnect(); Trace.WriteLine(string.Format("SpoolerClient2.StartSession Completed {0}", spoolerResult)); MyDebugLogger.Add("SpoolerClientInternal::StartSession", "Connected to Spooler", DebugLogger.LogType.Secondary); } catch (Exception ex) { ErrorLogger.LogException("Exception in SpoolerClient2.StartSession " + ex.Message, ex); spooler_connection = null; CloseSession(); } if (spooler_connection != null) { StartThreads(); } MyDebugLogger.Add("SpoolerClientInternal::StartSession", "SpoolerClient threads created", DebugLogger.LogType.Secondary); return(spoolerResult); }