using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Data.SqlClient; using System.Data; using YTSoft.DBUtility; namespace YTSoft.BaseCallCenter.DAL { /// /// 数据访问类:T_CTI_Task /// public partial class T_CTI_Task { public T_CTI_Task() { } #region Method /// /// 是否存在该记录 /// public bool Exists(long TaskID) { StringBuilder strSql = new StringBuilder(); strSql.Append("select count(1) from T_CTI_Task"); strSql.Append(" where TaskID=@TaskID"); SqlParameter[] parameters = { new SqlParameter("@TaskID", SqlDbType.BigInt) }; parameters[0].Value = TaskID; return DbHelperSQL.Exists(strSql.ToString(), parameters); } /// /// 增加一条数据 /// public long Add(YTSoft.BaseCallCenter.Model.T_CTI_Task model) { StringBuilder strSql = new StringBuilder(); strSql.Append("insert into T_CTI_Task("); strSql.Append("TaskName,TrunkGroupID,CallerNum,CallType,ExInfo,MaxTrunkCount,IntensityCoefficient,ItemTableName,State,AddTime,y_PSort,y_TkModelId,y_SXH,y_FPCount,y_YJCount,y_HCCount,y_HSCount,y_HTCount,y_HMCount,y_OkCount,y_RFCount,y_ConsCount,y_InvlCount,y_NoAnswerCount,y_ShutDownCount)"); strSql.Append(" values ("); strSql.Append("@TaskName,@TrunkGroupID,@CallerNum,@CallType,@ExInfo,@MaxTrunkCount,@IntensityCoefficient,@ItemTableName,@State,@AddTime,@y_PSort,@y_TkModelId,@y_SXH,@y_FPCount,@y_YJCount,@y_HCCount,@y_HSCount,@y_HTCount,@y_HMCount,@y_OkCount,@y_RFCount,@y_ConsCount,@y_InvlCount,@y_NoAnswerCount,@y_ShutDownCount)"); strSql.Append(";select @@IDENTITY"); SqlParameter[] parameters = { new SqlParameter("@TaskName", SqlDbType.VarChar,200), new SqlParameter("@TrunkGroupID", SqlDbType.Int,4), new SqlParameter("@CallerNum", SqlDbType.VarChar,11), new SqlParameter("@CallType", SqlDbType.Int,4), new SqlParameter("@ExInfo", SqlDbType.VarChar,200), new SqlParameter("@MaxTrunkCount", SqlDbType.Int,4), new SqlParameter("@IntensityCoefficient", SqlDbType.Float,8), new SqlParameter("@ItemTableName", SqlDbType.VarChar,100), new SqlParameter("@State", SqlDbType.Int,4), new SqlParameter("@AddTime", SqlDbType.DateTime), new SqlParameter("@y_PSort", SqlDbType.Int,4), new SqlParameter("@y_TkModelId", SqlDbType.BigInt,8), new SqlParameter("@y_SXH", SqlDbType.Int,4), new SqlParameter("@y_FPCount", SqlDbType.Int,4), new SqlParameter("@y_YJCount", SqlDbType.Int,4), new SqlParameter("@y_HCCount", SqlDbType.Int,4), new SqlParameter("@y_HSCount", SqlDbType.Int,4), new SqlParameter("@y_HTCount", SqlDbType.Int,4), new SqlParameter("@y_HMCount", SqlDbType.Int,4), new SqlParameter("@y_OkCount", SqlDbType.Int,4), new SqlParameter("@y_RFCount", SqlDbType.Int,4), new SqlParameter("@y_ConsCount", SqlDbType.Int,4), new SqlParameter("@y_InvlCount", SqlDbType.Int,4), new SqlParameter("@y_NoAnswerCount", SqlDbType.Int,4), new SqlParameter("@y_ShutDownCount", SqlDbType.Int,4)}; parameters[0].Value = model.TaskName; parameters[1].Value = model.TrunkGroupID; parameters[2].Value = model.CallerNum; parameters[3].Value = model.CallType; parameters[4].Value = model.ExInfo; parameters[5].Value = model.MaxTrunkCount; parameters[6].Value = model.IntensityCoefficient; parameters[7].Value = model.ItemTableName; parameters[8].Value = model.State; parameters[9].Value = model.AddTime; parameters[10].Value = model.y_PSort; parameters[11].Value = model.y_TkModelId; parameters[12].Value = model.y_SXH; parameters[13].Value = model.y_FPCount; parameters[14].Value = model.y_YJCount; parameters[15].Value = model.y_HCCount; parameters[16].Value = model.y_HSCount; parameters[17].Value = model.y_HTCount; parameters[18].Value = model.y_HMCount; parameters[19].Value = model.y_OkCount; parameters[20].Value = model.y_RFCount; parameters[21].Value = model.y_ConsCount; parameters[22].Value = model.y_InvlCount; parameters[23].Value = model.y_NoAnswerCount; parameters[24].Value = model.y_ShutDownCount; object obj = DbHelperSQL.GetSingle(strSql.ToString(), parameters); if (obj == null) { return 0; } else { return Convert.ToInt64(obj); } } /// /// 更新一条数据 /// public bool Update(YTSoft.BaseCallCenter.Model.T_CTI_Task model) { StringBuilder strSql = new StringBuilder(); strSql.Append("update T_CTI_Task set "); strSql.Append("TaskName=@TaskName,"); strSql.Append("y_TkModelId=@y_TkModelId"); strSql.Append(" where TaskID=@TaskID"); SqlParameter[] parameters = { new SqlParameter("@TaskName", SqlDbType.VarChar,200), new SqlParameter("@y_TkModelId", SqlDbType.BigInt,8), new SqlParameter("@TaskID", SqlDbType.BigInt,8)}; parameters[0].Value = model.TaskName; parameters[1].Value = model.y_TkModelId; parameters[2].Value = model.TaskID; int rows = DbHelperSQL.ExecuteSql(strSql.ToString(), parameters); if (rows > 0) { return true; } else { return false; } } /// /// 更新一条数据 /// public bool UpdateState(int id,int state) { StringBuilder strSql = new StringBuilder(); strSql.Append("update T_CTI_Task set "); strSql.Append("State=@State"); strSql.Append(" where TaskID=@TaskID"); SqlParameter[] parameters = { new SqlParameter("@State", SqlDbType.Int,4), new SqlParameter("@TaskID", SqlDbType.BigInt,8)}; parameters[0].Value = state; parameters[1].Value = id; int rows = DbHelperSQL.ExecuteSql(strSql.ToString(), parameters); if (rows > 0) { return true; } else { return false; } } /// /// 删除一条数据 /// public bool Delete(long TaskID) { StringBuilder strSql = new StringBuilder(); strSql.Append("delete from T_CTI_Task "); strSql.Append(" where TaskID=@TaskID"); SqlParameter[] parameters = { new SqlParameter("@TaskID", SqlDbType.BigInt) }; parameters[0].Value = TaskID; int rows = DbHelperSQL.ExecuteSql(strSql.ToString(), parameters); if (rows > 0) { return true; } else { return false; } } /// /// 批量删除数据 /// public bool DeleteList(string TaskIDlist) { StringBuilder strSql = new StringBuilder(); strSql.Append("delete from T_CTI_Task "); strSql.Append(" where TaskID in (" + TaskIDlist + ") "); int rows = DbHelperSQL.ExecuteSql(strSql.ToString()); if (rows > 0) { return true; } else { return false; } } /// /// 得到一个对象实体 /// public YTSoft.BaseCallCenter.Model.T_CTI_Task GetModel(long TaskID) { StringBuilder strSql = new StringBuilder(); strSql.Append("select top 1 TaskID,TaskName,TrunkGroupID,CallerNum,CallType,ExInfo,MaxTrunkCount,IntensityCoefficient,ItemTableName,State,AddTime,y_PSort,y_TkModelId,y_SXH,y_FPCount,y_YJCount,y_HCCount,y_HSCount,y_HTCount,y_HMCount,y_OkCount,y_RFCount,y_ConsCount,y_InvlCount,y_NoAnswerCount,y_ShutDownCount from T_CTI_Task "); strSql.Append(" where TaskID=@TaskID"); SqlParameter[] parameters = { new SqlParameter("@TaskID", SqlDbType.BigInt) }; parameters[0].Value = TaskID; YTSoft.BaseCallCenter.Model.T_CTI_Task model = new YTSoft.BaseCallCenter.Model.T_CTI_Task(); DataSet ds = DbHelperSQL.Query(strSql.ToString(), parameters); if (ds.Tables[0].Rows.Count > 0) { if (ds.Tables[0].Rows[0]["TaskID"] != null && ds.Tables[0].Rows[0]["TaskID"].ToString() != "") { model.TaskID = long.Parse(ds.Tables[0].Rows[0]["TaskID"].ToString()); } if (ds.Tables[0].Rows[0]["TaskName"] != null && ds.Tables[0].Rows[0]["TaskName"].ToString() != "") { model.TaskName = ds.Tables[0].Rows[0]["TaskName"].ToString(); } if (ds.Tables[0].Rows[0]["TrunkGroupID"] != null && ds.Tables[0].Rows[0]["TrunkGroupID"].ToString() != "") { model.TrunkGroupID = int.Parse(ds.Tables[0].Rows[0]["TrunkGroupID"].ToString()); } if (ds.Tables[0].Rows[0]["CallerNum"] != null && ds.Tables[0].Rows[0]["CallerNum"].ToString() != "") { model.CallerNum = ds.Tables[0].Rows[0]["CallerNum"].ToString(); } if (ds.Tables[0].Rows[0]["CallType"] != null && ds.Tables[0].Rows[0]["CallType"].ToString() != "") { model.CallType = int.Parse(ds.Tables[0].Rows[0]["CallType"].ToString()); } if (ds.Tables[0].Rows[0]["ExInfo"] != null && ds.Tables[0].Rows[0]["ExInfo"].ToString() != "") { model.ExInfo = ds.Tables[0].Rows[0]["ExInfo"].ToString(); } if (ds.Tables[0].Rows[0]["MaxTrunkCount"] != null && ds.Tables[0].Rows[0]["MaxTrunkCount"].ToString() != "") { model.MaxTrunkCount = int.Parse(ds.Tables[0].Rows[0]["MaxTrunkCount"].ToString()); } if (ds.Tables[0].Rows[0]["IntensityCoefficient"] != null && ds.Tables[0].Rows[0]["IntensityCoefficient"].ToString() != "") { model.IntensityCoefficient = decimal.Parse(ds.Tables[0].Rows[0]["IntensityCoefficient"].ToString()); } if (ds.Tables[0].Rows[0]["ItemTableName"] != null && ds.Tables[0].Rows[0]["ItemTableName"].ToString() != "") { model.ItemTableName = ds.Tables[0].Rows[0]["ItemTableName"].ToString(); } if (ds.Tables[0].Rows[0]["State"] != null && ds.Tables[0].Rows[0]["State"].ToString() != "") { model.State = int.Parse(ds.Tables[0].Rows[0]["State"].ToString()); } if (ds.Tables[0].Rows[0]["AddTime"] != null && ds.Tables[0].Rows[0]["AddTime"].ToString() != "") { model.AddTime = DateTime.Parse(ds.Tables[0].Rows[0]["AddTime"].ToString()); } if (ds.Tables[0].Rows[0]["y_PSort"] != null && ds.Tables[0].Rows[0]["y_PSort"].ToString() != "") { model.y_PSort = int.Parse(ds.Tables[0].Rows[0]["y_PSort"].ToString()); } if (ds.Tables[0].Rows[0]["y_TkModelId"] != null && ds.Tables[0].Rows[0]["y_TkModelId"].ToString() != "") { model.y_TkModelId = long.Parse(ds.Tables[0].Rows[0]["y_TkModelId"].ToString()); } if (ds.Tables[0].Rows[0]["y_SXH"] != null && ds.Tables[0].Rows[0]["y_SXH"].ToString() != "") { model.y_SXH = int.Parse(ds.Tables[0].Rows[0]["y_SXH"].ToString()); } if (ds.Tables[0].Rows[0]["y_FPCount"] != null && ds.Tables[0].Rows[0]["y_FPCount"].ToString() != "") { model.y_FPCount = int.Parse(ds.Tables[0].Rows[0]["y_FPCount"].ToString()); } if (ds.Tables[0].Rows[0]["y_YJCount"] != null && ds.Tables[0].Rows[0]["y_YJCount"].ToString() != "") { model.y_YJCount = int.Parse(ds.Tables[0].Rows[0]["y_YJCount"].ToString()); } if (ds.Tables[0].Rows[0]["y_HCCount"] != null && ds.Tables[0].Rows[0]["y_HCCount"].ToString() != "") { model.y_HCCount = int.Parse(ds.Tables[0].Rows[0]["y_HCCount"].ToString()); } if (ds.Tables[0].Rows[0]["y_HSCount"] != null && ds.Tables[0].Rows[0]["y_HSCount"].ToString() != "") { model.y_HSCount = int.Parse(ds.Tables[0].Rows[0]["y_HSCount"].ToString()); } if (ds.Tables[0].Rows[0]["y_HTCount"] != null && ds.Tables[0].Rows[0]["y_HTCount"].ToString() != "") { model.y_HTCount = int.Parse(ds.Tables[0].Rows[0]["y_HTCount"].ToString()); } if (ds.Tables[0].Rows[0]["y_HMCount"] != null && ds.Tables[0].Rows[0]["y_HMCount"].ToString() != "") { model.y_HMCount = int.Parse(ds.Tables[0].Rows[0]["y_HMCount"].ToString()); } if (ds.Tables[0].Rows[0]["y_OkCount"] != null && ds.Tables[0].Rows[0]["y_OkCount"].ToString() != "") { model.y_OkCount = int.Parse(ds.Tables[0].Rows[0]["y_OkCount"].ToString()); } if (ds.Tables[0].Rows[0]["y_RFCount"] != null && ds.Tables[0].Rows[0]["y_RFCount"].ToString() != "") { model.y_RFCount = int.Parse(ds.Tables[0].Rows[0]["y_RFCount"].ToString()); } if (ds.Tables[0].Rows[0]["y_ConsCount"] != null && ds.Tables[0].Rows[0]["y_ConsCount"].ToString() != "") { model.y_ConsCount = int.Parse(ds.Tables[0].Rows[0]["y_ConsCount"].ToString()); } if (ds.Tables[0].Rows[0]["y_InvlCount"] != null && ds.Tables[0].Rows[0]["y_InvlCount"].ToString() != "") { model.y_InvlCount = int.Parse(ds.Tables[0].Rows[0]["y_InvlCount"].ToString()); } if (ds.Tables[0].Rows[0]["y_NoAnswerCount"] != null && ds.Tables[0].Rows[0]["y_NoAnswerCount"].ToString() != "") { model.y_NoAnswerCount = int.Parse(ds.Tables[0].Rows[0]["y_NoAnswerCount"].ToString()); } if (ds.Tables[0].Rows[0]["y_ShutDownCount"] != null && ds.Tables[0].Rows[0]["y_ShutDownCount"].ToString() != "") { model.y_ShutDownCount = int.Parse(ds.Tables[0].Rows[0]["y_ShutDownCount"].ToString()); } return model; } else { return null; } } /// /// 获得数据列表 /// public DataSet GetList(string strWhere) { StringBuilder strSql = new StringBuilder(); strSql.Append("select * "); strSql.Append(" FROM vw_CTI_TaskPager "); if (strWhere.Trim() != "") { strSql.Append(" where " + strWhere); } return DbHelperSQL.Query(strSql.ToString()); } /// /// 获得前几行数据 /// 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(" TaskID,TaskName,TrunkGroupID,CallerNum,CallType,ExInfo,MaxTrunkCount,IntensityCoefficient,ItemTableName,State,AddTime,y_PSort,y_TkModelId,y_SXH,y_FPCount,y_YJCount,y_HCCount,y_HSCount,y_HTCount,y_HMCount,y_OkCount,y_RFCount,y_ConsCount,y_InvlCount,y_NoAnswerCount,y_ShutDownCount "); strSql.Append(" FROM T_CTI_Task "); if (strWhere.Trim() != "") { strSql.Append(" where " + strWhere); } strSql.Append(" order by " + filedOrder); return DbHelperSQL.Query(strSql.ToString()); } /// /// 获取记录总数 /// public int GetRecordCount(string strWhere) { StringBuilder strSql = new StringBuilder(); strSql.Append("select count(1) FROM T_CTI_Task "); if (strWhere.Trim() != "") { strSql.Append(" where " + strWhere); } object obj = DbHelperSQL.GetSingle(strSql.ToString()); if (obj == null) { return 0; } else { return Convert.ToInt32(obj); } } /// /// 分页获取数据列表 /// public DataSet GetListByPage(string strWhere, string orderby, int startIndex, int endIndex) { StringBuilder strSql = new StringBuilder(); strSql.Append("SELECT * FROM ( "); strSql.Append(" SELECT ROW_NUMBER() OVER ("); if (!string.IsNullOrEmpty(orderby.Trim())) { strSql.Append("order by T." + orderby); } else { strSql.Append("order by T.TaskID desc"); } strSql.Append(")AS Row, T.* from T_CTI_Task T "); if (!string.IsNullOrEmpty(strWhere.Trim())) { strSql.Append(" WHERE " + strWhere); } strSql.Append(" ) TT"); strSql.AppendFormat(" WHERE TT.Row between {0} and {1}", startIndex, endIndex); return DbHelperSQL.Query(strSql.ToString()); } /* /// /// 分页获取数据列表 /// public DataSet GetList(int PageSize,int PageIndex,string strWhere) { SqlParameter[] parameters = { new SqlParameter("@tblName", SqlDbType.VarChar, 255), new SqlParameter("@fldName", SqlDbType.VarChar, 255), new SqlParameter("@PageSize", SqlDbType.Int), new SqlParameter("@PageIndex", SqlDbType.Int), new SqlParameter("@IsReCount", SqlDbType.Bit), new SqlParameter("@OrderType", SqlDbType.Bit), new SqlParameter("@strWhere", SqlDbType.VarChar,1000), }; parameters[0].Value = "T_CTI_Task"; parameters[1].Value = "TaskID"; parameters[2].Value = PageSize; parameters[3].Value = PageIndex; parameters[4].Value = 0; parameters[5].Value = 0; parameters[6].Value = strWhere; return DbHelperSQL.RunProcedure("UP_GetRecordByPage",parameters,"ds"); }*/ #endregion Method } }