using DSWeb.Common; using DSWeb.Common.DB; using DSWeb.Common.Helper; using log4net; using log4net.Repository.Hierarchy; using Newtonsoft.Json; using Newtonsoft.Json.Linq; using Quartz; using RabbitMQ.Client; using System; using System.Collections.Generic; using System.ComponentModel; using System.Configuration; using System.Linq; using System.Runtime.Caching; using System.Runtime.Remoting.Contexts; using System.Text; using System.Threading.Tasks; namespace DSWeb.Service.Output { // public class JobFanWeiToDS7 : IJob { //private const string ExchangeName = "output"; //private const string QueuePrefix = "djy.output.cangdan.ds7."; private ILog log = LogManager.GetLogger(typeof(JobFanWeiToDS7)); //private string rabbitUri = ConfigurationManager.AppSettings["OutputDS7MQUri"]; string OAconnStr = ConfigurationManager.AppSettings["OAconnStr"]; string DS7connStr = ConfigurationManager.AppSettings["DS7connStr"]; string DS7URL = ConfigurationManager.AppSettings["DS7URL"]; public void Execute(IJobExecutionContext context) { //int reqTimeout = Convert.ToInt32(context.JobDetail.JobDataMap.GetString("RequestTimeout")); try { log.Debug("Execute start"); //int reqTimeout = Convert.ToInt32(context.JobDetail.JobDataMap.GetString("RequestTimeout")); var dc1 = new OtherDB(OAconnStr); var cdc = new CommonDataContext(DS7connStr); //从cdc中寻找待读取审核结果的业务 var 待审核付费申请List = cdc.ch_fee_payapplication.Where(x => x.BILLSTATUS == 2 && x.PAYAPPID != null && x.PAYAPPID != "").ToList(); if (待审核付费申请List == null || 待审核付费申请List.Count <= 0) return; var idList = 待审核付费申请List.Select(s => s.PAYAPPID).ToList(); log.Info(idList.ToList()); //从dc1中寻找这些id的业务的审核结果 var 审核结果List = dc1.view_pjrequestbas.Where(x => (x.workflowid == 79 || x.workflowid == 77) && x.currentnodetype == "3" && idList.Contains(x.requestid.ToString())).ToList(); //var AuditGidlistStr = ""; foreach (var item in 审核结果List) { SetAudit(dc1, cdc, DS7URL, item); } //将审核完成的更新至cdc中的业务中 //update ch_fee_payapplication set BILLSTATUS=0,AUDITUSER='" + USERID + "',AUDITTIME='" + DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") + "' where BILLNO=@BILLNO"); log.Debug("Execute end"); } catch (Exception ex) { log.Debug($"catch:{ex.Message}"); log.Error(ex.Message); log.Error(ex.StackTrace); } } public void DoWork() { var dc1 = new OtherDB(OAconnStr); var cdc = new CommonDataContext(DS7connStr); //从cdc中寻找待读取审核结果的业务 var 待审核付费申请List = cdc.ch_fee_payapplication.Where(x => x.BILLSTATUS == 2 && x.PAYAPPID != null && x.PAYAPPID != "").ToList(); if (待审核付费申请List == null || 待审核付费申请List.Count <= 0) return; var idList = 待审核付费申请List.Select(s => s.PAYAPPID).ToList(); log.Debug(idList.ToList()); //从dc1中寻找这些id的业务的审核结果 var 审核结果List = dc1.view_pjrequestbas.Where(x => x.workflowid == 79 && x.currentnodetype == "3" && idList.Contains(x.requestid.ToString())).ToList(); //var AuditGidlistStr = ""; foreach (var item in 审核结果List) { SetAudit(dc1, cdc, DS7URL, item); } } private void SetAudit(OtherDB dc1, CommonDataContext cdc, string DS7URL, view_pjrequestbas_md Audititem) { try { //根据oa系统的userid查找ds7系统的userid log.Debug("audit start"); var OAUser = dc1.view_hrmresource.FirstOrDefault(x => x.id == Audititem.lastoperator); var ds7user = cdc.VW_user.Where(x => x.SHOWNAME.Replace(" ","") == OAUser.lastname).ToList(); //var ds7user = cdc.VW_user.Where(x => x.SHOWNAME == "系统管理员").ToList(); if (ds7user != null && ds7user.Count > 0) { var userid = ds7user[0].USERID; var dic = new Dictionary { { "requestid",Audititem.requestid.ToString()}, { "userid",userid} }; log.Debug("url=" + DS7URL+";dic="+JsonConvert.SerializeObject(dic)); string rtn = WebRequestHelper.DoPost(DS7URL, dic, 12000); log.Debug("rtn=" + rtn); } log.Debug("audit end"); } catch (Exception e) { log.Error(e.Message); } } } }