public ProcessReturnValue CallProcess(ProcessInputParams args, ResponseFormType responseForm, bool asynchronous)
        {
            // A secondary operation domain has to be used so that the assemblies can be loaded/unloaded, as the function Assembly
            AppDomain          operationDomain = null;
            ProcessReturnValue result          = null;

            try
            {
                ArrayList methodArgs = new ArrayList();
                methodArgs.Add(args);
                ProcessReturnValue processReturnValue = new ProcessReturnValue();
                processReturnValue.responseForm = responseForm;
                methodArgs.Add(processReturnValue);

                operationDomain = Utils.CreateDomain();
                if (!asynchronous)
                {
                    // Load the assembly corresponding to the requested process
                    Utils.AssemblyLoader assemblyLoader = Utils.AssemblyLoader.Create(operationDomain);
                    assemblyLoader.Load(Utils.MapPath(Global.ProcessesBinPath + Identifier + ".dll"));
                    result = (ProcessReturnValue)assemblyLoader.ExecuteMethod(processClass, processMethod, methodArgs.ToArray(), null);
                    AppDomain.Unload(operationDomain);
                }
                else
                {
                    asyncOperationDomain = operationDomain;
                    asyncLoader          = Utils.AssemblyLoader.Create(operationDomain);
                    asyncLoader.Load(Utils.MapPath(Global.ProcessesBinPath + Identifier + ".dll"));
                    result = (ProcessReturnValue)asyncLoader.ExecuteAsyncMethod(processClass, processMethod, methodArgs.ToArray(), new object[] { AppDomain.CurrentDomain, Global.StoredResultsPath, Utils.ResolveUrl(Global.StoredResultsPath) });
                }
            }
            catch (ExceptionReport e)
            {
                if (operationDomain != null)
                {
                    AppDomain.Unload(operationDomain);
                }
                throw new ExceptionReport(e, "An error occurred when invoking the process: " + Identifier + ". Check the process parameters. If necessary, contact the administrator.");
            }
            catch (Exception e)
            {
                if (operationDomain != null)
                {
                    AppDomain.Unload(operationDomain);
                }
                throw new ExceptionReport("An error occurred when invoking the process: " + Identifier + ". Contact the administrator.\n" + e.ToString());
            }
            return(result);
        }
示例#2
0
        public ProcessReturnValue CallProcess(ProcessInputParams args, ResponseFormType responseForm, bool asynchronous)
        {
            // A secondary operation domain has to be used so that the assemblies can be loaded/unloaded, as the function Assembly
            AppDomain operationDomain = null;
            ProcessReturnValue result = null;
            try
            {
                ArrayList methodArgs = new ArrayList();
                methodArgs.Add(args);
                ProcessReturnValue processReturnValue = new ProcessReturnValue();
                processReturnValue.responseForm = responseForm;
                methodArgs.Add(processReturnValue);

                operationDomain = Utils.CreateDomain();
                if (!asynchronous)
                {
                    // Load the assembly corresponding to the requested process
                    Utils.AssemblyLoader assemblyLoader = Utils.AssemblyLoader.Create(operationDomain);
                    assemblyLoader.Load(Utils.MapPath(Global.ProcessesBinPath + Identifier + ".dll"));
                    result = (ProcessReturnValue)assemblyLoader.ExecuteMethod(processClass, processMethod, methodArgs.ToArray(), null);
                    AppDomain.Unload(operationDomain);
                }
                else
                {
                    asyncOperationDomain = operationDomain;
                    asyncLoader = Utils.AssemblyLoader.Create(operationDomain);
                    asyncLoader.Load(Utils.MapPath(Global.ProcessesBinPath + Identifier + ".dll"));
                    result = (ProcessReturnValue)asyncLoader.ExecuteAsyncMethod(processClass, processMethod, methodArgs.ToArray(), new object[] { AppDomain.CurrentDomain, Global.StoredResultsPath, Utils.ResolveUrl(Global.StoredResultsPath) });
                }
            }
            catch (ExceptionReport e)
            {
                if (operationDomain != null) AppDomain.Unload(operationDomain);
                throw new ExceptionReport(e, "An error occurred when invoking the process: " + Identifier + ". Check the process parameters. If necessary, contact the administrator.");
            }
            catch (Exception e)
            {
                if (operationDomain != null) AppDomain.Unload(operationDomain);
                throw new ExceptionReport("An error occurred when invoking the process: " + Identifier + ". Contact the administrator.\n" + e.ToString());
            }
            return result;
        }