public void Initialize(object objParam)
        {
            Log.Debug("init lineprovider");

            eFileSyncResult fsr = LineSr.SyncRoutines(eUpdateType.Initialize, "Adding bet types from configuration", DalStationSettings.Instance.UseDatabaseForLine, null, delegate(object obj)
            {
                BetDomainMap.EnsureInstance();
                return(false);
            });


            ExcpHelper.ThrowIf(fsr == eFileSyncResult.Failed, "Cannot initialize Bet Types");

            string sStationNumber = objParam as string;

            Debug.Assert(!string.IsNullOrEmpty(sStationNumber));

            LiveBetClient.Initialize(sStationNumber);
            VirtualLiveBetClient.Initialize(sStationNumber);
            PreMatchClient.Initialize(sStationNumber);
            StatisticsClient.Initialize(sStationNumber);
            MetainfoClient.Initialize(sStationNumber);
            //TournamentFlagsClient.Initialize(objParam.ToString());

#if ADD_OUTRIGHT_XML
            ImportOutrightExample();
            ImportOutrightExample();
#endif
        }
Example #2
0
        public BetDomainsViewModel()
        {
            PlaceBet = new Command <IOddVw>(OnBet);
            //Mediator.SendMessage<bool>(true, MsgTag.BlockSportFilter);
            //Mediator.SendMessage<bool>(true, MsgTag.BlockTimeFilter);
            Mediator.Register <string>(this, LanguageChosen, MsgTag.LanguageChosenHeader);
            Mediator.Register <string>(this, HeaderShowFirstView, MsgTag.RefreshStation);

            var scroller = this.GetScrollviewer();

            if (scroller != null)
            {
                scroller.ScrollToVerticalOffset(0);
            }

            ScrollChangedCommand = new Command <double>(ScrollChanged);

            if (StationRepository.IsStatisticsEnabled && MatchInfo == null && !ChangeTracker.CurrentMatch.IsLiveBet)
            {
                MatchInfo = new MatchStatistic(ChangeTracker.CurrentMatch.LineObject.BtrMatchId, ChangeTracker.CurrentMatch.TournamentView.LineObject.GroupTournament.BtrTournamentId);
            }

            if (ChangeTracker.CurrentMatch != null)
            {
                ChangeTracker.CurrentMatch.IsStartUp = true;
            }
            LineSr.SubsribeToEvent(DataCopy_DataSqlUpdateSucceeded);
            timer.Elapsed += timer_Tick;
            timer.Start();
            ChangeTracker.IsBetdomainViewOpen = true;
        }
Example #3
0
        public void ParsTournamentMinusMultistringXml()
        {
            ConfigurationManager.AppSettings["CreateDatabase"] = "0";

            string sXmlString = "";

            DatabaseCache.EnsureDatabaseCache();
            BetDomainMap.EnsureInstance();
            using (var reader = new StreamReader("dc.xml"))
            {
                sXmlString = reader.ReadToEnd();
            }
            var srlc            = LineSerializeHelper.StringToObject <SportRadarLineContainer>(sXmlString);
            UpdateStatistics us = new UpdateStatistics();

            var fsr = LineSr.SyncRoutines(eUpdateType.PreMatches, string.Format("SportRadar Pre-Match Update. DataSyncCacheId = {0}", 0), false, us, delegate(object objParam)
            {
                return(ProviderHelper.MergeFromSportRadarLineContainer(srlc, 0));
            });

            Assert.AreEqual(fsr, eFileSyncResult.Succeeded);
            var instance = LineSr.Instance.AllObjects.Groups.Where(x => x.Value.SvrGroupId == 5263).First();

            Assert.AreEqual(8, instance.Value.Strings.Count);
            Assert.AreEqual("Pro A", instance.Value.GetDisplayName("EN"));
        }
        private static void MetaSync(ThreadContext tc)
        {
            while (!tc.IsToStop)
            {

                if (StationRepository.IsPrematchEnabled)
                {
                    try
                    {
                        var stringsUpdateId = UpdateFileEntrySr.GetLastUpdate(eDataSyncCacheType.Metainfo);
                        var id = stringsUpdateId == null ? 0 : stringsUpdateId.DataSyncCacheID;

                        var updateline = WsdlRepository.GetMetainfo(StationRepository.StationNumber, id);
                        if (updateline != null && updateline.Length > 0)
                        {
                            ProviderHelper.UpdateDatabase(DateTime.Now, DalStationSettings.Instance.UseDatabaseForOthers, DataArrayToList(updateline));
                            LineSr.ProcessDataSqlUpdateSucceeded(eUpdateType.PreMatches, "SportRadar Metainfo Pre-Match Update.");
                        }

                        if (updateline != null && updateline.Length > 0)
                            continue;
                    }
                    catch (Exception)
                    {
                    }

                }

                var syncinterval = StationRepository.IsReady ? Convert.ToInt32(ConfigurationManager.AppSettings["METAINFO_SYNC_INTERVAL"]) : 1;

                Thread.Sleep(syncinterval * 1000);
            }
        }
Example #5
0
 public override void Close()
 {
     ChangeTracker.IsForecastOpen = false;
     Mediator.UnregisterRecipientAndIgnoreTags(this);
     Races.Clear();
     LineSr.UnsubscribeFromEnent(DataCopy_DataSqlUpdateSucceeded);
     base.Close();
 }
 public TopTournamentsViewModel()
 {
     LayoutUpdatedCommand = new Command <double>(LayoutUpdated);
     ScrollChangedCommand = new Command <double>(ScrollChanged);
     CheckedBox           = new Command <TournamentVw>(OnCheckedExecute);
     Choice = new Command <TournamentVw>(OnChoiceExecute);
     LineSr.SubsribeToEvent(LineSr_DataSqlUpdateSucceeded);
 }
Example #7
0
 private void DataCopy_DataSqlUpdateSucceeded(eUpdateType eut, string sProviderDescription)
 {
     if (ChangeTracker.CurrentMatch.VisibleBetDomainCount == 0)
     {
         LineSr.UnsubscribeFromEnent(DataCopy_DataSqlUpdateSucceeded);
         Mediator.SendMessage(true, MsgTag.NavigateBack);
         ShowError(TranslationProvider.Translate(MultistringTags.TERMINAL_NO_BETDOMAINS).ToString(), null, true, 3);
     }
 }
        private static void StatisticsSync(ThreadContext tc)
        {
            while (!tc.IsToStop)
            {
                if (StationRepository.IsStatisticsEnabled)
                {
                    //get statistics
                    try
                    {
                        var stringsUpdateId = UpdateFileEntrySr.GetLastUpdate(eDataSyncCacheType.Statistic);
                        var id = stringsUpdateId == null ? 0 : stringsUpdateId.DataSyncCacheID;

                        var updateline = WsdlRepository.UpdateStatistics(StationRepository.StationNumber, id);
                        if (updateline != null && updateline.Length > 0)
                        {
                            ProviderHelper.UpdateDatabase(DateTime.Now, DalStationSettings.Instance.UseDatabaseForOthers, DataArrayToList(updateline));
                        }

                        if (updateline != null && updateline.Length > 0)
                        {
                            continue;
                        }
                    }
                    catch (Exception)
                    {
                    }
                }


                //get flags
                try
                {
                    var resourceUpdateId = UpdateFileEntrySr.GetLastUpdate(eDataSyncCacheType.Resources);
                    var id = resourceUpdateId == null ? 0 : resourceUpdateId.DataSyncCacheID;

                    var updateline = WsdlRepository.UpdateFlags(StationRepository.StationNumber, id);

                    if (updateline != null && updateline.Length > 0)
                    {
                        ProviderHelper.UpdateDatabase(DateTime.Now, DalStationSettings.Instance.UseDatabaseForOthers, DataArrayToList(updateline));
                        LineSr.ProcessDataSqlUpdateSucceeded(eUpdateType.PreMatches, "SportRadar Pre-Match Update.");
                    }
                }
                catch (Exception ex)
                {
                }

                var syncinterval = Convert.ToInt32(ConfigurationManager.AppSettings["STATIONPROPERTY_SYNC_INTERVAL"]);
                if (StationRepository.SyncInterval > 0)
                {
                    syncinterval = StationRepository.SyncInterval;
                }

                Thread.Sleep(syncinterval * 1000);
            }
        }
