/// <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("动态查询模板配置完毕"); }
protected static void InitMapper() { ConfigureHandler handler = new ConfigureHandler(Configure); DomSqlMapBuilder builder = new DomSqlMapBuilder(); _mapper = builder.ConfigureAndWatch(handler); }
public ProductService() { DomSqlMapBuilder getdombuilder = new DomSqlMapBuilder(); if(getdombuilder!=null) ProductService._getsqlmapper = getdombuilder.Configure() as SqlMapper; _getsqlManager = Mapper.Instance(); }
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; }
/// <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); }
/// <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); }
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); }
/// <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; }
/// <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(); } }
public DsModel() { try { mapper = Mapper.Instance(); } catch (Exception ie) { Console.WriteLine(ie.ToString()); throw ie; } }
public UserManageDAO() { sqlMapper = Mapper.Instance(); if (sqlMapper == null) { isSqlValid = false; } else { isSqlValid = true; } }
/// <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; }
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(); }
public static IList<DataServiceLogConfig> GetLogConfigList(ISqlMapper sqlmap) { if (ConfigList == null) { lock (obj) { if (ConfigList == null) { ConfigList = GetConfigList(sqlmap); } } } return ConfigList; }
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); } } } }
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; }
/// <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); }
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); }
public TransporttypeDao() { DomSqlMapBuilder sqlMapBuilder = new DomSqlMapBuilder(); this.sqlMapper = sqlMapBuilder.Configure("etc/mybatis.sqlmap.cfg.xml"); }
public TraTransactionDAO(ISqlMapper _mapper) { this.mapper = _mapper; }
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); }
public TrunknumberprefixDao() { DomSqlMapBuilder sqlMapBuilder = new DomSqlMapBuilder(); this.sqlMapper = sqlMapBuilder.Configure("etc/mybatis.sqlmap.cfg.xml"); }
public User_PostDao(ISqlMapper mapper = null) : base(mapper) { }
public static int DyUpdate <TEntity>(this ISqlMapper sqlMapper, object entity, bool?enablePropertyChangedTrack) { return(sqlMapper.SessionStore.Open().DyUpdate <TEntity>(entity, enablePropertyChangedTrack)); }
/// <summary>构造函数</summary> public VerificationCodeProvider() { this.ibatisMapping = VerificationCodeConfigurationView.Instance.Configuration.Keys["IBatisMapping"].Value; this.ibatisMapper = ISqlMapHelper.CreateSqlMapper(this.ibatisMapping, true); }
public ConnectCallProvider() { this.ibatisMapping = ConnectConfigurationView.Instance.Configuration.Keys["IBatisMapping"].Value; this.ibatisMapper = ISqlMapHelper.CreateSqlMapper(this.ibatisMapping, true); }
public NestTest(SmartSqlFixture smartSqlFixture) { SqlMapper = smartSqlFixture.SqlMapper; }
/// <summary> /// 构造函数 /// </summary> /// <param name="sqlMapper"></param> protected RelatedSelectDaoBase(ISqlMapper sqlMapper) : base(sqlMapper) { }
public DbSessionTest(SmartSqlFixture smartSqlFixture) { SqlMapper = smartSqlFixture.SqlMapper; }
protected static void Configure(object obj) { _mapper = null; }
public static int DeleteAll <TEntity>(this ISqlMapper sqlMapper) { return(sqlMapper.SessionStore.Open().DeleteAll <TEntity>()); }
public AlertingDAO() { // XmlConfigurator.Configure(); mapper = Mapper.Instance(); mapper.DataSource.ConnectionString = ConfigurationManager.AppSettings["DbConnectionString"]; }
public static int Update <TEntity>(this ISqlMapper sqlMapper, TEntity entity) { return(sqlMapper.SessionStore.Open().Update <TEntity>(entity)); }
public FullTaskDao(ISqlMapper mapper) : base(mapper) { }
public MstInfoTypeDAO(ISqlMapper _mapper) { this.mapper = _mapper; }
public ActionDao(ISqlMapper mapper) : base(mapper) { }
/// <summary> /// /// </summary> /// <param name="obj"></param> public static void Configure(object obj) { _mapper = null; }
public SmartSqlController(ISqlMapper sqlMapper) { _sqlMapper = sqlMapper; }
public static TPrimaryKey Insert <TEntity, TPrimaryKey>(this ISqlMapper sqlMapper, TEntity entity) { return(sqlMapper.SessionStore.Open().Insert <TEntity, TPrimaryKey>(entity)); }
public UserInfoDao(ISqlMapper mapper) : base(mapper) { }
/// <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; }
protected static void Configure(object obj) { m_sqlMap = null; }
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); }
public static TEntity GetById <TEntity, TPrimaryKey>(this ISqlMapper sqlMapper, TPrimaryKey id, bool enablePropertyChangedTrack) { return(sqlMapper.SessionStore.Open().GetById <TEntity, TPrimaryKey>(id, enablePropertyChangedTrack)); }
public JobDao(ISqlMapper mapper) : base(mapper) { }
public static TEntity GetById <TEntity, TPrimaryKey>(this ISqlMapper sqlMapper, TPrimaryKey id) { return(GetById <TEntity, TPrimaryKey>(sqlMapper, id, false)); }
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()); }
public static int DeleteMany <TEntity, TPrimaryKey>(this ISqlMapper sqlMapper, IEnumerable <TPrimaryKey> ids) { return(sqlMapper.SessionStore.Open().DeleteMany <TEntity, TPrimaryKey>(ids)); }
public static int DeleteById <TEntity, TPrimaryKey>(this ISqlMapper sqlMapper, TPrimaryKey id) { return(sqlMapper.SessionStore.Open().DeleteById <TEntity, TPrimaryKey>(id)); }
public OrderByTest(SmartSqlFixture smartSqlFixture) { SqlMapper = smartSqlFixture.SqlMapper; }
public static int DyUpdate <TEntity>(this ISqlMapper sqlMapper, object entity) { return(sqlMapper.SessionStore.Open().DyUpdate <TEntity>(entity)); }
private static IList<DataServiceLogConfig> GetConfigList(ISqlMapper sqlmap) { return sqlmap.QueryForList<DataServiceLogConfig>("queryDataServiceLogConfigListT", new Hashtable()); }
public ProjectDao(ISqlMapper mapper) : base(mapper) { }
public SqlMapKeeper(ISqlMapper sqlMap) { _sqlMap = sqlMap; }
public ContextDao(ISqlMapper mapper) : base(mapper) { }
public MstIndexDAO(ISqlMapper _mapper) { this.mapper = _mapper; }
public CustomizeTypeHandlerTest(SmartSqlFixture smartSqlFixture) { SqlMapper = smartSqlFixture.SqlMapper; }