示例#1
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);
        }
示例#2
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;
        }
示例#3
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);
        }
示例#4
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;
        }