Пример #1
0
        private void btnOK_Click(object sender, EventArgs e)
        {
            Exception eError = null;

            //判断源数据是否连接
            if (this.textBoxUptRange.Text == "")
            {
                SysCommon.Error.ErrorHandle.ShowFrmErrorHandle("提示", "请设置更新范围数据连接");
                return;
            }
            if (this.textBoxUptData.Text == "")
            {
                SysCommon.Error.ErrorHandle.ShowFrmErrorHandle("提示", "请设置更新数据连接");
                return;
            }

            ClsBatchUpdate pClsBatchUpdate = new ClsBatchUpdate();

            //从数据树图中获取现势库和历史库节点
            DevComponents.AdvTree.Node pCurNode = pClsBatchUpdate.GetNodeOfProjectTree(v_AppGIS.ProjectTree, "DB", "现势库");
            DevComponents.AdvTree.Node pHisNode = pClsBatchUpdate.GetNodeOfProjectTree(v_AppGIS.ProjectTree, "DB", "历史库");
            if (pCurNode == null || pHisNode == null)
            {
                return;
            }

            //获取现势库连接
            XmlElement elementTemp   = (pCurNode.Tag as XmlElement).SelectSingleNode(".//连接信息") as XmlElement;
            IWorkspace pCurWorkSpace = ModDBOperator.GetDBInfoByXMLNode(elementTemp, "") as IWorkspace;

            if (pCurWorkSpace == null)
            {
                SysCommon.Error.ErrorHandle.ShowFrmErrorHandle("提示", "连接现势库失败!");
                return;
            }

            //获取历史库连接
            elementTemp = (pHisNode.Tag as XmlElement).SelectSingleNode(".//连接信息") as XmlElement;
            IWorkspace pHisWorkSpace = ModDBOperator.GetDBInfoByXMLNode(elementTemp, "") as IWorkspace;

            if (pHisWorkSpace == null)
            {
                SysCommon.Error.ErrorHandle.ShowFrmErrorHandle("提示", "连接历史库失败!");
                return;
            }

            //获取更新数据库连接
            SysCommon.Gis.SysGisDataSet pUptSysGisDT = new SysCommon.Gis.SysGisDataSet();//更新库连接
            SysCommon.enumWSType        pUptType     = SysCommon.enumWSType.PDB;
            if (this.textBoxUptData.Tag == "PDB")
            {
                pUptType = SysCommon.enumWSType.PDB;
            }
            else if (this.textBoxUptData.Tag == "GDB")
            {
                pUptType = SysCommon.enumWSType.GDB;
            }
            Exception ERR0 = null;

            pUptSysGisDT.SetWorkspace(this.textBoxUptData.Text, pUptType, out ERR0);
            IWorkspace pUptWorkSpace = pUptSysGisDT.WorkSpace;
            //获取更新范围
            IGeometry pUptGeometry = null;

            pUptGeometry = SysCommon.ModPublicFun.GetPolyGonFromFile(this.textBoxUptRange.Text);
            this.Hide();
            FrmProcessBar frmbar = new FrmProcessBar();

            frmbar.Show();
            if (pUptGeometry != null)
            {
                pClsBatchUpdate.DoBatchUpdate(pCurWorkSpace, pHisWorkSpace, pUptWorkSpace, pUptGeometry, pCurNode, pHisNode, frmbar);
            }
            frmbar.Close();
            this.Close();
        }
Пример #2
0
        public override void OnClick()
        {
            if (ModData.v_AppGIS.PolygonSearchGrid.DataSource == null && ModData.v_AppGIS.PolylineSearchGrid.DataSource == null)
            {
                return;
            }
            this.JoinResultTable.Rows.Clear();
            m_Hook.JoinMergeResultGrid.DataSource = null;
            List <IFeatureClass> FeaClsList = m_Hook.PolylineSearchGrid.Tag as List <IFeatureClass>;

            if (null == FeaClsList)
            {
                return;
            }
            IJoinOperation JoinOper = new ClsJoinOperationer();

            JoinOper.JoinFeaClss = FeaClsList;
            FrmProcessBar ProcessBar = new FrmProcessBar();

            ProcessBar.Text = "开始执行接边";//xisheng 20110901
            ProcessBar.Show();
            /////////
            XmlDocument Doc = new XmlDocument();

            Doc.Load(ModData.v_JoinSettingXML);
            bool      IsCreatLog = false;
            Exception ex         = null;

            if (Doc != null)
            {
                XmlElement ele     = Doc.SelectSingleNode(".//日志设置") as XmlElement;
                string     LogPath = ele.GetAttribute("日志路径").Trim();
                if (string.IsNullOrEmpty(LogPath))
                {
                    IsCreatLog = false;
                }
                else
                {
                    IsCreatLog = true;
                }
            }
            if (IsCreatLog)
            {
                IJoinLOG JoinLog = new ClsJoinLog();
                JoinLog.onDataJoin_Start(1, out ex);
                JoinOper.CreatLog = true;
            }
            else
            {
                JoinOper.CreatLog = false;
            }
            /////////
            if (null != m_Hook.PolylineSearchGrid.DataSource)/////线的接边
            {
                GetPolylineTable.Rows.Clear();
                DataTable TemTable = m_Hook.PolylineSearchGrid.DataSource as DataTable;
                for (int i = 0; i < m_Hook.PolylineSearchGrid.Rows.Count; i++)////遍历线型接边搜索表将选中的行记录下来
                {
                    if (m_Hook.PolylineSearchGrid.Rows[i].Cells[0].Value == null)
                    {
                        continue;
                    }
                    if (((bool)m_Hook.PolylineSearchGrid.Rows[i].Cells[0].Value) == true)
                    {
                        GetPolylineTable.Rows.Add(TemTable.Rows[i].ItemArray);
                    }
                }
                if (null != GetPolylineTable)
                {
                    DataTable mergeTable = JoinOper.MovePolylinePnt(GetPolylineTable);
                    if (null != mergeTable)
                    {
                        ProcessBar.SetFrmProcessBarMax(mergeTable.Rows.Count);
                        for (int i = 0; i < mergeTable.Rows.Count; i++)
                        {
                            ProcessBar.SetFrmProcessBarText("正在进行线的接边:");
                            ProcessBar.SetFrmProcessBarValue(i);
                            System.Windows.Forms.Application.DoEvents();
                            this.JoinResultTable.Rows.Add(mergeTable.Rows[i].ItemArray);
                        }
                    }
                }
            }
            if (null != m_Hook.PolygonSearchGrid.DataSource)/////多边形的接边
            {
                GetPolygonTable.Rows.Clear();
                DataTable TemTable = m_Hook.PolygonSearchGrid.DataSource as DataTable;
                for (int i = 0; i < m_Hook.PolygonSearchGrid.Rows.Count; i++)////遍历线型接边搜索表将选中的行记录下来
                {
                    if (m_Hook.PolygonSearchGrid.Rows[i].Cells[0].Value == null)
                    {
                        continue;
                    }
                    if (((bool)m_Hook.PolygonSearchGrid.Rows[i].Cells[0].Value) == true)
                    {
                        GetPolygonTable.Rows.Add(TemTable.Rows[i].ItemArray);
                    }
                }
                if (null != GetPolygonTable)
                {
                    DataTable mergeTable = JoinOper.MovePolygonPnt(GetPolygonTable);
                    if (null != mergeTable)
                    {
                        ProcessBar.SetFrmProcessBarMax(mergeTable.Rows.Count);
                        for (int i = 0; i < mergeTable.Rows.Count; i++)
                        {
                            ProcessBar.SetFrmProcessBarText("正在进行多边形的接边:");
                            ProcessBar.SetFrmProcessBarValue(i);
                            System.Windows.Forms.Application.DoEvents();
                            this.JoinResultTable.Rows.Add(mergeTable.Rows[i].ItemArray);
                        }
                    }
                }
            }
            //m_Hook.PolylineSearchGrid.DataSource = null;
            //m_Hook.PolygonSearchGrid.DataSource = null;
            if (IsCreatLog)
            {
                IJoinLOG JoinLog = new ClsJoinLog();
                JoinLog.onDataJoin_Terminate(1, out ex);
            }
            m_Hook.JoinMergeResultGrid.DataSource = this.JoinResultTable;
            ControlsDataJoinSearch.SelectALL(m_Hook.JoinMergeResultGrid);
            ProcessBar.Close();
        }
