Exemplo n.º 1
0
        /// <summary>
        /// 根据订单号查询该订单下的产品绑定关系
        /// </summary>
        /// <param name="orderId"></param>
        /// <returns></returns>
        public List <RelationViewModel> GetRelationSearch(int orderId)
        {
            string sql = $"SELECT u.NickName,s.TelePhone,r.Id as relationFlag,r.UpdateTime as StartTime, DATE_ADD(r.UpdateTime,INTERVAL r.protected_time Day) as endTime from entgoodsorder o LEFT JOIN  entgoodscart car on o.Id=car.GoodsOrderId LEFT JOIN salesmanrecorduser r on r.Id=car.salesManRecordUserId LEFT JOIN salesman s on s.Id=r.salesmanId  LEFT JOIN c_userinfo u on u.Id=car.userId where o.Id={orderId}";

            using (var dr = SqlMySql.ExecuteDataReader(Utility.dbEnum.MINIAPP.ToString(), CommandType.Text, sql))
            {
                List <RelationViewModel> list = new List <RelationViewModel>();
                while (dr.Read())
                {
                    RelationViewModel relationViewModel = new RelationViewModel();

                    relationViewModel.orderUserName       = Convert.ToString(dr["NickName"]);
                    relationViewModel.saleManTelephone    = dr["TelePhone"] == DBNull.Value ? "-" : Convert.ToString(dr["TelePhone"]);
                    relationViewModel.relationFlag        = dr["relationFlag"] == DBNull.Value ? 0 : Convert.ToInt32(dr["relationFlag"]);
                    relationViewModel.relationConnectTime = dr["StartTime"] == DBNull.Value ? "-" : Convert.ToString(dr["StartTime"]);
                    relationViewModel.relationEndTime     = dr["endTime"] == DBNull.Value ? "-" : Convert.ToString(dr["endTime"]);

                    if (relationViewModel.relationEndTime != "-")
                    {
                        if (Convert.ToDateTime(relationViewModel.relationEndTime) > DateTime.Now)
                        {
                            relationViewModel.state = "绑定";
                        }
                    }

                    list.Add(relationViewModel);
                }
                return(list);
            }
        }
Exemplo n.º 2
0
        public JsonResult SearchVehicleRelation(string mdl, int?groupId)
        {
            var model = new RelationViewModel();

            model.VehicleGroups = blVehicleGroup.Where(p => p.Status == "فعال").ToList();
            var vehicles = blVehicle.Where(p => p.Status == "فعال").ToList();

            if (!string.IsNullOrEmpty(mdl))
            {
                vehicles = vehicles.Where(p => p.Model.Contains(mdl.ToFarsiString().Trim())).ToList();
            }
            if (groupId != null)
            {
                vehicles = vehicles.Where(p => p.VehicleGroupId == groupId).ToList();
            }

            model.Vehicles = vehicles;

            return(Json(new JsonData()
            {
                Success = true,
                Script = "",
                Html = this.RenderPartialToString("_VehicleListRelation", model)
            }));
        }
Exemplo n.º 3
0
        public JsonResult SearchUserRelation(string name, int?roleId)
        {
            var model = new RelationViewModel();

            model.Roles = blRole.Where(p => p.Status == "فعال" && p.RoleName != "Admin" && p.RoleName != "HoleBoss").ToList();
            var users = blUser.Where(p => p.Status == "فعال" && p.Role.RoleName != "Admin" && p.Role.RoleName != "HoleBoss").ToList();

            if (!string.IsNullOrEmpty(name))
            {
                users = users.Where(p => p.Name.Contains(name.ToFarsiString().Trim())).ToList();
            }
            if (roleId != null)
            {
                users = users.Where(p => p.RoleId == roleId).ToList();
            }

            model.Users = users;

            return(Json(new JsonData()
            {
                Success = true,
                Script = "",
                Html = this.RenderPartialToString("_UserListRelation", model)
            }));
        }
Exemplo n.º 4
0
        public ActionResult Relation(long?tradeId)
        {
            try
            {
                var model = new RelationViewModel()
                {
                    Relations     = new List <Models.DomainModels.Relation>(),
                    Trades        = blTrade.Where(p => p.Status == "فعال").ToList(),
                    TradeGroups   = blTradeGroup.Where(p => p.Status == "فعال").ToList(),
                    Users         = blUser.Where(p => p.Status == "فعال" && p.Role.RoleName != "Admin" && p.Role.RoleName != "HoleBoss").ToList(),
                    Roles         = blRole.Where(p => p.Status == "فعال" && p.RoleName != "Admin" && p.RoleName != "HoleBoss").ToList(),
                    Vehicles      = blVehicle.Where(p => p.Status == "فعال").ToList(),
                    VehicleGroups = blVehicleGroup.Where(p => p.Status == "فعال").ToList(),
                    Colors        = blColor.Select().ToList(),
                    User          = new User {
                        Gender = true
                    },
                };

                if (tradeId != null)
                {
                    model.Trade     = blTrade.Where(p => p.Id == tradeId).Single();
                    model.Relations = blRelation.Where(p => p.TradeId == tradeId).ToList();
                }

                return(View(model));
            }
            catch
            {
                return(RedirectToAction("Error404", "Home"));
            }
        }
