Example #1
0
        public static TStrategy GetTStrategy(string id, NLog log)
        {
            TStrategy t = new TStrategy();

            try
            {
                using (SqlConnection connection = new SqlConnection(ConnectionString))
                {
                    SqlCommand command = new SqlCommand(string.Format("SELECT * FROM Strategy WHERE Id={0}", id), connection);
                    command.Connection.Open();
                    SqlDataReader reader = command.ExecuteReader();
                    while (reader.Read())
                    {
                        t.Id = (int)reader["Id"];
                        t.Name = (string)reader["Name"];
                        t.GMID = (string)reader["GMID"];
                        t.RiskMClass = (string)reader["RiskMClass"];
                        t.PoolId = (int)reader["PoolId"];
                        t.Args = (string)reader["Args"];
                        t.MDMode = (int)reader["MDMode"];
                    }
                    command.Connection.Close();
                }

                using (SqlConnection connection = new SqlConnection(ConnectionString))
                {
                    SqlCommand command = new SqlCommand("SELECT * FROM Login", connection);
                    command.Connection.Open();
                    SqlDataReader reader = command.ExecuteReader();
                    while (reader.Read())
                    {
                        t.UserName = (string)reader["UserName"];
                        t.Password = (string)reader["Password"];
                    }
                    command.Connection.Close();
                }

                t.Instruments = GetTInstruments(t.PoolId);
                t.Positions = GetTPositions(t.Id);
            }
            catch 
            {
                log.WriteError("Read TStrategies");
            }

            return t;
        }