Пример #1
0
 /// <summary>
 /// 只在系统启动时调用一次
 /// </summary>
 public static void InitSqlMapper()
 {
     var builder = new DomSqlMapBuilder();
     var configfileName = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, CONFIGPATH, FILENAME);
     _sqlMapper = builder.Configure(configfileName);
     Console.WriteLine("动态查询模板配置完毕");
 }
Пример #2
0
        protected static void InitMapper()
        {
            ConfigureHandler handler = new ConfigureHandler(Configure);
            DomSqlMapBuilder builder = new DomSqlMapBuilder();

            _mapper = builder.ConfigureAndWatch(handler);
        }
Пример #3
0
 public ProductService()
 {
     DomSqlMapBuilder getdombuilder = new DomSqlMapBuilder();
     if(getdombuilder!=null)
         ProductService._getsqlmapper = getdombuilder.Configure() as SqlMapper;
     _getsqlManager = Mapper.Instance();
 }
Пример #4
0
 public int generatorId(string sourceName, ISqlMapper sqlMap)
 {
     int curValue = 0;
     try
     {
         SysTableId sysTableId = new SysTableId();
         sysTableId.SourceName = sourceName;
         curValue = sqlMap.QueryForObject<int>("getSysTableIdCurValue", sysTableId);
         if (curValue > 0)
         {
             // 递增标识
             sysTableId.CurValue = curValue + SysTableId.STEP;
             sqlMap.Update("updateSysTableId", sysTableId);
         }
         else
         {
             curValue = SysTableId.START_ID;
             // 新建标识记录
             sysTableId.CurValue = SysTableId.START_ID + SysTableId.STEP;
             sqlMap.Insert("insertSysTableId", sysTableId);
         }
     }
     catch (Exception e)
     {
         throw new IBatisNetException("Error executing query getSysTableIdCurValue for object.  Cause: " + e.Message, e);
     }
     return curValue;
 }
Пример #5
0
        /// <summary>
        /// 构造方法。
        /// </summary>
        /// <param name="sqlMapper">SqlMapper对象</param>
        public SqlMapperManager(ISqlMapper sqlMapper)
        {
            this._isReadWriteSpliting = false;
            this._reader = this._writer = sqlMapper;

            this._reader.SessionStore = new HybridWebThreadSessionStore(this._reader.Id);
        }
Пример #6
0
        /// <summary>
        /// 构造方法。
        /// </summary>
        /// <param name="reader">从数据库读取数据的SqlMapper</param>
        /// <param name="writer">向数据库写入数据的SqlMapper</param>
        public SqlMapperManager(ISqlMapper reader, ISqlMapper writer)
        {
            this._reader = reader;
            this._writer = writer;

            this._isReadWriteSpliting = true;
            this._reader.SessionStore = new HybridWebThreadSessionStore(this._reader.Id);
            this._writer.SessionStore = new HybridWebThreadSessionStore(this._writer.Id);
        }
Пример #7
0
 protected static void InitMapper()
 {
     ConfigureHandler handler = new ConfigureHandler(Configure);
     DomSqlMapBuilder builder = new DomSqlMapBuilder();
     /*
     XmlDocument sqlMapConfig = Resources.GetEmbeddedResourceAsXmlDocument("MamShare.Persistence.Config.SqlMap.config, MamShare.Persistence");
     _mapper = builder.Configure(sqlMapConfig);
     */
     _mapper = builder.ConfigureAndWatch("SqlMap.config",handler);
 }
Пример #8
0
 /// <summary>
 /// Initializes a new instance of the <see cref="T:LazyList"/> class.
 /// </summary>
 /// <param name="mappedSatement">The mapped satement.</param>
 /// <param name="param">The param.</param>
 /// <param name="target">The target.</param>
 /// <param name="setAccessor">The set accessor.</param>
 public LazyList(IMappedStatement mappedSatement, object param,
     object target, ISetAccessor setAccessor)
 {
     _list = new ArrayList();
     _param = param;
     _statementId = mappedSatement.Id;
     _sqlMap = mappedSatement.SqlMap;
     _target = target;
     _setAccessor = setAccessor;
 }
