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));
            //    }
            //}
        }
        protected override void BeginProcessing()
        {
            var session = new SPUploadSession()
            {
                BaseSharePointUrl  = BaseSharePointUrl,
                DBConnectionString = DBConnectionString,
                DomainPassword     = DomainPassword,
                DomainUserName     = DomainUserName,
                LibraryTitle       = LibraryTitle,
                LocalFolder        = LocalFolder,
                SelectStatement    = SelectStatement,
                FileNameField      = FileNameField,
                ContentType        = ContentType,
                OverwriteIfExists  = OverwriteIfExists
            };

            WriteObject(session);
            base.BeginProcessing();
        }
Exemplo n.º 3
0
 protected override void BeginProcessing()
 {
     var session = new SPUploadSession()
     {
         BaseSharePointUrl = BaseSharePointUrl,
         DBConnectionString = DBConnectionString,
         DomainPassword = DomainPassword,
         DomainUserName = DomainUserName,
         LibraryTitle = LibraryTitle,
         LocalFolder = LocalFolder,
         SelectStatement = SelectStatement,
         FileNameField = FileNameField,
         ContentType = ContentType,
         OverwriteIfExists = OverwriteIfExists
     };
     WriteObject(session);
     base.BeginProcessing();
 }