Esempio n. 1
0
        private void tlProject_FocusedNodeChanged(object sender, DevExpress.XtraTreeList.FocusedNodeChangedEventArgs e)
        {
            m_CurrentProject = null;
            if (this.tlProject.FocusedNode != null)
                m_CurrentProject = this.tlProject.FocusedNode.Tag as ProjectInfo;

            if (this.FocusedProjectChanged != null)
                this.FocusedProjectChanged.Invoke(m_CurrentProject);
        }
Esempio n. 2
0
 private void ucPorject1_FocusedProjectChanged(ProjectInfo projectInfo)
 {
     this.m_SelectedProject = projectInfo;
     btnDelete.Enabled = btnOpen.Enabled = (m_SelectedProject != null);
 }
Esempio n. 3
0
        public static bool AddProjectInfo(ProjectInfo projectInfo)
        {
            if (projectInfo == null)
                return false;

            string projectID = Guid.NewGuid().ToString("N");
            string strSQL = @"Insert into GH_Project(
                                                        ProjectID,
                                                        ProjectName ,
                                                        ProjectType ,
                                                        Enterprise ,
                                                        ProjectAdrress ,
                                                        ProjectFolder,
                                                        ProjectFile
                                                    )
                                               values(
                                                        '{0}',
                                                        '{1}',
                                                        '{2}',
                                                        '{3}',
                                                        '{4}',
                                                        '{5}',
                                                        '{6}'
                                                      )";

            object[] objArgs ={
                                 projectID,
                                 projectInfo.Name,
                                 projectInfo.Type,
                                 projectInfo.Enterprise,
                                 projectInfo.Address,
                                 projectInfo.Folder,
                                 projectInfo.File
                             };

            try
            {
                Environment.AdodbHelper.ExecuteSQL(string.Format(strSQL, objArgs));
            }
            catch
            {
                return false;
            }

            foreach (SchemaInfo schemaInfo in projectInfo.Schemas)
            {
                strSQL = @"Insert into GH_Schema(
                                                    SchemaID,
                                                    SchemaName,
                                                    SchemaType ,
                                                    BuildingArea ,
                                                    VegetationArea,
                                                    RoadArea ,
                                                    ProjectID ,
                                                    SchemaFolder ,
                                                    SchemaFile

                                                )
                                          values(
                                                    '{0}',
                                                    '{1}',
                                                    '{2}',
                                                    {3},
                                                    {4},
                                                    {5},
                                                    '{6}',
                                                    '{7}',
                                                    '{8}'
                                                )";

                object[] objArgs2 ={
                                        Guid.NewGuid().ToString("N"),
                                        schemaInfo.Name,
                                        schemaInfo.Type,
                                        schemaInfo.BuildingArea,
                                        schemaInfo.VegetationArea,
                                        schemaInfo.RoadArea,
                                        projectID,
                                        schemaInfo.Folder,
                                        schemaInfo.File
                                };

                try
                {
                    Environment.AdodbHelper.ExecuteSQL(string.Format(strSQL, objArgs2));
                }
                catch
                {
                    return false;
                }

            }

            return true;
        }
Esempio n. 4
0
        public bool TestSysTable(ref List<ProjectInfo> projectInfos)
        {
            if (!Environment.AdodbHelper.TableExists("GH_Project"))
            {
                Environment.AdodbHelper.ExecuteSQL(strSQL);
                Environment.AdodbHelper.ExecuteSQL(strSQL2);

                return false;
            }

            try
            {
                DataTable  tProject = Environment.AdodbHelper.OpenTable("GH_Project");
                DataTable tSchema =  Environment.AdodbHelper.OpenTable("GH_Schema");

                int pID_Index = tProject.Columns.IndexOf("ProjectID");
                int pName_Index = tProject.Columns.IndexOf("ProjectName");
                int pType_Index = tProject.Columns.IndexOf("ProjectType");
                int pEnterprise_Index = tProject.Columns.IndexOf("Enterprise");
                int pAddress_Index = tProject.Columns.IndexOf("ProjectAdrress");
                int pFolder_Index = tProject.Columns.IndexOf("ProjectFolder");
                int pFile_Index = tProject.Columns.IndexOf("ProjectFile");

                int sID_Index = tSchema.Columns.IndexOf("SchemaID");
                int sName_Index = tSchema.Columns.IndexOf("SchemaName");
                int sType_Index = tSchema.Columns.IndexOf("SchemaType");
                int sBuilding_Index = tSchema.Columns.IndexOf("BuildingArea");
                int sVegetation_Index = tSchema.Columns.IndexOf("VegetationArea");
                int sRoad_Index = tSchema.Columns.IndexOf("RoadArea");
                int sFolder_Index = tSchema.Columns.IndexOf("SchemaFolder");
                int sFile_Index = tSchema.Columns.IndexOf("SchemaFile");

                projectInfos = new List<ProjectInfo>();

                foreach(DataRow rowProject in tProject.Rows)
                {
                    ProjectInfo pInfo = new ProjectInfo();
                    pInfo.ID = rowProject[pID_Index] as string;
                    pInfo.Name = rowProject[pName_Index] as string;
                    pInfo.Type = rowProject[pType_Index]as string;
                    pInfo.Enterprise = rowProject[pEnterprise_Index] as string;
                    pInfo.Address = rowProject[pAddress_Index] as string;
                    pInfo.Folder = rowProject[pFolder_Index] as string;
                    pInfo.File = rowProject[pFile_Index] as string;

                    List<SchemaInfo> sInfoList = new List<SchemaInfo>();
                    DataRow[] rowsSchema = tSchema.Select(string.Format("ProjectID='{0}'", pInfo.ID));
                   foreach(DataRow rowSchema in rowsSchema)
                    {
                        SchemaInfo sInfo = new SchemaInfo();
                        sInfo.ID = rowSchema[sID_Index] as string;
                        sInfo.Name = rowSchema[sName_Index] as string;
                        sInfo.Type = rowSchema[sType_Index] as string;
                        sInfo.VegetationArea = Convert.ToDouble(rowSchema[sVegetation_Index]);
                        sInfo.BuildingArea = Convert.ToDouble(rowSchema[sBuilding_Index]);
                        sInfo.RoadArea = Convert.ToDouble(rowSchema[sRoad_Index]);
                        sInfo.Folder = rowSchema[sFolder_Index] as string;
                        sInfo.File = rowSchema[sFile_Index] as string;

                        sInfo.Project = pInfo;
                        sInfoList.Add(sInfo);

                    }
                    pInfo.Schemas = sInfoList;

                    projectInfos.Add(pInfo);
                }

            }
            catch
            {
                return false;
            }

            return true;
        }
