private void WeaveMethods( TypeDefinition clazz, IReadOnlyList <CrossCutterN.Aspect.Metadata.ICustomAttribute> classCustomAttributes, MethodWeaver methodWeaver, IClassWeavingStatisticsBuilder statistics) { foreach (var method in clazz.Methods) { // methods without bodies can't be injected // property getter and setter will be handled in property phase if (!method.HasBody || IsPropertyMethod(method)) { continue; } var methodInfo = method.Convert(classCustomAttributes); var plan = planner.MakePlan(methodInfo); if (!plan.IsEmpty()) { var methodStatistics = StatisticsFactory.InitializeMethodWeavingRecord(method.Name, method.FullName); methodWeaver.Weave(method, plan, null, methodStatistics); var methodStatisticsFinished = methodStatistics.Build(); if (methodStatisticsFinished != null) { statistics.AddMethodWeavingStatistics(methodStatisticsFinished); } } } }
void statisticsTest() { /* Create Statistics in right and wrong manner */ StatisticsFactory factory = StatisticsFactory.GetExistingInstance(); /* Register a type */ TestStatisticsType testType = new TestStatisticsType(); createType(factory, testType); Util.Log("Statistics Type TestStats Registered"); /* Create a statistics */ Statistics testStat1 = factory.CreateStatistics(testType.testStatsType, "TestStatistics"); Assert.IsNotNull(testStat1, "Test Statistics Creation Failed"); /* Tests Find Type , Find Statistics */ Statistics temp = factory.FindFirstStatisticsByType(testType.testStatsType); Assert.IsNotNull(temp, "findFirstStatisticsByType Failed"); Util.Log("Statistics testStat1 Created Successfully."); /* Test Set Functions */ testGetSetIncFunctions(testStat1, testType); Util.Log("Get / Set / Inc Functions Tested "); /* Close Statistics */ testStat1.Close(); Statistics temp2 = factory.FindFirstStatisticsByType(testType.testStatsType); Assert.IsNull(temp2, "Statistics close() Failed"); Util.Log("StatisticsTest Completed"); }
private void WeaveProperties( TypeDefinition clazz, IReadOnlyList <CrossCutterN.Aspect.Metadata.ICustomAttribute> classCustomAttributes, MethodWeaver methodWeaver, IClassWeavingStatisticsBuilder statistics) { foreach (var property in clazz.Properties) { var propertyInfo = property.Convert(classCustomAttributes); var plan = planner.MakePlan(propertyInfo); if (!plan.IsEmpty()) { var propertyStatistics = StatisticsFactory.InitializePropertyWeavingRecord(property.Name, property.FullName); var getterPlan = plan.GetterPlan; var getter = property.GetMethod; if (!getterPlan.IsEmpty() && getter != null) { methodWeaver.Weave(getter, getterPlan, property.Name, propertyStatistics.GetterContainer); } var setterPlan = plan.SetterPlan; var setter = property.SetMethod; if (!setterPlan.IsEmpty() && setter != null) { methodWeaver.Weave(setter, setterPlan, property.Name, propertyStatistics.SetterContainer); } var propertyStatisticsFinished = propertyStatistics.Build(); if (propertyStatisticsFinished != null) { statistics.AddPropertyWeavingStatistics(propertyStatisticsFinished); } } } }
public static Pagination Search_MonthCardInfo(InParams paras, int PageSize, int PageIndex) { Pagination _pagination = new Pagination(); IStatistics factory = StatisticsFactory.GetFactory(); _pagination.Total = factory.Search_MonthCardInfoCount(paras); List <MonthCardInfoModel> iorecordlist = factory.Search_MonthCardInfo(paras, PageSize, PageIndex); if (iorecordlist != null && iorecordlist.Count > 0) { foreach (var m in iorecordlist) { if (m.StartTime > DateTime.MinValue) { m.strStartTime = m.StartTime.ToString("yyyy-MM-dd HH:mm:ss"); } if (m.EndTime > DateTime.MinValue) { m.strEndTime = m.EndTime.ToString("yyyy-MM-dd HH:mm:ss"); } } } _pagination.MonthCardList = iorecordlist; return(_pagination); }
/// <summary> /// 车牌前缀查询 /// </summary> /// <param name="paras">输入参数</param> /// <returns></returns> public static List <PlateNumberPrefixModel> Search_PlateNumberPrefix(InParams paras) { List <PlateNumberPrefixModel> iorecordlist = new List <PlateNumberPrefixModel>(); IStatistics factory = StatisticsFactory.GetFactory(); iorecordlist = factory.Search_PlateNumberPrefix(paras); BaseParkinfo park = Common.Services.ParkingServices.QueryParkingByParkingID(paras.ParkingID); int total = 0; //处理数据 if (iorecordlist != null && iorecordlist.Count > 0) { total = iorecordlist.Select(u => u.Number).Sum(); foreach (var record in iorecordlist) { if (park != null) { record.ParkingName = park.PKName; } record.Rate = ((record.Number / (total * 1.0)) * 100).ToString("0.00") + "%"; } } return(iorecordlist); }
private void WeaveExitJoinPoint( MethodDefinition method, ILProcessor processor, IReadOnlyCollection <IAdviceInfo> advices, ICanAddMethodWeavingRecord statistics, string propertyName, string methodSignature) { var instructions = new List <Instruction>(); if (advices != null && advices.Any()) { UpdateLocalVariablesOnExit(method, instructions, processor); // inject advices for (var i = 0; i < advices.Count; i++) { var advice = advices.ElementAt(i); CallAdvice(method, processor, advice, instructions, propertyName, methodSignature); var record = StatisticsFactory.InitializeWeavingRecord( JoinPoint.Exit, advice.AspectName, advice.Advice.GetFullName(), advice.Advice.GetSignatureWithTypeFullName(), i); statistics.AddWeavingRecord(record); } } CompleteWeavingExit(method, instructions, processor); }
public void makeStatistics() { var statistics = StatisticsFactory.createStatistics(); this._dbContext.statistics.Add(statistics); this._dbContext.SaveChanges(); }
/// <summary> /// 获得临停缴费记录 /// </summary> /// <param name="paras">输入参数</param> /// <returns></returns> public static List <ParkOrder> Search_TempPays(InParams paras) { IStatistics factory = StatisticsFactory.GetFactory(); List <ParkOrder> temp = factory.Search_TempPays(paras); ParkOrderFormat(temp); return(temp); }
/// <summary> /// 获取异常放行记录 /// </summary> /// <param name="paras">输入参数</param> /// <returns></returns> public static List <ParkIORecord> Search_ExceptionRelease(InParams paras) { List <ParkIORecord> iorecordlist = new List <ParkIORecord>(); IStatistics factory = StatisticsFactory.GetFactory(); iorecordlist = factory.Search_ExceptionRelease(paras); IORecordFormat(iorecordlist); return(iorecordlist); }
public static Pagination Search_DevConnctions(InParams paras, int PageSize, int PageIndex) { Pagination _pagination = new Pagination(); IStatistics factory = StatisticsFactory.GetFactory(); _pagination.Total = factory.Search_DevConnectionCount(paras); _pagination.GateEventList = factory.Search_DevConnection(paras, PageSize, PageIndex); return(_pagination); }
/// <summary> /// 获得临停缴费记录 /// </summary> /// <param name="paras">输入参数</param> /// <param name="PageSize">每页显示数</param> /// <param name="PageIndex">当前页</param> /// <returns></returns> public static Pagination Search_CarDerates(InParams paras, int PageSize, int PageIndex) { Pagination _pagination = new Pagination(); IStatistics factory = StatisticsFactory.GetFactory(); _pagination.Total = factory.Search_CarDeratesCount(paras); _pagination.CarDerateList = factory.Search_CarDerates(paras, PageSize, PageIndex); return(_pagination); }
/// <summary> /// 在场无牌车辆 /// </summary> /// <param name="paras">输入参数</param> /// <returns></returns> public static List <ParkIORecord> Search_NoPlateNumber(InParams paras) { List <ParkIORecord> iorecordlist = new List <ParkIORecord>(); IStatistics factory = StatisticsFactory.GetFactory(); iorecordlist = factory.Search_NoPlateNumber(paras); IORecordFormat(iorecordlist); return(iorecordlist); }
/// <summary> /// 获得临停缴费记录 /// </summary> /// <param name="paras">输入参数</param> /// <param name="PageSize">每页显示数</param> /// <param name="PageIndex">当前页</param> /// <returns></returns> public static Pagination Search_SellerRecharge(InParams paras, int PageSize, int PageIndex) { Pagination _pagination = new Pagination(); IStatistics factory = StatisticsFactory.GetFactory(); _pagination.Total = factory.Search_SellerRechargeCount(paras); _pagination.OrderList = factory.Search_SellerRecharges(paras, PageSize, PageIndex); return(_pagination); }
public static Pagination QueryParkVisitorReport(VisitorReportCondition paras, int PageSize, int PageIndex) { Pagination _pagination = new Pagination(); IStatistics factory = StatisticsFactory.GetFactory(); int recordTotalCount = 0; _pagination.VisitorList = factory.QueryParkVisitorReport(paras, PageSize, PageIndex, out recordTotalCount); _pagination.Total = recordTotalCount; return(_pagination); }
/// <summary> /// 获得月卡续期记录 /// </summary> /// <param name="paras">输入参数</param> /// <param name="PageSize">每页显示数</param> /// <param name="PageIndex">当前页</param> /// <returns></returns> public static Pagination Search_CardExtension(InParams paras, int PageSize, int PageIndex) { Pagination _pagination = new Pagination(); IStatistics factory = StatisticsFactory.GetFactory(); _pagination.Total = factory.Search_CardExtensionCount(paras); _pagination.OrderList = factory.Search_CardExtension(paras, PageSize, PageIndex); ParkOderMonthTimeLong(_pagination.OrderList); return(_pagination); }
public PerfStat(int threadID) { PerfStatType regStatType = PerfStatType.GetInstance(); statsType = regStatType.GetStatType(); StatisticsFactory factory = StatisticsFactory.GetExistingInstance(); string buf = String.Format("ThreadId-{0}", threadID); testStat = factory.CreateStatistics(statsType, buf); }
/// <summary> /// 获得临停缴费记录 /// </summary> /// <param name="paras">输入参数</param> /// <param name="PageSize">每页显示数</param> /// <param name="PageIndex">当前页</param> /// <returns></returns> public static Pagination Search_RechargePays(InParams paras, int PageSize, int PageIndex) { Pagination _pagination = new Pagination(); IStatistics factory = StatisticsFactory.GetFactory(); _pagination.Total = factory.Search_RechargePaysCount(paras); List <ParkOrder> temp = factory.Search_RechargePays(paras, PageSize, PageIndex); ParkOrderFormat(temp); _pagination.OrderList = temp; return(_pagination); }
public StatisticsType GetStatType() { StatisticsFactory m_factory = StatisticsFactory.GetExistingInstance(); StatisticsType statsType = m_factory.FindType("cacheperf.CachePerfStats"); if (statsType == null) { statDes[0] = m_factory.CreateIntCounter(PerfOps.PERF_PUTS, "Number of puts completed.", "operations", 1); statDes[1] = m_factory.CreateLongCounter(PerfOps.PERF_PUT_TIME, "Total time spent doing puts.", "nanoseconds", 0); statDes[2] = m_factory.CreateIntCounter(PerfOps.PERF_UPDATE_EVENTS, "Number of update events.", "events", 1); statDes[3] = m_factory.CreateLongCounter(PerfOps.PERF_UPDATE_LATENCY, "Latency of update operations.", "nanoseconds", 0); statDes[4] = m_factory.CreateIntCounter(PerfOps.PERF_CREATES, "Number of creates completed.", "operations", 1); statDes[5] = m_factory.CreateLongCounter(PerfOps.PERF_CREATE_TIME, "Total time spent doing creates.", "nanoseconds", 0); statDes[6] = m_factory.CreateIntCounter(PerfOps.PERF_LATENCY_SPIKES, "Number of latency spikes.", "spikes", 0); statDes[7] = m_factory.CreateIntCounter( PerfOps.PERF_NEGATIVE_LATENCIES, "Number of negative latencies (caused by insufficient clock skew correction).", "negatives", 0); statDes[8] = m_factory.CreateIntCounter(PerfOps.PERF_OPS, "Number of operations completed.", "operations", 1); statDes[9] = m_factory.CreateLongCounter(PerfOps.PERF_OP_TIME, "Total time spent doing operations.", "nanoseconds", 0); statDes[10] = m_factory.CreateIntCounter(PerfOps.PERF_CONNECTS, "Number of connects completed.", "operations", 1); statDes[11] = m_factory.CreateLongCounter(PerfOps.PERF_CONNECT_TIME, "Total time spent doing connects.", "nanoseconds", 0); statDes[12] = m_factory.CreateIntCounter(PerfOps.PERF_DISCONNECTS, "Number of disconnects completed.", "operations", 1); statDes[13] = m_factory.CreateLongCounter(PerfOps.PERF_DISCONNECT_TIME, "Total time spent doing disconnects.", "nanoseconds", 0); statDes[14] = m_factory.CreateIntCounter(PerfOps.PERF_GETS, "Number of gets completed.", "operations", 1); statDes[15] = m_factory.CreateLongCounter(PerfOps.PERF_GET_TIME, "Total time spent doing gets.", "nanoseconds", 0); statDes[16] = m_factory.CreateIntCounter(PerfOps.PERF_QUERIES, "Number of queries completed.", "operations", 1); statDes[17] = m_factory.CreateLongCounter(PerfOps.PERF_QUERY_TIME, "Total time spent doing queries.", "nanoseconds", 0); statDes[18] = m_factory.CreateIntCounter(PerfOps.PERF_UPDATES, "Number of updates completed.", "operations", 1); statDes[19] = m_factory.CreateLongCounter(PerfOps.PERF_UPDATES_TIME, "Total time spent doing updates.", "nanoseconds", 0); statsType = m_factory.CreateType("cacheperf.CachePerfStats", "Application statistics.", statDes, 20); } return(statsType); }
/// <summary> /// 获取小车场在场车辆记录 /// </summary> /// <param name="paras"></param> /// <param name="PageSize"></param> /// <param name="PageIndex"></param> /// <returns></returns> public static Pagination Search_PresenceSmall(InParams paras, int PageSize, int PageIndex) { Pagination _pagination = new Pagination(); IStatistics factory = StatisticsFactory.GetFactory(); _pagination.Total = factory.Search_PresenceCountSmall(paras); List <ParkIORecord> iorecordlist = factory.Search_PresenceSmall(paras, PageSize, PageIndex); IORecordFormat(iorecordlist); _pagination.IORecordsList = iorecordlist; return(_pagination); }
/// <summary> /// Add switch registering to a class. /// </summary> /// <param name="clazz">The class to register switch.</param> /// <param name="context">The weaving context.</param> /// <param name="switchData">Data of switches.</param> /// <param name="statistics">Weaving statistics.</param> public static void Weave(TypeDefinition clazz, IWeavingContext context, IReadOnlyList <SwitchInitializingData> switchData, IClassWeavingStatisticsBuilder statistics) { #if DEBUG if (clazz == null) { throw new ArgumentNullException("clazz"); } if (context == null) { throw new ArgumentNullException("context"); } if (switchData == null || !switchData.Any()) { throw new ArgumentNullException("switchData"); } if (statistics == null) { throw new ArgumentNullException("statistics"); } #endif var staticConstructor = clazz.Methods.FirstOrDefault(mthd => mthd.IsStaticConstructor()); MethodDefinition method = null; ILProcessor processor = null; if (staticConstructor == null) { method = new MethodDefinition( ".cctor", MethodAttributes.Static | MethodAttributes.HideBySig | MethodAttributes.SpecialName | MethodAttributes.RTSpecialName, context.GetTypeReference(typeof(void))); processor = method.Body.GetILProcessor(); method.Body.Instructions.Add(processor.Create(OpCodes.Ret)); clazz.Methods.Add(method); } else { method = staticConstructor; processor = method.Body.GetILProcessor(); } var typeName = clazz.GetFullName(); var instructions = new List <Instruction>(); foreach (var data in switchData) { RegisterSwitch(instructions, processor, context, data, typeName); statistics.AddSwitchWeavingRecord(StatisticsFactory.InitializeSwitchWeavingRecord(typeName, data.Property, data.MethodSignature, data.Aspect, data.Field.Name, data.Value)); } CompleteSwitchRegistration(method, instructions, processor, context, typeName); }
public ItemTemplate AddBaseAttribute(StatisticsTypes type, double Value, double perLevelChange) { var statFactory = new StatisticsFactory(); if (BaseAttributes == null) { BaseAttributes = new List <Statistics>(); } if (!BaseAttributes.ContainsType(type)) { BaseAttributes.Add(statFactory.CreateStatFlat(Value, perLevelChange, type)); } return(this); }
void createType(StatisticsFactory statFactory, TestStatisticsType testType) { StatisticDescriptor[] statDescriptorArr = new StatisticDescriptor[6]; statDescriptorArr[0] = statFactory.CreateIntCounter("IntCounter", "Test Statistic Descriptor int_t Counter.", "TestUnit"); statDescriptorArr[1] = statFactory.CreateIntGauge("IntGauge", "Test Statistic Descriptor int_t Gauge.", "TestUnit"); statDescriptorArr[2] = statFactory.CreateLongCounter("LongCounter", "Test Statistic Descriptor Long Counter.", "TestUnit"); statDescriptorArr[3] = statFactory.CreateLongGauge("LongGauge", "Test Statistic Descriptor Long Gauge.", "TestUnit"); statDescriptorArr[4] = statFactory.CreateDoubleCounter("DoubleCounter", "Test Statistic Descriptor Double Counter.", "TestUnit"); statDescriptorArr[5] = statFactory.CreateDoubleGauge("DoubleGauge", "Test Statistic Descriptor Double Gauge.", "TestUnit"); StatisticsType statsType = statFactory.CreateType("TestStatsType", "Statistics for Unit Test.", statDescriptorArr, 6); Assert.IsNotNull(statsType, "Error in creating Stats Type"); testType.testStatsType = statsType; testType.statIdIntCounter = statsType.NameToId("IntCounter"); testType.statIdIntGauge = statsType.NameToId("IntGauge"); testType.statIdLongCounter = statsType.NameToId("LongCounter"); testType.statIdLongGauge = statsType.NameToId("LongGauge"); testType.statIdDoubleCounter = statsType.NameToId("DoubleCounter"); testType.statIdDoubleGauge = statsType.NameToId("DoubleGauge"); StatisticsType statsType1 = statFactory.CreateType("TestStatsType1", "Statistics for Unit Test", statDescriptorArr, 6); testType.testStatsType = statsType1; /* Test Find */ Assert.IsNotNull(statFactory.FindType("TestStatsType"), "stat not found"); Assert.IsNotNull(statFactory.FindType("TestStatsType1"), "stat not found"); Assert.IsNull(statFactory.FindType("TestStatsType2"), "stat not to be found"); }
/// <summary> /// 获得临停缴费记录 /// </summary> /// <param name="paras">输入参数</param> /// <returns></returns> public static List <ReportPoundNoteModel> Search_TempPaysPound(InParams paras) { IStatistics factory = StatisticsFactory.GetFactory(); List <ReportPoundNoteModel> temp = factory.Search_TempPaysPound(paras); if (temp != null && temp.Count > 0) { foreach (var p in temp) { p.LongTime = Functions.CalLongTime(p.EntranceTime, p.ExitTime); p.OrderTimeName = p.OrderTime.ToString("yyyy-MM-dd HH:mm:ss"); p.EntranceTimeName = p.EntranceTime.ToString("yyyy-MM-dd HH:mm:ss"); p.ExitTimeName = p.ExitTime.ToString("yyyy-MM-dd HH:mm:ss"); } } return(temp); }
/// <summary> /// 获得临停缴费记录 /// </summary> /// <param name="paras">输入参数</param> /// <returns></returns> public static List <Statistics_Gather> Search_MonthStatistics(InParams paras) { IStatistics factory = StatisticsFactory.GetFactory(); List <Statistics_Gather> gatherlist = factory.Search_MonthStatistics(paras); if (!string.IsNullOrEmpty(paras.ParkingID) && gatherlist != null && gatherlist.Count > 0) { BaseParkinfo parkinfo = ParkingServices.QueryParkingByParkingID(paras.ParkingID); if (parkinfo != null) { foreach (var v in gatherlist) { v.ParkingName = parkinfo.PKName; } } } return(gatherlist); }
/// <summary> /// 获得临停缴费记录 /// </summary> /// <param name="paras">输入参数</param> /// <param name="PageSize">每页显示数</param> /// <param name="PageIndex">当前页</param> /// <returns></returns> public static Pagination Search_MonthStatistics(InParams paras, int PageSize, int PageIndex) { Pagination _pagination = new Pagination(); IStatistics factory = StatisticsFactory.GetFactory(); _pagination.Total = factory.Search_MonthStatisticsCount(paras); _pagination.StatisticsGatherList = factory.Search_MonthStatistics(paras, PageSize, PageIndex); if (!string.IsNullOrEmpty(paras.ParkingID) && _pagination.StatisticsGatherList != null && _pagination.StatisticsGatherList.Count > 0) { BaseParkinfo parkinfo = ParkingServices.QueryParkingByParkingID(paras.ParkingID); if (parkinfo != null) { foreach (var v in _pagination.StatisticsGatherList) { v.ParkingName = parkinfo.PKName; } } } return(_pagination); }
/// <summary> /// 获得临停缴费记录 /// </summary> /// <param name="paras">输入参数</param> /// <returns></returns> public static List <MonthCardInfoModel> Search_MonthCardInfo(InParams paras) { IStatistics factory = StatisticsFactory.GetFactory(); List <MonthCardInfoModel> gatherlist = factory.Search_MonthCardInfo(paras); if (gatherlist != null && gatherlist.Count > 0) { foreach (var m in gatherlist) { if (m.StartTime > DateTime.MinValue) { m.strStartTime = m.StartTime.ToString("yyyy-MM-dd HH:mm:ss"); } if (m.EndTime > DateTime.MinValue) { m.strEndTime = m.EndTime.ToString("yyyy-MM-dd HH:mm:ss"); } } } return(gatherlist); }
public ItemTemplate AddBaseStat(StatisticsTypes type, double Value, double perLevelChange, bool isPercentage) { var statFactory = new StatisticsFactory(); if (BaseStats == null) { BaseStats = new List <Statistics>(); } if (!BaseStats.ContainsType(type)) { if (isPercentage) { BaseStats.Add(statFactory.CreateStatPercent(Value, perLevelChange, type)); } else { BaseStats.Add(statFactory.CreateStatFlat(Value, perLevelChange, type)); } } return(this); }
/// <summary> /// 车场收入分析 /// </summary> /// <param name="ParkingID">车场编号</param> /// <returns></returns> public static InComeResult Analysis_InCome(string ParkingID) { InComeResult incomeresult = new InComeResult(); IStatistics factory = StatisticsFactory.GetFactory(); DateTime dtNow = DateTime.Now; DateTime StartTime = DateTime.Parse(dtNow.ToString("yyyy-MM-01 00:00:00")).AddMonths(-11); DateTime EndTime = DateTime.Parse(dtNow.ToString("yyyy-MM-dd 23:59:59")); #region 近12个月的统计数据 List <string> templist = new List <string>(); templist.Add(ParkingID); List <Statistics_Gather> gatherlist = factory.GetStatisticsGroupByMonth(templist, StartTime, EndTime); if (gatherlist != null && gatherlist.Count > 0) { if (gatherlist.Count < 12) { for (int i = 0; i < 12; i++) { var isexists = gatherlist.Find(u => u.KeyName == dtNow.AddMonths(-i).ToString("yyyy-MM")); if (isexists == null) { gatherlist.Add(new Statistics_Gather { KeyName = dtNow.AddMonths(-i).ToString("yyyy-MM"), GatherTime = dtNow.Date.AddMonths(-i) }); } } } } else { gatherlist = new List <Statistics_Gather>(); for (int i = 0; i < 12; i++) { gatherlist.Add(new Statistics_Gather { KeyName = dtNow.AddMonths(-i).ToString("yyyy-MM"), GatherTime = dtNow.Date.AddMonths(-i) }); } } #endregion incomeresult.GatherMonth12 = gatherlist; #region 环比数据 var mom1 = gatherlist.Find(u => u.KeyName == dtNow.ToString("yyyy-MM")); if (mom1 != null) { incomeresult.MOM.Add(mom1); } else { incomeresult.MOM.Add(new Statistics_Gather { KeyName = dtNow.ToString("yyyy-MM"), GatherTime = dtNow.Date }); } var mom2 = gatherlist.Find(u => u.KeyName == dtNow.AddMonths(-1).ToString("yyyy-MM")); if (mom2 != null) { incomeresult.MOM.Add(mom2); } else { incomeresult.MOM.Add(new Statistics_Gather { KeyName = dtNow.AddMonths(-1).ToString("yyyy-MM"), GatherTime = dtNow.Date.AddMonths(-1) }); } #endregion #region 比数据 var yoy1 = gatherlist.Find(u => u.KeyName == dtNow.ToString("yyyy-MM")); if (yoy1 != null) { incomeresult.YOY.Add(yoy1); } else { incomeresult.YOY.Add(new Statistics_Gather { KeyName = dtNow.ToString("yyyy-MM"), GatherTime = dtNow.Date }); } StartTime = DateTime.Parse(dtNow.Date.AddYears(-1).ToString("yyyy-MM-01 00:00:00")); EndTime = StartTime.AddSeconds(-1).AddMonths(1); //获取去年同月的统计数据 List <Statistics_Gather> yoygather = factory.GetStatisticsGroupByMonth(templist, StartTime, EndTime); if (yoygather != null && yoygather.Count == 1) { incomeresult.YOY.Add(yoygather[0]); } else { incomeresult.YOY.Add(new Statistics_Gather { KeyName = dtNow.Date.AddYears(-1).AddHours(1).AddSeconds(-1).ToString("yyyy-MM"), GatherTime = dtNow.Date }); } #endregion return(incomeresult); }
/// <summary> /// 进出分析 /// </summary> /// <param name="ParkingID">车场编号</param> /// <returns></returns> public static InOutResult Analysis_InOut(string ParkingID) { InOutResult inoutmodel = new InOutResult(); IStatistics factory = StatisticsFactory.GetFactory(); DateTime dtNow = DateTime.Now; DateTime StartTime = DateTime.Parse(dtNow.AddDays(-14).ToString("yyyy-MM-dd 00:00:00")); DateTime EndTime = DateTime.Parse(dtNow.ToString("yyyy-MM-dd 23:59:59")); List <string> parkings = new List <string>(); parkings.Add(ParkingID); List <Statistics_Gather> _gatherday15 = factory.GetStatisticsGroupByDay(parkings, StartTime, EndTime); for (int i = 0; i < 10; i++) { string temp = DateTime.Now.AddDays(-(i + 1)).ToString("yyyy-MM-dd"); if (!_gatherday15.Select(u => u.KeyName).Contains(temp)) { _gatherday15.Add(new Statistics_Gather { KeyName = temp, Entrance_Count = 0, Cash_Amount = 0, Real_Amount = 0, OnLine_Amount = 0, Receivable_Amount = 0 }); } } if (_gatherday15 != null && _gatherday15.Count > 0) { for (int i = 0; i < 15; i++) { var v = _gatherday15.Find(u => u.KeyName == dtNow.AddDays(-i).ToString("yyyy-MM-dd")); if (v == null) { _gatherday15.Add(new Statistics_Gather { KeyName = dtNow.AddDays(-i).ToString("yyyy-MM-dd"), GatherTime = dtNow.AddDays(-i) }); } } _gatherday15 = _gatherday15.OrderBy(u => u.GatherTime).ToList(); foreach (Statistics_Gather g in _gatherday15) { g.KeyName = g.KeyName.Split('-')[1] + "月" + g.KeyName.Split('-')[2] + "日"; } } //进出高峰 StartTime = DateTime.Parse(dtNow.ToString("yyyy-MM-dd 00:00:00")); inoutmodel.InOutPeak = factory.Search_InOutPeak(ParkingID, StartTime, EndTime); //30天进场数 inoutmodel.DailyTemp = _gatherday15.OrderByDescending(u => u.KeyName).ToList(); //近10个月的入场数据 StartTime = DateTime.Parse(dtNow.AddMonths(-9).ToString("yyyy-MM-01 00:00:00")); List <string> templist = new List <string>(); templist.Add(ParkingID); List <Statistics_Gather> sg = factory.GetStatisticsGroupByMonth(templist, StartTime, EndTime); if (sg != null) { if (sg.Count < 10) { for (int i = 0; i < 10; i++) { var v = sg.Find(u => u.KeyName == dtNow.AddMonths(-i).ToString("yyyy-MM")); if (v == null) { sg.Add(new Statistics_Gather { KeyName = DateTime.Parse(dtNow.ToString("yyyy-MM")).AddMonths(-i).ToString("yyyy-MM"), GatherTime = DateTime.Parse(dtNow.ToString("yyyy-MM-01")).AddMonths(-i) }); } } } } else { for (int i = 0; i < 10; i++) { sg.Add(new Statistics_Gather { KeyName = DateTime.Parse(dtNow.ToString("yyyy-MM")).AddMonths(-i).ToString("yyyy-MM"), GatherTime = DateTime.Parse(dtNow.ToString("yyyy-MM-01")).AddMonths(-i) }); } } inoutmodel.MonthTemp = sg.OrderByDescending(u => u.KeyName).ToList(); //近30天的放行数据 decimal sumnormal = _gatherday15.Select(u => u.ReleaseType_Normal).Sum(); decimal sumcatch = _gatherday15.Select(u => u.ReleaseType_Catch).Sum(); decimal sumfree = _gatherday15.Select(u => u.ReleaseType_Free).Sum(); decimal sumcharge = _gatherday15.Select(u => u.ReleaseType_Charge).Sum(); decimal releasetypesum = sumnormal + sumcatch + sumfree + sumcharge; if (releasetypesum > 0) { inoutmodel.ReleaseType.Add(new KeyValue { KeyName = "正常放行", KeyValue1 = sumnormal, KeyValue2 = Math.Round(sumnormal * 100 / (sumnormal + sumcatch + sumfree + sumcharge), 2) }); inoutmodel.ReleaseType.Add(new KeyValue { KeyName = "免费放行", KeyValue1 = sumfree, KeyValue2 = Math.Round(sumfree * 100 / (sumnormal + sumcatch + sumfree + sumcharge), 2) }); inoutmodel.ReleaseType.Add(new KeyValue { KeyName = "收费放行", KeyValue1 = sumcharge, KeyValue2 = Math.Round(sumcharge * 100 / (sumnormal + sumcatch + sumfree + sumcharge), 2) }); inoutmodel.ReleaseType.Add(new KeyValue { KeyName = "异常放行", KeyValue1 = sumcatch, KeyValue2 = Math.Round(sumcatch * 100 / (sumnormal + sumcatch + sumfree + sumcharge), 2) }); } else { inoutmodel.ReleaseType.Add(new KeyValue { KeyName = "正常放行", KeyValue1 = sumnormal, KeyValue2 = 100 }); inoutmodel.ReleaseType.Add(new KeyValue { KeyName = "免费放行", KeyValue1 = sumfree, KeyValue2 = 0 }); inoutmodel.ReleaseType.Add(new KeyValue { KeyName = "收费放行", KeyValue1 = sumcharge, KeyValue2 = 0 }); inoutmodel.ReleaseType.Add(new KeyValue { KeyName = "异常放行", KeyValue1 = sumcatch, KeyValue2 = 0 }); } //近30天的停车类型 int vipcard = _gatherday15.Select(u => u.VIPCard).Sum(); int stordcard = _gatherday15.Select(u => u.StordCard).Sum(); int monthcard = _gatherday15.Select(u => u.MonthCard).Sum(); int jobcard = _gatherday15.Select(u => u.JobCard).Sum(); int tempcard = _gatherday15.Select(u => u.TempCard).Sum(); int sum = _gatherday15.Select(u => u.VIPCard).Sum() + _gatherday15.Select(u => u.StordCard).Sum() + _gatherday15.Select(u => u.MonthCard).Sum() + _gatherday15.Select(u => u.JobCard).Sum() + _gatherday15.Select(u => u.TempCard).Sum(); if (sum > 0) { inoutmodel.CardType.Add(new KeyValue { KeyName = "贵宾卡", Key_Value = vipcard, KeyValue2 = Math.Round(System.Convert.ToDecimal(vipcard * 1.0 * 100 / sum), 2) }); inoutmodel.CardType.Add(new KeyValue { KeyName = "储值卡", Key_Value = stordcard, KeyValue2 = Math.Round(System.Convert.ToDecimal(stordcard * 1.0 * 100 / sum), 2) }); inoutmodel.CardType.Add(new KeyValue { KeyName = "月卡", Key_Value = monthcard, KeyValue2 = Math.Round(System.Convert.ToDecimal(monthcard * 1.0 * 100 / sum), 2) }); inoutmodel.CardType.Add(new KeyValue { KeyName = "临时卡", Key_Value = tempcard, KeyValue2 = Math.Round(System.Convert.ToDecimal(tempcard * 1.0 * 100 / sum), 2) }); inoutmodel.CardType.Add(new KeyValue { KeyName = "工作卡", Key_Value = jobcard, KeyValue2 = Math.Round(System.Convert.ToDecimal(jobcard * 1.0 * 100 / sum), 2) }); } else { inoutmodel.CardType.Add(new KeyValue { KeyName = "贵宾卡", Key_Value = 0, KeyValue2 = 0 }); inoutmodel.CardType.Add(new KeyValue { KeyName = "储值卡", Key_Value = 0, KeyValue2 = 0 }); inoutmodel.CardType.Add(new KeyValue { KeyName = "月卡", Key_Value = 0, KeyValue2 = 0 }); inoutmodel.CardType.Add(new KeyValue { KeyName = "临时卡", Key_Value = 0, KeyValue2 = 0 }); inoutmodel.CardType.Add(new KeyValue { KeyName = "工作卡", Key_Value = 0, KeyValue2 = 100 }); } return(inoutmodel); }
public static List <ParkEvent> Search_Event(DateTime timedate) { IStatistics factory = StatisticsFactory.GetFactory(); return(factory.Search_Event(timedate)); }