Example #1
0
        public void Store(Handnotes handnotes)
        {
            try
            {
                using (var session = ModelEntities.OpenSession())
                {
                    using (var transaction = session.BeginTransaction())
                    {
                        var existingHandNote = session
                                               .Query <Handnotes>()
                                               .FirstOrDefault(x => x.PokersiteId == handnotes.PokersiteId && x.Gamenumber == handnotes.Gamenumber);

                        if (existingHandNote != null)
                        {
                            existingHandNote.HandTag = handnotes.HandTag;
                            existingHandNote.Note    = handnotes.Note;
                        }
                        else
                        {
                            existingHandNote = handnotes;
                        }

                        session.SaveOrUpdate(existingHandNote);
                        transaction.Commit();
                    }
                }
            }
            catch (Exception e)
            {
                LogProvider.Log.Error(this, "Couldn't save hand notes", e);
            }
        }
Example #2
0
        private string LoadHandNoteViewModel(long gameNumber, short pokerSiteId)
        {
            _handNoteEntity = _dataService.GetHandNote(gameNumber, pokerSiteId);
            if (_handNoteEntity != null)
            {
                return(_handNoteEntity.Note);
            }

            return(string.Empty);
        }
Example #3
0
        /// <summary>
        /// The save.
        /// </summary>
        private void Save()
        {
            if (_handNoteEntity == null)
            {
                _handNoteEntity = new Handnotes
                {
                    Gamenumber  = this._gameNumber,
                    PokersiteId = this._pokerSiteId,
                };
            }

            _handNoteEntity.Note = Note;
            _dataService.Store(_handNoteEntity);
            CloseAction.Invoke();
        }
        public void AddHandNote(Handnotes handNote)
        {
            if (handNote == null)
            {
                return;
            }

            try
            {
                var noteKey = new HandNoteKey(handNote.Gamenumber, handNote.PokersiteId);
                handNotes.AddOrUpdate(noteKey, handNote, (key, oldValue) => handNote);
            }
            catch (Exception e)
            {
                LogProvider.Log.Error(this, "Failed to add hand note to note cache service.", e);
            }
        }
Example #5
0
        private void TagHand(object obj)
        {
            var tag = EnumHandTag.None;

            if (!Enum.TryParse(obj.ToString(), out tag))
            {
                return;
            }

            try
            {
                var dataService = ServiceLocator.Current.GetInstance <IDataService>();

                var handNote = dataService.GetHandNote(CurrentHand.GameNumber, CurrentHand.PokersiteId);

                if (handNote == null)
                {
                    handNote = new Handnotes
                    {
                        Gamenumber  = CurrentHand.GameNumber,
                        PokersiteId = CurrentHand.PokersiteId
                    };
                }

                handNote.HandTag = (int)tag;

                dataService.Store(handNote);

                var storageModel = ServiceLocator.Current.GetInstance <SingletonStorageModel>();

                var statistic = storageModel.FindStatistic(x => x.GameNumber == CurrentHand.GameNumber && x.PokersiteId == CurrentHand.PokersiteId);

                if (statistic == null)
                {
                    return;
                }

                statistic.HandNote = handNote;
            }
            catch (Exception e)
            {
                LogProvider.Log.Error(this, $"Could not tag hand #{CurrentHand.GameNumber} for {(EnumPokerSites)CurrentHand.PokersiteId} from replayer.", e);
            }
        }
Example #6
0
        private void TagHand(object sender, RadRoutedEventArgs e)
        {
            var item = sender as RadMenuItem;

            if (item == null)
            {
                return;
            }

            var reportHand = item.DataContext as ReportHandViewModel;

            if (reportHand == null)
            {
                return;
            }

            var handNoteEntity = new Handnotes
            {
                Note        = reportHand.HandNote,
                Gamenumber  = reportHand.GameNumber,
                PokersiteId = (short)reportHand.PokerSiteId,
                HandTag     = (int)(item.Tag ?? 0)
            };

            dataService.Store(handNoteEntity);

            reportHand.HandTag = handNoteEntity.HandTag.HasValue ?
                                 (EnumHandTag)handNoteEntity.HandTag.Value :
                                 EnumHandTag.None;

            var statistic = reportGadgetViewModel.ReportSelectedItem?.Statistics?
                            .FirstOrDefault(x => x.GameNumber == reportHand.GameNumber && x.PokersiteId == reportHand.PokerSiteId);

            if (statistic != null)
            {
                statistic.HandNote = handNoteEntity;
            }

            if (reportGadgetViewModel.FilterTaggedHands_IsChecked)
            {
                reportGadgetViewModel.RefreshReport();
            }
        }
Example #7
0
        private void TagHand(long gameNumber, short pokerSiteId, int tag)
        {
            try
            {
                var dataService = ServiceLocator.Current.GetInstance <IDataService>();

                var handNote = dataService.GetHandNote(gameNumber, pokerSiteId);

                if (handNote == null)
                {
                    handNote = new Handnotes
                    {
                        Gamenumber  = gameNumber,
                        PokersiteId = pokerSiteId
                    };
                }

                handNote.HandTag = tag;

                dataService.Store(handNote);

                var storageModel = ServiceLocator.Current.GetInstance <SingletonStorageModel>();

                var statistic = storageModel.FindStatistic(x => x.GameNumber == gameNumber && x.PokersiteId == pokerSiteId);

                if (statistic == null)
                {
                    HandNoteCacheService.AddHandNote(handNote);
                    return;
                }

                statistic.HandNote = handNote;
            }
            catch (Exception e)
            {
                LogProvider.Log.Error(this, $"Could not tag hand #{gameNumber} for {(EnumPokerSites)pokerSiteId}", e);
            }
        }
        public bool TryGetNote(long gameNumber, int pokerSite, out Handnotes handNote)
        {
            var noteKey = new HandNoteKey(gameNumber, pokerSite);

            return(handNotes.TryRemove(noteKey, out handNote));
        }