170 lines
6.8 KiB
C#
170 lines
6.8 KiB
C#
using System;
|
|
using System.Text;
|
|
using System.Text.RegularExpressions;
|
|
using System.Web;
|
|
using WX.CRM.BLL.Util;
|
|
|
|
namespace WX.CRM.CRMServices.SoftUser
|
|
{
|
|
public class GetRegUserByUrl
|
|
{
|
|
string companyId = "";
|
|
DateTime v_sd = System.DateTime.Now;
|
|
DateTime v_ed = System.DateTime.Now;
|
|
string GetMobiles(out bool isSuss, out DateTime lastTime)
|
|
{
|
|
lastTime = System.DateTime.Now;
|
|
isSuss = false;
|
|
string result = "";
|
|
try
|
|
{
|
|
WX.CRM.BLL.Soft.GET_REGUSER dpar = new WX.CRM.BLL.Soft.GET_REGUSER();
|
|
DateTime sd = dpar.GetServiceLastExecTime();
|
|
DateTime ed = sd.AddDays(5);
|
|
ed = ed <= System.DateTime.Now ? ed : System.DateTime.Now;
|
|
lastTime = ed;
|
|
v_sd = sd;
|
|
v_ed = lastTime;
|
|
|
|
CACHE_BL cachebl = new CACHE_BL();
|
|
string companyCode = cachebl.GetValue_Parameter("Sys_Bussiness_Code");
|
|
|
|
string _url = System.Configuration.ConfigurationManager.AppSettings["GetRegUserResourceUrl"];
|
|
string _id = System.Configuration.ConfigurationManager.AppSettings["typeId"];
|
|
companyId = _id;
|
|
|
|
System.Web.Script.Serialization.JavaScriptSerializer serize = new System.Web.Script.Serialization.JavaScriptSerializer();
|
|
//string message = serize.Serialize(new ResModel() { StartTime = sd.ToString(), EndTime = ed.ToString(), typeId = _id });
|
|
string message = serize.Serialize(new ResModel() { StartTime = sd.ToString(), EndTime = ed.ToString(), companyCode = companyCode });
|
|
string clientid = SecurityHelper.OrderClientIdKey;
|
|
string key = "key={0}&clientId=UPWEBSITE&sign={1}";
|
|
string jiami = new SecurityHelper().encyptData(clientid, message);
|
|
string jiami1 = HttpUtility.UrlEncode(jiami, Encoding.UTF8);
|
|
string jiasuo = new SecurityHelper().signData(clientid, jiami);
|
|
string jiasuo1 = HttpUtility.UrlEncode(jiasuo, Encoding.UTF8);
|
|
key = string.Format(key, jiami1, jiasuo1);
|
|
|
|
//WX.CRM.Common.LogHelper.Error(_url);
|
|
// string str = WX.CRM.Common.Utility.HttpPostData(_url, key, Encoding.UTF8);
|
|
string str = WX.CRM.Common.Utility.PostData(_url + "?" + key, System.Text.Encoding.UTF8);
|
|
str = new SecurityHelper().decyptData(SecurityHelper.OrderClientIdKey, str);
|
|
|
|
// WX.CRM.Common.LogHelper.Error(string.Concat("AY.ResourceSystem.AddMobileByInterface.GetMobiles():", str));
|
|
|
|
res info = new res();
|
|
info = WX.CRM.Common.Utility.JSONToObject<res>(str);
|
|
if (info.result == true)
|
|
{
|
|
result = string.Format("{0}", info.returnData).Trim();
|
|
}
|
|
else
|
|
{
|
|
WX.CRM.Common.LogHelper.Error(string.Concat("错误,返回值为:", str));
|
|
}
|
|
isSuss = true;
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
result = "";
|
|
WX.CRM.Common.LogHelper.Error(string.Concat("AY.ResourceSystem.GetRegUserByUrl.GetMobiles():", ex.Message, ex.StackTrace));
|
|
}
|
|
return result;
|
|
}
|
|
public void Insert()
|
|
{
|
|
bool v_isSuss = true;
|
|
DateTime lastTime = System.DateTime.Now;
|
|
string str = string.Format("{0}", GetMobiles(out v_isSuss, out lastTime));
|
|
try
|
|
{
|
|
DateTime? maxD = null;
|
|
if (string.IsNullOrEmpty(str))
|
|
{
|
|
if (v_isSuss == true)
|
|
new WX.CRM.BLL.Soft.GET_REGUSER().UpdateExecLastTime(lastTime);
|
|
return;
|
|
}
|
|
string[] mbs = str.Split('|');
|
|
string rgs = @"^(13|15|18|14|17|16)\d{9}$";
|
|
Regex reg = new Regex(rgs);
|
|
foreach (string mb in mbs)
|
|
{
|
|
//WX.CRM.Common.LogHelper.Error("-----------------foreach------------------");
|
|
//18696548545,5001,6201075,5001,2013-8-7 13:54:16 【手机号,标签,卡号,用户名,注册时候】
|
|
string[] ar = mb.Split(',');
|
|
if (!string.IsNullOrEmpty(ar[3])) //用户名不为空
|
|
{
|
|
DateTime? rd = getDatetime(ar[4]);
|
|
int cid = getDecimal(companyId);
|
|
|
|
//WX.CRM.Common.LogHelper.Error(string.Format("------{0},{1},{2},{3},{4},{5}", ar[0], ar[1], ar[2], ar[3], rd, cid));
|
|
new WX.CRM.BLL.Soft.GET_REGUSER().RegUser(ar[0], ar[1], ar[2], ar[3], rd, cid);
|
|
}
|
|
|
|
DateTime tem = System.DateTime.Now;
|
|
if (DateTime.TryParse(ar[4], out tem))
|
|
{
|
|
if (maxD == null)
|
|
maxD = tem;
|
|
else
|
|
maxD = maxD < tem ? tem : maxD;
|
|
}
|
|
else
|
|
{
|
|
tem = System.DateTime.Now;
|
|
}
|
|
}
|
|
//WX.CRM.Common.LogHelper.Error("-------------------注册用户抓取开始执行end--------------" + DateTime.Now.ToString());
|
|
//WX.CRM.Common.LogHelper.Error("---------------------------------------" + maxD.GetValueOrDefault(System.DateTime.Now).ToString());
|
|
if (v_sd == maxD)
|
|
maxD = v_ed;
|
|
new WX.CRM.BLL.Soft.GET_REGUSER().UpdateExecLastTime(maxD.GetValueOrDefault(System.DateTime.Now));
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
WX.CRM.Common.LogHelper.Error(string.Concat("AY.ResourceSystem.GetRegUserByUrl.Insert():", ex.Message, ex.StackTrace));
|
|
}
|
|
}
|
|
|
|
int getDecimal(string str)
|
|
{
|
|
int r = 0;
|
|
try
|
|
{
|
|
r = int.Parse(str);
|
|
}
|
|
catch
|
|
{
|
|
r = 0;
|
|
}
|
|
return r;
|
|
}
|
|
DateTime? getDatetime(string dstr)
|
|
{
|
|
DateTime? d = null;
|
|
try
|
|
{
|
|
d = DateTime.Parse(dstr);
|
|
}
|
|
catch
|
|
{
|
|
d = null;
|
|
}
|
|
return d;
|
|
}
|
|
|
|
public class ResModel
|
|
{
|
|
public string StartTime { get; set; }
|
|
public string EndTime { get; set; }
|
|
public string companyCode { get; set; }
|
|
}
|
|
public class res
|
|
{
|
|
public bool result { get; set; }
|
|
public string retcode { get; set; }
|
|
public string returnData { get; set; }
|
|
}
|
|
}
|
|
}
|