public async Task LoadAsync()
        {
            try
            {
                //LOAD EQUIPMENTS
                var lookup = await _equipmentLookupDataService.GetEquipmentLookupAsync();

                Equipments.Clear();
                foreach (var item in lookup)
                {
                    Equipments.Add(item);
                }
                //LOAD COMPONENTS
                var components = await _componentDataService.GetComponentLookupAsync();

                Components.Clear();
                foreach (var item in components)
                {
                    Components.Add(item);
                }
            }
            catch (Exception e)
            {
                MessageBox.Show(e.Message, "An error occurred", MessageBoxButton.OK, MessageBoxImage.Warning);
                //create new error object from the exception and add to DB
                Error error = new Error
                {
                    ErrorMessage    = e.Message,
                    ErrorTimeStamp  = DateTime.Now,
                    ErrorStackTrace = e.StackTrace
                };
                await _errorDataService.AddError(error);
            }
        }
Example #2
0
 private void Awake()
 {
     foreach (SlotType slotType in (SlotType[])Enum.GetValues(typeof(SlotType)))
     {
         Equipments.Add(slotType, new Attachment());
     }
 }
        private void OnSearchTextChanged()
        {
            Equipments.Clear();

            if (string.IsNullOrWhiteSpace(searchText))
            {
                foreach (EquipmentViewModel x in rootViewModel.AllEquipments)
                {
                    Equipments.Add(x);
                }
            }
            else
            {
                var searchStatement = SearchStatement.Create(searchText);

                foreach (EquipmentViewModel x in rootViewModel.AllEquipments)
                {
                    bool isVisible = searchStatement.IsMatching(Localization.Get(x.Name)) ||
                                     x.Abilities.Any(a => IsMatching(a, searchStatement));

                    if (isVisible)
                    {
                        Equipments.Add(x);
                    }
                }
            }
        }
Example #4
0
        public void AddComponent()
        {
            var equipment = CreateNewEquipment(Model);

            Equipments.Add(equipment);
            SelectedEquipment = equipment;
        }
Example #5
0
        //LOAD EQUIPMENT LIST
        public async Task LoadEquipmentAsync()
        {
            try
            {
                var lookup = await _equipmentLookupDataService.GetEquipmentLookupAsync();

                Equipments.Clear();
                foreach (var item in lookup)
                {
                    Equipments.Add(item);
                }
                EquipmentView        = CollectionViewSource.GetDefaultView(Equipments);
                EquipmentView.Filter = new Predicate <object>(Filter);
            }
            catch (Exception e)
            {
                MessageBox.Show(e.Message, "An error occurred", MessageBoxButton.OK, MessageBoxImage.Warning);
                //create new error object from the exception and add to DB
                Error error = new Error
                {
                    ErrorMessage    = e.Message,
                    ErrorTimeStamp  = DateTime.Now,
                    ErrorStackTrace = e.StackTrace,
                    LoginId         = CurrentUser.LoginId
                };
                await _errorDataService.AddError(error);
            }
        }
Example #6
0
 public bool AddEquipment(string id)
 {
     if (Equipments.Any(x => x == id))
     {
         return(false);
     }
     Equipments.Add(id);
     return(true);
 }
Example #7
0
 public CHR()
 {
     for (int i = 0; i < 8; i++)
     {
         Equipments.Add(new EquipmentCHR());
         BattleMovieIndexers.Add(new MemoryIndexer());
         //BattleMovies.Add(new MetalXMovie());
     }
 }
