Пример #1
0
        public void CalculateWeight(string term)
        {
            if (string.IsNullOrWhiteSpace(term))
            {
                return;
            }

            var sourceArray = term.Split(new char[] { ' ' });

            foreach (var text in sourceArray)
            {
                if (string.IsNullOrWhiteSpace(text))
                {
                    continue;
                }

                if (Name.IsMatch(text))
                {
                    SumWeight += WeightList.Where(w => w.Name == "name").Select(w => w.W).FirstOrDefault();
                }

                if (Type.IsMatch(text))
                {
                    SumWeight += WeightList.Where(w => w.Name == "type").Select(w => w.W).FirstOrDefault();
                }

                if (SerialNumber.IsMatch(text))
                {
                    SumWeight += WeightList.Where(w => w.Name == "serialNumber").Select(w => w.W).FirstOrDefault();
                }

                if (Floor.IsMatch(text))
                {
                    SumWeight += WeightList.Where(w => w.Name == "floor").Select(w => w.W).FirstOrDefault();
                }

                if (RoomNumber.IsMatch(text))
                {
                    SumWeight += WeightList.Where(w => w.Name == "roomNumber").Select(w => w.W).FirstOrDefault();
                }

                if (Description.IsMatch(text))
                {
                    SumWeight += WeightList.Where(w => w.Name == "description").Select(w => w.W).FirstOrDefault();
                }
            }
        }
Пример #2
0
        public void CalculateWeight(string term, IEnumerable <Lock> locks)
        {
            LockCount = locks.Count(l => l.BuildingId.Equals(Id));

            if (string.IsNullOrWhiteSpace(term))
            {
                return;
            }

            var sourceArray = term.Split(new char[] { ' ' });

            foreach (var text in sourceArray)
            {
                if (string.IsNullOrWhiteSpace(text))
                {
                    continue;
                }

                if (Name.IsMatch(text))
                {
                    SumWeight += WeightList.Where(w => w.Name == "name").Select(w => w.W).FirstOrDefault();
                    if (LockCount > 0)
                    {
                        SumWeight += WeightList.Where(w => w.Name == "name").Select(w => w.WT).FirstOrDefault();
                    }
                }

                if (ShortCut.IsMatch(text))
                {
                    SumWeight += WeightList.Where(w => w.Name == "shortCut").Select(w => w.W).FirstOrDefault();
                    if (LockCount > 0)
                    {
                        SumWeight += WeightList.Where(w => w.Name == "shortCut").Select(w => w.WT).FirstOrDefault();
                    }
                }

                if (Description.IsMatch(text))
                {
                    SumWeight += WeightList.Where(w => w.Name == "description").Select(w => w.W).FirstOrDefault();
                    if (LockCount > 0)
                    {
                        SumWeight += WeightList.Where(w => w.Name == "description").Select(w => w.WT).FirstOrDefault();
                    }
                }
            }
        }