Пример #9
0
        /// <summary>
        /// ���SqlMap����
        /// </summary>
        public static void Reset()
        {
            try {
                sqlMap.CloseConnection();

            }
            catch { }
            finally {
                sqlMap = null;
            }
        }
 public DataDictionaryGroupAndItemDao(ISqlMapper mapper = null)
 {
     if (mapper != null)
     {
         this.mapper = mapper;
     }
     else
     {
         this.mapper = IBatisNet.DataMapper.Mapper.Instance();
     }
 }
Пример #11
0
 public DsModel()
 {
     try
     {
         mapper = Mapper.Instance();
     }
     catch (Exception ie)
     {
         Console.WriteLine(ie.ToString());
         throw ie;
     }
 }
Пример #12
0
 public UserManageDAO()
 {
     sqlMapper = Mapper.Instance();
     if (sqlMapper == null)
     {
         isSqlValid = false;
     }
     else
     {
         isSqlValid = true;
     }
 }
Пример #13
0
        /// <summary>
        /// Init the 'default' SqlMapper defined by the SqlMap.Config file.
        /// </summary>
        protected static void InitMapper()
        {
            ConfigureHandler handler = new ConfigureHandler(Configure);
            DomSqlMapBuilder builder = new DomSqlMapBuilder();
            string resourceDirectory = ConfigurationManager.AppSettings.Get("sqlmapconfig");
            string resource = InitMapXML(resourceDirectory);

            InitMapXML(resourceDirectory);

            ISqlMapper sqlmapper = builder.ConfigureAndWatch(resource, handler);

            _Mapper = sqlmapper;
        }
Пример #14
0
        protected void Application_Start()
        {
            AreaRegistration.RegisterAllAreas();

            if (mapper == null)
            {
                mapper = MyMapper.Instance();
            }

            SysStatisticDAO statisticDAO = new SysStatisticDAO(this.mapper);
            Application[Constants.Statistic.VisitedUser] = statisticDAO.GetVisitedUser();
            RegisterRoutes(RouteTable.Routes);
            log4net.Config.XmlConfigurator.Configure();
        }
Пример #15
0
        public static IList<DataServiceLogConfig> GetLogConfigList(ISqlMapper sqlmap)
        {
            if (ConfigList == null)
            {
                lock (obj)
                {
                    if (ConfigList == null)
                    {
                        ConfigList = GetConfigList(sqlmap);
                    }
                }
            }

            return ConfigList;
        }
Пример #16
0
 static MyIbatisNet()
 {
     if (SqlMap == null)
     {
         lock (syncObj)
         {
             if (SqlMap == null)
             {
                 Assembly assembly = Assembly.Load("Test.Respository");
                 Stream stream = assembly.GetManifestResourceStream("Test.Respository.sqlmap.config");
                 DomSqlMapBuilder builder = new DomSqlMapBuilder();
                 SqlMap = builder.Configure(stream);
             }
         }
     }
 }
Пример #17
0
        public static DataServiceLogConfig GetConfigByClassName(string ClassName, ISqlMapper sqlmap)
        {
            DataServiceLogConfig Config = new DataServiceLogConfig();

            IList<DataServiceLogConfig> List = GetLogConfigList(sqlmap);
            if (List != null && List.Count > 0)
            {
                var ConfigList = from config in List where config.ClassName == ClassName select config;
                foreach (var item in ConfigList)
                {
                    Config = (DataServiceLogConfig)item;
                    break;
                }
            }

            return Config;
        }
Пример #18
0
		/// <summary>
		/// Initialize an sqlMap
		/// </summary>
		protected static void InitSqlMap()
		{
			//DateTime start = DateTime.Now;

			ConfigureHandler handler = new ConfigureHandler( Configure );
			DomSqlMapBuilder builder = new DomSqlMapBuilder();
#if dotnet2
            sqlMap = builder.ConfigureAndWatch("sqlmap" + "_" + ConfigurationManager.AppSettings["database"] + "_"
                + ConfigurationManager.AppSettings["providerType"] + ".config", handler);
#else
			sqlMap = builder.ConfigureAndWatch( "sqlmap"+ "_" +  ConfigurationSettings.AppSettings["database"] + "_"
				+ ConfigurationSettings.AppSettings["providerType"] +".config", handler );
#endif

            //string loadTime = DateTime.Now.Subtract(start).ToString();
            //Console.WriteLine("Loading configuration time :"+loadTime);
		}
