private void InitContentGridByFeatureClass(OracleConnection conn, IFeatureClass pFeatureclass, string strRegionField) { if (pFeatureclass == null) { return; } string strTableName = (pFeatureclass as IDataset).Name; enumTmpDBCheckState state = enumTmpDBCheckState.NULL; if (_ListRegions == null) { _ListRegions = new List <string>(); } if (_DicCheckStates == null) { _DicCheckStates = new Dictionary <string, enumTmpDBCheckState>(); } OracleDataReader pReader = ModOracle.GetReader(conn, "select distinct " + strRegionField + " from " + strTableName); if (pReader != null) { while (pReader.Read()) { if (pReader.GetValue(0) != null) { string strRegion = pReader.GetValue(0).ToString(); if (!_ListRegions.Contains(strRegion)) { _ListRegions.Add(strRegion); } } } pReader.Close(); } for (int i = 0; i < _ListRegions.Count; i++) { string CurRegion = _ListRegions[i]; enumTmpDBCheckState CurState = enumTmpDBCheckState.NULL; if (_DicCheckStates.ContainsKey(CurRegion)) { CurState = _DicCheckStates[CurRegion]; } else { _DicCheckStates.Add(CurRegion, CurState); } if (CurState == enumTmpDBCheckState.Part) { continue; } pReader = ModOracle.GetReader(conn, "select distinct CheckState from " + strTableName + " where " + strRegionField + "='" + CurRegion + "'"); if (pReader != null) { while (pReader.Read()) { if (CurState == enumTmpDBCheckState.Part) { break; } object objValue = pReader.GetValue(0); if (objValue == null) { if (CurRegion == "140211") { int tmp = 0; } CurState = ModifyState(CurState, enumTmpDBCheckState.No); } else { if (objValue.ToString() == "Y") { CurState = ModifyState(CurState, enumTmpDBCheckState.Yes); } else { if (CurRegion == "140211") { int tmp = 0; } CurState = ModifyState(CurState, enumTmpDBCheckState.No); } } } pReader.Close(); _DicCheckStates[CurRegion] = CurState; } } }
private void InitContentGrid() { this.lblTips.Text = "读取审核状态..."; Application.DoEvents(); this.dGridCheckRes.Rows.Clear(); if (_CurFeatureDataset == null) { return; } if (this.cmbLayer.Text == "所有图层") { _CurFeatureClass = null; } string strRegionField = GetRegionField(); if (_Conn == null) { if (_ConnectXmlNode != null) { string Server = _ConnectXmlNode.Attributes["服务器"].Value.ToString(); string Database = _ConnectXmlNode.Attributes["数据库"].Value.ToString(); string strUser = _ConnectXmlNode.Attributes["用户"].Value.ToString(); string strPassword = _ConnectXmlNode.Attributes["密码"].Value.ToString(); _Conn = ModOracle.GetOracleConnection(Server, Database, strUser, strPassword); } } if (_Conn != null) { if (_Conn.State == System.Data.ConnectionState.Closed) { _Conn.Open(); } if (_CurFeatureClass == null) { this.dGridCheckRes.Rows.Clear(); progressBarX1.Visible = true; progressBarX1.Maximum = this.cmbLayer.Items.Count; progressBarX1.Minimum = 1; progressBarX1.Value = 1; progressBarX1.Step = 1; IEnumDataset pEnumDs = null; pEnumDs = _CurFeatureDataset.Subsets; pEnumDs.Reset(); IDataset pDs = pEnumDs.Next(); while (pDs != null) { IFeatureClass pFeatureClass = pDs as IFeatureClass; progressBarX1.PerformStep(); this.lblTips.Text = "读取'" + pFeatureClass.AliasName + "'图层审核状态..."; Application.DoEvents(); InitContentGridByFeatureClass(_Conn, pFeatureClass, strRegionField); pDs = pEnumDs.Next(); } } else { this.dGridCheckRes.Rows.Clear(); this.lblTips.Text = "读取'" + _CurFeatureClass.AliasName + "'图层审核状态..."; Application.DoEvents(); InitContentGridByFeatureClass(_Conn, _CurFeatureClass, strRegionField); } _Conn.Close(); if (_ListRegionNames == null) { _ListRegionNames = new List <string>(); } _ListRegionNames.Clear(); for (int i = 0; i < _ListRegions.Count; i++) { string strRegion = _ListRegions[i]; string strRegionName = GetRegionName(strRegion); _ListRegionNames.Add(strRegionName); } for (int i = 0; i < _ListRegions.Count; i++) { string strRegion = _ListRegions[i]; enumTmpDBCheckState CurState = _DicCheckStates[strRegion]; string strState = ""; switch (CurState) { case enumTmpDBCheckState.Yes: strState = "通过"; break; case enumTmpDBCheckState.No: strState = "未通过"; break; case enumTmpDBCheckState.Part: strState = "部分通过"; break; case enumTmpDBCheckState.NULL: strState = "无数据"; break; } this.dGridCheckRes.Rows.Add(_ListRegionNames[i], strState); } _Conn.Close(); progressBarX1.Visible = false; this.lblTips.Text = "获取审核状态完毕。"; Application.DoEvents(); } else { this.lblTips.Text = "获取临时库连接失败!"; Application.DoEvents(); } }