| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536 |
- using CallCenter.Utility;
- using CallCenterApi.Common;
- using CallCenterApi.DB;
- using CallCenterApi.Interface.Controllers.Base;
- using System;
- using System.Collections.Generic;
- using System.Data;
- using System.Linq;
- using System.Web;
- using System.Web.Mvc;
- namespace CallCenterApi.Interface.Controllers.tel
- {
- public class MobiledataController : BaseController
- {
- //获取号码归属地列表
- public ActionResult GetList(string strtelnum)
- {
- ActionResult res = NoToken("未知错误,请重新登录");
- if (Request.IsAuthenticated)
- {
- string sql = " and F_IsDelete=0";
- DataTable dt = new DataTable();
- string strpageindex = RequestString.GetQueryString("page");
- int pageindex = 1;
- string strpagesize = RequestString.GetQueryString("pagesize");
- int pagesize = 10;
- if (strtelnum != null && strtelnum.Trim() != "")
- {
- sql += " and (F_MobileNum like '%" + strtelnum.Trim() + "%' or F_ZipCode like '%" + strtelnum.Trim()
- + "%' or F_CityDes like '%" + strtelnum.Trim() + "%'or F_CardDes like '%" + strtelnum.Trim() + "%')";
- }
- if (strpageindex.Trim() != "")
- {
- pageindex = Convert.ToInt32(strpageindex);
- }
- if (strpagesize.Trim() != "")
- {
- pagesize = Convert.ToInt32(strpagesize);
- }
- int recordCount = 0;
- dt = BLL.PagerBLL.GetListPager(
- "T_Sys_MobileData",
- "F_Id",
- "*",
- sql,
- "ORDER BY F_Id desc",
- pagesize,
- pageindex,
- true,
- out recordCount);
- var obj = new
- {
- state = "success",
- message = "成功",
- rows = dt,
- total = recordCount
- };
- res = Content(obj.ToJson());
- }
- return res;
- }
- public ActionResult GetMobiledata(int id)
- {
- ActionResult res = NoToken("未知错误,请重新登录");
- if (Request.IsAuthenticated)
- {
- BLL.T_Sys_MobileData dBLL = new BLL.T_Sys_MobileData();
- Model.T_Sys_MobileData dModel = dBLL.GetModel(id);
- res = Success("获取号码归属地成功", dModel);
- }
- return res;
- }
- //获取号码归属地
- public ActionResult GetMobiledataByNum(string mobileNum)
- {
- ActionResult res = NoToken("未知错误,请重新登录");
- if (Request.IsAuthenticated)
- {
- if (mobileNum != null && mobileNum.Trim() != "")
- {
- BLL.T_Sys_MobileData dBLL = new BLL.T_Sys_MobileData();
- Model.T_Sys_MobileData dModel = dBLL.GetModelList(" F_MobileNum='" + mobileNum.Trim() + "' ").FirstOrDefault();
- if (dModel != null)
- {
- res = Success("获取号码归属地成功", dModel);
- }
- else
- {
- res = Error("获取号码归属地失败");
- }
- }
- else
- {
- res = Error("获取参数失败");
- }
- }
- return res;
- }
- //添加/编辑号码归属地
- public ActionResult AddMobiledata(string mobileNum, string zipCode, string cityDes, string cardDes, int id = 0)
- {
- ActionResult res = NoToken("未知错误,请重新登录");
- if (Request.IsAuthenticated)
- {
- int userId = CurrentUser.UserData.F_UserId;
- Model.T_Sys_UserAccount ua = new BLL.T_Sys_UserAccount().GetModel(userId);
- BLL.T_Sys_MobileData dBLL = new BLL.T_Sys_MobileData();
- Model.T_Sys_MobileData dModel = new Model.T_Sys_MobileData();
- if (id != 0)
- {
- dModel = dBLL.GetModel(id);
- if (dModel != null)
- {
- if (!string.IsNullOrWhiteSpace(mobileNum.Trim()))
- {
- dModel.F_MobileNum = mobileNum.Trim();
- }
- if (!string.IsNullOrWhiteSpace(zipCode.Trim()))
- {
- dModel.F_ZipCode = zipCode.Trim();
- }
- if (!string.IsNullOrWhiteSpace(cityDes.Trim()))
- {
- dModel.F_CityDes = cityDes.Trim();
- }
- if (!string.IsNullOrWhiteSpace(cardDes.Trim()))
- {
- dModel.F_CardDes = cardDes.Trim();
- }
- bool b = dBLL.Update(dModel);
- if (b)
- {
- res = Success("编辑成功");
- }
- else
- {
- res = Error("编辑失败");
- }
- }
- else
- {
- res = Error("编辑失败");
- }
- }
- else
- {
- dModel = new Model.T_Sys_MobileData();
- if (!string.IsNullOrWhiteSpace(mobileNum.Trim()))
- {
- dModel.F_MobileNum = mobileNum.Trim();
- }
- if (!string.IsNullOrWhiteSpace(zipCode.Trim()))
- {
- dModel.F_ZipCode = zipCode.Trim();
- }
- if (!string.IsNullOrWhiteSpace(cityDes.Trim()))
- {
- dModel.F_CityDes = cityDes.Trim();
- }
- if (!string.IsNullOrWhiteSpace(cardDes.Trim()))
- {
- dModel.F_CardDes = cardDes.Trim();
- }
- dModel.F_IsDelete = 0;
- dModel.F_CreateUser = ua.F_UserCode;
- dModel.F_CreateTime = DateTime.Now;
- int n = new BLL.T_Sys_MobileData().Add(dModel);
- if (n > 0)
- {
- res = Success("添加成功", n);
- }
- else
- {
- res = Error("添加失败");
- }
- }
- }
- return res;
- }
- //删除号码归属地记录
- public ActionResult DelMobiledata(string[] nums)
- {
- ActionResult res = NoToken("未知错误,请重新登录");
- if (Request.IsAuthenticated)
- {
- int userId = CurrentUser.UserData.F_UserId;
- Model.T_Sys_UserAccount ua = new BLL.T_Sys_UserAccount().GetModel(userId);
- if (nums != null && nums.Length > 0)
- {
- string idd = " ";
- foreach (string str in nums)
- {
- idd += "'" + str + "',";
- }
- if (new BLL.T_Sys_MobileData().DeleteList(idd.TrimEnd(','), ua.F_UserCode))
- {
- res = Success("删除成功");
- }
- else
- res = Error("删除失败");
- }
- else
- {
- res = Error("请选择要删除的记录");
- }
- }
- return res;
- }
- //IVR获取号码归属地
- public ActionResult IVRGetList(string strtelnum)
- {
- ActionResult res = NoToken("未知错误,请重新登录");
- if (Request.IsAuthenticated)
- {
- string sql = " and isDelete=0";
- DataTable dt = new DataTable();
- string strpageindex = RequestString.GetQueryString("page");
- int pageindex = 1;
- string strpagesize = RequestString.GetQueryString("pagesize");
- int pagesize = 10;
- if (strtelnum != null && strtelnum.Trim() != "")
- {
- sql += " and tel like '%" + strtelnum.Trim() + "%'";
- }
- if (strpageindex.Trim() != "")
- {
- pageindex = Convert.ToInt32(strpageindex);
- }
- if (strpagesize.Trim() != "")
- {
- pagesize = Convert.ToInt32(strpagesize);
- }
- int recordCount = 0;
- dt = BLL.PagerBLL.GetListPager(
- "tel_location",
- "tel_location.id",
- "*",
- sql,
- "ORDER BY tel_location.id asc",
- pagesize,
- pageindex,
- true,
- out recordCount);
- var obj = new
- {
- state = "success",
- message = "成功",
- rows = dt,
- total = recordCount
- };
- res = Content(obj.ToJson());
- }
- return res;
- }
- public ActionResult GetMobileUsersData(int id)
- {
- ActionResult res = NoToken("未知错误,请重新登录");
- if (Request.IsAuthenticated)
- {
- BLL.telloc_users dBLL = new BLL.telloc_users();
- Model.telloc_users dModel = dBLL.GetModel(id);
- res = Success("获取号码归属地成功", dModel);
- }
- return res;
- }
- //获取IVR号码归属地坐席关联
- public ActionResult GetMobileUsersList()
- {
- ActionResult res = NoToken("未知错误,请重新登录");
- if (Request.IsAuthenticated)
- {
- string sql = " and isDelete=0";
- DataTable dt = new DataTable();
- int userid = 0;
- userid = RequestString.GetQueryString("userid").ToString() == "" ? 0 : int.Parse(RequestString.GetQueryString("userid").ToString());
- string locstr = RequestString.GetQueryString("location");
- string strpageindex = RequestString.GetQueryString("page");
- int pageindex = 1;
- string strpagesize = RequestString.GetQueryString("pagesize");
- int pagesize = 10;
- List<int> telloclist = new List<int>();
- if (userid != 0)
- {
- //sql += " and userid="+userid;
- DataTable dttelusers = DbHelperSQL.Query(" select tellocid from telloc_users where isdelete=0 and userid=" + userid).Tables[0];
- if (dttelusers.Rows.Count > 0)
- {
- foreach (DataRow dr in dttelusers.Rows)
- {
- telloclist.Add(int.Parse(dr[0].ToString()));
- }
- }
- }
- if (locstr.Trim() != "")
- {
- sql += " and (province like '%" + locstr + "%' or city like '%" + locstr + "%')";
- }
- if (strpageindex.Trim() != "")
- {
- pageindex = Convert.ToInt32(strpageindex);
- }
- if (strpagesize.Trim() != "")
- {
- pagesize = Convert.ToInt32(strpagesize);
- }
- int recordCount = 0;
- dt = BLL.PagerBLL.GetListPager(
- "tel_location",
- "tel_location.id",
- "*",
- sql,
- "ORDER BY tel_location.id asc",
- pagesize,
- pageindex,
- true,
- out recordCount);
- dt.Columns.Add("res");
- dt.Columns.Add("uid");
- if (userid == 0)
- {
- foreach (DataRow dr in dt.Rows)
- {
- dr["res"] = 0;
- dr["uid"] = 0;
- }
- }
- else
- {
- foreach (DataRow dr in dt.Rows)
- {
- int tid = int.Parse(dr["id"].ToString());
- if (telloclist.Contains(tid))
- {
- dr["res"] = 1;
- dr["uid"] = userid;
- }
- else
- {
- dr["res"] = 0;
- dr["uid"] = 0;
- }
- }
- }
- var obj = new
- {
- state = "success",
- message = "成功",
- rows = dt,
- total = recordCount
- };
- res = Content(obj.ToJson());
- }
- return res;
- }
- //添加/修改IVR号码归属地坐席关联
- public ActionResult AddMobileUsers(int tellocid, int userid, int type)
- {
- ActionResult res = NoToken("未知错误,请重新登录");
- if (Request.IsAuthenticated)
- {
- int userId = CurrentUser.UserData.F_UserId;
- Model.T_Sys_UserAccount ua = new BLL.T_Sys_UserAccount().GetModel(userId);
- BLL.telloc_users dBLL = new BLL.telloc_users();
- Model.telloc_users dModel = new Model.telloc_users();
- //if (type == 1)//0为添加,1是解除
- //{
- // dModel = dBLL.GetModel(userid,tellocid);
- // if (dModel != null)
- // {
- // dModel.isdelete = 1;
- // bool b = dBLL.Update(dModel);
- // if (b)
- // {
- // res = Success("解除成功");
- // }
- // else
- // {
- // res = Error("解除失败");
- // }
- // }
- // else
- // {
- // res = Error("解除失败");
- // }
- //}
- //else
- //{
- // dModel = new Model.telloc_users();
- // if (!string.IsNullOrWhiteSpace(tellocid.ToString()))
- // {
- // dModel.tellocid = tellocid;
- // }
- // if (!string.IsNullOrWhiteSpace(userid.ToString()))
- // {
- // dModel.userid = userid;
- // }
- // dModel.isdelete = 0;
- // int n = new BLL.telloc_users().Add(dModel);
- // if (n > 0)
- // {
- // res = Success("添加成功", n);
- // }
- // else
- // {
- // res = Error("添加失败");
- // }
- //}
- dModel = new Model.telloc_users();
- if (!string.IsNullOrWhiteSpace(tellocid.ToString()))
- {
- dModel.tellocid = tellocid;
- }
- if (!string.IsNullOrWhiteSpace(userid.ToString()))
- {
- dModel.userid = userid;
- }
- dModel = dBLL.GetModel(userid, tellocid);
- if (dModel != null)
- {
- dModel.isdelete = type;
- bool b = dBLL.Update(dModel);
- var str = type == 1 ? "解除" : "添加";
- if (b)
- {
- res = Success(str + "成功");
- }
- else
- {
- res = Error(str + "失败");
- }
- }
- else
- {
- dModel.isdelete = 0;
- int n = new BLL.telloc_users().Add(dModel);
- if (n > 0)
- {
- res = Success("添加成功", n);
- }
- else
- {
- res = Error("添加失败");
- }
- }
- }
- return res;
- }
- //删除IVR号码归属地坐席关联
- public ActionResult DeleteMobileUsers(int id)
- {
- ActionResult res = NoToken("未知错误,请重新登录");
- if (Request.IsAuthenticated)
- {
- BLL.telloc_users dBLL = new BLL.telloc_users();
- Model.telloc_users dModel = new Model.telloc_users();
- if (id != 0)//修改
- {
- dModel = dBLL.GetModel(id);
- if (dModel != null)
- {
- dModel.isdelete = 1;
- bool b = dBLL.Update(dModel);
- if (b)
- {
- res = Success("删除成功");
- }
- else
- {
- res = Error("删除失败");
- }
- }
- else
- {
- res = Error("删除失败");
- }
- }
- else
- {
- res = Error("传入参数错误");
- }
- }
- return res;
- }
- public ActionResult GetSeatGroup()
- {
- ActionResult res = NoToken("未知错误,请重新登录");
- if (Request.IsAuthenticated)
- {
- BLL.T_Sys_SeatGroup dBLL = new BLL.T_Sys_SeatGroup();
- var seatgroups = dBLL.GetModelList("1=1").Select(n => new { n.F_ZXZID, n.F_ZXZName });
- res = Success("获取坐席组成功", seatgroups);
- }
- return res;
- }
- }
- }
|