Пример #19
0
        protected override void OnActionExecuting(ActionExecutingContext filterContext)
        {
            mapper = MyMapper.Instance();
            mapper.BeginTransaction(System.Data.IsolationLevel.Serializable);

            if (Session["UserSession"] == null || !Session.IsNewSession) {
                HttpCookie cookie = Request.Cookies[FormsAuthentication.FormsCookieName];
                if (cookie != null)
                {
                    FormsAuthenticationTicket ticket = FormsAuthentication.Decrypt(cookie.Value);
                    if (ticket.IsPersistent)
                    {
                        SysUserDAO sysUserDAO = new SysUserDAO(this.mapper);
                        SysUserModels user = sysUserDAO.GetUserByUserCode(ticket.Name);
                        if (user != null)
                        {
                            FormsAuthentication.SetAuthCookie(user.userCode, true);
                            Session["UserSession"] = user;
                        }
                    }
                }
            }
            base.OnActionExecuting(filterContext);
        }
Пример #20
0
        public TransporttypeDao()
        {
            DomSqlMapBuilder sqlMapBuilder = new DomSqlMapBuilder();

            this.sqlMapper = sqlMapBuilder.Configure("etc/mybatis.sqlmap.cfg.xml");
        }
Пример #21
0
 public TraTransactionDAO(ISqlMapper _mapper)
 {
     this.mapper = _mapper;
 }
Пример #22
0
        public string Add(Model.User user, UserInfo ui, List <string> roleidlist)
        {
            #region risk user
            ISqlMapper mapper = Common.GetMapperFromSession();
            if (user == null)
            {
                throw new Exception("user不能为null!");
            }
            UserDao dao   = new UserDao(mapper);
            var     exist = dao.Query(new UserQueryForm {
                Name = user.Name
            });
            if (exist.Count > 0)
            {
                throw new Exception("已存在用户名:" + user.Name);
            }
            if (string.IsNullOrEmpty(ui.WX) && string.IsNullOrEmpty(ui.Mobile))
            {
                throw new Exception("微信号或者手机不能为空");
            }
            string id = dao.Add(user);
            if (ui == null)
            {
                ui = new UserInfo();
            }
            UserInfoDao infodao = new UserInfoDao(mapper);
            ui.ID = id;
            infodao.Add(ui);
            if (roleidlist == null)
            {
                return(id);
            }
            User_RoleDao urdao = new User_RoleDao(mapper);
            foreach (var role in roleidlist)
            {
                User_Role ur = new User_Role {
                    RoleID = role, UserID = user.ID
                };
                urdao.Add(ur);
            }
            #endregion

            #region weixin user
            RoleDao roledao = new RoleDao(mapper);
            var     roles   = roledao.Query(new RoleQueryForm {
                IDs = roleidlist
            });
            var weixinids = (from r in roles
                             where !string.IsNullOrEmpty(r.WeiXinID)
                             select Convert.ToInt32(r.WeiXinID)).ToArray();
            try
            {
                SOAFramework.Library.WeiXin.WeiXinApi.User.Create(new SOAFramework.Library.WeiXin.User
                {
                    department = weixinids,
                    enable     = 1,
                    mobile     = ui.Mobile,
                    name       = ui.CnName,
                    weixinid   = ui.WX,
                    userid     = user.Name,
                });
            }
            catch (SOAFramework.Library.WeiXin.WeiXinException ex)
            {
                switch (ex.Code)
                {
                case "60004":
                case "60003":
                    foreach (var role in roles)
                    {
                        //部门不存在就新建部门
                        Role parentrole = null;
                        if (!string.IsNullOrEmpty(role.ParentID))
                        {
                            roledao.Query(new RoleQueryForm {
                                ID = role.ParentID
                            }).FirstOrDefault();
                        }
                        var department = new SOAFramework.Library.WeiXin.Department
                        {
                            name = role.Name,
                        };
                        if (parentrole != null)
                        {
                            department.parentid = parentrole.WeiXinID;
                        }
                        var response = SOAFramework.Library.WeiXin.WeiXinApi.Department.Create(department);
                        roledao.Update(new RoleUpdateForm
                        {
                            Entity = new Role {
                                WeiXinID = response.id
                            },
                            RoleQueryForm = new RoleQueryForm {
                                ID = role.ID
                            },
                        });
                    }
                    SOAFramework.Library.WeiXin.WeiXinApi.User.Create(new SOAFramework.Library.WeiXin.User
                    {
                        department = weixinids,
                        enable     = 1,
                        mobile     = ui.Mobile,
                        name       = ui.CnName,
                        weixinid   = ui.WX,
                        userid     = user.Name,
                    });
                    break;

                case "60102":    //用户已存在
                    SOAFramework.Library.WeiXin.WeiXinApi.User.Update(new SOAFramework.Library.WeiXin.User
                    {
                        department = weixinids,
                        mobile     = ui.Mobile,
                        name       = ui.CnName,
                        weixinid   = ui.WX,
                        userid     = user.Name,
                    });
                    break;

                default:
                    throw ex;
                }
            }
            #endregion
            return(id);
        }