Example #9
0
 public void EnsureDatabase(bool isTestMode)
 {
     DatabaseManager.EnsureDatabase(isTestMode);
     if (isTestMode)
     {
         CreateTestMatches();
     }
     DatabaseCache.EnsureDatabaseCache();
     LineSr.EnsureFromCache();
 }
Example #10
0
        public override void Close()
        {
            _timer.Stop();
            _timer.Tick -= Timer_Elapsed;

            Mediator.UnregisterRecipientAndIgnoreTags(this);
            Matches.Clear();
            LineSr.UnsubscribeFromEnent(DataCopy_DataSqlUpdateSucceeded);
            base.Close();
        }
 public override void OnNavigationCompleted()
 {
     SelectedTournaments = ChangeTracker.SelectedTournaments;
     Mediator.Register <string>(this, OnLanguageChosenExecute, MsgTag.LanguageChosen);
     Mediator.Register <bool>(this, Refresh, MsgTag.Refresh);
     //Mediator.SendMessage<bool>(false, MsgTag.BlockTimeFilter);
     FillTournaments();
     LineSr.SubsribeToEvent(LineSr_DataSqlUpdateSucceeded);
     ChangeTracker.SelectedSports = true;
     base.OnNavigationCompleted();
 }
Example #12
0
        public MatchesViewModel(params object[] args)
        {
            _ScrollViewerModule = new ScrollViewerModule(Dispatcher);

            BindingOperations.EnableCollectionSynchronization(_matches, _itemsLock);
            BindingOperations.EnableCollectionSynchronization(_sportsBarItemsPreMatch, _itemsLock2);
            OpenMatch         = new Command <IMatchVw>(OnChoiceExecute);
            OpenOutrightMatch = new Command <IMatchVw>(OnOutrightChoiceExecute);

            Mediator.Register <string>(this, OnLanguageChosenExecute, MsgTag.LanguageChosen);
            Mediator.Register <bool>(this, Refresh, MsgTag.Refresh);
            Mediator.Register <string>(this, HeaderShowFirstView, MsgTag.RefreshStation);
            Mediator.Register <bool>(this, ClearSelectedSports, MsgTag.ClearSelectedSports);
            //Mediator.Register<bool>(this, ShowSelectedTournaments, MsgTag.ShowSelectedTournaments);
            PreMatchScrollChangedCommand = new Command(PreMatchScrollChanged);
            PreMatchScrollLoadedCommand  = new Command <System.Windows.Controls.ScrollViewer>(PreMatchScrollLoaded);

            PlaceBet             = new Command <IOddVw>(OnBet);
            ScrollChangedCommand = new Command <double>(ScrollChanged);

            ScrollLeftStart  = new Command(OnScrollLeftStart);
            ScrollRightStart = new Command(OnScrollRightStart);
            CheckedBox       = new Command <SportBarItem>(OnCheckedExecute);

            ElementsVisibility     = Visibility.Collapsed;
            MainElementsVisibility = Visibility.Visible;

            if (args.Length > 0 && args[0] is HashSet <string> )
            {
                SelectedTournaments = args[0] as HashSet <string>;
            }

            if (args.Length > 0 && args[0] is int)
            {
                if ((int)args[0] == 1)
                {
                    MainElementsVisibility = Visibility.Collapsed;
                    ElementsVisibility     = Visibility.Visible;
                }
            }



            var scroller = this.GetScrollviewer();

            if (scroller != null)
            {
                scroller.ScrollToVerticalOffset(0);
            }
            //selected tournaments handling

            LineSr.SubsribeToEvent(LineSr_DataSqlUpdateSucceeded);
        }
Example #13
0
        public HeaderViewModel()
        {
            //FillComboBoxes();



            Mediator.Register <string>(this, OpenLogin, MsgTag.OpenLogin);
            Mediator.Register <string>(this, LanguageChosen, MsgTag.LanguageChosenHeader);
            Mediator.Register <string>(this, ShowFirstViewAndResetFilters, MsgTag.ShowFirstViewAndResetFilters);
            //Mediator.Register<string>(this, ResetFilters, MsgTag.ResetFilters);
            //Mediator.Register<bool>(this, BlockTimeFilter, MsgTag.BlockTimeFilter);
            Mediator.Register <long>(this, LockStation, MsgTag.LockStation);
            Mediator.Register <bool>(this, ShowResultFilter, MsgTag.ShowResultFilters);
            Mediator.Register <bool>(this, ActivateForwardSelected, MsgTag.ActivateForwardSelected);
            Mediator.Register <bool>(this, ActivateShowSelected, MsgTag.ActivateShowSelected);
            Mediator.Register <bool>(this, NavigateBack, MsgTag.NavigateBack);


            IsSportFilterEnabled      = true;
            ShowMenuCommand           = new Command(OnShowMenu);
            OpenPlaceBetCommand       = new Command(OpenPlaceBetWindow);
            OpenAuthorizationCommand  = new Command(OpenAuthorizationWindow);
            OpenUserProfile           = new Command(OpenProfile);
            ShowCashViewCommand       = new Command(ShowCash);
            PrintCreditNoteCommand    = new Command(AskPrintCreditNote);
            InsertCreditNoteCommand   = new Command(InsertCreditNote);
            RestoreTicketCommand      = new Command(RestoreTicket);
            DoSearchCommand           = new Command(DoSearch);
            ShowResultsViewCommand    = new Command(ShowResultsViewModel);
            ShowCategoriesViewCommand = new Command(ShowSports);
            ShowLiveViewCommand       = new Command(ShowLiveView);
            PrevView = new Command(OnPrevViewExecute);
            NextView = new Command(OnNextViewExecute);
            ShowEntertainmentCommand     = new Command(ShowEntertainment);
            ExitTestMode                 = new Command(onExitTestMode);
            _forwardButtonText           = TranslationProvider.Translate(MultistringTags.TERMINAL_NAVIGATION_FORWARD) as string;
            _forwardButtonImagePath      = "BreadcrumbsCenter.png";
            _forwardButtonLeftImagePath  = "BreadcrumbsButtonLeft.png";
            _forwardButtonRightImagePath = "BreadcrumbsRight.png";
            LogoutCommand                = new Command(OnLogoutQuestion);
            OpenAnonymousSessionFromHeader();
            ResultsTimeCommand = new Command <string>(OnResultsTimeCommand);
            LiveModeCommand    = new Command <string>(OnLiveModeCommand);

            TopTournamentsCommand = new Command(OnTopTournamentsCommand);
            LastMinuteCommand     = new Command(OnLastMinuteCommand);
            TodaysOfferCommand    = new Command(OnTodaysOfferCommand);
            AllSportsCommand      = new Command(OnAllSportsCommand);
            IsTimeFilterEnabled   = true;
            InitCashin();

            LineSr.SubsribeToEvent(DataCopy_DataSqlUpdateSucceeded);
        }
