Esempio n. 1
0
        public AddGroupEquipment(EquipmentGroup equipmentGroup = null)
        {
            InitializeComponent();

            this.comboBox1.AutoCompleteMode   = AutoCompleteMode.SuggestAppend;
            this.comboBox1.AutoCompleteSource = AutoCompleteSource.CustomSource;
            List <Workshop> workshops = Program.db.Workshops.ToList();

            this.comboBox1.DataSource = workshops;
            this.comboBox1.AutoCompleteCustomSource.AddRange(workshops.Select(i => i.name).ToArray());


            if (equipmentGroup != null)
            {
                this.Text = "Справочник - Редактировать группу оборудования";
                this.button_AddGroupEquipment.Text         = "Изменить";
                this.button_AddGroupEquipmentAndClose.Text = "Изменить и закрыть";
                this.textBox_NameEquipment.Text            = equipmentGroup.name;
                this.textBox_Cipher.Text = equipmentGroup.сipher;

                Workshop workshop = Program.db.Workshops.Find(equipmentGroup.PK_Workshop);
                if (workshop != null)
                {
                    comboBox1.SelectedItem = workshop;
                }
                else
                {
                    comboBox1.Text = "Указанный цех не существует...";
                }


                this.EditEquipmentGroup = equipmentGroup;
            }
        }
Esempio n. 2
0
        private void AddLeasingForm_Activated(object sender, EventArgs e)
        {
            Workshop       workshop = ((Workshop)this.comboBox_Workshop.SelectedItem);
            EquipmentGroup group    = ((EquipmentGroup)this.comboBox_Equipment.SelectedItem);
            Organization   leaser   = ((Organization)this.comboBox_Leaser.SelectedItem);
            Organization   seller   = ((Organization)this.comboBox_Seller.SelectedItem);



            List <Organization> leasers = Program.db.Organizations.Where(b => b.PK_Role == 2).ToList();

            this.comboBox_Leaser.DataSource = leasers;
            this.comboBox_Leaser.AutoCompleteCustomSource.AddRange(leasers.Select(i => i.name).ToArray());
            this.comboBox_Leaser.SelectedItem = leaser;

            List <Organization> sellers = Program.db.Organizations.Where(b => b.PK_Role == 3).ToList();

            this.comboBox_Seller.DataSource = sellers;
            this.comboBox_Seller.AutoCompleteCustomSource.AddRange(sellers.Select(i => i.name).ToArray());
            this.comboBox_Seller.SelectedItem = seller;

            List <Workshop> workshops = Program.db.Workshops.ToList();

            this.comboBox_Workshop.DataSource = workshops;
            this.comboBox_Workshop.AutoCompleteCustomSource.AddRange(workshops.Select(i => i.name).ToArray());
            this.comboBox_Workshop.SelectedItem = workshop;


            List <EquipmentGroup> groups = Program.db.EquipmentGroups.ToList();

            this.comboBox_Equipment.DataSource = groups;
            this.comboBox_Equipment.AutoCompleteCustomSource.AddRange(workshops.Select(i => i.name).ToArray());
            this.comboBox_Equipment.SelectedItem = group;
        }
        /// <summary>
        /// Spawns items from the equipment group
        /// </summary>
        /// <param name="selectedGroup"></param>
        /// <param name="position"></param>
        /// <param name="rotation"></param>
        /// <param name="callback"></param>
        /// <param name="tolerance"></param>
        /// <returns></returns>
        public static IEnumerator InstantiateFromEquipmentGroup(EquipmentGroup selectedGroup, Vector3 position, Quaternion rotation, Action <GameObject> callback = null, float tolerance = 1.3f)
        {
            float currentHeight = 0;

            foreach (EquipmentGroup group in selectedGroup.GetSpawnedEquipmentGroups())
            {
                for (int i = 0; i < group.ItemsToSpawn; i++)
                {
                    FVRObject selectedFVR;
                    if (IM.OD.TryGetValue(group.GetObjects().GetRandom(), out selectedFVR))
                    {
                        //First, async get the game object to spawn
                        AnvilCallback <GameObject> objectCallback = selectedFVR.GetGameObjectAsync();
                        yield return(objectCallback);

                        GameObject gameObject = objectCallback.Result;

                        //Next calculate the height needed for this item
                        float heightNeeded = gameObject.GetMaxBounds().size.y / 2 * tolerance;
                        currentHeight += heightNeeded;

                        //Finally spawn the item and call the callback if it's not null
                        GameObject spawnedObject = UnityEngine.GameObject.Instantiate(gameObject, position + (Vector3.up * currentHeight), rotation);
                        if (callback != null)
                        {
                            callback.Invoke(spawnedObject);
                        }
                        yield return(null);
                    }
                }
            }
        }
Esempio n. 4
0
        public static void RemoveUnloadedObjectIDs(EquipmentGroup group)
        {
            if (group.IDOverride != null)
            {
                for (int i = 0; i < group.IDOverride.Count; i++)
                {
                    if (!IM.OD.ContainsKey(group.IDOverride[i]))
                    {
                        //If this is a vaulted gun with all it's components loaded, we should still have this in the object list
                        if (LoadedTemplateManager.LoadedVaultFiles.ContainsKey(group.IDOverride[i]))
                        {
                            if (!LoadedTemplateManager.LoadedVaultFiles[group.IDOverride[i]].AllComponentsLoaded())
                            {
                                TNHTweakerLogger.LogWarning("TNHTweaker -- Vaulted gun in table does not have all components loaded, removing it! VaultID : " + group.IDOverride[i]);
                                group.IDOverride.RemoveAt(i);
                                i -= 1;
                            }
                        }

                        //If this was not a vaulted gun, remove it
                        else
                        {
                            TNHTweakerLogger.LogWarning("TNHTweaker -- Object in table not loaded, removing it from object table! ObjectID : " + group.IDOverride[i]);
                            group.IDOverride.RemoveAt(i);
                            i -= 1;
                        }
                    }
                }
            }
        }
