private void button1_Click(object sender, EventArgs e) { schemaFile = textBox1.Text; targetGeodatabase = textBox2.Text; IWorkspaceFactory workspaceFactory = new SdeWorkspaceFactory(); IWorkspace targetWorkspace = workspaceFactory.OpenFromFile(targetGeodatabase, 0); ListSchemaChanges(targetWorkspace, schemaFile, true); MessageBox.Show("Successfully Updated!"); }
/// <summary> /// 获取SDE数据库工作空间 /// </summary> /// <param name="sdePath">.sde文件</param> /// <returns></returns> public static IWorkspace GetSdeWorkspace(string sdePath) { if (sdePath == "" || !sdePath.EndsWith(".sde") || !File.Exists(sdePath)) { throw new Exception(string.Format("请选择sde文件")); } try { IWorkspaceFactory2 wf = new SdeWorkspaceFactory() as IWorkspaceFactory2; IWorkspace workspace = wf.OpenFromFile(sdePath, 0); return(workspace); } catch (Exception ex) { throw new Exception(string.Format("打开SDE数据库失败"), ex); } }
public static IWorkspace OpenSDEGDB(string string_0) { IWorkspace workspace = null; IWorkspaceFactory o = new SdeWorkspaceFactory(); try { workspace = o.OpenFromFile(string_0, 0); } catch (COMException exception) { MessageBox.Show("错误代码:" + exception.ErrorCode.ToString() + "\r\n" + exception.Message); } catch (Exception) { } ComReleaser.ReleaseCOMObject(o); o = null; return(workspace); }
public static IWorkspace OpenSDEGDB(string string_0) { IWorkspace workspace = null; IWorkspaceFactory sdeWorkspaceFactoryClass = new SdeWorkspaceFactory(); try { workspace = sdeWorkspaceFactoryClass.OpenFromFile(string_0, 0); } catch (COMException cOMException1) { COMException cOMException = cOMException1; int errorCode = cOMException.ErrorCode; MessageBox.Show(string.Concat("错误代码:", errorCode.ToString(), "\r\n", cOMException.Message)); } catch (Exception exception) { } ComReleaser.ReleaseCOMObject(sdeWorkspaceFactoryClass); sdeWorkspaceFactoryClass = null; return(workspace); }
public static IWorkspace GetSDEWorkspace(string connectFile) { IWorkspaceFactory factory = new SdeWorkspaceFactory(); return(factory.OpenFromFile(connectFile, 0)); }
private static IWorkspace WorkspaceFromSDEFile(string path) { SdeWorkspaceFactory pWSFactory = new SdeWorkspaceFactory(); IWorkspace pWSpace = pWSFactory.OpenFromFile(path, 0); return pWSpace; }
private void ConnectWorkspace(string connectionString) { string str = ""; IWorkspaceFactory factory; foreach (string str2 in connectionString.Split(new char[] { ';' })) { string[] strArray3 = str2.Split(new char[] { '=' }); switch (strArray3[0].ToLower()) { case "dbclient": dbclient = strArray3[1].ToLower(); break; case "server": SDEServer = strArray3[1]; break; case "authentication_mode": authentication_mode = strArray3[1].ToLower(); break; case "user": SDEUser = strArray3[1]; break; case "password": SDEPassword = strArray3[1]; break; case "version": SDEVersion = strArray3[1]; break; case "database": SDEDatabase = strArray3[1]; break; case "gdbname": str = strArray3[1]; break; } } if (dbclient == "mdb") { if (str[1] != ':') { str = Path.Combine(Application.StartupPath, str); } factory = new AccessWorkspaceFactoryClass(); this.Workspace = factory.OpenFromFile(str, 0); } else if (dbclient == "gdb") { if (str[1] != ':') { str = Path.Combine(Application.StartupPath, str); } factory = new FileGDBWorkspaceFactoryClass(); this.Workspace = factory.OpenFromFile(str, 0); } else if (dbclient == "sde") { if (str[1] != ':') { str = Path.Combine(Application.StartupPath, str); } factory = new SdeWorkspaceFactory(); this.Workspace = factory.OpenFromFile(str, 0); } else { IWorkspaceFactory factory2 = new SdeWorkspaceFactoryClass(); try { IPropertySet connectionProperties = this.CreateConnectionProperty(); if (connectionProperties == null) { return; } this.Workspace = factory2.Open(connectionProperties, 0); } catch (Exception exception) { //CErrorLog.writeErrorLog(null, exception, ""); } } if (this.Workspace != null) { this._templateTable = (this.Workspace as IFeatureWorkspace).OpenTable("YT_MAPTEMPLATE"); this._classTable = (this.Workspace as IFeatureWorkspace).OpenTable("YT_MAPTEMPLATE_CLASS"); this._elementTable = (this.Workspace as IFeatureWorkspace).OpenTable("YT_MAPTEMPLATE_ELEMENT"); this._paramTable = (this.Workspace as IFeatureWorkspace).OpenTable("YT_MAPTEMPLATE_PARAM"); this.ReadClasses(); this._connectionString = connectionString; } }