public override ValidationResult Validate(object value, CultureInfo cultureInfo) { BindingGroup bindingGroup = (BindingGroup)value; if (bindingGroup.Items.Count > 0) { object obj = bindingGroup.Items[0]; PgM.PgTableBaseM tableM = obj as PgM.PgTableBaseM; String schemeName = (String)bindingGroup.GetValue(tableM, "SchemeName"); String baseName = (String)bindingGroup.GetValue(tableM, "Name"); String systemName = (String)bindingGroup.GetValue(tableM, "Text"); AbsM.EGeomType geomType = (AbsM.EGeomType)((EnumWrapper)(bindingGroup.GetValue(tableM, "GeomType"))).Value; if (String.IsNullOrEmpty(schemeName)) { return(new ValidationResult(false, "Схема не должна быть пустой")); } if (String.IsNullOrEmpty(baseName)) { return(new ValidationResult(false, "Название таблицы в базе не должно быть пустым")); } if (String.IsNullOrEmpty(systemName)) { return(new ValidationResult(false, "Название таблицы в системе не должно быть пустым")); } if (tableM.IsLayer && geomType == AbsM.EGeomType.None) { return(new ValidationResult(false, "Слой карты должен иметь тип геометрии")); } } return(ValidationResult.ValidResult); }
public PgImportTableVM(FileInfo fileInfo, ImportTableV importWindow) { _fileInfo = fileInfo; _importWindow = importWindow; _tableInfo = null; _dataTable = null; _geomType = 0; _progressKey = "importProgress" + DateTime.Now.Ticks.ToString(); _srid = -1; CanLoad = true; switch (_fileInfo.Extension.ToLower()) { case ".dbf": _importer = new DBFImporter(); break; case ".xls": case ".xlsx": _importer = new ExcelImporter(); break; case ".shp": case ".tab": case ".bna": case ".csv": case ".geojson": case ".gml": case ".gmt": case ".itf": case ".kml": case ".mif": case ".xml": case ".gxt": case ".dxf": case ".sqlite": _importer = new SHPImporter(); break; default: _importer = null; break; } if (_importer == null) { MessageBox.Show(Rekod.Properties.Resources.ImportWindow_NotSupportExtension); return; } _importer.WorkerSupportsCancellation = true; _importer.ProgressChanged += new System.ComponentModel.ProgressChangedEventHandler(importer_ProgressChanged); _importer.RunWorkerCompleted += new System.ComponentModel.RunWorkerCompletedEventHandler(importer_RunWorkerCompleted); try { _importer.Init(_fileInfo, _tableInfo); _dataTable = _importer.GetPreviewTable(); if (_importer is SHPImporter) { _geomType = (AbsM.EGeomType)((SHPImporter)_importer).GetGeometryType(); _srid = ((SHPImporter)_importer).GetSRID(); } } catch (Exception e) { cti.ThreadProgress.Close(_progressKey); MessageBox.Show(Properties.Resources.LabelControl_ErrorShowResult + Environment.NewLine + e.Message, Properties.Resources.error, MessageBoxButton.OK, MessageBoxImage.Error); _importer.CancelAsync(); _importer.Dispose(); return; } if (_dataTable == null) { MessageBox.Show(Properties.Resources.LabelControl_ErrorShowResult); _importer.CancelAsync(); _importer.Dispose(); return; } _knownGeometry = _geomType != 0; }