public IFIDSet AppendCadastralXML(ICadastralFabric Fabric, ICadastralJob CadastralJob, IProjectedCoordinateSystem TargetProjectedCoordinateSystem, string CadastralXMLPath) { try { string sTempPath = System.IO.Path.GetTempPath(); string sCopiedCadastralXMLFile = System.IO.Path.Combine(sTempPath, CadastralJob.Name.Replace('/', '_').Replace(':', '_') + ".xml"); //rename ALL oID tags so that they're ignored ReplaceInFile(CadastralXMLPath, sCopiedCadastralXMLFile, "oID>", "old_xxX>"); //Possible TODO for merge-point workaround: analyze coordinates of incoming file and if any are identical to existing fabric coordinates, then make the oID tag match //the oID of the existing point in the target fabric. This will trigger point merging of identical points ITrackCancel pTrkCan = new CancelTracker(); // Create and display the Progress Dialog IProgressDialogFactory pProDlgFact = new ProgressDialogFactory(); IProgressDialog2 pProDlg = pProDlgFact.Create(pTrkCan, 0) as IProgressDialog2; //Set the properties of the Progress Dialog pProDlg.CancelEnabled = false; pProDlg.Description = " "; pProDlg.Title = "Append"; pProDlg.Animation = esriProgressAnimationTypes.esriProgressGlobe; // do an extract to set the spatial reference ((ICadastralFabric3)Fabric).ExtractCadastralPacket(CadastralJob.Name, TargetProjectedCoordinateSystem, null, true); IXMLStream pStream = new XMLStream(); pStream.LoadFromFile(sCopiedCadastralXMLFile); IFIDSet pFIDSet = null;//new FIDSet(); (Fabric as ICadastralFabric3).PostCadastralPacket(pStream, pTrkCan, esriCadastralPacketSetting.esriCadastralPacketNoSetting, ref pFIDSet); //(Fabric as ICadastralFabric3).InsertCadastralPacket(CadastralJob, pStream, pTrkCan, esriCadastralPacketSetting.esriCadastralPacketNoSetting, ref pFIDSet); int setCnt = pFIDSet.Count(); RefreshFabricLayers(ArcMap.Document.ActiveView.FocusMap, Fabric); File.Delete(sCopiedCadastralXMLFile); if (pProDlg != null) { pProDlg.HideDialog(); } return(pFIDSet); } catch (Exception ex) { MessageBox.Show(ex.Message); return(null); } }
public static bool CreateCadastralJob(ICadastralFabric Fabric, string JobName, out ICadastralJob NewCadastralJob, bool WriteToFabric, ref bool JobExists) { try { JobExists = false; //first assume it does not exist //Create a job. ICadastralJob pJob = new CadastralJobClass(); pJob.Name = JobName; pJob.Owner = System.Windows.Forms.SystemInformation.UserName; pJob.Description = "Append Cadastral XML"; int jobId; NewCadastralJob = null; if (WriteToFabric) { try { jobId = Fabric.CreateJob(pJob); NewCadastralJob = pJob; } catch (COMException ex) { if (ex.ErrorCode == (int)fdoError.FDO_E_CADASTRAL_FABRIC_JOB_ALREADY_EXISTS) { //now set the job variable to existing job NewCadastralJob = Fabric.GetJob(JobName); JobExists = true; } return(false); } } else { NewCadastralJob = pJob; } return(true); } catch (Exception ex) { //create a dictionary of error codes for cadastral job related activities. Dictionary <int, String> errorCodeDict = new Dictionary <int, String>(); errorCodeDict.Add(-2147212278, "Job has already been committed."); errorCodeDict.Add(-2147212277, "Job not found."); errorCodeDict.Add(-2147212269, "Parcel feature is part of a job that is currently being edited."); errorCodeDict.Add(-2147212268, "Source datum does not match the fabric datum."); errorCodeDict.Add(-2147212271, "The version of XML cannot be loaded."); errorCodeDict.Add(-2147212274, "The specified cadastral job does not belong to the current fabric."); errorCodeDict.Add(-2147212284, "A job with the specified name already exists."); errorCodeDict.Add(-2147212283, "The status of the job is invalid for this procedure."); errorCodeDict.Add(-2147212282, "Schema error. Required fields are missing."); errorCodeDict.Add(-2147212281, "Lock already exists for cadastral feature."); COMException c_Ex = (COMException)ex; NewCadastralJob = null; MessageBox.Show(ex.Message + Environment.NewLine + errorCodeDict[c_Ex.ErrorCode]); return(false); } }