123 lines
3.8 KiB
C#
123 lines
3.8 KiB
C#
using Newtonsoft.Json;
|
|
using Quartz;
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Text;
|
|
using WX.CRM.BLL.Util;
|
|
using WX.CRM.BLL.Ww;
|
|
using WX.CRM.Common;
|
|
|
|
namespace WX.CRM.CRMServices.Res_AlloCate
|
|
{
|
|
public class WwHhuserAct
|
|
{
|
|
string url = "http://post.hc.dn8188.com/Rights/WeworkUser2Eid.html";
|
|
|
|
WW_HHUSER_EID_ACT_BL _wwHhuserAct = new WW_HHUSER_EID_ACT_BL();
|
|
|
|
SecurityHelper sHelper = new SecurityHelper();
|
|
|
|
public void Start()
|
|
{
|
|
try
|
|
{
|
|
var deptcode = Utility.GetSettingOrNullByKey("DataClientCode");
|
|
var channel = Utility.GetSettingOrNullByKey("Channel");
|
|
var ch = 0;
|
|
if (!string.IsNullOrEmpty(channel))
|
|
{
|
|
ch = int.Parse(channel);
|
|
}
|
|
|
|
var list = _wwHhuserAct.GetList(p => p.ISEXE == 0).OrderBy(p => p.CTIME);
|
|
|
|
var time = (long)Utility.ConvertDateTimeInt(DateTime.Now);
|
|
var message = JsonConvert.SerializeObject(new { account = "dn.crm", time });
|
|
var para = sHelper.createSignEncodingStr(message);
|
|
|
|
var urlUp = url + "?" + para;
|
|
|
|
var listUp = new List<WeworkUser2Eid>();
|
|
foreach (var item in list)
|
|
{
|
|
listUp.Add(new WeworkUser2Eid(item.APPID, item.USERID, Convert.ToInt32(item.EID), 1, deptcode, ch, item.ASSIGNSTATUS.HasValue ? Convert.ToInt32(item.ASSIGNSTATUS.Value) : 0));
|
|
}
|
|
|
|
var rsp = Utility.HttpPostData(urlUp, JsonConvert.SerializeObject(listUp), Encoding.UTF8);
|
|
|
|
var ret = JsonConvert.DeserializeAnonymousType(rsp, new { errcode = -1, errmsg = string.Empty });
|
|
|
|
if (ret.errcode == 0)
|
|
{
|
|
foreach (var item in list)
|
|
{
|
|
try
|
|
{
|
|
item.ISEXE = 1;
|
|
_wwHhuserAct.Update(item);
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
LogHelper.Error("更新上传关系记录失败:" + item.ToJson() + "---" + ex.ToString());
|
|
}
|
|
}
|
|
}
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
LogHelper.Error(ex);
|
|
}
|
|
}
|
|
}
|
|
|
|
public class WeworkUser2Eid
|
|
{
|
|
public WeworkUser2Eid()
|
|
{
|
|
}
|
|
|
|
public WeworkUser2Eid(string appid, string userid, int eid, int status, string deptcode, int ch, int assignstatus)
|
|
{
|
|
this.appid = appid;
|
|
this.userid = userid;
|
|
this.eid = eid;
|
|
this.status = status;
|
|
this.deptcode = deptcode;
|
|
this.ch = ch;
|
|
this.assignstatus = assignstatus;
|
|
}
|
|
|
|
public string appid { get; set; }
|
|
public string userid { get; set; }
|
|
public int eid { get; set; }
|
|
public int status { get; set; }
|
|
public string deptcode { get; set; }
|
|
public int ch { get; set; }
|
|
public int assignstatus { get; set; }
|
|
}
|
|
|
|
public class WwHhuserActJob : IJob
|
|
{
|
|
static bool _isNotice = false;
|
|
public void Execute(JobExecutionContext context)
|
|
{
|
|
if (_isNotice)
|
|
return;
|
|
_isNotice = true;
|
|
try
|
|
{
|
|
new WwHhuserAct().Start();
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
WX.CRM.Common.LogHelper.Error("WX.CRM.CRMServices.Res_AlloCate.WwHhuserActJob.WwHhuserAct().Execute:" + e);
|
|
}
|
|
finally
|
|
{
|
|
_isNotice = false;
|
|
}
|
|
}
|
|
}
|
|
}
|