using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; using GDNXFD.Data.Model; using System.ServiceModel.Activation; using log4net; using GDNXFD.Data.Repositories; namespace GDNXFD.WcfService { public class AdviceService : IAdviceService { private static ILog logger = LogManager.GetLogger("AppInfoLog"); public bool ExecuteAdvice(IList executeList,string userId,string userName) { try { for (int i = 0; i < executeList.Count; i++) { AdviceModel m = AdviceCache.Instance.AdviceList.Where(s => s.WindturbineId == executeList[i].WindturbineId).FirstOrDefault(); if (m != null && m.Status == 1) { //如果用户执行推荐动作 if (executeList[i].Status == 2) { m.Status = executeList[i].Status; m.ExecuteTime = executeList[i].ExecuteTime; m.ExecuteOperation = m.AdviseOperation; m.Operater = executeList[i].Operater; AdviceCache.Instance.UpdateAdviceModelHistory(m.WindturbineId,2,userName,userId); } //如果用户取消推荐动作 else if (executeList[i].Status == 3) { m.Status = executeList[i].Status; m.ExecuteTime = executeList[i].ExecuteTime; m.ExecuteOperation = OperateStyle.Unknow; m.Operater = executeList[i].Operater; AdviceCache.Instance.UpdateAdviceModelHistory(m.WindturbineId, 3, userName, userId); } } } Console.WriteLine("&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&"); IList cancelList = AdviceCache.Instance.AdviceList.Where(s => s.Status == 3).ToList(); IList doItList = AdviceCache.Instance.AdviceList.Where(s => s.Status == 2).ToList(); for (int i = 0; i < cancelList.Count; i++) { Console.WriteLine(cancelList[i].WindturbineId + "-" + cancelList[i].Status + "-取消时间" + (cancelList[i].ExecuteTime.HasValue ? cancelList[i].ExecuteTime.Value.ToString() : "") + "-建议动作:" + cancelList[i].AdviseOperation.ToString() + "-实际动作" + cancelList[i].ExecuteOperation.ToString()); } Console.WriteLine("-----------------------------"); for (int i = 0; i < doItList.Count; i++) { Console.WriteLine(doItList[i].WindturbineId + "-" + doItList[i].Status + "-执行时间" + (doItList[i].ExecuteTime.HasValue ? doItList[i].ExecuteTime.Value.ToString() : "") + "-建议动作:" + doItList[i].AdviseOperation.ToString() + "-实际动作" + doItList[i].ExecuteOperation.ToString()); } Console.WriteLine("&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&"); } catch (Exception ex) { throw; } return true; } public IList GetAdvice(string stationId, OperateStyle? adviseOperation = null) { var tmp = AdviceCache.Instance.AdviceList; if (tmp != null && tmp.Count > 0) { var r1 = tmp.AsQueryable().Where(s => s.Status == 1); if (!string.IsNullOrWhiteSpace(stationId)) { r1 = r1.Where(q => q.StationId == stationId); } if (adviseOperation.HasValue) { r1 = r1.Where(q => q.AdviseOperation == adviseOperation); } IList lst = r1.ToList(); return lst; } return null; } public IList GetAdviceHistoryPage(string filter, int pageIndex, int pageSize, ref int total) { IList list = new List(); list = AdviceHistoryModelRepository.GetHistoryList(filter, pageIndex, pageSize, ref total); return list; } public string GetTest(string s) { string ss = s + "响应内容" + DateTime.Now.ToString(); ; return ss; } } }