public static bool HasEdits(IApplication app, TransactionManager tm) { try { IWorkspaceEdit workspace = (IWorkspaceEdit)tm.Current().PGDBConnection; bool processQA = false; bool hasEdits = false; workspace.HasEdits(ref hasEdits); UID pUID = new UIDClass(); pUID.Value = "esriEditor.Editor"; IEditor editor = (IEditor)app.FindExtensionByCLSID(pUID); IEditTask task = editor.CurrentTask; IEditTask resetTask = editor.get_Task(0); editor.CurrentTask = resetTask; editor.CurrentTask = task; IEditor2 editor2 = (IEditor2)app.FindExtensionByCLSID(pUID); bool hasCachedEdits = editor2.HasEdits(); return hasCachedEdits || hasEdits; } catch (Exception e) { Logger.Write("Error testing if transaction has edits: " + e.Message + " : " + e.StackTrace, Logger.LogLevel.Debug); throw new Exception("Error", e); } }
public static bool SaveEdits(IApplication app, TransactionManager tm) { bool result = false; try { if (HasEdits(app, tm)) { UID pUID = new UIDClass(); pUID.Value = "esriEditor.Editor"; IWorkspaceEdit workspace = (IWorkspaceEdit)tm.Current().PGDBConnection; IEditor2 editor2 = (IEditor2)app.FindExtensionByCLSID(pUID); editor2.StopEditing(true); editor2.StartEditing((IWorkspace)workspace); workspace.StopEditing(true); workspace.StartEditing(false); } result = true; } catch (Exception e) { Logger.Write("Error saving edits to PGDB", Logger.LogLevel.Debug); MessageBox.Show("An error occured while attempting to save current edits."); result = false; } return result; }
public static ISpatialReference TransactionSpatialReference(TransactionManager tm, ISDUTExtension ext) { IMxDocument pMxDoc = RestTransactionManager.Instance.BaseTransactionManager.app.Document as IMxDocument; IMap pMap = pMxDoc.FocusMap; IEnumLayer enm = pMap.Layers; enm.Reset(); IFeatureLayer fl = enm.Next() as IFeatureLayer; while (fl != null) { try { IFeatureWorkspace thePgdbWorkspace = (IFeatureWorkspace)tm.Current().PGDBConnection; IFeatureClass theTransFC = thePgdbWorkspace.OpenFeatureClass(fl.Name); ISpatialReference sr = ((IGeoDataset)theTransFC).SpatialReference; if (sr != null) return sr; } catch (Exception e) { //ignore } fl = enm.Next() as IFeatureLayer; } return null; }
public RunTestsForm(ref dao.QATestCollection tests, IMap map, TransactionManager tm, QAManager qa) { // // Required for Windows Form Designer support // InitializeComponent(); if (tests == null) throw new ArgumentNullException("tests", "Must pass collection of QA tests to RunTestsForm"); if (tests.Count == 0) throw new ArgumentException("No QA tests passed to RunTestsForm", "tests"); if (map == null) throw new ArgumentNullException("map", "Must pass the focus map to RunTestsForm"); this._tests = tests; this._tm = tm; this._qa = qa; this._map = map; this._defaults = new util.SystemDefaults(); // Throw TM stuff at the QA tests and see if it sticks if (tm.Current() != null) { object[] theArgs = new object[2] { new ISDUTLib.tm.dao.EditsDAO((IFeatureWorkspace)tm.Current().PGDBConnection, tm.transactionConfig()), tm.transactionConfig() }; for (int i = 0; i < this._tests.Count; i++) { this._tests.get_Test(i).Test.UserData = theArgs; } } }