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
        }
        public void Stop(eLineType elt)
        {
            if (((int)elt & (int)eLineType.PreMatches) > 0)
            {
                PreMatchClient.Stop();
            }

            if (((int)elt & (int)eLineType.LiveMatches) > 0)
            {
                LiveBetClient.Stop();
                VirtualLiveBetClient.Stop();
            }
        }
        public void Run(eLineType elt)
        {
            Log.Debug("run line clients");

            if (((int)elt & (int)eLineType.PreMatches) > 0)
            {
                PreMatchClient.Run();
                StatisticsClient.Run();
                MetainfoClient.Run();
                //TournamentFlagsClient.Run();
            }

            if (((int)elt & (int)eLineType.LiveMatches) > 0)
            {
                LiveBetClient.Run();
                VirtualLiveBetClient.Run();
            }

            LineCleaner.Run();
        }
        private static void WorkerThread(ThreadContext tc)
        {
            while (m_bRunning) //(!m_bImportError)
            {
                try
                {
                    int iLiveQueueCount = m_sqMessages.Count;

                    int counter = 0;
                    if (!m_liveClient.IsAlive)
                    {
                        m_sqMessages.Clear();
                    }
                    else if (iLiveQueueCount > 0)
                    {
                        while (m_sqMessages.Count > 0)
                        {
                            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";
                                //if (lc.Attributes.ContainsKey("type") && lc.Attributes["type"] == "initial" && sType == eServerSourceType.BtrPre.ToString())
                                //    RemoveLiveMatches(eServerSourceType.BtrPre);
                                //if (lc.Attributes.ContainsKey("type") && lc.Attributes["type"] == "initial" && sType == eServerSourceType.BtrLive.ToString())
                                //    RemoveLiveMatches(eServerSourceType.BtrLive);
                                //if (lc.Attributes.ContainsKey("type") && lc.Attributes["type"] == "initial" && sType == eServerSourceType.BtrVfl.ToString())
                                //    RemoveLiveMatches(eServerSourceType.BtrVfl);
                                //if (lc.Attributes.ContainsKey("type") && lc.Attributes["type"] == "initial" && sType == eServerSourceType.BtrVhc.ToString())
                                //    RemoveLiveMatches(eServerSourceType.BtrVhc);

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

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


                                fsr = LineSr.SyncRoutines(eUpdateType.VirtualBet, 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.BtrVfl);
                                RemoveLiveMatches(eServerSourceType.BtrVhc);
                            }
                        }
                        LineSr.ProcessDataSqlUpdateSucceeded(eUpdateType.VirtualBet, string.Format("virtualUpdate {0} messages", counter));
                    }
                }
                catch (Exception excp)
                {
                    m_logger.Excp(excp, "WorkerThread() general ERROR");
                }

                Thread.Sleep(10);
            }
        }