Пример #3
0
        public override void OnClick()
        {
            /*  执行接边要素的搜索
             *  基本过程:
             *    1.获取基本参数信息:图幅结合表的图层、参与接边图层列表、接边参数(从配置xml文件中获取);
             *    2.实现IMapframe接口,通过接口获取接边的源、目标缓冲区域、接边边界;
             *    3.(接边要素粗选)实现IDestinatDataset接口,使用(2)返回的缓冲区域通过接口获取待接边源要素、目标要素的OID集合;
             *    4.(接边要素精选)实现ICheckOperation接口,通过接口在步骤(3)的OID集合中判断接边情况和属性匹配情况(若FieldsControlList不赋值,则不进行属性控制);
             *    5.将接口ICheckOperation返回的信息反映到界面上。
             */
            frmJoinFeaSearch FeaSearch      = new frmJoinFeaSearch();
            List <string>    JoinFeaClsName = null;
            Dictionary <string, List <string> > JoinField = new Dictionary <string, List <string> >();//////接边控制字段
            string MapFrameName  = string.Empty;
            string MapFrameField = "";

            if (System.Windows.Forms.DialogResult.OK == FeaSearch.ShowDialog())
            {
                JoinFeaClsName = FeaSearch.JoinLayerName;
                JoinField      = FeaSearch.FieldDic;
                MapFrameName   = FeaSearch.MapFrameName;
                MapFrameField  = FeaSearch.MapFrameField;
                IFeatureClass MapFrameFeaClss = null;
                #region 获取图幅范围
                int layercount = m_Hook.ArcGisMapControl.LayerCount;
                for (int i = 0; i < layercount; i++)
                {
                    ILayer getlayer = m_Hook.ArcGisMapControl.get_Layer(i);
                    if (getlayer.Name == MapFrameName)
                    {
                        IFeatureLayer FeaLayer = getlayer as IFeatureLayer;
                        MapFrameFeaClss = FeaLayer.FeatureClass;
                    }
                }
                #endregion
                List <IFeatureClass> JoinFeaCls = new List <IFeatureClass>();
                m_Hook.PolylineSearchGrid.Tag = JoinFeaCls;//////将待接边的图层列表挂在PolylineSearchGrid.Tag上供使用
                #region 获取接边图层列表
                layercount = m_Hook.ArcGisMapControl.LayerCount;
                for (int i = 0; i < layercount; i++)
                {
                    ILayer getlayer = m_Hook.ArcGisMapControl.get_Layer(i);
                    if (JoinFeaClsName.Contains(getlayer.Name))
                    {
                        IFeatureLayer FeaLayer   = getlayer as IFeatureLayer;
                        IFeatureClass getFeaClss = FeaLayer.FeatureClass;
                        JoinFeaCls.Add(getFeaClss);
                    }
                }
                #endregion
                double dDisTo     = -1;
                double dSeacherTo = -1;
                double dAngleTo   = -1;
                double dLengthTo  = -1;
                #region 获取接边参数
                XmlDocument XmlDoc = new XmlDocument();
                XmlDoc.Load(ModData.v_JoinSettingXML);
                if (null == XmlDoc)
                {
                    SysCommon.Error.ErrorHandle.ShowFrmErrorHandle("提示", "获取接边参数配置文件失败!");
                    return;
                }
                XmlElement ele = XmlDoc.SelectSingleNode(".//接边设置") as XmlElement;

                string sDisTo       = ele.GetAttribute("距离容差");
                string sSeacherTo   = ele.GetAttribute("搜索容差");
                string sAngleTo     = ele.GetAttribute("角度容差");
                string sLengthTo    = ele.GetAttribute("长度容差");
                string sJoinType    = ele.GetAttribute("接边类型");
                string sIsRemovePnt = ele.GetAttribute("删除多边形多余点").Trim();
                string sIsSimplify  = ele.GetAttribute("简单化要素").Trim();
                try
                {
                    dDisTo     = Convert.ToDouble(sDisTo);
                    dSeacherTo = Convert.ToDouble(sSeacherTo);
                    dAngleTo   = Convert.ToDouble(sAngleTo);
                    dLengthTo  = Convert.ToDouble(sLengthTo);
                }
                catch
                {
                    SysCommon.Error.ErrorHandle.ShowFrmErrorHandle("提示", "接边参数配置文件中参数不正确!");
                    return;
                }
                #endregion
                if (MapFrameFeaClss == null)
                {
                    return;
                }
                int            max          = MapFrameFeaClss.FeatureCount(null);
                IFeatureCursor JoinFrameCur = MapFrameFeaClss.Search(null, false);
                IFeature       MapFrameFea  = JoinFrameCur.NextFeature();

                IMapframe pMapframe = null;//////////接边图幅类初始化(标准图幅接边或非标准图幅接边)
                if (sJoinType == "标准图幅")
                {
                    pMapframe = new ClsMapFrame();
                }
                else
                {
                    pMapframe = new ClsTaskFrame();
                }
                pMapframe.MapFrameFea = MapFrameFeaClss;
                FrmProcessBar ProcessBar = new FrmProcessBar(max);
                ProcessBar.Show();
                ProcessBar.SetFrmProcessBarText("正在搜索接边要素");
                long value = 0;
                this.m_PolyLineSearchTable.Rows.Clear();
                this.m_PolygonSearchTable.Rows.Clear();
                IDestinatDataset DesData = null;
                if (sJoinType == "标准图幅")
                {
                    DesData = new ClsDestinatDataset(true);/////标准图幅接边搜索
                }
                else
                {
                    DesData = new ClsDestinatDataset(false);/////非标准图幅接边搜索
                }
                /////////////////////////////////
                DesData.Angle_to = dAngleTo;
                if (sIsRemovePnt == "Y")//////删除多边形上多余的点
                {
                    DesData.IsRemoveRedundantPnt = true;
                }
                else
                {
                    DesData.IsRemoveRedundantPnt = false;
                }

                if (sIsSimplify == "Y")///////要素简单化(针对有多个geometry的要素)
                {
                    DesData.IsGeometrySimplify = true;
                }
                else
                {
                    DesData.IsGeometrySimplify = false;
                }
                //////////////////////////////////////
                ele = XmlDoc.SelectSingleNode(".//日志设置") as XmlElement;
                string sLogPath = ele.GetAttribute("日志路径").Trim();



                DesData.JoinFeatureClass = JoinFeaCls;
                //////遍历每一个图幅搜索接边要素/////
                if (!string.IsNullOrEmpty(sLogPath))
                {
                    IJoinLOG  JoinLog = new ClsJoinLog();
                    Exception ex      = null;
                    JoinLog.onDataJoin_Start(0, out ex);
                }
                while (MapFrameFea != null)
                {
                    value += 1;
                    ProcessBar.SetFrmProcessBarValue(value);
                    Application.DoEvents();
                    int    index = MapFrameFea.Fields.FindField(MapFrameField);
                    string No    = string.Empty;
                    try
                    {
                        if (index > 0)
                        {
                            No = MapFrameFea.get_Value(index).ToString();
                        }
                    }
                    catch
                    {
                        No = string.Empty;
                    }
                    ProcessBar.SetFrmProcessBarText("正在处理图幅:" + No);
                    Application.DoEvents();
                    pMapframe.OriMapFrame = MapFrameFea;

                    IGeometry OriArea = null;
                    IGeometry DesArea = null;
                    ProcessBar.SetFrmProcessBarText("正在处理图幅:" + No + "正在生成缓冲区");
                    Application.DoEvents();
                    try
                    {
                        pMapframe.GetBufferArea(dDisTo, out OriArea, out DesArea);
                    }
                    catch
                    {
                        SysCommon.Error.ErrorHandle.ShowFrmErrorHandle("提示!", "生成接边搜索缓冲区失败!\n请检查图幅范围图层是否设置正确。");
                        ProcessBar.Close();
                        return;
                    }
                    ////////////////////////////////////
                    //IElement ele2 = null;
                    //IPolygonElement pPolElemnt = new PolygonElementClass();
                    //IFillShapeElement pFillShapeElement = (IFillShapeElement)pPolElemnt;
                    //pFillShapeElement.Symbol = GetDrawSymbol(0, 255, 0);
                    //ele2 = pFillShapeElement as IElement;
                    //ele2.Geometry = DesArea;
                    //IGraphicsContainer pMapGraphics = (IGraphicsContainer)m_Hook.ArcGisMapControl.Map;
                    //pMapGraphics.AddElement(ele2, 0);
                    //m_Hook.ArcGisMapControl.ActiveView.Refresh();

                    //IElement ele3 = null;
                    //pPolElemnt = new PolygonElementClass();
                    //pFillShapeElement = (IFillShapeElement)pPolElemnt;
                    //pFillShapeElement.Symbol = GetDrawSymbol(255, 0, 0);
                    //ele3 = pFillShapeElement as IElement;
                    //ele3.Geometry = OriArea;
                    ////IGraphicsContainer pMapGraphics = (IGraphicsContainer)this.axMapControl.Map;
                    //pMapGraphics.AddElement(ele3, 0);

                    /////////////////////////////////////
                    if (!string.IsNullOrEmpty(No))
                    {
                        ProcessBar.SetFrmProcessBarText("正在处理图幅:" + No + ",正在获取接边要素");
                    }
                    else
                    {
                        ProcessBar.SetFrmProcessBarText("正在获取接边要素");
                    }
                    Application.DoEvents();
                    Dictionary <string, List <long> > OriOidDic = DesData.GetFeaturesByGeometry(OriArea, true);  ////接边源要素记录
                    Dictionary <string, List <long> > DesOidDic = DesData.GetFeaturesByGeometry(DesArea, false); ////接边目标要素记录
                    ICheckOperation CheckOper = new ClsCheckOperationer();
                    CheckOper.Angel_Tolerrance  = dAngleTo;                                                      /////////////角度容差
                    CheckOper.borderline        = pMapframe.Getborderline();                                     //接边边界
                    CheckOper.Dis_Tolerance     = dDisTo;                                                        //////////////////距离容差
                    CheckOper.Search_Tolerrance = dSeacherTo;                                                    //////////搜索容差
                    CheckOper.Length_Tolerrance = dLengthTo;                                                     ///////////长度容差
                    CheckOper.DesBufferArea     = DesArea;                                                       /////////////////目标搜索缓冲区
                    CheckOper.OriBufferArea     = OriArea;                                                       /////////////////源搜索缓冲区

                    if (!string.IsNullOrEmpty(sLogPath))
                    {
                        CheckOper.CreatLog = true;
                    }
                    else
                    {
                        CheckOper.CreatLog = false;
                    }
                    if (null != OriOidDic)
                    {
                        foreach (KeyValuePair <string, List <long> > item in OriOidDic)
                        {
                            string OriFeaName = item.Key;
                            if (!string.IsNullOrEmpty(No))
                            {
                                ProcessBar.SetFrmProcessBarText("正在处理图幅:" + No + ",正在搜索图层:" + OriFeaName);
                            }
                            else
                            {
                                ProcessBar.SetFrmProcessBarText("正在搜索图层:" + OriFeaName);
                            }
                            Application.DoEvents();
                            List <long> OriFeaOIDL = item.Value;
                            List <long> DesFeaOIDL = null;
                            if (DesOidDic == null)
                            {
                                continue;
                            }
                            if (DesOidDic.ContainsKey(OriFeaName))
                            {
                                DesFeaOIDL = DesOidDic[OriFeaName];
                            }
                            if (null != OriFeaOIDL && null != DesFeaOIDL)
                            {
                                CheckOper.DesFeaturesOID = DesFeaOIDL;
                                CheckOper.OriFeaturesOID = OriFeaOIDL;
                                IFeatureClass JoinFea = DesData.TargetFeatureClass(OriFeaName);
                                if (null != JoinFeaCls)
                                {
                                    CheckOper.DestinatFeaCls = JoinFea;
                                    if (null != JoinField)
                                    {
                                        foreach (KeyValuePair <string, List <string> > getitem in JoinField)
                                        {
                                            if (getitem.Key == (JoinFea as IDataset).Name)
                                            {
                                                CheckOper.FieldsControlList = getitem.Value;
                                            }
                                        }
                                    }
                                    esriGeometryType GeoType = CheckOper.GetDatasetGeometryType();
                                    if (GeoType == esriGeometryType.esriGeometryPolyline)
                                    {
                                        if (!string.IsNullOrEmpty(No))
                                        {
                                            ProcessBar.SetFrmProcessBarText("正在处理图幅:" + No + ",正在搜索图层:" + OriFeaName + ",操作:线型要素记录");
                                        }
                                        else
                                        {
                                            ProcessBar.SetFrmProcessBarText("正在搜索图层:" + OriFeaName + ",操作:线型要素记录");
                                        }
                                        Application.DoEvents();
                                        DataTable table = CheckOper.GetPolylineDesFeatureOIDByOriFeature();
                                        if (null != table)
                                        {
                                            for (int i = 0; i < table.Rows.Count; i++)
                                            {
                                                if (!string.IsNullOrEmpty(No))
                                                {
                                                    ProcessBar.SetFrmProcessBarText("正在处理图幅:" + No + "正在搜索图层:" + OriFeaName + ",操作:添加记录到列表");
                                                }
                                                else
                                                {
                                                    ProcessBar.SetFrmProcessBarText("正在搜索图层:" + OriFeaName + ",操作:添加记录到列表");
                                                }
                                                Application.DoEvents();
                                                this.m_PolyLineSearchTable.Rows.Add(table.Rows[i].ItemArray);
                                            }
                                        }
                                    }
                                    if (GeoType == esriGeometryType.esriGeometryPolygon)
                                    {
                                        if (!string.IsNullOrEmpty(No))
                                        {
                                            ProcessBar.SetFrmProcessBarText("正在处理图幅:" + No + "正在搜索图层:" + OriFeaName + ",操作:多边形要素记录");
                                        }
                                        else
                                        {
                                            ProcessBar.SetFrmProcessBarText("正在搜索图层:" + OriFeaName + ",操作:多边形要素记录");
                                        }
                                        Application.DoEvents();
                                        DataTable table = CheckOper.GetPolygonDesFeatureOIDByOriFeature();
                                        if (null != table)
                                        {
                                            for (int i = 0; i < table.Rows.Count; i++)
                                            {
                                                if (!string.IsNullOrEmpty(No))
                                                {
                                                    ProcessBar.SetFrmProcessBarText("正在处理图幅:" + No + "正在搜索图层:" + OriFeaName + ",操作:添加记录到列表");
                                                }
                                                else
                                                {
                                                    ProcessBar.SetFrmProcessBarText("正在搜索图层:" + OriFeaName + ",操作:添加记录到列表");
                                                }
                                                Application.DoEvents();
                                                this.m_PolygonSearchTable.Rows.Add(table.Rows[i].ItemArray);
                                            }
                                        }
                                    }
                                }
                            }
                        }
                    }
                    MapFrameFea = JoinFrameCur.NextFeature();
                }
                if (!string.IsNullOrEmpty(sLogPath))
                {
                    IJoinLOG  JoinLog = new ClsJoinLog();
                    Exception ex      = null;
                    JoinLog.onDataJoin_Terminate(0, out ex);
                }
                m_Hook.PolygonSearchGrid.DataSource  = null;
                m_Hook.PolylineSearchGrid.DataSource = null;
                m_Hook.PolygonSearchGrid.DataSource  = this.m_PolygonSearchTable;
                m_Hook.PolylineSearchGrid.DataSource = this.m_PolyLineSearchTable;
                SelectALL(m_Hook.PolylineSearchGrid);
                SelectALL(m_Hook.PolygonSearchGrid);
                MessageBox.Show("线记录个数:" + this.m_PolyLineSearchTable.Rows.Count + ";面记录个数:" + this.m_PolygonSearchTable.Rows.Count);
                ProcessBar.Close();
            }
        }
