private void dataProvider_OnSecurityChanged(SecurityEventArgs arg)
        {
            Security sec = arg.Security;

            if (sec != null)
            {
                string feedMsg = arg.Message;

                string     fl  = sec.OrgSecurity.FirstOrDefault().ToString();
                DbLogQueue dbQ = FindQueue(fl.ToUpper());
                if (dbQ != null)
                {
                    SecurityDbLog log = new SecurityDbLogAdapter(sec, feedMsg);
                    log.DbManager = dbQ.DbManager;
                    dbQ.Enqueue(log);
                }
                else
                {
                    ProcessException(new ApplicationException(String.Format("{0} senedi için db kuyruğu bulunamadı", sec.OrgSecurity)));
                }



                #region MyRegion
                //if (DistOption.DistributeLimitControl && DistExchangeIDList.Contains(sec.ExchangeID))
                //{
                //    DistStreamQueue.Enqueue(() =>
                //    {
                //        LimitControl lc = new LimitControl();
                //        lc.OrgSecurity = sec.OrgSecurity;
                //        lc.Symbol = sec.Symbol;
                //        lc.SymbolSfx = sec.SymbolSfx;
                //        lc.LastUpdate = sec.LastUpdate;
                //        lc.IsDeleted = sec.IsDeleted;
                //        lc.Last = sec.Last;
                //        lc.IsBist30 = sec.IsBist30;
                //        lc.IsBist50 = sec.IsBist50;
                //        lc.IsBist100 = sec.IsBist100;
                //        lc.ExchangeID = sec.ExchangeID;
                //        //Broadcaster.BroadCastLimitControl(lc);//TODO bunucuda scs ile gonder
                //    });
                //}

                #endregion
                if (DistOption.DistributeSecurity && DistExchangeIDList.Contains(sec.ExchangeID))
                {
                    DistStreamQueue.Enqueue(() =>
                    {
                        BroadcastSecurity(sec);
                    });
                }
            }
        }
        public DbLogQueue FindQueue(string key)
        {
            DbLogQueue dbQ = null;
            string     value;

            if (letterKeys.TryGetValue(key, out value))
            {
                if (DbLogQueueCollection != null)
                {
                    DbLogQueueCollection.TryGetValue(value, out dbQ);
                }
            }
            return(dbQ);
        }
        private void Start()
        {
            try
            {
                StartLogger(logFileNamePrefix);

                DistExchangeIDList.Clear();
                if (string.IsNullOrEmpty(matriksDistExchangeIDList) == false)
                {
                    string[] tmpExchangeIDs = matriksDistExchangeIDList.Split(new string[] { "," }, StringSplitOptions.RemoveEmptyEntries);
                    foreach (var tmpExchangeID in tmpExchangeIDs)
                    {
                        DistExchangeIDList.Add(tmpExchangeID);
                    }
                }


                DbLogQueueCollection = new DbLogQueueCollection();


                letterKeys.Clear();
                List <string> letterValues = new List <string>();

                if (EnableFirstLetterForDbQueue)
                {
                    foreach (var item in strLetters)
                    {
                        letterValues.Add(item.ToString());
                    }
                }
                else
                {
                    letterValues.Add("ABCDEF");
                    letterValues.Add("GHIJKL");
                    letterValues.Add("MNOPRSQ");
                    letterValues.Add("TUVYZXW");
                }

                foreach (var l in strLetters)
                {
                    string key = l.ToString();
                    string value;

                    value = letterValues.FirstOrDefault(f => f.Contains(key));

                    letterKeys.AddOrUpdate(key, value, (k, v) => { return(value); });
                }


                foreach (var l in letterValues)
                {
                    DbLogQueue dbQ = new DbLogQueue();
                    dbQ.Key          = l;//yani ABCDEF
                    dbQ.DbManager    = new DbQueryManager(connString);
                    dbQ.OnDequeue   += DbLogQueue_OnDequeue;
                    dbQ.OnException += DbLogQueue_OnException;
                    DbLogQueueCollection.AddOrUpdate(l, dbQ);
                }

                DbQNews              = new DbNewsQueue();
                DbQNews.DbManager    = new DbQueryManager(connString);
                DbQNews.OnDequeue   += DbNewsQueue_OnDequeue;
                DbQNews.OnException += DbNewsQueue_OnException;


                DistStreamQueue              = new StreamQueue();
                DistStreamQueue.OnDequeue   += DistStreamQueue_OnDequeue;
                DistStreamQueue.OnException += DistStreamQueue_OnException;



                dataProvider = new MatriksTcpDataProvider(matriksStreamServerIP, matriksStreamServerPort);
                dataProvider.OnMaxTimeStampChanged  += DataProvider_OnMaxTimeStampChanged;
                dataProvider.OnSecurityChanged      += dataProvider_OnSecurityChanged;
                dataProvider.OnSecurityDepthChanged += dataProvider_OnSecurityDepthChanged;
                dataProvider.OnBistTimeChanged      += dataProvider_OnBistTimeChanged;
                dataProvider.OnHandleNewsChanged    += dataProvider_OnHandleNewsChanged;
                dataProvider.OnHandleUknownFeed     += DataProvider_OnHandleUknownFeed;
                dataProvider.OnLog       += DataProvider_OnLog;
                dataProvider.OnException += DataProvider_OnException;

                SetSecurities();

                //Broadcaster = new DataBroadcaster(notIP, NotPort);
                //Broadcaster.OnLog += NotSocketServer_OnLog;
                //Broadcaster.OnException += NotSocketServer_OnException;
                //Broadcaster.Start();
                dataProvider.Start();
            }
            catch (Exception ex)
            {
                TBYException tex = new TBYConfigurationException(MethodInfo.GetCurrentMethod().GetFullName(), "Veri yayın başlatılırken hata oluştu", ex);
                ProcessException(tex);
            }
        }