Пример #23
0
        public TrunknumberprefixDao()
        {
            DomSqlMapBuilder sqlMapBuilder = new DomSqlMapBuilder();

            this.sqlMapper = sqlMapBuilder.Configure("etc/mybatis.sqlmap.cfg.xml");
        }
Пример #24
0
 public User_PostDao(ISqlMapper mapper = null)
     : base(mapper)
 {
 }
Пример #25
0
 public static int DyUpdate <TEntity>(this ISqlMapper sqlMapper, object entity, bool?enablePropertyChangedTrack)
 {
     return(sqlMapper.SessionStore.Open().DyUpdate <TEntity>(entity, enablePropertyChangedTrack));
 }
Пример #26
0
        /// <summary>构造函数</summary>
        public VerificationCodeProvider()
        {
            this.ibatisMapping = VerificationCodeConfigurationView.Instance.Configuration.Keys["IBatisMapping"].Value;

            this.ibatisMapper = ISqlMapHelper.CreateSqlMapper(this.ibatisMapping, true);
        }
Пример #27
0
        public ConnectCallProvider()
        {
            this.ibatisMapping = ConnectConfigurationView.Instance.Configuration.Keys["IBatisMapping"].Value;

            this.ibatisMapper = ISqlMapHelper.CreateSqlMapper(this.ibatisMapping, true);
        }
Пример #28
0
 public NestTest(SmartSqlFixture smartSqlFixture)
 {
     SqlMapper = smartSqlFixture.SqlMapper;
 }
Пример #29
0
 /// <summary>
 /// 构造函数
 /// </summary>
 /// <param name="sqlMapper"></param>
 protected RelatedSelectDaoBase(ISqlMapper sqlMapper) : base(sqlMapper)
 {
 }
Пример #30
0
 public DbSessionTest(SmartSqlFixture smartSqlFixture)
 {
     SqlMapper = smartSqlFixture.SqlMapper;
 }
Пример #31
0
 protected static void Configure(object obj)
 {
     _mapper = null;
 }
Пример #32
0
 public static int DeleteAll <TEntity>(this ISqlMapper sqlMapper)
 {
     return(sqlMapper.SessionStore.Open().DeleteAll <TEntity>());
 }
Пример #33
0
 public AlertingDAO()
 {
     // XmlConfigurator.Configure();
     mapper = Mapper.Instance();
     mapper.DataSource.ConnectionString = ConfigurationManager.AppSettings["DbConnectionString"];
 }
Пример #34
0
 public static int Update <TEntity>(this ISqlMapper sqlMapper, TEntity entity)
 {
     return(sqlMapper.SessionStore.Open().Update <TEntity>(entity));
 }
Пример #35
0
 public FullTaskDao(ISqlMapper mapper)
     : base(mapper)
 {
 }
Пример #36
0
 public MstInfoTypeDAO(ISqlMapper _mapper)
 {
     this.mapper = _mapper;
 }
Пример #37
0
 public ActionDao(ISqlMapper mapper)
     : base(mapper)
 {
 }
Пример #38
0
 /// <summary>
 /// 
 /// </summary>
 /// <param name="obj"></param>
 public static void Configure(object obj)
 {
     _mapper = null;
 }
 public SmartSqlController(ISqlMapper sqlMapper)
 {
     _sqlMapper = sqlMapper;
 }
