Exemple #1
0
        // Constructor
        public ImportDocument(ImportSettings suppliedsettings)
        {
            // Settings - Initialise the settings
            importsettings = suppliedsettings;

            // Logging - Initialise the trace logs if required
            if (importsettings.LoggingToFile)
            {
                Trace.Listeners.Clear();
                string strLogFileName = Path.GetFileName(System.Reflection.Assembly.GetEntryAssembly().Location) + "." + DateTime.Now.ToString("yyyyMMddHHmmss") + ".log";
                LoggingToFileTraceListener = new TextWriterTraceListener(strLogFileName);
                Trace.Listeners.Add(LoggingToFileTraceListener);
                Trace.AutoFlush = true;
            }
        }
Exemple #2
0
 // Cancel an import
 public void Cancel()
 {
     // Clear the properties
     importdatatable = new DataTable();
     importprogress = new ImportProgress();
     importsettings = new ImportSettings();
 }
Exemple #3
0
        private void ImportSettingsToUI(ImportSettings importsettings)
        {
            // Basic import settings
            textBoxSourceFolder.Text = importsettings.SourceFolder;
            textBoxDestinationFolderURL.Text = importsettings.Destination.DestinationFolderUrl;
            textBoxDestinationServerURL.Text = importsettings.Destination.DestinationServerUrl;
            textBoxDestinationWebURL.Text = importsettings.Destination.DestinationWebUrl;
            textBoxDestinationLibraryName.Text = importsettings.Destination.DestinationLibraryName;
            checkBoxLoggingToFile.Checked = importsettings.LoggingToFile;
            
            // Render the import type to the User Interface
            if (importsettings.ImportType == ImportSettings.ImportTypes.FileSystemFolder)
            {
                radioButtonFileSystemFolder.Checked = true;
            }

            if (importsettings.ImportType == ImportSettings.ImportTypes.XMLDataSet)
            {
                radioButtonXMLDataSet.Checked = true;
                textBoxSourceFile.Text = importsettings.SourceFile;
            }

            if (importsettings.ImportType == ImportSettings.ImportTypes.CSVFile)
            {
                radioButtonCSVFile.Checked = true;
                textBoxSourceFile.Text = importsettings.SourceFile;
            }

            // Render the authentication details to the UI
            if (importsettings.authenticationsettings.AuthenticationType == AuthenticationSettings.AuthenticationTypes.Current)
            {
                radioButtonAuthenticationModeCurrent.Checked = true;
                panelAuthenticationCredentials.Enabled = false;
            }
            if (importsettings.authenticationsettings.AuthenticationType == AuthenticationSettings.AuthenticationTypes.Specified)
            {
                radioButtonAuthenticationModeSpecified.Checked = true;
                panelAuthenticationCredentials.Enabled = true;
                textBoxAuthenticationDomain.Enabled = true;
                textBoxAuthenticationDomain.Text = importsettings.authenticationsettings.domain;
                textBoxAuthenticationUsername.Text = importsettings.authenticationsettings.username;
                textBoxAuthenticationPassword.Text = importsettings.authenticationsettings.password;
            }
            if (importsettings.authenticationsettings.AuthenticationType == AuthenticationSettings.AuthenticationTypes.Forms)
            {
                radioButtonAuthenticationModeForms.Checked = true;
                panelAuthenticationCredentials.Enabled = true;
                textBoxAuthenticationDomain.Enabled = false;
                textBoxAuthenticationUsername.Text = importsettings.authenticationsettings.username;
                textBoxAuthenticationPassword.Text = importsettings.authenticationsettings.password;
            }
            if (importsettings.authenticationsettings.AuthenticationType == AuthenticationSettings.AuthenticationTypes.Office365)
            {
                radioButtonAuthenticationModeOffice365.Checked = true;
                panelAuthenticationCredentials.Enabled = true;
                textBoxAuthenticationDomain.Enabled = false;
                textBoxAuthenticationUsername.Text = importsettings.authenticationsettings.username;
                textBoxAuthenticationPassword.Text = importsettings.authenticationsettings.password;
            }
            

            // Render the import mappings
            // First the file date and time which have a custom UI

            ImportMapping importmapping = new ImportMapping();
            importmapping.InternalName = "Created";
            importmapping.DataColumn = importsettings.fieldFileSystemCreated;
            importmapping.FormatType = ImportMapping.FormatTypes.None;

            if (importsettings.ImportMappings.Contains(importmapping))
            {
                radioButtonCreatedFromFileSystem.Checked = true;
            }

            importmapping.InternalName = "Modified";
            importmapping.DataColumn = importsettings.fieldFileSystemModified;
            importmapping.FormatType = ImportMapping.FormatTypes.None;

            if (importsettings.ImportMappings.Contains(importmapping))
            {
                radioButtonModifiedFromFileSystem.Checked = true;
            }

           
        }
