Ejemplo n.º 1
0
        public static IExtendAction GetExtendAction(ISession session, string name)
        {
            ExtendFuncBizModel entity = ExtendConfigure.GetConfigureEntity(name);

            //找不到对应的配置则返回空
            if (entity == null)
            {
                return(null);
            }

            EnumAddinType type = entity.MstModel.FuncType;

            IExtendAction executor = null;

            if (type == EnumAddinType.Url)
            {
                executor = new ExtendUrlAction();
            }
            else if (type == EnumAddinType.Sql)
            {
                executor = new ExtendSqlAction();
            }
            else if (type == EnumAddinType.Assembly)
            {
                executor = new ExtendAssemblyAction();
            }
            //注入参数
            if (executor != null)
            {
                executor.Session         = session;
                executor.ConfigureEntity = entity;
            }

            return(executor);
        }
Ejemplo n.º 2
0
        public string Executor(string extendName)
        {
            LogHelper <ExtendExecutor> .Info("当前扩展程序的方法名是:" + extendName);

            ISession session = null;
            string   rtn     = string.Empty;

            try
            {
                session = hibernateTemplate.SessionFactory.OpenSession();
                if (session == null)
                {
                    throw new AddinException("NHibernate无法获取Session");
                }

                //初始化配置
                ExtendConfigure.InitConfigure(session);

                //打出环境参数
                LogHelper <ExtendExecutor> .PrintEvn();

                IExtendAction action = ExtendActionFactory.GetExtendAction(session, extendName);



                if (action != null)
                {
                    rtn = action.Execute();
                }

                session.Close();
                LogHelper <ExtendExecutor> .Info("当前扩展程序的执行结果集是:" + (rtn == null?"null":rtn));

                return(rtn);
            }
            catch (Exception e)
            {
                LogHelper <ExtendExecutor> .Error("执行扩展方法出错:" + e.Message);

                throw;
            }
            finally
            {
                try
                {
                    if (session.IsOpen)
                    {
                        session.Close();
                    }
                }
                catch (Exception)
                {
                    throw;
                }
            }
        }
Ejemplo n.º 3
0
        /// <summary>
        /// 重新刷新缓存配置
        /// </summary>
        public void RefreshConfigure()
        {
            ISession session = hibernateTemplate.SessionFactory.GetCurrentSession();

            if (session == null)
            {
                throw new AddinException("无法通过GetCurrentSession获得session");
            }
            ExtendConfigure.Refresh(session);
        }