protected override void BeginProcessing()
        {
            //Create mappings from database to sharepoint fields
            ISharePointUploader uploader = new SharePointUploader(Session.DomainUserName, Session.DomainPassword, Session.BaseSharePointUrl);

            var mappings = Session.Mappings;

            Session.ErroredFiles = new Dictionary<string, string>();
            Session.SkippedFiles = new List<string>();

            //Get database data (collection of DBRecords)
            var sql = Session.SelectStatement;
            var sm = new SQLManager(Session.DBConnectionString);
            var records = sm.GetData(sql, Session.FileNameField).ToSPDataRecords(mappings);

            var filenameList = Directory.EnumerateFiles(Session.LocalFolder).Select(p=>Path.GetFileName(p)).ToList<string>();
            bool recordFoundFlag = false;
            //Uploader functionality
            foreach (var filename in filenameList)
            {

                if(IsRecordAvailable(records, filename)) {
                    var record = records.Single(p => p.FileName.Equals(filename, StringComparison.InvariantCultureIgnoreCase));

                    //handle the uploading
                    Console.WriteLine(string.Format("Uploading File {0} at {1} - {2}", filename, DateTime.Now, "with Metadata"));
                    try
                    {
                        uploader.UploadFile(Session.LocalFolder, record, Session.LibraryTitle, Session.ContentType, Session.OverwriteIfExists);
                        MoveToUploaded(Session.LocalFolder, filename);
                    }
                    catch (Exception ex)
                    {
                        HandleError(ex.Message, filename);
                    }

                }
                else
                {
                    Session.ErroredFiles.Add(filename, "No Metadata found");
                    //Console.WriteLine(string.Format("Uploading File {0} at {1} - {2}", filename, DateTime.Now, "NO Metadata found."));
                    //try
                    //{
                    //    uploader.UploadFile(Session.LocalFolder, filename, Session.LibraryTitle, Session.ContentType);
                    //}
                    //catch (Exception ex2)
                    //{
                    //    HandleError(ex2.Message, filename);
                    //}
                }
            }

            WriteObject(Session);
            base.BeginProcessing();
        }
        public void UploadIntegrationTest1()
        {
            //Create mappings from database to sharepoint fields
            //ISharePointUploader uploader = new SharePointUploader(_testUserId, _testPassword, _testBaseUrl);
            SPUploadSession session = new SPUploadSession()
            {
                BaseSharePointUrl=_testBaseUrl,
                ContentType=_contentType,
                DBConnectionString = _connection,
                DomainUserName = _testUserId,
                DomainPassword=_testPassword,
                ErroredFiles = new Dictionary<string,string>(),
                FileNameField = "file_name",
                LibraryTitle = _testLibrary,
                LocalFolder = _localFolder,
                SelectStatement =    _sql,
                SkippedFiles = new List<string>()
            };

            var mappings = new SPColumnMappings("file_name");
            mappings.AddMapping("Application Title", "Title", "Text");
            mappings.AddMapping("Application Number", "Application Number", "Text");
            mappings.AddMapping("Application Title", "Application Title", "Text");
            mappings.AddMapping("Site Number", "Site Number", "Text");
            mappings.AddMapping("Plant Number", "Plant Number", "Numeric");
            mappings.AddMapping("Facility Name", "Facility Name", "Text");
            mappings.AddMapping("Engineer", "Engineer", "Text");
            mappings.AddMapping("PA Status", "PA Status", "Taxonomy");
            mappings.AddMapping("Status Date", "Status Date", "Date");

            //Create mappings from database to sharepoint fields
            ISharePointUploader uploader = new SharePointUploader(session.DomainUserName, session.DomainPassword, session.BaseSharePointUrl);

            //Get database data (collection of DBRecords)
            var sql = session.SelectStatement;
            var sm = new SQLManager(session.DBConnectionString);
            var records = sm.GetData(sql, session.FileNameField).ToSPDataRecords(mappings);

            //Uploader functionality
            //foreach (SPDataRecord record in records)
            //{
            //    try
            //    {
            //        Console.WriteLine(string.Format("Uploading File {0} at {1}", record.FileName, DateTime.Now));
            //        uploader.UploadFile(session.LocalFolder, record, session.LibraryTitle, session.ContentType, session.OverwriteIfExists);
            //    }
            //    catch (Exception ex)
            //    {
            //        session.ErroredFiles.Add(record.FileName, ex.Message);
            //        Console.WriteLine(string.Format("Could not upload {0} : Error {1}", record.FileName, ex.Message));
            //    }
            //}
        }
        public void GetDataTest()
        {
            //arrange
            using (var dm = new SQLManager(_connection))
            {
                //act
                var items = dm.GetData("select * from GeneralLedger", "file_name");

                //assert
                Assert.AreEqual(items.Count, 5);
            }
        }
        public void CreateManagerTest()
        {
            //arrange
            using (var dm = new SQLManager(_connection))
            {
                //act
                var items = dm.GetColumnNames("select * from GeneralLedger", "file_name");

                //assert
                Assert.AreEqual(items.Count, 4);
            }
        }