예제 #1
0
        protected virtual EnterpriseFunction addFunction(Type clazz, string applicationType, string functionName)
        {
            EnterpriseFunction function = Activator.CreateInstance(clazz) as EnterpriseFunction;

            if (functionName == null)
            {
                functionName = function.getName();
            }

            if (IsSubclassOfRawGeneric(clazz, "AbstractEnterpriseAsync"))
            {
                function.setHasAsynMethod(IsAsyncMethod(clazz, "executeAsync"));
            }
            else
            {
                function.setHasAsynMethod(IsAsyncMethod(clazz, "executeGenericAsync"));
            }

            EnterpriseFunction functionloaded = LoadFunction(function, applicationType, functionName, null);

            return(functionloaded);
        }
예제 #2
0
        /// <summary>
        /// Chiama una funzione.
        /// </summary>
        /// <param name="function">		la funzione da chiamare. </param>
        /// <param name="worker">		il worker che sta eseguendo la sessione. </param>
        /// <param name="context">		il contesto della chiamata.
        ///
        /// @return				il risultato della chiamata.
        /// </param>
        /// <exception cref="FunctionNotFoundException">	se la classe non � definita nel sistema. </exception>
        /// <exception cref="Exception">					se si verifica un errore. </exception>
        public Task <T> callFunctionAsync <T>(EnterpriseFunction function, IInfoContext info, FunctionContext context)
        {
#if DEBUG
            Stopwatch timeOperations = Stopwatch.StartNew();
#endif
            try
            {
                if (function.isAsyncMethod() || function.isYieldMethod())
                {
                    if (main.infoctx.DebugMode)
                    {
                        getLogger().Debug("Calling Async function " + function.getName());
                    }
                    return(function.executeGenericAsync <T>(info, context));
                }
                else
                {
                    if (main.infoctx.DebugMode)
                    {
                        getLogger().Debug("Calling Awaitable function " + function.getName());
                    }
                    var t = Task.Run <T>(async() =>
                    {
                        return(await function.executeGenericAsync <T>(info, context));
                    });
                    return(t);
                }
            }
            finally
            {
#if DEBUG
                timeOperations.Stop();
                getLogger().Debug("Called functionAsync " + function.getName() + " in " + timeOperations.ElapsedMilliseconds + "ms");
#endif
            }
        }
예제 #3
0
        public virtual void removeFunction(IInfoContext info, string functionName)
        {
            EnterpriseFunction function = getFunction(info.TypeApplication, functionName);

            removeFunction(function);
        }