void _worker_DoWork(object sender, DoWorkEventArgs e) { string errMsg; Replication repl = new Replication(); repl.CheckIn_FeatureInserted += new Replication.CheckIn_FeatureInsertedEventHandler(repl_CheckIn_FeatureInserted); repl.CheckIn_FeatureUpdated += new Replication.CheckIn_FeatureUpdatedEventHandler(repl_CheckIn_FeatureUpdated); repl.CheckIn_FeatureDeleted += new Replication.CheckIn_FeatureDeletedEventHandler(repl_CheckIn_FeatureDeleted); repl.CheckIn_ConflictDetected += new Replication.CheckIn_ConflictDetectedEventHandler(repl_CheckIn_ConflictDetected); repl.CheckIn_BeginPost += new Replication.CheckIn_BeginPostEventHandler(repl_CheckIn_BeginPost); _labelIndex = 1; Replication.ProcessType type = ((CheckinMode)e.Argument == CheckinMode.Reconcile) ? Replication.ProcessType.Reconcile : Replication.ProcessType.CheckinAndRelease; if (!repl.Process(_parentFc, _childFc, type, out errMsg)) { MessageBox.Show(errMsg); } _worker = null; CheckInFinisched(); }
private void CheckinProcess() { try { if (_fcs == null || _fcs.Count == 0) { return; } string errMsg = String.Empty; foreach (IFeatureClass fc in _fcs) { _resultString = new StringBuilder(); _inserted = 0; _updated = 0; _deleted = 0; _conflicts = 0; _processedFc = fc; SetListItemImage(fc, 1); IFeatureClass parentFc = Replication.FeatureClassParentFc(fc, out errMsg); if (parentFc == null) { SetItemText(fc, errMsg, true, true); SetListItemImage(fc, 3); continue; } Replication repl = new Replication(); repl.CheckIn_FeatureInserted += new Replication.CheckIn_FeatureInsertedEventHandler(repl_CheckIn_FeatureInserted); repl.CheckIn_FeatureUpdated += new Replication.CheckIn_FeatureUpdatedEventHandler(repl_CheckIn_FeatureUpdated); repl.CheckIn_FeatureDeleted += new Replication.CheckIn_FeatureDeletedEventHandler(repl_CheckIn_FeatureDeleted); repl.CheckIn_ConflictDetected += new Replication.CheckIn_ConflictDetectedEventHandler(repl_CheckIn_ConflictDetected); repl.CheckIn_BeginPost += new Replication.CheckIn_BeginPostEventHandler(repl_CheckIn_BeginPost); repl.CheckIn_Message += new Replication.CheckIn_MessageEventHandler(repl_CheckIn_Message); SetItemText(fc, "", true, true); SetItemText(fc, "Checkin:", true, true); Replication.ProcessType type = Replication.ProcessType.Reconcile; if (!repl.Process(parentFc, fc, type, out errMsg)) { SetItemText(fc, errMsg, true, true); SetListItemImage(fc, 3); } else { _resultString.Append("Reconcile:\t" + _inserted + "\t" + _updated + "\t" + _deleted + "\t" + _conflicts); SetItemText(fc, _resultString.ToString(), false, false); SetListItemImage(fc, 2); } } } catch { } finally { ThreadFinished(); _thread = null; } }
static int Main(string[] args) { string source_connstr = "", source_fc = ""; string dest_connstr = "", dest_fc = ""; Guid source_guid = Guid.Empty, dest_guid = Guid.Empty; bool reconcile = false; for (int i = 0; i < args.Length; i++) { if (args[i] == "-source_connstr") { source_connstr = args[++i]; } else if (args[i] == "-source_guid") { source_guid = new Guid(args[++i]); } else if (args[i] == "-source_fc") { source_fc = args[++i]; } else if (args[i] == "-dest_connstr") { dest_connstr = args[++i]; } else if (args[i] == "-dest_guid") { dest_guid = new Guid(args[++i]); } else if (args[i] == "-dest_fc") { dest_fc = args[++i]; } else if (args[i] == "-reconcile") { reconcile = true; } else if (args[i] == "-silent") { _silent = true; } } if (source_connstr == "" || source_fc == "" || source_guid == Guid.Empty || dest_connstr == "" || dest_fc == "" || dest_guid == Guid.Empty) { Console.WriteLine("USAGE:"); Console.WriteLine("gView.Cmd.Checkin -source_connstr <Source Dataset Connection String>"); Console.WriteLine(" -source_guid <GUID of Dataset Extension>"); Console.WriteLine(" -source_fc <Featureclass name>"); Console.WriteLine(" -dest_connstr <Destination Dataset Connection String>"); Console.WriteLine(" -dest_guid <GUID of Dataset Extension>"); Console.WriteLine(" -dest_fc <Featureclass name>"); Console.WriteLine(" [-reconcile]"); Console.WriteLine(" [-silent]"); return(1); } Console.WriteLine("\n" + source_fc + ":"); PlugInManager compMan = new PlugInManager(); IFeatureDataset sourceDS = compMan.CreateInstance(source_guid) as IFeatureDataset; if (sourceDS == null) { Console.WriteLine("ERROR: Component with GUID '" + source_guid.ToString() + "' not found..."); return(1); } IFeatureDataset destDS = compMan.CreateInstance(dest_guid) as IFeatureDataset; if (destDS == null) { Console.WriteLine("ERROR: Component with GUID '" + dest_guid.ToString() + "' not found..."); return(1); } sourceDS.ConnectionString = source_connstr; destDS.ConnectionString = dest_connstr; if (!sourceDS.Open() || !(sourceDS.Database is IFeatureDatabaseReplication)) { Console.WriteLine("ERROR: Component with GUID '" + source_guid.ToString() + "' is not a replicatable feature dataset..."); return(1); } if (!destDS.Open() || !(destDS.Database is IFeatureDatabaseReplication)) { Console.WriteLine("ERROR: Component with GUID '" + dest_guid.ToString() + "' is not a replicatable feature dataset..."); return(1); } IDatasetElement sourceElement = sourceDS[source_fc]; IDatasetElement destElement = destDS[dest_fc]; IFeatureClass sourceFC = ((sourceElement != null) ? sourceElement.Class as IFeatureClass : null); IFeatureClass destFC = ((destElement != null) ? destElement.Class as IFeatureClass : null); if (sourceFC == null) { Console.WriteLine("ERROR: Featureclass " + source_fc + " is not available..."); return(1); } if (destFC == null) { Console.WriteLine("ERROR: Featureclass " + dest_fc + " is not available..."); return(1); } string errMsg = String.Empty; Replication repl = new Replication(); repl.CheckIn_ConflictDetected += new Replication.CheckIn_ConflictDetectedEventHandler(repl_CheckIn_ConflictDetected); repl.CheckIn_FeatureDeleted += new Replication.CheckIn_FeatureDeletedEventHandler(repl_CheckIn_FeatureDeleted); repl.CheckIn_FeatureInserted += new Replication.CheckIn_FeatureInsertedEventHandler(repl_CheckIn_FeatureInserted); repl.CheckIn_FeatureUpdated += new Replication.CheckIn_FeatureUpdatedEventHandler(repl_CheckIn_FeatureUpdated); repl.CheckIn_IgnoredSqlStatement += new Replication.CheckIn_IgnoredSqlStatementEventHandler(repl_CheckIn_IgnoredSqlStatement); repl.CheckIn_BeginPost += new Replication.CheckIn_BeginPostEventHandler(repl_CheckIn_BeginPost); repl.CheckIn_BeginCheckIn += new Replication.CheckIn_BeginCheckInEventHandler(repl_CheckIn_BeginCheckIn); repl.CheckIn_ChangeSessionLockState += new Replication.CheckIn_ChangeSessionLockStateEventHandler(repl_CheckIn_ChangeSessionLockState); repl.CheckIn_Message += new Replication.CheckIn_MessageEventHandler(repl_CheckIn_Message); Replication.ProcessType type = (reconcile) ? Replication.ProcessType.Reconcile : Replication.ProcessType.CheckinAndRelease; if (!repl.Process(destFC, sourceFC, type, out errMsg)) { Console.WriteLine(); Console.WriteLine("ERROR :" + errMsg); Console.WriteLine(); } else { if (!String.IsNullOrEmpty(_checkInResults)) { if (_silent) { Console.WriteLine(_checkInResults); } else { Console.WriteLine("\n" + _checkInResults); } } if (reconcile) { Console.WriteLine("Reconcile:\t" + _inserted + "\t" + _updated + "\t" + _deleted + "\t" + _conflicts); } else { Console.WriteLine(); Console.WriteLine("\t\tINSERT\tUPDATE\tDELETE\tCONFLICTS"); Console.WriteLine("------------------------------------------------------------"); Console.WriteLine("Checkin :\t" + _inserted + "\t" + _updated + "\t" + _deleted + "\t" + _conflicts); } } Console.WriteLine("------------------------------------------------------------"); return(0); }