Пример #4
0
        public override void OnClick()
        {
            if (m_Hook.JoinMergeResultGrid.DataSource == null)
            {
                return;
            }
            if (((DataTable)m_Hook.JoinMergeResultGrid.DataSource).TableName != "JoinResultTable")
            {
                return;
            }
            List <IFeatureClass> MergeFeaClsList = null;
            ////////获取融合参数///////
            XmlDocument XmlDoc = new XmlDocument();

            XmlDoc.Load(ModData.v_JoinSettingXML);
            if (null == XmlDoc)
            {
                SysCommon.Error.ErrorHandle.ShowFrmErrorHandle("提示", "获取融合参数配置文件失败!");
                return;
            }
            XmlElement ele            = XmlDoc.SelectSingleNode(".//融合设置") as XmlElement;
            string     sIsDesAtrToOri = ele.GetAttribute("属性覆盖").Trim();

            ////////

            MergeFeaClsList = m_Hook.PolylineSearchGrid.Tag as List <IFeatureClass>;
            if (null == MergeFeaClsList)
            {
                return;
            }
            IMergeOperation Meroper = new ClsMergeOperationer();

            Meroper.JoinFeaClss = MergeFeaClsList;
            //////////融合要素属性处理选择////////
            if (sIsDesAtrToOri == "Y")
            {
                Meroper.SetDesValueToOri = true;
            }
            else
            {
                Meroper.SetDesValueToOri = false;
            }
            /////////日志
            bool      IsCreatLog = false;
            Exception ex         = null;

            if (XmlDoc != null)
            {
                XmlElement ele2    = XmlDoc.SelectSingleNode(".//日志设置") as XmlElement;
                string     LogPath = ele2.GetAttribute("日志路径").Trim();
                if (string.IsNullOrEmpty(LogPath))
                {
                    IsCreatLog       = false;
                    Meroper.CreatLog = false;
                }
                else
                {
                    IsCreatLog       = true;
                    Meroper.CreatLog = true;
                }
                //////////////////日志中属性处理记录信息
                string sAttriPro = string.Empty;
                if (sIsDesAtrToOri == "Y")
                {
                    sAttriPro = "覆盖";
                }
                else
                {
                    sAttriPro = "累加";
                }
                /////////////若日志存在则记录到日志当中
                if (!string.IsNullOrEmpty(LogPath))
                {
                    try
                    {
                        XmlDocument Doc = new XmlDocument();
                        Doc.Load(LogPath);
                        if (null != Doc)
                        {
                            XmlElement Setele = Doc.SelectSingleNode(".//融合操作/参数") as XmlElement;
                            Setele.SetAttribute("属性处理", sAttriPro);
                            Doc.Save(LogPath);
                        }
                    }
                    catch
                    {
                    }
                }
            }
            if (IsCreatLog)
            {
                IJoinLOG JoinLog = new ClsJoinLog();
                JoinLog.onDataJoin_Start(2, out ex);
            }
            /////////
            DataTable  UnionResTable = new DataTable();
            DataColumn dc1           = new DataColumn("数据集", Type.GetType("System.String"));
            DataColumn dc2           = new DataColumn("要素类型", Type.GetType("System.String"));
            DataColumn dc3           = new DataColumn("源要素ID", Type.GetType("System.Int64"));

            dc3.DefaultValue = -1;
            DataColumn dc4 = new DataColumn("目标要素ID", Type.GetType("System.Int64"));

            dc4.DefaultValue = -1;
            DataColumn dc5 = new DataColumn("处理结果", Type.GetType("System.String"));

            UnionResTable.Columns.Add(dc1);
            UnionResTable.Columns.Add(dc2);
            UnionResTable.Columns.Add(dc3);
            UnionResTable.Columns.Add(dc4);
            UnionResTable.Columns.Add(dc5);
            DataTable JoinResultTable = m_Hook.JoinMergeResultGrid.DataSource as DataTable;

            /////////////////
            // DataTable UnionResTable = JoinResultTable;
            UnionResTable.TableName = "MergeResultTable";
            //  UnionResTable.Rows.Clear();
            if (JoinResultTable != null) //////融合操作(考虑多个要素相互融合的情况)
            {
                FrmProcessBar ProcessBar = new FrmProcessBar(JoinResultTable.Rows.Count);
                int           max        = JoinResultTable.Rows.Count;
                ProcessBar.Show();

                while (JoinResultTable.Rows.Count > 0)
                {
                    List <int>  lDeleRowNo = new List <int>();
                    long        OriFeaOID  = -1;
                    List <long> lDesFeaOID = new List <long>();
                    /////获取第一行
                    string DataSetName = string.Empty;
                    string type        = string.Empty;
                    long   OriOID      = -1;
                    long   DesOID      = -1;
                    string result      = string.Empty;
                    try
                    {
                        DataSetName = JoinResultTable.Rows[0]["数据集"].ToString().Trim();
                        type        = JoinResultTable.Rows[0]["要素类型"].ToString().Trim();
                        OriOID      = Convert.ToInt64(JoinResultTable.Rows[0]["源要素ID"].ToString());
                        DesOID      = Convert.ToInt64(JoinResultTable.Rows[0]["目标要素ID"].ToString());
                        result      = JoinResultTable.Rows[0]["处理结果"].ToString().Trim();
                    }
                    catch
                    {
                        return;
                    }
                    OriFeaOID = OriOID;
                    ProcessBar.SetFrmProcessBarText("处理要素:" + OriFeaOID);
                    ProcessBar.SetFrmProcessBarValue(max - JoinResultTable.Rows.Count);
                    System.Windows.Forms.Application.DoEvents();
                    if (result == "已接边")
                    {
                        lDesFeaOID.Add(DesOID);
                    }
                    lDeleRowNo.Add(0);
                    /////遍历剩下的行,若存在互接边关系记录到融合列表中,同时记录下这些行进行删除
                    #region 遍历剩下的行,若存在互接边关系记录到融合列表中,同时记录下这些行进行删除
                    //////做两次检索避免遗漏(当一条线多次穿越接边边界时,一次循环检索可能会遗漏部分融合要素,两次循环使遗漏减至最少)
                    GetAllunionFea(OriOID, ref lDesFeaOID, ref lDeleRowNo, JoinResultTable, type, DataSetName);
                    GetAllunionFea(OriOID, ref lDesFeaOID, ref lDeleRowNo, JoinResultTable, type, DataSetName);
                    #endregion
                    //////融合记录列表中的要素
                    string sunionres = string.Empty;
                    #region  融合记录列表中的要素
                    if (lDesFeaOID != null && OriFeaOID != -1)
                    {
                        for (int i = 0; i < lDesFeaOID.Count; i++)
                        {
                            long UnioOid = lDesFeaOID[i];
                            ProcessBar.SetFrmProcessBarText("融合要素:" + OriFeaOID + "," + UnioOid);
                            System.Windows.Forms.Application.DoEvents();
                            if (type == "Polyline")
                            {
                                if (Meroper.MergePolyline(DataSetName, OriFeaOID, UnioOid))
                                {
                                    sunionres = "已融合";
                                }
                                else
                                {
                                    sunionres = "未融合";
                                }
                            }
                            else if (type == "Polygon")
                            {
                                if (Meroper.MergePolygon(DataSetName, OriFeaOID, UnioOid))
                                {
                                    sunionres = "已融合";
                                }
                                else
                                {
                                    sunionres = "未融合";
                                }
                            }
                        }
                    }
                    #endregion
                    DataRow addrow = UnionResTable.NewRow();
                    addrow["数据集"]    = DataSetName;
                    addrow["要素类型"]   = type;
                    addrow["源要素ID"]  = OriFeaOID;
                    addrow["目标要素ID"] = 0;
                    addrow["处理结果"]   = sunionres;
                    UnionResTable.Rows.Add(addrow);

                    #region  除行
                    if (null != lDeleRowNo)
                    {
                        for (int i = 0; i < lDeleRowNo.Count; i++)
                        {
                            JoinResultTable.Rows.Remove(JoinResultTable.Rows[lDeleRowNo[i] - i]);
                        }
                    }
                    #endregion
                }
                ProcessBar.Close();
            }
            if (IsCreatLog)
            {
                IJoinLOG JoinLog = new ClsJoinLog();
                JoinLog.onDataJoin_Terminate(2, out ex);
            }
            //// JoinResultTable.TableName = "MergeResultTable";
            //// ((DataTable)m_Hook.JoinMergeResultGrid.DataSource).TableName = "MergeResultTable";
            m_Hook.JoinMergeResultGrid.DataSource = UnionResTable;
            ControlsDataJoinSearch.SelectALL(m_Hook.JoinMergeResultGrid); //选择所有;xisheng 20110901
        }