Пример #40
0
 public static TPrimaryKey Insert <TEntity, TPrimaryKey>(this ISqlMapper sqlMapper, TEntity entity)
 {
     return(sqlMapper.SessionStore.Open().Insert <TEntity, TPrimaryKey>(entity));
 }
Пример #41
0
 public UserInfoDao(ISqlMapper mapper)
     : base(mapper)
 {
 }
Пример #42
0
 /// <summary>
 /// Constructor
 /// </summary>
 /// <param name="sqlMap">An SqlMap</param>
 /// <param name="statement">An SQL statement</param>
 internal UpdateMappedStatement(ISqlMapper sqlMap, IStatement statement)
     : base(sqlMap, statement)
 {
 }
        /// <summary>
        /// Constructor for a lazy list loader
        /// </summary>
        /// <param name="mappedSatement">The mapped statement used to build the list</param>
        /// <param name="param">The parameter object used to build the list</param>
        /// <param name="setAccessor">The proxified member accessor.</param>
        /// <param name="target">The target object which contains the property proxydied.</param>
        internal LazyLoadInterceptor(IMappedStatement mappedSatement, object param,
			object target, ISetAccessor setAccessor)
        {
            _param = param;
            _statementName = mappedSatement.Id;
            _sqlMap = mappedSatement.SqlMap;
            _target = target;
            _setAccessor = setAccessor;
        }
Пример #44
0
 protected static void Configure(object obj)
 {
     m_sqlMap = null;
 }
Пример #45
0
        public bool Update(Model.User user, UserInfo ui, List <string> roleidlist)
        {
            #region risk update
            ISqlMapper  mapper = Common.GetMapperFromSession();
            UserDao     udao   = new UserDao(mapper);
            UserInfoDao uidao  = new UserInfoDao(mapper);
            if (user != null)
            {
                Model.User entity = new User
                {
                    ID      = user.ID,
                    Enabled = user.Enabled,
                };
                udao.Update(new UserUpdateForm {
                    Entity = entity, UserQueryForm = new UserQueryForm {
                        ID = user.ID
                    }
                });
            }
            if (ui != null)
            {
                uidao.Update(new UserInfoUpdateForm {
                    Entity = ui, UserInfoQueryForm = new UserInfoQueryForm {
                        ID = ui.ID
                    }
                });
            }
            if (roleidlist != null)
            {
                User_RoleDao urdao = new User_RoleDao(mapper);
                urdao.Delete(new User_RoleQueryForm {
                    UserID = user.ID
                });
                foreach (var role in roleidlist)
                {
                    User_Role ur = new User_Role {
                        RoleID = role, UserID = user.ID
                    };
                    urdao.Add(ur);
                }
            }
            #endregion

            #region weixin api
            RoleDao roledao = new RoleDao(mapper);
            var     roles   = roledao.Query(new RoleQueryForm {
                IDs = roleidlist
            });
            var weixinids = (from r in roles
                             where !string.IsNullOrEmpty(r.WeiXinID)
                             select Convert.ToInt32(r.WeiXinID)).ToArray();
            var user_temp = udao.Query(new UserQueryForm {
                ID = user.ID
            }).FirstOrDefault();
            var ui_temp = uidao.Query(new UserInfoQueryForm {
                ID = user.ID
            }).FirstOrDefault();
            try
            {
                SOAFramework.Library.WeiXin.WeiXinApi.User.Update(new SOAFramework.Library.WeiXin.User
                {
                    department = weixinids,
                    mobile     = ui_temp.Mobile,
                    name       = ui_temp.CnName,
                    weixinid   = ui_temp.WX,
                    userid     = user_temp.Name,
                    enable     = 1,
                });
            }
            catch (SOAFramework.Library.WeiXin.WeiXinException ex)
            {
                switch (ex.Code)
                {
                case "60111":    //如果微信上不存在用户,就新建
                    SOAFramework.Library.WeiXin.WeiXinApi.User.Create(new SOAFramework.Library.WeiXin.User
                    {
                        enable     = 1,
                        userid     = user_temp.Name,
                        name       = ui_temp.CnName,
                        mobile     = ui_temp.Mobile,
                        weixinid   = ui_temp.WX,
                        department = weixinids,
                    });
                    break;

                default:
                    throw ex;
                }
            }
            #endregion
            return(true);
        }
