/// <summary> /// Load the database datafields directly from the xml to generate a query, /// this is more far efficient than loading the visual tree. /// </summary> /// <param name="pathFile">Path file to be used</param> protected void InitData(string pathFile) { Contract.Requires(!string.IsNullOrEmpty(pathFile), "Path name is not valied"); var currentAssemblyPath = System.IO.Path.GetDirectoryName( System.Reflection.Assembly.GetExecutingAssembly().GetName().CodeBase); var builder = new StringBuilder(); builder.Append(currentAssemblyPath); builder.Append(pathFile); var collection = SqlFieldLoader.LoadXmlData(builder.ToString()); foreach (var table in collection.DataList) { var tmpBuilder = new StringBuilder(); var fields = table.DataFields; foreach (var f in fields) { tmpBuilder.Append(f.Name); tmpBuilder.Append(","); } var query = tmpBuilder.ToString(); query = query.Substring(0, query.Length - 1); tmpBuilder.Clear(); if (!BaseQueryDictionary.ContainsKey(table.Name)) { BaseQueryDictionary.Add(table.Name, query); } } // now instance a map Mapper = MapperField.GetMapper(); }
protected override void InitializeShell() { // The main window and configuration services shall be injected just here // because in the configure container are not yet available. try { IMapper mapper = MapperField.GetMapper(); IConfigurationService shell = Container.Resolve <IConfigurationService>(); shell.Shell = Application.Current.MainWindow; PropertyInfo info = shell.Shell.GetType().GetProperty("UnityContainer"); if (info != null) { info.SetValue(shell.Shell, Container); } var wrapShell = this.WrapShell(); wrapShell.Show(); Container.Resolve <ProviderInfoView>(); Container.Resolve <CommissionAgentInfoView>(); Container.Resolve <BookingModule.Views.BookingInfoView>(); Container.Resolve <KarveControls.HeaderedWindow.LineGridView>(); Container.Resolve <BookingModule.Views.BookingFooterView>(); } catch (Exception e) { logger.Error("Error during bootstrap:" + e.Message); MessageBox.Show("Error during bootstrap" + e.Message); } }
/// <summary> /// Get magnifier settings by id. /// </summary> /// <param name="idValue">Identifier of the grid.</param> /// <returns></returns> public async Task <GridSettingsDto> GetMagnifierSettings(long idValue) { IMapper mapper = MapperField.GetMapper(); GridSettingsDto settingsDto = new GridSettingsDto(); if (_executorSql.State != ConnectionState.Open) { using (var dbConnection = _executorSql.OpenNewDbConnection()) { var dto = await dbConnection.GetAsync <GRID_SERIALIZATION>(idValue).ConfigureAwait(true); if (dto != null) { settingsDto = mapper.Map <GRID_SERIALIZATION, GridSettingsDto>(dto); } return(settingsDto); } } var settings = await _executorSql.Connection.GetAsync <GRID_SERIALIZATION>(idValue); settingsDto = mapper.Map <GRID_SERIALIZATION, GridSettingsDto>(settings); return(settingsDto); }
/// <summary> /// Client data saver /// </summary> /// <param name="executor">Sql command executor</param> public OfficeDataSaver(ISqlExecutor executor) { _executor = executor; /// FIXME: violate the law of demter. _mapper = MapperField.GetMapper(); _queryStoreFactory = new QueryStoreFactory(); }
public async Task <bool> SaveBranches(IDbConnection connection) { bool retValue = true; string deleteAll = string.Format("DELETE FROM ProDelega WHERE cldIdCliente='{0}'", this.Value.NUM_PROVEE); await connection.ExecuteAsync(deleteAll); IMapper tmpMapper = MapperField.GetMapper(); foreach (var branch in this.BranchesDtos) { ProDelega delega = tmpMapper.Map <BranchesDto, ProDelega>(branch); delega.cldIdCliente = this.Value.NUM_PROVEE; try { int value = await connection.InsertAsync(delega); } catch (System.Exception e) { retValue = false; string message = "Transaction Scope Exception in Vehicle Insertion. Reason: " + e.Message; logger.Error(message); DataLayerExecutionException dataLayer = new DataLayerExecutionException(message); throw dataLayer; } } return(retValue); }
public async Task <ObservableCollection <GridSettingsDto> > GetMagnifierSettingByIds(List <long> registeredGridIds) { ObservableCollection <GRID_SERIALIZATION> settings = new ObservableCollection <GRID_SERIALIZATION>(); Contract.Requires(registeredGridIds != null); using (var dbConnection = _executorSql.OpenNewDbConnection()) { if (dbConnection != null) { try { var dto = await dbConnection.GetAllAsync <GRID_SERIALIZATION>().ConfigureAwait(false); var first = dto.OrderBy(x => x.GRID_ID).ToList(); foreach (var ids in registeredGridIds) { settings.Add(first.FirstOrDefault(x => x.GRID_ID == ids)); } } catch (System.Exception e) { throw new DataLayerException(e.Message, e); } } } var outSettings = MapperField.GetMapper() .Map <IEnumerable <GRID_SERIALIZATION>, ObservableCollection <GridSettingsDto> >(settings); return(outSettings); }
/// <summary> /// Constructor /// </summary> /// <param name="sqlExecutor">This load the sql executor</param> public CompanyDataLoader(ISqlExecutor sqlExecutor) { _sqlExecutor = sqlExecutor; _mapper = MapperField.GetMapper(); _currentPos = 0; _helperBase = new HelperBase(); _queryStoreFactory = new QueryStoreFactory(); }
/// <summary> /// Constructor for the budget /// </summary> /// <param name="sqlExecutor"></param> public BudgetDataAccessLayer(ISqlExecutor sqlExecutor) : base(sqlExecutor) { _dataLoader = new BudgetDataLoader(sqlExecutor); _dataSaver = new BudgetDataSaver(sqlExecutor); _dataDeleter = new BudgetDataDeleter(sqlExecutor); TableName = "PRESUP1"; _mapper = MapperField.GetMapper(); }
/// <summary> /// Booking data access layer. /// </summary> /// <param name="executor">Executor handle database connection.</param> public BookingDataAccessLayer(ISqlExecutor executor) : base(executor) { _mapper = MapperField.GetMapper(); _dataLoader = new BookingDataLoader(SqlExecutor, _mapper); _dataDeleter = new BookingDataDeleter(SqlExecutor, _mapper); _dataSaver = new BookingDataSaver(SqlExecutor, _mapper); TableName = "RESERVAS1"; }
public ReservationRequestDataAccessLayer(ISqlExecutor sqlExecutor) : base(sqlExecutor) { _dataLoader = new DataLoader <PETICION, ReservationRequestDto>(sqlExecutor); _dataSaver = new DataSaver <PETICION, ReservationRequestDto>(sqlExecutor); _dataDeleter = new DataDeleter <PETICION, ReservationRequestDto>(sqlExecutor); TableName = "PETICION"; _mapper = MapperField.GetMapper(); }
public BookingDataAccessLayer(ISqlExecutor sqlExecutor) : base(sqlExecutor) { _dataLoader = new DataLoader <RESERVAS1, BookingDto>(sqlExecutor); _dataSaver = new DataSaver <RESERVAS1, BookingDto>(sqlExecutor); _dataDeleter = new DataDeleter <RESERVAS1, BookingDto>(sqlExecutor); TableName = "RESERVAS1"; _mapper = MapperField.GetMapper(); }
/// <summary> /// BookingIncidentDataAccessLayer /// </summary> /// <param name="sqlExecutor">SQL executor</param> public BookingIncidentDataAccessLayer(ISqlExecutor sqlExecutor) : base(sqlExecutor) { _dataLoader = new DataLoader <INCIRE, BookingIncidentViewObject>(sqlExecutor); _dataSaver = new DataSaver <INCIRE, BookingIncidentViewObject>(sqlExecutor); _dataDeleter = new DataDeleter <INCIRE, BookingIncidentViewObject>(sqlExecutor); TableName = "INCIRE"; _mapper = MapperField.GetMapper(); }
public UsersDataAccessLayer(ISqlExecutor sqlExecutor) : base(sqlExecutor) { _dataLoader = new DataLoader <USURE, UsersDto>(sqlExecutor); _dataSaver = new DataSaver <USURE, UsersDto>(sqlExecutor); _dataDeleter = new DataDeleter <USURE, UsersDto>(sqlExecutor); TableName = "USURE"; _mapper = MapperField.GetMapper(); }
/// <summary> /// KarveNavigator constructor /// </summary> /// <param name="dataServices">DataServices to be used for navigation</param> /// <param name="regionManager">RegionManager to be used for instantiating a videw</param> /// <param name="eventManager">EventManager to be used for communicating between view models</param> /// <param name="dialogService">DialogServicing to be used for spotting errors.</param> public KarveNavigator(IDataServices dataServices, IRegionManager regionManager, IEventManager eventManager, IDialogService dialogService) { _dataServices = dataServices; _regionManager = regionManager; _eventManager = eventManager; _dialogService = dialogService; _mapper = MapperField.GetMapper(); }
public IncidentDataAccessLayer(ISqlExecutor sqlExecutor) : base(sqlExecutor) { _dataLoader = new DataLoader <INCIDENCIAS, IncidentDto>(sqlExecutor); _dataSaver = new DataSaver <INCIDENCIAS, IncidentDto>(sqlExecutor); _dataDeleter = new DataDeleter <INCIDENCIAS, IncidentDto>(sqlExecutor); TableName = "INCIDENCIAS"; _mapper = MapperField.GetMapper(); }
/// <summary> /// Helper loader. This loader helps to load the data from dataservices /// </summary> /// <param name="services">Data services to be loaded.</param> public HelperLoader(IDataServices services) { _services = services; _helperDataServices = services.GetHelperDataServices(); _loadCompleted += OnLoadCompleted; _currentIndex = 0; _mapper = MapperField.GetMapper(); PageSize = _defaultPageSize; }
/// <summary> /// Office data service constructor /// </summary> /// <param name="sqlExecutor">Sql Executor, interface for ADO.NET/Dapper access</param> public OfficeDataService(ISqlExecutor sqlExecutor) : base(sqlExecutor) { _mapper = MapperField.GetMapper(); _loader = new OfficeDataLoader(SqlExecutor, _mapper); _saver = new OfficeDataSaver(SqlExecutor, _mapper); _deleter = new OfficeDataDeleter(SqlExecutor, _mapper); // it is useful for the page count. TableName = "OFICINAS"; }
public CommissionAgent() { _currentComisio = new COMISIO(); _commissionAgents = new List <COMISIO>(); _nacioPer = new List <Country>(); _tipoComis = new List <TIPOCOMI>(); _provinces = new List <PROVINCIA>(); _commissionAgentType = new CommissionAgentTypeData(); _mapper = MapperField.GetMapper(); }
/// <summary> /// This load a client using a valid executro. /// </summary> /// <param name="executor">Sql executor</param> public ClientDataLoader(ISqlExecutor executor) { _sqlExecutor = executor; _mapper = MapperField.GetMapper(); _currentPoco = new ClientDto(); _currentPoco.Helper = new HelperBase(); Valid = true; _currentQueryPos = 0; _queryStoreFactory = new QueryStoreFactory(); }
/// <summary> /// Booking data access layer. /// </summary> /// <param name="executor">Executor handle database connection.</param> public BookingDataAccessLayer(ISqlExecutor executor, IConfigurationService service) : base(executor) { _mapper = MapperField.GetMapper(); _dataLoader = new BookingDataLoader(SqlExecutor, _mapper); _dataDeleter = new BookingDataDeleter(SqlExecutor, _mapper); _dataSaver = new BookingDataSaver(SqlExecutor, _mapper); TableName = "RESERVAS1"; _configuration = service; }
public CommissionAgent(ISqlExecutor executor, string commissionId) { _executor = executor; _currentComisio = new COMISIO(); _currentComisio.NUM_COMI = commissionId; _commissionAgents = new List <COMISIO>(); _nacioPer = new List <Country>(); _tipoComis = new List <TIPOCOMI>(); _provinces = new List <PROVINCIA>(); _commissionAgentType = new CommissionAgentTypeData(); _mapper = MapperField.GetMapper(); }
public async Task <bool> SaveMagnifierSettings(GridSettingsDto settingsDto) { Contract.Requires(settingsDto != null); bool value = false; IMapper mapper = MapperField.GetMapper(); GRID_SERIALIZATION serialize = mapper.Map <GridSettingsDto, GRID_SERIALIZATION>(settingsDto); Contract.Requires(serialize != null); value = await SaveOrUpdate(serialize).ConfigureAwait(false); return(value); }
public async Task Should_Retrieve_ASortedClientPage() { Dictionary <string, ListSortDirection> direction = new Dictionary <string, ListSortDirection> { { "Name", ListSortDirection.Ascending }, { "City", ListSortDirection.Descending } }; IMapper mapper = MapperField.GetMapper(); var sortedData = await _clientDataServices.GetSortedCollectionPagedAsync(direction, 1, 25); Assert.NotNull(sortedData); Assert.GreaterOrEqual(25, sortedData.Count()); }
/// <summary> /// ProviderInfoViewModel. /// </summary> /// <param name="eventManager"></param> /// <param name="configurationService"></param> /// <param name="dataServices"></param> /// <param name="dialogService"></param> /// <param name="manager"></param> /// <param name="controller"></param> public ProviderInfoViewModel(IEventManager eventManager, IConfigurationService configurationService, IDataServices dataServices, IDialogService dialogService, IRegionManager manager, IInteractionRequestController controller) : base(eventManager, configurationService, dataServices, dialogService, manager, controller) { ConfigurationService = configurationService; MailBoxHandler += MessageHandler; AccountAssistQuery = _accountAssistQuery; EventManager.RegisterObserverSubsystem(MasterModuleConstants.ProviderSubsystemName, this); // TODO: all the mapping shall be isolated. mapper = MapperField.GetMapper(); _onBranchesPrimaryKey += ProviderInfoViewModel__onBranchesPrimaryKey; _onContactsPrimaryKey += ProviderInfoViewModel__onContactsPrimaryKey; _uniqueCounter++; _assistDataService = dataServices.GetAssistDataServices(); SubSystem = DataSubSystem.SupplierSubsystem; ViewModelUri = new Uri("karve://supplier/viewmodel?id=" + Guid.ToString()); InitVmCommands(); }
public async Task <ObservableCollection <GridSettingsDto> > GetMagnifierSettingByIds(List <long> registeredGridIds) { ObservableCollection <GRID_SERIALIZATION> settings = new ObservableCollection <GRID_SERIALIZATION>(); Contract.Requires(registeredGridIds != null); using (var dbConnection = _executorSql.OpenNewDbConnection()) { var dto = await dbConnection.GetAsyncAll <GRID_SERIALIZATION>(); var first = dto.OrderBy(x => x.GRID_ID).ToList(); foreach (var ids in registeredGridIds) { settings.Add(first.FirstOrDefault(x => x.GRID_ID == ids)); } } var outSettings = MapperField.GetMapper() .Map <IEnumerable <GRID_SERIALIZATION>, ObservableCollection <GridSettingsDto> >(settings); return(outSettings); }
public async Task Should_UpdateOrInsert_GridSerialized() { byte[] currentBytes = { 0x10, 0xFF, 0x23, 0x25, 0x23, 0x80 }; var base64 = Convert.ToBase64String(currentBytes); IMapper mapper = MapperField.GetMapper(); GridSettingsDto gridSettingsDto = new GridSettingsDto(); gridSettingsDto.GridIdentifier = 0x800; gridSettingsDto.GridName = "Not known"; gridSettingsDto.XmlBase64 = @"<grid></grid>"; try { var serialize = mapper.Map <GridSettingsDto, GRID_SERIALIZATION>(gridSettingsDto); using (IDbConnection connection = _sqlExecutor.OpenNewDbConnection()) { using (TransactionScope scope = new TransactionScope(TransactionScopeAsyncFlowOption.Enabled)) { var value = false; if (!connection.IsPresent <GRID_SERIALIZATION>(serialize)) { value = await connection.InsertAsync <GRID_SERIALIZATION>(serialize) > 0; } else { value = await connection.UpdateAsync <GRID_SERIALIZATION>(serialize); } Assert.IsTrue(value); scope.Complete(); } } } catch (Exception e) { var ex = e; Assert.Fail(ex.Message); } // nowe we have to assert this. }
protected override void InitializeShell() { // The main window and configuration services shall be injected just here // because in the configure container are not yet available. try { IConfigurationService shell = Container.Resolve <IConfigurationService>(); shell.Shell = Application.Current.MainWindow; PropertyInfo info = shell.Shell.GetType().GetProperty("UnityContainer"); if (info != null) { info.SetValue(shell.Shell, Container); } Application.Current.MainWindow.Show(); // we preload some heavy modules. // this is a trick to speed up further creations and load prism. // Container.Resolve<ProviderInfoView>(); // Container.Resolve<CommissionAgentInfoView>(); // Container.Resolve<ClientsInfoView>(); // Container.Resolve<VehicleInfoView>(); // Container.Resolve<DriverLicenseView>(); Container.Resolve <BookingModule.Views.BookingInfoView>(); Container.Resolve <KarveControls.HeaderedWindow.LineGridView>(); Container.Resolve <BookingModule.Views.BookingFooterView>(); /* * Resolve the view model. Kind of view model first approach. We can use a LineGridView * for every kind of subject and for the specific. * This allows the reuse better than view. */ IMapper mapper = MapperField.GetMapper(); } catch (Exception e) { logger.Error("Error during bootstrap:" + e.Message); MessageBox.Show("Error during bootstrap" + e.Message); } }
/// <summary> /// Commision agent info view model. /// </summary> /// <param name="configurationService"></param> /// <param name="eventManager"></param> /// <param name="services"></param> /// <param name="dialogService"></param> /// <param name="regionManager"></param> /// <param name="controller"></param> public CommissionAgentInfoViewModel(IConfigurationService configurationService, IEventManager eventManager, IDataServices services, IDialogService dialogService, IRegionManager regionManager, IInteractionRequestController controller ) : base(eventManager, configurationService, services, dialogService, regionManager, controller) { _queries = new Dictionary <string, string>(); _visibility = Visibility.Collapsed; _commissionAgentDataServices = DataServices.GetCommissionAgentDataServices(); _regionManager = regionManager; _onBranchesPrimaryKey += CommissionAgentInfoViewModel__onBranchesPrimaryKey; _onContactsPrimaryKey += CommissionAgentInfoViewModel__onContactsPrimaryKey; _onVisitPrimaryKey += CommissionAgentInfoViewModel__onVisitPrimaryKey; IsVisible = Visibility.Collapsed; AssistQueryDictionary = new Dictionary <string, string>(); PrimaryKeyValue = string.Empty; ConfigurationService = configurationService; InitEvents(); InitCommands(); ViewModelUri = new Uri("karve://broker/viewmodel?id=" + Guid.ToString()); _mapper = MapperField.GetMapper(); EventManager.RegisterObserverSubsystem(MasterModuleConstants.CommissionAgentSystemName, this); // update the assist. UpdateAssist(ref _leftSideDualDfSearchBoxes); UpdateChangeCommand(ref _leftSideDualDfSearchBoxes); // register itself in the broacast. EventManager.RegisterObserver(this); _countTime = 0; }
public TestMappingData() { _mapper = MapperField.GetMapper(); }
/// <summary> /// Constructor for the sql deleter. /// </summary> /// <param name="executor">SqlExecutor to delete</param> public ClientDeleter(ISqlExecutor executor) { _mapper = MapperField.GetMapper(); _executor = executor; }