protected override void OnNavigatedFrom(NavigationEventArgs e)
        {
            if (e.IsNavigationInitiator && e.NavigationMode == NavigationMode.Back)
            {
                if (Accessory != null)
                {
                    Accessory.Update(); // ecos sends not all events for accessory, so force update
                    Accessory.UnregisterControl();
                    Accessory.PropertyChanged -= Item_PropertyChanged;
                    Accessory = null;
                }

                App.EcosModel.AccessoryManager.ItemRemoved -= AccessoryManager_ItemRemoved;
            }
        }
        protected override void OnNavigatedFrom(NavigationEventArgs e)
        {
            base.OnNavigatedFrom(e);

            if (e.NavigationMode == NavigationMode.Back)
            {
                if (Accessory != null)
                {
                    //Accessory.Update(); // force update
                    Accessory.UnregisterControlAsync();
                    Accessory = null;
                }

                AppManager.EcosModel.AccessoriesManager.ItemRemoved -= AccessoryManager_ItemRemoved;
            }
        }
Пример #3
0
        /// <summary>�������� ��������</summary>
        /// <param name="MainProcess"></param>
        /// <param name="mainType">�������� (���������� ��� ���������) ��� �������������� (��� ��� � �������� ������)</param>
        /// <param name="mainTopic">������� (���������� ��� ���������) ���������</param>
        /// <param name="currentType">������� ��� �������������� (��� ��� �� ������� ������� � ���������)</param>
        /// <param name="currentTopic">������� ���������</param>
        /// <param name="accessory">�������������</param>
        /// <param name="topic">���������</param>
        /// <param name="barcode">��������������� �����-���</param>
        /// <param name="propertyName">������������� ��������</param>
        public ValueEditor(WMSClient MainProcess, Type mainType, string mainTopic, Type currentType, string currentTopic, Accessory accessory, string topic, string barcode, string propertyName)
            : base(MainProcess, 1)
        {
            MainProcess.ToDoCommand = topic;

            ValueEditor.accessory = accessory;
            ValueEditor.mainType = mainType;
            ValueEditor.mainTopic = mainTopic;
            this.currentType = currentType;
            this.currentTopic = currentTopic;
            this.barcode = barcode;
            this.propertyName = propertyName;

            IsLoad = true;
            DrawControls();
        }
Пример #4
0
        /// <summary>"��������� ��������������"</summary>
        /// <param name="MainProcess"></param>
        /// <param name="type">������� ��� ��������������</param>
        /// <param name="prevType">���������� ��� ��������������</param>
        /// <param name="topic">������� ���������</param>
        public EditBuilder(WMSClient MainProcess, Type type, Type prevType, string topic)
            : base(MainProcess, 1)
        {
            //���� ����������� ���� ���, �� ��� "������" - ����� ������� ��������� ���������� ��������� ������
            if (prevType == null)
                {
                mainType = type;
                mainTopic = topic;
                accessory = null;
                }

            currentType = type;
            currentTopic = topic;
            linkId = -1;
            MainProcess.ToDoCommand = currentTopic;

            IsLoad = true;
            existMode = false;
            DrawControls();
        }
Пример #5
0
        public ActionResult Import(HttpPostedFileBase file)
        {
            DataTable dt = file.ToDataSet().Tables[0];

            dt.Columns.Add("Status");
            dt.Columns.Add("Note");
            string _importDescription = string.Empty;

            if (dt != null)
            {
                //foreach (DataTable dt in ds.Tables)
                //{
                foreach (DataRow r in dt.Rows)
                {
                    try
                    {
                        var    category      = new Category();
                        string _categoryName = r[0].ToString();
                        string _name         = r[1].ToString();
                        string _amount       = r[2].ToString();
                        if (_name == string.Empty)
                        {
                            _importDescription = "Tên không thể trống";
                        }
                        if (_categoryName == string.Empty)
                        {
                            _importDescription = "Nhóm linh kiện không thể trống";
                        }

                        var iAmount = _amount != string.Empty ? int.Parse(_amount) : 0;
                        if (iAmount < 0 || iAmount > 100000)
                        {
                            _importDescription = string.Format("Số lượng phải trong khoảng 0 và 100000");
                        }

                        if (_importDescription == string.Empty)
                        {
                            if (_categoryName != string.Empty)
                            {
                                category = db.Categories.Where(c => c.Name.Equals(_categoryName, StringComparison.OrdinalIgnoreCase)).FirstOrDefault();
                                if (category == null)
                                {
                                    category      = new Category();
                                    category.Code = AutoNumberHelper.GenerateNumber(ObjectType.Category, db);
                                    category.Name = _categoryName;
                                    db.Categories.Add(category);
                                    db.SaveChanges();
                                }
                            }
                            Accessory item = db.Accessories.Where(p => p.Name.ToLower().Equals(_name.ToLower()) && p.CategoryId == category.Id).FirstOrDefault();
                            if (item != null)
                            {
                                item.CategoryId      = category.Id;
                                item.Name            = _name;
                                item.Amount          = iAmount;
                                db.Entry(item).State = EntityState.Modified;
                            }
                            else
                            {
                                item = new Accessory()
                                {
                                    CategoryId = category.Id,
                                    Name       = _name,
                                    Amount     = iAmount,
                                };
                                db.Accessories.Add(item);
                            }
                        }

                        if (_importDescription != string.Empty)
                        {
                            r[3] = "Không thành công";
                            r[4] = _importDescription;
                        }
                        else
                        {
                            r[3] = "Thành công";
                        }
                    }catch (Exception ex)
                    {
                        r[3] = "Lỗi";
                        r[4] = string.Format("Message: {0} - Inner exception: {1}", ex.Message, ex.InnerException);
                    }
                }
                //}
                db.SaveChanges();
            }
            FileExcel(dt, "Accessory");
            return(RedirectToAction("Index", "Accessory"));
        }
Пример #6
0
    void equipAccessory(Accessory a)
    {
        if (a == null) {
            throw new ArgumentNullException ("a");
        }

        if (accessories.Count < maxAccessories){
            inventory.Remove(a);
            accessories.AddLast(a);
        } else {
            throw new RulesException("Unequip another one first");
        }
    }
        public void SetFavoriteItem(Accessory item, bool isFavorite)
        {
            item.IsMyFavorite = isFavorite;

            if (isFavorite && !FavoriteItemsIDs.Contains(item.ID))
            {
                FavoriteItemsIDs.Add(item.ID);
                NotifyPropertyChanged("FavoriteItemsIDs");
            }
            if (!isFavorite && FavoriteItemsIDs.Contains(item.ID))
            {
                FavoriteItemsIDs.Remove(item.ID);
                NotifyPropertyChanged("FavoriteItemsIDs");
            }
        }
        /// <summary>
        /// Accessories part is right bellow this comment
        /// </summary>
        
        private void btnFOBPAddAccAdd_Click(object sender, RoutedEventArgs e)
        {
            if (getEmptyValForacc())
                System.Windows.MessageBox.Show("Need to fill all the fields", "Empty Fields", MessageBoxButton.OK, MessageBoxImage.Warning);
            else
            {
                calAss();
                string unitType = cmbFOBPAddAccUnit.Text;

                string cate = cmbFOBPAddAccType.Text;
                decimal priceperunit = Convert.ToDecimal(txtFOBPAddAccPricePerUnit.Text);
                float noofunits = (float)Convert.ToDouble(txtFOBPAddAccNoOfUnits.Text);
                decimal trasnport = Convert.ToDecimal(txtFOBPAddAccCourierTransport.Text);
                DateTime date = dtsFOBPAddAccDate.SelectedDate.Value;

                if (btnFOBPAddAccAdd.Content.ToString() == "Add")
                {
                    try
                    {
                        Accessory accAdd = new Accessory();
                        accAdd.Category = cate;
                        accAdd.UnitType = unitType;
                        accAdd.PricePerUnit = priceperunit;
                        accAdd.NoOfUnits = noofunits;
                        accAdd.TransportCost = trasnport;
                        accAdd.Date = date;

                        _context.Accessories.Add(accAdd);
                        _context.SaveChanges();

                        this.accessoryDataGrid.Items.Refresh();
                        _context.Accessories.Load();
                        System.Windows.MessageBox.Show("Succesfully Added", "Done", MessageBoxButton.OK, MessageBoxImage.Information);
                    }
                    catch (Exception ex)
                    {
                        MessageBox.Show(ex.InnerException.ToString(), "Exception");
                    }


                }
                else // code to update Accessories
                {
                    try
                    {

                        string accId = lbleditAssID.Content.ToString();
                        Accessory accEdit = _context.Accessories.FirstOrDefault(i => i.AccID == accId);
                        accEdit.Category = cate;
                        accEdit.UnitType = unitType;
                        accEdit.PricePerUnit = priceperunit;
                        accEdit.NoOfUnits = noofunits;
                        accEdit.TransportCost = trasnport;
                        accEdit.Date = date;

                        _context.SaveChanges();
                        this.accessoryDataGrid.Items.Refresh();
                        _context.Accessories.Load();

                        System.Windows.MessageBox.Show("Succesfully Updated", "Done", MessageBoxButton.OK, MessageBoxImage.Information);
                    }
                    catch (Exception ex)
                    {
                        MessageBox.Show(ex.InnerException.ToString(), "Exception");
                    }


                }
                fobpdao.populateAccUnit(cmbFOBPAddAccUnit);
                fobpdao.populateAccCat(cmbFOBPAccEditCatogery);
                fobpdao.populateAccCat(cmbFOBPAddAccType);
                resetAcc();



            }
        }
Пример #9
0
 private static void clearStaticFields()
 {
     accessory = null;
     linkId = -1;
     mainType = null;
     mainTopic = null;
 }
Пример #10
0
    //初期化メソッド unitはユニット手持ちのアイテム一覧などを表示する時に使用
    public void Init(Item item, StatusManager statusManager, Unit unit, int index)
    {
        this.statusManager = statusManager;
        this.unit          = unit;
        this.item          = item;
        this.index         = index;
        icon.gameObject.SetActive(true);
        if (item.ItemType == ItemType.WEAPON)
        {
            Weapon weapon = item.weapon;
            //配下の名前、回数、値段を設定
            itemNameText.text  = weapon.name;
            enduranceText.text = string.Format("{0}/{1}", weapon.endurance.ToString(), weapon.maxEndurance.ToString());

            //200825 武器の種類によってアイコンを読み込む
            if (weapon.type == WeaponType.SHOT)
            {
                icon.sprite = iconList[0];
            }
            else if (weapon.type == WeaponType.LASER)
            {
                icon.sprite = iconList[1];
            }
            else if (weapon.type == WeaponType.STRIKE)
            {
                icon.sprite = iconList[2];
            }
            else if (weapon.type == WeaponType.HEAL)
            {
                icon.sprite = iconList[3];
            }

            //隙間に入れた場合、Unitはnullで初期化されているのでグレーアウトは発生しない
            if (unit != null)
            {
                //装備出来るかどうか確認して出来ない場合はグレーアウト
                if (WeaponEquipWarn.NONE != WeaponEquipWarnUtil.GetWeaponEquipWarn(weapon, unit))
                {
                    isEquipable         = false;
                    itemNameText.color  = new Color(170 / 255f, 170 / 255f, 170 / 255f);
                    enduranceText.color = new Color(170 / 255f, 170 / 255f, 170 / 255f);
                }
                else
                {
                    isEquipable = true;
                }
            }
        }
        else if (item.ItemType == ItemType.POTION)
        {
            Potion potion = item.potion;
            itemNameText.text  = potion.name;
            enduranceText.text = string.Format("{0}/{1}", potion.useCount.ToString(), potion.maxUseCount.ToString());

            //ステータスアップアイテムは使用可能だが、それ以外は文字をグレーアウトさせる
            if (potion.potionType != PotionType.STATUSUP)
            {
                //文字を灰色に
                itemNameText.color  = new Color(170 / 255f, 170 / 255f, 170 / 255f);
                enduranceText.color = new Color(170 / 255f, 170 / 255f, 170 / 255f);
            }

            icon.sprite = iconList[4];
        }
        else if (item.ItemType == ItemType.ACCESSORY)
        {
            Accessory accessory = item.accessory;
            itemNameText.text = accessory.name;

            //耐久は無いので非表示に
            enduranceText.enabled = false;
            icon.sprite           = iconList[8];
        }
        else if (item.ItemType == ItemType.TOOL)
        {
            Tool tool = item.tool;
            itemNameText.text = tool.name;

            //金塊
            if (tool.name == "金塊" || tool.name == "大きな金塊" || tool.name == "巨大な金塊")
            {
                enduranceText.text = "";
                icon.sprite        = iconList[6];
                //文字を灰色に
                itemNameText.color  = new Color(170 / 255f, 170 / 255f, 170 / 255f);
                enduranceText.color = new Color(170 / 255f, 170 / 255f, 170 / 255f);
            }
            else if (tool.isClassChangeItem)
            {
                enduranceText.text = "1/1";
                icon.sprite        = iconList[7];

                //これはステータス画面で使用可能
            }
            else
            {
                //これは鍵など
                enduranceText.text = "1/1";
                icon.sprite        = iconList[5];

                //鍵などはステータス画面では使えないので文字を灰色に
                itemNameText.color  = new Color(170 / 255f, 170 / 255f, 170 / 255f);
                enduranceText.color = new Color(170 / 255f, 170 / 255f, 170 / 255f);
            }
        }

        //装備しているアイテムならマークを表示
        if (item.isEquip)
        {
            equipMark.SetActive(true);
        }
        else
        {
            equipMark.SetActive(false);
        }
    }
        private void AddNewRental(object sender, EventArgs e)
        {
            string inputAccessory = AccessoryId.Text;
            string inputClient    = ClientId.Text;
            int    x;
            int    y;

            if (int.TryParse(inputAccessory, out x) && int.TryParse(inputClient, out y))
            {
                using (var ctx = new PetRentalContext()) {
                    var rentals = ctx.Rentals
                                  .Include(a => a.Accessory)
                                  .ToList();
                    var acc = ctx.Accessories
                              .Where(p => p.Id == x)
                              .ToList();
                    var NotReturnedRentals = rentals
                                             .Where(b => b.ReturnDate is null)
                                             .Where(c => c.AccessoryId == x)
                                             .ToList();
                    var clients = ctx.Clients
                                  .Where(z => z.Id == y)
                                  .ToList();


                    if (NotReturnedRentals.Count == 0)
                    {
                        if (clients.Count == 1)
                        {
                            if (acc.Count == 0)
                            {
                                MessageBox.Show("This item does not exist in the database !");
                            }
                            else
                            {
                                Client    client    = clients[0];
                                Accessory accessory = acc[0];

                                var newRental = new Rental()
                                {
                                    Client = client, Accessory = accessory, RentalDate = DateTime.Now
                                };
                                ctx.Rentals.Add(newRental);
                                int result = ctx.SaveChanges();
                                if (result == 1)
                                {
                                    MessageBox.Show("Rental added !");
                                }
                            }
                        }
                        else
                        {
                            MessageBox.Show("Client not found !");
                        }
                    }
                    else
                    {
                        MessageBox.Show("This accessory is rented now !");
                    }
                }
            }
            else
            {
                MessageBox.Show("Incorrect id !");
            }
        }
Пример #12
0
    public StatusDto GetBuffedStatus(StatusDto statusDto, string name, Weapon weapon, Accessory accessory, List <Skill> skills, bool isBerserk)
    {
        //武器の補正 StausTypeがNONE以外なら何かしらバフが有る武器
        if (weapon != null)
        {
            StatusType statusType = weapon.statusType;
            //増加量
            int amount = weapon.amount;

            //クソ実装でステータスを上げる 良い方法無いかな・・・
            if (statusType == StatusType.HP)
            {
                statusDto.hp += amount;
            }
            else if (statusType == StatusType.LATK)
            {
                statusDto.latk += amount;
            }
            else if (statusType == StatusType.CATK)
            {
                statusDto.catk += amount;
            }
            else if (statusType == StatusType.AGI)
            {
                statusDto.agi += amount;
            }
            else if (statusType == StatusType.DEX)
            {
                statusDto.dex += amount;
            }
            else if (statusType == StatusType.LDEF)
            {
                statusDto.ldef += amount;
            }
            else if (statusType == StatusType.CDEF)
            {
                statusDto.cdef += amount;
            }
            else if (statusType == StatusType.LUK)
            {
                statusDto.luk += amount;
            }
            Debug.Log($"武器のステータス補正 武器名:{weapon.name} {statusType}+{amount}");
        }

        //アクセサリのバフ反映
        if (accessory != null)
        {
            //上昇量
            int amount = accessory.amount;

            if (accessory.effect == AccessoryEffectType.LDEFUP)
            {
                statusDto.ldef += amount;
            }
            else if (accessory.effect == AccessoryEffectType.LATKUP)
            {
                statusDto.latk += amount;
            }
            else if (accessory.effect == AccessoryEffectType.AGIUP)
            {
                statusDto.agi += amount;
            }
            Debug.Log($"装飾品のステータス補正 アクセサリ名:{accessory.name} {accessory.effect}+{amount}");
        }

        //TODO スキル補正
        //210226 スキル計算 増えてきたら別クラスにしても良いと思う
        if (skills.Contains(Skill.幸運))
        {
            statusDto.luk += 5;
            Debug.Log($"{name}スキル幸運 幸運+5");
        }

        if (skills.Contains(Skill.HP5))
        {
            statusDto.hp += 5;
            Debug.Log($"{name}スキル{Skill.HP5} {Skill.HP5.GetStringValue()}");
        }

        //210226 達人系スキル これはとても簡単
        if (skills.Contains(Skill.弾幕の達人) && weapon.type == WeaponType.SHOT)
        {
            statusDto.latk += 5;
            statusDto.catk += 5;
            Debug.Log($"{name}スキル{Skill.弾幕の達人} 遠距離近距離+5");
        }
        else if (skills.Contains(Skill.レーザーの達人) && weapon.type == WeaponType.LASER)
        {
            statusDto.latk += 5;
            statusDto.catk += 5;
            Debug.Log($"{name}スキル{Skill.レーザーの達人} 遠距離近距離+5");
        }
        else if (skills.Contains(Skill.武器の達人) && weapon.type == WeaponType.STRIKE)
        {
            statusDto.latk += 5;
            statusDto.catk += 5;
            Debug.Log($"{name}スキル{Skill.武器の達人} 遠距離近距離+5");
        }

        if (skills.Contains(Skill.威風堂々))
        {
            Debug.Log($"{name}スキル{Skill.威風堂々} 幸運+4、HP+4");
            statusDto.hp  += 5;
            statusDto.luk += 5;
        }

        if (isBerserk)
        {
            Debug.Log($"{name}スキル{Skill.狂化}: {Skill.狂化.GetStringValue()}");
            statusDto.latk += 4;
            statusDto.catk += 4;
        }


        //TODO バフ、デバフ補正

        //ここから上限を突破しないように設定
        if (statusDto.hp >= StatusConst.HP_MAX)
        {
            statusDto.hp = StatusConst.HP_MAX;
        }
        if (statusDto.latk >= StatusConst.LATK_MAX)
        {
            statusDto.latk = StatusConst.LATK_MAX;
        }
        if (statusDto.catk >= StatusConst.CATK_MAX)
        {
            statusDto.catk = StatusConst.CATK_MAX;
        }
        if (statusDto.agi >= StatusConst.AGI_MAX)
        {
            statusDto.agi = StatusConst.AGI_MAX;
        }
        if (statusDto.dex >= StatusConst.DEX_MAX)
        {
            statusDto.dex = StatusConst.DEX_MAX;
        }
        if (statusDto.ldef >= StatusConst.LDEF_MAX)
        {
            statusDto.ldef = StatusConst.LDEF_MAX;
        }
        if (statusDto.cdef >= StatusConst.CDEF_MAX)
        {
            statusDto.cdef = StatusConst.CDEF_MAX;
        }
        if (statusDto.luk >= StatusConst.LUK_MAX)
        {
            statusDto.luk = StatusConst.LUK_MAX;
        }
        return(statusDto);
    }