Пример #46
0
 public static TEntity GetById <TEntity, TPrimaryKey>(this ISqlMapper sqlMapper, TPrimaryKey id,
                                                      bool enablePropertyChangedTrack)
 {
     return(sqlMapper.SessionStore.Open().GetById <TEntity, TPrimaryKey>(id, enablePropertyChangedTrack));
 }
Пример #47
0
 public JobDao(ISqlMapper mapper) : base(mapper)
 {
 }
Пример #48
0
 public static TEntity GetById <TEntity, TPrimaryKey>(this ISqlMapper sqlMapper, TPrimaryKey id)
 {
     return(GetById <TEntity, TPrimaryKey>(sqlMapper, id, false));
 }
Пример #49
0
        void Session_Start(object sender, EventArgs e)
        {
            // Tăng số đang truy cập lên 1 nếu có khách truy cập
            if (Application[Constants.Statistic.VisitingUser] == null)
            {
                Application[Constants.Statistic.VisitingUser] = 1;
            }
            else
            {
                Application[Constants.Statistic.VisitingUser] = (int)Application[Constants.Statistic.VisitingUser] + 1;
            }

            // Tăng số đã truy cập lên 1 nếu có khách truy cập
            if (Application[Constants.Statistic.VisitedUser] == null)
            {
                Application[Constants.Statistic.VisitedUser] = 1;
            }
            else
            {
                Application[Constants.Statistic.VisitedUser] = Int32.Parse(Application[Constants.Statistic.VisitedUser].ToString()) +1;
            }
            if (mapper == null)
            {
                mapper = MyMapper.Instance();
            }
            mapper.BeginTransaction();
            try
            {
                SysStatisticDAO statisticDAO = new SysStatisticDAO(this.mapper);
                statisticDAO.UpdateVisitedUser(Application[Constants.Statistic.VisitedUser].ToString());
                mapper.CommitTransaction();
            }
            catch (Exception ex)
            {
                mapper.RollBackTransaction();
            }
            //File.WriteAllText(Server.MapPath("Count_Visited.txt"), Application["DaTruyCap"].ToString());
        }
Пример #50
0
 public static int DeleteMany <TEntity, TPrimaryKey>(this ISqlMapper sqlMapper, IEnumerable <TPrimaryKey> ids)
 {
     return(sqlMapper.SessionStore.Open().DeleteMany <TEntity, TPrimaryKey>(ids));
 }
Пример #51
0
 protected static void Configure(object obj)
 {
     _mapper = null;
 }
Пример #52
0
 public static int DeleteById <TEntity, TPrimaryKey>(this ISqlMapper sqlMapper, TPrimaryKey id)
 {
     return(sqlMapper.SessionStore.Open().DeleteById <TEntity, TPrimaryKey>(id));
 }
Пример #53
0
 public OrderByTest(SmartSqlFixture smartSqlFixture)
 {
     SqlMapper = smartSqlFixture.SqlMapper;
 }
Пример #54
0
 public static int DyUpdate <TEntity>(this ISqlMapper sqlMapper, object entity)
 {
     return(sqlMapper.SessionStore.Open().DyUpdate <TEntity>(entity));
 }
Пример #55
0
 private static IList<DataServiceLogConfig> GetConfigList(ISqlMapper sqlmap)
 {
     return sqlmap.QueryForList<DataServiceLogConfig>("queryDataServiceLogConfigListT", new Hashtable());
 }
Пример #56
0
 public ProjectDao(ISqlMapper mapper)
     : base(mapper)
 {
 }
Пример #57
0
		public SqlMapKeeper(ISqlMapper sqlMap)
		{
			_sqlMap = sqlMap;
		}
Пример #58
0
 public ContextDao(ISqlMapper mapper)
     : base(mapper)
 {
 }
Пример #59
0
 public MstIndexDAO(ISqlMapper _mapper)
 {
     this.mapper = _mapper;
 }
 public CustomizeTypeHandlerTest(SmartSqlFixture smartSqlFixture)
 {
     SqlMapper = smartSqlFixture.SqlMapper;
 }