Exemplo n.º 1
0
        public void SaveActivePlayer(string playerName, short?pokersiteId)
        {
            try
            {
                string dataPath = StringFormatter.GetActivePlayerFilePath();

                if (pokersiteId.HasValue)
                {
                    File.WriteAllText(dataPath, $"{playerName}{Environment.NewLine}{pokersiteId}");
                }
                else
                {
                    File.WriteAllText(dataPath, playerName);
                }
            }
            catch (Exception ex)
            {
                LogProvider.Log.Error(ex);
            }
        }
Exemplo n.º 2
0
        public ISessionFactory CreateSessionFactory()
        {
            if (sessionFactory == null || sessionFactory.IsClosed)
            {
                lock (factorylock)
                {
                    if (sessionFactory == null || sessionFactory.IsClosed)
                    {
                        var settings = ServiceLocator.Current.GetInstance <ISettingsService>().GetSettings().DatabaseSettings;

                        sessionFactory = Fluently.Configure()
                                         .Database(PostgreSQLConfiguration.Standard
                                                   .ConnectionString(
                                                       c => c.Is(StringFormatter.GetConnectionString(settings.Server, settings.Port, settings.Database, settings.User, settings.Password))))
                                         .Mappings(x => x.FluentMappings.AddFromAssemblyOf <HandhistoryMap>())
                                         .BuildSessionFactory();
                    }
                }
            }

            return(sessionFactory);
        }
Exemplo n.º 3
0
        public ISessionFactory CreateSQLiteSessionFactory()
        {
            if (sqliteSessionFactory == null || sqliteSessionFactory.IsClosed)
            {
                lock (factorylock)
                {
                    if (sqliteSessionFactory == null || sqliteSessionFactory.IsClosed)
                    {
                        sqliteSessionFactory = Fluently.Configure()
                                               .Database(SQLiteConfiguration.Standard.ConnectionString(StringFormatter.GetSQLiteConnectionString()))
                                               .Mappings(x => x.FluentMappings.AddFromAssemblyOf <DriveHUD.Entities.Mapping.TournamentsMap>())
                                               .BuildSessionFactory();
                    }
                }
            }

            return(sqliteSessionFactory);
        }
Exemplo n.º 4
0
        public IPlayer GetActivePlayer()
        {
            IPlayer activePlayer = new PlayerCollectionItem();

            string dataPath = StringFormatter.GetActivePlayerFilePath();

            if (File.Exists(dataPath))
            {
                var splittedResult = File.ReadAllText(dataPath).Split(new string[] { Environment.NewLine }, StringSplitOptions.None);

                if (splittedResult.Length < 2)
                {
                    try
                    {
                        using (var session = ModelEntities.OpenSession())
                        {
                            var alias = session.Query <Aliases>().Fetch(x => x.Players).FirstOrDefault(x => x.AliasName.Equals(splittedResult[0]));

                            if (alias != null)
                            {
                                activePlayer = new AliasCollectionItem
                                {
                                    PlayerId       = alias.AliasId,
                                    Name           = alias.AliasName,
                                    PlayersInAlias = new ObservableCollection <PlayerCollectionItem>(alias.Players.Select(p =>
                                                                                                                          new PlayerCollectionItem
                                    {
                                        PlayerId  = p.PlayerId,
                                        PokerSite = (EnumPokerSites)p.PokersiteId,
                                        Name      = p.Playername
                                    }))
                                };
                            }
                        }
                    }
                    catch (Exception e)
                    {
                        LogProvider.Log.Error(this, "Couldn't get active alias", e);
                    }

                    return(activePlayer);
                }

                if (!short.TryParse(splittedResult[1], out short pokerSiteId))
                {
                    return(activePlayer);
                }

                try
                {
                    using (var session = ModelEntities.OpenSession())
                    {
                        var player = session.Query <Players>().FirstOrDefault(x => x.Playername.Equals(splittedResult[0]) && x.PokersiteId == pokerSiteId);

                        if (player != null)
                        {
                            activePlayer = new PlayerCollectionItem {
                                PlayerId = player.PlayerId, Name = player.Playername, PokerSite = (EnumPokerSites)player.PokersiteId
                            };
                        }
                    }
                }
                catch (Exception e)
                {
                    LogProvider.Log.Error(this, "Couldn't get active player", e);
                }
            }

            return(activePlayer);
        }
