/** 版本信息模板在安装目录下,可自行修改。 * T_AutomaticCall_Phone.cs * * 功 能: N/A * 类 名: T_AutomaticCall_Phone * * Ver 变更日期 负责人 变更内容 * ─────────────────────────────────── * V0.01 2022/3/2 09:32:28 N/A 初版 * * Copyright (c) 2012 Maticsoft Corporation. All rights reserved. *┌──────────────────────────────────┐ *│ 此技术信息为本公司机密信息,未经本公司书面同意禁止向第三方披露. │ *│ 版权所有:动软卓越(北京)科技有限公司              │ *└──────────────────────────────────┘ */ using System; using System.Data; using System.Text; using System.Data.SqlClient; using CallCenterApi.DB; namespace CallCenterApi.DAL { /// /// 数据访问类:T_AutomaticCall_Phone /// public partial class T_AutomaticCall_Phone { public T_AutomaticCall_Phone() {} #region BasicMethod /// /// 增加一条数据 /// public int Add(CallCenterApi.Model.T_AutomaticCall_Phone model) { StringBuilder strSql=new StringBuilder(); strSql.Append("insert into T_AutomaticCall_Phone("); strSql.Append("taskId,fix,phone,createTime,createBy,callState,salesOffice,broadbandAccount,accessTime,channel,service,package,fusion,phoneState,orderNature,address,result1,result2,result3,isconnect,calltime)"); strSql.Append(" values ("); strSql.Append("@taskId,@fix,@phone,@createTime,@createBy,@callState,@salesOffice,@broadbandAccount,@accessTime,@channel,@service,@package,@fusion,@phoneState,@orderNature,@address,@result1,@result2,@result3,@isconnect,@calltime)"); strSql.Append(";select @@IDENTITY"); SqlParameter[] parameters = { new SqlParameter("@taskId", SqlDbType.Int,4), new SqlParameter("@fix", SqlDbType.NVarChar,10), new SqlParameter("@phone", SqlDbType.NVarChar,50), new SqlParameter("@createTime", SqlDbType.DateTime), new SqlParameter("@createBy", SqlDbType.NVarChar,50), new SqlParameter("@callState", SqlDbType.Int,4), new SqlParameter("@salesOffice", SqlDbType.NVarChar,100), new SqlParameter("@broadbandAccount", SqlDbType.NVarChar,100), new SqlParameter("@accessTime", SqlDbType.NVarChar,50), new SqlParameter("@channel", SqlDbType.NVarChar,100), new SqlParameter("@service", SqlDbType.NVarChar,100), new SqlParameter("@package", SqlDbType.NVarChar,200), new SqlParameter("@fusion", SqlDbType.NVarChar,50), new SqlParameter("@phoneState", SqlDbType.NVarChar,50), new SqlParameter("@orderNature", SqlDbType.NVarChar,50), new SqlParameter("@address", SqlDbType.NVarChar,500), new SqlParameter("@result1", SqlDbType.NVarChar,50), new SqlParameter("@result2", SqlDbType.NVarChar,50), new SqlParameter("@result3", SqlDbType.NVarChar,50), new SqlParameter("@isconnect", SqlDbType.Int,4), new SqlParameter("@calltime", SqlDbType.DateTime)}; parameters[0].Value = model.taskId; parameters[1].Value = model.fix; parameters[2].Value = model.phone; parameters[3].Value = model.createTime; parameters[4].Value = model.createBy; parameters[5].Value = model.callState; parameters[6].Value = model.salesOffice; parameters[7].Value = model.broadbandAccount; parameters[8].Value = model.accessTime; parameters[9].Value = model.channel; parameters[10].Value = model.service; parameters[11].Value = model.package; parameters[12].Value = model.fusion; parameters[13].Value = model.phoneState; parameters[14].Value = model.orderNature; parameters[15].Value = model.address; parameters[16].Value = model.result1; parameters[17].Value = model.result2; parameters[18].Value = model.result3; parameters[19].Value = model.isconnect; parameters[20].Value = model.calltime; object obj = DbHelperSQL.GetSingle(strSql.ToString(),parameters); if (obj == null) { return 0; } else { return Convert.ToInt32(obj); } } /// /// 更新一条数据 /// public bool Update(CallCenterApi.Model.T_AutomaticCall_Phone model) { StringBuilder strSql=new StringBuilder(); strSql.Append("update T_AutomaticCall_Phone set "); strSql.Append("taskId=@taskId,"); strSql.Append("fix=@fix,"); strSql.Append("phone=@phone,"); strSql.Append("createTime=@createTime,"); strSql.Append("createBy=@createBy,"); strSql.Append("callState=@callState,"); strSql.Append("salesOffice=@salesOffice,"); strSql.Append("broadbandAccount=@broadbandAccount,"); strSql.Append("accessTime=@accessTime,"); strSql.Append("channel=@channel,"); strSql.Append("service=@service,"); strSql.Append("package=@package,"); strSql.Append("fusion=@fusion,"); strSql.Append("phoneState=@phoneState,"); strSql.Append("orderNature=@orderNature,"); strSql.Append("address=@address,"); strSql.Append("result1=@result1,"); strSql.Append("result2=@result2,"); strSql.Append("result3=@result3,"); strSql.Append("isconnect=@isconnect,"); strSql.Append("calltime=@calltime"); strSql.Append(" where F_Id=@F_Id"); SqlParameter[] parameters = { new SqlParameter("@taskId", SqlDbType.Int,4), new SqlParameter("@fix", SqlDbType.NVarChar,10), new SqlParameter("@phone", SqlDbType.NVarChar,50), new SqlParameter("@createTime", SqlDbType.DateTime), new SqlParameter("@createBy", SqlDbType.NVarChar,50), new SqlParameter("@callState", SqlDbType.Int,4), new SqlParameter("@salesOffice", SqlDbType.NVarChar,100), new SqlParameter("@broadbandAccount", SqlDbType.NVarChar,100), new SqlParameter("@accessTime",SqlDbType.NVarChar,50), new SqlParameter("@channel", SqlDbType.NVarChar,100), new SqlParameter("@service", SqlDbType.NVarChar,100), new SqlParameter("@package", SqlDbType.NVarChar,200), new SqlParameter("@fusion", SqlDbType.NVarChar,50), new SqlParameter("@phoneState", SqlDbType.NVarChar,50), new SqlParameter("@orderNature", SqlDbType.NVarChar,50), new SqlParameter("@address", SqlDbType.NVarChar,500), new SqlParameter("@result1", SqlDbType.NVarChar,50), new SqlParameter("@result2", SqlDbType.NVarChar,50), new SqlParameter("@result3", SqlDbType.NVarChar,50), new SqlParameter("@isconnect", SqlDbType.Int,4), new SqlParameter("@calltime", SqlDbType.DateTime), new SqlParameter("@F_Id", SqlDbType.Int,4)}; parameters[0].Value = model.taskId; parameters[1].Value = model.fix; parameters[2].Value = model.phone; parameters[3].Value = model.createTime; parameters[4].Value = model.createBy; parameters[5].Value = model.callState; parameters[6].Value = model.salesOffice; parameters[7].Value = model.broadbandAccount; parameters[8].Value = model.accessTime; parameters[9].Value = model.channel; parameters[10].Value = model.service; parameters[11].Value = model.package; parameters[12].Value = model.fusion; parameters[13].Value = model.phoneState; parameters[14].Value = model.orderNature; parameters[15].Value = model.address; parameters[16].Value = model.result1; parameters[17].Value = model.result2; parameters[18].Value = model.result3; parameters[19].Value = model.isconnect; parameters[20].Value = model.calltime; parameters[21].Value = model.F_Id; int rows=DbHelperSQL.ExecuteSql(strSql.ToString(),parameters); if (rows > 0) { return true; } else { return false; } } /// /// 删除一条数据 /// public bool Delete(int F_Id) { StringBuilder strSql=new StringBuilder(); strSql.Append("delete from T_AutomaticCall_Phone "); strSql.Append(" where F_Id=@F_Id"); SqlParameter[] parameters = { new SqlParameter("@F_Id", SqlDbType.Int,4) }; parameters[0].Value = F_Id; int rows=DbHelperSQL.ExecuteSql(strSql.ToString(),parameters); if (rows > 0) { return true; } else { return false; } } /// /// 批量删除数据 /// public bool DeleteList(string F_Idlist ) { StringBuilder strSql=new StringBuilder(); strSql.Append("delete from T_AutomaticCall_Phone "); strSql.Append(" where F_Id in ("+F_Idlist + ") "); int rows=DbHelperSQL.ExecuteSql(strSql.ToString()); if (rows > 0) { return true; } else { return false; } } /// /// 得到一个对象实体 /// public CallCenterApi.Model.T_AutomaticCall_Phone GetModel(int F_Id) { StringBuilder strSql=new StringBuilder(); strSql.Append("select top 1 F_Id,taskId,fix,phone,createTime,createBy,callState,salesOffice,broadbandAccount,accessTime,channel,service,package,fusion,phoneState,orderNature,address,result1,result2,result3,isconnect,calltime from T_AutomaticCall_Phone "); strSql.Append(" where F_Id=@F_Id"); SqlParameter[] parameters = { new SqlParameter("@F_Id", SqlDbType.Int,4) }; parameters[0].Value = F_Id; CallCenterApi.Model.T_AutomaticCall_Phone model=new CallCenterApi.Model.T_AutomaticCall_Phone(); DataSet ds=DbHelperSQL.Query(strSql.ToString(),parameters); if(ds.Tables[0].Rows.Count>0) { return DataRowToModel(ds.Tables[0].Rows[0]); } else { return null; } } /// /// 得到一个对象实体 /// public CallCenterApi.Model.T_AutomaticCall_Phone DataRowToModel(DataRow row) { CallCenterApi.Model.T_AutomaticCall_Phone model=new CallCenterApi.Model.T_AutomaticCall_Phone(); if (row != null) { if(row["F_Id"]!=null && row["F_Id"].ToString()!="") { model.F_Id=int.Parse(row["F_Id"].ToString()); } if(row["taskId"]!=null && row["taskId"].ToString()!="") { model.taskId=int.Parse(row["taskId"].ToString()); } if(row["fix"]!=null) { model.fix=row["fix"].ToString(); } if(row["phone"]!=null) { model.phone=row["phone"].ToString(); } if(row["createTime"]!=null && row["createTime"].ToString()!="") { model.createTime=DateTime.Parse(row["createTime"].ToString()); } if(row["createBy"]!=null) { model.createBy=row["createBy"].ToString(); } if(row["callState"]!=null && row["callState"].ToString()!="") { model.callState=int.Parse(row["callState"].ToString()); } if(row["salesOffice"]!=null) { model.salesOffice=row["salesOffice"].ToString(); } if(row["broadbandAccount"]!=null) { model.broadbandAccount=row["broadbandAccount"].ToString(); } if(row["accessTime"]!=null && row["accessTime"].ToString()!="") { model.accessTime=row["accessTime"].ToString(); } if(row["channel"]!=null) { model.channel=row["channel"].ToString(); } if(row["service"]!=null) { model.service=row["service"].ToString(); } if(row["package"]!=null) { model.package=row["package"].ToString(); } if(row["fusion"]!=null) { model.fusion=row["fusion"].ToString(); } if(row["phoneState"]!=null) { model.phoneState=row["phoneState"].ToString(); } if(row["orderNature"]!=null) { model.orderNature=row["orderNature"].ToString(); } if(row["address"]!=null) { model.address=row["address"].ToString(); } if(row["result1"]!=null) { model.result1=row["result1"].ToString(); } if(row["result2"]!=null) { model.result2=row["result2"].ToString(); } if(row["result3"]!=null) { model.result3=row["result3"].ToString(); } if(row["isconnect"]!=null && row["isconnect"].ToString()!="") { model.isconnect=int.Parse(row["isconnect"].ToString()); } if(row["calltime"]!=null && row["calltime"].ToString()!="") { model.calltime=DateTime.Parse(row["calltime"].ToString()); } } return model; } /// /// 获得数据列表 /// public DataSet GetList(string strWhere) { StringBuilder strSql=new StringBuilder(); strSql.Append("select F_Id,taskId,fix,phone,createTime,createBy,callState,salesOffice,broadbandAccount,accessTime,channel,service,package,fusion,phoneState,orderNature,address,result1,result2,result3,isconnect,calltime "); strSql.Append(" FROM T_AutomaticCall_Phone "); 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(" F_Id,taskId,fix,phone,createTime,createBy,callState,salesOffice,broadbandAccount,accessTime,channel,service,package,fusion,phoneState,orderNature,address,result1,result2,result3,isconnect,calltime "); strSql.Append(" FROM T_AutomaticCall_Phone "); 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_AutomaticCall_Phone "); 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.F_Id desc"); } strSql.Append(")AS Row, T.* from T_AutomaticCall_Phone 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_AutomaticCall_Phone"; parameters[1].Value = "F_Id"; 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 BasicMethod #region ExtensionMethod public DataSet exportList(string strWhere) { //// "电话号码", "营业部","用户分类","问题1","结果1","问题2","结果2","问题3","结果3","是否接通","呼叫时间" //StringBuilder strSql = new StringBuilder(); StringBuilder tablenew = new StringBuilder(); tablenew.Append("select * from (select salesOffice, orderNature,phone,question1, callState,"); tablenew.Append("( case when isconnect = 1 then case result1 when 1 then '1' when 2 then '2' when 3 then '3' else '未评价' end else '' end ) result1,question2, "); tablenew.Append(" (case when isconnect = 1 then case result2 when 1 then '1' when 2 then '2' when 3 then '3' else '未评价' end else '' end ) result2,question3,"); // tablenew.Append(" case when question3 IS NULL then '' else case result3 when 1 then '十分满意' when 2 then '满意' when 3 then '不满意' else '未评价' end end else '' end result3 "); tablenew.Append("(case when question3 IS NULL then '' else case when isconnect = 1 then case result3 when 1 then '1' when 2 then '2' when 3 then '3' else '未评价' end else '' end end ) result3 ,"); tablenew.Append(" (case when isconnect =1 then '是' else '否' end ) connect, calltime,phone.taskId,isconnect,Isnull(phone.totalTime,0) totalTime from T_AutomaticCall_Phone phone left join T_AutomaticCall_Task task on phone.taskid = task.taskid) as t"); if (strWhere.Trim() != "") { tablenew.Append(" where " + strWhere); } tablenew.Append(" order by calltime desc"); return DbHelperSQL.Query(tablenew.ToString()); } #endregion ExtensionMethod } }