public void TestInitialize() { var serviceCollection = new ServiceCollection() .AddLogging(); serviceCollection.Add(new ServiceDescriptor(typeof(DatabaseContext), UnitTestDatabaseContext.Get())); serviceCollection.Add(new ServiceDescriptor(typeof(DaoManager), DaoManager.Get(UnitTestDatabaseContext.Get()))); var serviceProvider = serviceCollection.BuildServiceProvider(); var factory = serviceProvider.GetService <ILoggerFactory>(); var logger = factory.CreateLogger <OrderProductsController>(); Controller = new OrderProductsController(logger) { ControllerContext = new ControllerContext { HttpContext = new DefaultHttpContext { RequestServices = serviceProvider } } }; var identity = new ClaimsIdentity(); identity.AddClaim(new Claim(ClaimTypes.Sid, "3")); identity.AddClaim(new Claim(ClaimTypes.Role, "Admin")); Controller.ControllerContext.HttpContext.User = new ClaimsPrincipal(identity); }
private void LoadEvents() { _events.Clear(); Task.Factory.StartNew(() => { var databaseEvents = DaoManager.Get().EventDao.Find("Team_Id", _myApplication.CurrentTeam.Id.ToString()); foreach (var databaseEvent in databaseEvents) { _events.Add(new EventItem { Id = databaseEvent.Id, Name = databaseEvent.Name, StartDate = databaseEvent.StartDate, EndDate = databaseEvent.EndDate, EventType = databaseEvent.EventType }); } }).ContinueWith(task => { _eventAdapter = new EventAdapter(Activity, Resource.Layout.calendar_list_item, _events.ToArray()); _calendarList.Adapter = _eventAdapter; _eventAdapter.NotifyDataSetChanged(); }, TaskScheduler.FromCurrentSynchronizationContext()); }
protected override void OnStart() { base.OnStart(); _clubDictionary = new Dictionary <string, int>(); Task.Factory.StartNew(() => { ShowOverlay(true); SetActivityLayoutChildElementsEnabled(false); _clubs = DaoManager.Get().ClubDao.FindAll().ToArray(); _clubDictionary.Add(GetString(Resource.String.spn_club_select), 0); foreach (var club in _clubs) { _clubDictionary.Add(club.Name, club.Id); } ShowOverlay(false); SetActivityLayoutChildElementsEnabled(true); }).ContinueWith(task => { _clubAdapter = new ArrayAdapter <string>(this, Android.Resource.Layout.SimpleSpinnerItem, new List <string>(_clubDictionary.Keys)); _clubDropdown.Adapter = _clubAdapter; }, TaskScheduler.FromCurrentSynchronizationContext()); }
private void ConfirmButtonClicked(object sender, EventArgs eventArgs) { Task.Factory.StartNew(() => { ToggleLayout(); var titleValue = _titleEditText.Text; var bodyValue = _bodyEditText.Text; if (CheckForValidEntries(titleValue, bodyValue)) { var newsDao = DaoManager.Get().NewsDao; var news = new News { Title = titleValue, Body = bodyValue, Team_Id = _myApplication.CurrentTeam.Id }; newsDao.Save(news); } ToggleLayout(); }).ContinueWith(task => { _activity.OnBackPressed(); }, TaskScheduler.FromCurrentSynchronizationContext()); }
public CatalogService(DaoManager daoManager) { _daoManager = daoManager; _categoryDao = _daoManager[typeof(ICategoryDao)] as ICategoryDao; _productDao = _daoManager[typeof(IProductDao)] as IProductDao; _itemDao = _daoManager[typeof(IItemDao)] as IItemDao; }
protected string GetLocalSqlMap() { var daoManager = DaoManager.GetInstance(this); var sqlMapDaoSession = (AzureDaoSession)daoManager.LocalDaoSession; return(sqlMapDaoSession.DataSource.ConnectionString); }
public BillingService(DaoManager daoManager) { _daoManager = daoManager; _itemDao = _daoManager[typeof(IItemDao)] as IItemDao; _orderDao = _daoManager[typeof(IOrderDao)] as IOrderDao; _sequenceDao = _daoManager[typeof(ISequenceDao)] as ISequenceDao; }
/// <summary> /// Looks up the parent DaoManager, gets the local transaction /// (which should be a SqlMapDaoTransaction) and returns the /// SqlMap associated with this DAO. /// </summary> /// <returns>The SqlMap instance for this DAO.</returns> protected SqlMapper GetLocalSqlMap() { DaoManager daoManager = DaoManager.GetInstance(this); SqlMapDaoSession sqlMapDaoSession = (SqlMapDaoSession)daoManager.LocalDaoSession; return(sqlMapDaoSession.SqlMap); }
private void ConfirmButtonClick(object sender, EventArgs e) { Task.Factory.StartNew(() => { ToggleLayout(); if (_myAttendant == null) { _myAttendant = new Attendant { EventId = _eventId, UserId = _myApplication.CurrentUser.Id }; } _myAttendant.Attending = _myAttendantState; _myAttendant.Reason = _reasonEditText.Text; DaoManager.Get().AttendantDao.Save(_myAttendant); ToggleLayout(); }).ContinueWith(task => { Load(); }, TaskScheduler.FromCurrentSynchronizationContext()); }
public NPetshopContainer() : base() { TypedFactoryFacility facility = new TypedFactoryFacility(); AddFacility("typedfactory", facility); facility.AddTypedFactoryEntry( new FactoryEntry("stateFactory", typeof(IStateFactory), "Create", "Release")); // Add DaoManager bool test = Convert.ToBoolean(ConfigurationSettings.AppSettings["test"]); DomDaoManagerBuilder builder = new DomDaoManagerBuilder(); if (test) { builder.Configure(@"..\..\..\NPetshop.Persistence\dao.config"); } else { builder.Configure(@"..\NPetshop.Persistence\dao.config"); } this.Kernel.AddComponentInstance("DaoManager", typeof(DaoManager), DaoManager.GetInstance("SqlMapDao")); // Add services AddServices(); // Add Controllers AddControllers(); AddMVC(test); }
protected override void OnStart() { base.OnStart(); _teamListItems = new List <TeamListItem>(); Task.Factory.StartNew(() => { var userTeams = DaoManager.Get().TeamUserDao.Find("User_Id", _application.CurrentUser.Id.ToString()); var teamIds = userTeams.Select(ut => ut.TeamId.ToString()).ToList(); var teams = DaoManager.Get().TeamDao.FindByList("Team_Id", teamIds); var clubIds = teams.Select(t => t.ClubId.ToString()).Distinct().ToList(); var clubs = DaoManager.Get().ClubDao.FindByList("Club_Id", clubIds); foreach (var team in teams) { foreach (var club in clubs) { if (team.ClubId == club.Id) { _teamListItems.Add(new TeamListItem { Team = team, Club = club }); } } } }).ContinueWith(task => { _adapter.SetItems(_teamListItems.ToArray()); }, TaskScheduler.FromCurrentSynchronizationContext()); }
private CatalogService() { _daoManager = ServiceConfig.GetInstance().DaoManager; _categoryDao = _daoManager[typeof(ICategoryDao)] as ICategoryDao; _productDao = _daoManager[typeof(IProductDao)] as IProductDao; _itemDao = _daoManager[typeof(IItemDao)] as IItemDao; }
public void FixtureSetUp() { DomDaoManagerBuilder builder = new DomDaoManagerBuilder(); builder.Configure("dao_MSSQL_" + Configuration["providerType"] + ".config"); daoManager = DaoManager.GetInstance(); }
public void FixtureSetUp() { DomDaoManagerBuilder builder = new DomDaoManagerBuilder(); builder.Configure("dao" + "_" + Configuration["database"] + "_" + Configuration["providerType"] + ".config"); daoManager = DaoManager.GetInstance("SqlMapDao"); }
public MainForm() { InitializeComponent(); daoManager = DaoManager.getManager(); login(); stockRecord_init(); }
public AddUserLayout() { InitializeComponent(); daoManager = DaoManager.getManager(); roleC.Items.AddRange(new string[] { "admin", "user" }); roleC.SelectedIndex = 0; }
/// <summary> /// /// </summary> /// <param name="daoManager"></param> /// <returns></returns> public DaoSession GetDaoSession(DaoManager daoManager) { if (_dataSource == null) { throw new DataAccessException("Source is null in DaoSessionHandler (check the context source configurationin config)."); } return(new SimpleDaoSession(daoManager, _dataSource)); }
protected internal override void write() { this.writeH((short)0xE02); this.writeD(Convert.ToInt32(DateTime.Now.ToString("yyMMddHHmm"))); DaoManager daoManager = new DaoManager(this.gm); daoManager.getInventory(this.p_id); }
/// <summary> /// /// </summary> /// <param name="daoManager"></param> /// <returns></returns> public DaoSession GetDaoSession(DaoManager daoManager) { if (_dataSource == null) { throw new DataAccessException("Source is null in DaoSessionHandler (check the context source configurationin config)."); } return (new SimpleDaoSession(daoManager,_dataSource)); }
public void SetUp() { DomDaoManagerBuilder builder = new DomDaoManagerBuilder(); builder.Configure(@"..\..\..\NPetshop.Persistence\dao.config"); daoManager = DaoManager.GetInstance("SqlMapDao"); }
public void FixtureSetUp() { DomDaoManagerBuilder builder = new DomDaoManagerBuilder(); builder.Configure("dao_Oracle_" + ConfigurationSettings.AppSettings["providerType"] + ".config"); daoManager = DaoManager.GetInstance(); }
private void LoadEvent() { var events = DaoManager.Get().EventDao.Find(_eventId); if (events.Count != 0) { _event = events[0]; SetEventInfoOnTextViews(_event); } }
private void OnClickSubmit(object sender, EventArgs e) { var result = NoResult; Task.Factory.StartNew(() => { ToggleLayout(); while (result == NoResult) { if (string.IsNullOrEmpty(_teamName.Text)) { result = NoTeamName; } else if (_clubId == 0) { result = NoClub; } var foundTeams = DaoManager.Get().TeamDao.Count("name", _teamName.Text); if (foundTeams > 0) { result = TeamNameAlreadyTaken; } else { var newTeam = new Team { Name = _teamName.Text, ClubId = _clubId }; newTeam = DaoManager.Get().TeamDao.Save(newTeam); var newTeamUser = new TeamUser() { TeamId = newTeam.Id, UserId = _application.CurrentUser.Id }; DaoManager.Get().TeamUserDao.Save(newTeamUser); result = NoError; } } ToggleLayout(); }).ContinueWith(task => { ProcessResult(result); }, TaskScheduler.FromCurrentSynchronizationContext()); }
public void SetUp() { DomDaoManagerBuilder builder = new DomDaoManagerBuilder(); builder.Configure("dao" + "_" + ConfigurationSettings.AppSettings["database"] + "_" + ConfigurationSettings.AppSettings["providerType"] + ".config"); daoManager = DaoManager.GetInstance("SqlMapDao"); daoManager2 = DaoManager.GetInstance("NHibernateDao"); InitScript(daoManager.LocalDataSource, ScriptDirectory + "account-init.sql"); InitScript(daoManager2.LocalDataSource, ScriptDirectory + "user-init.sql"); }
public void FixtureSetUp() { DomDaoManagerBuilder builder = new DomDaoManagerBuilder(); #if dotnet2 builder.Configure("dao_MySql_" + ConfigurationManager.AppSettings["providerType"] + ".config"); #else builder.Configure("dao_MySql_" + ConfigurationSettings.AppSettings["providerType"] + ".config"); #endif daoManager = DaoManager.GetInstance(); }
public IDaoManager getDaoManager(string name) { IDaoManager instance; if (string.IsNullOrEmpty(name)) { instance = DaoManager.GetInstance(); } else { instance = DaoManager.GetInstance(name); } return(instance); }
public string GetDbtype() { IDaoManager instance; if (string.IsNullOrEmpty(this.ContextName)) { instance = DaoManager.GetInstance(); } else { instance = DaoManager.GetInstance(this.ContextName); } return(instance.LocalDataSource.DbProvider.Name); }
public void getCurrentUser() { List <Database.Entities.User> result = null; Task.Factory.StartNew(() => { result = DaoManager.Get().UserDao.Find(_userId); Log.Debug("user: ", result.ToString()); return(result); }).ContinueWith(task => { ProcessResult(result); }, TaskScheduler.FromCurrentSynchronizationContext()); }
public void SetUp() { string scriptDirectory = Path.Combine(Path.Combine(Path.Combine(Path.Combine(Resources.ApplicationBase, ".."), ".."), "Scripts"), ConfigurationSettings.AppSettings["database"]) + Path.DirectorySeparatorChar; // Resources.RootDirectory + Path.DirectorySeparatorChar + // "Scripts" + Path.DirectorySeparatorChar + // ConfigurationSettings.AppSettings["database"]+ Path.DirectorySeparatorChar; DomDaoManagerBuilder builder = new DomDaoManagerBuilder(); builder.Configure("dao" + "_" + ConfigurationSettings.AppSettings["database"] + "_" + ConfigurationSettings.AppSettings["providerType"] + ".config"); _daoManager = DaoManager.GetInstance("NHibernateDao"); InitScript(_daoManager.LocalDataSource, scriptDirectory + "user-init.sql"); }
/// <summary> /// Initialize dao object. /// </summary> public void Initialize(DaoManager daoManager) { try { _daoManager = daoManager; _daoImplementation = TypeUtils.ResolveType(this.Implementation); _daoInterface = TypeUtils.ResolveType(this.Interface); // Create a new instance of the Dao object. _daoInstance = _daoImplementation.GetConstructor(Type.EmptyTypes).Invoke(null) as IDao; _proxy = DaoProxy.NewInstance(this); } catch (Exception e) { throw new ConfigurationErrorsException(string.Format("Error configuring DAO. Cause: {0}", e.Message), e); } }
private void LoadAttendants() { _attendants = DaoManager.Get().AttendantDao.Find("Event_Id", _eventId.ToString()); //Setup new attendants if 0 are found if (_attendants.Count == 0) { var users = DaoManager.Get().TeamUserDao.FindByTeamId(_myApplication.CurrentTeam.Id); foreach (var teamUser in users) { var newAttendant = new Attendant { Attending = AttendingState.Maybe, EventId = _eventId, Reason = "", UserId = teamUser.UserId }; var datatabasAttendant = DaoManager.Get().AttendantDao.Save(newAttendant); _attendants.Add(datatabasAttendant); } } foreach (var attendant in _attendants) { if (attendant.UserId == _myApplication.CurrentUser.Id) { _myAttendant = attendant; break; } } _attendantsListItems = new List <AttendantListItem>(); foreach (var attendant in _attendants) { var user = DaoManager.Get().UserDao.Find(attendant.UserId); var newItem = new AttendantListItem { User = user[0], AttendState = attendant.Attending, Reason = attendant.Reason }; _attendantsListItems.Add(newItem); } }
/// <summary> /// Parse dao factory tag /// </summary> /// <param name="configurationScope">The scope of the configuration</param> /// <param name="daoManager"></param> private void ParseDaoFactory(ConfigurationScope configurationScope, DaoManager daoManager) { Dao dao = null; configurationScope.ErrorContext.MoreInfo = "configure dao"; foreach (XmlNode node in configurationScope.NodeContext.SelectNodes(ApplyNamespacePrefix(XML_DAO), configurationScope.XmlNamespaceManager )) { dao = DaoDeSerializer.Deserialize(node, configurationScope); //(Dao) serializer.Deserialize(new XmlNodeReader(node)); configurationScope.ErrorContext.ObjectId = dao.Implementation; dao.Initialize(daoManager); daoManager.RegisterDao(dao); } configurationScope.ErrorContext.Resource = string.Empty; configurationScope.ErrorContext.MoreInfo = string.Empty; configurationScope.ErrorContext.ObjectId = string.Empty; }
/// <summary> /// /// </summary> /// <param name="daoManager"></param> /// <param name="dataSource"></param> public SimpleDaoSession(DaoManager daoManager, DataSource dataSource) : base(daoManager) { _dataSource = dataSource; }
/// <summary> /// /// </summary> /// <param name="daoManager"></param> /// <param name="sqlMap"></param> public SqlMapDaoSession(DaoManager daoManager, ISqlMapper sqlMap) : base(daoManager) { _sqlMap = sqlMap; }
/// <summary> /// /// </summary> /// <param name="daoManager"></param> /// <returns></returns> public DaoSession GetDaoSession(DaoManager daoManager) { return (new SqlMapDaoSession(daoManager, _sqlMap)); }