using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Data;
using System.Data.SqlClient;
using System.Configuration;

namespace CUP_POD_Mail_Reader
{
    class FTPServerDbOperations
    {
        //SqlConnection conn = new SqlConnection("Server=172.29.254.182;Database=ECS;User Id=Pondydb;Password=#Pondy#1234");
        SqlConnection conn = new SqlConnection(ConfigurationManager.AppSettings["connectStr"].ToString());
        //ConfigurationManager.AppSettings["connectStr"].ToString()
        public DataTable GetFtpCredentials(string projectid)
        {
            conn.Open();
            SqlCommand cmd = new SqlCommand("select UserName,Password,HostName from FTPCredentials where ProjectCode=@projectcode", conn);
            cmd.Parameters.AddWithValue("@projectcode", projectid);
            SqlDataAdapter da = new SqlDataAdapter(cmd);
            DataSet ds = new DataSet();
            da.Fill(ds);
            conn.Close();
            return ds.Tables[0];
        }
        public DataTable GetFtpDirectory(string projectid)
        {
            conn.Open();
            SqlCommand cmd = new SqlCommand("select * from FTPDirectory where ProjectCode=@projectcode", conn);
            cmd.Parameters.AddWithValue("@projectcode", projectid);
            SqlDataAdapter da = new SqlDataAdapter(cmd);
            DataSet ds = new DataSet();
            da.Fill(ds);
            conn.Close();
            return ds.Tables[0];
        }       
    }
}