Пример #5
0
        /// <summary>
        /// 下载文件
        /// </summary>
        /// <param name="ftpfilepath">相对根目录的文件完整路径</param>
        /// <param name="filePath">本地保存文件的完整路径</param>
        /// <param name="fileName">文件名</param>
        /// <returns></returns>
        public bool Download(string ftpfilepath, string filePath, string fileName, out string errorinfo)////上面的代码实现了从ftp服务器下载文件的功能
        {
            Exception ex = null;

            errorinfo = "";
            FrmProcessBar ProcBar = new FrmProcessBar();

            ProcBar.Show();
            try
            {
                filePath = filePath.Replace("我的电脑\\", "");
                String onlyFileName = Path.GetFileName(fileName);
                string newFileName  = filePath;
                if (File.Exists(newFileName))
                {
                    errorinfo = string.Format("本地文件{0}已存在,无法下载", newFileName);
                    return(false);
                }
                ftpfilepath = ftpfilepath.Replace("\\", "/");
                string url = "ftp://" + ftpServerIP + "/" + ftpfilepath;
                Connect(url);//连接
                reqFTP.Credentials = new NetworkCredential(ftpUserID, ftpPassword);
                reqFTP.KeepAlive   = false;
                reqFTP.Timeout     = 10000;
                FtpWebResponse response   = (FtpWebResponse)reqFTP.GetResponse();
                Stream         ftpStream  = response.GetResponseStream();
                long           cl         = response.ContentLength;
                int            bufferSize = 2048;

                int    readCount;
                byte[] buffer = new byte[bufferSize];
                readCount = ftpStream.Read(buffer, 0, bufferSize);
                FileStream outputStream = new FileStream(newFileName, FileMode.Create);
                long       ProcBarValue = 0;
                //////
                long all = GetFileSize(ftpfilepath, out ex);
                {
                    if (null != ex)
                    {
                        return(false);
                    }
                }
                ProcBar.SetFrmProcessBarMax(all / 2048);
                //////
                while (readCount > 0)
                {
                    ProcBarValue++;
                    ProcBar.SetFrmProcessBarText("正在下载文件:" + fileName);
                    ProcBar.SetFrmProcessBarValue(ProcBarValue);
                    Application.DoEvents();
                    outputStream.Write(buffer, 0, readCount);
                    readCount = ftpStream.Read(buffer, 0, bufferSize);
                }
                ftpStream.Close();
                outputStream.Close();
                response.Close();
                errorinfo = "Succeed";
                return(true);
            }
            catch (Exception exx)
            {
                errorinfo = string.Format("因{0},无法下载", exx.Message);
                return(false);
            }
            finally
            {
                ProcBar.Dispose();
                ProcBar.Close();
            }
        }