Example #8
0
        private void LoadEquipmentForCustomer(int customerId)
        {
            CustomerDto customer = Customers.Where(c => c.CustomerID == customerId).SingleOrDefault();

            Equipments.Clear();
            foreach (var item in customer.EquipmentCollection)
            {
                Equipments.Add(item);
            }
        }
        public async Task LoadEquipment()
        {
            var lookup = await _equipmentLookupDataService.GetEquipmentLookupAsync();

            Equipments.Clear();
            foreach (var item in lookup)
            {
                Equipments.Add(item);
            }
        }
        public EquipmentExplorerViewModel(RootViewModel rootViewModel)
        {
            this.rootViewModel = rootViewModel;

            foreach (EquipmentViewModel equipment in rootViewModel.AllEquipments)
            {
                Equipments.Add(equipment);
            }

            CancelCommand = new AnonymousCommand(OnCancel);
        }
        private void OnAddExecute()
        {
            var wrapper = new EquipmentWrapper(new Equipment());

            wrapper.PropertyChanged += Wrapper_PropertyChanged;
            _equipmentRepository.Add(wrapper.Model);
            Equipments.Add(wrapper);

            //trigger the validation
            wrapper.Name = "";
        }
Example #12
0
        private async void LoadEquipments()
        {
            var equipments = await _restServices.GetEquipments();

            foreach (var equipment in equipments)
            {
                Equipments.Add(equipment);
            }
            IsBusy  = false;
            HasItem = (Equipments.Count > 0) ? true : false;
        }
        private async Task LoadEquipmentsLookupAsync()
        {
            Equipments.Clear();
            //Equipments.Add(new NullLookupItem { DisplayMember = " - " });
            var lookup = await _equipmentLookupDataService.GetEquipmentLookupAsync();

            foreach (var lookupItem in lookup)
            {
                Equipments.Add(lookupItem);
            }
        }
        public override void AddReference(ModelCode referenceId, long globalId)
        {
            switch (referenceId)
            {
            case ModelCode.EQUIPMENT_EQUIPCONTAINER:
                Equipments.Add(globalId);
                break;

            default:
                base.AddReference(referenceId, globalId);
                break;
            }
        }
Example #15
0
        public ViewModel()
        {
            foreach (var info in Info.Instance().Party)
            {
                Party.Add(new Character(0x5616 + info.Value * 148)
                {
                    Info = info
                });
            }

            for (uint i = 0; i < 256; i++)
            {
                Items.Add(new Item(0x3F14 + i * 2, 0x4114 + i));
            }

            foreach (var info in Info.Instance().KeyItems)
            {
                KeyItems.Add(new BitValue(0x44D4, info));
            }

            for (uint i = 0; i < 200; i++)
            {
                Equipments.Add(new Equipment(0x44EA + i * 22));
            }

            foreach (var info in Info.Instance().Blitz_Player)
            {
                if (info.Value >= 60)
                {
                    continue;
                }
                Blitz.Add(new BlitzBall(0x1234, info));
            }
            for (uint i = 0; i < 8; i++)
            {
                Blitz_Term.Add(new IntValue(0x1676 + i, 1));
            }

            foreach (var info in Info.Instance().Monsters)
            {
                Monsters.Add(new IntValue(0x4254 + info.Value, 1)
                {
                    Info = info
                });
            }

            for (uint i = 0; i < 6; i++)
            {
                FavorabilityRatings.Add(new IntValue(0x78 + i * 4, 4));
            }
        }
Example #16
0
        public void Equipments_Valid_NonEmpty()
        {
            Equipments equipments = new Equipments();

            Mock <Equipment> equipment = GetMockEquipment();

            equipment.Setup(s => s.IsValid(ref It.Ref <ValidationCode> .IsAny)).Returns(true);

            equipments.Add(equipment.Object);

            ValidationCode errorCode = ValidationCode.SUCCESS;

            // need to suppress the type check because moq uses a different type
            Assert.IsTrue(equipments.IsValidRecordSet(ref errorCode, suppressTypeCheck: true));
        }
Example #17
0
        private async void searchEquipment(object obj)
        {
            var searchText = obj as string;

            var equipments = (string.IsNullOrWhiteSpace(searchText) ? await _restServices.GetEquipments() :
                              await _restServices.SearchEquipment(searchText));

            Equipments.Clear();
            foreach (var equipment in equipments)
            {
                Equipments.Add(equipment);
            }
            IsBusy  = false;
            HasItem = (Equipments.Count > 0) ? true : false;
        }
        void AddEquipmentFromJSON(JToken equip)
        {
            Equipment e = new Equipment();

            e.LoadFromJSON(equip);

            if (equip.SelectToken("flavorText") != null)
            {
                e.Flavor = equip.SelectToken("flavorText").ToObject <string>();
            }

            e.Description = ExtractAbilitiesAndConditions(e.Description, ref e.DescriptionAbilities, ref e.DescriptionConditions);

            Equipments.Add(e.ID, e);
        }
