ArcGIS Engine开发的ArcGIS 版本管理的功能

简介: 原文:ArcGIS Engine开发的ArcGIS 版本管理的功能转自:http://blog.csdn.net/linghe301/article/details/7965901 这是以前的ArcGIS Engine开发成果,主要是Geodatabase方面的,模仿ArcGIS版本的流程系统环...
原文: ArcGIS Engine开发的ArcGIS 版本管理的功能

转自:http://blog.csdn.net/linghe301/article/details/7965901

这是以前的ArcGIS Engine开发成果,主要是Geodatabase方面的,模仿ArcGIS版本的流程
系统环境:

VS2010、ArcGIS Engine10、DevExpress721(第三方控件,比较常用易于下载)

 

------------------------------------------------------------------

我跟大家分享了存在#百度网盘#上的文件,“DXperienceEval-7.2.1.exe”,点击链接进行查看和下载。 http://t.cn/zWsdZRY  (分享自 @百度网盘官方微博)
------------------------------------------------------------------

系统的连接参数都写在代码里面了,如果有问题,跟踪一下代码即可解决

相关功能:

1:打开ArcSDE版本数据

2:切换版本

3:创建新版本

4:查看版本信息

5:协调版本

6:冲突解决

7:提交版本

8:历史归档管理

 

因为这是很早的东西了,是自己兴趣开发的,会有相关bug,如果有一定基础肯定可以顺利的进行参考!希望能给大家带来帮助!


仅供参考!

 

下图为系统界面

 

下图为创建子版本

 

下图为协调版本

 

下图为冲突对话框

 

核心代码冲突对话框

 

