public int GetNodeFcid(int nodeId) { NodeFcIdsPage page = LoadNodeFcIdPage(NetworkObjectSerializer.Page(nodeId)); if (page == null) { return(-1); } return(page.GetNodeFcId(nodeId)); }
private NodeFcIdsPage LoadNodeFcIdPage(int page) { lock (_thisLock) { if (_nodeFcIdsPages.ContainsKey(page)) { return(_nodeFcIdsPages[page]); } if (_dbfactory != null) { try { int from = page * NetworkObjectSerializer.PageSize + 1; int to = (page + 1) * NetworkObjectSerializer.PageSize; using (DbConnection connection = _dbfactory.CreateConnection()) { connection.ConnectionString = _connectionString; DbCommand command = _dbfactory.CreateCommand(); command.Connection = connection; command.CommandText = "select " + _dbNames.DbColName("FDB_OID") + "," + _dbNames.DbColName("FCID") + " from " + _nodeTableName + " where " + _dbNames.DbColName("FCID") + ">-1 and " + _dbNames.DbColName("FDB_OID") + ">=" + from + " and " + _dbNames.DbColName("FDB_OID") + "<=" + to; connection.Open(); DbDataAdapter adapter = _dbfactory.CreateDataAdapter(); adapter.SelectCommand = command; DataTable tab = new DataTable(); adapter.Fill(tab); NodeFcIdsPage nodeFcIdsPage = new NodeFcIdsPage(); foreach (DataRow row in tab.Rows) { nodeFcIdsPage.Add(Convert.ToInt32(row["FDB_OID"]), Convert.ToInt32(row["FCID"])); } connection.Close(); _nodeFcIdsPages.Add(page, nodeFcIdsPage); return(nodeFcIdsPage); } } catch { } } return(null); } }