Esempio n. 5
0
        public static bool ImportProject(ProjectFileStructure pFileStructure,ref ProjectInfo projectInfo)
        {
            if (pFileStructure == null)
                return false;

            if (projectInfo == null)
                projectInfo = new ProjectInfo();

            try
            {
                projectInfo.Folder = Path.Combine(m_WorkFolder, Guid.NewGuid().ToString());// pFileStructure.RootFolder;
                Directory.CreateDirectory(projectInfo.Folder);
                projectInfo.File = Path.Combine(projectInfo.Folder, FlyFile);
                File.Copy(pFileStructure.FlyFile, projectInfo.File);

                DataTable dtProejct = ExcelHelper.ReadData(pFileStructure.ProjectExcel);
                if (dtProejct != null && dtProejct.Rows.Count > 0)
                {
                    projectInfo.Name = dtProejct.Rows[0][0] as string;
                    projectInfo.Type = dtProejct.Rows[0][1] as string;
                    projectInfo.Enterprise = dtProejct.Rows[0][2] as string;
                    projectInfo.Address = dtProejct.Rows[0][3] as string;
                }

                List<SchemaInfo> schemaList = new List<SchemaInfo>();
                foreach (SchemaFileStructure schemaStructure in pFileStructure.SchemaStruactures)
                {
                    SchemaInfo schemaInfo = new SchemaInfo();
                    schemaInfo.Folder = System.IO.Path.Combine(projectInfo.Folder, System.IO.Path.GetFileName(schemaStructure.SchemaFolder));
                    schemaInfo.File = Path.Combine(schemaInfo.Folder, BuildingShp);

                    DataTable dtSchema = ExcelHelper.ReadData(schemaStructure.SchemaExcel);
                    if (dtSchema != null && dtSchema.Rows.Count > 0)
                    {
                        schemaInfo.Name = dtSchema.Rows[0][0] as string;
                        schemaInfo.Type = dtSchema.Rows[0][1] as string;
                        schemaInfo.BuildingArea = Convert.ToDouble(dtSchema.Rows[0][2]);
                        schemaInfo.VegetationArea = Convert.ToDouble(dtSchema.Rows[0][3]);
                        schemaInfo.RoadArea = Convert.ToDouble(dtSchema.Rows[0][4]);
                    }

                    schemaInfo.Project = projectInfo;

                    Directory.CreateDirectory(schemaInfo.Folder);                   // 方案文件夹
                    string modelFolder = Path.Combine(schemaInfo.Folder, ModelFolder); // 模型文件夹
                    Directory.CreateDirectory(modelFolder);
                    string[] modelFiles = Directory.GetFiles(schemaStructure.ModelFolder);// 模型
                    foreach (string strFile in modelFiles)
                    {
                        File.Copy(strFile, Path.Combine(modelFolder, Path.GetFileName(strFile)));
                    }
                    //schemaStructure.LocationExcel
                    //File.Copy(m_LocationTemplateShp+".shp",schemaInfo.File);

                    // shp
                    //CopyShp(Path.Combine(schemaStructure.SchemaFolder, BuildingShp), Path.Combine(schemaInfo.Folder, BuildingShp));
                    //CopyShp(Path.Combine(schemaStructure.SchemaFolder, "Building"), schemaInfo.Folder,"Building");
                    CopyShp(Path.Combine(schemaStructure.SchemaFolder, "Building"), Path.Combine(schemaInfo.Folder, "Building"));

                    // ESRI.ArcGIS.Geodatabase

                    schemaList.Add(schemaInfo);
                }

                projectInfo.Schemas = schemaList;

                // 记录
                AddProjectInfo(projectInfo);

            }
            catch
            {
                return false;
            }

            return true;
        }
Esempio n. 6
0
        public static bool DeleteProjectInfo(ProjectInfo projectInfo)
        {
            try
            {
                Environment.AdodbHelper.ExecuteSQL(string.Format("delete from GH_Project where ProjectID='{0}'", projectInfo.ID));
                Environment.AdodbHelper.ExecuteSQL(string.Format("delete from GH_Schema where ProjectID='{0}'", projectInfo.ID));

                return true;
            }
            catch
            {
                return false;
            }
        }