Пример #13
0
 public void Update(Accessory accessoryIn)
 {
     _accessories.ReplaceOne(accessory => accessory.Id == accessoryIn.Id, accessoryIn);
 }
Пример #14
0
 public Accessory Create(Accessory accessory)
 {
     _accessories.InsertOne(accessory);
     return(accessory);
 }
Пример #15
0
        public static int SeedBoschDiyGreenToolsGraphData(JobAssistantContext jobContext)
        {
            #region Tenants defined

            jobContext.Tenants.AddRange(new List <Tenant> {
                BoschGreenDataTenant
            });
            jobContext.SaveChanges();

            #endregion

            #region Bosch Green Tools and Accessories defined

            var tool_IXO = new Tool()
            {
                ModelNumber    = "IXO",
                Name           = "Lithium-ion Cordless Screwdriver",
                Description    = string.Empty,
                DomainId       = BoschGreenDataTenant.DomainId,
                MaterialNumber = "06039A8000"
            };

            var tool_IXO_Family_Set = new Tool()
            {
                ModelNumber    = "IXO Family Set",
                Name           = "Lithium-ion Cordless Screwdriver",
                Description    = string.Empty,
                DomainId       = BoschGreenDataTenant.DomainId,
                MaterialNumber = "06039A800M"
            };

            var tool_PSRSelect = new Tool()
            {
                ModelNumber    = "PSR Select",
                Name           = "PSR Select Cordless Screwdriver",
                Description    = "One cordless screwdriver with nine adapters.",
                DomainId       = BoschGreenDataTenant.DomainId,
                MaterialNumber = "0603977000"
            };

            var tool_EasyDrill12 = new Tool()
            {
                ModelNumber    = "EasyDrill 12",
                Name           = "EasyDrill 12",
                Description    = "Compact Lithium-ion Cordless Drill/Driver",
                DomainId       = BoschGreenDataTenant.DomainId,
                MaterialNumber = "06039B3000"
            };

            var tool_EasyDrill1200 = new Tool()
            {
                ModelNumber    = "EasyDrill 1200",
                Name           = "EasyDrill 1200",
                Description    = "Lithium-ion Cordless Two-Speed Drill/Driver",
                DomainId       = BoschGreenDataTenant.DomainId,
                MaterialNumber = "06039A210B"
            };

            var tool_PSB1800 = new Tool
            {
                ModelNumber = "PSB 1800",
                Name        = "Bosch PSB 1800 LI-2 Lithium-ion Cordless Two-speed Combi",
                Description =
                    "Its low weight of 1.3 kilograms and compact dimensions make the PSB 1800 LI-2 from Bosch one of the handiest cordless combi drills of its kind. Thanks to its maximum torque of 38 newton metres, you can even drill and drive screws in hard materials without any problems.",
                DomainId = BoschGreenDataTenant.DomainId
            };

            var tool_EasyImpact12 = new Tool
            {
                ModelNumber = "EasyImpact 12",
                Name        = "EasyImpact 12 (1 battery pack)",
                Description =
                    "The EasyImpact 12 cordless 2-speed combi drill – the universal talent in the compact class",
                DomainId       = BoschGreenDataTenant.DomainId,
                MaterialNumber = "0603983974"
            };

            var tool_ImpactDrillPSB500RE = new Tool()
            {
                ModelNumber = "PSB 500",
                Name        = "PSB 500 RE Hammer Drill [Energy Class A]",
                Description = "The PSB 500 RE is a lightweight impact drill that provides unbeatable user comfort thanks to its powerful 500 watt motor.",
                DomainId    = BoschGreenDataTenant.DomainId,
            };

            var tool_ImpactDrillPSB750RE = new Tool()
            {
                ModelNumber = "PSB 750",
                Name        = "PSB 750 RE Hammer Drill",
                Description = "The PSB 750 RCE is a compact universal impact drill that makes drilling jobs in concrete, stone, wood and steel, even at large diameters, easy for DIYers.",
                DomainId    = BoschGreenDataTenant.DomainId,
            };

            var tool_ImpactDrillPSB850_2RE = new Tool()
            {
                ModelNumber = "PSB 850 RE",
                Name        = "PSB 850 RE Hammer Drill",
                Description = "The powerful and sturdy PSB 850-2 RE impact drill is suitable for the most demanding DIYers. This impact drill also comes with exceptionally stable and well insulated aluminium housing. The keyless chuck allows you to change drill bits rapidly and simply.",
                DomainId    = BoschGreenDataTenant.DomainId,
            };

            var tool_RotaryHammerPBH2100RE = new Tool()
            {
                ModelNumber = "PSB 2100 RE",
                Name        = "PSB 2100 RE Hammer Drill",
                Description = "The PBH 2100 RE rotary hammer from Bosch is a handy and powerful tool for all common hammering, drilling or chiselling jobs. A high impact force is provided by its 550 watts of power and its pneumatic Bosch hammer mechanism with a single impact energy of 1.7 joules.",
                DomainId    = BoschGreenDataTenant.DomainId,
            };

            var tool_JigsawPST650 = new Tool()
            {
                ModelNumber = "PST 650",
                Name        = "Easy Jigsaw PST 650",
                Description = "The Easy Jigsaw PST 650 from Bosch: Easy Rider – for precise curves and straight lines",
                DomainId    = BoschGreenDataTenant.DomainId,
            };
            var tool_Jigsaw_PST700E = new Tool()
            {
                ModelNumber = "PST 700E",
                Name        = "Easy Jigsaw PST 700 E",
                Description = "The Easy Jigsaw PST 700 E from Bosch: Easy Rider – for precise curves and straight lines",
                DomainId    = BoschGreenDataTenant.DomainId,
            };
            var tool_JigSawPST900PEL = new Tool()
            {
                ModelNumber = "PST 700 PEL",
                Name        = "The Expert Jigsaw PST 900 PEL",
                Description = "The Expert Jigsaw PST 900 PEL from Bosch: With maximum precision through all materials",
                DomainId    = BoschGreenDataTenant.DomainId,
            };

            var accessory_MiniXLineZ = new Accessory()
            {
                Name           = "Mini-X-Line drill bit set, spirit level, hand screwdriver",
                Description    = "Metal and masonry drill bit set, spirit level with screwdriver bits and hand screwdriver.",
                DomainId       = BoschGreenDataTenant.DomainId,
                MaterialNumber = "2607017200"
            };

            #endregion

            #region Bosch Green Jobs defined

            var screwDrivingJob = new Job
            {
                JobId    = 8100,
                Name     = "Screw-driving",
                DomainId = BoschGreenDataTenant.DomainId
            };
            var drillingAndChisellingJob = new Job
            {
                JobId    = 8101,
                Name     = "Drilling and Chi-selling",
                DomainId = BoschGreenDataTenant.DomainId
            };
            var drillingAndChisellingMortisingJob = new Job
            {
                JobId    = 8102,
                Name     = "Drilling, Chi-selling and Mortising",
                DomainId = BoschGreenDataTenant.DomainId
            };
            var sawingJob = new Job()
            {
                JobId    = 8103,
                Name     = "Sawing",
                DomainId = BoschGreenDataTenant.DomainId
            };
            var sandingJob = new Job()
            {
                JobId    = 8104,
                Name     = "Sanding Wood Surfaces",
                DomainId = BoschGreenDataTenant.DomainId
            };
            var gridingAndCuttingJob = new Job()
            {
                JobId    = 8105,
                Name     = "Grinding and Cutting Metal",
                DomainId = BoschGreenDataTenant.DomainId
            };

            var plantingAndRoutingJob = new Job()
            {
                JobId    = 8106,
                Name     = "Planting and Routing",
                DomainId = BoschGreenDataTenant.DomainId
            };

            var measuringAndLevelingJob = new Job()
            {
                JobId    = 8107,
                Name     = "Measuring, Leveling and Detecting",
                DomainId = BoschGreenDataTenant.DomainId
            };

            var paintingJob = new Job()
            {
                JobId    = 8108,
                Name     = "Working with Paint and Wallpaper",
                DomainId = BoschGreenDataTenant.DomainId
            };

            var craftingJob = new Job()
            {
                JobId    = 8109,
                Name     = "Crafting, Repairing and Cleaning, Decorating",
                DomainId = BoschGreenDataTenant.DomainId
            };

            var layingTilesJob = new Job()
            {
                JobId    = 8110,
                Name     = "Laying Tiles",
                DomainId = BoschGreenDataTenant.DomainId
            };

            var layingFloorJob = new Job()
            {
                JobId    = 8111,
                Name     = "Laying a Floor",
                DomainId = BoschGreenDataTenant.DomainId
            };

            jobContext.Jobs.AddRange(new List <Job>
            {
                screwDrivingJob,
                drillingAndChisellingJob,
                drillingAndChisellingMortisingJob,
                sawingJob,
                sandingJob,
                gridingAndCuttingJob,
                plantingAndRoutingJob,
                measuringAndLevelingJob,
                paintingJob,
                craftingJob,
                layingTilesJob,
                layingFloorJob
            });

            #endregion

            var easyMaterialForScrewDriving = new Material()
            {
                Name = "Easy Material", Tools = new List <Tool>(), DomainId = BoschGreenDataTenant.DomainId
            };
            easyMaterialForScrewDriving.Tools.Add(tool_IXO);
            easyMaterialForScrewDriving.Tools.Add(tool_EasyImpact12);
            easyMaterialForScrewDriving.Tools.Add(tool_ImpactDrillPSB500RE);

            var mediumMaterialForScrewDriving = new Material()
            {
                Name = "Medium Material", Tools = new List <Tool>(), DomainId = BoschGreenDataTenant.DomainId
            };
            mediumMaterialForScrewDriving.Tools.Add(tool_ImpactDrillPSB750RE);

            var hardMaterialForScrewDriving = new Material()
            {
                Name = "Hard Material", Tools = new List <Tool>(), DomainId = BoschGreenDataTenant.DomainId
            };
            hardMaterialForScrewDriving.Tools.Add(tool_ImpactDrillPSB850_2RE);

            screwDrivingJob.Materials = new List <Material> {
                easyMaterialForScrewDriving, mediumMaterialForScrewDriving, hardMaterialForScrewDriving
            };

            var easyMaterialDrillingAndChiselling = new Material()
            {
                Name = "Easy Material", Tools = new List <Tool>(), DomainId = BoschGreenDataTenant.DomainId
            };
            easyMaterialDrillingAndChiselling.Tools.Add(tool_ImpactDrillPSB500RE);

            var mediumMaterialDrillingAndChiselling = new Material()
            {
                Name = "Medium Material", Tools = new List <Tool>(), DomainId = BoschGreenDataTenant.DomainId
            };
            mediumMaterialDrillingAndChiselling.Tools.Add(tool_ImpactDrillPSB750RE);
            drillingAndChisellingJob.Materials = new List <Material>
            {
                mediumMaterialDrillingAndChiselling
            };

            var hardMaterialDrillingAndChiselling = new Material()
            {
                Name = "Hard Material", Tools = new List <Tool>(), DomainId = BoschGreenDataTenant.DomainId
            };
            hardMaterialDrillingAndChiselling.Tools.Add(tool_ImpactDrillPSB850_2RE);

            drillingAndChisellingJob.Materials = new List <Material> {
                easyMaterialDrillingAndChiselling, mediumMaterialDrillingAndChiselling, hardMaterialDrillingAndChiselling
            };

            var easyMaterialForDrillingChisellingAndMortising = new Material()
            {
                Name = "Medium Material", Tools = new List <Tool>(), DomainId = BoschGreenDataTenant.DomainId
            };
            easyMaterialForDrillingChisellingAndMortising.Tools.Add(tool_RotaryHammerPBH2100RE);

            drillingAndChisellingMortisingJob.Materials = new List <Material>()
            {
                easyMaterialForDrillingChisellingAndMortising
            };

            // Create materials and associate sample tools to material(s).
            //
            var easyMaterialForSawing = new Material {
                Name = "Easy Material", Tools = new List <Tool> {
                    tool_JigsawPST650, tool_Jigsaw_PST700E
                }, DomainId = BoschGreenDataTenant.DomainId
            };
            var hardMaterialForSawing = new Material()
            {
                Name = "Hard Material", Tools = new List <Tool> {
                    tool_JigSawPST900PEL
                }, DomainId = BoschGreenDataTenant.DomainId
            };

            sawingJob.Materials = new List <Material>()
            {
                easyMaterialForSawing, hardMaterialForSawing
            };

            // Create materials and associate sample tools to material(s).
            //
            sandingJob.Materials = new List <Material>();

            // Create materials and associate sample tools to material(s).
            //
            gridingAndCuttingJob.Materials = new List <Material>();

            // Create materials and associate sample tools to material(s).
            //
            plantingAndRoutingJob.Materials = new List <Material>();

            // Create materials and associate sample tools to material(s).
            //
            measuringAndLevelingJob.Materials = new List <Material>();

            // Create materials and associate sample tools to material(s).
            //
            paintingJob.Materials = new List <Material>();

            // Create materials and associate sample tools to material(s).
            //
            craftingJob.Materials = new List <Material>();

            // Create materials and associate sample tools to material(s).
            //
            layingTilesJob.Materials = new List <Material>();

            // Create materials and associate sample tools to material(s).
            //
            layingFloorJob.Materials = new List <Material>();

            /***
             * Using the ".Materials" collection, ADD associate materials for the job.
             * Then, using the ".Tools" collection, ADD tools and associate materials for other jobs including:
             *
             *  drillingAndChisellingMortisingJob,
             *  sawingJob,
             *  sandingJob,
             *  gridingAndCuttingJob,
             *  plantingAndRoutingJob,
             *  measuringAndLevelingJob,
             *  paintingJob,
             *  craftingJob,
             *  layingTilesJob,
             *  layingFloorJob
             */

            var cordlessToolsCategory = new Category
            {
                Name     = "Bosch - Cordless Tools Cordless Tools",
                DomainId = BoschGreenDataTenant.DomainId
            };
            jobContext.Categories.Add(cordlessToolsCategory);

            var impactDrillsCategory = new Category {
                Name = "Impact Drills", DomainId = BoschGreenDataTenant.DomainId
            };
            jobContext.Categories.Add(impactDrillsCategory);

            var rotaryHammersCategory =
                new Category {
                Name = "Rotary hammers", DomainId = BoschGreenDataTenant.DomainId
            };
            jobContext.Categories.Add(rotaryHammersCategory);

            var sawsCategory = new Category {
                Name = "Saws", DomainId = BoschGreenDataTenant.DomainId
            };
            jobContext.Categories.Add(sawsCategory);

            var benchtopToolsCategory =
                new Category {
                Name = "Benchtop tools", DomainId = BoschGreenDataTenant.DomainId
            };
            jobContext.Categories.Add(benchtopToolsCategory);

            cordlessToolsCategory.Tools = new List <Tool> {
                tool_IXO, tool_IXO_Family_Set, tool_PSRSelect, tool_EasyDrill12, tool_EasyDrill1200, tool_PSB1800
            };
            cordlessToolsCategory.Accessories = new List <Accessory> {
                accessory_MiniXLineZ
            };

            var savedCount = jobContext.SaveChanges();
            return(savedCount);
        }
Пример #16
0
        protected void submit_Click(object sender, EventArgs e)
        {
            string[] content = Request.Form.GetValues("TA");
            for (int i = 0; i < ProblemList.Count; i++)
            {
                Answer answer = new Answer();
                answer.content = content[i];
                answer.student = stu.username;
                answer.problem = ProblemList[i].id;
                answer.score   = (float)0.0;
                answer.comment = "no comment";
                answer.major   = stu.major;
                answer.state   = "2";
                if (AnswerList == null)
                {
                    AnswerList = new List <Answer>();
                }
                AnswerList.Add(answer);
            }

            if (submitFlag)
            {
                AnswerMan.AddAnswer(AnswerList);

                if (accessory == null)
                {
                    accessory = new Accessory();
                }

                try
                {
                    //获取上传文件的路径
                    string filepath = FileUpload2.PostedFile.FileName;
                    //获取后缀名
                    int filepos = filepath.LastIndexOf(".");
                    //截取后缀名
                    String strfilename = filepath.Substring(filepos);
                    //获取时间
                    string time1 = System.DateTime.Now.ToString("yyyyMMddHHmmssffff");
                    //保存到服务器的路径,这是我们网站固定网址
                    string serverpath = Server.MapPath("Accessory") + "\\" + stu.username + "_" + id + "_" + time1 + strfilename;
                    //确定上传文件
                    FileUpload2.PostedFile.SaveAs(serverpath);

                    string DBFilePath = "http://tasksystem.apphb.com/Accessory/" + stu.username + "_" + id + "_" + time1 + strfilename;
                    accessory.adress     = DBFilePath;
                    accessory.assignment = System.Int32.Parse(id);
                    accessory.student    = stu.username;
                    AccessoryMan.Create(accessory);
                }
                catch (System.Exception error)
                {
                    Response.Write(error.Message.ToString());
                }
            }
            else
            {
                AnswerMan.UpdateAnswer(AnswerList);
                //accessory = AccessoryMan.GetAccessory(stu.username, System.Int32.Parse(id));
            }

            //Response.Redirect("StudentMainForm.aspx");
            Response.Write("<script language=javascript>alert('提交成功!');location='StudentMainForm.aspx'</script>");
        }
