Пример #1
0
 public static bool WriteLog(int managerID,int boxID,  EnumLogAction action, string title, string description, string memo)
 {
     DB_Talk.Model.Data_SystemLog log = new DB_Talk.Model.Data_SystemLog();
     //string str = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
     log.dt_DateTime = DateTime.Now;
     log.ManagerID = managerID;
     log.ActionTypeID = action.GetHashCode();
     log.vc_Title = title;
     log.BoxID = boxID;
     log.vc_Description = description;
     log.vc_Memo = memo;
     if ((new DB_Talk.BLL.Data_SystemLog()).Add(log) > 0)
     {
         return true;
     }
     else
     {
         return false;
     }
 }
		/// <summary>
		/// 获得数据列表
		/// </summary>
		public List<DB_Talk.Model.Data_SystemLog> DataTableToList(DataSet ds)
		{
			List<DB_Talk.Model.Data_SystemLog> modelList = new List<DB_Talk.Model.Data_SystemLog>();
			if (ds == null) return modelList;
            DataTable dt = ds.Tables[0];
			int rowsCount = dt.Rows.Count;
			if (rowsCount > 0)
			{
				DB_Talk.Model.Data_SystemLog model;
				for (int n = 0; n < rowsCount; n++)
				{
				  model = new DB_Talk.Model.Data_SystemLog();	
                  if(dt.Rows[n]["ID"]!=null && dt.Rows[n]["ID"].ToString()!="")
				  {
				      model.ID=int.Parse(dt.Rows[n]["ID"].ToString());
				  }
				  if(dt.Rows[n]["BoxID"]!=null && dt.Rows[n]["BoxID"].ToString()!="")
				  {
				      model.BoxID=int.Parse(dt.Rows[n]["BoxID"].ToString());
				  }
				  if(dt.Rows[n]["ManagerID"]!=null && dt.Rows[n]["ManagerID"].ToString()!="")
				  {
				      model.ManagerID=int.Parse(dt.Rows[n]["ManagerID"].ToString());
				  }
				  if(dt.Rows[n]["vc_IP"]!=null && dt.Rows[n]["vc_IP"].ToString()!="")
				  {
				     model.vc_IP= dt.Rows[n]["vc_IP"].ToString();
				  }
				  if(dt.Rows[n]["ActionTypeID"]!=null && dt.Rows[n]["ActionTypeID"].ToString()!="")
				  {
				      model.ActionTypeID=int.Parse(dt.Rows[n]["ActionTypeID"].ToString());
				  }
				  if(dt.Rows[n]["vc_Title"]!=null && dt.Rows[n]["vc_Title"].ToString()!="")
				  {
				     model.vc_Title= dt.Rows[n]["vc_Title"].ToString();
				  }
				  if(dt.Rows[n]["vc_Description"]!=null && dt.Rows[n]["vc_Description"].ToString()!="")
				  {
				     model.vc_Description= dt.Rows[n]["vc_Description"].ToString();
				  }
				  if(dt.Rows[n]["i_Result"]!=null && dt.Rows[n]["i_Result"].ToString()!="")
				  {
				      model.i_Result=int.Parse(dt.Rows[n]["i_Result"].ToString());
				  }
				  if(dt.Rows[n]["dt_DateTime"]!=null && dt.Rows[n]["dt_DateTime"].ToString()!="")
				  {
				      model.dt_DateTime=DateTime.Parse(dt.Rows[n]["dt_DateTime"].ToString());
				  }
				  if(dt.Rows[n]["vc_Memo"]!=null && dt.Rows[n]["vc_Memo"].ToString()!="")
				  {
				     model.vc_Memo= dt.Rows[n]["vc_Memo"].ToString();
				  }
				  if(dt.Rows[n]["i_Flag"]!=null && dt.Rows[n]["i_Flag"].ToString()!="")
				  {
				      model.i_Flag=int.Parse(dt.Rows[n]["i_Flag"].ToString());
				  }
				   modelList.Add(model);
				
				}
			}
			return modelList;
		}
		/// <summary>
		/// 根据条件得到一个对象实体
		/// </summary>
		public DB_Talk.Model.Data_SystemLog GetModel(string strWhere)
		{
			StringBuilder strSql=new StringBuilder();
			strSql.Append("  select top 1 ");
			strSql.Append("  ID, BoxID, ManagerID, vc_IP, ActionTypeID, vc_Title, vc_Description, i_Result, dt_DateTime, vc_Memo, i_Flag  ");			
			strSql.Append("  from Data_SystemLog ");
			if(strWhere.Trim()!="")
			{
				strSql.Append(" where "+strWhere);
			}
			DB_Talk.Model.Data_SystemLog model=new DB_Talk.Model.Data_SystemLog();
			DataSet ds=GetDataSet(strSql.ToString());
			if(ds!=null && ds.Tables[0].Rows.Count>0)
			{
                model=DataTableToList(ds)[0];						
				return model;
			}
			else
			{
				return null;
			}
		}