Ejemplo n.º 1
0
        public static ProcessDescription GetProcessDescription(string processId)
        {
            AppDomain mainDomain = AppDomain.CurrentDomain;
            // A secondary operation domain has to be used so that the assemblies can be loaded/unloaded, as the function Assembly
            AppDomain          operationDomain = null;
            ProcessDescription result          = null;

            try
            {
                operationDomain = Utils.CreateDomain();
                Utils.AssemblyLoader assemblyLoader = Utils.AssemblyLoader.Create(operationDomain);
                assemblyLoader.Load(Utils.MapPath(Global.ProcessesBinPath + processId + ".dll"));
                result = (ProcessDescription)assemblyLoader.ExecuteMethod("WPSProcess." + processId, "GetDescription", null, null);
                AppDomain.Unload(operationDomain);
            }
            catch (Exception /*e*/)
            {
                if (operationDomain != null)
                {
                    AppDomain.Unload(operationDomain);
                }
                throw new ExceptionReport("Unable to retrieve the description of the process '" + processId + "'.\nEnsure that the Identifier parameter really is the name of a service proposed on this server. The name is case dependent. The name of the available processes can be get with the GetCapabilities operation.", ExceptionCode.InvalidParameterValue, "Identifier");
            }

            return(result);
        }
Ejemplo n.º 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);
        }
Ejemplo n.º 3
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;
        }