/// <summary> /// Calls the print UI utility. /// </summary> /// <param name="printerPath">The printer path.</param> /// <param name="credential">The credential.</param> private static void CallPrintUi(string printerPath, OfficeWorkerCredential credential = null) { string arg = Resources.PrintUICommand.FormatWith(printerPath); TraceFactory.Logger.Debug(arg); CitrixSessionManager.StartProcess(credential, "CMD.EXE", arg, TimeSpan.FromMinutes(10)); }
internal static void StartPublishedApp(OfficeWorkerCredential credential, string citrixServer, string publishedApp) { Environment.SpecialFolder folder = (Environment.Is64BitOperatingSystem) ? Environment.SpecialFolder.ProgramFilesX86 : Environment.SpecialFolder.ProgramFiles; string resourcePath = Path.Combine ( Environment.GetFolderPath(folder), Resources.WFICA32Path ); credential.WorkingDirectory = Directory.GetCurrentDirectory(); TraceFactory.Logger.Debug("Starting published app {0}".FormatWith(publishedApp)); string icaFile = CitrixSessionManager.CreateIcaFile(credential, citrixServer, publishedApp); CitrixSessionManager.StartProcess(credential, resourcePath, icaFile, TimeSpan.FromSeconds(10)); }
private bool CheckSessionStarted(OfficeWorkerCredential credential, string resourcePath) { bool sessionStarted = false; string appId = string.Empty; // The Citrix Office Worker can run on a Citrix server in two different ways, one as a published // app and the other under a desktop session. This block of code defines how the ICA file // should be constructed in order to run the session in one of the two options. It is based // on the value of the RunMode which is chosen by the user at runtime. switch (_worker.WorkerRunMode) { case CitrixWorkerRunMode.Desktop: string key = "{0}-CitrixWorkerDesktop".FormatWith(_citrixServer); appId = GlobalSettings.Items[key]; if (string.IsNullOrEmpty(appId)) { throw new InvalidOperationException("The CitrixWorkerDesktop System Setting value is missing."); } break; case CitrixWorkerRunMode.PublishedApp: appId = "{0}-OWC".FormatWith(_citrixServer); break; } // Start the worker process on the remote Citrix server by running the ICA client // as administrator, and the ICA config file contains the credentials for the the // actual Office Worker string icaFile = CitrixSessionManager.CreateIcaFile(credential, _citrixServer, appId); CitrixSessionManager.StartProcess(credential, resourcePath, icaFile, TimeSpan.FromSeconds(10)); // The Citrix server will display a Citrix license warning anytime a user is not admin // and is running a client process. So delay here about 10 seconds to let this dialog // display and eventually go away. TraceFactory.Logger.Info("Sleep 20 seconds to wait on Citrix to startup"); Thread.Sleep(TimeSpan.FromSeconds(20)); try { Retry.WhileThrowing ( () => sessionStarted = PingWorker(credential), 10, TimeSpan.FromSeconds(10), new List <Type>() { typeof(FaultException), typeof(EndpointNotFoundException), typeof(SocketException) } ); } catch (FaultException ex) { TraceFactory.Logger.Debug("Ping worker failed (1): {0}".FormatWith(ex.Message)); } catch (EndpointNotFoundException ex) { TraceFactory.Logger.Debug("Ping worker failed (2): {0}".FormatWith(ex.Message)); } catch (SocketException ex) { TraceFactory.Logger.Debug("Ping worker failed (3): {0}".FormatWith(ex.Message)); } catch (Exception ex) { TraceFactory.Logger.Debug("Ping worker failed (4): {0}".FormatWith(ex.Message)); } finally { TraceFactory.Logger.Debug("Session Started: {0}".FormatWith(sessionStarted)); } return(sessionStarted); }