using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace CRVM.Utility
{
    public class StringConnectItem
    {
        protected string strSourceConn;
        protected string strDestConn;
        //private EDBItem dbItem;

        /// <summary>
        /// Initializes a new instance of the <see cref="IDBProject"/> class.
        /// </summary>
        /// <param name="projitem">The projitem.</param>
        public StringConnectItem()
        {
        }

        public static string InitialStrConn(EDBItem dbItem)
        {
            if (dbItem != null)
            {
                if (dbItem.DataType.ToLower() == "db2")
                return String.Format("Provider=IBMDADB2;DataBase={0};User ID={1};hostname={2};pwd={3};PROTOCOL=TCPIP;PORT={4}", dbItem.Database, dbItem.Userid, dbItem.Ipaddress, dbItem.Password, 50000);
                else if (dbItem.DataType.ToLower() == "oracle")
                    return String.Format("Data Source={0};Persist Security Info=True;User ID={1};Password={2};Unicode=True", dbItem.Database, dbItem.Userid, dbItem.Password);
                else if (dbItem.DataType.ToLower() == "postgres")
                    return String.Format("Server={0};Port={1}; User Id={2};Password={3};Database={4};Pooling=false;", dbItem.Ipaddress,"5432", dbItem.Userid, dbItem.Password,dbItem.Database);
                else if (dbItem.DataType.ToLower() == "access")
                    return String.Format("Provider=Microsoft.ACE.OLEDB.12.0;Data Source={0};Jet OLEDB:database Password={1}", dbItem.Database, dbItem.Password);
                else
                    return String.Empty;
            }
            else
                return "";
        }


    }


}

