public static void ListenMq() { //var mappers = AppDomain.CurrentDomain.GetAssemblies() // .SelectMany(a => a.GetTypes().Where(t => t.GetInterfaces().Contains(typeof(PFConsumerTask)))); Type[] taskTypes = new Type[] { typeof(PFConsumerTask), typeof(PFConsumerResponseTask) }; var mappers = AppDomain.CurrentDomain.GetAssemblies() .SelectMany(a => a.GetTypes().Where(t => t.GetInterfaces().Any(b => taskTypes.Contains(b)))); //if (!mappers.Any()) { throw new Exception("必需实现接口IPFConfigMapper"); } foreach (var i in mappers) { var taskObj = Activator.CreateInstance(i); if (taskObj is PFConsumerResponseTask) { PFConsumerResponseTask tmpObj = taskObj as PFConsumerResponseTask; PFMqHelper.BuildConsumer(tmpObj); } else if (taskObj is PFConsumerTask) { PFConsumerTask tmpObj = taskObj as PFConsumerTask; PFMqHelper.BuildConsumer(tmpObj); } //PFConsumerTask tmpObj = Activator.CreateInstance(i) as PFConsumerTask; //PFMqHelper.BuildConsumer(tmpObj); } //var mapper = Activator.CreateInstance(mappers.First()); }
public static List <CompareCnt> Product(string backupDatabase) { var resMsg = ""; var p = new PagingParameters(); p["backupDatabase"] = "bonus"; var st = DateTime.Now; var t = PFMqHelper.BuildProducer(JsonConvert.SerializeObject(p), new MonthDataCompareCntProducer()); t.Wait(); resMsg = t.Result.Body; var result = JsonConvert.DeserializeObject <List <CompareCnt> >(resMsg); return(result); }