Пример #17
0
        static void Main(string[] args)
        {
            Accessory.WelcomeMessageAndInitParameters();

            string currentCommand;

            // Creating factory of ftp methods
            FtpMethodFactory factory = new FtpMethodFactory();

            // Registers all implemented ftp methods
            factory.Register <DirectoryList>("ls");
            factory.Register <DownloadFile>("dl");
            factory.Register <ChangeDirectory>("cd");

            // Filling dictionary with commands
            // First param is key=command, second param is func which processes this command
            // Dictionary consists of delegate to provide flexibility. You can pass both simple
            // one-line method like 'exit' and whole method of some class.

            // There's three ways to add commands to dictionary: in constructor, by Add method
            // of Dictionary class and by wrapper method DefineOperation

            // In constructor...
            commands = new Dictionary <string, Command>
            {
                { "exit", (dummy) => Environment.Exit(0) },
            };

            // By using Dictionary.Add method
            // Note: you needn't construct whole class, just code small simple lambda methods
            commands.Add("help", (dummy) => {
                using (StreamReader file = new StreamReader("../readme.txt"))
                {
                    Console.WriteLine(file.ReadToEnd());
                }
                return;
            });

            // And by shell-method DefineOperation
            string[] aliases = new string[] { "ls", "dl", "cd" };

            // Adds aliases and its appropriate fucntions to commands dictionary
            foreach (string alias in aliases)
            {
                DefineOperation(alias, factory);
            }

            Console.WriteLine();
            commands["ls"]();

            // Program main loop
            // Processes commands until 'exit' found
            do
            {
                Console.Write("{0}>", AbstractFtpMethod.FtpUri);
                currentCommand = Console.ReadLine();

                // Splt arguments to get them into function
                string[] currentArguments = Accessory.ParseArguments(ref currentCommand);

                // Invokes the appropriate func
                if (commands.ContainsKey(currentCommand))
                {
                    commands[currentCommand](currentArguments);
                }
            } while (currentCommand != "exit");

            Console.ReadKey();
        }
 private void AddRecentItem(Accessory item)
 {
     if (item != null)
     {
         if (RecentItemsIDs.Any(id => id == item.ID))
         {
             if (RecentItemsIDs.IndexOf(item.ID) != 0)
             {
                 RecentItemsIDs.Remove(item.ID);
                 RecentItemsIDs.Insert(0, item.ID);
                 NotifyPropertyChanged(nameof(RecentItemsIDs));
             }
         }
         else
         {
             RecentItemsIDs.Insert(0, item.ID);
             NotifyPropertyChanged(nameof(RecentItemsIDs));
         }
     }
 }
Пример #19
0
 public void UpdateText(Accessory accessory)
 {
     this.itemName.text   = accessory.name;
     this.detailText.text = accessory.annotationText;
     icon.sprite          = iconList[4];
 }
Пример #20
0
        /// <summary>��������� �� ���������</summary>
        private void fillFromPrev()
        {
            //��������� ��������, � �� �� ��������
            string currBarcode = accessory.BarCode;
            Accessory lastObj;

            //�������� ������ ���������� ��������������
            if (Accessory.GetLastAccesory(currentType, out lastObj))
                {
                accessory = lastObj.CopyWithoutLinks();
                MainProcess.ClearControls();
                accessory.Status = TypesOfLampsStatus.Storage;

                accessory.ClearPosition();
                showData(false, currBarcode);
                }
        }
Пример #21
0
 // Implement this method in a buddy class to set properties that are specific to 'Accessory' (if any)
 partial void Merge(Accessory entity, ItemDTO dto, object state);
Пример #22
0
 private void attach_Accessories(Accessory entity)
 {
     this.SendPropertyChanging("Accessories");
     entity.Dealer = this;
 }
Пример #23
0
 private void button_Send_Click(object sender, EventArgs e)
 {
     if (comboBox_Printer.Items.Count > 0 && comboBox_Printer.SelectedItem.ToString() != "")
     {
         if (textBox_command.Text + textBox_param.Text != "")
         {
             string outStr;
             if (checkBox_hexCommand.Checked)
             {
                 outStr = textBox_command.Text;
             }
             else
             {
                 outStr = Accessory.ConvertStringToHex(textBox_command.Text);
             }
             if (checkBox_hexParam.Checked)
             {
                 outStr += textBox_param.Text;
             }
             else
             {
                 outStr += Accessory.ConvertStringToHex(textBox_param.Text);
             }
             if (outStr != "")
             {
                 if (checkBox_hexTerminal.Checked)
                 {
                     collectBuffer(outStr, Port1DataOut);
                 }
                 else
                 {
                     collectBuffer(Accessory.ConvertHexToString(outStr), Port1DataOut);
                 }
                 textBox_command.AutoCompleteCustomSource.Add(textBox_command.Text);
                 textBox_param.AutoCompleteCustomSource.Add(textBox_param.Text);
                 RawPrinterSender.SendRAWToPrinter(comboBox_Printer.SelectedItem.ToString(), Accessory.ConvertHexToByteArray(outStr));
             }
         }
     }
 }
Пример #24
0
        /// <summary>�������� ���������� ������������� (� ����������� � ��������� �� ������� �������� ��������)</summary>
        /// <param name="typeOfAccessories">��� ��������������</param>
        /// <param name="accessory">������</param>
        /// <param name="topic">���������</param>
        /// <param name="listOfDetail">������� ��������� � ��������� �����������</param>
        /// <returns>������ ...</returns>
        public static List<LabelForConstructor> GetVisualPresenter(TypeOfAccessories typeOfAccessories, Accessory accessory, out string topic, out Dictionary<string, KeyValuePair<Type, object>> listOfDetail)
        {
            topic = Cases.GetDescriptionOfAccessory(typeOfAccessories);
            listOfDetail = new Dictionary<string, KeyValuePair<Type, object>>();
            List<LabelForConstructor> list = new List<LabelForConstructor>();

            bool notCase = (typeOfAccessories == TypeOfAccessories.ElectronicUnit ||
                            typeOfAccessories == TypeOfAccessories.Lamp);
            if (accessory != null)
                {
                Type type = accessory.GetType();
                PropertyInfo[] fields = type.GetProperties();

                if (notCase)
                    {
                    listOfDetail.Add("������", new KeyValuePair<Type, object>(typeof(Cases), CatalogHelper.FindCaseId(accessory.Id, typeOfAccessories)));
                    }

                foreach (PropertyInfo field in fields)
                    {
                    if (notCase && field.Name == "Case")
                        {
                        continue;
                        }
                    Attribute[] attributes = Attribute.GetCustomAttributes(field);

                    foreach (Attribute a in attributes)
                        {
                        dbFieldAtt attribute = a as dbFieldAtt;

                        if (attribute != null)
                            {
                            if (attribute.NeedDetailInfo)
                                {
                                object value = field.GetValue(accessory, null);
                                listOfDetail.Add(attribute.Description, new KeyValuePair<Type, object>(attribute.dbObjectType, value));
                                }
                            else if (!attribute.NotShowInForm || attribute.ShowEmbadedInfo)
                                {
                                object value = field.GetValue(accessory, null);

                                if (attribute.dbObjectType == null)
                                    {
                                    if (field.PropertyType == typeof(DateTime))
                                        {
                                        DateTime dateValue = (DateTime)value;

                                        value = dateValue != SqlDateTime.MinValue.Value
                                                    ? String.Format("{0:dd.MM.yyyy}", dateValue)
                                                    : string.Empty;
                                        }
                                    else if (field.PropertyType.IsEnum)
                                        {
                                        value = EnumWorker.GetDescription(field.PropertyType, Convert.ToInt32(value));
                                        }
                                    else if (field.PropertyType == typeof(bool))
                                        {
                                        value = (bool)value ? "+" : "-";
                                        }
                                    }
                                else
                                    {
                                    if (attribute.ShowEmbadedInfo)
                                        {
                                        dbObject detailObject = (dbObject)Activator.CreateInstance(attribute.dbObjectType);
                                        detailObject = (dbObject)detailObject.Read(attribute.dbObjectType, value, IDENTIFIER_NAME);
                                        Dictionary<string, KeyValuePair<Type, object>> subListOfDetail;
                                        List<LabelForConstructor> subList = GetSingleVisualPresenter(
                                            attribute.dbObjectType, out subListOfDetail, detailObject, false);

                                        list.AddRange(subList);
                                        }

                                    if (!attribute.NotShowInForm)
                                        {
                                        value = ReadDescription(attribute.dbObjectType, value);
                                        }
                                    }

                                string data = String.Format("{0}: {1}", attribute.Description, value);

                                list.Add(new LabelForConstructor(data, ControlsStyle.LabelSmall, false));
                                break;
                                }
                            }
                        }
                    }
                }

            return list;
        }
Пример #25
0
        private async void button_sendFile_ClickAsync(object sender, EventArgs e)
        {
            if (SendComing > 0)
            {
                SendComing++;
            }
            else if (SendComing == 0)
            {
                UInt16 repeat = 1, delay = 1, strDelay = 1;

                if (textBox_fileName.Text != "" && textBox_sendNum.Text != "" && UInt16.TryParse(textBox_sendNum.Text, out repeat) && UInt16.TryParse(textBox_delay.Text, out delay) && UInt16.TryParse(textBox_strDelay.Text, out strDelay))
                {
                    SendComing               = 1;
                    button_Send.Enabled      = false;
                    button_openFile.Enabled  = false;
                    button_sendFile.Text     = "Stop";
                    textBox_fileName.Enabled = false;
                    textBox_sendNum.Enabled  = false;
                    textBox_delay.Enabled    = false;
                    textBox_strDelay.Enabled = false;
                    for (int n = 0; n < repeat; n++)
                    {
                        string outStr = "";
                        string outErr = "";
                        long   length = 0;
                        if (repeat > 1)
                        {
                            collectBuffer(" Send cycle " + (n + 1).ToString() + "/" + repeat.ToString() + ">> ", 0);
                        }
                        try
                        {
                            length = new FileInfo(textBox_fileName.Text).Length;
                        }
                        catch (Exception ex)
                        {
                            MessageBox.Show("\r\nError opening file " + textBox_fileName.Text + ": " + ex.Message);
                        }
                        if (comboBox_Printer.Items.Count > 0 && comboBox_Printer.SelectedItem.ToString() != "")
                        {
                            //binary file read
                            if (!checkBox_hexFileOpen.Checked)
                            {
                                //byte-by-byte
                                if (radioButton_byByte.Checked)
                                {
                                    byte[] tmpBuffer = new byte[length];
                                    try
                                    {
                                        tmpBuffer = File.ReadAllBytes(textBox_fileName.Text);
                                    }
                                    catch (Exception ex)
                                    {
                                        MessageBox.Show("\r\nError reading file " + textBox_fileName.Text + ": " + ex.Message);
                                    }
                                    for (int l = 0; l < tmpBuffer.Length; l++)
                                    {
                                        byte[] outByte = { tmpBuffer[l] };
                                        if (checkBox_hexTerminal.Checked)
                                        {
                                            outStr = Accessory.ConvertByteArrayToHex(tmpBuffer, tmpBuffer.Length);
                                        }
                                        else
                                        {
                                            outStr = Encoding.GetEncoding(RawPrnControl.Properties.Settings.Default.CodePage).GetString(tmpBuffer);
                                        }
                                        collectBuffer(outStr, Port1DataOut);

                                        if (RawPrinterSender.SendRAWToPrinter(comboBox_Printer.SelectedItem.ToString(), outByte))
                                        {
                                            progressBar1.Value = (n * tmpBuffer.Length + l) * 100 / (repeat * tmpBuffer.Length);
                                            if (strDelay > 0)
                                            {
                                                await TaskEx.Delay(strDelay);
                                            }
                                        }
                                        else
                                        {
                                            collectBuffer("Byte " + l.ToString() + ": Write Failure", Port1Error);
                                        }
                                        if (SendComing > 1)
                                        {
                                            l = tmpBuffer.Length;
                                        }
                                    }
                                }
                                //stream
                                else
                                {
                                    byte[] tmpBuffer = new byte[length];
                                    try
                                    {
                                        tmpBuffer = File.ReadAllBytes(textBox_fileName.Text);
                                    }
                                    catch (Exception ex)
                                    {
                                        MessageBox.Show("\r\nError reading file " + textBox_fileName.Text + ": " + ex.Message);
                                    }
                                    int r = 0;
                                    while (r < 10 && !RawPrinterSender.SendRAWToPrinter(comboBox_Printer.SelectedItem.ToString(), tmpBuffer))
                                    {
                                        collectBuffer("USB write retry " + r.ToString(), Port1Error);
                                        await TaskEx.Delay(100);

                                        r++;
                                    }
                                    if (r >= 10)
                                    {
                                        outErr = "Block write failure";
                                    }
                                    if (checkBox_hexTerminal.Checked)
                                    {
                                        outStr = Accessory.ConvertByteArrayToHex(tmpBuffer, tmpBuffer.Length);
                                    }
                                    else
                                    {
                                        outStr = Encoding.GetEncoding(RawPrnControl.Properties.Settings.Default.CodePage).GetString(tmpBuffer);
                                    }
                                    if (outErr != "")
                                    {
                                        collectBuffer(outErr + ": start", Port1Error);
                                    }
                                    collectBuffer(outStr, Port1DataOut);
                                    if (outErr != "")
                                    {
                                        collectBuffer(outErr + ": end", Port1Error);
                                    }
                                    progressBar1.Value = ((n * tmpBuffer.Length) * 100) / (repeat * tmpBuffer.Length);
                                }
                            }
                            //hex file read
                            else
                            {
                                //String-by-string
                                if (radioButton_byString.Checked)
                                {
                                    String[] tmpBuffer = { };
                                    try
                                    {
                                        tmpBuffer = File.ReadAllText(textBox_fileName.Text).Replace('\n', '\r').Replace("\r\r", "\r").Split('\r');
                                    }
                                    catch (Exception ex)
                                    {
                                        MessageBox.Show("\r\nError reading file " + textBox_fileName.Text + ": " + ex.Message);
                                    }
                                    for (int l = 0; l < tmpBuffer.Length; l++)
                                    {
                                        if (tmpBuffer[l] != "")
                                        {
                                            tmpBuffer[l] = Accessory.CheckHexString(tmpBuffer[l]);
                                            collectBuffer(outStr, Port1DataOut);
                                            if (RawPrinterSender.SendRAWToPrinter(comboBox_Printer.SelectedItem.ToString(), Accessory.ConvertHexToByteArray(tmpBuffer[l])))
                                            {
                                                if (checkBox_hexTerminal.Checked)
                                                {
                                                    outStr = tmpBuffer[l];
                                                }
                                                else
                                                {
                                                    outStr = Accessory.ConvertHexToString(tmpBuffer[l]);
                                                }
                                                if (strDelay > 0)
                                                {
                                                    await TaskEx.Delay(strDelay);
                                                }
                                            }
                                            else  //??????????????
                                            {
                                                outErr = "String" + l.ToString() + ": Write failure";
                                            }
                                            if (SendComing > 1)
                                            {
                                                l = tmpBuffer.Length;
                                            }
                                            collectBuffer(outErr, Port1Error);
                                            progressBar1.Value = (n * tmpBuffer.Length + l) * 100 / (repeat * tmpBuffer.Length);
                                        }
                                    }
                                }
                                //byte-by-byte
                                if (radioButton_byByte.Checked)
                                {
                                    string tmpStrBuffer = "";
                                    try
                                    {
                                        tmpStrBuffer = Accessory.CheckHexString(File.ReadAllText(textBox_fileName.Text));
                                    }
                                    catch (Exception ex)
                                    {
                                        MessageBox.Show("Error reading file " + textBox_fileName.Text + ": " + ex.Message);
                                    }
                                    byte[] tmpBuffer = new byte[tmpStrBuffer.Length / 3];
                                    tmpBuffer = Accessory.ConvertHexToByteArray(tmpStrBuffer);
                                    for (int l = 0; l < tmpBuffer.Length; l++)
                                    {
                                        byte[] outByte = { tmpBuffer[l] };
                                        if (checkBox_hexTerminal.Checked)
                                        {
                                            outStr = Accessory.ConvertByteArrayToHex(tmpBuffer, tmpBuffer.Length);
                                        }
                                        else
                                        {
                                            outStr = Encoding.GetEncoding(RawPrnControl.Properties.Settings.Default.CodePage).GetString(tmpBuffer);
                                        }
                                        collectBuffer(outStr, Port1DataOut);
                                        if (RawPrinterSender.SendRAWToPrinter(comboBox_Printer.SelectedItem.ToString(), outByte))
                                        {
                                            progressBar1.Value = (n * tmpBuffer.Length + l) * 100 / (repeat * tmpBuffer.Length);
                                            if (strDelay > 0)
                                            {
                                                await TaskEx.Delay(strDelay);
                                            }
                                        }
                                        else
                                        {
                                            collectBuffer("Byte " + l.ToString() + ": Write Failure", Port1Error);
                                        }
                                        if (SendComing > 1)
                                        {
                                            l = tmpBuffer.Length;
                                        }
                                    }
                                }
                                //stream
                                else
                                {
                                    string tmpStrBuffer = "";
                                    try
                                    {
                                        tmpStrBuffer = Accessory.CheckHexString(File.ReadAllText(textBox_fileName.Text));
                                    }
                                    catch (Exception ex)
                                    {
                                        MessageBox.Show("Error reading file " + textBox_fileName.Text + ": " + ex.Message);
                                    }
                                    byte[] tmpBuffer = new byte[tmpStrBuffer.Length / 3];
                                    tmpBuffer = Accessory.ConvertHexToByteArray(tmpStrBuffer);
                                    int r = 0;
                                    while (r < 10 && !RawPrinterSender.SendRAWToPrinter(comboBox_Printer.SelectedItem.ToString(), tmpBuffer))
                                    {
                                        collectBuffer("USB write retry " + r.ToString(), Port1Error);
                                        await TaskEx.Delay(100);

                                        r++;
                                    }
                                    if (r >= 10)
                                    {
                                        outErr = "Block write failure";
                                    }
                                    if (checkBox_hexTerminal.Checked)
                                    {
                                        outStr = Accessory.ConvertByteArrayToHex(tmpBuffer, tmpBuffer.Length);
                                    }
                                    else
                                    {
                                        outStr = Encoding.GetEncoding(RawPrnControl.Properties.Settings.Default.CodePage).GetString(tmpBuffer);
                                    }
                                    if (outErr != "")
                                    {
                                        collectBuffer(outErr + " start", Port1Error);
                                    }
                                    collectBuffer(outStr, Port1DataOut);
                                    if (outErr != "")
                                    {
                                        collectBuffer(outErr + " end", Port1Error);
                                    }
                                    progressBar1.Value = ((n * tmpBuffer.Length) * 100) / (repeat * tmpBuffer.Length);
                                }
                            }
                        }
                        if (repeat > 1)
                        {
                            await TaskEx.Delay(delay);
                        }
                        if (SendComing > 1)
                        {
                            n = repeat;
                        }
                    }
                    button_Send.Enabled      = true;
                    button_openFile.Enabled  = true;
                    button_sendFile.Text     = "Send file";
                    textBox_fileName.Enabled = true;
                    textBox_sendNum.Enabled  = true;
                    textBox_delay.Enabled    = true;
                    textBox_strDelay.Enabled = true;
                }
                SendComing = 0;
            }
        }
 /// <summary>
 /// Create a new Accessory object.
 /// </summary>
 /// <param name="productID">Initial value of ProductID.</param>
 /// <param name="systemName">Initial value of SystemName.</param>
 public static Accessory CreateAccessory(int productID, string systemName)
 {
     Accessory accessory = new Accessory();
     accessory.ProductID = productID;
     accessory.SystemName = systemName;
     return accessory;
 }
