Exemplo n.º 1
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);
                            }
                        }
                    }
                }
            }
        }
Exemplo n.º 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();
        }
Exemplo n.º 3
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();
            }
        }
Exemplo n.º 4
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();
            }
        }