Ejemplo n.º 1
0
        public PowerActionFilterAttribute()
        {
            IHibernateOper hibernateOper = HibernateFactory.GetInstance();

            empModFuncOper = new TbBaseOper <EmpModFunc>(hibernateOper, typeof(EmpModFunc));
            empModOper     = new TbBaseOper <EmpMod>(hibernateOper, typeof(EmpMod));
        }
Ejemplo n.º 2
0
 public BaseController()
 {
     try
     {
         //获取数据库操作对象
         HibernateOper = HibernateFactory.GetInstance();
     }
     catch (Exception e)
     {
         throw e;
     }
 }
Ejemplo n.º 3
0
 public BaseController()
 {
     try
     {
         //获取数据库操作对象
         HibernateOper = HibernateFactory.GetInstance();
     }
     catch (Exception e)
     {
         throw e;
     }
 }
Ejemplo n.º 4
0
        /// <summary>
        /// 由OpenId得到客户
        /// </summary>
        /// <param name="hibernateOper"></param>
        /// <param name="openId"></param>
        /// <returns></returns>
        public static Customer GetCust(IHibernateOper hibernateOper, string openId)
        {
            Customer retVal = null;

            Exec(hibernateOper,
                 delegate(ISession s){
                //查找客户openId
                retVal = GetCust(s, openId);
            }
                 );

            return(retVal);
        }
Ejemplo n.º 5
0
        /// <summary>
        /// 由OpenId得到客户
        /// </summary>
        /// <param name="hibernateOper"></param>
        /// <param name="openId"></param>
        /// <returns></returns>
        public static Customer GetCust(IHibernateOper hibernateOper, string openId)
        {
            Customer retVal = null;

            Exec(hibernateOper,
                delegate(ISession s){
                    //查找客户openId
                retVal = GetCust(s, openId);
                }
                );

            return retVal;
        }
Ejemplo n.º 6
0
        /// <summary>
        /// 获取最短距离的分店
        /// </summary>
        /// <param name="hibernateOper"></param>
        /// <param name="loc">地址</param>
        /// <param name="maxDist">最长距离</param>
        /// <returns></returns>
        public static Department GetMinDistDept(IHibernateOper hibernateOper, TbLocation loc, double maxDist)
        {
            Department retVal = null;

            Exec(hibernateOper,
                 delegate(ISession s)
            {
                //查找地址码
                retVal = GetMinDistDept(s, loc, maxDist);
            }
                 );

            return(retVal);
        }
Ejemplo n.º 7
0
        /// <summary>
        /// 由地址码获取地址全称
        /// </summary>
        /// <param name="hibernateOper"></param>
        /// <param name="code"></param>
        /// <returns></returns>
        public static string GetAddrForCode(IHibernateOper hibernateOper, string code)
        {
            string retVal = null;

            Exec(hibernateOper,
                 delegate(ISession s)
            {
                //查找地址码
                retVal = GetAddrForCode(s, code);
            }
                 );

            return(retVal);
        }
Ejemplo n.º 8
0
        public static Employee GetEmployee(IHibernateOper hibernateOper, string code)
        {
            Employee retVal = null;

            Exec(hibernateOper,
                 delegate(ISession s)
            {
                //查找员工工号
                retVal = GetEmployee(s, code);
            }
                 );

            return(retVal);
        }
Ejemplo n.º 9
0
        protected void Application_Start()
        {
            AreaRegistration.RegisterAllAreas();

            WebApiConfig.Register(GlobalConfiguration.Configuration);
            FilterConfig.RegisterGlobalFilters(GlobalFilters.Filters);
            RouteConfig.RegisterRoutes(RouteTable.Routes);
            BundleConfig.RegisterBundles(BundleTable.Bundles);

            try
            {
                //获取数据库操作对象
                HibernateOper = HibernateFactory.GetInstance();
                updateVersion();//更新数据库
            }
            catch (Exception e)
            {
                throw e;
            }
        }
Ejemplo n.º 10
0
        protected void Application_Start()
        {
            AreaRegistration.RegisterAllAreas();

            WebApiConfig.Register(GlobalConfiguration.Configuration);
            FilterConfig.RegisterGlobalFilters(GlobalFilters.Filters);
            RouteConfig.RegisterRoutes(RouteTable.Routes);
            BundleConfig.RegisterBundles(BundleTable.Bundles);

            try
            {
                //获取数据库操作对象
                HibernateOper = HibernateFactory.GetInstance();
                updateVersion();//更新数据库
            }
            catch (Exception e)
            {
                throw e;
            }
        }