Пример #27
0
        public async static Task GenerateProductList()
        {
            var saddles = await App.storeManager.SaddleStore.GetItemsAsync(false, true);

            var accessory = await App.storeManager.AccessoryStore.GetItemsAsync(false, true);

            var service = await App.storeManager.ServiceStore.GetItemsAsync(false, true);

            var saddle_attrs = await App.storeManager.SaddleStore.GetSaddleAttributes();

            var saddle_values = await App.storeManager.SaddleStore.GetSaddleValue();

            var saddke_models = await App.storeManager.SaddleStore.GetSaddleModel();


            if (saddle_attrs != null)
            {
                SaddleAttributes.AddRange(saddle_attrs);
            }

            if (saddke_models != null)
            {
                SaddleModels.AddRange(saddke_models);
            }

            if (saddle_values != null)
            {
                SaddleValues.AddRange(saddle_values);
            }


            List <string> SaddleModel = new List <string>();

            List <string> SaddleColor = new List <string>();

            List <string> SaddleLeather = new List <string>();

            List <string> ServiceModel = new List <string>();

            List <string> ServiceSubCategoryModel = new List <string>();

            List <string> AccessoryModel = new List <string>();

            List <string> AccessoryCategory = new List <string>();

            List <string> AccessorySubCategory = new List <string>();


            if (saddles.Any())
            {
                SaddleModel.AddRange(saddles.Select((arg) => string.IsNullOrWhiteSpace(arg.Name) ? "N.A" : arg.Name));

                SaddleLeather.AddRange(saddles.Select((arg) => string.IsNullOrWhiteSpace(arg.Leather) ? "N.A" : arg.Leather));
                Saddles.Clear();

                Saddles.AddRange(saddles);
            }

            if (service.Any())
            {
                ServiceModel.AddRange(service.Select((arg) => string.IsNullOrWhiteSpace(arg.Name) ? "N.A" : arg.Name));
                ServiceSubCategoryModel.AddRange(service.Select((arg) => string.IsNullOrWhiteSpace(arg.SubCategoryName) ? "N.A" : arg.SubCategoryName));
                Services.Clear();
                Services.AddRange(service);
            }

            if (accessory.Any())
            {
                AccessoryModel.AddRange(accessory.Select((arg) => string.IsNullOrWhiteSpace(arg.Name) ? "N.A" : arg.Name));
                AccessoryCategory.AddRange(accessory.Select((arg) => string.IsNullOrWhiteSpace(arg.CategoryName) ? "N.A" : arg.CategoryName));
                AccessorySubCategory.AddRange(accessory.Select((arg) => string.IsNullOrWhiteSpace(arg.SubCategoryName) ? "N.A" : arg.SubCategoryName));

                Accessory.Clear();
                Accessory.AddRange(accessory);
            }

            SaddleModel = SaddleModel.Distinct().ToList();

            SaddleColor.Add("Black");
            SaddleColor.Add("Brown");

            SaddleLeather = SaddleLeather.Distinct().ToList();

            ServiceModel = ServiceModel.Distinct().ToList();

            ServiceSubCategoryModel = ServiceSubCategoryModel.Distinct().ToList();

            AccessoryModel = AccessoryModel.Distinct().ToList();

            AccessoryCategory = AccessoryCategory.Distinct().ToList();

            AccessorySubCategory = AccessorySubCategory.Distinct().ToList();

            foreach (var item in Saddles)
            {
                if (string.IsNullOrWhiteSpace(item.Name))
                {
                    item.Name = "N.A";
                }
                if (string.IsNullOrWhiteSpace(item.Leather))
                {
                    item.Leather = "N.A";
                }
            }

            foreach (var item in Services)
            {
                if (string.IsNullOrWhiteSpace(item.Name))
                {
                    item.Name = "N.A";
                }
                if (string.IsNullOrWhiteSpace(item.SubCategoryName))
                {
                    item.SubCategoryName = "N.A";
                }
            }

            foreach (var item in Accessory)
            {
                if (string.IsNullOrWhiteSpace(item.Name))
                {
                    item.Name = "N.A";
                }
                if (string.IsNullOrWhiteSpace(item.CategoryName))
                {
                    item.CategoryName = "N.A";
                }
                if (string.IsNullOrWhiteSpace(item.SubCategoryName))
                {
                    item.SubCategoryName = "N.A";
                }
            }


            Products.Clear();

            Products.Add(new Product()
            {
                Description = "Saddle",
                Name        = "Saddle",
                Name_FR     = AppResources.P_Saddle,
                ProductKind = ProductKind.saddle,
                Properties  = new List <ProductProperty>()
                {
                    new ProductProperty(PropertyType.IsText)
                    {
                        PropertyName = "Rider Name", PropertyValue = null, PropertyName_FR = AppResources.P_RiderName
                    },
                    new ProductProperty(PropertyType.IsPicker)
                    {
                        PropertyName = "Model", PropertyName_FR = AppResources.P_Model, PropertyValue = null, ItemSource = SaddleModel
                    },

                    new ProductProperty(PropertyType.IsBoolean)
                    {
                        PropertyName = "2nd Skin", PropertyValue = null, PropertyName_FR = AppResources.P_2ndSkin
                    },
                    new ProductProperty(PropertyType.IsBoolean)
                    {
                        PropertyName = "RBQ grained", PropertyValue = null, PropertyName_FR = AppResources.P_RBQgrained
                    },

                    new ProductProperty(PropertyType.IsText)
                    {
                        PropertyName = "Seat", PropertyValue = null, PropertyName_FR = AppResources.P_Seat
                    },
                    new ProductProperty(PropertyType.IsText)
                    {
                        PropertyName = "Tree", PropertyValue = null, PropertyName_FR = AppResources.P_Tree
                    },
                    new ProductProperty(PropertyType.IsText)
                    {
                        PropertyName = "Flaps", PropertyValue = null, PropertyName_FR = AppResources.P_Flaps
                    },



                    new ProductProperty(PropertyType.IsPicker)
                    {
                        PropertyName = "Color", PropertyName_FR = AppResources.P_Color
                    },
                    new ProductProperty(PropertyType.IsPicker)
                    {
                        PropertyName = "Leather", PropertyName_FR = AppResources.P_Leather
                    },
                    new ProductProperty(PropertyType.IsPicker)
                    {
                        PropertyName = "Front Block", PropertyValue = null, PropertyName_FR = AppResources.P_FrontBlock
                    },
                    new ProductProperty(PropertyType.IsPicker)
                    {
                        PropertyName = "Rear Block", PropertyValue = null, PropertyName_FR = AppResources.P_RearBlock
                    },


                    new ProductProperty(PropertyType.IsPicker)
                    {
                        PropertyName = "Grained", PropertyName_FR = AppResources.P_Grained
                    },


                    new ProductProperty(PropertyType.IsLabel)
                    {
                        PropertyName = "Unit Price", PropertyName_FR = AppResources.P_UnitPrice, PropertyValue = null
                    },

                    new ProductProperty(PropertyType.IsPicker)
                    {
                        PropertyName = "Panel Base", PropertyValue = null, PropertyName_FR = AppResources.P_PanelBase
                    },

                    new ProductProperty(PropertyType.IsText)
                    {
                        PropertyName = "A", PropertyValue = null, PropertyName_FR = "A"
                    },
                    new ProductProperty(PropertyType.IsText)
                    {
                        PropertyName = "B", PropertyValue = null, PropertyName_FR = "B"
                    },
                    new ProductProperty(PropertyType.IsText)
                    {
                        PropertyName = "C", PropertyValue = null, PropertyName_FR = "C"
                    },
                    new ProductProperty(PropertyType.IsText)
                    {
                        PropertyName = "D", PropertyValue = null, PropertyName_FR = "D"
                    },
                    new ProductProperty(PropertyType.IsText)
                    {
                        PropertyName = "Comments", PropertyValue = null, PropertyName_FR = AppResources.P_Comments
                    },
                    new ProductProperty(PropertyType.IsBoolean)
                    {
                        PropertyName = "NamePlate", PropertyValue = null, PropertyName_FR = AppResources.P_NamePlate
                    },

                    new ProductProperty(PropertyType.IsBoolean)
                    {
                        PropertyName = "Greasing", PropertyValue = null, PropertyName_FR = AppResources.P_Greasing
                    },

                    new ProductProperty(PropertyType.IsBoolean)
                    {
                        PropertyName = "Sp Saddle", PropertyValue = null, PropertyName_FR = AppResources.P_SpSaddle
                    },

                    new ProductProperty(PropertyType.IsText)
                    {
                        PropertyName = "Note", PropertyValue = null, PropertyName_FR = AppResources.Note
                    }
                }
            });

            Products.Add(new Product()
            {
                Description = "Accessory",
                Name        = "Accessory",
                Name_FR     = AppResources.P_Accessory,
                ProductKind = ProductKind.accessory,
                Properties  = new List <ProductProperty>()
                {
                    new ProductProperty(PropertyType.IsPicker)
                    {
                        PropertyName = "Parent Category", PropertyValue = null, AllSource = AccessoryCategory, ItemSource = AccessoryCategory, PropertyName_FR = AppResources.P_ParentCategory
                    },
                    new ProductProperty(PropertyType.IsPicker)
                    {
                        PropertyName = "Category", PropertyValue = null, AllSource = AccessorySubCategory, ItemSource = AccessorySubCategory, PropertyName_FR = AppResources.P_Category
                    },
                    new ProductProperty(PropertyType.IsPicker)
                    {
                        PropertyName = "Name", PropertyValue = null, AllSource = AccessoryModel, ItemSource = AccessoryModel, PropertyName_FR = AppResources.Name
                    },
                    new ProductProperty(PropertyType.IsLabel)
                    {
                        PropertyName = "Unit Price", PropertyValue = null, PropertyName_FR = AppResources.P_UnitPrice
                    },
                    new ProductProperty(PropertyType.IsLabel)
                    {
                        PropertyName = "Reference", PropertyValue = null, IsVisible = false, PropertyName_FR = AppResources.P_Reference
                    },
                    new ProductProperty(PropertyType.IsText)
                    {
                        PropertyName = "Note", PropertyValue = null, PropertyName_FR = AppResources.P_Note
                    },
                }
            });

            Products.Add(new Product()
            {
                Description = "Service",
                Name        = "Service",
                Name_FR     = AppResources.P_Service,
                ProductKind = ProductKind.service,
                Properties  = new List <ProductProperty>()
                {
                    new ProductProperty(PropertyType.IsText)
                    {
                        PropertyName = "Serial number", PropertyValue = null, PropertyName_FR = AppResources.P_Serial_number
                    },
                    new ProductProperty(PropertyType.IsText)
                    {
                        PropertyName = "Brand", PropertyValue = null, PropertyName_FR = AppResources.P_Brand
                    },
                    new ProductProperty(PropertyType.IsText)
                    {
                        PropertyName = "Model", PropertyValue = null, PropertyName_FR = AppResources.P_Model
                    },
                    new ProductProperty(PropertyType.IsBoolean)
                    {
                        PropertyName = "After sale service", PropertyValue = null, ItemSource = ServiceSubCategoryModel, PropertyName_FR = AppResources.P_AfterSale
                    },
                    new ProductProperty(PropertyType.IsPicker)
                    {
                        PropertyName = "Service category", PropertyValue = null, AllSource = ServiceModel, ItemSource = new List <string>()
                        {
                            "N.A"
                        }, PropertyName_FR = AppResources.P_ServiceCategory
                    },
                    new ProductProperty(PropertyType.IsLabel)
                    {
                        PropertyName = "Unit Price", PropertyValue = null, PropertyName_FR = AppResources.P_UnitPrice
                    },
                    new ProductProperty(PropertyType.IsLabel)
                    {
                        PropertyName = "Reference", PropertyValue = null, PropertyName_FR = AppResources.P_Reference
                    },
                    new ProductProperty(PropertyType.IsText)
                    {
                        PropertyName = "Seat size", PropertyValue = null, PropertyName_FR = AppResources.P_Seatsize
                    },
                    new ProductProperty(PropertyType.IsText)
                    {
                        PropertyName = "Flap size", PropertyValue = null, PropertyName_FR = AppResources.P_Flapsize
                    },
                    new ProductProperty(PropertyType.IsText)
                    {
                        PropertyName = "Leather", PropertyValue = null, PropertyName_FR = AppResources.P_Leather
                    },
                    new ProductProperty(PropertyType.IsPicker)
                    {
                        PropertyName = "Color", PropertyValue = null, ItemSource = new List <string>()
                        {
                            "Light Brown", "Chocolate", "Black"
                        }, PropertyName_FR = AppResources.P_Color
                    },
                    new ProductProperty(PropertyType.IsText)
                    {
                        PropertyName = "Category", PropertyValue = null, PropertyName_FR = AppResources.P_Category
                    },
                    new ProductProperty(PropertyType.IsText)
                    {
                        PropertyName = "Comments", PropertyValue = null, PropertyName_FR = AppResources.P_Comments
                    },
                }
            });

            Products.Add(new Product()
            {
                Description = "Other",
                Name        = "Other",
                Name_FR     = AppResources.P_Other,
                ProductKind = ProductKind.other,
                Properties  = new List <ProductProperty>()
                {
                    new ProductProperty(PropertyType.IsText)
                    {
                        PropertyName = "Name", PropertyValue = null, PropertyName_FR = AppResources.Name
                    },
                    new ProductProperty(PropertyType.IsText)
                    {
                        PropertyName = "Price", PropertyValue = null, IsNumberKeyboard = true, PropertyName_FR = AppResources.P_Price
                    },
                    new ProductProperty(PropertyType.IsText)
                    {
                        PropertyName = "Description", PropertyValue = null, PropertyName_FR = AppResources.P_Description
                    }
                }
            });

            Products.Add(new Product()
            {
                Description = "TradeIn",
                Name        = "TradeIn",
                Name_FR     = AppResources.P_TradeIn,
                ProductKind = ProductKind.tradein,
                Properties  = new List <ProductProperty>()
                {
                    new ProductProperty(PropertyType.IsText)
                    {
                        PropertyName = "Serial number", PropertyValue = null, PropertyName_FR = AppResources.P_Serial_number
                    },
                    new ProductProperty(PropertyType.IsText)
                    {
                        PropertyName = "Brand", PropertyValue = null, PropertyName_FR = AppResources.P_Brand
                    },
                    new ProductProperty(PropertyType.IsText)
                    {
                        PropertyName = "Model", PropertyValue = null, PropertyName_FR = AppResources.P_Model
                    },
                    new ProductProperty(PropertyType.IsText)
                    {
                        PropertyName = "Size", PropertyValue = null, PropertyName_FR = AppResources.P_Size
                    },
                    new ProductProperty(PropertyType.IsText)
                    {
                        PropertyName = "Flap", PropertyValue = null, PropertyName_FR = AppResources.P_Flaps
                    },
                    new ProductProperty(PropertyType.IsPicker)
                    {
                        PropertyName = "Color", PropertyValue = null, ItemSource = new List <string>()
                        {
                            "Light Brown", "Chocolate", "Black"
                        }, PropertyName_FR = AppResources.P_Color
                    },
                    new ProductProperty(PropertyType.IsText)
                    {
                        PropertyName = "Leather", PropertyValue = null, PropertyName_FR = AppResources.P_Leather
                    },
                    new ProductProperty(PropertyType.IsBoolean)
                    {
                        PropertyName = "Blocks", PropertyValue = null, PropertyName_FR = AppResources.P_Blocks
                    },
                    new ProductProperty(PropertyType.IsText)
                    {
                        PropertyName = "Other", PropertyValue = null, PropertyName_FR = AppResources.P_Other
                    },
                    new ProductProperty(PropertyType.IsText)
                    {
                        PropertyName = "Amount", PropertyValue = null, IsNumberKeyboard = true, PropertyName_FR = AppResources.Amount
                    },
                    new ProductProperty(PropertyType.IsText)
                    {
                        PropertyName = "Note", PropertyValue = null, PropertyName_FR = AppResources.P_Note
                    },
                }
            });

            Products.Add(new Product()
            {
                Description = "Discount",
                Name        = "Discount",
                Name_FR     = AppResources.P_Discount,
                ProductKind = ProductKind.discount,
                Properties  = new List <ProductProperty>()
                {
                    new ProductProperty(PropertyType.IsText)
                    {
                        PropertyName = "Name", PropertyValue = null, PropertyName_FR = AppResources.Name
                    },
                    new ProductProperty(PropertyType.IsText)
                    {
                        PropertyName = "Price", PropertyValue = null, IsNumberKeyboard = true, PropertyName_FR = AppResources.P_Price
                    },
                    new ProductProperty(PropertyType.IsText)
                    {
                        PropertyName = "Note", PropertyValue = null, PropertyName_FR = AppResources.P_Note
                    }
                }
            });
        }
Пример #28
0
 public void RefreshRole(Accessory accessory)
 {
     this.LoadPrefab(accessory);
     this.StopAllCoroutines();
     this.StartCoroutine(this.RandomAnimation());
 }
