private void clearRouteModel(ExeRouteGroupModel routeGroupModel) { if (routeGroupModel.Listperiod != null) { foreach (List <DateTime> o in routeGroupModel.Listperiod) { o.Clear(); } routeGroupModel.Listperiod.Clear(); } foreach (RouteMap o in routeGroupModel.RouteMaps) { foreach (var p in o.Routes) { foreach (MarkAssist q in p.RouteAssistMarks) { this.Clear(q); } } foreach (var r in o.Marks) { this.Clear(r); } } routeGroupModel.RouteMaps.Clear(); routeGroupModel.Name = null; }
public ExeRouteGroupModel GetGroupModelN(string name, FArrayList fa, FDateTime dt) { var exeRouteGroup = new ExeRouteGroupModel(); exeRouteGroup.Name = name; if (fa.Count == 0) { return(exeRouteGroup); } var dict = (Dictionary <string, Dictionary <string, List <TransSrvSplitOrderDTO> > >)fa[0]; var tranlist = (List <TransSrvSplitOrderDTO>)fa[1]; foreach (TransSrvSplitOrderDTO transSrvSplitOrderDto in tranlist) { var routeMap = new RouteMap(); routeMap.StartDay = dt; Dictionary <string, List <TransSrvSplitOrderDTO> > dic = dict[transSrvSplitOrderDto.Id_srv]; List <TransSrvSplitOrderDTO> a = dic[dic.Keys.First()]; routeMap.Name = a[0].Name_srv; var listperiod = new List <List <DateTime> >(); foreach (string keys in dic.Keys) { List <TransSrvSplitOrderDTO> list = dic[keys]; if (!list[0].Fg_long.Value) //list.Count == 1 { if (list[0].Dt_mp_plan == null) { continue; } var mark = new RouteMark(); mark.StartTime = dt; mark.Time = (DateTime)list[0].Dt_mp_plan; mark.IdOr = list[0].Id_or; mark.Id = list[0].Id_or + "_" + list[0].Dt_mp_plan; if (list[0].Orsrv_su_mp == "0") { mark.ExeStatus = ExeStatuses.Pending; } else if (list[0].Orsrv_su_mp == "1") { mark.ExeStatus = ExeStatuses.Executing; } if (list[0].Orsrv_su_mp == "2") { mark.ExeStatus = ExeStatuses.NoEecution; } if (list[0].Orsrv_su_mp == "4") { mark.ExeStatus = ExeStatuses.Executed; } mark.IsLongTerm = false; routeMap.Marks.Add(mark); } else if (list[0].Fg_long.Value) //list.Count > 1 { var listd = new List <DateTime>(); IOrderedEnumerable <TransSrvSplitOrderDTO> ff = list.OrderBy(item => item.Dt_mp_plan); TransSrvSplitOrderDTO[] srv = ff.ToArray(); if (srv.Count() > 1) { DateTime?ps = getbounddt((DateTime)srv[0].Dt_mp_plan, true); DateTime?pe = getbounddt((DateTime)srv[srv.Count() - 1].Dt_mp_plan, false); if (ps != null && pe != null) { listd.Add((DateTime)ps); listd.Add((DateTime)pe); convetdatePeriod(listperiod, listd); } } var RouteAssistMarks = new List <MarkAssist>(); foreach (TransSrvSplitOrderDTO splitsrvDto in srv) { var mark = new MarkAssist(); if (splitsrvDto.Orsrv_su_mp == "0") { mark.ExeStatus = ExeStatuses.Pending; } else if (splitsrvDto.Orsrv_su_mp == "1") { mark.ExeStatus = ExeStatuses.Executing; } if (splitsrvDto.Orsrv_su_mp == "2") { mark.ExeStatus = ExeStatuses.NoEecution; } if (splitsrvDto.Orsrv_su_mp == "4") { mark.ExeStatus = ExeStatuses.Executed; } mark.IdOr = splitsrvDto.Id_or; mark.Id = splitsrvDto.Id_or + "_" + splitsrvDto.Dt_mp_plan; mark.Time = (DateTime)splitsrvDto.Dt_mp_plan; mark.IsLongTerm = true; if (splitsrvDto.Dt_mp_plan.ToString().Equals(srv[srv.Count() - 1].Dt_mp_plan.ToString())) { //mark. mark.IsEndRourkMark = true; } else { mark.IsEndRourkMark = false; } RouteAssistMarks.Add(mark); } var num = (int)srv[0].Freqcnt; var route = new Route { DailySlot = 6, DailyTimes = num, StartTime = (DateTime)srv[0].Dt_mp_plan, EndTime = (DateTime)srv[srv.Count() - 1].Dt_mp_plan }; route.AcStartDateTime = (DateTime)srv[0].Dt_mp_plan; route.RouteAssistMarks = RouteAssistMarks; routeMap.Routes.Add(route); } } if (routeMap.Marks.Count() == 0 && routeMap.Routes.Count() == 0) { continue; } routeMap.Listperiod = listperiod; exeRouteGroup.RouteMaps.Add(routeMap); } return(exeRouteGroup); }