Esempio n. 5
0
 private void save_row_data()
 {
     workshop_saved = ((Workshop)comboBox_Workshop.SelectedItem);
     group_saved    = ((EquipmentGroup)comboBox_Equipment.SelectedItem);
     amount_saved   = this.textBox_Amount.Text;
     cost_saved     = this.numericUpDown_Cost.Value;
 }
Esempio n. 6
0
        private void Equipment_Activated(object sender, EventArgs e)
        {
            // сохраним выбор
            Workshop       selected_wrokshop = ((Workshop)this.comboBox_Workshop.SelectedItem);
            EquipmentGroup selected_group    = ((EquipmentGroup)this.comboBox_GroupEquipment.SelectedItem);

            //List<Equipment> equipments = Program.db.Equipments.ToList();

            //dataGridView.DataSource = equipments;
            //dataGridView.ClearSelection();

            List <Workshop> workshops = Program.db.Workshops.ToList();

            this.comboBox_Workshop.DataSource = workshops;
            if (selected_wrokshop != null && workshops.Contains(selected_wrokshop))
            {
                this.comboBox_Workshop.SelectedItem = selected_wrokshop;
            }
            else
            {
                this.comboBox_Workshop.SelectedItem = null;
            }

            this.comboBox_GroupEquipment.SelectedItem = selected_group;

            //this.button_Search.PerformClick();
        }
Esempio n. 7
0
        private void ShowEquipmentUpgradesMenuItem_Click(object sender, EventArgs e)
        {
            if (CharactersTreeView.SelectedNode == null)
            {
                return;
            }

            EquipmentGroup characterEquipment = new EquipmentGroup();
            EquipmentGroup muleEquipment      = new EquipmentGroup();

            foreach (var item in boundList)
            {
                if (item.Owner == CharactersTreeView.SelectedNode.Text && item.EquippedSlot != 0)
                {
                    characterEquipment.Add(item);
                }

                if (item.Owner != CharactersTreeView.SelectedNode.Text && item.EquippedSlot == 0)
                {
                    muleEquipment.Add(item);
                }
            }

            var upgrades = characterEquipment.GetUpgradeOptions(muleEquipment);

            EquipmentUpgradesForm equipmentUpgradesForm = new EquipmentUpgradesForm();

            equipmentUpgradesForm.Owner = this;

            equipmentUpgradesForm.Show();

            equipmentUpgradesForm.Update(upgrades);
        }
        public void Update(EquipmentGroup obsoleteEquipment, EquipmentGroup upgradeEquipment)
        {
            currentEquipmentGrid.DataSource = obsoleteEquipment;
            currentEquipmentGrid.AutoResizeColumns(DataGridViewAutoSizeColumnsMode.AllCellsExceptHeader);

            upgradeEquipmentGrid.DataSource = upgradeEquipment;
            upgradeEquipmentGrid.AutoResizeColumns(DataGridViewAutoSizeColumnsMode.AllCellsExceptHeader);
        }
		public void Update(EquipmentGroup obsoleteEquipment, EquipmentGroup upgradeEquipment)
		{
			currentEquipmentGrid.DataSource = obsoleteEquipment;
			currentEquipmentGrid.AutoResizeColumns(DataGridViewAutoSizeColumnsMode.AllCellsExceptHeader);

			upgradeEquipmentGrid.DataSource = upgradeEquipment;
			upgradeEquipmentGrid.AutoResizeColumns(DataGridViewAutoSizeColumnsMode.AllCellsExceptHeader);
		}
Esempio n. 10
0
        /* Для редактирования строки акта */
        private void SaveBeforeEdit()
        {
            workshopSaved  = (Workshop)comboBox_Workshop.SelectedItem;
            groupSaved     = (EquipmentGroup)comboBox_GroupEquipment.SelectedItem;
            equipmentSaved = (Equipment)comboBox_Equipment.SelectedItem;
            reasonSaved    = (ReasonDebit)comboBox_ReasonDebit.SelectedItem;

            stateAllSaved = checkBox_AllGroupDebit.Checked;
        }
        private void AddGroupClick(object sender, RoutedEventArgs e)
        {
            var group = new EquipmentGroup();

            group.EquipmentGroupDelete += GroupDelete;
            group.PageGroup             = true;

            ((StackPanel)pages.Children[currentPage - 1]).Children.Add(group);
        }
Esempio n. 12
0
 public async Task <IActionResult> DeleteEquipGroup(EquipmentGroup delEquipGroup)
 {
     equipmentGroup.UpdateStatusById(delEquipGroup.EquipmentGroupId);
     if (await equipmentGroup.SaveChangesAsync() >= 0)
     {
         return(RedirectToAction("ShowAll"));
     }
     return(View());
 }
Esempio n. 13
0
 public async Task <IActionResult> UpdateGroupEquipment(EquipmentGroup equipGroup)
 {
     equipGroup.Username   = HttpContext.Session.GetString("adminName");
     equipGroup.CreateDate = DateTime.Now;
     equipmentGroup.Update(equipGroup.EquipmentGroupId, equipGroup);
     if (await equipmentGroup.SaveChangesAsync() >= 0)
     {
         return(RedirectToAction("ShowAll"));
     }
     return(View());
 }
        public UnitComplectationModel(IGrouping <EquipmentGroup, Equipment> equipmentGroup)
        {
            EquipmentGroup group = equipmentGroup.Key;

            this.Id   = group.Id;
            this.Name = group.Name;

            var equipmentList = equipmentGroup.ToList();

            this.IsFullyEquipped    = equipmentList.TrueForAll(equipment => equipment.IsInTheUnit);
            this.EquipmentModelList = equipmentList.Select(equipment =>
                                                           new EquipmentModel(equipment)).ToList();
        }