Пример #29
0
        public IHttpActionResult GetInBoxItemByBoxID(string boxID)
        {
            Client_InBoxItems_Shelf <Client_Shelf> result;
            Client_Shelf            client_Shelf;
            List <Client_InBoxItem> client_InBoxItems = new List <Client_InBoxItem>();
            BoxDAO     boxDAO     = new BoxDAO();
            StoringDAO storingDAO = new StoringDAO();

            try
            {
                // Get client Shelf
                Box       box  = boxDAO.GetBoxByBoxID(boxID);
                StoredBox sBox = boxDAO.GetStoredBoxbyBoxPK(box.BoxPK);
                if (sBox == null)
                {
                    return(Content(HttpStatusCode.Conflict, "BOX KHÔNG HỢP LỆ!"));
                }
                Shelf shelf = db.Shelves.Find(sBox.ShelfPK);
                Row   row   = db.Rows.Find(shelf.RowPK);
                client_Shelf = new Client_Shelf(shelf.ShelfID, row.RowID);

                // Get list inBoxItem
                List <Entry> entries = (from e in db.Entries
                                        where e.StoredBoxPK == sBox.StoredBoxPK
                                        select e).ToList();

                // Hiện thực cặp value ko được trùng 2 key là itemPK và isRestored
                HashSet <KeyValuePair <int, bool> > listItemPK = new HashSet <KeyValuePair <int, bool> >();
                foreach (var entry in entries)
                {
                    listItemPK.Add(new KeyValuePair <int, bool>(entry.ItemPK, entry.IsRestored));
                }
                foreach (var itemPK in listItemPK)
                {
                    List <Entry> tempEntries = new List <Entry>();
                    foreach (var entry in entries)
                    {
                        if (entry.ItemPK == itemPK.Key && entry.IsRestored == itemPK.Value)
                        {
                            tempEntries.Add(entry);
                        }
                    }
                    if (tempEntries.Count > 0)
                    {
                        Entry        entry = tempEntries[0];
                        PassedItem   passedItem;
                        RestoredItem restoredItem;
                        if (entry.IsRestored)
                        {
                            restoredItem = db.RestoredItems.Find(entry.ItemPK);
                            Restoration restoration = db.Restorations.Find(restoredItem.RestorationPK);
                            Accessory   accessory   = db.Accessories.Find(restoredItem.AccessoryPK);
                            client_InBoxItems.Add(new Client_InBoxItem(accessory, restoration.RestorationID, storingDAO.EntriesQuantity(tempEntries), restoredItem.RestoredItemPK, true));
                        }
                        else
                        {
                            passedItem = db.PassedItems.Find(entry.ItemPK);
                            ClassifiedItem classifiedItem = db.ClassifiedItems.Find(passedItem.ClassifiedItemPK);
                            PackedItem     packedItem     = db.PackedItems.Find(classifiedItem.PackedItemPK);
                            // lấy pack ID
                            Pack pack = (from p in db.Packs
                                         where p.PackPK == packedItem.PackPK
                                         select p).FirstOrDefault();

                            // lấy phụ liệu tương ứng
                            OrderedItem orderedItem = (from oI in db.OrderedItems
                                                       where oI.OrderedItemPK == packedItem.OrderedItemPK
                                                       select oI).FirstOrDefault();

                            Accessory accessory = (from a in db.Accessories
                                                   where a.AccessoryPK == orderedItem.AccessoryPK
                                                   select a).FirstOrDefault();
                            client_InBoxItems.Add(new Client_InBoxItem(accessory, pack.PackID, storingDAO.EntriesQuantity(tempEntries), passedItem.PassedItemPK, false));
                        }
                    }
                }
                result = new Client_InBoxItems_Shelf <Client_Shelf>(client_Shelf, client_InBoxItems);
            }
            catch (Exception e)
            {
                return(Content(HttpStatusCode.Conflict, new Content_InnerException(e).InnerMessage()));
            }
            return(Content(HttpStatusCode.OK, result));
        }
        //[CustomAuthorize(Roles = "Merchant")]
        public ActionResult CreatePoster(UploadPoster P)
        {
            if (User.IsInRole("Merchant"))
            {
                if (ModelState.IsValid)
                {
                    string user_id  = User.Identity.GetUserId();
                    var    merchant = db.Merchants.FirstOrDefault(a => a.UserID == user_id);
                    int    usecoin  = 0;
                    if (P.Type == false)
                    {
                        usecoin = Convert.ToInt32(ConfigurationManager.AppSettings["posterGeneral"]);
                    }
                    else
                    {
                        usecoin = Convert.ToInt32(ConfigurationManager.AppSettings["posterVip"]);
                    }
                    if (merchant.Coin == null || merchant.Coin < usecoin)
                    {
                        SetCallout("Tài khoản Coin không đủ để đăng tin!", "warning");
                        ViewBag.Category = new SelectList(db.Categories, "CategoryID", "Name");
                        return(View(P));
                    }

                    Price price = new Price();//lưu price
                    price.SellingPrice = P.SellingPrice;
                    price.Created      = DateTime.Now;
                    db.Prices.Add(price);//---lưu price
                    db.SaveChanges();

                    Poster poster = new Poster();//lưu poster
                    poster.CategoryID = P.CategoryID; poster.MerchantID = merchant.MerchantID;
                    poster.StatusID   = P.Quantity <= 0 ? false : true; poster.Type = P.Type;
                    poster.Created    = DateTime.Now; poster.LastChanged = DateTime.Now;
                    poster.Keyword    = P.Keyword; poster.Description = P.Description;
                    poster.Quantity   = P.Quantity; poster.PriceID = price.PriceID;
                    db.Posters.Add(poster);//---lưu poster
                    db.SaveChanges();
                    var pri = db.Prices.Where(p => p.PriceID == price.PriceID).FirstOrDefault();
                    pri.PosterID        = poster.PosterID;
                    db.Entry(pri).State = EntityState.Modified;

                    List <WebsiteThuongMaiDienTu.Models.Image> images = new List <WebsiteThuongMaiDienTu.Models.Image>();
                    for (int i = 0; i < Request.Files.Count; i++)
                    {
                        var file = Request.Files[i];

                        if (file != null && file.ContentLength > 0)
                        {
                            var fileName = Path.GetFileName(file.FileName);
                            WebsiteThuongMaiDienTu.Models.Image image = new WebsiteThuongMaiDienTu.Models.Image()//lưu tên tệp ảnh vào bảng
                            {
                                Filename  = fileName,
                                Extension = Path.GetExtension(fileName),
                                PosterID  = poster.PosterID
                            };
                            db.Images.Add(image);//---lưu tên tệp ảnh vào bảng
                            images.Add(image);

                            var path = Path.Combine(Server.MapPath("~/images/Products/"), image.Filename);
                            file.SaveAs(path);
                        }
                    }

                    if (P.CategoryID == 1)//lưu thông tin cấu hình
                    {
                        PhoneConfig phone = P.PhoneConfig;
                        phone.PosterID   = poster.PosterID;
                        phone.CategoryID = P.CategoryID;
                        db.PhoneConfigs.Add(phone);
                    }
                    else if (P.CategoryID == 2)
                    {
                        LaptopConfig laptop = P.LaptopConfig;
                        laptop.PosterID   = poster.PosterID;
                        laptop.CategoryID = P.CategoryID;
                        db.LaptopConfigs.Add(laptop);
                    }
                    else if (P.CategoryID == 3)
                    {
                        Accessory access = P.Accessory;
                        access.PosterID   = poster.PosterID;
                        access.CategoryID = P.CategoryID;
                        db.Accessories.Add(access);
                    }
                    //trừ Coin trong table Merchant
                    merchant.Coin            = merchant.Coin - usecoin;
                    db.Entry(merchant).State = EntityState.Modified;
                    //lưu vào historyusecoin
                    HistoryUseCoin huc = new HistoryUseCoin();
                    huc.MerchantID  = merchant.MerchantID;
                    huc.PosterID    = poster.PosterID;
                    huc.Description = "Đăng tin";
                    huc.Coin        = usecoin;
                    huc.Created     = poster.Created;
                    db.HistoryUseCoins.Add(huc);

                    db.SaveChanges();
                    return(RedirectToAction("ListPoster", "Poster"));
                }
                return(View(P));
            }
            else
            {
                return(RedirectToAction("Shop", "Home", new { area = "" }));
            }
        }
Пример #31
0
        public IHttpActionResult GetIdentifyItemByBoxID(string boxID)
        {
            List <IdentifiedItem> identifiedItems;
            List <Client_IdentifiedItemStored> client_IdentifiedItems = new List <Client_IdentifiedItemStored>();
            BoxDAO          boxController   = new BoxDAO();
            IdentifyItemDAO identifyItemDAO = new IdentifyItemDAO();

            try
            {
                Box         box  = boxController.GetBoxByBoxID(boxID);
                UnstoredBox uBox = boxController.GetUnstoredBoxbyBoxPK(box.BoxPK);
                if (!boxController.IsStored(box.BoxPK) && uBox.IsIdentified == true)
                {
                    identifiedItems = (from iI in db.IdentifiedItems.OrderByDescending(unit => unit.PackedItemPK)
                                       where iI.UnstoredBoxPK == uBox.UnstoredBoxPK
                                       select iI).ToList();

                    foreach (var identifiedItem in identifiedItems)
                    {
                        PackedItem     packedItem     = db.PackedItems.Find(identifiedItem.PackedItemPK);
                        ClassifiedItem classifiedItem = (from cI in db.ClassifiedItems
                                                         where cI.PackedItemPK == packedItem.PackedItemPK
                                                         select cI).FirstOrDefault();
                        if (classifiedItem != null)
                        {
                            PassedItem passedItem = (from pI in db.PassedItems
                                                     where pI.ClassifiedItemPK == classifiedItem.ClassifiedItemPK
                                                     select pI).FirstOrDefault();
                            if (passedItem != null)
                            {
                                // lấy pack ID
                                Pack pack = (from p in db.Packs
                                             where p.PackPK == packedItem.PackPK
                                             select p).FirstOrDefault();

                                // lấy phụ liệu tương ứng
                                OrderedItem orderedItem = (from oI in db.OrderedItems
                                                           where oI.OrderedItemPK == packedItem.OrderedItemPK
                                                           select oI).FirstOrDefault();

                                Accessory accessory = (from a in db.Accessories
                                                       where a.AccessoryPK == orderedItem.AccessoryPK
                                                       select a).FirstOrDefault();

                                client_IdentifiedItems.Add(new Client_IdentifiedItemStored(identifiedItem, accessory, pack,
                                                                                           identifyItemDAO.ActualQuantity(identifiedItem.IdentifiedItemPK)));
                            }
                            else
                            {
                                return(Content(HttpStatusCode.Conflict, "TỒN TẠI ÍT NHẤT MỘT CỤM PHỤ LIỆU KHÔNG ĐẠT!"));
                            }
                        }
                        else
                        {
                            return(Content(HttpStatusCode.Conflict, "TỒN TẠI ÍT NHẤT MỘT CỤM PHỤ LIỆU KHÔNG ĐẠT!"));
                        }
                    }
                }
                else
                {
                    return(Content(HttpStatusCode.Conflict, "BOX ĐÃ ĐƯỢC STORE HOẶC CHƯA IDENTIFIED !"));
                }
            }
            catch (Exception e)
            {
                return(Content(HttpStatusCode.Conflict, new Content_InnerException(e).InnerMessage()));
            }

            return(Content(HttpStatusCode.OK, client_IdentifiedItems));
        }
Пример #32
0
 void OnAccessoryInstantiate(ItemSolid itemSolid)
 {
     _accessorySolid = itemSolid;
     _accessory = (Accessory)_accessorySolid.item;
     _accessorySolid.transform.SetParent(_animator.GetBoneTransform(accessory.targetBone));
     _accessorySolid.transform.localPosition = Vector3.zero;
     _accessorySolid.transform.localRotation = Quaternion.identity;
     _accessorySolid.transform.localScale = new Vector3(0.13f, 0.13f, 0.13f);
     _accessorySolid.enabled = false;
     _accessorySolid.GetComponent<Floater>().enabled = false;
     _accessorySolid.GetComponent<ItemSpawnEffector>().enabled = false;
 }
Пример #33
0
 public void EquipAccessory(Accessory accessory)
 {
     this.accessory = accessory;
 }
Пример #34
0
 private void save()
 {
     Accessory.SetNewState(typeOfAccessory, accessoryBarcode, newState);
     OnHotKey(KeyAction.Esc);
 }
        public IHttpActionResult GetAccessoriesForFilter(Client_ConceptionsAndAccessoryTypes input, bool onlyNonImagedAccessory, string customerName)
        {
            List <Accessory_RestoreItem2> result = new List <Accessory_RestoreItem2>();

            try
            {
                Customer customer = (from cus in db.Customers
                                     where cus.CustomerName == customerName
                                     select cus).FirstOrDefault();
                if (customer == null)
                {
                    return(Content(HttpStatusCode.Conflict, "CUSTOMER KHÔNG TỒN TẠI!"));
                }
                List <int> tempAccessoriesPK = (from acc in db.Accessories
                                                where acc.CustomerPK == customer.CustomerPK
                                                select acc.AccessoryPK).ToList();
                foreach (var AccessoryPK in tempAccessoriesPK)
                {
                    if (input.conceptionPKs.Count == 0)
                    {
                        Accessory tempAccessory = db.Accessories.Find(AccessoryPK);
                        if (input.accessorytypePKs.Contains(tempAccessory.AccessoryTypePK))
                        {
                            if (onlyNonImagedAccessory == true)
                            {
                                if (tempAccessory.Image == null)
                                {
                                    tempAccessory.Image = "default.png";
                                    result.Add(new Accessory_RestoreItem2(tempAccessory));
                                }
                            }
                            else
                            {
                                if (tempAccessory.Image == null)
                                {
                                    tempAccessory.Image = "default.png";
                                }
                                result.Add(new Accessory_RestoreItem2(tempAccessory));
                            }
                        }
                    }
                    else
                    {
                        foreach (var conceptionPK in input.conceptionPKs)
                        {
                            if ((from unit in db.ConceptionAccessories
                                 where unit.ConceptionPK == conceptionPK && unit.AccessoryPK == AccessoryPK
                                 select unit).FirstOrDefault() != null)
                            {
                                Accessory tempAccessory = db.Accessories.Find(AccessoryPK);
                                if (input.accessorytypePKs.Contains(tempAccessory.AccessoryTypePK))
                                {
                                    if (onlyNonImagedAccessory == true)
                                    {
                                        if (tempAccessory.Image == null)
                                        {
                                            tempAccessory.Image = "default.png";
                                            result.Add(new Accessory_RestoreItem2(tempAccessory));
                                        }
                                    }
                                    else
                                    {
                                        if (tempAccessory.Image == null)
                                        {
                                            tempAccessory.Image = "default.png";
                                        }
                                        result.Add(new Accessory_RestoreItem2(tempAccessory));
                                    }
                                }
                            }
                        }
                    }
                }
            }
            catch (Exception e)
            {
                return(Content(HttpStatusCode.Conflict, new Content_InnerException(e).InnerMessage()));
            }
            return(Content(HttpStatusCode.OK, result));
        }
        private void RegisterItemNotifications(Accessory item)
        {
            if (item != null)
            {
                item.CommandError += (object sender, MessageEventArgs e) =>
                {
                    if (!item.ProcessCommandError(e.Message))
                        NotifyCommandError(e.Message);
                };

                item.PropertyChanged += (s, e) =>
                {
                    if (e.PropertyName == nameof(item.IsMyFavorite))
                    {
                        if (item.IsMyFavorite)
                        {
                            if (!favoriteItemsIDs.Contains(item.ID))
                            {
                                favoriteItemsIDs.Add(item.ID);
                                NotifyPropertyChanged(nameof(FavoriteItemsIDs));
                            }
                        }
                        else
                        {
                            if (favoriteItemsIDs.Contains(item.ID))
                            {
                                favoriteItemsIDs.Remove(item.ID);
                                NotifyPropertyChanged(nameof(FavoriteItemsIDs));
                            }
                        }
                    }
                };
            }
        }
        public async Task <IHttpActionResult> UploadFile(int AccessoryPK, string userID)
        {
            if (!Request.Content.IsMimeMultipartContent())
            {
                return(Content(HttpStatusCode.Conflict, "DATA GỬI LÊN KHÔNG PHẢI HÌNH!"));
            }
            if (new ValidationBeforeCommandDAO().IsValidUser(userID, "Merchandiser"))
            {
                try
                {
                    Accessory accessory = db.Accessories.Find(AccessoryPK);
                    if (accessory == null)
                    {
                        return(Content(HttpStatusCode.Conflict, "ACCESSORY KHÔNG TỒN TẠI!"));
                    }
                    else
                    {
                        // upload img
                        var root     = HttpContext.Current.Server.MapPath("~/Image");
                        var provider = new MultipartFormDataStreamProvider(root);
                        await Request.Content.ReadAsMultipartAsync(provider);

                        //foreach (var file in provider.FileData)
                        //{
                        //    var name = file.Headers.ContentDisposition.FileName;
                        //    string now = DateTime.Now.Subtract(DateTime.MinValue.AddYears(1969)).TotalMilliseconds + "";
                        //    name = now.Replace('.', '8') + ".png";
                        //    var localFileName = file.LocalFileName;
                        //    var filePath = Path.Combine(root, name);
                        //    File.Move(localFileName, filePath);
                        //    if (accessory.Image != null)
                        //    {
                        //        File.Delete(Path.Combine(root, accessory.Image));
                        //    }
                        //    accessory.Image = name;
                        //    db.Entry(accessory).State = EntityState.Modified;
                        //    db.SaveChanges();
                        //    return Content(HttpStatusCode.OK, "ĐĂNG HÌNH THÀNH CÔNG!");
                        //}

                        // nạp hình và tìm đường dẫn, ko đc upload nhiều hình cùng lúc
                        MultipartFileData file = provider.FileData[0];
                        var    name            = file.Headers.ContentDisposition.FileName;
                        string now             = DateTime.Now.Subtract(DateTime.MinValue.AddYears(1969)).TotalMilliseconds + "";
                        name = now.Replace('.', '8') + ".png";
                        var localFileName = file.LocalFileName;
                        var filePath      = Path.Combine(root, name);
                        File.Move(localFileName, filePath);

                        // nếu đã có hình thì xóa hình cũ
                        if (accessory.Image != null)
                        {
                            File.Delete(Path.Combine(root, accessory.Image));
                        }
                        accessory.Image           = name;
                        db.Entry(accessory).State = EntityState.Modified;

                        // create activity
                        Activity activity = new Activity("photoUpdate", accessory.AccessoryID, "Accessory", userID);
                        db.Activities.Add(activity);

                        db.SaveChanges();
                        return(Content(HttpStatusCode.OK, "ĐĂNG HÌNH THÀNH CÔNG!"));
                    }
                }
                catch (Exception e)
                {
                    return(Content(HttpStatusCode.Conflict, new Content_InnerException(e).InnerMessage()));
                }
            }
            else
            {
                return(Content(HttpStatusCode.Conflict, "BẠN KHÔNG CÓ QUYỀN ĐỂ THỰC HIỆN VIỆC NÀY!"));
            }
        }
