示例#1
0
        /// <summary>
        /// Reads in connection information via a sql script.
        /// </summary>
        /// <param name="args"></param>
        /// <returns></returns>
        public static ConnectionInfo LoadFromDataBase(string[] args, ConnectionInfo conn)
        {
            string query = "";

            if (conn.PrivateKey == null)
            {
                conn.PrivateKey = new PrivateKey();
            }

            logger.Log("Reading SQL script");
            using (StreamReader sr = new StreamReader(GetParameter(args, "SQLScript")))
            {
                while (!sr.EndOfStream)
                {
                    query += sr.ReadLine();
                }
            }
            logger.Log("SQL scrip successfully read in");
            using (SqlConnection con = new SqlConnection(GetParameter(args, "Connection_String")))
            {
                logger.Log("Attempting to connect to database");
                SqlCommand command = new SqlCommand(query, con);
                con.Open();
                logger.Log("Connection established");

                using (SqlDataReader reader = command.ExecuteReader())
                {
                    while (reader.Read())
                    {
                        for (int i = 0; i < reader.FieldCount; i++)
                        {
                            string colName  = reader.GetName(i);
                            string colValue = reader[colName].ToString();
                            conn = LoadParameters(conn, colName, colValue);
                        }
                    }
                }
            }

            if (conn.PrivateKey.KeyPassword.Length > 0 && conn.PrivateKey.KeyPath.Length > 0)
            {
                conn.PrivateKey.IsUsed = true;
            }
            else
            {
                conn.PrivateKey.IsUsed = false;
            }

            return(conn);
        }
示例#2
0
        /// <summary>
        /// Retrieves a list of files from the local path
        /// </summary>
        /// <returns></returns>
        public List <string> GetFiles(string path, string searchPattern = "*")
        {
            logger.Log("Reteiving local file list from '" + path + "' directory, using the following search pattern: " + searchPattern);

            List <string> files = Directory.GetFiles(path, searchPattern).ToList();

            logger.Log(files.Count + " files found:");
            logger.LogEnumarable(files);

            return(files);
        }