Exemplo n.º 5
0
        public JsonResult SearchTradeRelation(string name, int?groupId)
        {
            var model = new RelationViewModel();

            model.TradeGroups = blTradeGroup.Select().ToList();

            if (!string.IsNullOrEmpty(name.Trim()) && groupId != null)
            {
                string text = name.ToFarsiString().Trim();
                model.Trades = blTrade.Where(p => p.Name.Contains(text) && p.TradeGroupId == groupId && p.Status == "فعال").ToList();
            }
            else if (string.IsNullOrEmpty(name.Trim()) && groupId != null)
            {
                model.Trades = blTrade.Where(p => p.TradeGroupId == groupId && p.Status == "فعال").ToList();
            }
            else if (!string.IsNullOrEmpty(name.Trim()) && groupId == null)
            {
                string text = name.ToFarsiString().Trim();
                model.Trades = blTrade.Where(p => p.Name.Contains(text) && p.Status == "فعال").ToList();
            }
            else
            {
                model.Trades = blTrade.Where(p => p.Status == "فعال").ToList();
            }

            return(Json(new JsonData()
            {
                Success = true,
                Script = "",
                Html = this.RenderPartialToString("_TradeListRelation", model)
            }));
        }
Exemplo n.º 6
0
        public ActionResult Create(RelationViewModel model)
        {
            try
            {
                if (ModelState.IsValid)
                {
                    service.Insert(model);
                    service.Save();
                    return(RedirectToAction("Index"));
                }
                var employees = employeeService.GetEmployeeSelectListItems().Select(x => new {
                    Id   = x.Id,
                    Name = x.LastName + " - " + x.FirstName
                }).ToList();
                ViewBag.Employees = new SelectList(employees, "Id", "Name");

                var employees1 = employeeService.GetEmployeeSelectListItems1().Select(x => new {
                    Id   = x.Id,
                    Name = x.LastName + " - " + x.FirstName
                }).ToList();
                ViewBag.Employees1 = new SelectList(employees, "Id", "Name");
                return(View(model));
            }
            catch
            {
                return(View());
            }
        }
Exemplo n.º 7
0
        public void Delete(RelationViewModel model)
        {
            var item = _repository.FindById(model.Id);

            if (item != null)
            {
                _repository.Delete(item);
            }
        }
Exemplo n.º 8
0
        public OmsGraphViewModel Map(UIModel topologyModel)
        {
            OmsGraphViewModel graph = new OmsGraphViewModel();

            // map nodes
            foreach (KeyValuePair <long, UINode> keyValue in topologyModel.Nodes)
            {
                NodeViewModel graphNode = new NodeViewModel
                {
                    Id             = keyValue.Value.Id.ToString(),
                    Name           = keyValue.Value.Name,
                    Description    = keyValue.Value.Description,
                    Mrid           = keyValue.Value.Mrid,
                    IsActive       = keyValue.Value.IsActive,
                    DMSType        = keyValue.Value.DMSType,
                    IsRemote       = keyValue.Value.IsRemote,
                    NoReclosing    = keyValue.Value.NoReclosing,
                    NominalVoltage = keyValue.Value.NominalVoltage.ToString(),
                    Measurements   = new List <MeasurementViewModel>()
                };

                foreach (var measurement in keyValue.Value.Measurements)
                {
                    graphNode.Measurements.Add(new MeasurementViewModel()
                    {
                        Id        = measurement.Gid.ToString(),
                        Type      = measurement.Type,
                        Value     = measurement.Value,
                        AlarmType = AlarmType.NO_ALARM
                    });
                }

                graph.Nodes.Add(
                    graphNode.DMSType == PowerTransformerDmsTypeName
                    ? graphNode.ToTransformerNode()
                    : graphNode
                    );
            }

            // map relations
            foreach (KeyValuePair <long, HashSet <long> > keyValue in topologyModel.Relations)
            {
                foreach (long targetNodeId in keyValue.Value)
                {
                    RelationViewModel graphRelation = new RelationViewModel
                    {
                        SourceNodeId = keyValue.Key.ToString(),
                        TargetNodeId = targetNodeId.ToString(),
                        IsActive     = topologyModel.Nodes[keyValue.Key].IsActive || topologyModel.Nodes[targetNodeId].IsActive
                    };

                    graph.Relations.Add(graphRelation);
                }
            }

            return(graph.SquashTransformerWindings());
        }