Esempio n. 15
0
        private bool add_edit_Equipment()
        {
            // проверка на заполненность строк
            if (String.IsNullOrWhiteSpace(this.textBox_InventoryNum.Text) ||
                String.IsNullOrWhiteSpace(this.textBox_NameEquipment.Text) ||
                String.IsNullOrWhiteSpace(this.textBox_SerialNum.Text) ||
                this.comboBox_Workshop.SelectedItem == null || this.comboBox_Workshop.SelectedIndex == -1 ||
                this.comboBox_GroupEquipment.SelectedItem == null || this.comboBox_Workshop.SelectedIndex == -1)
            {
                MessageBox.Show("Чтобы добавить или изменить запись заполните все поля!", "Внимание!", MessageBoxButtons.OK, MessageBoxIcon.Information);
                return(false);
            }


            // если добавляем
            if (this.EditEquipment == null)
            {
                Equipment newEquipment = new Equipment();

                newEquipment.name               = this.textBox_NameEquipment.Text;
                newEquipment.inventory_number   = this.textBox_InventoryNum.Text;
                newEquipment.serial_number      = this.textBox_SerialNum.Text;
                newEquipment.PK_Equipment_Group = ((EquipmentGroup)this.comboBox_GroupEquipment.SelectedItem).PK_Equipment_Group;
                newEquipment.cost               = this.numericUpDown_Cost.Value;

                Program.db.Equipments.Add(newEquipment);
                MessageBox.Show("Успешно добавлено!", "Успех!", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }


            // редактируем
            else
            {
                this.EditEquipment.name             = this.textBox_NameEquipment.Text;
                this.EditEquipment.inventory_number = this.textBox_InventoryNum.Text;
                this.EditEquipment.serial_number    = this.textBox_SerialNum.Text;
                this.EditEquipment.cost             = this.numericUpDown_Cost.Value;

                // Workshop workshop = ((Workshop)this.comboBox_Workshop.SelectedItem);
                EquipmentGroup equipmentGroup = ((EquipmentGroup)this.comboBox_GroupEquipment.SelectedItem);

                this.EditEquipment.PK_Equipment_Group = equipmentGroup.PK_Equipment_Group;
                Program.db.Equipments.Update(this.EditEquipment);
                MessageBox.Show("Успешно изменено!", "Успех!", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }

            Program.db.SaveChanges();

            return(true);
        }
Esempio n. 16
0
        void OnDestroy()
        {
            if (dontDrop)
            {
                return;
            }

            TNHTweakerLogger.Log("TNHTweaker -- Lootable link was destroyed!", TNHTweakerLogger.LogType.TNH);

            List <GameObject> toSpawn       = new List <GameObject>();
            EquipmentGroup    selectedGroup = group.GetSpawnedEquipmentGroups().GetRandom();
            string            selectedItem;

            for (int itemIndex = 0; itemIndex < selectedGroup.ItemsToSpawn; itemIndex++)
            {
                if (selectedGroup.IsCompatibleMagazine)
                {
                    FVRObject mag = FirearmUtils.GetAmmoContainerForEquipped(selectedGroup.MinAmmoCapacity, selectedGroup.MaxAmmoCapacity);
                    if (mag != null)
                    {
                        selectedItem = mag.ItemID;
                    }
                    else
                    {
                        TNHTweakerLogger.Log(
                            "TNHTweaker -- Spawning nothing, since group was compatible magazines, and could not find a compatible magazine for player",
                            TNHTweakerLogger.LogType.TNH);
                        return;
                    }
                }

                else
                {
                    selectedItem = selectedGroup.GetObjects().GetRandom();
                }

                if (LoadedTemplateManager.LoadedVaultFiles.ContainsKey(selectedItem))
                {
                    AnvilManager.Run(TNHTweakerUtils.SpawnFirearm(LoadedTemplateManager.LoadedVaultFiles[selectedItem],
                                                                  transform.position, transform.rotation));
                }
                else
                {
                    toSpawn.Add(IM.OD[selectedItem].GetGameObject());
                }
            }

            AnvilManager.Run(TNHTweakerUtils.InstantiateList(toSpawn, transform.position));
        }
 protected EquipmentGroupView ConvertToViewModel(EquipmentGroup entity) => new EquipmentGroupView
 {
     EquipmentGroupId   = entity.Id,
     EquipmentGroupSeq  = entity.Seq,
     EquipmentGroupName = entity.Name,
     Equipments         = entity.Equipments.OrderBy(x => x.Seq).Select(c => new EquipmentView
     {
         EquipmentId   = c.Id,
         EquipmentName = c.Name,
         EquipmentSeq  = c.Seq,
         Desc          = c.Desc,
         Value         = c.Value,
         ModifiedOn    = c.ModifiedOn.HasValue ? c.ModifiedOn.Value.ToString("yyyy/MM/dd HH:mm:ss"): null,
     })
 };
Esempio n. 18
0
		public void Update(Dictionary<SuitBuildableMyWorldObject, List<SuitBuildableMyWorldObject>> upgrades)
		{
			EquipmentGroup obsoleteEquipment = new EquipmentGroup();
			EquipmentGroup upgradeEquipment = new EquipmentGroup();

			foreach (var kvp in upgrades)
			{
				obsoleteEquipment.Add(kvp.Key);

				foreach (var v in kvp.Value)
					upgradeEquipment.Add(v);
			}

			Update(obsoleteEquipment, upgradeEquipment);
		}
        public void Update()
        {
            var d = new Dictionary<int, EquipmentGroup>();
            if (Staff.Current.Homeport.Equipments == null) return;
            foreach (var item in Staff.Current.Homeport.Equipments)
            {
                int typeid = item.EquipInfo.Id;
                EquipmentGroup group;
                if (!d.TryGetValue(typeid, out group))
                {
                    group = new EquipmentGroup { Item = item.EquipInfo };
                    d.Add(typeid, group);
                }
                int i;
                EquipmentImprovementGroup group2 = null;
                for (i = 0; i < group.Groups.Count; i++)
                {
                    if (group.Groups[i].Level == item.ImproveLevel) group2 = group.Groups[i];
                    if (group.Groups[i].Level >= item.ImproveLevel) break;
                }
                if (group2 == null)
                {
                    group2 = new EquipmentImprovementGroup { Level = item.ImproveLevel };
                    group.Groups.Insert(i, group2);
                }
                EquipmentProficiencyGroup group3 = null;
                for (i = 0; i < group2.Groups.Count; i++)
                {
                    if (group2.Groups[i].Level == item.AirProficiency) group3 = group2.Groups[i];
                    if (group2.Groups[i].Level >= item.AirProficiency) break;
                }
                if (group3 == null)
                {
                    group3 = new EquipmentProficiencyGroup { Level = item.AirProficiency };
                    group2.Groups.Insert(i, group3);
                }

                group3.Count++;
                if (item.OnShip != null)
                {
                    if (group3.Equipped.ContainsKey(item.OnShip)) group3.Equipped[item.OnShip]++;
                    else group3.Equipped.Add(item.OnShip, 1);
                }
                else group3.Left++;
            }
            Groups = d.Values.OrderBy(x => x.Item.EquipType.Id).ThenBy(x => x.Item.Id).ToArray();
        }
        public void Update(Dictionary <SuitBuildableMyWorldObject, List <SuitBuildableMyWorldObject> > upgrades)
        {
            EquipmentGroup obsoleteEquipment = new EquipmentGroup();
            EquipmentGroup upgradeEquipment  = new EquipmentGroup();

            foreach (var kvp in upgrades)
            {
                obsoleteEquipment.Add(kvp.Key);

                foreach (var v in kvp.Value)
                {
                    upgradeEquipment.Add(v);
                }
            }

            Update(obsoleteEquipment, upgradeEquipment);
        }
Esempio n. 21
0
        public async Task <IActionResult> CreateNew(EquipmentGroup equipGroup)
        {
            equipGroup.EquipmentGroupId = util.RandomString(8);
            EquipmentGroup group;

            do
            {
                group = null;
                group = equipmentGroup.Get(equipGroup.EquipmentGroupId);
            }while (group != null);
            await HttpContext.Session.LoadAsync();

            equipGroup.CreateDate = DateTime.Now;
            equipGroup.Username   = HttpContext.Session.GetString("adminName");
            equipmentGroup.Add(equipGroup);
            return(RedirectToAction("ShowAll"));
        }
Esempio n. 22
0
        public StatusPage(StreamReader statusLines)
        {
            InitializeComponent();

            try
            {
                string line = statusLines.ReadLine();
                while (!statusLines.EndOfStream && !line.StartsWith("Page End"))
                {
                    if (line.StartsWith("Background Image: "))
                    {
                        backgroundImageFilename = line.Replace("Background Image: ", null);

                        if (File.Exists(backgroundImageFilename))
                        {
                            backgroundImage.Source = new BitmapImage(new Uri(backgroundImageFilename));
                        }

                        line = statusLines.ReadLine();
                    }

                    while (line.StartsWith("Start Group:"))
                    {
                        var group = new EquipmentGroup(line.Remove(0, 13), statusLines);
                        group.EquipmentGroupDelete += GroupDelete;
                        DockPanel.SetDock(group, Dock.Top);

                        page.Children.Add(group);

                        line = statusLines.ReadLine();
                    }
                }
            }catch (Exception ex)
            {
                var error = "Error Initializine Main Window";

                ErrorLogger.ErrorDialog(error, ErrorType.Failure);
                ErrorLogger.LogError(error, ex,
                                     Environment.GetFolderPath(Environment.SpecialFolder.CommonApplicationData) +
                                     Properties.Settings.Default.AppDataFolder +
                                     Properties.Settings.Default.ErrorLogFilename);
            }
        }
Esempio n. 23
0
        private void button_EditGroupEquipment_Click(object sender, EventArgs e)
        {
            int PK_Group_Equipment = -1;

            try
            {
                PK_Group_Equipment = Convert.ToInt32(dataGridView_DataSearch.SelectedRows[0].Cells[0].Value);
            }
            catch
            {
                MessageBox.Show("Выбранная запись отсутствует в таблице!", "Внимание!", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }

            EquipmentGroup equipmentGroup = Program.db.EquipmentGroups.Find(PK_Group_Equipment);

            if (equipmentGroup != null)
            {
                new AddGroupEquipment(equipmentGroup).ShowDialog();
            }
        }
Esempio n. 24
0
        private void button_Edit_Click(object sender, EventArgs e)
        {
            int index = -1;

            try
            {
                index = Convert.ToInt32(dataGridView1.SelectedRows[0].Index);
            }
            catch (Exception exception)
            {
                MessageBox.Show("Выберите строку в таблице, которую нужно изменить", "Внимание!", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }



            if (index == -1)
            {
                return;
            }

            this.index_row_in_edit = index;

            // сохраняем введенные данные
            save_row_data();

            // заполняем поля из таблицы

            EquipmentGroup equipmentGroupInEdit = Program.db.EquipmentGroups.Find(Convert.ToInt32(dataGridView1.Rows[index].Cells[0].Value));

            this.comboBox_Workshop.SelectedItem  = equipmentGroupInEdit.workshop;
            this.comboBox_Equipment.SelectedItem = equipmentGroupInEdit;
            this.textBox_Amount.Text             = Convert.ToString(dataGridView1.Rows[index].Cells[3].Value);
            this.numericUpDown_Cost.Value        = Convert.ToDecimal(dataGridView1.Rows[index].Cells[2].Value);

            // переименовываем кнопки

            this.button_AddRowEquipment.Text = "Применить";
            this.button_RemoveEquipment.Text = "Отменить";
        }
Esempio n. 25
0
        public SosigTemplate(SosigEnemyTemplate template)
        {
            DisplayName        = template.DisplayName;
            SosigEnemyCategory = template.SosigEnemyCategory;
            SosigEnemyID       = template.SosigEnemyID.ToString();
            SecondaryChance    = template.SecondaryChance;
            TertiaryChance     = template.TertiaryChance;

            SosigPrefabs           = template.SosigPrefabs.Select(o => o.ItemID).ToList();
            WeaponOptions          = template.WeaponOptions.Select(o => o.ItemID).ToList();
            WeaponOptionsSecondary = template.WeaponOptions_Secondary.Select(o => o.ItemID).ToList();
            WeaponOptionsTertiary  = template.WeaponOptions_Tertiary.Select(o => o.ItemID).ToList();

            Configs       = template.ConfigTemplates.Select(o => new SosigConfig(o)).ToList();
            ConfigsEasy   = template.ConfigTemplates_Easy.Select(o => new SosigConfig(o)).ToList();
            OutfitConfigs = template.OutfitConfig.Select(o => new OutfitConfig(o)).ToList();

            DroppedLootChance = 0;
            DroppedObjectPool = new EquipmentGroup();

            this.template = template;
        }
Esempio n. 26
0
        public async Task <ActionResult> Save(EquipmentGroupViewModel model)
        {
            using (EquipmentGroupServiceClient client = new EquipmentGroupServiceClient())
            {
                EquipmentGroup obj = new EquipmentGroup()
                {
                    Key         = model.Name,
                    Description = model.Description,
                    Editor      = User.Identity.Name,
                    EditTime    = DateTime.Now,
                    CreateTime  = DateTime.Now,
                    Creator     = User.Identity.Name
                };
                MethodReturnResult rst = await client.AddAsync(obj);

                if (rst.Code == 0)
                {
                    rst.Message = string.Format(FMMResources.StringResource.EquipmentGroup_Save_Success
                                                , model.Name);
                }
                return(Json(rst));
            }
        }
Esempio n. 27
0
    public void LoadDataByString(string _dataString)
    {
        string[] splittedString = _dataString.Split('_');
        if (splittedString.Length == 1)
        {
            return;
        }
        excerciseName = splittedString[0];
        Debug.Log(splittedString[2]);
        muscleGroup      = (MuscleGroup)System.Enum.Parse(typeof(MuscleGroup), splittedString[1]);
        equipmentGroup   = (EquipmentGroup)System.Enum.Parse(typeof(EquipmentGroup), splittedString[2]);
        setIsTimed       = (splittedString[3] == "True");
        repDuration      = int.Parse(splittedString[4]);
        breakDuration    = int.Parse(splittedString[5]);
        setAmount        = int.Parse(splittedString[6]);
        repetitionAmount = int.Parse(splittedString[7]);

        totalTimesDone      = int.Parse(splittedString[8]);
        totalTimesDoneToday = int.Parse(splittedString[9]);
        totalTimesDoneWeek  = int.Parse(splittedString[10]);
        totalTimesDoneMonth = int.Parse(splittedString[11]);
        totalTimesDoneMonth = int.Parse(splittedString[12]);
    }
Esempio n. 28
0
        public void Update()
        {
            var d = new Dictionary <int, EquipmentGroup>();

            if (Staff.Current.Homeport.Equipments == null)
            {
                return;
            }
            foreach (var item in Staff.Current.Homeport.Equipments)
            {
                int typeid = item.EquipInfo.Id;
                if (!d.TryGetValue(typeid, out EquipmentGroup group))
                {
                    group = new EquipmentGroup {
                        Item = item.EquipInfo
                    };
                    d.Add(typeid, group);
                }
                int i;
                EquipmentImprovementGroup group2 = null;
                for (i = 0; i < group.Groups.Count; i++)
                {
                    if (group.Groups[i].Level == item.ImproveLevel)
                    {
                        group2 = group.Groups[i];
                    }
                    if (group.Groups[i].Level >= item.ImproveLevel)
                    {
                        break;
                    }
                }
                if (group2 == null)
                {
                    group2 = new EquipmentImprovementGroup {
                        Level = item.ImproveLevel
                    };
                    group.Groups.Insert(i, group2);
                }
                EquipmentProficiencyGroup group3 = null;
                for (i = 0; i < group2.Groups.Count; i++)
                {
                    if (group2.Groups[i].Level == item.AirProficiency)
                    {
                        group3 = group2.Groups[i];
                    }
                    if (group2.Groups[i].Level >= item.AirProficiency)
                    {
                        break;
                    }
                }
                if (group3 == null)
                {
                    group3 = new EquipmentProficiencyGroup {
                        Level = item.AirProficiency
                    };
                    group2.Groups.Insert(i, group3);
                }

                group3.Count++;
                if (item.OnShip != null)
                {
                    if (group3.Equipped.ContainsKey(item.OnShip))
                    {
                        group3.Equipped[item.OnShip]++;
                    }
                    else
                    {
                        group3.Equipped.Add(item.OnShip, 1);
                    }
                }
                else
                {
                    group3.Left++;
                }
            }
            Groups = d.Values.OrderBy(x => x.Item.EquipType.Id).ThenBy(x => x.Item.Id).ToArray();
        }
        public async Task <IActionResult> GetResponseByFeedbackId(string feedbackId)
        {
            /*_equipmentGroup.*/
            //get questionId from feedbackId
            List <Question>              listQuestion      = _questionRepository.GetAll().ToList <Question>();
            List <Question>              listQuestionForFb = new List <Question>();
            List <string>                listQuestionId    = new List <string>();
            List <ResponseModel>         listResponse      = new List <ResponseModel>();
            List <Response>              listTmp           = new List <Response>();
            List <ResponseModel>         listResForOneQues = new List <ResponseModel>();
            List <List <ResponseModel> > listResult        = new List <List <ResponseModel> >();

            foreach (Question que in listQuestion)
            {
                if (que.FeedbackId.Equals(feedbackId))
                {
                    listQuestionId.Add(que.QuestionId);
                    listQuestionForFb.Add(que);
                }
            }
            //get all response from QuestionID
            for (int questionIndex = 0; questionIndex < listQuestionId.Count; questionIndex++)
            {
                listTmp = _responseRepository.GetResponseByQuestionId(listQuestionId[questionIndex]).ToList();
                foreach (Response r in listTmp)
                {
                    String        tmpResponseDetail  = r.ResponseDetail;
                    List <string> listResponseDetail = new List <string>();
                    //TypeOfQuestion 1: Emotion
                    if (r.Question.TypeOfQuestion == 1)
                    {
                        switch (tmpResponseDetail)
                        {
                        case "1":
                            tmpResponseDetail = "Thất vọng";
                            break;

                        case "2":
                            tmpResponseDetail = "Tạm ổn";
                            break;

                        case "3":
                            tmpResponseDetail = "Tốt";
                            break;

                        case "4":
                            tmpResponseDetail = "Tuyệt vời";
                            break;

                        case "5":
                            tmpResponseDetail = "Yêu thích";
                            break;
                        }
                    }
                    //TypeOfQuestion 2: Rating star
                    else if (r.Question.TypeOfQuestion == 2)
                    {
                        tmpResponseDetail = r.ResponseDetail.Substring(0, 1) + " sao";
                    }
                    else if (r.Question.TypeOfQuestion == 3)
                    {
                        listResponseDetail = getResponseDetail(r.ResponseDetail);
                        foreach (string detail in listResponseDetail)
                        {
                            ResponseModel resModelForMultichoice = new ResponseModel
                            {
                                equipmentId    = r.EquipmentId,
                                questionId     = questionIndex + "",
                                responseDetail = detail,
                                typeOfQuestion = r.Question.TypeOfQuestion + "",
                                responseTime   = r.ResponseTime
                            };
                            listResponse.Add(resModelForMultichoice);
                        }
                    }
                    //TypeOfQuestion 4: one choice
                    else if (r.Question.TypeOfQuestion == 4)
                    {
                        tmpResponseDetail = r.ResponseDetail;
                    }

                    if (r.Question.TypeOfQuestion != 3)
                    {
                        ResponseModel resModel = new ResponseModel
                        {
                            equipmentId    = r.EquipmentId,
                            questionId     = questionIndex + "",
                            responseDetail = tmpResponseDetail,
                            typeOfQuestion = r.Question.TypeOfQuestion + "",
                            responseTime   = r.ResponseTime
                        };
                        listResponse.Add(resModel);
                        if (questionIndex == 0)
                        {
                            listResForOneQues.Add(resModel);
                        }
                    }
                }
                listResult.Add(listResponse);
            }

            var settings = new ConnectionConfiguration(new Uri("http://localhost:9200"))
                           .RequestTimeout(TimeSpan.FromMinutes(2));
            var lowlevelClient = new ElasticLowLevelClient(settings);
            //push data on elastic for count response of feedback
            int i = 0;
            int checkIdOfIndexExist = 0;

            if (HttpContext.Session.GetInt32("TotalIdIndexOfCountRes") != null)
            {
                checkIdOfIndexExist = (int)HttpContext.Session.GetInt32("TotalIdIndexOfCountRes");
                if (checkIdOfIndexExist != 0)
                {
                    //Clear all data in index
                    for (int j = 1; j <= checkIdOfIndexExist; j++)
                    {
                        lowlevelClient.Delete <StringResponse>("countresponseforfb", Convert.ToString(j));
                    }
                    HttpContext.Session.Remove("TotalIdIndexOfCountRes");
                }
            }
            foreach (ResponseModel res in listResForOneQues)
            {
                lowlevelClient.Index <StringResponse>("countresponseforfb", Convert.ToString(++i), PostData.Serializable(res));
            }
            HttpContext.Session.SetInt32("TotalIdIndexOfCountRes", i);


            //Id cho tung object trong index
            #region push response on elastic
            i = 0;
            checkIdOfIndexExist = 0;
            if (HttpContext.Session.GetInt32("TotalIdIndex") != null)
            {
                checkIdOfIndexExist = (int)HttpContext.Session.GetInt32("TotalIdIndex");
                if (checkIdOfIndexExist != 0)
                {
                    //Clear all data in index
                    for (int j = 1; j <= checkIdOfIndexExist; j++)
                    {
                        lowlevelClient.Delete <StringResponse>("testresponse", Convert.ToString(j));
                    }
                    HttpContext.Session.Remove("TotalIdIndex");
                }
            }

            foreach (ResponseModel res in listResponse)
            {
                lowlevelClient.Index <StringResponse>("testresponse", Convert.ToString(++i), PostData.Serializable(res));
            }

            HttpContext.Session.SetInt32("TotalIdIndex", i);
            #endregion

            ViewBag.countResponse = listResForOneQues.Count;
            ViewBag.listQuestion  = listQuestionForFb;
            ViewBag.feedbackId    = feedbackId;
            getFeedbackIDByBrandId();
            getEquipmentGroupId();

            await HttpContext.Session.LoadAsync();

            HttpContext.Session.SetString("feedbackId", feedbackId);
            await HttpContext.Session.CommitAsync();

            EquipmentGroup e = new EquipmentGroup {
                EquipmentGroupId = HttpContext.Session.GetString("equipmentGroupId")
            };
            await GetListFeedbackByEquipmentGroupId(e);

            return(View("Admin"));
        }
        public async Task <IActionResult> GetListFeedbackByEquipmentGroupId(EquipmentGroup eGroup)
        {
            // get list equipment by equipGroupId
            //1. get equipmentId from nameOfGroup
            //List<EquipmentGroup> listequipmentGroups = _equipmentGroup.GetAll().ToList<EquipmentGroup>();
            List <Feedback> listTmp      = new List <Feedback>();
            List <Feedback> listFeedback = new List <Feedback>();

            /*string equipGroupId = null;
             * foreach (EquipmentGroup group in listequipmentGroups)
             * {
             *  if (group.NameOfGroup.Equals(eGroup.NameOfGroup))
             *  {
             *      equipGroupId = group.EquipmentGroupId;
             *  }
             * }*/
            //2. get list equipment
            if (_equipmentRepository.GetEquipmentByGroupId(eGroup.EquipmentGroupId) != null)
            {
                List <Equipment> listEquip = _equipmentRepository.GetEquipmentByGroupId(eGroup.EquipmentGroupId).ToList <Equipment>();

                //get list feedback by list equipment
                foreach (Equipment e in listEquip)
                {
                    listTmp = await _feedbackRepository.GetFeebackByEquipmentId(e.EquipmentId);

                    foreach (Feedback fb in listTmp)
                    {
                        listFeedback.Add(fb);
                    }
                }

                List <SelectListItem> listItems = new List <SelectListItem>();
                foreach (Feedback fb in listFeedback)
                {
                    if (fb.FeedbackId.Equals(HttpContext.Session.GetString("feedbackId")))
                    {
                        SelectListItem itemSelected = new SelectListItem(fb.Title, fb.FeedbackId, true);
                        listItems.Add(itemSelected);
                        /*HttpContext.Session.Remove("feedbackId");*/
                    }
                    else
                    {
                        SelectListItem item = new SelectListItem(fb.Title, fb.FeedbackId);
                        listItems.Add(item);
                    }
                }

                ViewBag.listFeedback = listItems;
                ViewBag.EQuipId      = eGroup.EquipmentGroupId;
                await HttpContext.Session.LoadAsync();

                HttpContext.Session.SetString("equipmentGroupId", eGroup.EquipmentGroupId);
                await HttpContext.Session.CommitAsync();

                getEquipmentGroupId();
            }
            else
            {
                getEquipmentGroupId();
                ViewBag.checkListEquipmentNotNull = 1;
            }
            return(View("Admin"));
        }
Esempio n. 31
0
		private void ShowEquipmentUpgradesMenuItem_Click(object sender, EventArgs e)
		{
			if (CharactersTreeView.SelectedNode == null)
				return;

			EquipmentGroup characterEquipment = new EquipmentGroup();
			EquipmentGroup muleEquipment = new EquipmentGroup();

			foreach (var item in boundList)
			{
				if (item.Owner == CharactersTreeView.SelectedNode.Text && item.EquippedSlot != 0)
					characterEquipment.Add(item);

				if (item.Owner != CharactersTreeView.SelectedNode.Text && item.EquippedSlot == 0)
					muleEquipment.Add(item);
			}

			var upgrades = characterEquipment.GetUpgradeOptions(muleEquipment);

			EquipmentUpgradesForm equipmentUpgradesForm = new EquipmentUpgradesForm();
			equipmentUpgradesForm.Owner = this;

			equipmentUpgradesForm.Show();

			equipmentUpgradesForm.Update(upgrades);
		}
Esempio n. 32
0
        private void button_AddRowEquipment_Click(object sender, EventArgs e)
        {
            // все поля должны быть заполнены
            if ((this.comboBox_Equipment.SelectedItem == null || this.comboBox_Equipment.SelectedIndex == -1) ||
                String.IsNullOrWhiteSpace(this.textBox_Amount.Text) ||
                String.IsNullOrWhiteSpace(this.numericUpDown_Cost.Text))
            {
                MessageBox.Show("Необходимо заполнить все поля, чтобы добавить строку в таблицу", "Внимание!", MessageBoxButtons.OK, MessageBoxIcon.Information);
                return;
            }

            // стоисть и кол-во - это числа + они ещё и положительные
            try
            {
                int value = Convert.ToInt32(this.textBox_Amount.Text);

                if (value < 0)
                {
                    throw new Exception("Negative value!");
                }
            }
            catch
            {
                MessageBox.Show("Количество должно иметь неотрицательное целочисленное значение!", "Внимание!", MessageBoxButtons.OK, MessageBoxIcon.Information);
                return;
            }

            try
            {
                Decimal value = this.numericUpDown_Cost.Value;
                if (value < 0)
                {
                    throw new Exception("Negative value!");
                }
            }
            catch
            {
                MessageBox.Show("Стоимость - это неотрицательное численное значение!", "Внимание!", MessageBoxButtons.OK, MessageBoxIcon.Information);
                return;
            }



            EquipmentGroup group = (EquipmentGroup)this.comboBox_Equipment.SelectedItem;

            // изменение строки таблицы
            if (this.button_AddRowEquipment.Text == "Применить")
            {
                this.dataGridView1.Rows[this.index_row_in_edit].Cells[0].Value = group.PK_Equipment_Group;
                this.dataGridView1.Rows[this.index_row_in_edit].Cells[1].Value = group.name;
                this.dataGridView1.Rows[this.index_row_in_edit].Cells[2].Value = this.numericUpDown_Cost.Value;
                this.dataGridView1.Rows[this.index_row_in_edit].Cells[3].Value = this.textBox_Amount.Text;
                this.dataGridView1.Rows[this.index_row_in_edit].Cells[5].Value = Convert.ToInt32(this.textBox_Amount.Text) * this.numericUpDown_Cost.Value;

                restore_row_data();
                this.button_AddRowEquipment.Text = "Добавить";
                this.button_RemoveEquipment.Text = "Удалить";
                return;
            }


            // добавление в таблицу
            dataGridView1.Rows.Add(group.PK_Equipment_Group, group.name, this.numericUpDown_Cost.Text, this.textBox_Amount.Text, "шт", Convert.ToInt32(this.textBox_Amount.Text) * this.numericUpDown_Cost.Value);
        }
Esempio n. 33
0
        // метод добавления/редактирования группы оборудования
        private void add_edit_equipment_group()
        {
            if (String.IsNullOrWhiteSpace(this.textBox_NameEquipment.Text) ||
                String.IsNullOrWhiteSpace(this.textBox_Cipher.Text) ||
                comboBox1.SelectedItem == null || comboBox1.SelectedIndex == -1)
            {
                MessageBox.Show("Чтобы добавить или изменить запись заполните все поля!", "Внимание!", MessageBoxButtons.OK, MessageBoxIcon.Information);
                return;
            }


            // если добавляем
            if (this.EditEquipmentGroup == null)
            {
                EquipmentGroup newEquipmentGroup = new EquipmentGroup();

                newEquipmentGroup.name   = this.textBox_NameEquipment.Text;
                newEquipmentGroup.сipher = this.textBox_Cipher.Text;

                int PK_Workshop = -1;
                if (comboBox1.SelectedItem != null && comboBox1.SelectedIndex != -1)
                {
                    PK_Workshop = ((Workshop)this.comboBox1.SelectedItem).PK_Workshop;


                    string[] temp = ((Workshop)comboBox1.SelectedItem).name.Split();

                    string workshop_short_name = "";

                    try
                    {
                        foreach (string item in temp)
                        {
                            workshop_short_name += item.ToUpper()[0];
                        }
                    }
                    catch { }


                    newEquipmentGroup.сipher = workshop_short_name + "-" + newEquipmentGroup.сipher;
                }


                if (PK_Workshop != -1)
                {
                    Program.db.EquipmentGroups.Add(newEquipmentGroup);
                    MessageBox.Show("Успешно добавлено!", "Успех!", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    newEquipmentGroup.PK_Workshop = PK_Workshop;
                }
                else
                {
                    MessageBox.Show("Выберите цех!", "Ошибка!", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
            }


            // редактируем
            else
            {
                this.EditEquipmentGroup.name   = this.textBox_NameEquipment.Text;
                this.EditEquipmentGroup.сipher = this.textBox_Cipher.Text;

                // это плохо, хз как сделать нормально
                Workshop temp = null;
                foreach (Workshop item in Program.db.Workshops.ToList())
                {
                    if (item.name == this.comboBox1.Text)
                    {
                        temp = item;
                        break;
                    }
                }

                this.EditEquipmentGroup.PK_Workshop = temp.PK_Workshop;

                Program.db.EquipmentGroups.Update(EditEquipmentGroup);
                MessageBox.Show("Успешно изменено!", "Успех!", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }

            Program.db.SaveChanges();
        }
Esempio n. 34
0
        private void button_RemoveGroupEquipment_Click(object sender, EventArgs e)
        {
            // сформируем список для удаления
            // заранее - потому что messagebox, который отвечает за подтверждение удаления (ниже)
            // вызывает событие Activated, что обновляет таблицу
            // из-за этого selectedrows сбрасывается...

            List <EquipmentGroup> EquipmentGroupsForRemove = new List <EquipmentGroup>();

            int PK_EquipmentGroup = -1;

            try
            {
                foreach (DataGridViewRow row in dataGridView_DataSearch.SelectedRows)
                {
                    PK_EquipmentGroup = Convert.ToInt32(row.Cells[0].Value);
                    EquipmentGroup curEquipmentGroup = Program.db.EquipmentGroups.Find(PK_EquipmentGroup);

                    if (curEquipmentGroup != null)
                    {
                        EquipmentGroupsForRemove.Add(curEquipmentGroup);
                    }
                }
            }
            catch (Exception exception)
            {
                MessageBox.Show(exception.Message);
            }


            // запрос подтверждения
            if (MessageBox.Show("Вы действительно хотите удалить выбранные цеха? Данное действие нельзя будет отменить!", "Внимание!", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.No)
            {
                return;
            }



            // Оставим в списке те, которые можно удалить
            List <EquipmentGroup> good_list = new List <EquipmentGroup>();
            bool check = false; // флаг - имеются записи, которые не будут удалены

            foreach (var item in EquipmentGroupsForRemove)
            {
                if (item.is_there_relationships() == false)
                {
                    good_list.Add(item);
                }
                else
                {
                    check = true;
                }
            }


            // запрос подтверждения
            if (good_list.Count() > 0 && check)
            {
                if (MessageBox.Show("Среди выбранных групп оборудования есть те, которые невозможно удалить! \n\nПричины могут быть следующие\n в группе содержит в себе оборудование;\n группа указана хотя бы в одном акте списания;\n группа указана хотя бы в одном договоре лизинга. \nУдалить группы оборудования, которые не вызвали такого конфликта?", "Внимание!", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.No)
                {
                    return;
                }
            }
            else if (good_list.Count() == 0 && check)
            {
                MessageBox.Show("Невозможно выполнить удаление.\n\nПричины могут быть следующие\n в группе содержит в себе оборудование;\n группа указана хотя бы в одном акте списания;\n группа указана хотя бы в одном договоре лизинга.");
            }


            // применим удаление
            foreach (var equipmentGroup in good_list)
            {
                Program.db.Remove(equipmentGroup);
            }


            Program.db.SaveChanges();


            this.button_Search.PerformClick();
        }