[python]  view plain  copy
 
 print?
  1. using System;  
  2. using System.Collections.Generic;  
  3. using System.ComponentModel;  
  4. using System.Data;  
  5. using System.Drawing;  
  6. using System.Linq;  
  7. using System.Text;  
  8. using System.Windows.Forms;  
  9. using DevExpress.XtraEditors;  
  10. using ESRI.ArcGIS.Geometry;  
  11. using ESRI.ArcGIS.Geodatabase;  
  12. using ESRI.ArcGIS.esriSystem;  
  13. using ESRI.ArcGIS.Display;  
  14. using LSCommonHelper;  
  15. using LSGISHelper;  
  16. using ESRI.ArcGIS.DataSourcesGDB;  
  17. using ESRI.ArcGIS.Controls;  
  18. using ESRI.ArcGIS.Carto;  
  19. using DevExpress.XtraGrid.Views.Grid;  
  20. namespace LSVersion.Version  
  21. {  
  22.     public partial class ConflictsForm : Form  
  23.     {  
  24.         public ConflictsForm()  
  25.         {  
  26.             InitializeComponent();  
  27.         }  
  28.         private IVersion m_peditVersion=null;  
  29.         public IVersion EditVersion  
  30.         {  
  31.             get { return m_peditVersion; }  
  32.             set { m_peditVersion = value; }  
  33.         }  
  34.         private IVersion m_ptargetVersion = null;  
  35.         public IVersion TargetVersion  
  36.         {  
  37.             get { return m_ptargetVersion; }  
  38.             set { m_ptargetVersion = value; }  
  39.         }  
  40.         private void ConflictsForm_Load(object sender, EventArgs e)  
  41.         {  
  42.             Init();  
  43.         }  
  44.         private IFeatureWorkspace featureWorkspace = null;  
  45.         private IFeatureWorkspace commonAncestorFWorkspace = null;  
  46.         private IFeatureWorkspace preReconcileFWorkspace = null;  
  47.         private IFeatureWorkspace reconcileFWorkspace = null;  
  48.         private AxMapControl m_pMapControl = null;  
  49.         public AxMapControl MapControl  
  50.         {  
  51.             get { return m_pMapControl; }  
  52.             set { m_pMapControl = value; }  
  53.         }  
  54.   
  55.         IFeature featurePreReconcile = null;  
  56.         IFeature featureReconcile = null;  
  57.         IFeature featureCommonAncestor = null;  
  58.         private void ClickID(string sLayerName, int sOID, TreeNode sSelNode)  
  59.         {  
  60.             IFeatureClass featureClassPreReconcile =  
  61.                     preReconcileFWorkspace.OpenFeatureClass(sLayerName);  
  62.             IFeatureClass featureClassReconcile =  
  63.               reconcileFWorkspace.OpenFeatureClass(sLayerName);  
  64.             IFeatureClass featureClassCommonAncestor =  
  65.               commonAncestorFWorkspace.OpenFeatureClass(sLayerName);  
  66.             
  67.           
  68.             this.axMapControl1.ClearLayers();  
  69.             this.axMapControl2.ClearLayers();  
  70.             this.axMapControl3.ClearLayers();  
  71.   
  72.             this.listView1.Items.Clear();  
  73.             int flag = -1;  
  74.             if (sSelNode.Parent.Text == "更新-更新冲突")  
  75.             {  
  76.                 flag = 0;  
  77.             }  
  78.             else if (sSelNode.Parent.Text == "删除-更新冲突")  
  79.             {  
  80.                 flag = 1;  
  81.             }  
  82.             else if (sSelNode.Parent.Text == "更新-删除冲突")  
  83.             {  
  84.                 flag = 2;  
  85.             }  
  86.             IFeatureLayer PreReconcileFL = new FeatureLayerClass();  
  87.             PreReconcileFL.FeatureClass = featureClassPreReconcile;  
  88.   
  89.             IFeatureLayer ReconcileFL = new FeatureLayerClass();  
  90.             ReconcileFL.FeatureClass = featureClassReconcile;  
  91.   
  92.             IFeatureLayer CommonAncestorFL = new FeatureLayerClass();  
  93.             CommonAncestorFL.FeatureClass = featureClassCommonAncestor;  
  94.   
  95.             this.axMapControl1.Map.AddLayer(ReconcileFL as ILayer);  
  96.             this.axMapControl2.Map.AddLayer(PreReconcileFL as ILayer);  
  97.             this.axMapControl3.Map.AddLayer(CommonAncestorFL as ILayer);  
  98.   
  99.   
  100.            
  101.             try  
  102.             {  
  103.                 featurePreReconcile =  
  104.                                    featureClassPreReconcile.GetFeature(sOID);  
  105.             }  
  106.             catch { this.axMapControl2.ClearLayers(); }  
  107.             try  
  108.             {  
  109.                 featureReconcile = featureClassReconcile.GetFeature(sOID);  
  110.             }  
  111.             catch { this.axMapControl1.ClearLayers(); }  
  112.             try  
  113.             {  
  114.                 featureCommonAncestor =  
  115.                  featureClassCommonAncestor.GetFeature(sOID);  
  116.             }  
  117.             catch { this.axMapControl3.ClearLayers(); }  
  118.             IField pField = null;  
  119.             if (flag == 0)  
  120.             {  
  121.                 for (int i = 0; i < featureReconcile.Fields.FieldCount; i++)  
  122.                 {  
  123.                     pField = featureReconcile.Fields.get_Field(i);  
  124.                     ListViewItem lv = new ListViewItem();  
  125.                     lv.SubItems.Add(pField.AliasName);  
  126.                     lv.SubItems.Add(LSGISHelper.FeatureHelper.GetFeatureStringValue(featureReconcile, pField.AliasName));  
  127.                     lv.SubItems.Add(LSGISHelper.FeatureHelper.GetFeatureStringValue(featurePreReconcile, pField.AliasName));  
  128.                     lv.SubItems.Add(LSGISHelper.FeatureHelper.GetFeatureStringValue(featureReconcile, pField.AliasName));  
  129.                     lv.SubItems.Add(LSGISHelper.FeatureHelper.GetFeatureStringValue(featureCommonAncestor, pField.AliasName));  
  130.                     this.listView1.Items.Add(lv);  
  131.                 }  
  132.             }  
  133.             else if (flag == 1)  
  134.             {  
  135.                 for (int i = 0; i < featureReconcile.Fields.FieldCount; i++)  
  136.                 {  
  137.                     pField = featureReconcile.Fields.get_Field(i);  
  138.                     ListViewItem lv = new ListViewItem();  
  139.                     lv.SubItems.Add(pField.AliasName);  
  140.                     if (i == 0)  
  141.                     {  
  142.                        
  143.                         lv.SubItems.Add(LSGISHelper.FeatureHelper.GetFeatureStringValue(featureReconcile, pField.AliasName));  
  144.                         lv.SubItems.Add("Deleted");  
  145.                         lv.SubItems.Add(LSGISHelper.FeatureHelper.GetFeatureStringValue(featureReconcile, pField.AliasName));  
  146.                         lv.SubItems.Add(LSGISHelper.FeatureHelper.GetFeatureStringValue(featureCommonAncestor, pField.AliasName));  
  147.                     }  
  148.                     else  
  149.                     {  
  150.   
  151.                         lv.SubItems.Add(LSGISHelper.FeatureHelper.GetFeatureStringValue(featureReconcile, pField.AliasName));  
  152.                         lv.SubItems.Add("");  
  153.                         lv.SubItems.Add(LSGISHelper.FeatureHelper.GetFeatureStringValue(featureReconcile, pField.AliasName));  
  154.                         lv.SubItems.Add(LSGISHelper.FeatureHelper.GetFeatureStringValue(featureCommonAncestor, pField.AliasName));  
  155.                     }  
  156.                     this.listView1.Items.Add(lv);  
  157.                 }  
  158.             }  
  159.             else if (flag == 2)  
  160.             {  
  161.                 for (int i = 0; i < featurePreReconcile.Fields.FieldCount; i++)  
  162.                 {  
  163.                     pField = featurePreReconcile.Fields.get_Field(i);  
  164.                     ListViewItem lv = new ListViewItem();  
  165.                     lv.SubItems.Add(pField.AliasName);  
  166.                     if (i == 0)  
  167.                     {  
  168.                         lv.SubItems.Add("Deleted");  
  169.                         lv.SubItems.Add(LSGISHelper.FeatureHelper.GetFeatureStringValue(featurePreReconcile, pField.AliasName));  
  170.                         lv.SubItems.Add("Deleted");  
  171.                         lv.SubItems.Add(LSGISHelper.FeatureHelper.GetFeatureStringValue(featureCommonAncestor, pField.AliasName));  
  172.                     }  
  173.                     else  
  174.                     {  
  175.                         lv.SubItems.Add("");  
  176.                         lv.SubItems.Add(LSGISHelper.FeatureHelper.GetFeatureStringValue(featurePreReconcile, pField.AliasName));  
  177.                         lv.SubItems.Add("");  
  178.                         lv.SubItems.Add(LSGISHelper.FeatureHelper.GetFeatureStringValue(featureCommonAncestor, pField.AliasName));  
  179.                     }  
  180.                     this.listView1.Items.Add(lv);  
  181.                 }  
  182.             }  
  183.             Flash(this.axMapControl1, featureReconcile);  
  184.             Flash(this.axMapControl2, featurePreReconcile);  
  185.             Flash(this.axMapControl3, featureCommonAncestor);  
  186.   
  187.             #region//Display  
  188.             pageCon = this.m_pMapControl.ActiveView.GraphicsContainer;  
  189.             pageCon.DeleteAllElements();  
  190.             Display(featureReconcile);  
  191.             Display(featurePreReconcile);  
  192.             Display(featureCommonAncestor);  
  193.             
  194.             #endregion  
  195.   
  196.         }  
  197.         IGraphicsContainer pageCon = null;  
  198.         private void Display(IFeature pFea)  
  199.         {  
  200.             IFillShapeElement pPEle = new PolygonElementClass();  
  201.             IFillSymbol pFillSym = new SimpleFillSymbolClass();  
  202.             RgbColorClass rgbClr = new RgbColorClass();  
  203.             rgbClr.Transparency = 0;  
  204.   
  205.             ILineSymbol pLineSym = new SimpleLineSymbolClass();  
  206.             pLineSym.Color = LSGISHelper.ColorHelper.CreateRandomColor();  
  207.             pLineSym.Width = 4;  
  208.   
  209.             pFillSym.Color = rgbClr;  
  210.             pFillSym.Outline = pLineSym;  
  211.             pPEle.Symbol = pFillSym;  
  212.             IElement pEle = pPEle as IElement;  
  213.             pEle.Geometry = pFea.ShapeCopy;  
  214.   
  215.   
  216.         
  217.             this.m_pMapControl.ActiveView.PartialRefresh(esriViewDrawPhase.esriViewGraphics, null, null);  
  218.             pageCon.AddElement(pEle, 0);  
  219.   
  220.         }  
  221.         private void Flash(AxMapControl axMapControl3, IFeature pFea)  
  222.         {  
  223.             if (pFea != null)  
  224.             {  
  225.                 axMapControl3.Extent = pFea.Shape.Envelope;  
  226.                 axMapControl3.ActiveView.PartialRefresh(esriViewDrawPhase.esriViewGeography, null, null);  
  227.                 axMapControl3.FlashShape(pFea.ShapeCopy);  
  228.             }  
  229.         }  
  230.         private void Init()  
  231.         {  
  232.             this.myTreeView1.Nodes.Clear();  
  233.             this.listView1.Items.Clear();  
  234.             
  235.             try  
  236.             {  
  237.                 IWorkspaceEdit workspaceEdit = (IWorkspaceEdit2)m_peditVersion;  
  238.                 IVersionEdit4 versionEdit4 = (IVersionEdit4)workspaceEdit;  
  239.                  featureWorkspace = m_peditVersion as IFeatureWorkspace;  
  240.                 // Get the various versions on which to output information.  
  241.                  commonAncestorFWorkspace = (IFeatureWorkspace)  
  242.                   versionEdit4.CommonAncestorVersion;  
  243.                  preReconcileFWorkspace = (IFeatureWorkspace)  
  244.                   versionEdit4.PreReconcileVersion;  
  245.                  reconcileFWorkspace = (IFeatureWorkspace)  
  246.                   versionEdit4.ReconcileVersion;  
  247.   
  248.                 IEnumConflictClass enumConflictClass = versionEdit4.ConflictClasses;  
  249.   
  250.                 TreeNode pRootNode = new TreeNode();  
  251.                 pRootNode.Text = "Conflicts";  
  252.                 this.myTreeView1.Nodes.Add(pRootNode);  
  253.   
  254.                 IConflictClass conflictClass = null;  
  255.                 while ((conflictClass = enumConflictClass.Next()) != null)  
  256.                 {  
  257.                     IDataset dataset = (IDataset)conflictClass;  
  258.   
  259.                     // Make sure class is a feature class.  
  260.                     if (dataset.Type == esriDatasetType.esriDTFeatureClass)  
  261.                     {  
  262.                         String datasetName = dataset.Name;  
  263.                         TreeNode pRoot2Node = new TreeNode();  
  264.                         pRoot2Node.Text = datasetName;  
  265.                         this.myTreeView1.Nodes[0].Nodes.Add(pRoot2Node);  
  266.   
  267.                         IFeatureClass featureClass = featureWorkspace.OpenFeatureClass  
  268.                           (datasetName);  
  269.   
  270.                       //  Console.WriteLine("Conflicts on feature class {0}", datasetName);  
  271.                         // Get conflict feature classes on the three reconcile versions.  
  272.                     
  273.   
  274.                         // Get all UpdateUpdate conflicts.  
  275.                         ISelectionSet updateUpdates = conflictClass.UpdateUpdates;  
  276.                         if (updateUpdates.Count > 0)  
  277.                         {  
  278.                             TreeNode pUUNode = new TreeNode();  
  279.                             pUUNode.Text = "更新-更新冲突";  
  280.                             pRoot2Node.Nodes.Add(pUUNode);  
  281.                             #region 更新更新  
  282.                             // Iterate through each OID, outputting information.  
  283.                             IEnumIDs enumIDs = updateUpdates.IDs;  
  284.                             int oid =  enumIDs.Next();  
  285.                           
  286.                                 while (oid != -1)  
  287.                                 //loop through all conflicting features  
  288.                                 {  
  289.                                     // Console.WriteLine("UpdateUpdate conflicts on feature {0}", oid);  
  290.                                     // Get conflict feature on the three reconcile versions.  
  291.                                     TreeNode pOidNode = new TreeNode();  
  292.                                     pOidNode.Text ="OID:"+ oid.ToString();  
  293.                                     pUUNode.Nodes.Add(pOidNode);  
  294.                                     #region---处理  
  295.                                     // Check to make sure each shape is different than the common ancestor (conflict is on shape field).  
  296.   
  297.                                   
  298.                                     #endregion  
  299.                                     oid = enumIDs.Next();  
  300.                                 }  
  301.                              
  302.                             #endregion  
  303.                         }  
  304.                           ISelectionSet deleteUpdates = conflictClass.DeleteUpdates;  
  305.                           if (deleteUpdates.Count > 0)  
  306.                           {  
  307.                               TreeNode pDUNode = new TreeNode();  
  308.                               pDUNode.Text = "删除-更新冲突";  
  309.                               pRoot2Node.Nodes.Add(pDUNode);  
  310.                               #region 删除更新  
  311.                               // Iterate through each OID, outputting information.  
  312.                               IEnumIDs enumIDs = deleteUpdates.IDs;  
  313.                               int oid = enumIDs.Next();  
  314.   
  315.                               while (oid != -1)  
  316.                               //loop through all conflicting features  
  317.                               {  
  318.                                   // Console.WriteLine("UpdateUpdate conflicts on feature {0}", oid);  
  319.                                   // Get conflict feature on the three reconcile versions.  
  320.                                   TreeNode pOidNode = new TreeNode();  
  321.                                   pOidNode.Text = "OID:" + oid.ToString();  
  322.                                   pDUNode.Nodes.Add(pOidNode);  
  323.                       
  324.                                   oid = enumIDs.Next();  
  325.                               }  
  326.                               #endregion  
  327.                           }  
  328.                           ISelectionSet Updatedeletes = conflictClass.UpdateDeletes;  
  329.                           if (Updatedeletes.Count > 0)  
  330.                           {  
  331.                               TreeNode pUDNode = new TreeNode();  
  332.                               pUDNode.Text = "更新-删除冲突";  
  333.                               pRoot2Node.Nodes.Add(pUDNode);  
  334.                               #region 更新删除  
  335.                               // Iterate through each OID, outputting information.  
  336.                               IEnumIDs enumIDs = Updatedeletes.IDs;  
  337.                               int oid = enumIDs.Next();  
  338.   
  339.                               while (oid != -1)  
  340.                               //loop through all conflicting features  
  341.                               {  
  342.                                 
  343.                                   TreeNode pOidNode = new TreeNode();  
  344.                                   pOidNode.Text = "OID:" + oid.ToString();  
  345.                                   pUDNode.Nodes.Add(pOidNode);  
  346.   
  347.                                   oid = enumIDs.Next();  
  348.                               }  
  349.                               #endregion  
  350.                           }  
  351.                     }  
  352.                 }  
  353.                 this.myTreeView1.ExpandAll();  
  354.             }  
  355.             catch (System.Runtime.InteropServices.COMException comExc)  
  356.             {  
  357.                 Console.WriteLine("Error Message: {0}, Error Code: {1}", comExc.Message,  
  358.                   comExc.ErrorCode);  
  359.             }  
  360.         }  
  361.   
  362.         // Method to determine if shape field is in conflict.  
  363.         private bool IsShapeInConflict(IFeature commonAncestorFeature, IFeature  
  364.           preReconcileFeature, IFeature reconcileFeature)  
  365.         {  
  366.             // 1st check: Common Ancestor with PreReconcile.  
  367.             // 2nd check: Common Ancestor with Reconcile.  
  368.             // 3rd check: Reconcile with PreReconcile (case of same change on both versions)  
  369.             if (IsGeometryEqual(commonAncestorFeature.ShapeCopy,  
  370.               preReconcileFeature.ShapeCopy) || IsGeometryEqual  
  371.               (commonAncestorFeature.ShapeCopy, reconcileFeature.ShapeCopy) ||  
  372.               IsGeometryEqual(reconcileFeature.ShapeCopy, preReconcileFeature.ShapeCopy)  
  373.               )  
  374.             {  
  375.                 return false;  
  376.             }  
  377.             else  
  378.             {  
  379.                 return true;  
  380.             }  
  381.         }  
  382.   
  383.         // Method returning if two shapes are equal to one another.  
  384.         private bool IsGeometryEqual(IGeometry shape1, IGeometry shape2)  
  385.         {  
  386.             if (shape1 == null & shape2 == null)  
  387.             {  
  388.                 return true;  
  389.             }  
  390.             else if (shape1 == null ^ shape2 == null)  
  391.             {  
  392.                 return false;  
  393.             }  
  394.             else  
  395.             {  
  396.                 IClone clone1 = (IClone)shape1;  
  397.                 IClone clone2 = (IClone)shape2;  
  398.                 return clone1.IsEqual(clone2);  
  399.             }  
  400.         }  
  401.   
  402.         private void myTreeView1_MouseDoubleClick(object sender, MouseEventArgs e)  
  403.         {  
  404.             if (this.myTreeView1.Nodes.Count > 0)  
  405.             {  
  406.                 TreeNode sSelNode = this.myTreeView1.SelectedNode;  
  407.                 if (sSelNode != null)  
  408.                 {  
  409.                     string sSel = sSelNode.Text;  
  410.                     if (LSCommonHelper.OtherHelper.GetLeftName(sSel, ":") == "OID")  
  411.                     {  
  412.                         string sLayerName = sSelNode.Parent.Parent.Text;  
  413.                         int sOID = LSCommonHelper.ConvertHelper.ObjectToInt(  
  414.                             LSCommonHelper.OtherHelper.GetRightName(sSel, ":"));  
  415.                         ClickID(sLayerName, sOID, sSelNode);  
  416.                     }  
  417.                 }  
  418.   
  419.             }  
  420.         }  
  421.   
  422.         private void ConflictsForm_FormClosing(object sender, FormClosingEventArgs e)  
  423.         {  
  424.             pageCon.DeleteAllElements();  
  425.         }  
  426.         private void replaceObjectWith(IFeature pfea,  
  427.             TreeNode pNode )  
  428.         {  
  429.             pageCon.DeleteAllElements();  
  430.             TreeNode sSelNode = this.myTreeView1.SelectedNode;  
  431.             if (sSelNode != null)  
  432.             {  
  433.                 string sSel = sSelNode.Text;  
  434.                 if (LSCommonHelper.OtherHelper.GetLeftName(sSel, ":") == "OID")  
  435.                 {  
  436.                     string sLayerName = sSelNode.Parent.Parent.Text;  
  437.                     int sOID = LSCommonHelper.ConvertHelper.ObjectToInt(  
  438.                         LSCommonHelper.OtherHelper.GetRightName(sSel, ":"));  
  439.                     IFeatureClass featureClass = featureWorkspace.OpenFeatureClass(sLayerName);  
  440.                    
  441.                      
  442.                     IFeature feature = featureClass.GetFeature(sOID);  
  443.                     feature.Shape = pfea.ShapeCopy;  
  444.                     feature.Store();  
  445.                     m_pMapControl.ActiveView.Refresh();  
  446.                 }  
  447.             }  
  448.               
  449.         }  
  450.         private TreeNode sSelNode = null;  
  451.         private void myTreeView1_MouseDown(object sender, MouseEventArgs e)  
  452.         {  
  453.              sSelNode = this.myTreeView1.GetNodeAt(e.X, e.Y);  
  454.             if (sSelNode == null) return;  
  455.   
  456.             if (e.Button == MouseButtons.Left)  
  457.             {//左键  
  458.   
  459.             }  
  460.             else  
  461.             {  
  462.                 System.Drawing.Point aPt = new System.Drawing.Point(e.X, e.Y);  
  463.              //   TreeNode sSelNode = this.myTreeView1.SelectedNode;  
  464.                 if (sSelNode != null)  
  465.                 {  
  466.                     string sSel = sSelNode.Text;  
  467.                     if (LSCommonHelper.OtherHelper.GetLeftName(sSel, ":") == "OID")  
  468.                     {  
  469.   
  470.                     this.contextMenuStrip1.Show(this.myTreeView1, aPt);  
  471.                     }  
  472.                 }  
  473.                  
  474.             }  
  475.         }  
  476.   
  477.         private void replaceObjectWithCommonAncestorVersionToolStripMenuItem_Click(object sender, EventArgs e)  
  478.         {  
  479.   
  480.             replaceObjectWith(featureCommonAncestor,  sSelNode);  
  481.         }  
  482.   
  483.         private void replaceObjectWithPreReconcileVersionToolStripMenuItem_Click(object sender, EventArgs e)  
  484.         {  
  485.             replaceObjectWith(featurePreReconcile, sSelNode);  
  486.         }  
  487.   
  488.         private void replaceObjectWithConflictsVersionToolStripMenuItem_Click(object sender, EventArgs e)  
  489.         {  
  490.             replaceObjectWith(featureReconcile, sSelNode);  
  491.         }  
  492.   
  493.         private void mergeGeometryToolStripMenuItem_Click(object sender, EventArgs e)  
  494.         {  
  495.             MergeGeometry(featureCommonAncestor, featurePreReconcile, featureReconcile, sSelNode);  
  496.         }  
  497.   
  498.         private void MergeGeometry(IFeature featureCommonAncestor  
  499.             , IFeature featurePreReconcile, IFeature featureReconcile,TreeNode pNode)  
  500.         {  
  501.              pageCon.DeleteAllElements();  
  502.             TreeNode sSelNode = this.myTreeView1.SelectedNode;  
  503.             if (sSelNode != null)  
  504.             {  
  505.                 string sSel = sSelNode.Text;  
  506.                 if (LSCommonHelper.OtherHelper.GetLeftName(sSel, ":") == "OID")  
  507.                 {  
  508.                     string sLayerName = sSelNode.Parent.Parent.Text;  
  509.                     int sOID = LSCommonHelper.ConvertHelper.ObjectToInt(  
  510.                         LSCommonHelper.OtherHelper.GetRightName(sSel, ":"));  
  511.                     IFeatureClass featureClass = featureWorkspace.OpenFeatureClass(sLayerName);  
  512.                     // Check to make sure each shape is different than the common ancestor (conflict is on shape field).  
  513.                     if (IsShapeInConflict(featureCommonAncestor,  
  514.                         featurePreReconcile, featureReconcile))  
  515.                     {  
  516.                         //Console.WriteLine(  
  517.                         //    " Shape attribute has changed on both versions...");  
  518.   
  519.                         // Geometries are in conflict ... merge geometries.  
  520.                         try  
  521.                         {  
  522.                             IConstructMerge constructMerge = new  
  523.                                 GeometryEnvironmentClass();  
  524.                             IGeometry newGeometry =  
  525.                                 constructMerge.MergeGeometries  
  526.                                 (featureCommonAncestor.ShapeCopy,  
  527.                                 featureReconcile.ShapeCopy,  
  528.                                 featurePreReconcile.ShapeCopy);  
  529.   
  530.                             // Setting new geometry as a merge between the two versions.  
  531.                             IFeature feature = featureClass.GetFeature(sOID);  
  532.                             feature.Shape = newGeometry;  
  533.                             feature.Store();  
  534.                             //updateUpdates.RemoveList(1, ref oid);  
  535.                             //conflictsRemoved = true;  
  536.                         }  
  537.                         catch (System.Runtime.InteropServices.COMException comExc)  
  538.                         {  
  539.                             // Check if the error is from overlapping edits.  
  540.                             if (comExc.ErrorCode == (int)  
  541.                                 fdoError.FDO_E_WORKSPACE_EXTENSION_DATASET_CREATE_FAILED || comExc.ErrorCode == (int)fdoError.FDO_E_WORKSPACE_EXTENSION_DATASET_DELETE_FAILED)  
  542.                             {  
  543.                                 // Edited areas overlap.  
  544.                              LSCommonHelper.MessageBoxHelper.ShowMessageBox(  
  545.                                     "Error from overlapping edits on feature {0}"+  
  546.                                     " Can't merge overlapping edits to same feature.");  
  547.                             }  
  548.                             else  
  549.                             {  
  550.                                 // Unexpected COM exception, throw this to the exception handler.  
  551.                                 throw comExc;  
  552.                             }  
  553.                         }  
  554.                     }  
  555.                 }  
  556.             }  
  557.   
  558.         }  
  559.   
  560.     }  
  561. }  

 

