📄 adzone.cs
字号:
info.ZoneIntro = rdr.GetString("ZoneIntro");
info.ZoneType = (ADZoneType) rdr.GetInt32("ZoneType");
info.DefaultSetting = rdr.GetBoolean("DefaultSetting");
info.Setting = rdr.GetString("ZoneSetting");
info.ZoneWidth = rdr.GetInt32("ZoneWidth");
info.ZoneHeight = rdr.GetInt32("ZoneHeight");
info.Active = rdr.GetBoolean("Active");
info.ShowType = rdr.GetInt32("ShowType");
info.UpdateTime = rdr.GetDateTime("UpdateTime");
return info;
}
public IList<ADZoneInfo> GetAllADZone(int startRowIndexId, int maxNumberRows, ADZoneSearchType listType, string keywords)
{
Database database = DatabaseFactory.CreateDatabase();
IList<ADZoneInfo> list = new List<ADZoneInfo>();
string storedProcedureName = "PR_Common_GetList";
string str2 = BuildQuery(listType, keywords);
DbCommand storedProcCommand = database.GetStoredProcCommand(storedProcedureName);
database.AddInParameter(storedProcCommand, "@StartRows", DbType.Int32, startRowIndexId);
database.AddInParameter(storedProcCommand, "@PageSize", DbType.Int32, maxNumberRows);
database.AddInParameter(storedProcCommand, "@SortColumn", DbType.String, "ZoneID");
database.AddInParameter(storedProcCommand, "@StrColumn", DbType.String, "*");
database.AddInParameter(storedProcCommand, "@Sorts", DbType.String, "DESC");
database.AddInParameter(storedProcCommand, "@Filter", DbType.String, str2);
database.AddInParameter(storedProcCommand, "@TableName", DbType.String, "PE_AdZone");
database.AddOutParameter(storedProcCommand, "@Total", DbType.Int32, maxNumberRows);
using (NullableDataReader reader = new NullableDataReader(database.ExecuteReader(storedProcCommand)))
{
while (reader.Read())
{
list.Add(GetAdZoneInfoFromrdr(reader));
}
}
this.m_NumADZones = (int) database.GetParameterValue(storedProcCommand, "@Total");
return list;
}
public IList<ADZoneInfo> GetImportList(string importDatabase)
{
OleDbConnection connection = new OleDbConnection("Provider=Microsoft.Jet.OleDb.4.0;Data Source=" + importDatabase);
IList<ADZoneInfo> list = new List<ADZoneInfo>();
try
{
connection.Open();
OleDbCommand command = new OleDbCommand(" SELECT ZoneID,ZoneName,ZoneJSName,ZoneIntro,ZoneType,DefaultSetting,ZoneSetting,ZoneWidth,ZoneHeight,ShowType,Active,UpdateTime FROM PE_AdZone ORDER BY ZoneId ASC", connection);
NullableDataReader rdr = new NullableDataReader(command.ExecuteReader(CommandBehavior.CloseConnection));
while (rdr.Read())
{
list.Add(GetAdZoneInfoFromrdr(rdr));
}
}
catch
{
}
finally
{
connection.Close();
}
return list;
}
private static int GetMaxADZoneId()
{
Database database = DatabaseFactory.CreateDatabase();
DbCommand sqlStringCommand = database.GetSqlStringCommand("SELECT Max(ZoneID) FROM PE_AdZone");
if (database.ExecuteScalar(sqlStringCommand) == DBNull.Value)
{
return 1;
}
return (((int) database.ExecuteScalar(sqlStringCommand)) + 1);
}
public string GetNewJSName()
{
return (DateTime.Today.Year.ToString() + DateTime.Today.Month.ToString().PadLeft(2, '0') + "/" + GetMaxADZoneId().ToString() + ".js");
}
private static Parameters GetParameters(ADZoneInfo adZoneInfo)
{
Parameters parameters = new Parameters();
parameters.AddInParameter("@ZoneName", DbType.String, adZoneInfo.ZoneName);
parameters.AddInParameter("@ZoneJSName", DbType.String, adZoneInfo.ZoneJSName);
parameters.AddInParameter("@ZoneIntro", DbType.String, adZoneInfo.ZoneIntro);
parameters.AddInParameter("@ZoneType", DbType.Int32, adZoneInfo.ZoneType);
parameters.AddInParameter("@DefaultSetting", DbType.Boolean, adZoneInfo.DefaultSetting);
parameters.AddInParameter("@ZoneSetting", DbType.String, adZoneInfo.Setting);
parameters.AddInParameter("@ZoneWidth", DbType.Int32, adZoneInfo.ZoneWidth);
parameters.AddInParameter("@ZoneHeight", DbType.Int32, adZoneInfo.ZoneHeight);
parameters.AddInParameter("@Active", DbType.Boolean, adZoneInfo.Active);
parameters.AddInParameter("@ShowType", DbType.Int32, adZoneInfo.ShowType);
parameters.AddInParameter("@UpdateTime", DbType.DateTime, adZoneInfo.UpdateTime);
return parameters;
}
private static DbCommand GetProcdbComm(Database db, string proName, ADZoneInfo adZoneInfo)
{
DbCommand storedProcCommand = db.GetStoredProcCommand(proName);
db.AddInParameter(storedProcCommand, "@ZoneId", DbType.Int32, adZoneInfo.ZoneId);
db.AddInParameter(storedProcCommand, "@ZoneName", DbType.String, adZoneInfo.ZoneName);
db.AddInParameter(storedProcCommand, "@ZoneJSName", DbType.String, adZoneInfo.ZoneJSName);
db.AddInParameter(storedProcCommand, "@ZoneIntro", DbType.String, adZoneInfo.ZoneIntro);
db.AddInParameter(storedProcCommand, "@ZoneType", DbType.Int32, adZoneInfo.ZoneType);
db.AddInParameter(storedProcCommand, "@DefaultSetting", DbType.Boolean, adZoneInfo.DefaultSetting);
db.AddInParameter(storedProcCommand, "@ZoneSetting", DbType.String, adZoneInfo.Setting);
db.AddInParameter(storedProcCommand, "@ZoneWidth", DbType.Int32, adZoneInfo.ZoneWidth);
db.AddInParameter(storedProcCommand, "@ZoneHeight", DbType.Int32, adZoneInfo.ZoneHeight);
db.AddInParameter(storedProcCommand, "@Active", DbType.Boolean, adZoneInfo.Active);
db.AddInParameter(storedProcCommand, "@ShowType", DbType.Int32, adZoneInfo.ShowType);
db.AddInParameter(storedProcCommand, "@UpdateTime", DbType.DateTime, adZoneInfo.UpdateTime);
return storedProcCommand;
}
public int GetTotalOfADZone()
{
return this.m_NumADZones;
}
public bool ImportData(string zoneId, string importDatabase)
{
bool flag;
Database db = DatabaseFactory.CreateDatabase();
StringBuilder builder = new StringBuilder("");
builder.Append(" SELECT ZoneID,ZoneName,ZoneJSName,ZoneIntro,ZoneType,DefaultSetting,ZoneSetting,ZoneWidth,ZoneHeight,ShowType,Active,UpdateTime FROM PE_AdZone ");
OleDbConnection connection = new OleDbConnection("Provider=Microsoft.Jet.OleDb.4.0;Data Source=" + importDatabase);
try
{
connection.Open();
builder.Append("Where ZoneID in (" + zoneId + ") order by ZoneID");
OleDbCommand command = new OleDbCommand(builder.ToString(), connection);
NullableDataReader reader = new NullableDataReader(command.ExecuteReader(CommandBehavior.CloseConnection));
while (reader.Read())
{
ADZoneInfo adZoneInfo = new ADZoneInfo();
adZoneInfo.ZoneId = GetMaxADZoneId();
adZoneInfo.ZoneName = reader.GetString("ZoneName");
adZoneInfo.ZoneJSName = reader.GetString("ZoneJSName");
adZoneInfo.ZoneIntro = reader.GetString("ZoneIntro");
adZoneInfo.ZoneType = (ADZoneType) reader.GetInt32("ZoneType");
adZoneInfo.DefaultSetting = reader.GetBoolean("DefaultSetting");
adZoneInfo.Setting = reader.GetString("ZoneSetting");
adZoneInfo.ZoneWidth = reader.GetInt32("ZoneWidth");
adZoneInfo.ZoneHeight = reader.GetInt32("ZoneHeight");
adZoneInfo.ShowType = reader.GetInt32("ShowType");
adZoneInfo.Active = reader.GetBoolean("Active");
adZoneInfo.UpdateTime = reader.GetDateTime("UpdateTime");
DbCommand command2 = GetProcdbComm(db, "PR_Ad_ADZone_ADD", adZoneInfo);
try
{
db.ExecuteNonQuery(command2);
continue;
}
catch
{
reader.Close();
return false;
}
}
flag = true;
}
catch
{
flag = false;
}
finally
{
connection.Close();
}
return flag;
}
public bool PauseADZone(string id)
{
Parameters cmdParams = new Parameters();
cmdParams.AddInParameter("@strZoneId", DbType.String, id);
return DBHelper.ExecuteProc("PR_AD_ADZone_Pause", cmdParams);
}
public bool Update(ADZoneInfo adZoneInfo)
{
Parameters cmdParams = GetParameters(adZoneInfo);
cmdParams.AddInParameter("@ZoneId", DbType.Int32, adZoneInfo.ZoneId);
return DBHelper.ExecuteProc("PR_AD_ADZone_UPDATE", cmdParams);
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -