Пример #1
0
 private List<ChangeCusWithOMViewModel> GetVehGroupTree(string tenantCode, ulong parentID, IList<EMVehicleGroup> ltVehGroups)
 {
     List<ChangeCusWithOMViewModel> list = new List<ChangeCusWithOMViewModel>();
     var res = ltVehGroups.Where(p => p.TenantCode == tenantCode && p.ParentGroupID == parentID);
     if (res.Count() > 0)
     {
         foreach (var item in res)
         {
             ChangeCusWithOMViewModel vm = new ChangeCusWithOMViewModel
             {
                 IsVehGroup = true,
                 IsLastCreated = false,
                 IsOM = false,
                 TenantCode = tenantCode,
                 GroupID = item.GroupID.ToString(),
                 TenantName = item.GroupName,
                 OperatorLevel = null,
                 Children = new List<ChangeCusWithOMViewModel>(),
                 VehicleCount = 0,
                 VehicleOnlineNum = 0,
                 iconSkin = "gIcon"
             };
             List<ChangeCusWithOMViewModel> ltChildren = GetVehGroupTree(tenantCode, item.GroupID, ltVehGroups);
             if (!ltChildren.IsNullOrEmpty())
             {
                 vm.Children.AddRange(ltChildren);
             }
             list.Add(vm);
         }
     }
     return list;
 }
Пример #2
0
 private List<ChangeCusWithOMViewModel> ConvertToCusWithOmVM(IList<EMTenant> OMList, IList<EMTenant> CusList, Dictionary<string, int> dicVehicleCount, string LastCreatedTenantCode)
 {
     List<ChangeCusWithOMViewModel> list = new List<ChangeCusWithOMViewModel>();
     foreach (EMTenant om in OMList)
     {
         ChangeCusWithOMViewModel CusWithOMViewModel = new ChangeCusWithOMViewModel();
         CusWithOMViewModel.TenantCode = om.TenantCode;
         CusWithOMViewModel.TenantName = om.TenantName;
         CusWithOMViewModel.Children = new List<ChangeCusWithOMViewModel>();
         IList<EMTenant> CusOfOmList = CusList.Where(o => o.SuperTenantID == om.TenantCode).ToList();
         if(CusOfOmList == null || CusOfOmList.Count==0)
             continue;
         foreach (EMTenant cus in CusOfOmList)
         {
             ChangeCusWithOMViewModel viewModel = new ChangeCusWithOMViewModel()
             {
                 TenantCode = cus.TenantCode,
                 TenantName = cus.TenantName,
                 RegisterUserCode = cus.RegisterUserCode,
                 VehicleCount = dicVehicleCount.ContainsKey(cus.TenantCode) ? dicVehicleCount[cus.TenantCode] : 0
             };
             if (viewModel.TenantCode == LastCreatedTenantCode)
                 viewModel.TenantCode = "#LastCreated#" + LastCreatedTenantCode;
             CusWithOMViewModel.Children.Add(viewModel);
         }
         CusWithOMViewModel.Children = CusWithOMViewModel.Children.OrderBy(o => o.TenantName).ToList();
         list.Add(CusWithOMViewModel);
     }
     list = list.OrderBy(o => o.TenantName).ToList();
     return list;
 }
Пример #3
0
        private IList<ChangeCusWithOMViewModel> GetChildren(string tenantCode, string lastCreateTenantCode,
            IList<EMTenant> ltTenantAll, Dictionary<string, int> dicVehicleCount, IList<EMVehicleGroup> ltVehGroups)
        {
            List<ChangeCusWithOMViewModel> list = new List<ChangeCusWithOMViewModel>();
            var subTenants = ltTenantAll.Where(s=>s.SuperTenantID == tenantCode);
            foreach (EMTenant tenant in subTenants)
            {
                ChangeCusWithOMViewModel vm = new ChangeCusWithOMViewModel
                {
                    IsLastCreated = false,
                    IsOM = tenant.TenantType == EnumTenantType.OperatingMerchant,
                    TenantCode = tenant.TenantCode,
                    TenantName = tenant.TenantName,
                    OperatorLevel = tenant.OperatorLevel,
                    Children = new List<ChangeCusWithOMViewModel>(),
                    RegisterUserCode = tenant.RegisterUserCode,
                    VehicleCount = 0,
                    VehicleOnlineNum = 0
                };
                if (!vm.IsOM) //不是运营商
                {
                    vm.iconSkin = "icon";
                    vm.IsLastCreated = lastCreateTenantCode == tenant.TenantCode;
                    if (dicVehicleCount != null && dicVehicleCount.ContainsKey(vm.TenantCode))
                    {
                        vm.TenantName = string.Format("{0}({1})", vm.TenantName, dicVehicleCount[vm.TenantCode]);
                        vm.VehicleCount = dicVehicleCount[vm.TenantCode];
                    }
                    else
                    {
                        vm.TenantName = string.Format("{0}(0)", vm.TenantName);
                    }
                    /*
                    if (!ltVehGroups.IsNullOrEmpty())
                    {//处理终端用户的车辆组树形结构
                        var endCusRootVehGroups = ltVehGroups.Where(p => p.TenantCode == tenant.TenantCode && p.ParentGroupID.HasValue == false);
                        if (endCusRootVehGroups.Count() > 0)
                        {
                            foreach (var item in endCusRootVehGroups)
                            {
                                vm.Children.Add(new ChangeCusWithOMViewModel
                                {
                                    IsVehGroup = true,
                                    IsLastCreated = false,
                                    IsOM = false,
                                    TenantCode = tenant.TenantCode,
                                    GroupID = item.GroupID.ToString(),
                                    TenantName = item.GroupName,
                                    OperatorLevel = null,
                                    Children = GetVehGroupTree(tenant.TenantCode, item.GroupID, ltVehGroups),
                                    VehicleCount = 0,
                                    VehicleOnlineNum = 0,
                                    iconSkin = "gIcon"
                                });
                            }
                        }
                    }*/
                }
                else
                {
                    IList<ChangeCusWithOMViewModel> ltChildren = GetChildren(vm.TenantCode, lastCreateTenantCode, ltTenantAll, dicVehicleCount, ltVehGroups);
                    if (!ltChildren.IsNullOrEmpty())
                    {
                        vm.iconSkin = "pIcon";
                        vm.Children.AddRange(ltChildren);
                    }
                    else
                    {
                        vm.iconSkin = "icon";
                    }
                }
                list.Add(vm);
            }

            return list;
        }
Пример #4
0
 private List<ChangeCusWithOMViewModel> ConvertToCusVM(IList<EMTenant> ltTenant, Dictionary<string, int> dicVehicleCount, string LastCreatedTenantCode)
 {
     List<ChangeCusWithOMViewModel> list = new List<ChangeCusWithOMViewModel>();
     foreach (EMTenant obj in ltTenant)
     {
         ChangeCusWithOMViewModel viewModel = new ChangeCusWithOMViewModel()
         {
             TenantCode = obj.TenantCode,
             TenantName = obj.TenantName,
             RegisterUserCode = obj.RegisterUserCode,
             VehicleCount = dicVehicleCount.ContainsKey(obj.TenantCode) ? dicVehicleCount[obj.TenantCode] : 0
         };
         if (viewModel.TenantCode == LastCreatedTenantCode)
             viewModel.TenantCode = "#LastCreated#" + LastCreatedTenantCode;
         list.Add(viewModel);
     }
     list = list.OrderBy(o => o.TenantName).ToList();
     return list;
 }