/// <summary> /// Run the standalone application with the given script context. /// </summary> /// <param name="context">The script context from the plugin script.</param> /// <exception cref="StandaloneRunnerException"> /// An exception occurred while trying to run the standalone application. /// Perhaps the application was not found or an error occurred while /// building the command-line arguments from the script context. /// </exception> public static void RunWith(ScriptContext context) { try { var contextArgs = ScriptContextArgs.From(context); Process.Start(GetStandalonePath(), contextArgs.ToArgs()); } catch (Exception) { throw new StandaloneRunnerException("Unable to launch the application."); } }
/// <summary> /// Creates a new instance of StandaloneScriptContext, initialized /// using the given command-line arguments and Application object. /// </summary> /// <param name="args">The command-line arguments containing the script context.</param> /// <param name="app">The initialized ESAPI Application object.</param> /// <returns>A new instance of the StandaloneScriptContext.</returns> public static StandaloneScriptContext From(string[] args, Application app) { var scriptContext = new StandaloneScriptContext(); scriptContext.CurrentUser = app.CurrentUser; // Note: It's possible that the user from the command-line arguments // and the user that signed in to the standalone app are different, // but the best we can do is return the standalone app user var scArgs = ScriptContextArgs.From(args); scriptContext.ApplicationName = scArgs.ApplicationName; scriptContext.VersionInfo = scArgs.VersionInfo; // If there's no patient, there's nothing else to open if (scArgs.PatientId == null) { return(scriptContext); } var patient = GetPatient(app, scArgs.PatientId); scriptContext.Patient = patient; scriptContext.Course = GetCourse(patient, scArgs.CourseId); scriptContext.Image = GetImage(patient, scArgs.SeriesUid, scArgs.ImageId); scriptContext.StructureSet = GetStructureSet(patient, scArgs.StructureSetId); scriptContext.PlanSetup = GetPlanSetup(patient, scArgs.PlanSetupId, scArgs.CourseId); scriptContext.ExternalPlanSetup = GetExternalPlanSetup(patient, scArgs.ExternalPlanSetupId, scArgs.CourseId); scriptContext.BrachyPlanSetup = GetBrachyPlanSetup(patient, scArgs.BrachyPlanSetupId, scArgs.CourseId); scriptContext.PlansInScope = GetPlansInScope(patient, scArgs.PlansInScopeUids); scriptContext.ExternalPlansInScope = GetExternalPlansInScope(patient, scArgs.ExternalPlansInScopeUids); scriptContext.BrachyPlansInScope = GetBrachyPlansInScope(patient, scArgs.BrachyPlansInScopeUids); scriptContext.PlanSumsInScope = GetPlanSumsInScope(patient, scArgs.PlanSumsInScopeCourseIds, scArgs.PlanSumsInScopeIds); return(scriptContext); }