326 lines
13 KiB
C#
326 lines
13 KiB
C#
|
|
using System;
|
|||
|
|
using System.Data;
|
|||
|
|
using System.Text;
|
|||
|
|
using System.Data.SqlClient;
|
|||
|
|
|
|||
|
|
namespace Mtxfw.DAL
|
|||
|
|
{
|
|||
|
|
/// <summary>
|
|||
|
|
/// <20><><EFBFBD>ݷ<EFBFBD><DDB7><EFBFBD><EFBFBD><EFBFBD>:user_live_online
|
|||
|
|
/// </summary>
|
|||
|
|
public partial class user_live_online : Mtxfw.Utility.Myabstract
|
|||
|
|
{
|
|||
|
|
public user_live_online()
|
|||
|
|
: base("user_live_online")
|
|||
|
|
{ }
|
|||
|
|
|
|||
|
|
/// <summary>
|
|||
|
|
/// <20><><EFBFBD><EFBFBD>һ<EFBFBD><D2BB><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
|
/// </summary>
|
|||
|
|
public int Add(Mtxfw.Model.user_live_online model)
|
|||
|
|
{
|
|||
|
|
StringBuilder strSql = new StringBuilder();
|
|||
|
|
strSql.Append("insert into user_live_online(");
|
|||
|
|
strSql.Append("MemberId,liveid,dz,ly,IP,ttype,isonline,addtime,gtype)");
|
|||
|
|
strSql.Append(" values (");
|
|||
|
|
strSql.Append("@MemberId,@liveid,@dz,@ly,@IP,@ttype,@isonline,@addtime,@gtype)");
|
|||
|
|
strSql.Append(";select SCOPE_IDENTITY()");
|
|||
|
|
SqlParameter[] parameters = {
|
|||
|
|
new SqlParameter("@MemberId", SqlDbType.Int),
|
|||
|
|
new SqlParameter("@liveid", SqlDbType.Int),
|
|||
|
|
new SqlParameter("@dz", SqlDbType.VarChar,250),
|
|||
|
|
new SqlParameter("@ly", SqlDbType.VarChar,250),
|
|||
|
|
new SqlParameter("@IP", SqlDbType.VarChar,250),
|
|||
|
|
new SqlParameter("@ttype", SqlDbType.Int),
|
|||
|
|
new SqlParameter("@isonline", SqlDbType.Int),
|
|||
|
|
new SqlParameter("@addtime", SqlDbType.DateTime),
|
|||
|
|
new SqlParameter("@gtype", SqlDbType.Int)};
|
|||
|
|
parameters[0].Value = model.MemberId;
|
|||
|
|
parameters[1].Value = model.liveid;
|
|||
|
|
parameters[2].Value = model.dz;
|
|||
|
|
parameters[3].Value = model.ly;
|
|||
|
|
parameters[4].Value = model.IP;
|
|||
|
|
parameters[5].Value = model.ttype;
|
|||
|
|
parameters[6].Value = model.isonline;
|
|||
|
|
parameters[7].Value = model.addtime;
|
|||
|
|
parameters[8].Value = model.gtype;
|
|||
|
|
string obj = Mtxfw.Utility.SqlDbHelper_U.GetObject(strSql.ToString(), parameters).ToString();
|
|||
|
|
if (obj == "")
|
|||
|
|
{
|
|||
|
|
return 0;
|
|||
|
|
}
|
|||
|
|
else
|
|||
|
|
{
|
|||
|
|
return Convert.ToInt32(obj);
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
/// <summary>
|
|||
|
|
/// <20><><EFBFBD><EFBFBD>һ<EFBFBD><D2BB><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
|
/// </summary>
|
|||
|
|
public bool Update(int isonline,int Id)
|
|||
|
|
{
|
|||
|
|
StringBuilder strSql = new StringBuilder();
|
|||
|
|
strSql.Append("update user_live_online set ");
|
|||
|
|
strSql.Append("isonline=@isonline");
|
|||
|
|
strSql.Append(" where Id=@Id");
|
|||
|
|
SqlParameter[] parameters = {
|
|||
|
|
new SqlParameter("@isonline", SqlDbType.Int),
|
|||
|
|
new SqlParameter("@Id", SqlDbType.Int)};
|
|||
|
|
parameters[0].Value = isonline;
|
|||
|
|
parameters[1].Value = Id;
|
|||
|
|
int rows = Mtxfw.Utility.SqlDbHelper_U.ExecuteCmd(strSql.ToString(), parameters);
|
|||
|
|
if (rows > 0)
|
|||
|
|
{
|
|||
|
|
return true;
|
|||
|
|
}
|
|||
|
|
else
|
|||
|
|
{
|
|||
|
|
return false;
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
/// <summary>
|
|||
|
|
/// <20><><EFBFBD><EFBFBD>һ<EFBFBD><D2BB><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
|
/// </summary>
|
|||
|
|
public bool Update(int isonline, DateTime outtime, int gtype, int liveid, int MemberId)
|
|||
|
|
{
|
|||
|
|
StringBuilder strSql = new StringBuilder();
|
|||
|
|
strSql.Append("update user_live_online set ");
|
|||
|
|
strSql.Append("isonline=@isonline,");
|
|||
|
|
strSql.Append("outtime=@outtime");
|
|||
|
|
strSql.Append(" where gtype=@gtype and liveid=@liveid And MemberId=@MemberId And isonline=0");
|
|||
|
|
SqlParameter[] parameters = {
|
|||
|
|
new SqlParameter("@isonline", SqlDbType.Int),
|
|||
|
|
new SqlParameter("@outtime", SqlDbType.DateTime),
|
|||
|
|
new SqlParameter("@gtype", SqlDbType.Int),
|
|||
|
|
new SqlParameter("@liveid", SqlDbType.Int),
|
|||
|
|
new SqlParameter("@MemberId", SqlDbType.Int),};
|
|||
|
|
parameters[0].Value = isonline;
|
|||
|
|
parameters[1].Value = outtime;
|
|||
|
|
parameters[2].Value = gtype;
|
|||
|
|
parameters[3].Value = liveid;
|
|||
|
|
parameters[4].Value = MemberId;
|
|||
|
|
int rows = Mtxfw.Utility.SqlDbHelper_U.ExecuteCmd(strSql.ToString(), parameters);
|
|||
|
|
if (rows > 0)
|
|||
|
|
{
|
|||
|
|
return true;
|
|||
|
|
}
|
|||
|
|
else
|
|||
|
|
{
|
|||
|
|
return false;
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
/// <summary>
|
|||
|
|
/// <20><><EFBFBD><EFBFBD>һ<EFBFBD><D2BB><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
|
/// </summary>
|
|||
|
|
public bool Update(int isonline, DateTime outtime, int gtype, int liveid, string IP, DateTime StartTime)
|
|||
|
|
{
|
|||
|
|
StringBuilder strSql = new StringBuilder();
|
|||
|
|
strSql.Append("update user_live_online set ");
|
|||
|
|
strSql.Append("isonline=@isonline,");
|
|||
|
|
strSql.Append("outtime=@outtime");
|
|||
|
|
strSql.Append(" where gtype=@gtype and liveid=@liveid And IP=@IP And isonline=0 And addtime>convert(datetime,'" + StartTime + "')");
|
|||
|
|
SqlParameter[] parameters = {
|
|||
|
|
new SqlParameter("@isonline", SqlDbType.Int),
|
|||
|
|
new SqlParameter("@outtime", SqlDbType.DateTime),
|
|||
|
|
new SqlParameter("@gtype", SqlDbType.Int),
|
|||
|
|
new SqlParameter("@liveid", SqlDbType.Int),
|
|||
|
|
new SqlParameter("@IP", SqlDbType.VarChar,50)};
|
|||
|
|
parameters[0].Value = isonline;
|
|||
|
|
parameters[1].Value = outtime;
|
|||
|
|
parameters[2].Value = gtype;
|
|||
|
|
parameters[3].Value = liveid;
|
|||
|
|
parameters[4].Value = IP;
|
|||
|
|
int rows = Mtxfw.Utility.SqlDbHelper_U.ExecuteCmd(strSql.ToString(), parameters);
|
|||
|
|
if (rows > 0)
|
|||
|
|
{
|
|||
|
|
return true;
|
|||
|
|
}
|
|||
|
|
else
|
|||
|
|
{
|
|||
|
|
return false;
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
/// <summary>
|
|||
|
|
/// <20><><EFBFBD><EFBFBD>һ<EFBFBD><D2BB><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
|
/// </summary>
|
|||
|
|
public Mtxfw.Model.user_live_online GetModel(int gtype, int liveid, string IP, DateTime StartTime)
|
|||
|
|
{
|
|||
|
|
StringBuilder strSql = new StringBuilder();
|
|||
|
|
strSql.Append("select top 1 * from user_live_online");
|
|||
|
|
strSql.Append(" where gtype=@gtype and ttype=1 and liveid=@liveid And IP=@IP and isonline=0 And addtime>convert(datetime,'" + StartTime + "')");
|
|||
|
|
SqlParameter[] parameters = {
|
|||
|
|
new SqlParameter("@gtype", SqlDbType.Int),
|
|||
|
|
new SqlParameter("@liveid", SqlDbType.Int),
|
|||
|
|
new SqlParameter("@IP", SqlDbType.VarChar,50)};
|
|||
|
|
parameters[0].Value = gtype;
|
|||
|
|
parameters[1].Value = liveid;
|
|||
|
|
parameters[2].Value = IP;
|
|||
|
|
Mtxfw.Model.user_live_online model = new Mtxfw.Model.user_live_online();
|
|||
|
|
DataSet ds = Mtxfw.Utility.SqlDbHelper_U.GetDataSet(strSql.ToString(), parameters);
|
|||
|
|
if (ds.Tables[0].Rows.Count > 0)
|
|||
|
|
{
|
|||
|
|
model.Id = int.Parse(ds.Tables[0].Rows[0]["Id"].ToString());
|
|||
|
|
model.MemberId = int.Parse(ds.Tables[0].Rows[0]["MemberId"].ToString());
|
|||
|
|
model.liveid = int.Parse(ds.Tables[0].Rows[0]["liveid"].ToString());
|
|||
|
|
model.dz = ds.Tables[0].Rows[0]["dz"].ToString();
|
|||
|
|
model.ly = ds.Tables[0].Rows[0]["ly"].ToString();
|
|||
|
|
model.IP = ds.Tables[0].Rows[0]["IP"].ToString();
|
|||
|
|
model.isonline = int.Parse(ds.Tables[0].Rows[0]["isonline"].ToString());
|
|||
|
|
model.ttype = int.Parse(ds.Tables[0].Rows[0]["ttype"].ToString());
|
|||
|
|
model.addtime = Convert.ToDateTime(ds.Tables[0].Rows[0]["addtime"].ToString());
|
|||
|
|
if (ds.Tables[0].Rows[0]["outtime"].ToString() != "")
|
|||
|
|
{
|
|||
|
|
model.outtime = Convert.ToDateTime(ds.Tables[0].Rows[0]["outtime"].ToString());
|
|||
|
|
}
|
|||
|
|
return model;
|
|||
|
|
}
|
|||
|
|
else
|
|||
|
|
{
|
|||
|
|
return null;
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
/// <summary>
|
|||
|
|
/// <20><><EFBFBD><EFBFBD>һ<EFBFBD><D2BB><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
|
/// </summary>
|
|||
|
|
public Mtxfw.Model.user_live_online GetModel(int gtype, int liveid, int MemberId, DateTime StartTime)
|
|||
|
|
{
|
|||
|
|
StringBuilder strSql = new StringBuilder();
|
|||
|
|
strSql.Append("select top 1 * from user_live_online");
|
|||
|
|
strSql.Append(" where gtype=@gtype and liveid=@liveid And MemberId=@MemberId and isonline=0 And addtime>convert(datetime,'" + StartTime + "') Order By addtime desc");
|
|||
|
|
SqlParameter[] parameters = {
|
|||
|
|
new SqlParameter("@gtype", SqlDbType.Int),
|
|||
|
|
new SqlParameter("@liveid", SqlDbType.Int),
|
|||
|
|
new SqlParameter("@MemberId", SqlDbType.Int),};
|
|||
|
|
parameters[0].Value = gtype;
|
|||
|
|
parameters[1].Value = liveid;
|
|||
|
|
parameters[2].Value = MemberId;
|
|||
|
|
Mtxfw.Model.user_live_online model = new Mtxfw.Model.user_live_online();
|
|||
|
|
DataSet ds = Mtxfw.Utility.SqlDbHelper_U.GetDataSet(strSql.ToString(), parameters);
|
|||
|
|
if (ds.Tables[0].Rows.Count > 0)
|
|||
|
|
{
|
|||
|
|
model.Id = int.Parse(ds.Tables[0].Rows[0]["Id"].ToString());
|
|||
|
|
model.MemberId = int.Parse(ds.Tables[0].Rows[0]["MemberId"].ToString());
|
|||
|
|
model.liveid = int.Parse(ds.Tables[0].Rows[0]["liveid"].ToString());
|
|||
|
|
model.dz = ds.Tables[0].Rows[0]["dz"].ToString();
|
|||
|
|
model.ly = ds.Tables[0].Rows[0]["ly"].ToString();
|
|||
|
|
model.IP = ds.Tables[0].Rows[0]["IP"].ToString();
|
|||
|
|
model.isonline = int.Parse(ds.Tables[0].Rows[0]["isonline"].ToString());
|
|||
|
|
model.ttype = int.Parse(ds.Tables[0].Rows[0]["ttype"].ToString());
|
|||
|
|
model.addtime = Convert.ToDateTime(ds.Tables[0].Rows[0]["addtime"].ToString());
|
|||
|
|
if (ds.Tables[0].Rows[0]["outtime"].ToString() != "")
|
|||
|
|
{
|
|||
|
|
model.outtime = Convert.ToDateTime(ds.Tables[0].Rows[0]["outtime"].ToString());
|
|||
|
|
}
|
|||
|
|
return model;
|
|||
|
|
}
|
|||
|
|
else
|
|||
|
|
{
|
|||
|
|
return null;
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
/// <summary>
|
|||
|
|
/// <20>õ<EFBFBD>һ<EFBFBD><D2BB><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʵ<EFBFBD><CAB5>
|
|||
|
|
/// </summary>
|
|||
|
|
public Mtxfw.Model.user_live_online GetModel(int Id)
|
|||
|
|
{
|
|||
|
|
|
|||
|
|
StringBuilder strSql = new StringBuilder();
|
|||
|
|
strSql.Append("select top 1 * from user_live_online ");
|
|||
|
|
strSql.Append(" where Id=@Id");
|
|||
|
|
SqlParameter[] parameters = {
|
|||
|
|
new SqlParameter("@Id", SqlDbType.Int,4)};
|
|||
|
|
parameters[0].Value = Id;
|
|||
|
|
|
|||
|
|
Mtxfw.Model.user_live_online model = new Mtxfw.Model.user_live_online();
|
|||
|
|
DataSet ds = Mtxfw.Utility.SqlDbHelper_U.GetDataSet(strSql.ToString(), parameters);
|
|||
|
|
if (ds.Tables[0].Rows.Count > 0)
|
|||
|
|
{
|
|||
|
|
model.Id = int.Parse(ds.Tables[0].Rows[0]["Id"].ToString());
|
|||
|
|
model.MemberId = int.Parse(ds.Tables[0].Rows[0]["MemberId"].ToString());
|
|||
|
|
model.liveid = int.Parse(ds.Tables[0].Rows[0]["liveid"].ToString());
|
|||
|
|
model.dz = ds.Tables[0].Rows[0]["dz"].ToString();
|
|||
|
|
model.ly = ds.Tables[0].Rows[0]["ly"].ToString();
|
|||
|
|
model.IP = ds.Tables[0].Rows[0]["IP"].ToString();
|
|||
|
|
model.isonline = int.Parse(ds.Tables[0].Rows[0]["isonline"].ToString());
|
|||
|
|
model.ttype = int.Parse(ds.Tables[0].Rows[0]["ttype"].ToString());
|
|||
|
|
model.addtime = Convert.ToDateTime(ds.Tables[0].Rows[0]["addtime"].ToString());
|
|||
|
|
if (ds.Tables[0].Rows[0]["outtime"].ToString() != "")
|
|||
|
|
{
|
|||
|
|
model.outtime = Convert.ToDateTime(ds.Tables[0].Rows[0]["outtime"].ToString());
|
|||
|
|
}
|
|||
|
|
return model;
|
|||
|
|
}
|
|||
|
|
else
|
|||
|
|
{
|
|||
|
|
return null;
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
/// <summary>
|
|||
|
|
/// ɾ<><C9BE>һ<EFBFBD><D2BB><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
|
/// </summary>
|
|||
|
|
public bool Delete(int Id)
|
|||
|
|
{
|
|||
|
|
|
|||
|
|
StringBuilder strSql = new StringBuilder();
|
|||
|
|
strSql.Append("delete from user_live_online ");
|
|||
|
|
strSql.Append(" where Id=@Id");
|
|||
|
|
SqlParameter[] parameters = {
|
|||
|
|
new SqlParameter("@Id", SqlDbType.Int,4)
|
|||
|
|
};
|
|||
|
|
parameters[0].Value = Id;
|
|||
|
|
|
|||
|
|
int rows = Mtxfw.Utility.SqlDbHelper_U.ExecuteCmd(strSql.ToString(), parameters);
|
|||
|
|
if (rows > 0)
|
|||
|
|
{
|
|||
|
|
return true;
|
|||
|
|
}
|
|||
|
|
else
|
|||
|
|
{
|
|||
|
|
return false;
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
|
|||
|
|
|
|||
|
|
/// <summary>
|
|||
|
|
/// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>б<EFBFBD>
|
|||
|
|
/// </summary>
|
|||
|
|
public DataSet GetList(string strWhere)
|
|||
|
|
{
|
|||
|
|
StringBuilder strSql = new StringBuilder();
|
|||
|
|
strSql.Append("select * ");
|
|||
|
|
strSql.Append(" FROM user_live_online ");
|
|||
|
|
if (strWhere.Trim() != "")
|
|||
|
|
{
|
|||
|
|
strSql.Append(" where " + strWhere);
|
|||
|
|
}
|
|||
|
|
return Mtxfw.Utility.SqlDbHelper_U.GetDataSet(strSql.ToString());
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
/// <summary>
|
|||
|
|
/// <20><><EFBFBD><EFBFBD>ǰ<EFBFBD><C7B0><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
|
/// </summary>
|
|||
|
|
public DataSet GetList(int Top, string strWhere, string filedOrder)
|
|||
|
|
{
|
|||
|
|
StringBuilder strSql = new StringBuilder();
|
|||
|
|
strSql.Append("select ");
|
|||
|
|
if (Top > 0)
|
|||
|
|
{
|
|||
|
|
strSql.Append(" top " + Top.ToString());
|
|||
|
|
}
|
|||
|
|
strSql.Append(" * ");
|
|||
|
|
strSql.Append(" FROM user_live_online ");
|
|||
|
|
if (strWhere.Trim() != "")
|
|||
|
|
{
|
|||
|
|
strSql.Append(" where " + strWhere);
|
|||
|
|
}
|
|||
|
|
strSql.Append(" order by " + filedOrder);
|
|||
|
|
return Mtxfw.Utility.SqlDbHelper_U.GetDataSet(strSql.ToString());
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|