Example #14
0
 private void DataCopy_DataSqlUpdateSucceeded(eUpdateType eut, string sProviderDescription)
 {
     if (!StationRepository.IsLiveMatchEnabled)
     {
         LineSr.UnsubscribeFromEnent(DataCopy_DataSqlUpdateSucceeded);
         disabledLive = true;
         Mediator.SendMessage("", MsgTag.ShowFirstViewAndResetFilters);
     }
     if (eut == eUpdateType.LiveBet)
     {
         Update();
     }
 }
        public CategoriesViewModel()
        {
            BindingOperations.EnableCollectionSynchronization(_categories, _itemsLock);

            Choice = new Command <long>(OnChoiceExecute);
            ScrollChangedCommand = new Command <double>(ScrollChanged);
            LayoutUpdatedCommand = new Command <double>(LayoutUpdated);
            Mediator.Register <string>(this, OnLanguageChosenExecute, MsgTag.LanguageChosen);
            Mediator.Register <bool>(this, Refresh, MsgTag.Refresh);
            Mediator.Register <string>(this, HeaderShowFirstView, MsgTag.RefreshStation);

            LineSr.SubsribeToEvent(LineSr_DataSqlUpdateSucceeded);
        }
        public bool MatchFilter(IMatchLn matchLn)
        {
            if (!matchLn.Active.Value)
            {
                return(false);
            }

            if (matchLn.IsLiveBet.Value)
            {
                return(false);
            }

            if (matchLn.MatchView.CategoryView == null)
            {
                return(false);
            }

            if (matchLn.MatchView.VisibleBetDomainCount == 0)
            {
                return(false);
            }

            if (matchLn.MatchView.AllVisibleOddCount == 0)
            {
                return(false);
            }

            if (matchLn.ExpiryDate.Value.LocalDateTime < DateTime.Now)
            {
                return(false);
            }

            if (SelectedCategoryId != 0)
            {
                if (matchLn.MatchView.CategoryView == null || matchLn.MatchView.CategoryView.LineObject.GroupId != SelectedCategoryId)
                {
                    return(false);
                }
            }

            if (matchLn.MatchView.TournamentView != null)
            {
                if (!LineSr.IsTournamentVisible(matchLn.MatchView.TournamentView.LineObject.SvrGroupId.ToString()))
                {
                    return(false);
                }
            }

            return(true);
        }
Example #17
0
        public VFLViewModel()
        {
            NextPageCmd          = new Command(NextPage);
            PreviousPageCmd      = new Command(PrevPage);
            OpenVflPage          = new Command <VFLMatchButton>(OnOpenVflPage);
            OpenMatch            = new Command <IMatchVw>(OnChoiceExecute);
            PlaceBet             = new Command <IOddVw>(OnBet);
            ScrollChangedCommand = new Command <double>(ScrollChanged);

            _timer          = new DispatcherTimer(DispatcherPriority.Background);
            _timer.Interval = new TimeSpan(0, 0, 1);
            _timer.Tick    += Timer_Elapsed;
            _timer.Start();
            LineSr.SubsribeToEvent(DataCopy_DataSqlUpdateSucceeded);
        }
        public override void Close()
        {
            if (ChangeTracker.CurrentMatch != null)
            {
                ChangeTracker.CurrentMatch.IsStartUp = true;

                if (ChangeTracker.CurrentMatch.GoalsTimer != null)
                {
                    ChangeTracker.CurrentMatch.GoalsTimer.Stop();
                }
            }
            LineSr.UnsubscribeFromEnent(DataCopy_DataSqlUpdateSucceeded);
            ChangeTracker.IsBetdomainViewOpen = false;
            base.Close();
        }
Example #19
0
        public void ClearDatabase()
        {
            ConfigurationManager.AppSettings["CreateDatabase"] = "1";
            StationSettingsUtils.m_sStartupPath = Path.GetDirectoryName(Assembly.GetAssembly(typeof(DatabaseTests)).Location);
            DatabaseManager.EnsureDatabase(false);
            DatabaseCache.EnsureDatabaseCache();
            LineSr.EnsureFromCache();

            UpdateFileEntrySr updateFileEntrySr = new UpdateFileEntrySr();

            updateFileEntrySr.DataSyncCacheType = eDataSyncCacheType.Statistic.ToString();

            UpdateFileEntrySr updateFileEntrySr2 = new UpdateFileEntrySr();

            updateFileEntrySr2.DataSyncCacheType = eDataSyncCacheType.Match.ToString();


            updateFileEntrySr.Save();
            updateFileEntrySr2.Save();
            long count;
            var  sql = "select count(" + UpdateFileEntrySr.TableSpec.IdentityNames.First() + ") FROM " + UpdateFileEntrySr.TableSpec.TableName + " where DataSyncCacheType = '" + eDataSyncCacheType.Statistic.ToString() + "'";

            long.TryParse(DataCopy.ExecuteScalar(sql).ToString(), out count);

            Assert.IsTrue(count > 0);


            sql = "select count(" + UpdateFileEntrySr.TableSpec.IdentityNames.First() + ") FROM " + UpdateFileEntrySr.TableSpec.TableName + " where DataSyncCacheType = '" + eDataSyncCacheType.Match.ToString() + "'";
            long.TryParse(DataCopy.ExecuteScalar(sql).ToString(), out count);

            Assert.IsTrue(count > 0);


            DbManager.Instance.DeleteOldObjects();

            sql = "select count(" + UpdateFileEntrySr.TableSpec.IdentityNames.First() + ") FROM " + UpdateFileEntrySr.TableSpec.TableName + " where DataSyncCacheType = '" + eDataSyncCacheType.Statistic.ToString() + "'";

            long.TryParse(DataCopy.ExecuteScalar(sql).ToString(), out count);


            Assert.IsTrue(count > 0);

            sql = "select count(" + UpdateFileEntrySr.TableSpec.IdentityNames.First() + ") FROM " + UpdateFileEntrySr.TableSpec.TableName + " where DataSyncCacheType = '" + eDataSyncCacheType.Match.ToString() + "'";
            long.TryParse(DataCopy.ExecuteScalar(sql).ToString(), out count);
            Assert.AreEqual(0, count);

            DatabaseManager.DropDatabase(false);
        }
        private static void ImportOutrightExample()
        {
            try
            {
                string sXml = TraceHelper.ReadTextFromFile("OutrightExample.xml");

                SportRadarLineContainer srlc = SportRadarLineContainer.FromXmlString(sXml);

                eFileSyncResult fsr = LineSr.SyncRoutines(eUpdateType.PreMatches, string.Format("SportRadar Pre-Match Update. DataSyncCacheId = {0}", 1), true, null, delegate(object objParam)
                {
                    return(ProviderHelper.MergeFromSportRadarLineContainer(srlc, 1));
                });
            }
            catch (Exception excp)
            {
            }
        }
Example #21
0
        public CategoriesViewModel()
        {
            Category._instances.Clear();
            BindingOperations.EnableCollectionSynchronization(_categories, _itemsLock);

            TournamentChoice     = new Command <TournamentVw>(OnTournamentChoiceExecute);
            CountryChoice        = new Command <object>(OnCountryChoiceExecute);
            Choice               = new Command <long>(OnChoiceExecute);
            PlaceBet             = new Command <IOddVw>(OnBet);
            OpenMatch            = new Command <IMatchVw>(OnChoiceExecute);
            ScrollChangedCommand = new Command <double>(ScrollChanged);
            LayoutUpdatedCommand = new Command <double>(LayoutUpdated);
            Mediator.Register <string>(this, OnLanguageChosenExecute, MsgTag.LanguageChosen);
            Mediator.Register <bool>(this, Refresh, MsgTag.Refresh);
            Mediator.Register <string>(this, HeaderShowFirstView, MsgTag.RefreshStation);

            LineSr.SubsribeToEvent(LineSr_DataSqlUpdateSucceeded);
        }
Example #22
0
        private static void RemoveLiveMatches(eServerSourceType linetype) // DK - PreMatches means live that comes from LiveBetServer like Vfl, Vhc etc
        {
            m_logger.Warn("RemoveLiveMatches() been called.");

            LineSr.SyncRoutines(eUpdateType.LiveBet, "Connection lost. SportRadar LiveMarket is cleared.", DalStationSettings.Instance.UseDatabaseForLiveMatches, null, delegate(object obj)
            {
                return(LineSr.Instance.RemoveMatches(delegate(MatchLn match)
                {
                    if (match.SourceType == linetype && match.IsLiveBet.Value)
                    {
                        return true;
                    }

                    //Debug.Assert(false);
                    return false;
                }));
            });
            LineSr.ProcessDataSqlUpdateSucceeded(eUpdateType.LiveBet, "Connection lost. SportRadar LiveMarket is cleared.");
        }
Example #23
0
        public void ParseOutright()
        {
            ConfigurationManager.AppSettings["CreateDatabase"] = "0";

            string sXmlString = "";

            DatabaseCache.EnsureDatabaseCache();
            BetDomainMap.EnsureInstance();
            using (var reader = new StreamReader("groupsLanguages.xml"))
            {
                sXmlString = reader.ReadToEnd();
            }
            var srlc            = LineSerializeHelper.StringToObject <SportRadarLineContainer>(sXmlString);
            UpdateStatistics us = new UpdateStatistics();

            var fsr = LineSr.SyncRoutines(eUpdateType.PreMatches, string.Format("SportRadar Pre-Match Update. DataSyncCacheId = {0}", 0), false, us, delegate(object objParam)
            {
                return(ProviderHelper.MergeFromSportRadarLineContainer(srlc, 0));
            });

            Assert.AreEqual(fsr, eFileSyncResult.Succeeded);

            //matches
            using (var reader = new StreamReader("content.xml"))
            {
                sXmlString = reader.ReadToEnd();
            }
            srlc = LineSerializeHelper.StringToObject <SportRadarLineContainer>(sXmlString);
            us   = new UpdateStatistics();

            fsr = LineSr.SyncRoutines(eUpdateType.PreMatches, string.Format("SportRadar Pre-Match Update. DataSyncCacheId = {0}", 0), false, us, delegate(object objParam)
            {
                return(ProviderHelper.MergeFromSportRadarLineContainer(srlc, 0));
            });

            Assert.AreEqual(fsr, eFileSyncResult.Succeeded);
            var instance = LineSr.Instance.AllObjects.Matches.Where(x => x.Value.MatchId == 1004106).First();

            Assert.AreEqual("RHL - Podium1", instance.Value.GetOutrightDisplayName("EN"));
            Assert.AreEqual("RHL - Podium1", instance.Value.MatchView.Name);
        }
Example #24
0
        public override void OnNavigationCompleted()
        {
            ChangeTracker.SelectedLive          = true;
            ChangeTracker.LiveSelectedAllSports = true;

            if (disabledLive)
            {
                LineSr.SubsribeToEvent(DataCopy_DataSqlUpdateSucceeded);
                disabledLive = false;
            }

            Mediator.SendMessage(true, MsgTag.ActivateForwardSelected);
            Mediator.Register <bool>(this, ChangeOffset, MsgTag.OffsetChanged);
            Mediator.Register <string>(this, HeaderShowFirstView, MsgTag.RefreshStation);
            Mediator.Register <string>(this, OnLanguageChosenExecute, MsgTag.LiveLanguageChosen);
            Mediator.Register <bool>(this, Refresh, MsgTag.Refresh);
            Mediator.Register <bool>(this, ClearSelectedSports, MsgTag.ClearSelectedSports);

            base.OnNavigationCompleted();
            UpdateSorting();

            Dispatcher.Invoke((Action)(() =>
            {
                var window = (Window)GetActiveWindow();
                if (window != null)
                {
                    window.Focus();
                }
            }));
            Mediator.SendMessage <bool>(true, MsgTag.UpdateLiveMonitorTemplates);

            Update();
            //ClearSelectedSports(true);

            //FillSportsBar();

            //CheckSportBarButtons();
        }
Example #25
0
        public VHCViewModel()
        {
            if (ChangeTracker.VhcSelectedType == null)
            {
                ChangeTracker.VhcSelectedType = VHCType.WinPlace;
            }
            _winVisibility      = Visibility.Visible;
            _invertedVisibility = Visibility.Collapsed;

            onWinPlacePressed = new Command(OpenWinPlace);
            onForecastPressed = new Command(OpenForecast);
            onTricastPressed  = new Command(OpenTricast);

            PlaceBet = new Command <IOddVw>(OnBet);

            PreviousPageCmd = new Command(PrevPage);
            NextPageCmd     = new Command(NextPage);

            OpenVHCHelpCommand = new Command(OpenVHCHelp);

            ScrollChangedCommand = new Command <double>(ScrollChanged);
            LineSr.SubsribeToEvent(DataCopy_DataSqlUpdateSucceeded);
        }
Example #26
0
        private static void WorkerThread(ThreadContext tc)
        {
            while (m_bRunning) //(!m_bImportError)
            {
                try
                {
                    int counter         = 0;
                    int iLiveQueueCount = m_sqMessages.Count;

                    if (!m_liveClient.IsAlive)
                    {
                        m_sqMessages.Clear();
                    }
                    else if (iLiveQueueCount > 0)
                    {
                        while (m_sqMessages.Count > 0)
                        {
                            counter++;

                            LineContainer lc = m_sqMessages.Dequeue();

                            eFileSyncResult fsr = eFileSyncResult.Failed;
                            Debug.Assert(lc != null);

                            try
                            {
                                string     sSrcTime  = lc.Attributes["srctime"];
                                DateTimeSr dtSrcTime = DateTimeSr.FromString(sSrcTime);
                                string     sSrcDelay = (DateTime.UtcNow - dtSrcTime.UtcDateTime).ToString();

                                string     sTime = lc.Attributes["time"];
                                DateTimeSr dt    = DateTimeSr.FromString(sTime);
                                TimeSpan   ts    = DateTime.UtcNow - dt.UtcDateTime;

                                string sType = lc.Attributes.ContainsKey("line") ? lc.Attributes["line"] : "none";

                                m_logger.InfoFormat("Queue={0} Delay={1} Size={2}", iLiveQueueCount, ts, lc.OriginalXml.Length);

                                if (ConfigurationManager.AppSettings["betradar_xml_files"] != null)
                                {
                                    SaveXml(lc, "Live");
                                }


                                fsr = LineSr.SyncRoutines(eUpdateType.LiveBet, string.Format("Host='{0}' Connected={1}; SrcDelay={2}; Delay={3}; Line={4}", m_sHost, DateTime.Now - m_dtConnected, sSrcDelay, ts, sType), DalStationSettings.Instance.UseDatabaseForLiveMatches, null, delegate(object objParam)
                                                          { return(ProviderHelperNew.MergeFromLineContainer(lc)); });
                            }
                            catch (Exception excp)
                            {
                                fsr = eFileSyncResult.Failed;
                                m_logger.Excp(excp, "WorkerThread() ERROR for {0}", lc);
                            }


                            if (fsr == eFileSyncResult.Failed)
                            {
                                m_liveClient.Disconnect();
                                RemoveLiveMatches(eServerSourceType.BtrPre);
                                RemoveLiveMatches(eServerSourceType.BtrLive);
                            }
                        }
                        LineSr.ProcessDataSqlUpdateSucceeded(eUpdateType.LiveBet, string.Format("liveUpdate {0} messages", counter));
                    }
                }
                catch (Exception excp)
                {
                    m_logger.Excp(excp, "WorkerThread() general ERROR");
                }

                Thread.Sleep(10);
            }
        }
