예제 #1
0
        /// <summary>
        /// 
        /// </summary>
        /// <returns></returns>
        internal List<Business.Security> GetAllSecurity()
        {
            List<Business.Security> Result = new List<Business.Security>();
            System.Data.SqlClient.SqlConnection conn = new System.Data.SqlClient.SqlConnection(DBConnection.DBConnection.Connection);
            DSTableAdapters.SecurityTableAdapter adap = new DSTableAdapters.SecurityTableAdapter();
            DSTableAdapters.SecurityConfigTableAdapter adapSecurityConfig = new DSTableAdapters.SecurityConfigTableAdapter();

            DSTableAdapters.SymbolTableAdapter adapSymbol = new DSTableAdapters.SymbolTableAdapter();
            DSTableAdapters.TradingConfigTableAdapter adapTradingConfig = new DSTableAdapters.TradingConfigTableAdapter();

            DS.SymbolDataTable tbSymbol = new DS.SymbolDataTable();
            DS.TradingConfigDataTable tbTradingConfig = new DS.TradingConfigDataTable();
            DS.SecurityDataTable tbSecurity = new DS.SecurityDataTable();
            DS.SecurityConfigDataTable tbSecurityConfig = new DS.SecurityConfigDataTable();

            try
            {
                conn.Open();
                adap.Connection = conn;
                adapSecurityConfig.Connection = conn;
                adapSymbol.Connection = conn;
                adapTradingConfig.Connection = conn;

                tbSecurity = adap.GetData();

                if (tbSecurity != null)
                {
                    int count = tbSecurity.Count;
                    for (int i = 0; i < count; i++)
                    {
                        Business.Security newSecurity = new Business.Security();
                        newSecurity.ParameterItems = new List<Business.ParameterItem>();
                        newSecurity.SymbolGroup = new List<Business.Symbol>();

                        newSecurity.SecurityID = tbSecurity[i].SecurityID;
                        newSecurity.Name = tbSecurity[i].Name;
                        newSecurity.Description = tbSecurity[i].Description;
                        newSecurity.MarketAreaID = tbSecurity[i].MarketAreaID;

                        #region GET SECURITY CONFIG BY SECURITY ID
                        //GET SECURITY CONFIG BY SECURITY ID
                        tbSecurityConfig = adapSecurityConfig.GetSecurityConfigBySecurityID(newSecurity.SecurityID);

                        if (tbSecurityConfig != null)
                        {
                            int countSecurityConfig = tbSecurityConfig.Count;
                            for (int j = 0; j < countSecurityConfig; j++)
                            {
                                Business.ParameterItem newParameterItem = new Business.ParameterItem();
                                newParameterItem.ParameterItemID = tbSecurityConfig[j].SecurityConfigID;
                                newParameterItem.SecondParameterID = tbSecurityConfig[j].SecurityID;
                                newParameterItem.Name = tbSecurityConfig[j].Name;
                                newParameterItem.Code = tbSecurityConfig[j].Code;
                                newParameterItem.NumValue = tbSecurityConfig[j].NumValue;
                                newParameterItem.StringValue = tbSecurityConfig[j].StringValue;
                                newParameterItem.DateValue = tbSecurityConfig[j].DateValue;
                                newParameterItem.BoolValue = tbSecurityConfig[j].BoolValue;

                                Result[i].ParameterItems.Add(newParameterItem);
                            }
                        }
                        #endregion

                        #region GET SYMBOL BY SECURITY ID
                        tbSymbol = adapSymbol.GetSymbolBySecurityID(newSecurity.SecurityID);
                        if (tbSymbol != null)
                        {
                            int countSymbol = tbSymbol.Count;
                            for (int j = 0; j < countSymbol; j++)
                            {
                                Business.Symbol newSymbol = new Business.Symbol();
                                newSymbol.ParameterItems = new List<Business.ParameterItem>();

                                if (Business.Market.MarketArea != null)
                                {
                                    int countMarket = Business.Market.MarketArea.Count;
                                    for (int n = 0; n < countMarket; n++)
                                    {
                                        if (Business.Market.MarketArea[n].IMarketAreaID == tbSymbol[j].MarketAreaID)
                                        {
                                            newSymbol.MarketAreaRef = Business.Market.MarketArea[n];
                                            break;
                                        }
                                    }
                                }

                                newSymbol.Name = tbSymbol[j].Name;
                                newSymbol.SecurityID = tbSymbol[j].SecurityID;
                                newSymbol.SymbolID = tbSymbol[j].SymbolID;

                                tbTradingConfig = adapTradingConfig.GetTradingConfigBySymbolID(tbSymbol[j].SymbolID);
                                if (tbTradingConfig != null)
                                {
                                    int countTradingConfig = tbTradingConfig.Count;
                                    for (int n = 0; n < countTradingConfig; n++)
                                    {
                                        Business.ParameterItem newParameter = new Business.ParameterItem();
                                        newParameter.BoolValue = tbTradingConfig[n].BoolValue;
                                        newParameter.Code = tbTradingConfig[n].Code;
                                        newParameter.DateValue = tbTradingConfig[n].DateValue;
                                        newParameter.NumValue = tbTradingConfig[n].NumValue;
                                        newParameter.ParameterItemID = tbTradingConfig[n].TradingConfigID;
                                        newParameter.SecondParameterID = tbTradingConfig[n].SymbolID;

                                        newSymbol.ParameterItems.Add(newParameter);
                                    }
                                }

                                newSecurity.SymbolGroup.Add(newSymbol);
                            }
                        }
                        #endregion

                        Result.Add(newSecurity);
                    }
                }
            }
            catch (Exception ex)
            {
                return null;
            }
            finally
            {
                adap.Connection.Close();
                adapSecurityConfig.Connection.Close();
                adapSymbol.Connection.Close();
                adapTradingConfig.Connection.Close();
                conn.Close();
            }

            return Result;
        }
예제 #2
0
        /// <summary>
        /// 
        /// </summary>
        /// <param name="SecurityID"></param>
        /// <returns></returns>
        internal List<Business.Symbol> GetSymbolBySecurityID(int SecurityID)
        {
            List<Business.Symbol> Result = new List<Business.Symbol>();
            System.Data.SqlClient.SqlConnection conn = new System.Data.SqlClient.SqlConnection(DBConnection.DBConnection.Connection);
            DSTableAdapters.SymbolTableAdapter adap = new DSTableAdapters.SymbolTableAdapter();
            DSTableAdapters.TradingConfigTableAdapter adapTradingConfig = new DSTableAdapters.TradingConfigTableAdapter();
            DS.SymbolDataTable tbSymbol = new DS.SymbolDataTable();
            DS.TradingConfigDataTable tbTradingConfig = new DS.TradingConfigDataTable();

            try
            {
                conn.Open();
                adap.Connection = conn;
                adapTradingConfig.Connection = conn;

                tbSymbol= adap.GetSymbolBySecurityID(SecurityID);

                if (tbSymbol != null)
                {
                    int count = tbSymbol.Count;
                    for (int i = 0; i < count; i++)
                    {
                        Business.Symbol newSymbol = new Business.Symbol();
                        if (Business.Market.MarketArea != null)
                        {
                            int countMarket = Business.Market.MarketArea.Count;
                            for (int j = 0; j < countMarket; j++)
                            {
                                if (Business.Market.MarketArea[j].IMarketAreaID == tbSymbol[i].MarketAreaID)
                                {
                                    newSymbol.MarketAreaRef = Business.Market.MarketArea[j];
                                    break;
                                }
                            }
                        }

                        newSymbol.Name = tbSymbol[i].Name;
                        newSymbol.SecurityID = tbSymbol[i].SecurityID;
                        newSymbol.SymbolID = tbSymbol[i].SymbolID;
                        newSymbol.RefSymbol = this.GetSymbolByRefSymbolID(tbSymbol[i].SymbolID);

                        tbTradingConfig = adapTradingConfig.GetTradingConfigBySymbolID(tbSymbol[i].SymbolID);
                        if (tbTradingConfig != null)
                        {
                            int countTradingConfig = tbTradingConfig.Count;
                            for (int j = 0; j < countTradingConfig; j++)
                            {
                                Business.ParameterItem newParameter = new Business.ParameterItem();
                                newParameter.BoolValue = tbTradingConfig[j].BoolValue;
                                newParameter.Code = tbTradingConfig[j].Code;
                                newParameter.DateValue = tbTradingConfig[j].DateValue;
                                newParameter.NumValue = tbTradingConfig[j].NumValue;
                                newParameter.ParameterItemID = tbTradingConfig[j].TradingConfigID;
                                newParameter.SecondParameterID = tbTradingConfig[j].SymbolID;

                                if (newSymbol.ParameterItems == null)
                                    newSymbol.ParameterItems = new List<Business.ParameterItem>();

                                newSymbol.ParameterItems.Add(newParameter);
                            }
                        }

                        //newSymbol.ParameterItems = DBWSymbol.TradingConfigInstance.GetParameterItemBySymbolID(tbSymbol[i].SymbolID);

                        Result.Add(newSymbol);
                    }
                }
            }
            catch (Exception ex)
            {
                return null;
            }
            finally
            {
                adap.Connection.Close();
                adapTradingConfig.Connection.Close();
                conn.Close();
            }

            return Result;
        }