public ICodeDomain GetDomain(string domainName) { string connectionString = SQLiteHelpers.ConnectionStringBuilder(_databaseName); using (SQLiteConnection connection = new SQLiteConnection(connectionString)) { connection.Open(); using (SQLiteCommand command = new SQLiteCommand( "select ZDZ,ZDSM,SFQS from vg_dictionary where ZDMC='" + domainName + "' Order by PX,ZDZ", connection)) { ICodeDomain codeDomain = new CodeDomain() {Name = domainName}; using (SQLiteDataReader reader = command.ExecuteReader()) { while (reader.Read()) { ICodeDomainValue codeDomainValue = new CodeDomainValue(reader.GetString(0), reader.GetString(1), reader.GetBoolean(2)); codeDomain.Values.Add(codeDomainValue); if (codeDomainValue.IsDefault) { codeDomain.DefaultValue = codeDomainValue; } } } return codeDomain; } } }
public bool InitREDatabase(int epsgCode, ProjectLoadingView loadingForm, out string errorMsg) { errorMsg = ""; if (string.IsNullOrEmpty(_databaseName)) { errorMsg = "没有设置数据库!"; return false; } _epsgCode = epsgCode; FileInfo info = new FileInfo(_databaseName); if (!info.Exists) { loadingForm.ShowProgress(60,"创建数据库"); System.IO.FileInfo tmpFileInfo = SQLiteHelpers.GetTemplateDBInfo(); tmpFileInfo.CopyTo(_databaseName); } using (SQLiteConnection connection = new SQLiteConnection(SQLiteHelpers.ConnectionStringBuilder(_databaseName))) { connection.Open(); SpatialiteSharp.SpatialiteLoader.Load(connection); loadingForm.ShowProgress(70, "创建系统表"); CreateRESystemTables(connection); loadingForm.ShowProgress(70, "创建数据字典"); ImportDictionary(connection); loadingForm.ShowProgress(80, "创建地籍表"); CreateREZDTables(connection); loadingForm.ShowProgress(90, "创建居民地底图表"); CreateREBasemapTables(connection,"JMD"); loadingForm.ShowProgress(92, "创建道路底图表"); CreateREBasemapTables(connection, "DL"); loadingForm.ShowProgress(93, "创建水系底图表"); CreateREBasemapTables(connection, "SX"); loadingForm.ShowProgress(94, "创建地貌底图表"); CreateREBasemapTables(connection, "DMTZ"); loadingForm.ShowProgress(95, "创建独立地物底图表"); CreateREBasemapTables(connection, "DLDW"); loadingForm.ShowProgress(96, "创建其他底图表"); CreateREBasemapTables(connection, "QT"); loadingForm.ShowProgress(97, "创建注记底图表"); CreateREBasemapTables(connection, "ZJ",true,true,false,true); loadingForm.ShowProgress(90, "创建临时表"); CreateRECADTempTables(connection); } return true; }
public List<IObjectClass> GetClasses(bool IsRecursion = true) { List<IObjectClass> _datasets = new List<IObjectClass>(); string connectionString = SQLiteHelpers.ConnectionStringBuilder(_databaseName); using (SQLiteConnection connection = new SQLiteConnection(connectionString)) { connection.Open(); using (SQLiteCommand command = new SQLiteCommand( "select MC,ZWMC,DXLX,XHZDMC,TXZDMC,TXLX,FBMC from vg_objectclasses Order by ParentName", connection)) { using (SQLiteDataReader reader = command.ExecuteReader()) { while (reader.Read()) { IObjectClass objectClass = new ObjectClass(reader); objectClass.DatabaseName = _databaseName; _datasets.Add(objectClass); } } } } if (IsRecursion == false) return _datasets; else { List<IObjectClass> list = _datasets.FindAll(c => c.ParentName == ""); List<IObjectClass> newList = new List<IObjectClass>(list); foreach (IObjectClass objectClass in newList) { List<IObjectClass> children = FindChildClasses(_datasets, objectClass.Name); if (children != null && children.Count > 0) { objectClass.SubClasses = children; } } return newList; } }