Beispiel #1
0
        //public Boolean InitForm(IFeatureLayer pFeatureLayer)
        //{
        //    if (pFeatureLayer == null) return false;
        //    IFeatureClass pFeaClass = pFeatureLayer.FeatureClass;
        //    if (pFeaClass == null) return false;
        //    m_FeatureLayer = pFeatureLayer;
        //    this.comboBoxLayer.Text = pFeatureLayer.Name;
        //    IFields pFields = pFeaClass.Fields as IFields;
        //    for (int i = 0; i < pFields.FieldCount; i++)
        //    {
        //        //this.comboBoxExGroupF.Items.Add(pFields.get_Field(i).AliasName );
        //        this.comboBoxExSumF.Items.Add(pFields.get_Field(i).AliasName );
        //    }
        //    return true;
        //}
        private void buttonXStatic_Click(object sender, EventArgs e)
        {
            //判断分组字段是否设置
            if (this.listSelectColumns.Items.Count == 0)
            {
                MessageBox.Show("请选择分组字段!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                return;
            }
            //判断汇总字段是否设置
            if (this.comboBoxExSumF.Text.Equals(""))
            {
                MessageBox.Show("请选择汇总字段!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                return;
            }

            //初始化进度条
            IFeatureClass pFeatureClass = _FeatureLayer.FeatureClass;

            if (pFeatureClass.FeatureCount(null) == 0)
            {
                MessageBox.Show("图层中没有可供统计的数据!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                return;
            }
            IFields pFields      = pFeatureClass.Fields;
            int     iFieldsindex = 0;

            iFieldsindex = pFields.FindFieldByAliasName(this.comboBoxExSumF.Text);
            string        sSumField = pFields.get_Field(iFieldsindex).Name;
            IField        pSumField = pFields.get_Field(iFieldsindex);
            esriFieldType pType     = pFields.get_Field(iFieldsindex).Type;

            if (pType != esriFieldType.esriFieldTypeDouble && pType != esriFieldType.esriFieldTypeInteger && pType != esriFieldType.esriFieldTypeSingle && pType != esriFieldType.esriFieldTypeSmallInteger)
            {
                MessageBox.Show("汇总字段须是数值型!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                return;
            }
            List <IField> listGroupbyFields = new List <IField>();

            for (int i = 0; i < listSelectColumns.Items.Count; i++)
            {
                string strFieldname  = listSelectColumns.Items[i] as string;
                int    tmpFieldindex = pFields.FindFieldByAliasName(strFieldname);
                IField pField        = pFields.get_Field(tmpFieldindex);
                if (strFieldname.Equals(this.comboBoxExSumF.Text))
                {
                    continue;
                }
                listGroupbyFields.Add(pField);
            }
            if (listGroupbyFields.Count == 0)
            {
                MessageBox.Show("请选择有效地分组字段!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                return;
            }
            this.Hide();

            SysCommon.CProgress vProgress = new SysCommon.CProgress("进度条");
            vProgress.EnableCancel    = false;
            vProgress.ShowDescription = true;
            vProgress.FakeProgress    = true;
            vProgress.TopMost         = true;
            vProgress.ShowProgress();
            vProgress.SetProgress("创建临时成果数据库");
            try
            {
                string workpath      = Application.StartupPath + "\\..\\Temp";
                string workSpaceName = Application.StartupPath + "\\..\\Temp\\TmpStatistic.mdb";
                if (File.Exists(workSpaceName))
                {
                    File.Delete(workSpaceName);
                }
                //判断结果目录是否存在,不存在则创建
                if (System.IO.Directory.Exists(workpath) == false)
                {
                    System.IO.Directory.CreateDirectory(workpath);
                }
                //创建一个新的mdb数据库,并打开工作空间
                IWorkspace pOutWorkSpace     = ChangeJudge.CreatePDBWorkSpace(workpath, "TmpStatistic.mdb");
                string     sFeatureClassName = "";
                vProgress.SetProgress("分析目标图层数据");
                if (_FeatureLayer != null)
                {
                    IDataset   pDataSet   = _FeatureLayer.FeatureClass as IDataset;
                    IWorkspace pWorkSpace = pDataSet.Workspace;
                    sFeatureClassName = pDataSet.Name;
                    CopyPasteGDBData.CopyPasteGeodatabaseData(pWorkSpace, pOutWorkSpace, sFeatureClassName, esriDatasetType.esriDTFeatureClass);
                }
                pOutWorkSpace = null;
                if (sFeatureClassName.Contains("."))
                {
                    sFeatureClassName = sFeatureClassName.Substring(sFeatureClassName.IndexOf(".") + 1);
                }
                ModStatReport.DoCustomizeStat(workSpaceName, _FeatureLayer.Name, sFeatureClassName, listGroupbyFields, pSumField as Field, vProgress);
                this.DialogResult = DialogResult.OK;
            }
            catch (Exception err)
            {
                MessageBox.Show(err.Message, "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                vProgress.Close();
            }
        }
        private void DoStatistic(string XmlPath, string XZQcode, string XZQName, string strYear, string strAreaUnit, int FractionNum, string ResultPath, SysCommon.CProgress vProgress)
        {
            string DLTBNodeKey = "";
            string XZDWNodeKey = "";
            string LXDWNodeKey = "";

            //SysCommon.Log.SysLocalLog pLog = new SysCommon.Log.SysLocalLog();
            //pLog.CreateLogFile(Application.StartupPath+"\\..\\Log\\统计.log");
            ModStatReport.WriteStaticLog("查找森林资源现状数据");
            //pLog.WriteLocalLog("查找森林资源现状数据");
            ModStatReport.GetTDLYLayerKey(XmlPath, XZQcode, strYear, out DLTBNodeKey, out XZDWNodeKey, out LXDWNodeKey);
            if (DLTBNodeKey == "")
            {
                vProgress.Close();
                MessageBox.Show("找不到该行政区的森林资源现状数据!");
                return;
            }
            IFeatureClass pDLTBFeaCls = SysCommon.ModSysSetting.GetFeatureClassByNodeKey(Plugin.ModuleCommon.TmpWorkSpace, XmlPath, DLTBNodeKey);
            IFeatureClass pXZDWFeaCls = SysCommon.ModSysSetting.GetFeatureClassByNodeKey(Plugin.ModuleCommon.TmpWorkSpace, XmlPath, XZDWNodeKey);
            IFeatureClass pLXDWFeaCls = SysCommon.ModSysSetting.GetFeatureClassByNodeKey(Plugin.ModuleCommon.TmpWorkSpace, XmlPath, LXDWNodeKey);

            if (pDLTBFeaCls == null)
            {
                vProgress.Close();
                MessageBox.Show("找不到该行政区的森林资源现状数据!");
                return;
            }
            ModStatReport.WriteStaticLog("创建临时成果数据库");
            //pLog.WriteLocalLog("创建临时成果数据库");
            //string workpath = Application.StartupPath + @"\..\OutputResults\统计成果\" + System.DateTime.Now.ToString("yyyyMMddHHmmss");
            string strMDBName    = XZQName + strYear + "年LandUse" + System.DateTime.Now.ToString("yyyyMMddHHmmss") + ".mdb";
            string workSpaceName = ResultPath + "\\" + strMDBName;

            //判断结果目录是否存在,不存在则创建
            if (System.IO.Directory.Exists(ResultPath) == false)
            {
                System.IO.Directory.CreateDirectory(ResultPath);
            }
            //创建一个新的mdb数据库,并打开工作空间
            if (vProgress != null)
            {
                vProgress.SetProgress("创建结果库...");
            }
            IWorkspace pOutWorkSpace = ChangeJudge.CreatePDBWorkSpace(ResultPath, strMDBName);


            string strDLTBname = "";
            string strXZDWname = "";
            string strLXDWname = "";

            if (pDLTBFeaCls != null)
            {
                ModStatReport.WriteStaticLog("拷贝地类图斑数据");
                CopyPasteGDBData.CopyPasteGeodatabaseData((pDLTBFeaCls as IDataset).Workspace, pOutWorkSpace, (pDLTBFeaCls as IDataset).Name, esriDatasetType.esriDTFeatureClass);

                strDLTBname = (pDLTBFeaCls as IDataset).Name;
                strDLTBname = strDLTBname.Substring(strDLTBname.IndexOf(".") + 1);//added by chulili 20110922 去掉oracle中用户名
            }
            else
            {
                strDLTBname = "";
            }
            if (pXZDWFeaCls != null)
            {
                ModStatReport.WriteStaticLog("拷贝线状地物数据");
                CopyPasteGDBData.CopyPasteGeodatabaseData((pXZDWFeaCls as IDataset).Workspace, pOutWorkSpace, (pXZDWFeaCls as IDataset).Name, esriDatasetType.esriDTFeatureClass);
                strXZDWname = (pXZDWFeaCls as IDataset).Name;
                strXZDWname = strXZDWname.Substring(strXZDWname.IndexOf(".") + 1);//added by chulili 20110922 去掉oracle中用户名
            }
            else
            {
                strXZDWname = "";
            }
            if (pLXDWFeaCls != null)
            {
                ModStatReport.WriteStaticLog("拷贝零星地物数据");
                CopyPasteGDBData.CopyPasteGeodatabaseData((pLXDWFeaCls as IDataset).Workspace, pOutWorkSpace, (pLXDWFeaCls as IDataset).Name, esriDatasetType.esriDTFeatureClass);
                strLXDWname = (pLXDWFeaCls as IDataset).Name;
                strLXDWname = strLXDWname.Substring(strLXDWname.IndexOf(".") + 1);//added by chulili 20110922 去掉oracle中用户名
            }
            else
            {
                strLXDWname = "";
            }


            ModStatReport.WriteStaticLog("拷贝行政区字典表");
            CopyPasteGDBData.CopyPasteGeodatabaseData(Plugin.ModuleCommon.TmpWorkSpace, pOutWorkSpace, Plugin.ModuleCommon.TmpWorkSpace.ConnectionProperties.GetProperty("User").ToString() + ".行政区字典表", esriDatasetType.esriDTTable);
            string strExcelName = XZQName + strYear + "年森林资源现状统计表.xls";

            ModStatReport.WriteStaticLog("拷贝森林资源现状统计模板");
            if (File.Exists(ResultPath + "\\" + strExcelName))
            {
                File.Delete(ResultPath + "\\" + strExcelName);
            }
            File.Copy(Application.StartupPath + "\\..\\Template\\森林资源现状统计模板.xls", ResultPath + "\\" + strExcelName);

            ModStatReport.WriteStaticLog("生成基础统计表");

            ModStatReport.DoLandUseStatic(workSpaceName, strDLTBname, strXZDWname, strLXDWname, vProgress);

            ModStatReport.WriteStaticLog("生成森林资源现状一级分类面积统计表");
            ModStatReport.LandUseCurReport(ResultPath, strMDBName, XZQcode, strAreaUnit, FractionNum, 1, ResultPath + "\\一级分类面积.xls", vProgress);

            ModStatReport.WriteStaticLog("生成森林资源现状二级分类面积统计表");
            ModStatReport.LandUseCurReport(ResultPath, strMDBName, XZQcode, strAreaUnit, FractionNum, 2, ResultPath + "\\二级分类面积.xls", vProgress);


            ModStatReport.WriteStaticLog("拷贝EXCEL中的工作区表");
            ModStatReport.CopyExcelSheet(ResultPath + "\\一级分类面积.xls", "Sheet1", ResultPath + "\\" + strExcelName, "森林资源现状一级分类面积");
            ModStatReport.CopyExcelSheet(ResultPath + "\\二级分类面积.xls", "Sheet1", ResultPath + "\\" + strExcelName, "森林资源现状二级分类面积");
            File.Delete(ResultPath + "\\一级分类面积.xls");
            File.Delete(ResultPath + "\\二级分类面积.xls");
            ModStatReport.WriteStaticLog("打开森林资源现状统计表");
            ModStatReport.OpenExcelFile(ResultPath + "\\" + strExcelName);
            vProgress.Close();
            ModStatReport.WriteStaticLog("统计结束");
            System.Runtime.InteropServices.Marshal.ReleaseComObject(pOutWorkSpace);
            pOutWorkSpace = null;
            try
            {
                File.Delete(workSpaceName);
            }
            catch (Exception err)
            { }
            //pLog = null;
        }
        //added by chulili 20110914 指定范围森林资源现状统计,指定范围来自一个地物类
        //changed by chulili 20110919 删除行政区编码参数,改为从数据中直接获取
        private void DoImportAreaLandUseStatic(string XmlPath, IFeatureClass pImportFeaClass, string strYear, string strAreaUnit, int FractionNum, bool SelectTDLY, bool SelectZTGH, string ResultPath, SysCommon.CProgress pProgress)
        {
            string StaticConfigPath = Application.StartupPath + "\\..\\Res\\Xml\\StatisticConfig.xml";

            SysCommon.ModSysSetting.CopyConfigXml(Plugin.ModuleCommon.TmpWorkSpace, "查询配置", StaticConfigPath);
            //读取xml文件
            XmlDocument pXmlDoc = new XmlDocument();

            pXmlDoc.Load(StaticConfigPath);
            //读取
            ModStatReport.WriteStaticLog("读取统计配置");
            if (pProgress != null)
            {
                pProgress.SetProgress("读取统计配置...");
            }
            string strSearch     = "//StatisticConfig";
            string LayerTreePath = Application.StartupPath + "\\..\\Res\\Xml\\展示图层树0.xml";

            SysCommon.ModSysSetting.CopyLayerTreeXmlFromDataBase(Plugin.ModuleCommon.TmpWorkSpace, LayerTreePath);
            XmlNode pXmlNode = pXmlDoc.SelectSingleNode(strSearch);

            if (pXmlNode == null)
            {
                if (pProgress != null)
                {
                    pProgress.Close();
                }
                System.IO.File.Delete(StaticConfigPath);
                System.IO.File.Delete(LayerTreePath);
                return;
            }
            //直接从数据源中获取地物类
            if (pProgress != null)
            {
                pProgress.SetProgress("获取统计图层...");
            }
            ModStatReport.WriteStaticLog("读取统计配置中的行政区");
            IFeatureClass pXZQFeatureClass = null;
            XmlNode       pXZQNode         = null;

            try
            {
                pXZQNode = pXmlNode["XZQ"];
            }
            catch (Exception err)
            { }
            //获取行政区划层
            if (pXZQNode != null)
            {
                string strNodeKey = "";
                if ((pXZQNode as XmlElement).HasAttribute("TableNodeKey"))
                {
                    strNodeKey = pXZQNode.Attributes["TableNodeKey"].Value;
                }
                ModStatReport.WriteStaticLog("读取行政区层");
                pXZQFeatureClass = SysCommon.ModSysSetting.GetFeatureClassByNodeKey(Plugin.ModuleCommon.TmpWorkSpace, LayerTreePath, strNodeKey);
            }
            if (pXZQFeatureClass == null)
            {
                if (pProgress != null)
                {
                    pProgress.Close();
                }
                MessageBox.Show("未找到行政区划图层!请检查配置文件");
                ModStatReport.WriteStaticLog("未找到行政区划图层,退出");
                System.IO.File.Delete(StaticConfigPath);
                System.IO.File.Delete(LayerTreePath);
                return;
            }
            //string workpath = Application.StartupPath + @"\..\OutputResults\统计成果\" + System.DateTime.Now.ToString("yyyyMMddHHmmss");
            ModStatReport.WriteStaticLog("创建临时成果数据库");
            string strMDBName    = "ImportStatistic" + System.DateTime.Now.ToString("yyyyMMddHHmmss") + ".mdb";
            string workSpaceName = ResultPath + "\\" + strMDBName;

            //判断结果目录是否存在,不存在则创建
            if (System.IO.Directory.Exists(ResultPath) == false)
            {
                System.IO.Directory.CreateDirectory(ResultPath);
            }
            //创建一个新的mdb数据库,并打开工作空间
            if (pProgress != null)
            {
                pProgress.SetProgress("创建结果库...");
            }
            IWorkspace        pOutWorkSpace    = ChangeJudge.CreatePDBWorkSpace(ResultPath, strMDBName);
            IFeatureWorkspace pOutFeaWorkSpace = pOutWorkSpace as IFeatureWorkspace;

            //叠置分析
            if (pProgress != null)
            {
                pProgress.SetProgress("进行叠置分析...");
            }
            //行政区划叠置
            string            strXZQResName   = "XZQ_RES";
            IFeatureClassName pResDataName    = new FeatureClassNameClass();
            IDataset          pOutDataset     = (IDataset)pOutWorkSpace;
            IDatasetName      pOutDatasetName = (IDatasetName)pResDataName;

            pOutDatasetName.WorkspaceName = (IWorkspaceName)pOutDataset.FullName;
            pOutDatasetName.Name          = strXZQResName;
            IBasicGeoprocessor pGeoProcessor = new BasicGeoprocessorClass();
            double             rol           = 0.001;

            ModStatReport.WriteStaticLog("叠置行政区图层");
            pGeoProcessor.Intersect(pXZQFeatureClass as ITable, false, pImportFeaClass as ITable, false, rol, pResDataName);
            string strXZQCode = ModStatReport.GetXZQcode(workSpaceName, strXZQResName);

            if (strXZQCode.Equals(""))
            {
                if (pProgress != null)
                {
                    pProgress.Close();
                }
                MessageBox.Show("找不到导入区域所在的行政区!请验证导入区域与行政区划图层的位置关系。");
                ModStatReport.WriteStaticLog("找不到导入区域所在的行政区,退出");
                pResDataName  = null;
                pGeoProcessor = null;
                pXmlDoc       = null;
                System.IO.File.Delete(StaticConfigPath);
                System.IO.File.Delete(LayerTreePath);
                return;
            }
            string DLTBNodeKey = "";
            string XZDWNodeKey = "";
            string LXDWNodeKey = "";
            string JBNTNodeKey = "";
            string YTFQNodeKey = "";
            string JSYDNodeKey = "";

            IFeatureClass pDLTBFeaCls = null;
            IFeatureClass pXZDWFeaCls = null;
            IFeatureClass pLXDWFeaCls = null;

            string strDLTBResName = "DLTB_RES";
            string strXZDWResName = "XZDW_RES";
            string strLXDWResName = "LXDW_RES";

            IFeatureClass pJBNTFeaCls = null;
            IFeatureClass pYTFQFeaCls = null;
            IFeatureClass pJSYDFeaCls = null;

            string strJBNTResName = "JBNT_RES";
            string strYTFQResName = "YTFQ_RES";
            string strJSYDResName = "JSYD_RES";

            if (SelectTDLY)
            {
                ModStatReport.WriteStaticLog("获取叠置行政区内的森林资源图层标识号");
                ModStatReport.GetTDLYLayerKey(XmlPath, strXZQCode, strYear, out DLTBNodeKey, out XZDWNodeKey, out LXDWNodeKey);
                ModStatReport.WriteStaticLog("获取叠置行政区内的森林资源图层");
                pDLTBFeaCls = SysCommon.ModSysSetting.GetFeatureClassByNodeKey(Plugin.ModuleCommon.TmpWorkSpace, XmlPath, DLTBNodeKey);
                pXZDWFeaCls = SysCommon.ModSysSetting.GetFeatureClassByNodeKey(Plugin.ModuleCommon.TmpWorkSpace, XmlPath, XZDWNodeKey);
                pLXDWFeaCls = SysCommon.ModSysSetting.GetFeatureClassByNodeKey(Plugin.ModuleCommon.TmpWorkSpace, XmlPath, LXDWNodeKey);

                pProgress.SetProgress("正在叠置分析地类图斑数据...");
                pOutDatasetName.Name = strDLTBResName;
                ModStatReport.WriteStaticLog("叠置分析地类图斑图层");
                pGeoProcessor.Intersect(pDLTBFeaCls as ITable, false, pImportFeaClass as ITable, false, rol, pResDataName);
                IFeatureClass pTBFeaCls = pOutFeaWorkSpace.OpenFeatureClass(strDLTBResName);
                SysCommon.modCalArea.CalCulateAllipsoidArea(pTBFeaCls, "TBMJ", 114);
                //线状地物叠置
                if (pXZDWFeaCls != null)
                {
                    pProgress.SetProgress("正在叠置分析线状地物数据...");
                    pOutDatasetName.Name = strXZDWResName;
                    //叠置分析
                    ModStatReport.WriteStaticLog("叠置分析线状地物图层");
                    pGeoProcessor.Intersect(pXZDWFeaCls as ITable, false, pImportFeaClass as ITable, false, rol, pResDataName);
                }
                else
                {
                    strXZDWResName = "";
                }

                //零星地物叠置
                if (pLXDWFeaCls != null)
                {
                    pProgress.SetProgress("正在叠置分析零星地物数据...");
                    pOutDatasetName.Name = strLXDWResName;
                    //叠置分析
                    ModStatReport.WriteStaticLog("叠置分析零星地物图层");
                    pGeoProcessor.Intersect(pLXDWFeaCls as ITable, false, pImportFeaClass as ITable, false, rol, pResDataName);
                }
                else
                {
                    strLXDWResName = "";
                }
                try
                {
                    pProgress.SetProgress("正在组织森林资源现状数据...");
                    ModStatReport.WriteStaticLog("拷贝行政区字典");
                    CopyPasteGDBData.CopyPasteGeodatabaseData(Plugin.ModuleCommon.TmpWorkSpace, pOutWorkSpace, Plugin.ModuleCommon.TmpWorkSpace.ConnectionProperties.GetProperty("User").ToString() + ".行政区字典表", esriDatasetType.esriDTTable);
                    //CopyPasteGDBData.CopyPasteGeodatabaseData(Plugin.ModuleCommon.TmpWorkSpace, pOutWorkSpace, Plugin.ModuleCommon.TmpWorkSpace.ConnectionProperties.GetProperty("User").ToString() + ".森林用途字典", esriDatasetType.esriDTTable);
                }
                catch
                { }
            }
            if (SelectZTGH)
            {
                ModStatReport.WriteStaticLog("获取叠置行政区内的总体规划图层标识号");
                ModStatReport.GetZTGHLayerKey(XmlPath, strXZQCode, out JBNTNodeKey, out YTFQNodeKey, out JSYDNodeKey);
                pJBNTFeaCls = SysCommon.ModSysSetting.GetFeatureClassByNodeKey(Plugin.ModuleCommon.TmpWorkSpace, XmlPath, JBNTNodeKey);
                pYTFQFeaCls = SysCommon.ModSysSetting.GetFeatureClassByNodeKey(Plugin.ModuleCommon.TmpWorkSpace, XmlPath, YTFQNodeKey);
                pJSYDFeaCls = SysCommon.ModSysSetting.GetFeatureClassByNodeKey(Plugin.ModuleCommon.TmpWorkSpace, XmlPath, JSYDNodeKey);

                //基本农田叠置
                if (pJBNTFeaCls != null)
                {
                    pProgress.SetProgress("正在叠置分析基本农田数据...");
                    pOutDatasetName.Name = strJBNTResName;
                    //叠置分析
                    ModStatReport.WriteStaticLog("叠置分析基本农田图层");
                    pGeoProcessor.Intersect(pJBNTFeaCls as ITable, false, pImportFeaClass as ITable, false, rol, pResDataName);
                    IFeatureClass pResJBNTFeaCls = pOutFeaWorkSpace.OpenFeatureClass(strJBNTResName);
                    SysCommon.modCalArea.CalCulateAllipsoidArea(pResJBNTFeaCls, "JBNTMJ", 114);
                }
                else
                {
                    strJBNTResName = "";
                }
                //用途分区叠置
                if (pYTFQFeaCls != null)
                {
                    pProgress.SetProgress("正在叠置分析森林用途分区数据...");
                    pOutDatasetName.Name = strYTFQResName;
                    //叠置分析
                    ModStatReport.WriteStaticLog("叠置分析森林用途图层");
                    pGeoProcessor.Intersect(pYTFQFeaCls as ITable, false, pImportFeaClass as ITable, false, rol, pResDataName);
                    IFeatureClass pResTDYTFeaCls = pOutFeaWorkSpace.OpenFeatureClass(strYTFQResName);
                    SysCommon.modCalArea.CalCulateAllipsoidArea(pResTDYTFeaCls, "MJ", 114);
                }
                else
                {
                    strYTFQResName = "";
                }
                //建设用地叠置
                if (pJSYDFeaCls != null)
                {
                    pProgress.SetProgress("正在叠置分析建设用地管制分区数据...");
                    pOutDatasetName.Name = strJSYDResName;
                    //叠置分析
                    ModStatReport.WriteStaticLog("叠置分析建设用地图层");
                    pGeoProcessor.Intersect(pJSYDFeaCls as ITable, false, pImportFeaClass as ITable, false, rol, pResDataName);
                    IFeatureClass pResJSYDFeaCls = pOutFeaWorkSpace.OpenFeatureClass(strJSYDResName);
                    SysCommon.modCalArea.CalCulateAllipsoidArea(pResJSYDFeaCls, "MJ", 114);
                }
                else
                {
                    strJSYDResName = "";
                }
            }
            pOutWorkSpace = null;
            pResDataName  = null;
            pGeoProcessor = null;
            //try
            //{
            //    File.Delete(workSpaceName);
            //}
            //catch(Exception err)
            //{}
            if (!SelectTDLY)
            {
                ModStatReport.WriteStaticLog("拷贝规划模板");
                if (File.Exists(ResultPath + "\\规划统计表.xls"))
                {
                    File.Delete(ResultPath + "\\规划统计表.xls");
                }
                File.Copy(Application.StartupPath + "\\..\\Template\\规划统计模板ZTGH.xls", ResultPath + "\\规划统计表.xls");
            }
            else if (!SelectZTGH)
            {
                ModStatReport.WriteStaticLog("拷贝森林资源模板");
                if (File.Exists(ResultPath + "\\规划统计表.xls"))
                {
                    File.Delete(ResultPath + "\\规划统计表.xls");
                }
                File.Copy(Application.StartupPath + "\\..\\Template\\规划统计模板TDLY.xls", ResultPath + "\\规划统计表.xls");
            }
            else
            {
                ModStatReport.WriteStaticLog("拷贝森林资源的总体模板");
                File.Copy(Application.StartupPath + "\\..\\Template\\规划统计模板.xls", ResultPath + "\\规划统计表.xls");
            }
            if (SelectTDLY)
            {
                if (pProgress != null)
                {
                    pProgress.SetProgress("生成森林资源现状数据基础统计表...");
                }
                string resDLTB = "";
                ModStatReport.WriteStaticLog("重新计算图斑的各种面积");
                ModStatReport.ComputeXZDWMJ(workSpaceName, strDLTBResName, strXZDWResName, out resDLTB);
                if (resDLTB != "")
                {
                    strDLTBResName = resDLTB;
                }
                //string connstr = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + workSpaceName;
                //OleDbConnection oledbconn = new OleDbConnection(connstr);
                //oledbconn.Open();
                //OleDbCommand oledbcomm = oledbconn.CreateCommand();

                //oledbcomm.CommandText = "update " + strDLTBResName + " set " + ModFieldConst.g_TBJMJ + " =round(" + ModFieldConst.g_TBJMJ + "*shape_area/" + ModFieldConst.g_TBMJ + ",2)," + ModFieldConst.g_TKMJ + "=round(" + ModFieldConst.g_TKMJ + "*shape_area/" + ModFieldConst.g_TBMJ + ",2) where " + ModFieldConst.g_TBMJ + ">0 and (" + ModFieldConst.g_TBMJ + "-shape_area)>0.01";
                //oledbcomm.ExecuteNonQuery();
                //if (strXZDWResName != "")
                //{
                //    oledbcomm.CommandText = "update " + strXZDWResName + " set " + ModFieldConst.g_XZMJ + " =round(" + ModFieldConst.g_XZMJ + "*shape_length/" + ModFieldConst.g_ChangDu + ",2) where " + ModFieldConst.g_ChangDu + ">0 and (" + ModFieldConst.g_ChangDu + "-shape_length)>0.01";
                //    oledbcomm.ExecuteNonQuery();
                //}
                //oledbconn.Close();
                ModStatReport.WriteStaticLog("生成基础统计表");
                ModStatReport.DoLandUseStatic(workSpaceName, strDLTBResName, strXZDWResName, strLXDWResName, null);
                if (pProgress != null)
                {
                    pProgress.SetProgress("生成森林资源现状一级分类面积汇总表...");
                }
                ModStatReport.WriteStaticLog("生成森林资源现状一级分类面积汇总表");
                ModStatReport.LandUseCurReport(ResultPath, strMDBName, strXZQCode, strAreaUnit, FractionNum, 1, ResultPath + "\\一级分类面积.xls", null);
                if (pProgress != null)
                {
                    pProgress.SetProgress("生成森林资源现状二级分类面积汇总表...");
                }
                ModStatReport.WriteStaticLog("生成森林资源现状二级分类面积汇总表");
                ModStatReport.LandUseCurReport(ResultPath, strMDBName, strXZQCode, strAreaUnit, FractionNum, 2, ResultPath + "\\二级分类面积.xls", null);
            }
            if (SelectZTGH)
            {
                ModStatReport.WriteStaticLog("基本农田占用分析");
                ModStatReport.DoJBNTStatistic(ResultPath, strMDBName, strJBNTResName, Application.StartupPath + "\\..\\Template\\基本农田压占统计表.cel", ResultPath + "\\基本农田.xls", strAreaUnit, FractionNum);
                ModStatReport.WriteStaticLog("森林用途占用分析");
                ModStatReport.DoYTFQStatistic(ResultPath, strMDBName, strYTFQResName, Application.StartupPath + "\\..\\Template\\森林用途区压占统计表.cel", ResultPath + "\\森林用途.xls", strAreaUnit, FractionNum);
                ModStatReport.WriteStaticLog("建设用地占用分析");
                ModStatReport.DoJSYDStatistic(ResultPath, strMDBName, strJSYDResName, Application.StartupPath + "\\..\\Template\\建设用地管制区压占统计表.cel", ResultPath + "\\建设用地.xls", strAreaUnit, FractionNum);
            }
            if (SelectTDLY)
            {
                pProgress.SetProgress("生成森林资源现状数据分析结果...");
                ModStatReport.WriteStaticLog("拷贝EXCEL中工作区表");
                ModStatReport.CopyExcelSheet(ResultPath + "\\一级分类面积.xls", "Sheet1", ResultPath + "\\规划统计表.xls", "森林资源现状一级分类面积");
                ModStatReport.CopyExcelSheet(ResultPath + "\\二级分类面积.xls", "Sheet1", ResultPath + "\\规划统计表.xls", "森林资源现状二级分类面积");
                File.Delete(ResultPath + "\\一级分类面积.xls");
                File.Delete(ResultPath + "\\二级分类面积.xls");
            }
            if (SelectZTGH)
            {
                pProgress.SetProgress("生成森林资源总体规划数据分析结果...");
                ModStatReport.WriteStaticLog("拷贝EXCEL中工作区表");
                ModStatReport.CopyExcelSheet(ResultPath + "\\基本农田.xls", "Sheet1", ResultPath + "\\规划统计表.xls", "基本农田");
                ModStatReport.CopyExcelSheet(ResultPath + "\\森林用途.xls", "Sheet1", ResultPath + "\\规划统计表.xls", "森林用途分区");
                ModStatReport.CopyExcelSheet(ResultPath + "\\建设用地.xls", "Sheet1", ResultPath + "\\规划统计表.xls", "建设用地管制区");

                File.Delete(ResultPath + "\\基本农田.xls");
                File.Delete(ResultPath + "\\森林用途.xls");
                File.Delete(ResultPath + "\\建设用地.xls");
            }
            try
            {
                File.Delete(workSpaceName);
            }
            catch (Exception err)
            {}
            ModStatReport.WriteStaticLog("打开统计结果");
            ModStatReport.OpenExcelFile(ResultPath + "\\规划统计表.xls");
            if (pProgress != null)
            {
                pProgress.Close();
            }
            pResDataName  = null;
            pGeoProcessor = null;
            pXmlDoc       = null;
            ModStatReport.WriteStaticLog("统计结束");
            System.Runtime.InteropServices.Marshal.ReleaseComObject(pOutWorkSpace);
            pOutWorkSpace = null;
            try
            {
                File.Delete(workSpaceName);
            }
            catch (Exception err)
            { }

            System.IO.File.Delete(StaticConfigPath);
            System.IO.File.Delete(LayerTreePath);
        }