Example #27
0
        private static void ReaderThread(ThreadContext tc)
        {
            RemoveLiveMatches(eServerSourceType.BtrPre);
            RemoveLiveMatches(eServerSourceType.BtrLive);

            DateTime dtLastReceived = DateTime.Now;

            bool bDisabled       = false;
            bool bRemoved        = false;
            var  lineReseiveCopy = "";

            while (m_bRunning && !tc.IsToStop)
            {
                m_dtConnected = DateTime.Now;

                try
                {
                    string sServerMessage = "";

                    while (m_bRunning && !tc.IsToStop && m_liveClient.IsAlive)
                    {
                        lineReseiveCopy = LinesToReceive;

                        //if (m_liveClient.HaveData)
                        sServerMessage = m_liveClient.ReadLine();
                        ExcpHelper.ThrowIf(string.IsNullOrEmpty(sServerMessage), "Received Empty Message");

                        m_logger.Debug("received live message " + sServerMessage.Length);
                        m_liveClient.WriteLine(lineReseiveCopy);


                        if (sServerMessage == LIVEBET_MSG_HELLO || sServerMessage == LIVEBET_MSG_EMPTY)
                        {
                            m_logger.DebugFormat("Received '{0}'", sServerMessage);
                            dtLastReceived          = DateTime.Now;
                            LineSr.LiveBetConnected = true;
                        }
                        else
                        {
                            try
                            {
                                var originalLength = sServerMessage.Length;
                                if (sServerMessage.StartsWith(COMPRESSED))
                                {
                                    string sPrefix = sServerMessage.Substring(0, COMPRESSED_MASK_SIZE);

                                    string sSize = sPrefix.Substring(COMPRESSED.Length);

                                    int  iCompressedMessageSize = 0;
                                    bool bSizeParsed            = int.TryParse(sSize, out iCompressedMessageSize);
                                    Debug.Assert(bSizeParsed && iCompressedMessageSize > 0);
                                    //Debug.Assert(iCompressedMessageSize + COMPRESSED_MASK_SIZE == sServerMessage.Length);

                                    sServerMessage = TextUtil.DecompressBase64String(sServerMessage.Substring(COMPRESSED_MASK_SIZE));
                                }

                                int startIndex = sServerMessage.IndexOf('<');

                                ExcpHelper.ThrowIf(startIndex < 0, "Cannot find start xml point '<'");
                                sServerMessage = sServerMessage.Substring(startIndex);

                                TimeSpan tsDuration = DateTime.Now - m_dtConnected;

                                LineContainer lc = LineContainer.FromXml(sServerMessage);

                                ExcpHelper.ThrowIf <NullReferenceException>(lc == null, "LineContainer is Null");
                                //lc.Duration = tsDuration;
                                m_sqMessages.Enqueue(lc);

                                int iQueueCount = m_sqMessages.Count;

                                ExcpHelper.ThrowIf(iQueueCount > DalStationSettings.Instance.LiveErrorQueueSize, "Live Client Queue size ({0}) is too big.", iQueueCount);

                                if (iQueueCount > DalStationSettings.Instance.LiveWarnQueueSize)
                                {
                                    m_logger.Warn("Live Client Queue size = " + iQueueCount);
                                }

                                dtLastReceived = DateTime.Now;
                                bDisabled      = false;
                                bRemoved       = false;
                                string sType = lc.Attributes.ContainsKey("line") ? lc.Attributes["line"] : "none";

                                m_logger.DebugFormat("Enqueueing message {0} (Total messages in queue {1}; Connected {2}; Duration {3},type {4},length {5},compressedLength {6})", lc.GetDocId(), m_sqMessages.Count, m_dtConnected, tsDuration, sType, sServerMessage.Length, originalLength);
                            }
                            catch (Exception excp)
                            {
                                m_logger.Warn(ExcpHelper.FormatException(excp, "Could not process incoming server message (Size={0})", sServerMessage.Length));
                                throw;
                            }
                        }

                        LineSr.LiveBetConnected = true;
                        Thread.Sleep(10);
                    }
                }
                catch (Exception excp)
                {
                    m_logger.Error(excp.Message, excp);

                    m_sqMessages.Clear();
                    m_logger.Excp(excp, "Connection to server lost after importing time ({0}) ms bacause of {1}", DateTime.Now - m_dtConnected, excp.GetType());
                    LineSr.LiveBetConnected = false;
                }

                if (dtLastReceived + LIVE_TIME_OUT_TO_DISABLE < DateTime.Now && !bDisabled)
                {
                    LineSr.SyncRoutines(eUpdateType.LiveBet, "Connection lost. SportRadar LiveMarket is disabled.", DalStationSettings.Instance.UseDatabaseForLiveMatches, null, delegate(object obj)
                    {
                        LineSr.Instance.DisableLiveMatches(eServerSourceType.BtrLive);
                        return(false);
                    });


                    LineSr.ProcessDataSqlUpdateSucceeded(eUpdateType.LiveBet, "Connection lost. SportRadar LiveMarket is cleared.");

                    bDisabled = true;
                }
                else if (dtLastReceived + LIVE_TIME_OUT_TO_REMOVE < DateTime.Now && !bRemoved)
                {
                    m_logger.ErrorFormat("Removing all live matches because last message ('{0}') were too long time ago (TimeOut='{1}')", new Exception(), dtLastReceived, LIVE_TIME_OUT_TO_REMOVE);
                    RemoveLiveMatches(eServerSourceType.BtrPre);
                    RemoveLiveMatches(eServerSourceType.BtrLive);
                    bRemoved = true;
                }

                Thread.Sleep(10);

                EnsureConnection();
            }
        }
        public static bool MergeFromLineContainer(LineContainer lc)
        {
            CheckTime ct = new CheckTime(false, "MergeFromLineContainer() entered");

            long lOperationMask = 0L;

            eServerSourceType esst = eServerSourceType.BtrPre;

            if (lc.Attributes.ContainsKey("line"))
            {
                string sLine = lc.Attributes["line"];
                ExcpHelper.ThrowIf(!Enum.TryParse(sLine, true, out esst), "Cannot parse LineType from '{0}'", sLine);
            }

            string sType      = lc.Attributes["type"];
            string sMessageId = lc.Attributes["messageid"];

            try
            {
                /*
                 * sTrace += string.Format("{0} docid={1}\r\n", sTrace, sMessageId);
                 *
                 * if (bExtendTrace)
                 * {
                 *  sTrace += lc.BuildTraceString();
                 * }
                 */

                // TimeTypeLn
                {
                    TimeTypeDictionary ttd = LineSr.Instance.AllObjects.GetLineObjectCollection <TimeTypeLn>() as TimeTypeDictionary;

                    int iCount = LineSr.MergeLineObjects <TimeTypeLn>(lc, ttd, new LineSr.MergeLineObjectsCallBack <TimeTypeLn>()
                    {
                        GetLineObject = delegate(ISerializableObject so)
                        {
                            SerializableProperty <string> spTag = so.GetSerializableProperty("Tag") as SerializableProperty <string>;

                            return(ttd.GetObject(spTag.Value));
                        },
                        CreateLineObject = delegate()
                        {
                            return(new TimeTypeLn());
                        }
                    });

                    ct.AddEvent("TimeType(s) Succeeded ({0})", iCount);
                }

                // ScoreTypeLn
                {
                    ScoreTypeDictionary std = LineSr.Instance.AllObjects.GetLineObjectCollection <ScoreTypeLn>() as ScoreTypeDictionary;

                    int iCount = LineSr.MergeLineObjects <ScoreTypeLn>(lc, std, new LineSr.MergeLineObjectsCallBack <ScoreTypeLn>()
                    {
                        GetLineObject = delegate(ISerializableObject so)
                        {
                            SerializableProperty <string> spTag = so.GetSerializableProperty("Tag") as SerializableProperty <string>;

                            return(std.GetObject(spTag.Value));
                        },
                        CreateLineObject = delegate()
                        {
                            return(new ScoreTypeLn());
                        }
                    });

                    ct.AddEvent("ScoreType(s) Succeeded ({0})", iCount);
                }

                // BetTypeLn
                {
                    BetTypeDictionary btd = LineSr.Instance.AllObjects.GetLineObjectCollection <BetTypeLn>() as BetTypeDictionary;

                    int iCount = LineSr.MergeLineObjects <BetTypeLn>(lc, btd, new LineSr.MergeLineObjectsCallBack <BetTypeLn>()
                    {
                        GetLineObject = delegate(ISerializableObject so)
                        {
                            SerializableProperty <string> spTag = so.GetSerializableProperty("Tag") as SerializableProperty <string>;

                            return(btd.GetObject(spTag.Value));
                        },
                        CreateLineObject = delegate()
                        {
                            return(new BetTypeLn());
                        }
                    });

                    ct.AddEvent("BetType(s) Succeeded ({0})", iCount);
                }

                // BetDomainTypeLn
                {
                    BetDomainTypeDictionary bdtd = LineSr.Instance.AllObjects.GetLineObjectCollection <BetDomainTypeLn>() as BetDomainTypeDictionary;

                    int iCount = LineSr.MergeLineObjects <BetDomainTypeLn>(lc, bdtd, new LineSr.MergeLineObjectsCallBack <BetDomainTypeLn>()
                    {
                        GetLineObject = delegate(ISerializableObject so)
                        {
                            SerializableProperty <string> spTag = so.GetSerializableProperty("Tag") as SerializableProperty <string>;

                            return(bdtd.GetObject(spTag.Value));
                        },
                        CreateLineObject = delegate()
                        {
                            return(new BetDomainTypeLn());
                        }
                    });

                    ct.AddEvent("BetDomainType(s) Succeeded ({0})", iCount);
                }

                // Groups
                {
                    GroupDictionary gd = LineSr.Instance.AllObjects.GetLineObjectCollection <GroupLn>() as GroupDictionary;

                    int iCount = LineSr.MergeLineObjects <GroupLn>(lc, gd, new LineSr.MergeLineObjectsCallBack <GroupLn>()
                    {
                        GetLineObject = delegate(ISerializableObject so)
                        {
                            // 143881406612

                            SerializableProperty <string> spType = so.GetSerializableProperty("Type") as SerializableProperty <string>;
                            SerializableProperty <long> spSvrId  = so.GetSerializableProperty("SvrGroupId") as SerializableProperty <long>;

                            Debug.Assert(spType != null);
                            Debug.Assert(spSvrId != null);

                            return(gd.SafelyGetGroupByKeyName(spType.Value, spSvrId.Value));
                        },
                        CreateLineObject = delegate()
                        {
                            return(new GroupLn());
                        }
                    });

                    ct.AddEvent("Group(s) Succeeded ({0})", iCount);
                }

                // Competitors
                {
                    CompetitorDictionary cd = LineSr.Instance.AllObjects.GetLineObjectCollection <CompetitorLn>() as CompetitorDictionary;

                    int iCount = LineSr.MergeLineObjects <CompetitorLn>(lc, cd, new LineSr.MergeLineObjectsCallBack <CompetitorLn>()
                    {
                        GetLineObject = delegate(ISerializableObject so)
                        {
                            SerializableProperty <long> spCompetitor = so.GetSerializableProperty("CompetitorId") as SerializableProperty <long>;

                            Debug.Assert(spCompetitor != null);

                            return(cd.GetObject(spCompetitor.Value));
                        },
                        CreateLineObject = delegate()
                        {
                            return(new CompetitorLn());
                        }
                    });

                    ct.AddEvent("Competitor(s) Succeeded ({0})", iCount);
                }
                // CompetitorToOutrightLn
                {
                    var cd = LineSr.Instance.AllObjects.GetLineObjectCollection <CompetitorToOutrightLn>() as CompetitorToOutrightDictionary;

                    int iCount = LineSr.MergeLineObjects <CompetitorToOutrightLn>(lc, cd, new LineSr.MergeLineObjectsCallBack <CompetitorToOutrightLn>()
                    {
                        GetLineObject = delegate(ISerializableObject so)
                        {
                            SerializableProperty <long> spCompetitor = so.GetSerializableProperty("match2competitorid") as SerializableProperty <long>;

                            Debug.Assert(spCompetitor != null);

                            return(cd.GetObject(spCompetitor.Value));
                        },
                        CreateLineObject = delegate()
                        {
                            return(new CompetitorToOutrightLn());
                        }
                    });

                    ct.AddEvent("Competitor(s) Succeeded ({0})", iCount);
                }

                // Strings
                {
                    TaggedStringDictionary tsd = LineSr.Instance.AllObjects.GetLineObjectCollection <TaggedStringLn>() as TaggedStringDictionary;
                    int iCount = LineSr.MergeLineObjects <TaggedStringLn>(lc, tsd, new LineSr.MergeLineObjectsCallBack <TaggedStringLn>()
                    {
                        GetLineObject = delegate(ISerializableObject so)
                        {
                            SerializableProperty <long> spStringId = so.GetSerializableProperty("StringId") as SerializableProperty <long>;

                            return(tsd.GetObject(spStringId.Value));
                        },
                        CreateLineObject = delegate()
                        {
                            return(new TaggedStringLn());
                        }
                    });

                    ct.AddEvent("String(s) Succeeded ({0})", iCount);
                }

                SyncList <MatchLn> lMatchesToRemove = new SyncList <MatchLn>();

                // Matches
                {
                    SyncHashSet <long> lMatchIds = new SyncHashSet <long>();

                    MatchDictionary md     = LineSr.Instance.AllObjects.GetLineObjectCollection <MatchLn>() as MatchDictionary;
                    int             iCount = LineSr.MergeLineObjects <MatchLn>(lc, md, new LineSr.MergeLineObjectsCallBack <MatchLn>()
                    {
                        GetLineObject = delegate(ISerializableObject so)
                        {
                            SerializableProperty <long> spMatchId = so.GetSerializableProperty("MatchId") as SerializableProperty <long>;

                            lMatchIds.Add(spMatchId.Value);

                            return(md.GetObject(spMatchId.Value));
                        },
                        CreateLineObject = delegate()
                        {
                            return(new MatchLn());
                        },
                        OnLineObjectMerged = delegate(MatchLn match)
                        {
                            if (match != null)
                            {
                                if (match.Code.Value == 0)
                                {
                                    match.Code.Value = Math.Abs((int)(match.MatchId % 100000));
                                }

                                if (match.EndDate.Value == null)
                                {
                                    match.EndDate.Value = new DateTimeSr(DateTime.MaxValue);
                                }
                            }
                        },
                        RemoveLineObject = delegate(MatchLn match)
                        {
                            lMatchesToRemove.Add(match);
                        }
                    }, ref lOperationMask);

                    if (sType.ToLowerInvariant() == "initial")
                    {
                        SyncList <MatchLn> lAllLiveMatches = LineSr.Instance.QuickSearchMatches(delegate(MatchLn match)
                        {
                            return(match.IsLiveBet.Value && match.SourceType == esst);
                        });

                        foreach (var match in lAllLiveMatches)
                        {
                            if (!lMatchIds.Contains(match.MatchId))
                            {
                                lMatchesToRemove.Add(match);
                            }
                        }
                    }

                    ct.AddEvent("Match(es) Succeeded ({0})", iCount);
                }

                // MatchToGroup items
                {
                    MatchToGroupDictionary mtogd = LineSr.Instance.AllObjects.GetLineObjectCollection <MatchToGroupLn>() as MatchToGroupDictionary;
                    int iCount = LineSr.MergeLineObjects <MatchToGroupLn>(lc, mtogd, new LineSr.MergeLineObjectsCallBack <MatchToGroupLn>()
                    {
                        GetLineObject = delegate(ISerializableObject so)
                        {
                            SerializableProperty <long> spMatchId = so.GetSerializableProperty("MatchId") as SerializableProperty <long>;
                            SerializableProperty <long> spGroupId = so.GetSerializableProperty("GroupId") as SerializableProperty <long>;

                            return(mtogd.GetObject(MatchToGroupLn.GetKeyName(spMatchId.Value, spGroupId.Value)));
                        },
                        CreateLineObject = delegate()
                        {
                            return(new MatchToGroupLn());
                        }
                    });

                    ct.AddEvent("MatchToGroup(s) Succeeded ({0})", iCount);
                }

                // LiveMatchInfo
                {
                    LiveMatchInfoDictionary lmid = LineSr.Instance.AllObjects.GetLineObjectCollection <LiveMatchInfoLn>() as LiveMatchInfoDictionary;
                    int iCount = LineSr.MergeLineObjects <LiveMatchInfoLn>(lc, lmid, new LineSr.MergeLineObjectsCallBack <LiveMatchInfoLn>()
                    {
                        GetLineObject = delegate(ISerializableObject so)
                        {
                            SerializableProperty <long> spMatchId = so.GetSerializableProperty("MatchId") as SerializableProperty <long>;

                            return(lmid.GetObject(spMatchId.Value));
                        },
                        CreateLineObject = delegate()
                        {
                            return(new LiveMatchInfoLn());
                        },
                        OnLineObjectMerged = delegate(LiveMatchInfoLn matchInfo)
                        {
                            if (matchInfo != null)
                            {
                                if (matchInfo.ExpiryDate.Value == null)
                                {
                                    matchInfo.ExpiryDate.Value = new DateTimeSr(DateTime.Now.AddMinutes(30)); // Half an hour
                                }

                                if (matchInfo.ChangedProps.Contains(matchInfo.PeriodInfo))
                                {
                                    lOperationMask |= (long)eOperationMask.MatchPeriodInfoChanged;
                                }
                            }
                        },
                        RemoveLineObject = delegate(LiveMatchInfoLn lmi)
                        {
                        }
                    });

                    ct.AddEvent("LiveMatchInfo(s) Succeeded ({0})", iCount);
                }

                // BetDomainLn
                {
                    BetDomainDictionary bdmd = LineSr.Instance.AllObjects.GetLineObjectCollection <BetDomainLn>() as BetDomainDictionary;
                    int iCount = LineSr.MergeLineObjects <BetDomainLn>(lc, bdmd, new LineSr.MergeLineObjectsCallBack <BetDomainLn>()
                    {
                        GetLineObject = delegate(ISerializableObject so)
                        {
                            SerializableProperty <long> spBetDomainId = so.GetSerializableProperty("BetDomainId") as SerializableProperty <long>;

                            return(bdmd.GetObject(spBetDomainId.Value));
                        },
                        CreateLineObject = delegate()
                        {
                            return(new BetDomainLn());
                        },
                        RemoveLineObject = delegate(BetDomainLn bdmn)
                        {
                            LineSr.Instance.RemoveBetDomain(bdmn);
                        }
                    }, ref lOperationMask);

                    ct.AddEvent("BetDomain(s) Succeeded ({0})", iCount);
                }

                // OddLn
                {
                    OddDictionary oddd   = LineSr.Instance.AllObjects.GetLineObjectCollection <OddLn>() as OddDictionary;
                    int           iCount = LineSr.MergeLineObjects <OddLn>(lc, oddd, new LineSr.MergeLineObjectsCallBack <OddLn>()
                    {
                        GetLineObject = delegate(ISerializableObject so)
                        {
                            SerializableProperty <long> spOutcomeId = so.GetSerializableProperty("OutcomeId") as SerializableProperty <long>;

                            return(oddd.GetObject(spOutcomeId.Value));
                        },
                        CreateLineObject = delegate()
                        {
                            return(new OddLn());
                        },
                        RemoveLineObject = delegate(OddLn odd)
                        {
                            odd.Active.Value = false;
                            //LineSr.Instance.RemoveOdd(odd);
                        }
                    });

                    ct.AddEvent("Odd(s) Succeeded ({0})", iCount);
                }

                // Process Removed matches
                foreach (var match in lMatchesToRemove)
                {
                    LiveMatchInfoLn lmi = match.LiveMatchInfo;

                    if (lmi.Status.Value == eMatchStatus.Ended && match.SourceType == eServerSourceType.BtrLive)
                    {
                        MergeMatchResult(match);
                    }

                    LineSr.Instance.RemoveMatch(match);
                }
            }
            catch (Exception excp)
            {
                ct.AddEvent("ERROR");
                m_logger.Error(excp.Message, excp);
                m_logger.Excp(excp, "MergeFromLigaStavok() ERROR");
                throw;
            }
            finally
            {
                //m_logger.Info(sTrace);
                //m_logger.DebugFormat("LineContainer Trace Length = {0}", sTrace.Length);
                ct.AddEvent("MergeFromLigaStavok(Type={0}, MessageId={1}) completed", sType, sMessageId);
                ct.Info(m_logger);
            }

#if DEBUG
            if ((lOperationMask & EVENT_REASON_MASK) > 0)
            {
                m_logger.InfoFormat("MergeFromLineContainer() result {0}", lOperationMask);
            }
#endif

            return(true);
        }