Example #19
0
        public void Equipments_Invalid_BadType()
        {
            Equipments equipments = new Equipments();

            Mock <Equipment> equipment = GetMockEquipment();

            equipment.Setup(s => s.IsValid(ref It.Ref <ValidationCode> .IsAny)).Returns(true);

            equipments.Add(equipment.Object);

            ValidationCode errorCode = ValidationCode.SUCCESS;

            // do not suppress type check. Since moq uses a different type anyway,
            // there is no need to test with a different IRecord type
            Assert.IsFalse(equipments.IsValidRecordSet(ref errorCode, suppressTypeCheck: false));
        }
Example #20
0
        public EquipmentViewModel(IEquipmentService equipmentService = null)
        {
            _equipmentService = equipmentService ?? (IEquipmentService)Locator.Current.GetService(typeof(IEquipmentService));



            this.WhenAnyValue(vm => vm.Name)
            .Throttle(TimeSpan.FromSeconds(1))
            .Subscribe(name =>
            {
                if (name != "")
                {
                    Search(Name, Status, Type);
                }
                else
                {
                    GetAllEquipment();
                }
            });

            MessagingCenter.Subscribe <Equipment>(this, "NewEquipment", (item) =>
            {
                //var newItem = item as Equipment;
                Equipments.Add(item);
                //_equipmentService.Add(item);
            });

            MessagingCenter.Subscribe <Equipment>(this, "EditEquipment", (item) =>
            {
                var index                  = Equipments.ToList().FindIndex(c => c.Id == item.Id);
                Equipments[index].Id       = item.Id;
                Equipments[index].Name     = item.Name;
                Equipments[index].Type     = item.Type;
                Equipments[index].TypeName = item.TypeName;
                Equipments[index].Quantity = item.Quantity;
            });


            //this.WhenAnyValue(vm => vm.Type).Subscribe(type =>
            //{
            //    Search(Name, Status, Type);
            //});
            //this.WhenAnyValue(vm => vm.Status).Subscribe(status =>
            //{
            //    Search(Name, Status, Type);
            //});
        }
Example #21
0
        public Charactor(uint address)
        {
            mAddress = address;

            for (uint i = 0; i < 8; i++)
            {
                Skills.Add(new Skill(address, i));
            }
            for (uint i = 0; i < 7; i++)
            {
                Equipments.Add(new Value(41 + i, 1));
            }
            for (uint i = 0; i < 8; i++)
            {
                Arts.Add(new Value(33 + i, 1));
            }
        }
        public async override Task LoadAsync(int id)
        {
            Id = id;
            foreach (var wrapper in Equipments)
            {
                wrapper.PropertyChanged -= Wrapper_PropertyChanged;
            }

            Equipments.Clear();
            var equipments = await _equipmentRepository.GetAllAsync();

            foreach (var model in equipments)
            {
                var wrapper = new EquipmentWrapper(model);
                wrapper.PropertyChanged += Wrapper_PropertyChanged;
                Equipments.Add(wrapper);
            }
        }
Example #23
0
        private async Task ExecuteLoadItemsCommand()
        {
            IsBusy = true;

            try
            {
                Equipments.Clear();
                var items = await DataStore.GetItemsAsync(true);

                foreach (var item in items)
                {
                    Equipments.Add(item);
                }
            }
            catch (Exception ex)
            {
                Debug.WriteLine(ex);
            }
            finally
            {
                IsBusy = false;
            }
        }
Example #24
0
 public void AddEquipment(IModuleEquipment equipment)
 {
     equipment.AssociatedModule = this;
     Equipments.Add(equipment);
 }
