/// <summary> /// Job执行代理请求 /// </summary> /// <param name="proxy"></param> /// <returns></returns> public ReturnMessage <bool> ProxyDoByJob(Proxy proxy) { if (proxy == null) { throw new ProxyServiceException("proxy is null"); } var proxyType = proxy.ProxyType; Type proxyBaseType = ProxyHelper.GetType(proxyType); if (string.IsNullOrEmpty(proxy.ProxyJsonString)) { throw new ProxyServiceException("proxy.ProxyJsonString is empty"); } ProxyBase proxyBase = ProxyJsonHelper.ProxyObjectFromJsonString(proxy.ProxyJsonString, proxyBaseType, proxyType.UseDataMemberTransData) as ProxyBase; if (proxyBase == null) { throw new ProxyServiceException(string.Format("proxyType:{0},{1} is not a proxy base object", proxyType.FullName, proxyType.AssemblyName)); } string[] arrTypeName = proxy.ProxyType.FullName.Split('.'); string requestCode = arrTypeName[arrTypeName.Length - 1]; string requestName = requestCode; string bpFullName = string.Join(".", new List <string>(arrTypeName).GetRange(0, arrTypeName.Length - 2).ToArray()); bpFullName += "." + requestCode.Substring(0, requestCode.Length - 5); RequestSubmit rs = new RequestSubmit(); //参数applicaiton表示应用模块的代号. rs.Application = 3000; //参数priority表示调度执行的优先级,1表示最高优先级 rs.Priority = 1; //参数bpfullname表示服务的全名,包括命名空间 rs.BPFullName = bpFullName; //表示需要调度执行的应用,及调度具体执行的应用 rs.BPAgentObj = proxyBase; //表示请求执行的应用代码,即具体的服务名称 rs.RequestCode = requestCode; //在表示请求执行的服务名称,即在请求监控中看到的进程名称 rs.RequestName = requestName; //任何语言都可以的描述 rs.RequestDescription = requestName; // 是否成功执行不能重新执行 rs.IsSuccessCanNotReStart = true; //表示任务执行的时限,以秒为单位,即指定秒后开始进行调度执行 rs.SchedulerProject = new PatternRunOnce().PatternInstant(); //参数表示 提交到job进程里,可以保证在设定时间进行应用程序的执行 rs.Submit(); ReturnMessage <bool> ret = new ReturnMessage <bool>(); ret.IsSuccess = true; ret.Result = true; return(ret); }
public static long DoApproveAsynchronous(string ApproveProxyFullName, string BPFullName, List <SM.SO.SO.EntityKey> SO, List <SM.SO.SOLine.EntityKey> SOLine, DateTime ExecuteDate, string RequestCode, string RequestName, string RequestDescription) { DateTime date = UFIDA.U9.Base.Context.LoginDate; if (ExecuteDate > date) { Random rnd = new Random(DateTime.Now.Millisecond); //date = ExecuteDate.AddMinutes(rnd.Next(0, 59));//随机加分钟 //date = ExecuteDate.AddMinutes(1);//指定2分钟 date = date.AddSeconds(rnd.Next(5, 59)); } else { return(0); } //else // date = DateTime.Now.AddSeconds(1);//延迟1秒提交请求 string path = string.Empty; if (AppDomain.CurrentDomain.BaseDirectory.Contains("MailService")) { path = AppDomain.CurrentDomain.BaseDirectory + "Libs\\UFIDA.U9.Cust.GS.FT.FTBP.Agent.dll"; } else { path = AppDomain.CurrentDomain.BaseDirectory + "ApplicationServer\\Libs\\UFIDA.U9.Cust.GS.FT.FTBP.Agent.dll"; } //throw new Exception(path); System.Reflection.Assembly a = System.Reflection.Assembly.LoadFile(path); object o = a.CreateInstance(ApproveProxyFullName); Type t = o.GetType(); UFSoft.UBF.Util.TypeLoader typeLoader = new UFSoft.UBF.Util.TypeLoader(); //Type t = typeLoader.LoadType(ApproveProxyFullName); //object o = a.CreateInstance(ApproveProxyFullName); List <long> soList = new List <long>(); List <long> soLineList = new List <long>(); if (SO != null && SO.Count > 0) { foreach (SM.SO.SO.EntityKey so in SO) { soList.Add(so.ID); } } if (SOLine != null && SOLine.Count > 0) { foreach (SM.SO.SOLine.EntityKey line in SOLine) { soLineList.Add(line.ID); } } if (t.GetProperty("SO") != null) { t.GetProperty("SO").SetValue(o, soList, null); } if (t.GetProperty("SOLine") != null) { t.GetProperty("SOLine").SetValue(o, soLineList, null); } if (t.GetProperty("IsJobServer") != null) { t.GetProperty("IsJobServer").SetValue(o, false, null); } RequestSubmit rsb = new RequestSubmit(); rsb.Application = 3032; rsb.BPFullName = BPFullName; rsb.Priority = 1; rsb.RequestCode = RequestCode; PatternRunOnce once = new PatternRunOnce(); rsb.SchedulerProject = once.PatternID(date); rsb.RequestDescription = RequestDescription; rsb.RequestName = RequestName; rsb.BPAgentObj = o; return(rsb.Submit()); }