public void loadCSharpScriptsGuiOnSeparateAppDomainUsingWCF_ManualWay() { // create Wcf Host var wcfHostName = "loadCSharpScriptsGui"; var wcfHost = O2WcfUtils.createWcfHostAndStartIt(wcfHostName); IO2WcfKernelMessage o2WcfClientProxy = wcfHost.getClientProxy(); Assert.That(o2WcfClientProxy.allOK(), "o2WcfProxy was not OK"); // create separateAppDomain var testAppDomain = "AppDomainWithCSharpScripts"; var targetAssemblies = new List <string> { typeof(StartCSharpScriptGui).Assembly.Location }; var directoryWithSourceAssemblies = DI.config.hardCodedO2LocalBuildDir; var dependentAssemblies = new CecilAssemblyDependencies(targetAssemblies, new List <string> { directoryWithSourceAssemblies }).calculateDependencies(); o2WcfClientProxy.createAppDomainWithDlls(testAppDomain, new List <string>(dependentAssemblies.Values)); // will just open an empty O2 Gui //o2WcfClientProxy.invokeOnAppDomainObject(testAppDomain, "O2AscxGUI", "launch",null); // open the CSharpScripts O2 Module by simulating the Main execution invocation o2WcfClientProxy.invokeOnAppDomainObject(testAppDomain, typeof(StartCSharpScriptGui).FullName, "Main", new object[0]); o2WcfClientProxy.invokeOnAppDomainObject(testAppDomain, "O2AscxGUI", "logInfo", new[] { "Hello from Unit test" }); // Processes.Sleep(2000); o2WcfClientProxy.invokeOnAppDomainObject(testAppDomain, "O2AscxGUI", "close", null); // o2WcfClientProxy.invokeOnAppDomainObject(testAppDomain); //O2WcfUtils. wcfHost.stopHost(); }
public void test_openCirDataControlUsingLocalWcfHost() { O2WcfUtils.createWcfHostForThisO2KernelProcess(); IO2WcfKernelMessage o2WcfProxy = O2WcfUtils.getClientProxyForThisO2KernelProcess(); var ascxControlName = "Cir Analysis"; Assert.That(o2WcfProxy.allOK(), "o2WcfProxy.allOK() returned false"); DI.log.info("o2WcfProxy.allOK() = {0}", o2WcfProxy.allOK()); Assert.That(Processes.getCurrentProcessID() == o2WcfProxy.getO2KernelProcessId(), "Processes ID should be the same"); o2WcfProxy.O2Messages("openAscxAsForm", new object[] { typeof(ascx_CirAnalysis).FullName, ascxControlName }); o2WcfProxy.O2Messages("executeOnAscxSync", new object[] { ascxControlName, "loadO2CirDataFile", new [] { DI.config.ExecutingAssembly } }); //o2WcfProxy.O2Messages("getAscxSync", new object[] {ascxControlName}); //var cirClasses = o2WcfProxy.O2Messages("executeOnAscxSync", new object[] { ascxControlName, "getClasses", new string[0]}); var cirClasses = o2WcfProxy.getStringListFromAscxControl(ascxControlName, "getClasses", new string[0]); Assert.That(cirClasses != null, "prob with fetched cirClasses object"); Assert.That(cirClasses.Count > 0, "There were no classes returned in cirClasses"); DI.log.info("There were {0} classes returned", cirClasses.Count); var cirFunctions = o2WcfProxy.getStringListFromAscxControl(ascxControlName, "getFunctions", new string[0]); Assert.That(cirFunctions != null && cirFunctions.Count > 0, "prob with fetched cirFunctions object"); DI.log.info("There were {0} functions returned", cirFunctions.Count); o2WcfProxy.O2Messages("closeAscxParent", new object[] { ascxControlName }); WCF_DI.o2WcfKernelMessage.stopHost(); //o2WcfProxy.closeO2KernelProcess(); }
public void sendMessagesToNewKernel() { DI.log.info("in sendMessagesToNewKernel"); o2WcfProxy = O2WcfUtils.createClientProxy(newO2KernelProcessName); Assert.That(o2WcfProxy.allOK(), "o2WcfProxy.allOK() returned false"); Assert.That(!string.IsNullOrEmpty(o2WcfProxy.getName()), "o2WcfProxy.getName() was null or empty"); DI.log.info("o2WcfProxy Name: {0}", o2WcfProxy.getName()); o2WcfProxy.o2ShellCommand("echo Hello_from_another_process"); }
public void CreateRemoteO2KernelAndGetProxy() { var newO2KernelProcessName = "Client_O2Kernel"; DI.log.info("Creating new O2Kernel Process with Name: {0}", DI.config.O2KernelAssemblyName); Processes.startProcess(DI.config.O2KernelAssemblyName, newO2KernelProcessName); o2WcfProxy = O2WcfUtils.createClientProxy(newO2KernelProcessName); Assert.That(o2WcfProxy.allOK(), "o2WcfProxy.allOK() returned false"); Assert.That(!string.IsNullOrEmpty(o2WcfProxy.getName()), "o2WcfProxy.getName() was null or empty"); }
public void o2ShellCommand(string shellCommandToExecute) { O2WcfUtils.wcfMessageReceived("WcfRequest: shellCommandToExecute( " + shellCommandToExecute + " )"); if (WCF_DI.o2Shell != null) { WCF_DI.o2Shell.shellExecution.execute(shellCommandToExecute); } else { WCF_DI.log.error("received sendO2ShellCommand command but no O2Shell is currently available"); } }
public bool createAppDomainWithDlls(string appDomainName, List <string> dllsOfDllsToLoadInNewAppDomain) { try { O2WcfUtils.wcfMessageReceived("WcfRequest: createAppDomainWithDlls( " + appDomainName + " , with " + dllsOfDllsToLoadInNewAppDomain.Count + " dlls)"); var appDomainTempDirectory = WCF_DI.config.TempFolderInTempDirectory; new O2AppDomainFactory(appDomainName, appDomainTempDirectory, dllsOfDllsToLoadInNewAppDomain); return(true); } catch (Exception) { return(false); } }
public static void Main(string[] args) { if (args.Length == 1) { AppDomainUtils.renameCurrentO2KernelProcessName(args[0]); O2WcfUtils.createWcfHostForThisO2KernelProcess(); } WCF_DI.o2Shell = new O2Shell(); WCF_DI.o2Shell.startShell(); if (WCF_DI.o2WcfKernelMessage != null) { WCF_DI.o2WcfKernelMessage.stopHost(); } }
public void test_openCirDataControlOnSeparateAppDomainViaWcf() { // First we need to figure out which DLL has the type we need var targetAssemblies = new List <string> { typeof(ascx_CirAnalysis).Assembly.Location, typeof(O2AscxGUI).Assembly.Location }; //Assert.That(File.Exists(targetAssembly), "could not find assembly: " + targetAssembly); var dependentAssemblies = new CecilAssemblyDependencies(targetAssemblies, new List <string> { DI.config.hardCodedO2LocalBuildDir }).calculateDependencies(); Assert.That(dependentAssemblies.Count > 0, "There we no dependencies calculated"); DI.log.info("There are {0} dependent assemblies", dependentAssemblies.Count); // StringsAndLists.showListContents(dependentAssemblies); // uncoment to see list of dlls var wcfHost = O2WcfUtils.createWcfHostForThisO2KernelProcess(); IO2WcfKernelMessage o2WcfProxy = O2WcfUtils.getClientProxyForThisO2KernelProcess(); runTestsViaWcfProxy(o2WcfProxy); // now that all tests are completed close host wcfHost.stopHost(); }
public void test_openCirDataControlOnRemoteWcfHost() { DI.log.info("Creating new O2Kernel Process with Name: {0}", DI.config.O2KernelAssemblyName); Processes.startProcess(DI.config.O2KernelAssemblyName, newO2KernelProcessName); IO2WcfKernelMessage o2WcfProxy = O2WcfUtils.createClientProxy(newO2KernelProcessName); Assert.That(o2WcfProxy.allOK(), "o2WcfProxy.allOK() returned false"); DI.log.info("o2WcfProxy.allOK() = {0}", o2WcfProxy.allOK()); // confirm that o2WcfProxy is running of a different process var currentProcessID = Processes.getCurrentProcessID(); var remoteProcessID = o2WcfProxy.getO2KernelProcessId(); DI.log.info("Processes ID -> Current: {0} remote: {1}", currentProcessID, remoteProcessID); Assert.That(currentProcessID != remoteProcessID, "Processes ID should not be the same"); runTestsViaWcfProxy(o2WcfProxy); // close remote proxy and process var process = Processes.getProcess(o2WcfProxy.getO2KernelProcessId()); o2WcfProxy.closeO2KernelProcess(); process.WaitForExit(); // wait for its exit }
public int getO2KernelProcessId() { O2WcfUtils.wcfMessageReceived("WcfRequest: getCurrentProcessId()"); return(O2Kernel_Processes.getCurrentProcessId()); }
public void closeO2KernelProcess() { O2WcfUtils.wcfMessageReceived("closeO2KernelProcess()"); O2Kernel_Processes.KillCurrentO2Process(1000); }
public string getName() { O2WcfUtils.wcfMessageReceived("getName()"); return(PublicDI.O2KernelProcessName); //set { DI.O2KernelProcessName = value; } }