59 lines
2.1 KiB
C#
59 lines
2.1 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using System.IO;
|
|
using System.Linq;
|
|
using System.Xml.Serialization;
|
|
using WX.CRM.BLL.Res;
|
|
using WX.CRM.Model.Entity;
|
|
|
|
namespace WX.CRM.CRMServices.ServicesModel
|
|
{
|
|
public class ResIdAndPhone
|
|
{
|
|
public string ResId { get; set; }
|
|
public string Number { get; set; }
|
|
}
|
|
|
|
public class RegPhone
|
|
{
|
|
public List<ResIdAndPhone> listPhone { get; private set; }
|
|
public RegPhone(List<ResIdAndPhone> _listPhone)
|
|
{
|
|
this.listPhone = _listPhone;
|
|
}
|
|
public void RegisterList()
|
|
{
|
|
List<string> resIds = this.listPhone.Select(p => p.ResId).ToList();
|
|
RES_CUSTOMER_BL res_customer = new RES_CUSTOMER_BL();
|
|
List<WX.CRM.Model.Entity.RES_CUSTOMER> exists_customer = new List<RES_CUSTOMER>();
|
|
int count = Convert.ToInt32(Math.Ceiling(resIds.Count / 300.00));
|
|
for (int i = 1; i <= count; i++)
|
|
{
|
|
string[] _resid = null;
|
|
if (i <= 1)
|
|
{
|
|
_resid = resIds.Take(300).ToArray();
|
|
}
|
|
else
|
|
{
|
|
_resid = resIds.Skip((i - 1) * 300).Take(300).ToArray();//分页
|
|
}
|
|
var resList = res_customer.getResByResIds(_resid);
|
|
exists_customer.AddRange(resList);
|
|
}
|
|
string[] isRegs = exists_customer.Select(p => p.RESID).ToArray();
|
|
var needToRegister = this.listPhone.Where(p => !isRegs.Contains(p.ResId));
|
|
foreach (var model in needToRegister)
|
|
{
|
|
RES_CUSTOMER customer = new RES_CUSTOMER();
|
|
customer.RESID = model.ResId;
|
|
var customerDetail = customer.RES_CUSTOMERDETAIL;
|
|
var xmls = new XmlSerializer(typeof(RES_CUSTOMERDETAIL));
|
|
var sw = new StringWriter();
|
|
xmls.Serialize(sw, customerDetail);
|
|
res_customer.ResgisterCustomer(model.Number, model.ResId, "CallRecord", sw.ToString());
|
|
}
|
|
}
|
|
}
|
|
}
|