Пример #38
0
        /// <summary>"��������� ��������������"</summary>
        /// <param name="MainProcess"></param>
        /// <param name="mainType">�������� (���������� ��� ���������) ��� �������������� (��� ��� � �������� ������)</param>
        /// <param name="mainTopic">������� (���������� ��� ���������) ���������</param>
        /// <param name="currentType">������� ��� �������������� (��� ��� �� ������� ������� � ���������)</param>
        /// <param name="currentTopic">������� ���������</param>
        /// <param name="accessory">�������������</param>
        /// <param name="barcode">��������������� �����-���</param>
        public EditBuilder(WMSClient MainProcess, Type mainType, string mainTopic, Type currentType, string currentTopic, Accessory accessory, string barcode)
            : base(MainProcess, 1)
        {
            StopNetworkConnection();

            EditBuilder.accessory = accessory;
            EditBuilder.mainType = mainType;
            EditBuilder.mainTopic = mainTopic;
            this.currentType = currentType;
            this.currentTopic = currentTopic;
            this.barcode = barcode;

            IsLoad = true;
            existMode = true;

            OnBarcode(barcode);
        }
Пример #39
0
        private async void Button_sendFile_ClickAsync(object sender, EventArgs e)
        {
            if (SendComing > 0)
            {
                SendComing++;
            }
            else if (SendComing == 0)
            {
                timer1.Enabled = false;

                if (textBox_fileName.Text != "" && textBox_sendNum.Text != "" &&
                    ushort.TryParse(textBox_sendNum.Text, out var repeat) &&
                    ushort.TryParse(textBox_delay.Text, out var delay) &&
                    ushort.TryParse(textBox_strDelay.Text, out var strDelay))
                {
                    SendComing               = 1;
                    button_Send.Enabled      = false;
                    button_closeport.Enabled = false;
                    button_openFile.Enabled  = false;
                    button_sendFile.Text     = "Stop";
                    textBox_fileName.Enabled = false;
                    textBox_sendNum.Enabled  = false;
                    textBox_delay.Enabled    = false;
                    textBox_strDelay.Enabled = false;
                    for (var n = 0; n < repeat; n++)
                    {
                        var  outStr = "";
                        var  outErr = "";
                        long length = 0;
                        if (repeat > 1)
                        {
                            _logger.AddText(" Send cycle " + (n + 1) + "/" + repeat + ">> ", (byte)DataDirection.Info,
                                            DateTime.Now, TextLogger.TextLogger.TextFormat.PlainText);
                        }

                        try
                        {
                            length = new FileInfo(textBox_fileName.Text).Length;
                        }
                        catch (Exception ex)
                        {
                            MessageBox.Show("\r\nError opening file " + textBox_fileName.Text + ": " + ex.Message);
                        }

                        if (!checkBox_hexFileOpen.Checked)  //binary data read
                        {
                            if (radioButton_byByte.Checked) //byte-by-byte
                            {
                                var tmpBuffer = new byte[length];
                                try
                                {
                                    tmpBuffer = File.ReadAllBytes(textBox_fileName.Text);
                                }
                                catch (Exception ex)
                                {
                                    MessageBox.Show("\r\nError reading file " + textBox_fileName.Text + ": " +
                                                    ex.Message);
                                }

                                for (var m = 0; m < tmpBuffer.Length; m++)
                                {
                                    byte[] outByte = { tmpBuffer[m] };
                                    if (WriteTCP(outByte))
                                    {
                                        progressBar1.Value = (n * tmpBuffer.Length + m) * 100 /
                                                             (repeat * tmpBuffer.Length);
                                        if (strDelay > 0)
                                        {
                                            await TaskEx.Delay(strDelay);
                                        }
                                        var inStream = ReadTCP();
                                        if (inStream.Length > 0)
                                        {
                                            if (checkBox_saveInput.Checked)
                                            {
                                                if (checkBox_hexTerminal.Checked)
                                                {
                                                    File.AppendAllText(textBox_saveTo.Text,
                                                                       Accessory.ConvertByteArrayToHex(inStream, inStream.Length),
                                                                       Encoding.GetEncoding(Settings.Default.CodePage));
                                                }
                                                else
                                                {
                                                    File.AppendAllText(textBox_saveTo.Text,
                                                                       Encoding.GetEncoding(Settings.Default.CodePage)
                                                                       .GetString(inStream),
                                                                       Encoding.GetEncoding(Settings.Default.CodePage));
                                                }
                                            }

                                            _logger.AddText(
                                                Encoding.GetEncoding(Settings.Default.CodePage).GetString(inStream),
                                                (byte)DataDirection.Received, DateTime.Now);
                                        }
                                    }
                                    else
                                    {
                                        _logger.AddText("Write Failure", (byte)DataDirection.Error, DateTime.Now,
                                                        TextLogger.TextLogger.TextFormat.PlainText);
                                    }

                                    outStr = Encoding.GetEncoding(Settings.Default.CodePage).GetString(tmpBuffer);
                                    _logger.AddText(outStr, (byte)DataDirection.Sent, DateTime.Now);

                                    if (SendComing > 1)
                                    {
                                        m = tmpBuffer.Length;
                                    }
                                }
                            }
                            else //stream
                            {
                                var tmpBuffer = new byte[length];
                                try
                                {
                                    tmpBuffer = File.ReadAllBytes(textBox_fileName.Text);
                                }
                                catch (Exception ex)
                                {
                                    MessageBox.Show("\r\nError reading file " + textBox_fileName.Text + ": " +
                                                    ex.Message);
                                }

                                if (WriteTCP(tmpBuffer))
                                {
                                    var inStream = ReadTCP();
                                    if (inStream.Length > 0)
                                    {
                                        if (checkBox_saveInput.Checked)
                                        {
                                            if (checkBox_hexTerminal.Checked)
                                            {
                                                File.AppendAllText(textBox_saveTo.Text,
                                                                   Accessory.ConvertByteArrayToHex(inStream, inStream.Length),
                                                                   Encoding.GetEncoding(Settings.Default.CodePage));
                                            }
                                            else
                                            {
                                                File.AppendAllText(textBox_saveTo.Text,
                                                                   Encoding.GetEncoding(Settings.Default.CodePage).GetString(inStream),
                                                                   Encoding.GetEncoding(Settings.Default.CodePage));
                                            }
                                        }

                                        _logger.AddText(
                                            Encoding.GetEncoding(Settings.Default.CodePage).GetString(inStream),
                                            (byte)DataDirection.Received, DateTime.Now);
                                    }
                                }
                                else
                                {
                                    outErr = "Write Failure";
                                }

                                outStr = Encoding.GetEncoding(Settings.Default.CodePage).GetString(tmpBuffer);
                                _logger.AddText(outStr, (byte)DataDirection.Sent, DateTime.Now);
                                _logger.AddText(outErr, (byte)DataDirection.Error, DateTime.Now,
                                                TextLogger.TextLogger.TextFormat.PlainText);
                                progressBar1.Value = n * 100 / (repeat * tmpBuffer.Length);
                            }
                        }
                        else //hex text read
                        {
                            if (radioButton_byString.Checked) //String-by-string
                            {
                                string[] tmpBuffer = { };
                                try
                                {
                                    length    = new FileInfo(textBox_fileName.Text).Length;
                                    tmpBuffer = File.ReadAllText(textBox_fileName.Text).Replace("\n", "").Split('\r');
                                }
                                catch (Exception ex)
                                {
                                    MessageBox.Show("\r\nError reading file " + textBox_fileName.Text + ": " +
                                                    ex.Message);
                                }

                                for (var m = 0; m < tmpBuffer.Length; m++)
                                {
                                    tmpBuffer[m] = Accessory.CheckHexString(tmpBuffer[m]);
                                    if (WriteTCP(Accessory.ConvertHexToByteArray(tmpBuffer[m])))
                                    {
                                        if (checkBox_hexTerminal.Checked)
                                        {
                                            outStr = tmpBuffer[m];
                                        }
                                        else
                                        {
                                            outStr = Accessory.ConvertHexToString(tmpBuffer[m]);
                                        }
                                        if (strDelay > 0)
                                        {
                                            await TaskEx.Delay(strDelay);
                                        }
                                        var inStream = ReadTCP();
                                        if (inStream.Length > 0)
                                        {
                                            if (checkBox_saveInput.Checked)
                                            {
                                                if (checkBox_hexTerminal.Checked)
                                                {
                                                    File.AppendAllText(textBox_saveTo.Text,
                                                                       Accessory.ConvertByteArrayToHex(inStream, inStream.Length),
                                                                       Encoding.GetEncoding(Settings.Default.CodePage));
                                                }
                                                else
                                                {
                                                    File.AppendAllText(textBox_saveTo.Text,
                                                                       Encoding.GetEncoding(Settings.Default.CodePage)
                                                                       .GetString(inStream),
                                                                       Encoding.GetEncoding(Settings.Default.CodePage));
                                                }
                                            }

                                            _logger.AddText(
                                                Encoding.GetEncoding(Settings.Default.CodePage).GetString(inStream),
                                                (byte)DataDirection.Received, DateTime.Now);
                                        }
                                    }
                                    else //??????????????
                                    {
                                        outErr = "Write failure";
                                    }

                                    if (SendComing > 1)
                                    {
                                        m = tmpBuffer.Length;
                                    }
                                    _logger.AddText(outStr, (byte)DataDirection.Sent, DateTime.Now);
                                    _logger.AddText(outErr, (byte)DataDirection.Error, DateTime.Now,
                                                    TextLogger.TextLogger.TextFormat.PlainText);
                                    progressBar1.Value = (n * tmpBuffer.Length + m) * 100 / (repeat * tmpBuffer.Length);
                                }
                            }
                            else if (radioButton_byByte.Checked) //byte-by-byte
                            {
                                var tmpBuffer = "";
                                try
                                {
                                    length    = new FileInfo(textBox_fileName.Text).Length;
                                    tmpBuffer = File.ReadAllText(textBox_fileName.Text);
                                }
                                catch (Exception ex)
                                {
                                    MessageBox.Show("\r\nError reading file " + textBox_fileName.Text + ": " +
                                                    ex.Message);
                                }

                                tmpBuffer = Accessory.CheckHexString(tmpBuffer);
                                for (var m = 0; m < tmpBuffer.Length; m += 3)
                                {
                                    if (WriteTCP(Accessory.ConvertHexToByteArray(tmpBuffer.Substring(m, 3))))
                                    {
                                        if (checkBox_hexTerminal.Checked)
                                        {
                                            outStr = tmpBuffer.Substring(m, 3);
                                        }
                                        else
                                        {
                                            outStr = Accessory.ConvertHexToString(tmpBuffer.Substring(m, 3));
                                        }
                                        if (strDelay > 0)
                                        {
                                            await TaskEx.Delay(strDelay);
                                        }
                                        var inStream = ReadTCP();
                                        if (inStream.Length > 0)
                                        {
                                            if (checkBox_saveInput.Checked)
                                            {
                                                if (checkBox_hexTerminal.Checked)
                                                {
                                                    File.AppendAllText(textBox_saveTo.Text,
                                                                       Accessory.ConvertByteArrayToHex(inStream, inStream.Length),
                                                                       Encoding.GetEncoding(Settings.Default.CodePage));
                                                }
                                                else
                                                {
                                                    File.AppendAllText(textBox_saveTo.Text,
                                                                       Encoding.GetEncoding(Settings.Default.CodePage)
                                                                       .GetString(inStream),
                                                                       Encoding.GetEncoding(Settings.Default.CodePage));
                                                }
                                            }

                                            _logger.AddText(
                                                Encoding.GetEncoding(Settings.Default.CodePage).GetString(inStream),
                                                (byte)DataDirection.Received, DateTime.Now);
                                        }
                                    }
                                    else
                                    {
                                        outErr += "Write Failure\r\n";
                                    }

                                    if (SendComing > 1)
                                    {
                                        m = tmpBuffer.Length;
                                    }
                                    _logger.AddText(outStr, (byte)DataDirection.Sent, DateTime.Now);
                                    _logger.AddText(outErr, (byte)DataDirection.Error, DateTime.Now,
                                                    TextLogger.TextLogger.TextFormat.PlainText);
                                    progressBar1.Value = (n * tmpBuffer.Length + m) * 100 / (repeat * tmpBuffer.Length);
                                }
                            }
                            else //stream
                            {
                                var tmpBuffer = "";
                                try
                                {
                                    length    = new FileInfo(textBox_fileName.Text).Length;
                                    tmpBuffer = Accessory.CheckHexString(File.ReadAllText(textBox_fileName.Text));
                                }
                                catch (Exception ex)
                                {
                                    MessageBox.Show("\r\nError reading file " + textBox_fileName.Text + ": " +
                                                    ex.Message);
                                }

                                if (WriteTCP(Accessory.ConvertHexToByteArray(tmpBuffer)))
                                {
                                    var inStream = ReadTCP();
                                    if (inStream.Length > 0)
                                    {
                                        if (checkBox_saveInput.Checked)
                                        {
                                            if (checkBox_hexTerminal.Checked)
                                            {
                                                File.AppendAllText(textBox_saveTo.Text,
                                                                   Accessory.ConvertByteArrayToHex(inStream, inStream.Length),
                                                                   Encoding.GetEncoding(Settings.Default.CodePage));
                                            }
                                            else
                                            {
                                                File.AppendAllText(textBox_saveTo.Text,
                                                                   Encoding.GetEncoding(Settings.Default.CodePage).GetString(inStream),
                                                                   Encoding.GetEncoding(Settings.Default.CodePage));
                                            }
                                        }

                                        _logger.AddText(
                                            Encoding.GetEncoding(Settings.Default.CodePage).GetString(inStream),
                                            (byte)DataDirection.Received, DateTime.Now);
                                    }
                                }
                                else
                                {
                                    _logger.AddText("Write Failure\r\n", (byte)DataDirection.Error, DateTime.Now,
                                                    TextLogger.TextLogger.TextFormat.PlainText);
                                }

                                outStr = Accessory.ConvertHexToString(tmpBuffer);
                                _logger.AddText(outStr, (byte)DataDirection.Sent, DateTime.Now);

                                progressBar1.Value = n * 100 / (repeat * tmpBuffer.Length);
                            }
                        }

                        if (repeat > 1)
                        {
                            await TaskEx.Delay(delay);
                        }
                        if (SendComing > 1)
                        {
                            n = repeat;
                        }
                    }

                    button_Send.Enabled      = true;
                    button_closeport.Enabled = true;
                    button_openFile.Enabled  = true;
                    button_sendFile.Text     = "Send file";
                    textBox_fileName.Enabled = true;
                    textBox_sendNum.Enabled  = true;
                    textBox_delay.Enabled    = true;
                    textBox_strDelay.Enabled = true;
                }

                SendComing     = 0;
                timer1.Enabled = true;
            }
        }
Пример #40
0
        /// <summary>�������</summary>
        /// <param name="sender">��������� ��� ���������� �������������</param>
        private void button_click(object sender)
        {
            Button button = ((Button)sender);
            Type type = button.Tag as Type;

            if (isMainDataEntered)
                {
                if (warrantlyDataIsValid())
                    {
                    if (type != null)
                        {
                        MainProcess.ClearControls();
                        bool isNewObject = accessory.IsNew;

                        //���� ��������� ��� ��������� � �������� ����� - "���������� ������������ ������"
                        if (mainType == type && linkId != -1)
                            {
                            accessory.SetValue(mainType.Name.Substring(0, mainType.Name.Length - 1), linkId);
                            //��������� ��� ���� ��� �� �������� accessory.Id
                            accessory.Write();

                            dbObject mainObj = (Accessory)Activator.CreateInstance(mainType);
                            mainObj = (Accessory)mainObj.Read(mainType, linkId, dbObject.IDENTIFIER_NAME);
                            mainObj.SetValue(currentType.Name.Substring(0, currentType.Name.Length - 1), accessory.Id);
                            mainObj.Write();
                            }

                        //������
                        accessory.Write();

                        //���� �������� ����� - ������ ��� ������� "�����������"
                        if (isNewObject)
                            {
                            //�������� ������ � "�����������"
                            Movement.RegisterLighter(accessory.BarCode, accessory.SyncRef,
                                                     OperationsWithLighters.Registration);
                            }

                        //�����������
                        string propertyName = type.Name.Substring(0, type.Name.Length - 1);
                        object newAccessory = accessory.GetPropery(propertyName);
                        long newAccessoryId = newAccessory == null ? 0 : Convert.ToInt64(newAccessory);

                        //������� �� ��������� �������������
                        if ((newAccessoryId != 0 || (newAccessoryId == 0 && linkId != -1 && mainType == type))
                            && button.Text != okBtnText && button.Text != nextBtnText)
                            {
                            Accessory newObj = (Accessory)Activator.CreateInstance(type);
                            newObj.Read(type, newAccessoryId, dbObject.IDENTIFIER_NAME);
                            MainProcess.Process = new EditBuilder(MainProcess, mainType, mainTopic, type,
                                                                  button.Text, newObj, newObj.BarCode);
                            accessory = newObj;
                            }
                        //������� �� ����� ��������� ��� ��������������
                        else
                            {
                            //���� ��������� ��� ��������� � �������� �����
                            if (mainType == type)
                                {
                                if (mainType == null || linkId == -1)
                                    {
                                    accessory = (Accessory)accessory.Copy();
                                    accessory.ClearPosition();
                                    MainProcess.Process = new EditBuilder(MainProcess, mainType, mainType, mainTopic);
                                    }

                                MainProcess.Process = new EditBuilder(MainProcess, mainType, mainType, mainTopic);
                                }
                            //�� ��������� - "�������� �� �������������� � �������� ���������"
                            else
                                {
                                MainProcess.Process = new EditBuilder(MainProcess, type, mainType, button.Text,
                                                                      accessory.Id, type == typeof(ElectronicUnits));
                                }

                            //���� �� ���� ����������� ����������� ����� ��� ���������� ��������������, �� �������� ��� ����
                            if (!accessory.IsNew)
                                {
                                accessory = null;
                                }
                            }
                        }
                    }
                }
            else
                {
                showWriteErrorMessage();
                }
        }
