﻿using dg.interfaces;
using dg.interfaces.Providers;
using dg.objects;
using System;
using System.Collections.Generic;
using System.Data.SqlClient;

namespace dg.mssql.Providers
{
    public class DataProvider : IValueProvider
    {
        private const string selectCommandText = @"SELECT * 
            FROM {0}.{1}";

        private readonly ICache cache;
        private readonly string chunkSize;
        private readonly IDictionary<string, string> settings;
        private readonly string sourceColumn;
        private readonly string sourceConnectionString;
        private readonly string sourceSchema;
        private readonly string sourceTable;

        public DataProvider(ICache cache, IDictionary<string, string> settings)
        {
            this.cache = cache;
            this.sourceConnectionString = settings[Keys.SourceConnectionString];
            this.sourceTable = settings[Keys.SourceTable];
            this.sourceColumn = settings[Keys.SourceColumn];
            this.sourceSchema = settings[Keys.SourceSchema];
            this.chunkSize = settings[Keys.ChunkSize];
            this.settings = settings;
        }

        public IEnumerable<object[]> GetAll()
        {
            throw new NotImplementedException();
            //    using (var conn = new SqlConnection(sourceConnectionString))
            //    using (var cmd = conn.CreateCommand())
            //    {
            //        conn.Open();
            //        cmd.CommandText = string.Format(selectCommandText, sourceSchema, sourceTable);
            //        using (var reader = cmd.ExecuteReader())
            //        {
            //            if (reader.Read())
            //            {
            //                reader.GetValues()
            //                learerLabel.Text = reader.GetString(reader.GetOrdinal("somecolumn"))
            //            }
            //        }
            //    }
        }

        private void LoadData()
        {
        }
    }
}