Ejemplo n.º 11
0
 public static IHibernateOper GetInstance()
 {
     try
     {
         if (hibernateOper == null)
         {
             lock (_lock)
             {
                 if (hibernateOper == null)
                 {
                     hibernateOper = new HibernateOper();
                 }
             }
         }
     }
     catch (Exception e)
     {
         throw e;
     }
     
     return hibernateOper;
 }
Ejemplo n.º 12
0
        public static IHibernateOper GetInstance()
        {
            try
            {
                if (hibernateOper == null)
                {
                    lock (_lock)
                    {
                        if (hibernateOper == null)
                        {
                            hibernateOper = new HibernateOper();
                        }
                    }
                }
            }
            catch (Exception e)
            {
                throw e;
            }

            return(hibernateOper);
        }
Ejemplo n.º 13
0
        public static void Exec(IHibernateOper hibernateOper, OnSession onSession)
        {
            ISession s = null;
            ITransaction trans = null;
            try
            {
                s = hibernateOper.GetCurrentSession();
                trans = s.BeginTransaction();

                onSession(s);
                
                trans.Commit();
            }
            catch (Exception e)
            {
                if (trans != null)
                {
                    trans.Rollback();
                }
                throw e;
            }
        }
Ejemplo n.º 14
0
        public static void Exec(IHibernateOper hibernateOper, OnSession onSession)
        {
            ISession     s     = null;
            ITransaction trans = null;

            try
            {
                s     = hibernateOper.GetCurrentSession();
                trans = s.BeginTransaction();

                onSession(s);

                trans.Commit();
            }
            catch (Exception e)
            {
                if (trans != null)
                {
                    trans.Rollback();
                }
                throw e;
            }
        }
Ejemplo n.º 15
0
 public TbBaseOper(IHibernateOper hibernateOper, Type type)
 {
     this.hibernateOper = hibernateOper;
     this.type          = type;
 }
Ejemplo n.º 16
0
        public static Employee GetEmployee(IHibernateOper hibernateOper, string code)
        {
            Employee retVal = null;

            Exec(hibernateOper,
                delegate(ISession s)
                {
                    //查找员工工号
                    retVal = GetEmployee(s, code);
                }
                );

            return retVal;
        }
Ejemplo n.º 17
0
        /// <summary>
        /// 获取最短距离的分店
        /// </summary>
        /// <param name="hibernateOper"></param>
        /// <param name="loc">地址</param>
        /// <param name="maxDist">最长距离</param>
        /// <returns></returns>
        public static Department GetMinDistDept(IHibernateOper hibernateOper, TbLocation loc,double maxDist)
        {
            Department retVal = null;

            Exec(hibernateOper,
                delegate(ISession s)
                {
                    //查找地址码
                    retVal = GetMinDistDept(s, loc, maxDist);
                }
                );

            return retVal;
        }
Ejemplo n.º 18
0
 /// <summary>
 /// 获取最短距离的分店
 /// </summary>
 /// <param name="hibernateOper"></param>
 /// <param name="loc">地址</param>
 /// <returns></returns>
 public static Department GetMinDistDept(IHibernateOper hibernateOper, TbLocation loc)
 {
     return GetMinDistDept(hibernateOper,loc,double.MaxValue);
 }
Ejemplo n.º 19
0
        /// <summary>
        /// 由地址码获取地址全称
        /// </summary>
        /// <param name="hibernateOper"></param>
        /// <param name="code"></param>
        /// <returns></returns>
        public static string GetAddrForCode(IHibernateOper hibernateOper, string code)
        {
            string retVal = null;

            Exec(hibernateOper,
                delegate(ISession s)
                {
                    //查找地址码
                    retVal = GetAddrForCode(s, code);
                }
                );

            return retVal;
        }
Ejemplo n.º 20
0
        public HomeController()
        {
            IHibernateOper hibernateOper = HibernateFactory.GetInstance();

            empOper = new TbBaseOper <Employee>(hibernateOper, typeof(Employee));
        }
Ejemplo n.º 21
0
 /// <summary>
 /// 获取最短距离的分店
 /// </summary>
 /// <param name="hibernateOper"></param>
 /// <param name="loc">地址</param>
 /// <returns></returns>
 public static Department GetMinDistDept(IHibernateOper hibernateOper, TbLocation loc)
 {
     return(GetMinDistDept(hibernateOper, loc, double.MaxValue));
 }