Пример #41
0
        /// <summary>
        /// Loads a saved character.
        /// </summary>
        /// <param name="savexmlstring"></param>
        /// <param name="dataxmlstring"></param>
        private Character(string savexmlstring, string dataxmlstring)
        {
            _halve = new List<Element>();
            _void = new List<Element>();
            _absorb = new List<Element>();
            _immune = new List<Status>();

            XmlDocument savexml = new XmlDocument();
            XmlDocument dataxml = new XmlDocument();
            savexml.Load(new MemoryStream(Encoding.UTF8.GetBytes(savexmlstring)));
            dataxml.Load(new MemoryStream(Encoding.UTF8.GetBytes(dataxmlstring)));

            _name = savexml.FirstChild.Name;

            // Old Way : xml.SelectSingleNode("/" + _name + "/stats/lvl").InnerText

            // Stats
            _strength_base = Int32.Parse(savexml.SelectSingleNode("//str").InnerText);
            _dexterity_base = Int32.Parse(savexml.SelectSingleNode("//dex").InnerText);
            _vitality_base = Int32.Parse(savexml.SelectSingleNode("//vit").InnerText);
            _magic_base = Int32.Parse(savexml.SelectSingleNode("//mag").InnerText);
            _spirit_base = Int32.Parse(savexml.SelectSingleNode("//spi").InnerText);
            _luck_base = Int32.Parse(savexml.SelectSingleNode("//lck").InnerText);

            // Experience and Level
            _exp = Int32.Parse(savexml.SelectSingleNode("//exp").InnerText);
            _level = Int32.Parse(savexml.SelectSingleNode("//lvl").InnerText);
            _limitlvl = Int32.Parse(savexml.SelectSingleNode("//limitlvl").InnerText);

            // HP
            _hp = Int32.Parse(savexml.SelectSingleNode("//hp").InnerText);
            _maxhp = Int32.Parse(savexml.SelectSingleNode("//maxhp").InnerText);
            if (_hp > _maxhp) throw new SavegameException("HP > MAXHP for " + _name);
            _death = (_hp == 0);

            // MP
            _mp = Int32.Parse(savexml.SelectSingleNode("//mp").InnerText);
            _maxmp = Int32.Parse(savexml.SelectSingleNode("//maxmp").InnerText);
            if (_mp > _maxmp) throw new SavegameException("MP > MAXMP for " + _name);

            // Fury/Sadness
            _sadness = Boolean.Parse(savexml.SelectSingleNode("//sadness").InnerText);
            _fury = Boolean.Parse(savexml.SelectSingleNode("//fury").InnerText);
            if (_sadness && _fury) throw new SavegameException("Can't be both sad and furious");

            // Sex
            _sex = (Sex)Enum.Parse(typeof(Sex), dataxml.SelectSingleNode("//sex").InnerText);

            // Equipment
            _weaponType = (WeaponType)Enum.Parse(typeof(WeaponType), _name.Replace(" ", ""));

            _weapon = new Weapon(savexml.SelectSingleNode("//weapon/name").InnerText);
            foreach (XmlNode orb in savexml.SelectNodes("//weapon/materia/orb"))
            {
                string id = orb.Attributes["id"].Value;
                MateriaType type = (MateriaType)Enum.Parse(typeof(MateriaType), orb.Attributes["type"].Value);
                int ap = Int32.Parse(orb.Attributes["ap"].Value);
                int slot = Int32.Parse(orb.Attributes["slot"].Value);
                if (slot >= _weapon.Slots.Length)
                    throw new SavegameException("Materia orb assigned to slot that doesnt exist on weapon.");

                _weapon.Slots[slot] = Atmosphere.BattleSimulator.Materia.Create(id, ap, type);
            }

            _armor = new Armor(savexml.SelectSingleNode("//armor/name").InnerText);
            foreach (XmlNode orb in savexml.SelectNodes("//armor/materia/orb"))
            {
                string id = orb.Attributes["id"].Value;
                MateriaType type = (MateriaType)Enum.Parse(typeof(MateriaType), orb.Attributes["type"].Value);
                int ap = Int32.Parse(orb.Attributes["ap"].Value);
                int slot = Int32.Parse(orb.Attributes["slot"].Value);
                if (slot >= _weapon.Slots.Length)
                    throw new SavegameException("Materia orb assigned to slot that doesnt exist on armor.");

                _armor.Slots[slot] = Atmosphere.BattleSimulator.Materia.Create(id, ap, type);
            }

            string acc = savexml.SelectSingleNode("//accessory").InnerText;
            _accessory = String.IsNullOrEmpty(acc) ? new Accessory() : Accessory.AccessoryTable[acc];

            // Q-Values
            InitTable(ref _qvals, dataxml.SelectSingleNode("//qvals").InnerText, ',');

            // Luck base/gradient tables
            InitTable(ref _lck_base, dataxml.SelectSingleNode("//lbvals").InnerText, ',');
            InitTable(ref _lck_gradient, dataxml.SelectSingleNode("//lgvals").InnerText, ',');

            // HP base/gradient tables
            InitTable(ref _hp_base, dataxml.SelectSingleNode("//hpbvals").InnerText, ',');
            InitTable(ref _hp_gradient, dataxml.SelectSingleNode("//hpgvals").InnerText, ',');

            // MP base/gradient tables
            InitTable(ref _mp_base, dataxml.SelectSingleNode("//mpbvals").InnerText, ',');
            InitTable(ref _mp_gradient, dataxml.SelectSingleNode("//mpgvals").InnerText, ',');

            // Stat ranks
            InitTable(ref _stat_ranks, dataxml.SelectSingleNode("//ranks").InnerText, ',');
        }
Пример #42
0
        /// <summary>��������� ������ ��������������</summary>
        /// <param name="accesoryIsExist">������������� ����������</param>
        /// <param name="barcodeValue">��������</param>
        private void readAccessory(bool accesoryIsExist, string barcodeValue)
        {
            //���� ������������� ��� �� ��������������� - "�������"/"��������� ������������"
            if (accessory == null || (accesoryIsExist && !accessory.IsModified))
                {
                accessory = (Accessory)Activator.CreateInstance(currentType);

                if (string.IsNullOrEmpty(barcodeValue) && !accesoryIsExist)
                    {
                    return;
                    }

                if (string.IsNullOrEmpty(barcodeValue) && emptyBarcodeEnabled)
                    {
                    long id = ElectronicUnits.GetIdByEmptyBarcode(linkId);

                    if (id != 0)
                        {
                        accessory = (Accessory)accessory.Read(currentType, id, dbObject.IDENTIFIER_NAME);
                        }
                    }
                else
                    {
                    accessory = (Accessory)accessory.Read(currentType, barcodeValue, dbObject.BARCODE_NAME);
                    }

                accessory.Status = TypesOfLampsStatus.Storage;
                }
        }
Пример #43
0
 protected GetMessageDelegate(Accessory accessory) : base(accessory)
 {
 }
Пример #44
0
        /// <summary>"��������� ��������������"</summary>
        /// <param name="MainProcess"></param>
        /// <param name="type">������� ��� ��������������</param>
        /// <param name="prevType">���������� ��� ��������������</param>
        /// <param name="topic">������� ���������</param>
        /// <param name="id">�� �������������� � �������� �������</param>
        /// <param name="emptyBarcode">���� ������� ��������� ��������</param>
        public EditBuilder(WMSClient MainProcess, Type type, Type prevType, string topic, long id, bool emptyBarcode)
            : base(MainProcess, 1)
        {
            if (prevType == null)
                {
                mainType = type;
                mainTopic = topic;
                accessory = null;
                }

            currentType = type;
            currentTopic = topic;
            linkId = id;
            MainProcess.ToDoCommand = currentTopic;
            emptyBarcodeEnabled = emptyBarcode;

            IsLoad = true;
            existMode = false;
            DrawControls();
        }
Пример #45
0
 public Section(TextBlock text, Accessory accessory) : base("section")
 {
     Text      = text;
     Accessory = accessory;
 }
Пример #46
0
 private void detach_Accessories(Accessory entity)
 {
     this.SendPropertyChanging("Accessories");
     entity.AccessoryType = null;
 }
Пример #47
0
 public Section(TextBlock text, Accessory accessory, string blockId) : base("section")
 {
     Text      = text;
     Accessory = accessory;
     BlockId   = blockId;
 }
Пример #48
0
 // Initialized the Items Type
 public void InitializeType()
 {
     if (itemType == ItemTypes.Accessory)
     {
         Accessory accessory = new Accessory();
         if (item_Id == -1)
         {
             accessory.InitializeAccessory(Item_Database.GetRandomAccessory(itemLevel), this);
         }
         else
         {
             accessory.InitializeAccessory(Item_Database.GetAccessory(item_Id), this);
         }
     }
     else if (itemType == ItemTypes.Armor)
     {
         Armor armor = new Armor();
         if (item_Id == -1)
         {
             armor.InitializeArmor(Item_Database.GetRandomArmor(itemLevel), this);
         }
         else
         {
             armor.InitializeArmor(Item_Database.GetArmor(item_Id), this);
         }
     }
     else if (itemType == ItemTypes.Monster)
     {
         Miscellaneous misc = new Miscellaneous();
         if (item_Id == -1)
         {
             misc.InitializeMiscellaneous(Item_Database.GetRandomMobDrop(), this);
         }
         else
         {
             misc.InitializeMiscellaneous(Item_Database.GetMobDrop(item_Id), this);
         }
     }
     else if (itemType == ItemTypes.Potion)
     {
         Potion potion = new Potion();
         if (item_Id == -1)
         {
             potion.InitializePotion(Item_Database.GetRandomPotion(), this);
         }
         else
         {
             potion.InitializePotion(Item_Database.GetPotion(item_Id), this);
         }
     }
     else if (itemType == ItemTypes.Quest)
     {
     }
     else if (itemType == ItemTypes.Weapon)
     {
         Weapon weapon = new Weapon();
         if (item_Id == -1)
         {
             weapon.InitializeWeapon(Item_Database.GetRandomWeapon(itemLevel), this);
         }
         else
         {
             weapon.InitializeWeapon(Item_Database.GetWeapon(item_Id), this);
         }
     }
     else if (itemType == ItemTypes.Food)
     {
         Food food = new Food();
         if (item_Id == -1)
         {
             food.InitializeFood(Item_Database.GetRandomFoodDrop(), this);
         }
         else
         {
             food.InitializeFood(Item_Database.GetFoodDrop(item_Id), this);
         }
     }
 }
Пример #49
0
        public static bool FindCommand(int _pos, string _printerModel)
        {
            //reset all result values
            ClearCommand();

            //find command
            var _tempCommandList = new Dictionary <int, string>();

            for (var i = 0; i < _commandList.Count; i++)
            {
                if (_pos + _commandList.ElementAt(i).Value.Length / 3 <= sourceData.Count
                    ) //check if it doesn't go over the last symbol
                {
                    if (Accessory.ConvertByteArrayToHex(sourceData
                                                        .GetRange(_pos, _commandList.ElementAt(i).Value.Length / 3).ToArray()) ==
                        _commandList.ElementAt(i).Value) //find command
                    {
                        if (_printerModel == "")
                        {
                            _tempCommandList.Add(_commandList.ElementAt(i).Key,
                                                 _commandList.ElementAt(i).Value); // check if printer model is correct
                        }
                        else
                        {
                            var tmpstr = _commandDataBase.Rows[_commandList.ElementAt(i).Key][CSVColumns.PrinterModel]
                                         .ToString().Split(',');
                            for (var i1 = 0; i1 < tmpstr.Count(); i1++)
                            {
                                if (tmpstr[i1].Trim() == _printerModel)
                                {
                                    _tempCommandList.Add(_commandList.ElementAt(i).Key,
                                                         _commandList.ElementAt(i).Value);
                                }
                            }
                        }
                    }
                }
            }

            //else return false;

            if (_tempCommandList.Count <= 0)
            {
                return(false);
            }
            for (var i = 0; i < _tempCommandList.Count; i++)
            {
                commandName.Add(_tempCommandList.ElementAt(i).Value);
                commandDbLineNum.Add(_tempCommandList.ElementAt(i).Key);
                commandDesc.Add(_commandDataBase.Rows[commandDbLineNum[i]][CSVColumns.Description].ToString());
                commandPosition.Add(_pos);
                commandPrinterModel.Add(_commandDataBase.Rows[commandDbLineNum[i]][CSVColumns.PrinterModel].ToString());
                //check command height - how many rows are occupated
                var i1 = 0;
                while (commandDbLineNum[i] + i1 + 1 < _commandDataBase.Rows.Count &&
                       _commandDataBase.Rows[commandDbLineNum[i] + i1 + 1][CSVColumns.CommandName].ToString() ==
                       "")
                {
                    i1++;
                }
                commandDbHeight.Add(i1);
            }

            return(true);
        }
Пример #50
0
 public void AddRecentItem(Accessory item, int maxCount)
 {
     if (RecentItemsIDs.Contains(item.ID))
     {
         if (RecentItemsIDs.IndexOf(item.ID) != 0)
         {
             RecentItemsIDs.Remove(item.ID);
             RecentItemsIDs.Insert(0, item.ID);
             NotifyPropertyChanged("RecentItemsIDs");
         }
     }
     else
     {
         RecentItemsIDs.Insert(0, item.ID);
         LimitRecentItemsIDs(maxCount);
     }
 }