Exemplo n.º 5
0
        public static void ConfigureContainer(IUnityContainer container)
        {
            if (container == null)
            {
                throw new ArgumentNullException(nameof(container));
            }

            container.RegisterType <IReportStatusService, ReportStatusService>(new ContainerControlledLifetimeManager());
            container.RegisterType <IPlayerStatisticRepository, PlayerStatisticRepository>(new ContainerControlledLifetimeManager());
            container.RegisterType <IFilterDataService, FilterDataService>(new ContainerControlledLifetimeManager(), new InjectionConstructor(StringFormatter.GetAppDataFolderPath()));
            container.RegisterType <IFilterModelManagerService, MainFilterModelManagerService>(FilterServices.Main.ToString(), new ContainerControlledLifetimeManager());
            container.RegisterType <IFilterModelManagerService, StickersFilterModelManagerService>(FilterServices.Stickers.ToString(), new ContainerControlledLifetimeManager());
            container.RegisterType <ISessionFactoryService, SessionFactoryService>(new ContainerControlledLifetimeManager());
            container.RegisterType <IProductAppStoreRepository, ProductAppStoreRepository>();
            container.RegisterType <IProductAppStoreModel, ProductAppStoreModel>();
            container.RegisterType <ITrainingAppStoreRepository, TrainingAppStoreRepository>();
            container.RegisterType <ITrainingAppStoreModel, TrainingAppStoreModel>();
            container.RegisterType <IAppsAppStoreRepository, AppsAppStoreRepository>();
            container.RegisterType <IAppsAppStoreModel, AppsAppStoreModel>();
            container.RegisterType <IRakebackAppStoreRepository, RakebackAppStoreRepository>();
            container.RegisterType <IRakebackAppStoreModel, RakebackAppStoreModel>();
            container.RegisterType <IOpponentReportService, OpponentReportService>(new ContainerControlledLifetimeManager());
            container.RegisterType <IPopulationReportService, PopulationReportService>(new ContainerControlledLifetimeManager());
            container.RegisterType <IHudPlayerTypeService, HudPlayerTypeService>();
            container.RegisterType <IHudBumperStickerService, HudBumperStickerService>();
            container.RegisterType <IEquitySolver, EquitySolver>();
            container.RegisterType <IHudStoreUploadModel, HudStoreUploadModel>();
            container.RegisterType <IHudStoreWebService, HudStoreWebService>();
            container.RegisterType <IHudStoreModel, HudStoreModel>();
            container.RegisterType <IPlayerStatisticCalculator, PlayerStatisticCalculator>(PlayerStatisticCalculatorServiceNames.Base);
            container.RegisterType <IPlayerStatisticCalculator, PKShortPlayerStatisticCalculator>(PlayerStatisticCalculatorServiceNames.PKShortDeck);
            container.RegisterType <IHandExportService, HandExportService>();
            container.RegisterType <IHandNoteCacheService, HandNoteCacheService>(new ContainerControlledLifetimeManager());

            #region Export services

            container.RegisterType <IHandExportPreparingService, CommonHandExportPreparingService>(HandExportPreparingServiceProvider.Common);
            container.RegisterType <IHandExportPreparingService, WPNHandExportPreparingService>(HandExportPreparingServiceProvider.WPN);
            container.RegisterType <IHandExportPreparingService, DHBasedHandExportPreparingService>(HandExportPreparingServiceProvider.DriveHUD);
            container.RegisterType <IHandExportPreparingService, IPokerHandExportPreparingService>(HandExportPreparingServiceProvider.CustomIPoker);

            #endregion
        }