📄 celldb.cs
字号:
using System;
using System.Data;
using System.IO;
namespace NiceTracker
{
/// <summary>
/// Summary description for CellDB.
/// </summary>
public class CellDB
{
private const string filename = "cells.xml";
private static DataSet dsData = new DataSet( "data" );
private static DataTable dtCells = null;
public CellDB()
{
}
public const string CELL_UNKNOWN = "Unknown";
public static void Load()
{
if ( !File.Exists( filename ) )
{
dtCells = setupCellDB( dsData );
dsData.WriteXml( filename );
}
else
{
dsData.ReadXml( filename );
dtCells = setupCellDB( dsData );
}
}
public static void Save()
{
dsData.WriteXml( filename );
}
private static DataTable setupCellDB( DataSet ds )
{
DataTable dt = null;
if ( ds.Tables.Contains( "cells" ) )
dt = ds.Tables[ "cells" ];
else
{
dt = new DataTable( "cells" );
ds.Tables.Add( dt );
}
if ( !dt.Columns.Contains( "description" ) )
dt.Columns.Add( "description", typeof( string ) );
if ( !dt.Columns.Contains( "lac" ) )
dt.Columns.Add( "lac", typeof( string ) );
if ( !dt.Columns.Contains( "ci" ) )
dt.Columns.Add( "ci", typeof( string ) );
return dt;
}
public static bool IsNewCell( string LAC, string CI )
{
DataTable dtCells = dsData.Tables[ "cells" ];
DataRow[] rows = dtCells.Select( "lac='" + LAC + "' and ci='" + CI + "'" );
return ( rows.Length == 0 );
}
public static string GetDescription( GSMCell cell )
{
return GetDescription( cell.LAC, cell.CI );
}
public static string GetDescription( string LAC, string CI )
{
DataTable dtCells = dsData.Tables[ "cells" ];
DataRow[] rows = dtCells.Select( "lac='" + LAC + "' and ci='" + CI + "'" );
if ( rows.Length >= 1 )
return rows[0]["description"].ToString();
else
return CELL_UNKNOWN;
}
public static void AddNewCell( string LAC, string CI )
{
DataRow dr = dtCells.NewRow();
dr[ "lac" ] = LAC;
dr[ "ci" ] = CI;
dtCells.Rows.Add( dr );
}
public static DataTable DTCells
{
get
{
return dtCells;
}
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -