예제 #1
0
        private void SaveCurrentMapping(string mappingFileName)
        {
            // TO DO - set drop down/mapping file values

            MappingDefinition currentMappingDefinition = new MappingDefinition();

            currentMappingDefinition.DefinitionFile     = ((ListBoxPair)DefinitionFileList.SelectedItem).Value;
            currentMappingDefinition.CompanyName        = CompanyNameTextBox.Text.Trim();
            currentMappingDefinition.MappingFilters     = MappingFilterList;
            currentMappingDefinition.RequiresLevel2File = checkBoxLevel2.IsChecked ?? false;
            currentMappingDefinition.RequiresOptOutFile = checkBoxOptOut.IsChecked ?? false;
            currentMappingDefinition.CanHaveErrorFile   = checkBoxErrorFile.IsChecked ?? false;


            MappingField mappingField = new MappingField();

            for (int idx = 0; idx < SampleHeaderRow.Count(); idx++)
            {
                mappingField             = new MappingField();
                mappingField.SampleID    = idx + 1;
                mappingField.SampleField = SampleHeaderRow[idx];
                mappingField.SampleValue = SampleDataRow[idx];
                var item = MappingSettingList[idx];
                mappingField.MiddlewareFieldIdentifier = item.Key;

                currentMappingDefinition.MappingFields.Add(mappingField);
            }

            CSVConvertorFileManagement.SaveMappingFile(currentMappingDefinition, mappingFileName, CSVAppFolderMapping, ".xml");
        }
        private void loadSelectedFile_Click(object sender, RoutedEventArgs e)
        {
            Microsoft.Win32.OpenFileDialog fileDialog = new Microsoft.Win32.OpenFileDialog();

            // Set filter for file extension and default file extension
            fileDialog.DefaultExt       = ".csv";
            fileDialog.Filter           = "CSV files (*.csv)|*.csv|Text files (*.txt)|*.txt";
            fileDialog.CheckFileExists  = true;
            fileDialog.InitialDirectory = Environment.GetFolderPath(Environment.SpecialFolder.DesktopDirectory);

            Nullable <bool> result = fileDialog.ShowDialog();

            if (!result.HasValue || !result.Value)
            {
                MessageBox.Show("No file loaded");
                return;
            }

            string fileName = fileDialog.FileName;

            switch (FileTypeForLoading)
            {
            case FileTypeForLoading.Level2:
                UpdateLevel2File(fileName);
                break;

            case FileTypeForLoading.OptOutNew:
                UpdateOptoutFile(fileName, true);
                break;

            case FileTypeForLoading.OptOutChanges:
                UpdateOptoutFile(fileName, false);
                break;

            case FileTypeForLoading.Errors:
                UpdateErrorFile(fileName);
                break;

            case FileTypeForLoading.None:
                return;
            }

            // save updated mapping file and update screen
            CSVConvertorFileManagement.SaveMappingFile(CurrentMappingDefinition, CurrentMappingFilename, CSVAppFolder, ".xml");
            SetAdditionFileDisplay(CurrentMappingDefinition);
        }