123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129 |
- 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<AdviceModel> 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<AdviceModel> cancelList = AdviceCache.Instance.AdviceList.Where(s => s.Status == 3).ToList();
- IList<AdviceModel> 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<AdviceModel> 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<AdviceModel> lst = r1.ToList();
- return lst;
- }
- return null;
- }
- public IList<AdviceHistoryModel> GetAdviceHistoryPage(string filter, int pageIndex, int pageSize, ref int total)
- {
- IList<AdviceHistoryModel> list = new List<AdviceHistoryModel>();
- list = AdviceHistoryModelRepository.GetHistoryList(filter, pageIndex, pageSize, ref total);
- return list;
- }
- public string GetTest(string s)
- {
- string ss = s + "响应内容" + DateTime.Now.ToString(); ;
- return ss;
- }
- }
- }
|