Пример #6
0
        /// <summary>
        /// 续传文件
        /// </summary>
        /// <param name="filename"></param>
        public bool Upload(string filename, long size, string path, out string errorinfo) //上面的代码实现了从ftp服务器上载文件的功能
        {
            FrmProcessBar frmbar = new FrmProcessBar();

            frmbar.Show();
            path = path.Replace("\\", "/");
            FileInfo fileInf = new FileInfo(filename);
            //string uri = "ftp://" + path + "/" + fileInf.Name;
            string uri = "ftp://" + ftpServerIP + "/" + path + filename;

            Connect(uri);//连接
            // 默认为true,连接不会被关闭
            // 在一个命令之后被执行
            reqFTP.KeepAlive = false;
            reqFTP.Timeout   = 10000;
            // 指定执行什么命令
            reqFTP.Method = WebRequestMethods.Ftp.AppendFile;
            // 上传文件时通知服务器文件的大小
            reqFTP.ContentLength = fileInf.Length;
            // 缓冲大小设置为kb
            long procMax = (fileInf.Length - size) / 2048;

            frmbar.SetFrmProcessBarMax(procMax);
            frmbar.SetFrmProcessBarText("正在续传文件:" + filename);
            int buffLength = 2048;

            byte[] buff = new byte[buffLength];
            int    contentLen;
            // 打开一个文件流(System.IO.FileStream) 去读上传的文件
            FileStream fs    = fileInf.OpenRead();
            int        value = 0;

            try
            {
                StreamReader dsad = new StreamReader(fs);
                fs.Seek(size, SeekOrigin.Begin);
                // 把上传的文件写入流
                Stream strm = reqFTP.GetRequestStream();
                // 每次读文件流的kb
                contentLen = fs.Read(buff, 0, buffLength);
                // 流内容没有结束
                while (contentLen != 0)
                {
                    // 把内容从file stream 写入upload stream
                    value++;
                    frmbar.SetFrmProcessBarValue(value);
                    Application.DoEvents();
                    strm.Write(buff, 0, contentLen);
                    contentLen = fs.Read(buff, 0, buffLength);
                }
                // 关闭两个流
                strm.Close();
                fs.Close();
                errorinfo = "Succeed";
                return(true);
            }
            catch (Exception ex)
            {
                errorinfo = string.Format("因{0},无法完成上传", ex.Message);
                return(false);
            }
            finally
            {
                if (null != fileInf)
                {
                    fileInf = null;
                }
                frmbar.Close();
                frmbar.Dispose();
            }
        }