Exemple #4
0
        // Cancel an import from the user interface

        // This function will return an Import Settings object based upon the current import settings showing in the UI
        private ImportSettings ImportSettingsFromUI()
        {
            // Create a settings object
            ImportSettings importsettings = new ImportSettings();

            // Get the basic settings
            importsettings.SourceFolder = textBoxSourceFolder.Text;
            importsettings.Destination.DestinationFolderUrl = textBoxDestinationFolderURL.Text;
            importsettings.Destination.DestinationServerUrl = textBoxDestinationServerURL.Text;
            importsettings.Destination.DestinationWebUrl = textBoxDestinationWebURL.Text;
            importsettings.Destination.DestinationLibraryName = textBoxDestinationLibraryName.Text;
            importsettings.LoggingToFile = checkBoxLoggingToFile.Checked;
            
            // Get the import type
            if (radioButtonFileSystemFolder.Checked)
            {
                importsettings.ImportType = ImportSettings.ImportTypes.FileSystemFolder;
            }
            
            if (radioButtonXMLDataSet.Checked)
            {
                importsettings.ImportType = ImportSettings.ImportTypes.XMLDataSet;
                importsettings.SourceFile = textBoxSourceFile.Text;
            }

            if (radioButtonCSVFile.Checked)
            {
                importsettings.ImportType = ImportSettings.ImportTypes.CSVFile;
                importsettings.SourceFile = textBoxSourceFile.Text;
            }

            // Get the authentication details
            importsettings.authenticationsettings = AuthenticationSettingsFromUI();


            // Get the mappings

            importsettings.ImportMappings = new ImportMapping[2];

            // First the file system mappings which have a dedicated UI experience for simplicity
            if (radioButtonCreatedFromFileSystem.Checked)
            {
                ImportMapping importmapping = new ImportMapping();
                importmapping.InternalName = "Created";
                importmapping.DataColumn = importsettings.fieldFileSystemCreated;
                importmapping.FormatType = ImportMapping.FormatTypes.None;
                importsettings.ImportMappings[0] = importmapping;
            }
            if (radioButtonModifiedFromFileSystem.Checked)
            {
                ImportMapping importmapping = new ImportMapping();
                importmapping.InternalName = "Modified";
                importmapping.DataColumn = importsettings.fieldFileSystemModified;
                importmapping.FormatType = ImportMapping.FormatTypes.None;
                importsettings.ImportMappings[1] = importmapping;
            }


            return importsettings;
        }
Exemple #5
0
        // Load a settings file
        public static ImportSettings LoadSettings(string strFileNameAndPath)
        {
            ImportSettings importsettings = new ImportSettings();

            XmlSerializer xmlserializer = new XmlSerializer(typeof(ImportSettings));
            FileStream filestream = new FileStream(strFileNameAndPath, FileMode.Open);

            importsettings = (ImportSettings)xmlserializer.Deserialize(filestream);
            filestream.Close();

            return importsettings;
        }
Exemple #6
0
 // Save a settings file
 public static void SaveSettings(string strFileNameAndPath, ImportSettings importsettings)
 {
     XmlSerializer xmlserializer = new XmlSerializer(typeof(ImportSettings));
     StreamWriter streamwriter = new StreamWriter(strFileNameAndPath);
     xmlserializer.Serialize(streamwriter, importsettings);
     streamwriter.Close();
 }