Ejemplo n.º 1
0
        private void toolStripButton1_Click(object sender, EventArgs e)
        {
            FrmAddVersion frmRemark = new FrmAddVersion();

            if (frmRemark.ShowDialog() == DialogResult.OK)
            {
                try
                {
                    int GroupID = this.m_Hook.ProjectTree.FindItem(strLabel);
                    if (GroupID > 0)
                    {
                        ILayer61 lyrModel = this.m_Hook.ProjectTree.GetLayer(GroupID);
                        // string strFile = Guid.NewGuid().ToString() + ".shp";
                        //Application.StartupPath + "\\GuiHua\\Versions\\" + Guid.NewGuid().ToString() + ".Shp";
                        lyrModel.Save();
                        string   strOld = lyrModel.DataSourceInfo.ConnectionString;
                        string[] strs   = strOld.Split(new char[] { ';' }, StringSplitOptions.RemoveEmptyEntries);
                        strOld = strs[0];
                        strOld = strOld.Substring(strOld.IndexOf("=") + 1);

                        string strFolder = System.IO.Path.GetDirectoryName(strOld);
                        string strName   = System.IO.Path.GetFileNameWithoutExtension(strOld);
                        string strSource = strFolder + "\\" + strName;
                        string strTarget = Application.StartupPath + "\\GuiHua\\Versions\\" + Guid.NewGuid().ToString();
                        try
                        {
                            File.Copy(strSource + ".shp", strTarget + ".shp");
                            File.Copy(strSource + ".shx", strTarget + ".shx");
                            File.Copy(strSource + ".dbf", strTarget + ".dbf");
                            File.Copy(strSource + ".shp.xml", strTarget + ".shp.xml");
                            File.Copy(strSource + ".prj", strTarget + ".prj");
                            File.Copy(strSource + ".sbx", strTarget + ".sbx");
                            File.Copy(strSource + ".sbn", strTarget + ".sbn");
                        }
                        catch
                        {
                        }

                        if (ProjectHelper.AddVersion(this.m_ProjectID, strTarget + ".shp", frmRemark.Description))
                        {
                            XtraMessageBox.Show("添加成功");
                            this.Refresh();
                        }
                        else
                        {
                            XtraMessageBox.Show("添加失败");
                        }
                    }
                }
                catch
                {
                    XtraMessageBox.Show("对不起,添加操作出现了错误,这通常是因为配置不当引起的。");
                }
            }
        }
Ejemplo n.º 2
0
        private void toolStripButton1_Click(object sender, EventArgs e)
        {
            FrmAddVersion frmRemark = new FrmAddVersion();
            if (frmRemark.ShowDialog() == DialogResult.OK)
            {
                try
                {
                    int GroupID = this.m_Hook.ProjectTree.FindItem(strLabel);
                    if (GroupID > 0)
                    {
                        ILayer61 lyrModel = this.m_Hook.ProjectTree.GetLayer(GroupID);
                        // string strFile = Guid.NewGuid().ToString() + ".shp";
                        //Application.StartupPath + "\\GuiHua\\Versions\\" + Guid.NewGuid().ToString() + ".Shp";
                        lyrModel.Save();
                        string strOld = lyrModel.DataSourceInfo.ConnectionString;
                        string[] strs = strOld.Split(new char[] { ';' }, StringSplitOptions.RemoveEmptyEntries);
                        strOld = strs[0];
                        strOld = strOld.Substring(strOld.IndexOf("=") + 1);

                        string strFolder = System.IO.Path.GetDirectoryName(strOld);
                        string strName = System.IO.Path.GetFileNameWithoutExtension(strOld);
                        string strSource = strFolder + "\\" + strName;
                        string strTarget = Application.StartupPath + "\\GuiHua\\Versions\\" + Guid.NewGuid().ToString();
                        try
                        {
                            File.Copy(strSource + ".shp", strTarget + ".shp");
                            File.Copy(strSource + ".shx", strTarget + ".shx");
                            File.Copy(strSource + ".dbf", strTarget + ".dbf");
                            File.Copy(strSource + ".shp.xml", strTarget + ".shp.xml");
                            File.Copy(strSource + ".prj", strTarget + ".prj");
                            File.Copy(strSource + ".sbx", strTarget + ".sbx");
                            File.Copy(strSource + ".sbn", strTarget + ".sbn");
                        }
                        catch
                        {
                        }

                        if (ProjectHelper.AddVersion(this.m_ProjectID, strTarget + ".shp", frmRemark.Description))
                        {
                            XtraMessageBox.Show("添加成功");
                            this.Refresh();
                        }
                        else
                        {
                            XtraMessageBox.Show("添加失败");
                        }
                    }
                }
                catch
                {
                    XtraMessageBox.Show("对不起,添加操作出现了错误,这通常是因为配置不当引起的。");
                }
            }
        }