Example #25
0
 public void AddEquipment(IEquipment equipment)
 {
     Equipments.Add(equipment);
 }
Example #26
0
 public void OnPostInsert()
 {
     EquipmentRepository.Insert(Equipment);
     Equipments.Add(Equipment);
 }
Example #27
0
 public void Equip(Equipment equipment)
 {
     Equipments.Add(equipment);
 }
Example #28
0
        /// <summary>
        /// Создать новый экземпляр класса и запустить процесс считывания данных из input.xml
        /// </summary>
        internal XmlBuilder()
        {
            string    path = Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), "input.xml");
            XDocument xdoc = XDocument.Load(path);

            //Метод планирования
            if (xdoc.Root.Element("pa")?.Value != null && xdoc.Root.Element("pa")?.Value == "mlq")
            {
                PlainType = PlainType.MLQ;
            }

            //Время кванта
            if (int.TryParse(xdoc.Root.Element("qt")?.Value, out int qt))
            {
                if (qt > 0)
                {
                    QuantTime = qt;
                }
            }

            //Максимальное время CPU burst
            if (int.TryParse(xdoc.Root.Element("maxt")?.Value, out int maxt))
            {
                if (maxt > 0)
                {
                    MaxCpuBurst = maxt;
                }
            }

            //Максимальный приоритет потока
            if (int.TryParse(xdoc.Root.Element("maxp")?.Value, out int maxp))
            {
                if (maxp > 0)
                {
                    MaxThreadPriority = maxp;
                }
            }

            //Количество преподавателей
            if (int.TryParse(xdoc.Root.Element("nt")?.Value, out int nt))
            {
                if (nt > 0)
                {
                    TeachersCount = nt;
                }
            }

            //Количество студентов у которых преподаватель может принимать зачет одновременно
            if (int.TryParse(xdoc.Root.Element("tmax")?.Value, out int tmax))
            {
                if (nt > 0)
                {
                    MaxStudentsCountForOneTeacher = tmax;
                }
            }

            //Список преподавателей
            var t = xdoc.Root.Element("teachers")?.Elements("teacher");

            if (t == null || t.Count() == 0)
            {
                Teachers = DataGenerator.GetTeachers(TeachersCount, MaxStudentsCountForOneTeacher).ToList();
            }
            else
            {
                for (int i = 0; i < TeachersCount; i++)
                {
                    if (t.ElementAtOrDefault(i) != null)
                    {
                        string lname     = t.ElementAt(i).Attribute("lname")?.Value ?? DataGenerator.GetRngLastName();
                        string fname     = t.ElementAt(i).Attribute("fname")?.Value ?? DataGenerator.GetRngFirstName();
                        string patr      = t.ElementAt(i).Attribute("patr")?.Value ?? DataGenerator.GetRngPatronymic();
                        int    studCount = MaxStudentsCountForOneTeacher;

                        if (int.TryParse(t.ElementAt(i).Attribute("stud")?.Value, out int stud))
                        {
                            if (stud > 0)
                            {
                                studCount = stud;
                            }
                        }

                        Teachers.Add(new Teacher(lname, fname, patr, studCount));
                    }
                    else
                    {
                        Teachers.Add(DataGenerator.GetTeacher(MaxStudentsCountForOneTeacher));
                    }
                }
            }

            //Количество оборудования
            if (int.TryParse(xdoc.Root.Element("ne")?.Value, out int ne))
            {
                if (ne > 0)
                {
                    EquipmentsCount = ne;
                }
            }

            //Максимальное количество оборудования каждого типа
            if (int.TryParse(xdoc.Root.Element("emax")?.Value, out int emax))
            {
                if (emax > 0)
                {
                    EquipmentInStock = emax;
                }
            }

            //Список оборудования
            var e = xdoc.Root.Element("equipments")?.Elements("equipment");

            if (e == null || e.Count() == 0)
            {
                Equipments = DataGenerator.GetEquipments(EquipmentsCount, EquipmentInStock, 1).ToList();
            }
            else
            {
                for (int i = 0; i < EquipmentsCount; i++)
                {
                    if (e.ElementAtOrDefault(i) != null)
                    {
                        string name  = e.ElementAt(i).Attribute("name")?.Value ?? DataGenerator.GetRngEquip();
                        int    stock = EquipmentInStock;

                        if (int.TryParse(e.ElementAt(i).Attribute("count")?.Value, out int count))
                        {
                            if (count > 0)
                            {
                                stock = count;
                            }
                        }

                        Equipments.Add(new Equipment(name, stock));
                    }
                    else
                    {
                        Equipments.Add(DataGenerator.GetEquipment(EquipmentInStock, 1));
                    }
                }
            }

            //Количество студентов
            if (int.TryParse(xdoc.Root.Element("ns")?.Value, out int ns))
            {
                if (ns > 0)
                {
                    StudentsCount = ns;
                }
            }

            //Максимальное количество оборудования, которое нужно студенту для сдачи
            StudentMaxEquip = EquipmentsCount;
            if (int.TryParse(xdoc.Root.Element("semax")?.Value, out int semax))
            {
                if (semax > 0 && semax < EquipmentsCount)
                {
                    StudentMaxEquip = semax;
                }
            }

            //Список студентов
            var s = xdoc.Root.Element("students")?.Elements("student");

            if (s == null || s.Count() == 0)
            {
                Students = DataGenerator.GetStudents(Equipments, MaxCpuBurst, MaxThreadPriority, StudentsCount).ToList();
            }
            else
            {
                for (int i = 0; i < StudentsCount; i++)
                {
                    if (s.ElementAtOrDefault(i) != null)
                    {
                        string lname = s.ElementAt(i).Attribute("lname")?.Value ?? DataGenerator.GetRngLastName();
                        string fname = s.ElementAt(i).Attribute("fname")?.Value ?? DataGenerator.GetRngFirstName();
                        string patr  = s.ElementAt(i).Attribute("patr")?.Value ?? DataGenerator.GetRngPatronymic();
                        string group = s.ElementAt(i).Attribute("group")?.Value ?? DataGenerator.GetRngGroup();

                        int prior = DataGenerator.GetRngNumber(1, MaxThreadPriority);
                        if (int.TryParse(s.ElementAt(i).Attribute("prior")?.Value, out int p))
                        {
                            if (p > 0 && p <= MaxThreadPriority)
                            {
                                prior = p;
                            }
                        }

                        int eqcount = DataGenerator.GetRngNumber(1, EquipmentsCount);
                        if (int.TryParse(s.ElementAt(i).Attribute("eqcount")?.Value, out int ec))
                        {
                            if (ec > 0 && ec <= EquipmentsCount)
                            {
                                eqcount = ec;
                            }
                        }

                        int cpuburst = DataGenerator.GetRngNumber(1, MaxCpuBurst);
                        if (int.TryParse(s.ElementAt(i).Attribute("cpuburst")?.Value, out int cb))
                        {
                            if (cb > 0 && cb <= MaxCpuBurst)
                            {
                                cpuburst = cb;
                            }
                        }

                        //Список предметов студента для сдачи
                        List <string> eqNames           = new List <string>();
                        var           personalEquipment = s.ElementAt(i).Element("equipments")?.Elements("equipment");
                        if (personalEquipment == null || personalEquipment.Count() == 0)
                        {
                            eqNames = DataGenerator.GetRandomItems(Equipments.Select(e => e.Name).ToList()).ToList();
                        }
                        else
                        {
                            foreach (var equip in personalEquipment)
                            {
                                eqNames.Add(equip.Attribute("name")?.Value ?? Equipments.First().Name);
                            }
                        }

                        Subject subj = new Subject(eqNames, cpuburst);
                        Student st   = new Student(lname, fname, patr, group, prior, subj);
                        Students.Add(st);
                    }
                    else
                    {
                        Students.Add(DataGenerator.GetStudent(Equipments, MaxCpuBurst, MaxThreadPriority));
                    }
                }
            }
        }