ComplianceServer/oldcode/WxService/WxOrderSvr.svc.cs

147 lines
6.8 KiB
C#

using Ninject;
using System;
using System.Collections.Generic;
using System.Data;
using System.ServiceModel;
using System.ServiceModel.Web;
using WX.CRM.Common;
using WX.CRM.IBLL.Csvr;
using WX.CRM.IBLL.Soft;
using WX.CRM.IBLL.Util;
using WX.CRM.Model.MAP;
using WX.CRM.WebHelper.Infrastructure;
namespace WxService
{
//[ServiceContract(Namespace = "")]
//[AspNetCompatibilityRequirements(RequirementsMode = AspNetCompatibilityRequirementsMode.Allowed)]
public class WxOrderSvr : IWxOrderSvr
{
//private readonly string _zxUrl = Utility.GetSettingByKey("ZxRegisterUrl");
//private readonly string _zxPassword = Utility.GetSettingByKey("ZxPassword");
//private readonly string _zxFrom = Utility.GetSettingByKey("ZxFrom");
//private readonly string _zxTeam = Utility.GetSettingByKey("ZxTeam");
private ISecurityHelper sHelper = NinjectControllerFactory.ninjectKernel.Get<ISecurityHelper>();
private ISOFT_USER_Q _soft_user_Q = NinjectControllerFactory.ninjectKernel.Get<ISOFT_USER_Q>();
//private IISVR_INTERFACECALLLOG logHelper = NinjectControllerFactory.ninjectKernel.Get<IISVR_INTERFACECALLLOG>();
//private IRES_CUSTOMER_Q res_Customer_Q_BL = NinjectControllerFactory.ninjectKernel.Get<IRES_CUSTOMER_Q>();
//private IRES_CUSTOMER res_Customer_BL = NinjectControllerFactory.ninjectKernel.Get<IRES_CUSTOMER>();
//private IWX_SZZYORDER wx_SzzyOrder_BL = NinjectControllerFactory.ninjectKernel.Get<IWX_SZZYORDER>();
//private IWX_SZZYPRODUCT wx_SzzyProduct_BL = NinjectControllerFactory.ninjectKernel.Get<IWX_SZZYPRODUCT>();
//private IWX_SZZYSUBPRODUCT wx_SzzySubProduct_BL = NinjectControllerFactory.ninjectKernel.Get<IWX_SZZYSUBPRODUCT>();
//private IRES_CUSTOMERDETAIL res_CustomerDetail_BL = NinjectControllerFactory.ninjectKernel.Get<IRES_CUSTOMERDETAIL>();
private string clientKey = WX.CRM.Common.Utility.GetSettingByKey("CRMClientKey");
private ICSVR_CALLRECORD _CSVR_CALLRECORD_BL = NinjectControllerFactory.ninjectKernel.Get<ICSVR_CALLRECORD>();
public JsonResult<IList<CallRecordView>> GetCallRecord(int page, string resId, string recordId = null)
{
//var customer = _customerQ.getResCustomerByResId(resId);
//if (customer == null)
// return new JsonResult<IList<WxRcontactView>> { result = false, retcode = (int)EnumInterfaceErrcode.参数错误, retmsg = null };
//var customerId = customer.CUSTOMERID;
//var ds = _rcontact.GetChatUserByResId(customerId);
//return new JsonResult<IList<CallRecordView>> { result = true, retcode = (int)EnumInterfaceErrcode.调用成功, retmsg = ds.ToList<CallRecordView>() };
Pager pg = new Pager()
{
page = page,
rows = 20
};
var ds = _CSVR_CALLRECORD_BL.GetCallRecord(ref pg, new QueryUserComboDto() { }, null, null, null, null, resId, recordId, -1, -1);
var list = ds.Tables[0];
var data = new List<CallRecordView>();
foreach (DataRow item in list.Rows)
{
var info = new CallRecordView();
info.recordid = Convert.ToDecimal(item["recordid"]);
info.RESID = item["RESID"].ToString();
var strIsTran = "";
if (item["ISTRAN"].ToString() == "1")
{
strIsTran = "(转接)";
}
if (item["CALLTYPE"].ToString() == "1")//呼出
{
info.CALLTYPE = "呼出" + strIsTran;
info.SERVICENUMBER = item["SERVICENUMBER"].ToString();//主叫
info.TELNUMBERLAST4 = item["TELNUMBERLAST4"].ToString();//被叫
}
else
{
info.CALLTYPE = "呼入" + strIsTran;
info.SERVICENUMBER = item["TELNUMBERLAST4"].ToString();//被叫
info.TELNUMBERLAST4 = item["SERVICENUMBER"].ToString();//主叫
}
info.TIMELENGTH = Convert.ToInt32(item["TIMELENGTH"]);
info.TIMESTART = Convert.ToDateTime(item["TIMESTART"]);
info.TIMEEND = Convert.ToDateTime(item["TIMEEND"]);
info.SALESEID = item["UNAME"].ToString() + "-" + item["SALESEID"].ToString();
info.FileName = item["FileName"].ToString();
data.Add(info);
}
return new JsonResult<IList<CallRecordView>> { result = true, retcode = pg.totalRows, retmsg = data };
}
public JsonResult<IList<SoftRptListView>> GetSoftRpt(DateTime stime, DateTime etime)
{
var list = _soft_user_Q.Soft_Rpt_Get(stime, etime);
return new JsonResult<IList<SoftRptListView>> { result = true, retcode = 200, retmsg = list };
}
}
[ServiceContract]
public interface IWxOrderSvr
{
[OperationContract]
[WebInvoke(Method = "*",
ResponseFormat = WebMessageFormat.Json,
BodyStyle = WebMessageBodyStyle.Bare,
UriTemplate = "CallRecord/Get?page={page}&resid={resid}&recordId={recordId}")]
JsonResult<IList<CallRecordView>> GetCallRecord(int page, string resId, string recordId = null);
[OperationContract]
[WebInvoke(Method = "*",
ResponseFormat = WebMessageFormat.Json,
BodyStyle = WebMessageBodyStyle.Bare,
UriTemplate = "SoftRpt/Get?stime={stime}&etime={etime}")]
JsonResult<IList<SoftRptListView>> GetSoftRpt(DateTime stime, DateTime etime);
}
public class CallRecordView
{
public decimal? recordid { get; set; }
public string RESID { get; set; }
public string CALLTYPE { get; set; }
public string SERVICENUMBER { get; set; }
public string TELNUMBERLAST4 { get; set; }
public decimal? TIMELENGTH { get; set; }
public DateTime? TIMESTART { get; set; }
public DateTime? TIMEEND { get; set; }
public string SALESEID { get; set; }
public string FileName { get; set; }
}
//public class SoftRptListView
//{
// public string ch { get; set; }
// public decimal registernumber { get; set; }
// public decimal resourcenumber { get; set; }
// public string resourcerate { get; set; }
// public decimal recordcount { get; set; }
// public string recordcountrate { get; set; }
// public decimal recordnumber { get; set; }
// public string recordrate { get; set; }
// public decimal firstcallnumber { get; set; }
// public decimal secondcallnumber { get; set; }
// public decimal allordernumber { get; set; }
// public string allorderrate { get; set; }
// public decimal allorderprice { get; set; }
//}
}