/// <summary> /// 输出流量计Uid和对应time的各个流量分析数值 /// </summary> /// <param name="uid"></param> /// <param name="time"></param> /// <returns></returns> public JsonResult Analysis(Guid uid, DateTime time) { JsonResult result = new JsonResult(); result.JsonRequestBehavior = JsonRequestBehavior.AllowGet; //User_t account = UserContext.account; FlowMeter_t flowmeter = flowmeter_Service.GetFlowMeterByFMUid(uid); Func <FlowMeterData> fmdataFunc = () => flowmeter_Service.GetAnalysisByFlowMeter(flowmeter, (DateTime)time); time = time == null ? System.DateTime.Now : time; result.Data = DBHelper.getT <FlowMeterData>(fmdataFunc, ConfigurationManager.AppSettings["FlowMeterAnalysisByFMUid"] + uid); //Func<List<FlowMeterData>> fmdataFunc = () => flowmeter_Service.GetFlowMetersDataByUserUid(account); //var fmdataanalysis = DBHelper.get<FlowMeterData>(fmdataFunc, ConfigurationManager.AppSettings["allFlowAnalysisByUserUid"] + account.Usr_UId); //result.Data = fmdataanalysis.Where(p => p.flowmeter.FM_UId == uid).FirstOrDefault(); return(result); }
/// <summary> /// 输出经常访问的流量计分析数据 /// </summary> /// <param name="fmUids"></param> /// <returns></returns> /// public JsonResult GetMostVisitsFlowMeter() { JsonResult result = new JsonResult(); result.JsonRequestBehavior = JsonRequestBehavior.AllowGet; List <FlowMeterData> fmdata_account = new List <FlowMeterData>(); User_t account = UserContext.account; //获取账号访问设备次数的list Func <List <VisitCount> > initvisit = () => { return(new List <VisitCount>()); }; List <VisitCount> vclist = DBHelper.get <List <VisitCount> >(initvisit, UserContext.account.Usr_UId + ConfigurationManager.AppSettings["VisitFlowMeterCount"]); //Func<List<FlowMeterData>> fmdataFunc = () => flowmeter_Service.GetFlowMetersDataByUserUid(account); //List<FlowMeterData> fmdataanalysis = DBHelper.get<FlowMeterData>(fmdataFunc, ConfigurationManager.AppSettings["allFlowAnalysisByUserUid"] + account.Usr_UId); List <FlowMeter_t> fmlist = new List <FlowMeter_t>(); if (account.Usr_Type == 3) { fmlist = flowmeter_Service.GetFlowMetersByUserUid(account.Usr_UId).ToList(); } else { fmlist = flowmeter_Service.GetAllFlowMeter(); } if (vclist.Count > 0) { vclist = vclist.OrderByDescending(p => p.count).ToList(); foreach (var vcitem in vclist) { FlowMeter_t fm = fmlist.First(p => p.FM_UId == Guid.Parse(vcitem.uid)); if (fm.FM_FlowCountLast != null) { Func <FlowMeterData> fmdataFunc = () => flowmeter_Service.GetAnalysisByFlowMeter(fm, (DateTime)fm.FM_FlowCountLast); var fmdata = DBHelper.getT <FlowMeterData>(fmdataFunc, ConfigurationManager.AppSettings["FlowMeterAnalysisByFMUid"] + fm.FM_UId); fmdata_account.Add(fmdata); } } foreach (FlowMeter_t item in fmlist) { if (vclist.All(p => p.uid != item.FM_UId.ToString()) && item.FM_FlowCountLast != null) { Func <FlowMeterData> fmdataFunc = () => flowmeter_Service.GetAnalysisByFlowMeter(item, (DateTime)item.FM_FlowCountLast); var fmdata = DBHelper.getT <FlowMeterData>(fmdataFunc, ConfigurationManager.AppSettings["FlowMeterAnalysisByFMUid"] + item.FM_UId); fmdata_account.Add(fmdata); } } } else { foreach (var item in fmlist) { if (item.FM_FlowCountLast != null) { Func <FlowMeterData> fmdataFunc = () => flowmeter_Service.GetAnalysisByFlowMeter(item, (DateTime)item.FM_FlowCountLast); var fmdata = DBHelper.getT <FlowMeterData>(fmdataFunc, ConfigurationManager.AppSettings["FlowMeterAnalysisByFMUid"] + item.FM_UId); fmdata_account.Add(fmdata); } } } string dataresult = ToJson <List <FlowMeterData> > .Obj2Json <List <FlowMeterData> >(fmdata_account).Replace("\\\\", ""); dataresult = dataresult.Replace("\\\\", ""); result.Data = dataresult; return(result); }