Пример #1
0
 public ImportSource(
     Common.CSVFormat format,
     string name,
     string description)
 {
     _format      = format;
     _name        = name;
     _description = description;
 }
Пример #2
0
        public static List <ImportFieldMapping> CreateMappings(Common.CSVFormat format)
        {
            List <ImportFieldMapping> mappings = new List <ImportFieldMapping>();

            switch (format)
            {
            case Common.CSVFormat.KeePassCSV1_x:
            {
                mappings.Add(new ImportFieldMapping(StandardFieldAttribute.Get(typeof(Credential), "Name"), "Account"));
                mappings.Add(new ImportFieldMapping(StandardFieldAttribute.Get(typeof(Credential), "Username"), "Login Name"));
                mappings.Add(new ImportFieldMapping(StandardFieldAttribute.Get(typeof(Credential), "Password"), "Password"));
                mappings.Add(new ImportFieldMapping(StandardFieldAttribute.Get(typeof(Credential), "Website"), "Web Site"));
                mappings.Add(new ImportFieldMapping(StandardFieldAttribute.Get(typeof(Credential), "Notes"), "Comments"));
                break;
            }
            }
            return(mappings);
        }
Пример #3
0
        public async void ImportCSV(object parameter)
        {
            App.AppLogger.Logger.Log(devoctomy.DFramework.Logging.Interfaces.LoggerMessageType.VerboseHigh | devoctomy.DFramework.Logging.Interfaces.LoggerMessageType.Information, "Import CSV.");

            FileData file = await CrossFilePicker.Current.PickFile(new string[] { ".csv" });

            if (file != null)
            {
                string destinationPath = file.FilePath;
                byte[] fileData        = await devoctomy.cachy.Framework.Native.Native.FileHandler.ReadAsync(destinationPath);

                string           fileStringData = System.Text.Encoding.UTF8.GetString(fileData);
                CSVImporter      import         = new CSVImporter(fileStringData);
                Common.CSVFormat autoFormat     = await import.DetermineFormat();

                App.Controller.ShowPopup("vault.importsource",
                                         new KeyValuePair <string, object>("Format", autoFormat),
                                         new KeyValuePair <string, object>("CSVImporter", import));
            }
        }
Пример #4
0
        public void SetParameter(String key, Object parameter)
        {
            switch (key)
            {
            case "Format":
            {
                Common.CSVFormat           format  = (Common.CSVFormat)parameter;
                IEnumerable <ImportSource> matches = SupportedImportSources.SupportedSources.Where(ins => ins.Format == format);
                if (matches.Any())
                {
                    SelectedImportSource = matches.First();
                }
                break;
            }

            case "CSVImporter":
            {
                _csvImporter = parameter as CSVImporter;
                break;
            }
            }
        }