Пример #51
0
        public static bool FindParameter(int _commandNum)
        {
            ClearParameters();
            if (_commandNum < 0 || _commandNum >= commandName.Count)
            {
                return(false);
            }
            //collect parameters
            var _stopSearch = commandDbLineNum[_commandNum] + 1;

            while (_stopSearch < _commandDataBase.Rows.Count &&
                   _commandDataBase.Rows[_stopSearch][CSVColumns.CommandName].ToString() == "")
            {
                _stopSearch++;
            }
            for (var i = commandDbLineNum[_commandNum] + 1; i < _stopSearch; i++)
            {
                if (_commandDataBase.Rows[i][CSVColumns.ParameterName].ToString() != "")
                {
                    paramDbLineNum.Add(i);
                    paramName.Add(_commandDataBase.Rows[i][CSVColumns.ParameterName].ToString());
                    paramDesc.Add(_commandDataBase.Rows[i][CSVColumns.Description].ToString());
                    paramType.Add(_commandDataBase.Rows[i][CSVColumns.ParameterType].ToString());
                }
            }

            errors = false; //Error in parameter found
            //process each parameter
            for (var parameter = 0; parameter < paramDbLineNum.Count; parameter++)
            {
                paramPosition.Add(commandPosition[_commandNum] + ResultLength(_commandNum));
                bitName.Add(new List <string>());
                bitValue.Add(new List <string>());
                bitDescription.Add(new List <string>());

                //collect predefined RAW values
                var predefinedParamsRaw = new List <string>();
                var j = paramDbLineNum[parameter] + 1;
                while (j < _commandDataBase.Rows.Count &&
                       _commandDataBase.Rows[j][CSVColumns.ParameterValue].ToString() != "")
                {
                    predefinedParamsRaw.Add(_commandDataBase.Rows[j][CSVColumns.ParameterValue].ToString());
                    j++;
                }

                //Calculate predefined params
                var predefinedParamsVal = new List <int>();
                foreach (var expresion in predefinedParamsRaw)
                {
                    var val = 0;
                    //select formula basing on parameter value "?k=1:n+n1 ?k-2:n*n1"
                    if (expresion.StartsWith("?"))
                    {
                        var tmpstr = expresion.Trim().Replace("\r", "").Replace("\n", "").Split('?');
                        foreach (var str in tmpstr)
                        {
                            if (str != "")
                            {
                                var equation =
                                    str.Substring(0,
                                                  str.IndexOf(':')); //calculate equation if needed
                                for (var i2 = 0;
                                     i2 < paramName.Count - 1;
                                     i2++) //insert all parameters before current into equation
                                {
                                    equation = equation.Replace(paramName[i2], paramValue[i2]);
                                    equation = equation.Replace('=', '-');
                                }

                                if (Accessory.Evaluate(equation) == 0)
                                {
                                    var equation2 = str.Substring(str.IndexOf(':') + 1).Trim();
                                    for (var i3 = 0; i3 < paramName.Count - 1; i3++)
                                    {
                                        equation2 = equation2.Replace(paramName[i3], paramValue[i3]);
                                    }
                                    try
                                    {
                                        val = (int)Accessory.Evaluate(equation2);
                                    }
                                    catch
                                    {
                                    }
                                }
                            }
                        }
                    }
                    else if (expresion.StartsWith("@"))
                    {
                        var equation = expresion.Substring(1);
                        //insert all parameters before current into equation
                        for (var i2 = 0; i2 < paramName.Count - 1; i2++)
                        {
                            equation = equation.Replace(paramName[i2], paramValue[i2]);
                        }
                        val = (int)Accessory.Evaluate(equation); // = str.Substring(str.IndexOf(':') + 1);
                    }
                    else
                    {
                        if (!int.TryParse(expresion.Trim(), out val))
                        {
                            val = 0;
                        }
                    }

                    predefinedParamsVal.Add(val);
                }

                //get parameter from text
                var tmpStrLength    = 0;
                var predefinedFound =
                    false; //Matching predefined parameter found and it's number is in "predefinedParameterMatched"
                var  errMessage = "";
                byte l = 0, h = 0;
                var  predefinedParameterMatched = 0;
                var  _prmType = _commandDataBase.Rows[paramDbLineNum[parameter]][CSVColumns.ParameterType].ToString()
                                .ToLower();
                if (_prmType == DataTypes.Byte)
                {
                    if (paramPosition[parameter] + 1 <= sourceData.Count)
                    {
                        paramRAWValue.Add(sourceData.GetRange(paramPosition[parameter], 1));
                        l = paramRAWValue[parameter].ToArray()[0];
                    }
                    else
                    {
                        errors     = true;
                        errMessage = "!!!ERR: Out of data!!!";
                        paramRAWValue.Add(sourceData.GetRange(paramPosition[parameter],
                                                              sourceData.Count - paramPosition[parameter]));
                    }

                    paramValue.Add(l.ToString());
                }
                else if (_prmType == DataTypes.Bitfield)
                {
                    if (paramPosition[parameter] + 1 <= sourceData.Count)
                    {
                        paramRAWValue.Add(sourceData.GetRange(paramPosition[parameter], 1));
                        l = paramRAWValue[parameter].ToArray()[0];
                        for (byte i2 = 0; i2 < 8; i2++)
                        {
                            bitName[parameter].Add("bit" + i2);
                            bitValue[parameter].Add(Accessory.GetBit(l, i2).ToString());
                            bitDescription[parameter]
                            .Add(_commandDataBase.Rows[paramDbLineNum[parameter] + i2 + 1][CSVColumns.Description]
                                 .ToString());
                        }
                    }
                    else
                    {
                        errors     = true;
                        errMessage = "!!!ERR: Out of data!!!";
                        paramRAWValue.Add(sourceData.GetRange(paramPosition[parameter],
                                                              sourceData.Count - paramPosition[parameter]));
                    }

                    paramValue.Add(l.ToString());
                }
                else if (_prmType == DataTypes.Word)
                {
                    if (paramPosition[parameter] + 2 <= sourceData.Count)
                    {
                        paramRAWValue.Add(sourceData.GetRange(paramPosition[parameter], 2));
                        l = paramRAWValue[parameter].GetRange(0, 1)[0];
                        h = paramRAWValue[parameter].GetRange(1, 1)[0];
                    }
                    else
                    {
                        errors     = true;
                        errMessage = "!!!ERR: Out of data!!!";
                        paramRAWValue.Add(sourceData.GetRange(paramPosition[parameter],
                                                              sourceData.Count - paramPosition[parameter]));
                    }

                    paramValue.Add((h * 256 + l).ToString());
                }
                else if (_prmType == DataTypes.Rword)
                {
                    if (paramPosition[parameter] + 2 <= sourceData.Count)
                    {
                        paramRAWValue.Add(sourceData.GetRange(paramPosition[parameter], 2));
                        h = paramRAWValue[parameter].GetRange(0, 1)[0];
                        l = paramRAWValue[parameter].GetRange(1, 1)[0];
                    }
                    else
                    {
                        errors     = true;
                        errMessage = "!!!ERR: Out of data!!!";
                        paramRAWValue.Add(sourceData.GetRange(paramPosition[parameter],
                                                              sourceData.Count - paramPosition[parameter]));
                    }

                    paramValue.Add((h * 256 + l).ToString());
                }
                else if (_prmType == DataTypes.Textstring || _prmType == DataTypes.Decstring ||
                         _prmType == DataTypes.Hexstring || _prmType == DataTypes.Binarystring)
                {
                    if (predefinedParamsVal.Count > 0)
                    {
                        //look for the end of the string (predefined byte)
                        while (predefinedFound == false && paramPosition[parameter] + tmpStrLength <= sourceData.Count)
                        {
                            //check for each predefined value
                            for (var i1 = 0; i1 < predefinedParamsVal.Count; i1++)
                            {
                                if (paramPosition[parameter] + tmpStrLength + 1 <= sourceData.Count)
                                {
                                    if (sourceData[paramPosition[parameter] + tmpStrLength] == predefinedParamsVal[i1])
                                    {
                                        predefinedFound            = true;
                                        predefinedParameterMatched = i1;
                                        paramRAWValue.Add(sourceData.GetRange(paramPosition[parameter], tmpStrLength));
                                    }
                                }
                                else
                                {
                                    errors     = true;
                                    errMessage = "!!!ERR: Out of data!!!";
                                }
                            }

                            tmpStrLength++;
                        }

                        if (tmpStrLength < 1)
                        {
                            errors     = true;
                            errMessage = "!!!ERR: Out of data!!!";
                        }

                        if (errors)
                        {
                            paramRAWValue.Add(sourceData.GetRange(paramPosition[parameter],
                                                                  sourceData.Count - paramPosition[parameter]));
                        }
                        if (paramRAWValue[parameter].Count != 0)
                        {
                            if ((_prmType == DataTypes.Textstring || _prmType == DataTypes.Decstring ||
                                 _prmType == DataTypes.Hexstring) &&
                                Accessory.PrintableByteArray(paramRAWValue[parameter].ToArray()))
                            {
                                paramValue.Add(Encoding.GetEncoding(Settings.Default.CodePage)
                                               .GetString(paramRAWValue[parameter].ToArray()));
                            }
                            else
                            {
                                paramValue.Add("[" +
                                               Accessory.ConvertByteArrayToHex(paramRAWValue[parameter].ToArray()) +
                                               "]");
                            }
                        }
                        else
                        {
                            paramValue.Add("");
                        }
                    }
                    else
                    {
                        errors     = true;
                        errMessage = "!!!ERR: There must be predefined values!!!";
                        paramRAWValue.Add(null);
                        paramValue.Add("");
                    }
                }
                else if (_prmType == DataTypes.Textarray || _prmType == DataTypes.Decarray ||
                         _prmType == DataTypes.Hexarray || _prmType == DataTypes.Binaryarray)
                {
                    if (predefinedParamsVal.Count == 1)
                    {
                        predefinedFound            = true;
                        predefinedParameterMatched = 0;
                        if (paramPosition[parameter] + predefinedParamsVal[0] <= sourceData.Count)
                        {
                            paramRAWValue.Add(sourceData.GetRange(paramPosition[parameter],
                                                                  (byte)predefinedParamsVal[0]));
                        }
                        else
                        {
                            errors     = true;
                            errMessage = "!!!ERR: Out of data bound!!!";
                            paramRAWValue.Add(sourceData.GetRange(paramPosition[parameter],
                                                                  sourceData.Count - paramPosition[parameter]));
                        }

                        if (paramRAWValue[parameter].Count != 0)
                        {
                            if ((_prmType == DataTypes.Textarray || _prmType == DataTypes.Decarray ||
                                 _prmType == DataTypes.Hexarray) &&
                                Accessory.PrintableByteArray(paramRAWValue[parameter].ToArray()))
                            {
                                paramValue.Add(Encoding.GetEncoding(Settings.Default.CodePage)
                                               .GetString(paramRAWValue[parameter].ToArray()));
                            }
                            else
                            {
                                paramValue.Add("[" +
                                               Accessory.ConvertByteArrayToHex(paramRAWValue[parameter].ToArray()) +
                                               "]");
                            }
                        }
                        else
                        {
                            paramValue.Add("");
                        }
                    }
                    else
                    {
                        errors     = true;
                        errMessage = "!!!ERR: There must be only one predefined value!!!";
                        paramRAWValue.Add(null);
                        paramValue.Add("");
                    }
                }
                else
                {
                    predefinedFound = true;
                    errors          = true;
                    errMessage      = "!!!ERR: Incorrect parameter type!!!";
                    paramRAWValue.Add(new List <byte>());
                    paramValue.Add("");
                }

                if (errors)
                {
                    paramDesc[parameter] += errMessage + "\r\n";
                }

                //compare parameter value with predefined values to get proper description
                if (predefinedFound == false && !errors)
                {
                    for (var i1 = 0; i1 < predefinedParamsVal.Count; i1++)
                    {
                        if (paramValue[parameter] == predefinedParamsVal[i1].ToString())
                        {
                            predefinedFound            = true;
                            predefinedParameterMatched = i1;
                            i1 = predefinedParamsVal.Count;
                        }
                    }

                    if (predefinedParamsVal.Count > 0 && predefinedFound == false)
                    {
                        errors = true; //if no parameters match predefined
                    }
                }

                //get description for predefined parameter
                //if description is within current command parameters group
                if (paramDbLineNum[parameter] + predefinedParameterMatched + 1 <=
                    commandDbLineNum[_commandNum] + commandDbHeight[_commandNum] && predefinedFound)
                {
                    paramDesc[parameter] +=
                        _commandDataBase.Rows[paramDbLineNum[parameter] + predefinedParameterMatched + 1][
                            CSVColumns.Description].ToString();
                }
            }

            ResultLength(_commandNum);
            return(!errors);
        }
 /// <summary>
 /// There are no comments for Accessory in the schema.
 /// </summary>
 public void AddToAccessory(Accessory accessory)
 {
     base.AddObject("Accessory", accessory);
 }
Пример #53
0
        /// <summary>
        /// Loads a saved character.
        /// </summary>
        /// <param name="savexmlstring"></param>
        /// <param name="dataxmlstring"></param>
        public Character(XmlNode savexml, XmlNode dataxml, DataStore data)
            : this()
        {
            _halve  = new List <Element>();
            _void   = new List <Element>();
            _absorb = new List <Element>();
            _immune = new List <Status>();


            Name = savexml.Name;


            // Stats
            _strength_base  = Int32.Parse(savexml.SelectSingleNode("./stats/str").InnerText);
            _dexterity_base = Int32.Parse(savexml.SelectSingleNode("./stats/dex").InnerText);
            _vitality_base  = Int32.Parse(savexml.SelectSingleNode("./stats/vit").InnerText);
            _magic_base     = Int32.Parse(savexml.SelectSingleNode("./stats/mag").InnerText);
            _spirit_base    = Int32.Parse(savexml.SelectSingleNode("./stats/spi").InnerText);
            _luck_base      = Int32.Parse(savexml.SelectSingleNode("./stats/lck").InnerText);
            _level          = Int32.Parse(savexml.SelectSingleNode("./stats/lvl").InnerText);

            // Experience and Level
            _exp      = Int32.Parse(savexml.SelectSingleNode("./exp").InnerText);
            _limitlvl = Int32.Parse(savexml.SelectSingleNode("./limitlvl").InnerText);

            // HP
            _hp    = Int32.Parse(savexml.SelectSingleNode("./hp").InnerText);
            _maxhp = Int32.Parse(savexml.SelectSingleNode("./maxhp").InnerText);
            if (_hp > _maxhp)
            {
                throw new SaveStateException("HP > MAXHP for " + Name);
            }
            //_death = (_hp == 0);

            // MP
            _mp    = Int32.Parse(savexml.SelectSingleNode("./mp").InnerText);
            _maxmp = Int32.Parse(savexml.SelectSingleNode("./maxmp").InnerText);
            if (_mp > _maxmp)
            {
                throw new SaveStateException("MP > MAXMP for " + Name);
            }

            // Fury/Sadness
            Sadness = Boolean.Parse(savexml.SelectSingleNode("./sadness").InnerText);
            Fury    = Boolean.Parse(savexml.SelectSingleNode("./fury").InnerText);
            if (Sadness && Fury)
            {
                throw new SaveStateException("Can't be both sad and furious");
            }

            // Sex
            _sex = (Sex)Enum.Parse(typeof(Sex), dataxml.SelectSingleNode("./sex").InnerText);

            // Back row?
            BackRow = Boolean.Parse(savexml.SelectSingleNode("./backRow").InnerText);

            // Equipment
            _weapon = data.GetWeapon(savexml.SelectSingleNode("./weapon/name").InnerText);

            foreach (XmlNode orb in savexml.SelectNodes("./weapon/materia/orb"))
            {
                string id   = orb.Attributes["id"].Value;
                int    ap   = Int32.Parse(orb.Attributes["ap"].Value);
                int    slot = Int32.Parse(orb.Attributes["slot"].Value);
                if (slot >= _weapon.Slots.Length)
                {
                    throw new SaveStateException("Materia orb assigned to slot that doesnt exist on weapon.");
                }

                _weapon.Slots[slot] = data.GetMateria(id, ap);
            }

            _armor = data.GetArmor(savexml.SelectSingleNode("./armor/name").InnerText);

            foreach (XmlNode orb in savexml.SelectNodes("./armor/materia/orb"))
            {
                string id   = orb.Attributes["id"].Value;
                int    ap   = Int32.Parse(orb.Attributes["ap"].Value);
                int    slot = Int32.Parse(orb.Attributes["slot"].Value);
                if (slot >= _weapon.Slots.Length)
                {
                    throw new SaveStateException("Materia orb assigned to slot that doesnt exist on armor.");
                }

                _armor.Slots[slot] = data.GetMateria(id, ap);
            }

            string acc = savexml.SelectSingleNode("./accessory").InnerText;

            _accessory = String.IsNullOrEmpty(acc) ? null : data.GetAccessory(acc);


            // Q-Values
            _qvals = InitTable(dataxml.SelectSingleNode("./qvals").InnerText);

            // Luck base/gradient tables
            _lck_base     = InitTable(dataxml.SelectSingleNode("./lbvals").InnerText);
            _lck_gradient = InitTable(dataxml.SelectSingleNode("./lgvals").InnerText);

            // HP base/gradient tables
            _hp_base     = InitTable(dataxml.SelectSingleNode("./hpbvals").InnerText);
            _hp_gradient = InitTable(dataxml.SelectSingleNode("./hpgvals").InnerText);

            // MP base/gradient tables
            _mp_base     = InitTable(dataxml.SelectSingleNode("./mpbvals").InnerText);
            _mp_gradient = InitTable(dataxml.SelectSingleNode("./mpgvals").InnerText);

            // Stat ranks
            _stat_ranks = InitTable(dataxml.SelectSingleNode("./ranks").InnerText);


            Profile      = new Gdk.Pixbuf(data.Assembly, "charfull." + Name.ToLower() + ".jpg");
            ProfileSmall = new Gdk.Pixbuf(data.Assembly, "charsmall." + Name.ToLower() + ".jpg");
            ProfileTiny  = new Gdk.Pixbuf(data.Assembly, "chartiny." + Name.ToLower() + ".jpg");


            // Sanity checks. Sometimes we'll load materia onto a save file which
            //    causes the max to drop, but we don't otherwise modify the current
            //    values. So we'll do that here.

            if (_hp > _maxhp)
            {
                _hp = _maxhp;
            }
            else if (_hp <= 0)
            {
                _hp = 0;
                InflictDeath();
            }

            if (_mp > _maxmp)
            {
                _mp = _maxmp;
            }
            else if (_mp < 0)
            {
                _mp = 0;
            }

            CharacterMetrics = data.CharacterMetrics;
        }
Пример #54
0
    /*	public void makeDrink (Item sc_drink, Vector3 drinkPos){
        //todo 미리 뿌려져있는 술과 겹쳐지게 해야함.
        TileInfo ti = boardManager._Stage [currStage].get_tileInfo ()[((int)drinkPos.y), ((int)drinkPos.x)];
        GameObject go_drink = Instantiate (Resources.Load ("Image_Drink/" + Config.spriteName_Item[sc_drink.GetItemCode()], typeof(GameObject))) as GameObject;
        go_drink.transform.position = drinkPos;
        ti.i.Add (sc_drink);					//Tile Info에 등록
    }*/
    public void makeItemGO(int itemType, Vector3 itemPos, string resourceName)
    {
        TileInfo ti = boardManager._Stage [currStage].get_tileInfo ()[((int)itemPos.y), ((int)itemPos.x)];

        if (itemType < 0) {																			//골드일 경우
            GameObject go_gold = Instantiate (Resources.Load (resourceName, typeof(GameObject))) as GameObject;
            go_gold.GetComponent<ObjectID> ().secondCode = -itemType;
            go_gold.transform.position = itemPos;
            go_gold.GetComponent<SpriteRenderer> ().sortingOrder = ti.i.Count+ti.d.Count;			//소팅 레이어 등록
            Gold sc_gold = new Gold ();
            sc_gold.SetGameObject (go_gold);
            sc_gold.init (-1, -itemType, 0);
        //			Debug.Log("make Item in " + itemPos.x + "," + itemPos.y);
            ti.i.Add (sc_gold);		//Tile Info에 드랍 골드 등록
        } else {
            switch(itemType){
            case 0:			//drink
                Debug.Log("Can't make drink here");
                break;
            case 1:			//weapon
                GameObject go_weapon = Instantiate (Resources.Load (resourceName, typeof(GameObject))) as GameObject;
                go_weapon.transform.position = itemPos;
                go_weapon.GetComponent<SpriteRenderer> ().sortingOrder = ti.i.Count+ti.d.Count;		//소팅 레이어 등록
                Weapon sc_weapon = new Weapon();
                sc_weapon.SetGameObject (go_weapon);
                ObjectID weaponId = go_weapon.GetComponent<ObjectID>();
                sc_weapon.init (weaponId.firstCode, weaponId.secondCode, weaponId.thirdCode);
                ti.i.Add (sc_weapon);		//Tile Info에 등록
                break;
            case 2:			//accessory
                GameObject go_acce = Instantiate (Resources.Load (resourceName, typeof(GameObject))) as GameObject;
                go_acce.transform.position = itemPos;
                go_acce.GetComponent<SpriteRenderer> ().sortingOrder = ti.i.Count+ti.d.Count;		//소팅 레이어 등록
                Accessory sc_acce = new Accessory();
                sc_acce.SetGameObject (go_acce);
                ObjectID acceId = go_acce.GetComponent<ObjectID>();
                sc_acce.init (acceId.firstCode, acceId.secondCode, acceId.thirdCode);
                ti.i.Add (sc_acce);		//Tile Info에 등록
                break;
            case 3:			//snack
                GameObject go_snack = Instantiate (Resources.Load (resourceName, typeof(GameObject))) as GameObject;
                go_snack.transform.position = itemPos;
                go_snack.GetComponent<SpriteRenderer> ().sortingOrder = ti.i.Count+ti.d.Count;		//소팅 레이어 등록
                Snack sc_snack = new Snack();
                sc_snack.SetGameObject (go_snack);
                ObjectID snackId = go_snack.GetComponent<ObjectID>();
                sc_snack.init (snackId.firstCode, snackId.secondCode, snackId.thirdCode);
                ti.i.Add (sc_snack);		//Tile Info에 등록
                break;
            case 4:			//alcoholBag
                GameObject go_abg = Instantiate (Resources.Load (resourceName, typeof(GameObject))) as GameObject;
                go_abg.transform.position = itemPos;
                go_abg.GetComponent<SpriteRenderer> ().sortingOrder = ti.i.Count+ti.d.Count;		//소팅 레이어 등록
                AlcoholBag sc_abg = new AlcoholBag();
                sc_abg.SetGameObject (go_abg);
                ObjectID abgId = go_abg.GetComponent<ObjectID>();
                sc_abg.init (abgId.firstCode, abgId.secondCode, abgId.thirdCode);
                ti.i.Add (sc_abg);			//Tile Info에 등록
                break;
            case 5:			//alcoholBottle
                GameObject go_abt = Instantiate (Resources.Load (resourceName, typeof(GameObject))) as GameObject;
                go_abt.transform.position = itemPos;
                go_abt.GetComponent<SpriteRenderer> ().sortingOrder = ti.i.Count+ti.d.Count;		//소팅 레이어 등록
                AlcoholBottle sc_abt = new AlcoholBottle();
                sc_abt.SetGameObject (go_abt);
                ObjectID abtId = go_abt.GetComponent<ObjectID>();
                sc_abt.init (abtId.firstCode, abtId.secondCode, abtId.thirdCode);
                ti.i.Add (sc_abt);			//Tile Info에 등록
                break;
            }
        }
    }
Пример #55
0
 public void unequipAccessory(Accessory a)
 {
     if (accessories.Contains (a)) {
         addToInventory(a);
         accessories.Remove (a);
     } else {
         throw new RulesException ("Accessory not equipped");
     }
 }