Exemplo n.º 9
0
        public ActionResult Index(Guid?categoryId, string sort, string order)
        {
            HomeViewModel            viewModel = new HomeViewModel();
            var                      relations = relationsRepository.FindRelations(categoryId, sort, order);
            List <RelationViewModel> relVMList = new List <RelationViewModel>();

            viewModel.Relations = relVMList;

            foreach (var relation in relations)
            {
                RelationViewModel relVM = new RelationViewModel()
                {
                    Id              = relation.Id,
                    Name            = relation.Name,
                    FullName        = relation.FullName,
                    Email           = relation.EMailAddress,
                    TelephoneNumber = relation.TelephoneNumber,
                    City            = relation.DefaultCity,
                    Country         = relation.DefaultCountry,
                    PostalCode      = relation.DefaultPostalCode,
                    Street          = relation.DefaultStreet,
                    StreetNumber    = relationsRepository.GetStreetNumberByRelationId(relation.Id),
                    IsDisabled      = relation.IsDisabled
                };
                relVMList.Add(relVM);
            }

            IEnumerable <string> KeywordsForSort = new List <string>()
            {
                "None", "Name", "Full Name", "Telephone Number", "Email", "Country", "City", "Street", "Postal Code", "Street Numder"
            };

            viewModel.KeywordsForSort = new SelectList(KeywordsForSort);

            List <CategoriesForFilter> categoriesForFiter = new List <CategoriesForFilter>();

            categoriesForFiter.Add(new CategoriesForFilter()
            {
                Name = "None", CategoryId = null
            });

            foreach (var category in relationsRepository.GetAllCategories())
            {
                categoriesForFiter.Add(new CategoriesForFilter()
                {
                    CategoryId = category.Id, Name = category.Name
                });
            }

            SelectList categoreisSelectList = new SelectList(categoriesForFiter, "CategoryId", "Name");

            viewModel.CategoriesList = categoreisSelectList;

            return(View(viewModel));
        }
Exemplo n.º 10
0
 public ActionResult Delete(RelationViewModel model)
 {
     try
     {
         service.Delete(model);
         service.Save();
         return(RedirectToAction("Index"));
     }
     catch
     {
         return(View());
     }
 }
Exemplo n.º 11
0
        public void Update(RelationViewModel model)
        {
            var contractType = AutoMapper.Mapper.Map <RelationViewModel, Relation>(model);

            _repository.Update(contractType);
        }
Exemplo n.º 12
0
        public void Insert(RelationViewModel model)
        {
            var contractType = AutoMapper.Mapper.Map <RelationViewModel, Relation>(model);

            _repository.Add(contractType);
        }
Exemplo n.º 13
0
        public async Task <List <RelationViewModel> > GetRelations(RelationshipStatus status, RelationDirection direction = RelationDirection.All)
        {
            List <RelationViewModel> targetList = new List <RelationViewModel>();
            var usr = UserHelpers.UserName();

            Func <UserRelationship, bool> selectorPredicate;

            switch (direction)
            {
            case RelationDirection.All:
                selectorPredicate = r => (r.Issuer.Email == usr || r.Recipient.Email == usr);
                break;

            case RelationDirection.IamIssuer:
                selectorPredicate = r => (r.Issuer.Email == usr);

                break;

            case RelationDirection.IamRecipient:
                selectorPredicate = r => (r.Recipient.Email == usr);

                break;

            default:
                throw new ArgumentOutOfRangeException(nameof(direction), direction, null);
            }

            var usrRelationsTmp = await _db.Relations
                                  .Include(r => r.Issuer)
                                  .Include(r => r.Recipient)
                                  .Select(r => r)
                                  .ToListAsync();

            var usrRelations = usrRelationsTmp.Where(r => selectorPredicate(r) && r.Status == status);
            List <ApplicationUser> distinctids = new List <ApplicationUser>();

            foreach (var usrr in usrRelations)
            {
                if (!distinctids.Contains(usrr.Issuer))
                {
                    distinctids.Add(usrr.Issuer);
                }
                if (!distinctids.Contains(usrr.Recipient))
                {
                    distinctids.Add(usrr.Recipient);
                }
            }

            var friends2 = _db.Users.ToList().Where(r => r.Email != usr && distinctids.Any(p => p.Id == r.Id)).ToList();


            foreach (var f in friends2)
            {
                var vm = new RelationViewModel {
                    UserId = f.Id, FirstName = f.FirstName, UserName = f.Pseudo
                };
                if (status == RelationshipStatus.Pending)
                {
                    //je suis issuer de la demande en attente => je peux la canceler mais pas l'accepter ou la rejeter
                    var relationIssuer = usrRelations.FirstOrDefault(r => r.Issuer.Email == usr && r.Recipient.Id == f.Id);
                    if (relationIssuer != null)
                    {
                        vm.CanCancel         = true;
                        vm.CanAcceptOrReject = false;
                    }


                    //je suis le destinataire de demande, je peux l'accepter, la rejeter mais pas la canceler
                    var relationDest = usrRelations.FirstOrDefault(r => r.Recipient.Email == usr && r.Issuer.Id == f.Id);
                    if (relationDest != null)
                    {
                        vm.CanCancel         = false;
                        vm.CanAcceptOrReject = true;
                    }
                }
                targetList.Add(vm);
            }



            return(targetList);
        }