예제 #1
0
        public string this[string columnName]
        {
            get {
                if (columnName == "NewValue") {
                    var service = new ImportService(PluginManager.Instance.User);
                    var result = service.ValidateImportValue(Mapping.TargetColumn, NewValue);
                    if (!result.IsValid) {
                        return result.Message;
                    }
                }

                return null;
            }
        }
예제 #2
0
        protected override void ImportRowImpl(int rowId, System.Data.Common.DbConnection connection)
        {
            var service = new ImportService(User);

            string strJAbbrev = Get("References.Journal Abbreviated Name");
            string strJName = Get("References.Journal name");
            string strBookTitle = Get("References.Book title");
            string strPublisher = Get("References.Book Publisher");
            string strPlacePublished = Get("References.Book Place of publication");

            string strRefType = null;

            if (!string.IsNullOrWhiteSpace(strJAbbrev) || !string.IsNullOrWhiteSpace(strJName)) {
                if (!string.IsNullOrWhiteSpace(strBookTitle)) {
                    strRefType = "JS";
                } else {
                    strRefType = "J";
                }
            } else if (!string.IsNullOrWhiteSpace(strPublisher) || !string.IsNullOrWhiteSpace(strPlacePublished)) {
                if (!string.IsNullOrWhiteSpace(strBookTitle)) {
                    strRefType = "BS";
                } else {
                    strRefType = "B";
                }

            } else {
                strRefType = "M";
            }

            int? startPage;
            int? endPage;

            ParserStartEndPages(Get("References.Total pages"), out startPage, out endPage);

            var r = new ReferenceImport {
                RefCode = Get("References.ReferenceCode"),
                Author = Get("References.Author(s)"),
                Title = Get("References.Article title"),
                BookTitle = strBookTitle,
                Editor = Get("References.Editor"),
                RefType = strRefType,
                YearOfPub = Get("References.Year of publication"),
                ActualDate = Get("References.Actual publication date"),
                JournalAbbrevName = strJAbbrev,
                JournalFullName = strJName,
                PartNo = Get("References.Part Number"),
                Series = Get("References.Series Number"),
                Publisher = strPublisher,
                Place = strPlacePublished,
                Volume = Get("References.Volume"),
                Pages = Get("References.Pages"),
                TotalPages = Get("References.Total pages"),
                Possess = Get("References.Possession"),
                Source = Get("References.Source"),
                Edition = Get("References.Edition"),
                ISBN = Get("References.ISBN"),
                ISSN = Get("References.ISSN"),
                Abstract = Get("References.Qualification"),
                DateQual = Get("References.Qualification-date"),
                StartPage = startPage,
                EndPage = endPage
            };

            r.RefID = Service.ImportReference(r);
        }
예제 #3
0
 public string this[string columnName]
 {
     get {
         if (!string.IsNullOrEmpty(TargetColumn)) {
             var service = new ImportService(PluginManager.Instance.User);
             var result = service.ValidateImportValue(TargetColumn, Value);
             if (!result.IsValid) {
                 return result.Message;
             }
         }
         return null;
     }
 }
예제 #4
0
        private void PreloadMappings(ImportWizardContext context)
        {
            var service = new ImportService(PluginManager.Instance.User);
            var fields = service.GetImportFields();

            var mappings = new List<ImportFieldMapping>();

            if (_options != null && _options.RowSource != null) {
                _options.RowSource.Reset();
                var columns = _options.RowSource.ColumnNames;
                foreach (String colName in columns) {
                    var candidate = fields.Find((field) => {
                        if (!string.IsNullOrEmpty(colName)) {
                            // First try a simple match of the name...
                            if (field.DisplayName.Equals(colName, StringComparison.CurrentCultureIgnoreCase)) {
                                return true;
                            };
                            // Next convert all underscores to spaces and try that....

                            var test = colName.Replace("_", " ");
                            if (field.DisplayName.Equals(test, StringComparison.CurrentCultureIgnoreCase)) {
                                return true;
                            }
                        }
                        return false;
                    });

                    var mapping = new ImportFieldMapping { SourceColumn = colName, TargetColumn = "Material.Other", DefaultValue = null, IsFixed = false };
                    if (candidate != null) {
                        mapping.TargetColumn = string.Format("{0}.{1}", candidate.Category, candidate.DisplayName);
                    } else {
                        DarwinCoreField dwc;
                        if (Enum.TryParse<DarwinCoreField>(colName, out dwc)) {

                            switch (dwc) {
                                case DarwinCoreField.fieldNotes:
                                case DarwinCoreField.validatorNotes:
                                case DarwinCoreField.transcriberNotes:
                                    mapping.TargetColumn = "Material.Notes";
                                    break;
                                case DarwinCoreField.associatedMedia:
                                    mapping.TargetColumn = "Material.Multimedia";
                                    break;
                            }
                        }
                    }
                    mappings.Add(mapping);
                }
            }

            context.FieldMappings = mappings;
        }