Example #1
0
        public void OnDataCheck()
        {
            if (Hook == null)
            {
                return;
            }
            IArcgisDataCheckParaSet dataCheckParaSet = Hook.DataCheckParaSet as IArcgisDataCheckParaSet;

            if (dataCheckParaSet == null)
            {
                return;
            }
            if (dataCheckParaSet.Workspace == null)
            {
                return;
            }

            //获取所有数据集
            SysCommon.Gis.SysGisDataSet sysGisDataSet   = new SysCommon.Gis.SysGisDataSet(dataCheckParaSet.Workspace);
            List <IDataset>             featureDatasets = sysGisDataSet.GetAllFeatureClass();

            ISchemeProject m_pProject = null;                                                        //数据库结构文件对象
            int            m_DBScale  = 0;                                                           //默认比例尺
            int            m_DSScale  = 0;                                                           //数据集比例尺

            Dictionary <string, IFeatureClass> pLayerDic = new Dictionary <string, IFeatureClass>(); //记录加载到map上的图层对象

            foreach (IDataset var in featureDatasets)
            {
                string FCName = var.Name;
                if (FCName.Contains("."))
                {
                    FCName = FCName.Substring(FCName.IndexOf('.') + 1);
                }
                IFeatureClass FC = var as IFeatureClass;
                if (FC != null && !pLayerDic.ContainsKey(FCName))
                {
                    pLayerDic.Add(FCName, FC);
                }
            }

            ///读取配置方案到对象
            ///
            m_pProject = new SchemeProjectClass();                                          //创建实例
            m_pProject.Load(GeoDataChecker.DBSchemaPath, e_FileType.GO_SCHEMEFILETYPE_MDB); //加载schema文件

            if (m_pProject != null)
            {
                #region 获得比例尺信息
                string   DBScale       = m_pProject.get_MetaDataValue("Scale") as string; //获取比例尺信息(总工程中的默认比例尺)
                string[] DBPScaleArayy = DBScale.Split(':');
                m_DBScale = Convert.ToInt32(DBPScaleArayy[1]);
                #endregion

                IChildItemList pProjects = m_pProject as IChildItemList;
                //获取属性库集合信息
                ISchemeItem    pDBList  = pProjects.get_ItemByName("ATTRDB");
                IChildItemList pDBLists = pDBList as IChildItemList;
                //遍历属性库集合
                long DBNum = pDBLists.GetCount();
                for (int i = 0; i < DBNum; i++)
                {
                    m_DSScale = 0;    //比例尺信息

                    //取得属性库信息
                    ISchemeItem pDB = pDBLists.get_ItemByIndex(i);
                    ///获取数据集的比例尺信息,如果获取失败则,取默认比例尺信息
                    IAttribute pa = pDB.AttributeList.get_AttributeByName("Scale") as IAttribute;
                    if (pa == null)
                    {
                        m_DSScale = m_DBScale;
                    }
                    else
                    {
                        string[] DBScaleArayy = pa.Value.ToString().Split(':');
                        m_DSScale = Convert.ToInt32(DBScaleArayy[1]);
                    }

                    IChildItemList pDBs         = pDB as IChildItemList;
                    string         pDatasetName = pDB.Name;

                    ////遍历属性表
                    int TabNum = pDBs.GetCount();
                    for (int j = 0; j < TabNum; j++)
                    {
                        //获取属性表信息
                        ISchemeItem pTable            = pDBs.get_ItemByIndex(j); //获取属性表对象
                        string      pFeatureClassName = pTable.Name;             //要素类名称

                        ///检查图层是否存在
                        if (!pLayerDic.ContainsKey(pFeatureClassName))
                        {
                            //传递错误日志
                            IDataErrInfo      dataErrInfo       = new DataErrInfo(new List <object>(new object[] { "批量检查", "数据结构检查", dataCheckParaSet.Workspace.PathName, enumErrorType.目标要素类缺失.GetHashCode(), "要素类在标准中存在,却在目标数据集中未找到", 0, 0, pFeatureClassName, 0, "", 0, false, System.DateTime.Now.ToString() }));
                            DataErrTreatEvent dataErrTreatEvent = new DataErrTreatEvent(dataErrInfo);
                            DataErrTreat(Hook.DataCheckParaSet as object, dataErrTreatEvent);
                            continue;
                        }

                        #region 检查要素类类型是否与配置方案一致
                        string pFeatureClassType = pTable.Value as string;   //要素类类型
                        ///检查图层类型是否一致
                        ///
                        IFeatureClass pfeatureclass;

                        bool GetlyrSeccess = pLayerDic.TryGetValue(pFeatureClassName, out pfeatureclass);

                        if (GetlyrSeccess)
                        {
                            //IFeatureLayer pFeatureLayer = player as IFeatureLayer;

                            switch (pFeatureClassType)
                            {
                            case "ANNO":
                                if (pfeatureclass.FeatureType != esriFeatureType.esriFTAnnotation)
                                {
                                    //传递错误日志
                                    IDataErrInfo      dataErrInfo       = new DataErrInfo(new List <object>(new object[] { "批量检查", "数据结构检查", dataCheckParaSet.Workspace.PathName, enumErrorType.要素类类型不一致.GetHashCode(), "目标要素类应为 注记 类型", 0, 0, pFeatureClassName, 0, "", 0, false, System.DateTime.Now.ToString() }));
                                    DataErrTreatEvent dataErrTreatEvent = new DataErrTreatEvent(dataErrInfo);
                                    DataErrTreat(Hook.DataCheckParaSet as object, dataErrTreatEvent);
                                }
                                break;

                            case "POINT":
                                if (pfeatureclass.ShapeType != ESRI.ArcGIS.Geometry.esriGeometryType.esriGeometryPoint)
                                {
                                    //传递错误日志
                                    IDataErrInfo      dataErrInfo       = new DataErrInfo(new List <object>(new object[] { "批量检查", "数据结构检查", dataCheckParaSet.Workspace.PathName, enumErrorType.要素类类型不一致.GetHashCode(), "目标要素类应为 点 类型", 0, 0, pFeatureClassName, 0, "", 0, false, System.DateTime.Now.ToString() }));
                                    DataErrTreatEvent dataErrTreatEvent = new DataErrTreatEvent(dataErrInfo);
                                    DataErrTreat(Hook.DataCheckParaSet as object, dataErrTreatEvent);
                                }
                                break;

                            case "LINE":
                                if (pfeatureclass.ShapeType != ESRI.ArcGIS.Geometry.esriGeometryType.esriGeometryPolyline)
                                {
                                    //传递错误日志
                                    IDataErrInfo      dataErrInfo       = new DataErrInfo(new List <object>(new object[] { "批量检查", "数据结构检查", dataCheckParaSet.Workspace.PathName, enumErrorType.要素类类型不一致.GetHashCode(), "目标要素类应为 线 类型", 0, 0, pFeatureClassName, 0, "", 0, false, System.DateTime.Now.ToString() }));
                                    DataErrTreatEvent dataErrTreatEvent = new DataErrTreatEvent(dataErrInfo);
                                    DataErrTreat(Hook.DataCheckParaSet as object, dataErrTreatEvent);
                                }
                                break;

                            case "AREA":
                                if (pfeatureclass.ShapeType != ESRI.ArcGIS.Geometry.esriGeometryType.esriGeometryPolygon)
                                {
                                    //传递错误日志
                                    IDataErrInfo      dataErrInfo       = new DataErrInfo(new List <object>(new object[] { "批量检查", "数据结构检查", dataCheckParaSet.Workspace.PathName, enumErrorType.要素类类型不一致.GetHashCode(), "目标要素类应为 面 类型", 0, 0, pFeatureClassName, 0, "", 0, false, System.DateTime.Now.ToString() }));
                                    DataErrTreatEvent dataErrTreatEvent = new DataErrTreatEvent(dataErrInfo);
                                    DataErrTreat(Hook.DataCheckParaSet as object, dataErrTreatEvent);
                                }
                                break;

                            default:
                                break;
                            }
                        }
                        else
                        {
                            continue;
                        }
                        #endregion

                        //遍历字段
                        IAttributeList pAttrs = pTable.AttributeList;
                        long           FNum   = pAttrs.GetCount();

                        //检查非GIS平台定义的字段
                        IFields fields = pfeatureclass.Fields;

                        //循环属性表中的字段,添加到arcgis的字段对象中
                        for (int k = 0; k < FNum; k++)
                        {
                            //添加自定义属性字段
                            CheckFields(pAttrs, k, fields, pFeatureClassName, dataCheckParaSet);
                        }
                    }
                }
            }
            else
            {
                return;
            }
        }
        /// <summary>
        /// 执行检查
        /// </summary>
        /// <param name="AppHk"></param>
        public void ExcuteCheck(Plugin.Application.IAppGISRef AppHk)
        {
            Plugin.Application.IAppFormRef pAppForm = AppHk as Plugin.Application.IAppFormRef;

            ISchemeProject m_pProject = null;                                  //数据库结构文件对象
            int            m_DBScale  = 0;                                     //默认比例尺
            int            m_DSScale  = 0;                                     //数据集比例尺

            ///从图层上获取所有的要素类
            ///
            IMap CurMap = AppHk.MapControl.Map as IMap;                                //获得当前地图对象

            Dictionary <string, ILayer> pLayerDic = new Dictionary <string, ILayer>(); //记录加载到map上的图层对象

            for (int i = 0; i < CurMap.LayerCount; i++)
            {
                ILayer player = CurMap.get_Layer(i);

                //如果是图层组,则退出不做检查
                if (player is IGroupLayer)
                {
                    ICompositeLayer pComLayer = player as ICompositeLayer;
                    for (int k = 0; k < pComLayer.Count; k++)
                    {
                        ILayer mmLayer = pComLayer.get_Layer(k);
                        if (mmLayer == null)
                        {
                            continue;
                        }
                        IFeatureLayer mmFeaLyer = mmLayer as IFeatureLayer;
                        if (mmFeaLyer == null)
                        {
                            continue;
                        }
                        IDataset mDT      = mmFeaLyer.FeatureClass as IDataset;
                        string   tempName = mDT.Name;
                        if (tempName.Contains("."))
                        {
                            tempName = tempName.Substring(tempName.IndexOf('.') + 1);
                        }
                        if (!pLayerDic.ContainsKey(tempName))
                        {
                            pLayerDic.Add(tempName, mmLayer);
                        }
                    }
                    continue;
                }
                IFeatureLayer pFeatlayer = player as IFeatureLayer;
                if (pFeatlayer == null)
                {
                    continue;
                }
                IDataset pdataset = pFeatlayer.FeatureClass as IDataset;

                string tempNm = pdataset.Name;
                if (tempNm.Contains("."))
                {
                    tempNm = tempNm.Substring(tempNm.IndexOf('.') + 1);
                }
                if (player != null && !pLayerDic.ContainsKey(tempNm))
                {
                    pLayerDic.Add(tempNm, player);
                }
            }


            ///读取配置方案到对象
            ///
            m_pProject = new SchemeProjectClass();                                    //创建实例
            m_pProject.Load(this._DBSchemaDocPath, e_FileType.GO_SCHEMEFILETYPE_MDB); //加载schema文件

            if (m_pProject != null)
            {
                #region 获得比例尺信息
                string   DBScale       = m_pProject.get_MetaDataValue("Scale") as string; //获取比例尺信息(总工程中的默认比例尺)
                string[] DBPScaleArayy = DBScale.Split(':');
                m_DBScale = Convert.ToInt32(DBPScaleArayy[1]);
                #endregion

                IChildItemList pProjects = m_pProject as IChildItemList;
                //获取属性库集合信息
                ISchemeItem    pDBList  = pProjects.get_ItemByName("ATTRDB");
                IChildItemList pDBLists = pDBList as IChildItemList;
                //遍历属性库集合
                long DBNum = pDBLists.GetCount();
                for (int i = 0; i < DBNum; i++)
                {
                    m_DSScale = 0;    //比例尺信息

                    //取得属性库信息
                    ISchemeItem pDB = pDBLists.get_ItemByIndex(i);
                    ///获取数据集的比例尺信息,如果获取失败则,取默认比例尺信息
                    IAttribute pa = pDB.AttributeList.get_AttributeByName("Scale") as IAttribute;
                    if (pa == null)
                    {
                        m_DSScale = m_DBScale;
                    }
                    else
                    {
                        string[] DBScaleArayy = pa.Value.ToString().Split(':');
                        m_DSScale = Convert.ToInt32(DBScaleArayy[1]);
                    }

                    IChildItemList pDBs         = pDB as IChildItemList;
                    string         pDatasetName = pDB.Name;

                    ////遍历属性表
                    int TabNum = pDBs.GetCount();
                    for (int j = 0; j < TabNum; j++)
                    {
                        //获取属性表信息
                        ISchemeItem pTable            = pDBs.get_ItemByIndex(j); //获取属性表对象
                        string      pFeatureClassName = pTable.Name;             //要素类名称

                        ///检查图层是否存在
                        if (!pLayerDic.ContainsKey(pFeatureClassName))
                        {
                            ///触发错误事件
                            this._StructErrorEventArgs.ErrorName        = "要素类缺失";
                            this._StructErrorEventArgs.ErrDescription   = "该要素类在标准中存在,却在当前数据中不存在";
                            this._StructErrorEventArgs.FeatureClassName = pFeatureClassName;
                            this.OnErrorFind(AppHk, this._StructErrorEventArgs);
                            this.OnProgressStep(AppHk, j + 1, TabNum);
                            continue;
                        }

                        #region 检查要素类类型是否与配置方案一致
                        string pFeatureClassType = pTable.Value as string;   //要素类类型
                        ///检查图层类型是否一致
                        ///
                        ILayer player;

                        bool GetlyrSeccess = pLayerDic.TryGetValue(pFeatureClassName, out player);

                        if (GetlyrSeccess)
                        {
                            IFeatureLayer pFeatureLayer = player as IFeatureLayer;

                            switch (pFeatureClassType)
                            {
                            case "ANNO":
                                if (pFeatureLayer.FeatureClass.FeatureType != esriFeatureType.esriFTAnnotation)
                                {
                                    ///触发错误事件
                                    this._StructErrorEventArgs.ErrorName        = "要素类类型不一致";
                                    this._StructErrorEventArgs.ErrDescription   = "该要素类在标准中被定义为注记类型";
                                    this._StructErrorEventArgs.FeatureClassName = pFeatureClassName;
                                    this.OnErrorFind(AppHk, this._StructErrorEventArgs);
                                }
                                break;

                            case "POINT":
                                if (pFeatureLayer.FeatureClass.ShapeType != ESRI.ArcGIS.Geometry.esriGeometryType.esriGeometryPoint)
                                {
                                    ///触发错误事件
                                    this._StructErrorEventArgs.ErrorName        = "要素类类型不一致";
                                    this._StructErrorEventArgs.ErrDescription   = "该要素类在标准中被定义为点要素类型";
                                    this._StructErrorEventArgs.FeatureClassName = pFeatureClassName;
                                    this.OnErrorFind(AppHk, this._StructErrorEventArgs);
                                }
                                break;

                            case "LINE":
                                if (pFeatureLayer.FeatureClass.ShapeType != ESRI.ArcGIS.Geometry.esriGeometryType.esriGeometryPolyline)
                                {
                                    ///触发错误事件
                                    this._StructErrorEventArgs.ErrorName        = "要素类类型不一致";
                                    this._StructErrorEventArgs.ErrDescription   = "该要素类在标准中被定义为线要素类型";
                                    this._StructErrorEventArgs.FeatureClassName = pFeatureClassName;
                                    this.OnErrorFind(AppHk, this._StructErrorEventArgs);
                                }
                                break;

                            case "AREA":
                                if (pFeatureLayer.FeatureClass.ShapeType != ESRI.ArcGIS.Geometry.esriGeometryType.esriGeometryPolygon)
                                {
                                    ///触发错误事件
                                    this._StructErrorEventArgs.ErrorName        = "要素类类型不一致";
                                    this._StructErrorEventArgs.ErrDescription   = "该要素类在标准中被定义为面要素类型";
                                    this._StructErrorEventArgs.FeatureClassName = pFeatureClassName;
                                    this.OnErrorFind(AppHk, this._StructErrorEventArgs);
                                }
                                break;

                            default:
                                break;
                            }
                        }
                        else
                        {
                            ///触发错误事件
                            this._StructErrorEventArgs.ErrorName        = "获取要素类失败";
                            this._StructErrorEventArgs.ErrDescription   = "获取图层失败";
                            this._StructErrorEventArgs.FeatureClassName = pFeatureClassName;
                            this.OnErrorFind(AppHk, this._StructErrorEventArgs);
                            this.OnProgressStep(AppHk, j + 1, TabNum);
                            continue;
                        }
                        #endregion

                        //遍历字段
                        IAttributeList pAttrs = pTable.AttributeList;
                        long           FNum   = pAttrs.GetCount();

                        //检查非GIS平台定义的字段
                        IFeatureLayer pChecklyr     = player as IFeatureLayer;
                        IFeatureClass pFeatureClass = pChecklyr.FeatureClass;
                        IFields       fields        = pFeatureClass.Fields;

                        //循环属性表中的字段,添加到arcgis的字段对象中
                        for (int k = 0; k < FNum; k++)
                        {
                            //添加自定义属性字段
                            CheckFields(pAttrs, k, fields, pFeatureClassName, AppHk);
                        }

                        this.OnProgressStep(AppHk, j + 1, TabNum);
                    }
                }
            }
            else
            {
                SetCheckState.Message(pAppForm, "提示", "加载配置方案失败!");
            }
        }
        /// <summary>
        /// 创建库体建构
        /// </summary>
        /// <param name="DbTemplatePath">库体配置方案模板路径</param>
        /// <param name="IsHisDb">是否为历史库体</param>
        /// <param name="ex"></param>
        public void CreateDataBase(string DbTemplatePath, bool IsHisDb, out Exception ex)
        {
            FrmProcessBar ProcFrm = new FrmProcessBar();

            ProcFrm.Show();
            ex = null;
            //***********************************************
            //guozheng added 保存表名和建表的SQL提供用户选择
            Dictionary <string, string> TableDic = new Dictionary <string, string>();
            //***********************************************
            ISchemeProject m_pProject = null;
            int            m_DBScale  = -1;/////比例尺信息

            ProcFrm.SetFrmProcessBarText("正在加载配置方案");
            #region 加载配置方案
            List <string> ltablename = new List <string>();
            try
            {
                m_pProject = new SchemeProjectClass();     //创建实例
                int    index    = DbTemplatePath.LastIndexOf('.');
                string lastName = DbTemplatePath.Substring(index + 1);
                if (lastName == "mdb")
                {
                    m_pProject.Load(DbTemplatePath, e_FileType.GO_SCHEMEFILETYPE_MDB);    //加载schema文件
                }
                else if (lastName == "gosch")
                {
                    m_pProject.Load(DbTemplatePath, e_FileType.GO_SCHEMEFILETYPE_GOSCH);    //加载schema文件
                }
                else
                {
                    ex = new Exception("数据库配置方案文件格式不规范,请检查");
                    ProcFrm.Close();
                    return;
                }

                ///如果加载成功则获取比例尺返回true,否则返回false
                if (m_pProject != null)
                {
                    string   DBScale      = m_pProject.get_MetaDataValue("Scale") as string; //获取比例尺信息(总工程中的默认比例尺)
                    string[] DBScaleArayy = DBScale.Split(':');
                    m_DBScale = Convert.ToInt32(DBScaleArayy[1]);
                }
                else
                {
                    ex = new Exception("加载数据库配置方案文件:" + DbTemplatePath + "失败!");
                    ProcFrm.Close();
                    return;
                }
            }
            catch
            {
                ex = new Exception("加载数据库配置方案文件:" + DbTemplatePath + "失败!");
                ProcFrm.Close();
                return;
            }
            #endregion
            List <string> DataSpace     = new List <string>();
            string        sDataBaseName = string.Empty;
            string        sNow          = DateTime.Now.ToLongDateString();
            #region 获取字段信息
            try
            {
                IChildItemList pProjects = m_pProject as IChildItemList;
                //获取属性库集合信息
                ISchemeItem    pDBList  = pProjects.get_ItemByName("ATTRDB");
                IChildItemList pDBLists = pDBList as IChildItemList;
                //遍历属性库集合
                long DBNum = pDBLists.GetCount();
                for (int i = 0; i < DBNum; i++)
                {
                    int m_DSScale = 0;    //比例尺信息
                    #region 获取比例尺
                    //取得属性库信息
                    ISchemeItem pDB = pDBLists.get_ItemByIndex(i);
                    ///获取数据集的比例尺信息,如果获取失败则,取默认比例尺信息
                    IAttribute pa = pDB.AttributeList.get_AttributeByName("Scale") as IAttribute;
                    if (pa == null)
                    {
                        m_DSScale = m_DBScale;
                    }
                    else
                    {
                        string[] DBScaleArayy = pa.Value.ToString().Split(':');
                        m_DSScale = Convert.ToInt32(DBScaleArayy[1]);
                    }
                    #endregion
                    IChildItemList pDBs         = pDB as IChildItemList;
                    string         pDatasetName = pDB.Name;
                    DataSpace.Add(pDatasetName);
                    sDataBaseName = pDatasetName;
                    //////////////////////////////////////创建库/////////////////////
                    //创建地物类集合
                    //遍历属性表
                    long TabNum = pDBs.GetCount();
                    ProcFrm.SetFrmProcessBarMax(TabNum);
                    for (int j = 0; j < TabNum; j++)
                    {
                        //获取属性表信息
                        ISchemeItem pTable = pDBs.get_ItemByIndex(j);  //获取属性表对象
                        ProcFrm.SetFrmProcessBarValue(j);
                        ProcFrm.SetFrmProcessBarText("正在获取属性表");

                        string pFeatureClassName = pTable.Name;            //要素类名称
                        string pFeatureClassType = pTable.Value as string; //要素类类型
                        string sTableName        = pFeatureClassName;
                        string sTableType        = pFeatureClassType;
                        //获得地物类的类型
                        string sField     = string.Empty;
                        string sViewField = string.Empty;
                        sField     += ModuleData.s_KeyFieldName + " NUMBER PRIMARY KEY,";
                        sViewField += ModuleData.s_KeyFieldName + ",";
                        ///////几何字段
                        sField = sField + ModuleData.s_GeometryFieldName + "  " + "MDSYS.SDO_GEOMETRY,";

                        if (pFeatureClassType == "ANNO")///////注记层不予处理
                        {
                            continue;
                        }

                        //遍历字段
                        IAttributeList pAttrs  = pTable.AttributeList;
                        long           FNum    = pAttrs.GetCount();
                        int            lfldcnt = pAttrs.GetCount();
                        int            n       = 0;
                        for (n = 0; n < lfldcnt; n++)
                        {
                            IAttribute pAttr = pAttrs.get_AttributeByIndex(n);
                            //获取扩展属性信息
                            IAttributeDes pAttrDes = pAttr.Description;
                            //以下变量用来定义字段的属性
                            string fieldName  = pAttr.Name;                           //记录字段名称
                            string fieldType  = pAttr.Type.ToString();                //记录字段类型
                            int    fieldLen   = Convert.ToInt32(pAttrDes.InputWidth); //记录字段长度
                            bool   isNullable = pAttrDes.AllowNull;                   //记录字段是否允许空值
                            if (fieldLen <= 0)
                            {
                                fieldLen = 30;
                            }
                            int  precision = Convert.ToInt32(pAttrDes.PrecisionEx);       //精度
                            bool required  = bool.Parse(pAttrDes.Necessary.ToString());
                            ////////////////记录字段用于创建表///////////////////
                            string sFildType = string.Empty;
                            switch (fieldType)
                            {
                            case "GO_VALUETYPE_STRING":
                                sFildType = "VARCHAR2(" + fieldLen.ToString() + ")";
                                break;

                            case "GO_VALUETYPE_LONG":
                                sFildType = "NUMBER";
                                break;

                            case "GO_VALUETYPE_DATE":
                                sFildType = "DATE";
                                break;

                            case "GO_VALUETYPE_FLOAT":
                                sFildType = "FLOAT";
                                break;

                            case "GO_VALUETYPE_DOUBLE":
                                sFildType = "NUMBER";
                                break;

                            case "GO_VALUETYPE_BYTE":
                                sFildType = "BLOB";
                                break;

                            case "GO_VALUETYPE_BOOL":
                                sFildType = "CHAR";
                                break;

                            default:
                                continue;
                                break;
                            }

                            if (!string.IsNullOrEmpty(sFildType))
                            {
                                if (fieldType == "GO_VALUETYPE_BOOL")
                                {
                                    sFildType += " CHECK (" + fieldName + " IN('N','Y'))";
                                }
                                else
                                {
                                    //************************************
                                    //guozheng 2010-12-8 added 增加非空判断
                                    if (!isNullable)
                                    {
                                        sFildType += " NOT NULL";
                                    }
                                    //************************************
                                }
                                sField      = sField + " " + fieldName + "  " + sFildType + ",";
                                sViewField += fieldName + ",";
                            }
                            else
                            {
                                continue;
                            }
                        }

                        string sMaxvalue = DateTime.MaxValue.ToLongDateString();
                        ///////////////////////////////创建表/////////////sTableName,sField
                        ProcFrm.SetFrmProcessBarText("正在组织表字段");
                        if (IsHisDb)                                 /////若是历史库表后增加后缀
                        {
                            sTableName = sTableName.Trim() + "_GOH"; ///////增加后缀
                            ///////增加字段
                            sField = sField + "FromDate" + "  " + "VARCHAR2(30)" + " " + "DEFAULT('" + sNow + "'),";
                            sField = sField + "ToDate" + "  " + "VARCHAR2(30)" + " " + "DEFAULT('" + sMaxvalue + "'),";
                            sField = sField + "SourceOID" + "  " + "NUMBER" + ",";
                            sField = sField + "State" + "  " + "NUMBER" + ",";
                            sField = sField + "VERSION" + "  " + "NUMBER" + " " + "DEFAULT(0) NOT NULL,";
                        }
                        //////构建建表SQL语句
                        string CreateSQL = string.Empty;
                        if (sTableType != "ANNO")/////不是注记层
                        {
                            sField    = sField.Substring(0, sField.LastIndexOf(","));
                            CreateSQL = "CREATE TABLE " + this._User.Trim() + "." + sTableName.Trim() + " " + "(" + sField + ")";
                        }
                        else////////注记层
                        {
                            continue;
                        }
                        //////////
                        ProcFrm.SetFrmProcessBarText("记录表" + sTableName);
                        //////////
                        if (!IsHisDb)
                        {
                            if (!TableDic.ContainsKey(sTableName.Trim()))
                            {
                                TableDic.Add(sTableName.Trim(), CreateSQL);
                            }
                        }
                        if (IsHisDb)
                        {
                            int index = sTableName.IndexOf("_GOH");
                            if (index < 0)
                            {
                                ex = new Exception("历史表名称不规范"); return;
                            }
                            string userTableName = sTableName.Substring(0, index);
                            string strsql        = "SELECT COUNT(*) FROM " + userTableName;
                            CreateTable(strsql, out ex); ////判断用户表是否存在
                            if (ex != null)              ////用户表不存在,不需要建立历史表
                            {
                                continue;
                            }
                            InitialHisTable(sTableName, CreateSQL, sViewField, out ex);
                            //if (!TableDic.ContainsKey(sTableName.Trim()))
                            //{
                            //    TableDic.Add(sTableName.Trim(), CreateSQL);
                            //}
                        }
                        ////////////////////////////////////////////////////////////////
                    }
                }
                ProcFrm.Close();
                if (!IsHisDb)
                {
                    ProcFrm.SetFrmProcessBarText("正在创建远程日志表");
                    /////////建立远程日志表//////
                    string LogSQL = "CREATE TABLE GO_DATABASE_UPDATELOG(OID NUMBER,STATE NUMBER,LAYERNAME VARCHAR2(30),LASTUPDATE DATE,VERSION NUMBER DEFAULT(0) NOT NULL,XMIN NUMBER,XMAX NUMBER,YMIN NUMBER,YMAX NUMBER)";
                    ltablename.Add("GO_DATABASE_UPDATELOG");
                    /////////远程更新日志
                    TableDic.Add("远程日志表:GO_DATABASE_UPDATELOG", LogSQL);
                    /////////数据库版本表
                    LogSQL = "CREATE TABLE go_database_version(VERSION NUMBER DEFAULT(0) NOT NULL,USERNAME VARCHAR2(30),VERSIONTIME DATE,DES VARCHAR2(30))";
                    ltablename.Add("go_database_version");
                    TableDic.Add("数据库版本表:go_database_version", LogSQL);
                    if (TableDic.Count > 0)
                    {
                        frmChooseTable fChooseTables = new frmChooseTable(TableDic, this._Server, this._User, this._Password);
                        if (DialogResult.OK == fChooseTables.ShowDialog())
                        {
                            Dictionary <string, string> getCreatedTables = fChooseTables.CreatedTable;
                        }
                        else
                        {
                            ex = new Exception("取消操作");
                            ProcFrm.Close();
                            return;
                        }
                    }
                }
                ProcFrm.Close();
            }
            catch (Exception dd)
            {
                //SysCommon.Error.ErrorHandle.ShowFrmErrorHandle("提示", dd.Message);
                ex = dd;
                ProcFrm.Close();
            }

            #endregion
            System.Runtime.InteropServices.Marshal.ReleaseComObject(m_pProject);
        }