Пример #7
0
        public void DoBatchUpdate(IWorkspace pCurWorkSpace, IWorkspace pHisWorkSpace, IWorkspace pUptWorkSpace, IGeometry pUptGeometry, DevComponents.AdvTree.Node pCurNode, DevComponents.AdvTree.Node pHisNode, FrmProcessBar frmbar)
        {
            IFeatureWorkspace pCurFeaWKS = pCurWorkSpace as IFeatureWorkspace;
            IFeatureWorkspace pHisFeaWKS = pHisWorkSpace as IFeatureWorkspace;
            IFeatureWorkspace pUptFeaWKS = pUptWorkSpace as IFeatureWorkspace;
            int barcnt = 0;

            frmbar.SetFrmProcessBarMax(100);
            frmbar.SetFrmProcessBarText("正在执行范围更新");
            int FDcnt = pCurNode.Nodes.Count;

            for (int i = 0; i < pCurNode.Nodes.Count; i++)
            {
                DevComponents.AdvTree.Node pTmpNode = pCurNode.Nodes[i];
                if (pTmpNode.DataKeyString == "FD")
                {
                    DevComponents.AdvTree.Node pTmpHisNode = GetHisNodeOfProjectTree(pHisNode, "FD", pTmpNode.Text);
                    int FCcnt = pTmpNode.Nodes.Count;
                    for (int j = 0; j < pTmpNode.Nodes.Count; j++)
                    {
                        DevComponents.AdvTree.Node pFCnode = pTmpNode.Nodes[j];
                        if (pFCnode.DataKeyString == "FC")
                        {
                            DevComponents.AdvTree.Node pHisFCnode = GetHisNodeOfProjectTree(pTmpHisNode, "FC", pFCnode.Text);
                            IFeatureClass pCurFeatureClass        = pCurFeaWKS.OpenFeatureClass(pFCnode.Text);
                            IFeatureClass pHisFeatureClass        = null;
                            if (pHisFCnode != null)
                            {
                                pHisFeatureClass = pHisFeaWKS.OpenFeatureClass(pHisFCnode.Text);
                            }
                            IFeatureClass pUptFeatureClass = null;
                            pUptFeatureClass = pUptFeaWKS.OpenFeatureClass(pFCnode.Text);
                            if (pHisFeatureClass != null && pUptFeatureClass != null)
                            {
                                double dValue = (i + 1) / FDcnt * (j + 1) / FCcnt * 100;
                                int    value  = (int)(Math.Floor(dValue));
                                if (value > barcnt)
                                {
                                    frmbar.SetFrmProcessBarValue(value);
                                    Application.DoEvents();
                                    barcnt = value;
                                }
                                frmbar.SetFrmProcessBarText("写历史库:" + pFCnode.Text);
                                WriteHisOfFeatureClass(pCurFeatureClass, pHisFeatureClass, pUptGeometry);
                                frmbar.SetFrmProcessBarText("更新现状数据:" + pFCnode.Text);
                                DoUpdateOfFeatureClass(pCurFeatureClass, pUptFeatureClass, pUptGeometry);
                            }
                        }
                    }
                }
            }
        }