相关代码下载地址,下载完毕后,请使用kuaiya解压即可,WINRAR不行

目录
相关文章
|
9月前
|
定位技术 数据格式
GIS开发:arcgis server发布CGCS2000切片
GIS开发:arcgis server发布CGCS2000切片
154 0
|
9月前
|
SQL 开发框架 数据可视化
ArcGIS Engine学习系列1 AE基础介绍
市面上AE教程大致到ArcGIS10.2,ESRI宣布从ArcGIS10.5开始便停止AE的更新,使用AO做开发,初学者可以在学习C#语言后,从AE入门,逐渐过度到AO。不同版本下AE数据类型数量Enums:枚举类型,用于实现一些定义的内容Structs:结构体Interfaces:接口Classes:类AE开发中,为了更好地管理COM对象,ESRI将这些COM对象放到不同的组件库中。
203 0
|
缓存 定位技术
GIS开发:arcgis server切片数据和wmts
GIS开发:arcgis server切片数据和wmts
124 0
|
XML 存储 定位技术
GIS开发:Arcgis的切片格式
GIS开发:Arcgis的切片格式
152 0
ArcGIS开发手动添加License类
版权声明:欢迎评论和转载,转载请注明来源。 https://blog.csdn.net/zy332719794/article/details/43699511 第一步: 在工程中添加类: 类文件名“LicenseInitializer.
1052 0
|
定位技术
ArcGIS Engine中的Symbols详解
本文由本人翻译ESRI官方帮助文档。尊重劳动成果,转载请注明来源。 Symbols     ArcObjects用了三种类型的Symbol(符号样式)来绘制图形特征:marker symbols(标记符号),line symbols(线符号),和fill symbols(填充符号)。
834 0
|
API 网络架构
ArcGIS API for Silverlight开发中常用问题汇总
下面对于开发中遇到的问题,进行汇总,不断整理补充中,希望对大家有所帮助!   1、在ArcGIS 9.
750 0
|
C++
ArcGIS Engine 10报错:ArcGIS version not specified...
        ArcGIS Engine 10桌面应用程序第一次开发,于是使用VS创建一个简单的AE应用程序,然后拖放一个toolbar、LicenseControl以及MapControl控件。
761 0
|
开发工具
ArcGIS开发帮助文档地址
1、ESRI官方帮助文档 http://resources.arcgis.com/zh-cn/node/1739   http://resources.
687 0
|
API 定位技术 开发工具
ArcGIS API for Silverlight开发入门准备
         微软的Silverlight提供了跨浏览器和跨平台开发环境,在Web中可用于创建和展现富互联网应用(RIA,Rich  Internet Application)。
1044 0