Example #29
0
        private static void PreMatchSync(ThreadContext tc)
        {
            try
            {
                var arrUpdateRecords = WsdlRepository.GetLatestConfidenceFactorsUpdate(StationNumber);

                ProviderHelper.UpdateDatabase(DateTime.Now, DalStationSettings.Instance.UseDatabaseForOthers, DataArrayToList(arrUpdateRecords));
            }
            catch (Exception e)
            {
            }

            while (!tc.IsToStop)
            {
                int?iTotal = 0;

                try
                {
                    if (true)
                    {
                        /*
                         * using (StreamReader streamReader = new StreamReader(@"C:\Library\Data.xml", Encoding.UTF8))
                         * {
                         *  string sXml = streamReader.ReadToEnd();
                         *
                         *  SportRadarLineContainer srlc = SportRadarLineContainer.FromXmlString(sXml);
                         *
                         *  LineSr.SyncRoutines(eUpdateType.PreMatches, "Test", "None", null, delegate(object obj)
                         *  {
                         *      ProviderHelper.MergeFromSportRadarLineContainer(srlc);
                         *  });
                         * }
                         */

                        while (!StationRepository.IsReady)
                        {
                            Thread.Sleep(1000);
                        }

                        valueForm vf = null;
                        BsmHubConfigurationResponse bhcr = null;

                        string sStationNumber = StationNumber;

                        var            stringsUpdateId = UpdateFileEntrySr.GetLastUpdate(eDataSyncCacheType.String);
                        var            id = stringsUpdateId == null ? 0 : stringsUpdateId.DataSyncCacheID;
                        UpdateRecord[] arrUpdateRecords = WsdlRepository.UpdateLocalization(sStationNumber, id);
                        ProviderHelper.UpdateDatabase(DateTime.Now, DalStationSettings.Instance.UseDatabaseForOthers, DataArrayToList(arrUpdateRecords));
                        if (arrUpdateRecords != null && arrUpdateRecords.Length > 0)
                        {
                            DataCopy.UpdateLanguages();
                        }
                        // Lock Offer
                        long[] arrLockedTournamentIds = null;
                        long[] arrLockedOddIds        = WsdlRepository.GetLockedOffer(sStationNumber, out arrLockedTournamentIds);

                        // Sync Locked Odds
                        LineSr.Instance.LockedObjects.SyncLockedOdds(arrLockedOddIds);
                        int counter = 0;
                        do
                        {
                            var lastUpdateId = UpdateFileEntrySr.GetLastUpdate(eDataSyncCacheType.Match);
                            id = lastUpdateId == null ? 0 : lastUpdateId.DataSyncCacheID;
                            arrUpdateRecords = WsdlRepository.UpdateLine(sStationNumber, id, DateTime.MinValue, out iTotal);

                            if (iTotal > 0 && arrUpdateRecords != null)
                            {
                                iTotal = iTotal + arrUpdateRecords.Length;
                            }
                            DataCopy.UpdateProgressBar(iTotal);

                            ProviderHelper.UpdateDatabase(DateTime.Now, DalStationSettings.Instance.UseDatabaseForPreMatches, DataArrayToList(arrUpdateRecords));
                            LineSr.ProcessDataSqlUpdateSucceeded(eUpdateType.PreMatches, "SportRadar Pre-Match Update.");
                        } while (iTotal > 0 && counter++ < 100);

                        /*
                         * // Sync Locked Groups
                         * SyncList<long> lLockedGroupIds = new SyncList<long>();
                         *
                         * // Tournament IDs to Group IDs
                         * foreach (long lTournamentId in arrLockedTournamentIds)
                         * {
                         *  GroupLn group = LineSr.Instance.AllObjects.Groups.SafelyGetGroupByKeyName(GroupLn.GROUP_TYPE_GROUP_T, lTournamentId);
                         *
                         *  if (group != null)
                         *  {
                         *      lLockedGroupIds.SafelyAdd(group.GroupId);
                         *  }
                         * }
                         *
                         * LineSr.Instance.LockedObjects.SyncLockedGroups(lLockedGroupIds);
                         */
                    }
                }
                catch (Exception excp)
                {
                }
                var syncinterval = Convert.ToInt32(ConfigurationManager.AppSettings["STATIONPROPERTY_SYNC_INTERVAL"]);
                if (StationRepository.SyncInterval > 0)
                {
                    syncinterval = StationRepository.SyncInterval;
                }
                if (iTotal > 0)
                {
                    syncinterval = 0;
                }
                Thread.Sleep(syncinterval * 1000);
            }
        }
        public override void Close()
        {
            LineSr.UnsubscribeFromEnent(LineSr_DataSqlUpdateSucceeded);

            base.Close();
        }