Esempio n. 1
0
 public CartItem(StoreItem product, int qty, string size, string color)
 {
     Product = product;
     Qty = qty;
     Size = size;
     Color = color;
     //
     // TODO: Add constructor logic here
     //
 }
Esempio n. 2
0
    static int Main()
    {
        StoreItem si = new StoreItem();

        si.CreateItem();
        si.Describe();

        System.Console.ReadKey();

        return 0;
    }
    public string Setup()
    {
        item = GetComponent<StoreItem>();
        string formated = "[" + NGUITools.EncodeColor(GetColorQuality(1)) + "]" + item.storeItemInfo.itemName;

        foreach(StoreItemDetail detail in item.storeItemInfo.itemDetail)
        {
            Debug.Log(detail.propertyName);
            formated = string.Format("{0}\n [" + NGUITools.EncodeColor(Color.white) + "]{1}: {2}", formated, detail.propertyName, detail.propertyValue.ToString());
        }

        return formated;
    }
Esempio n. 4
0
    static int Main()
    {
        StoreItem si = new StoreItem();

        si.itemNumber = 660284;
        si.itemName = "Tropical Wool Neutral Jacket";
        si.unitPrice = 200.00M;

        Console.WriteLine("Store Inventory");
        Console.Write("Item #:     ");
        Console.WriteLine(si.itemNumber);
        Console.Write("Item Name:  ");
        Console.WriteLine(si.itemName);
        Console.Write("Unit Price: ");
        Console.WriteLine(si.unitPrice);
        Console.WriteLine("=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=");

        System.Console.ReadKey();
        return 0;
    }
Esempio n. 5
0
    protected override void OnActivate()
    {
        base.OnActivate();

        int gearCount = 0;
        int i;

        // set up gear
        for (i = 0; i < Avatar.Instance.EquippedIDs.Count; i++)
        {
            StoreItem gear = Database.Instance.GetGearItem(Avatar.Instance.EquippedIDs[i]);
            if (gear.BodyType == Avatar.Instance.BodyType.ToString())
            {
                GearList[gearCount].GearImage.Image.sprite = AssetLookUp.Instance.GetGearIcon(gear.IconName);
                GearList[gearCount].GearImage.Activate();
                gearCount++;
            }
        }

        for (i = gearCount; i < GearList.Length; i++)
        {
            GearList[i].BGImage.Image.color = new Color(1.0f, 1.0f, 1.0f, 0.5f);
        }
    }
Esempio n. 6
0
        public StoreItemDto Create(StoreItemDto dto)
        {
            if (string.IsNullOrEmpty(dto.Name))
            {
                throw new ArgumentNullException("Name");
            }

            StoreItem storeItem = new StoreItem()
            {
                Name         = dto.Name,
                Description  = dto.Description,
                Cost         = dto.Cost,
                InStock      = dto.InStock,
                CreatedDate  = DateTime.UtcNow,
                ModifiedDate = DateTime.UtcNow,
                IsDeleted    = false
            };

            Db.StoreItems.Add(storeItem);

            Db.SaveChanges();

            return(Mapper.Map <StoreItemDto>(storeItem));
        }
Esempio n. 7
0
        public object InitializeBooster(string userId, ChestFields chestItem, StoreItem parameters, int ProductId)
        {
//            SetFinished(userId);


            var boosterData = new BoosterField();

            boosterData.UserId          = userId;
            boosterData.UserChestId     = chestItem.Id;
            boosterData.StoreProductId  = ProductId;
            boosterData.AdvancedImgUrls = parameters.AdvancedImgUrls;

            // todo from properties
            Dictionary <string, dynamic> properties = Json.Decode(parameters.property);

            boosterData.Property      = parameters.property;
            boosterData.BasicDuration = properties.ContainsKey("basicDuration") ? properties["basicDuration"] : null;


            if (ExistsActive(userId, ProductId))
//            if (true)
            {
                UpdateActivation(boosterData);
            }
            else
            {
                NewActivate(boosterData);
            }


            return(new
            {
                boosterData,
                massage = "Вы активировали бустер такой то"
            });
        }
        public void Update(StoreItem obj) //store item (inventory) should be updatable
        {
            if (obj is null)
            {
                //log it!
                throw new ArgumentNullException("Cannot update null store item");
            }
            else
            {
                var existing = GetStoreItemById(obj.Id);
                if (existing != null) //if given pizza is actually in db
                {
                    //update local values
                    _dbContext.Entry(existing).CurrentValues.SetValues(obj);

                    _dbContext.SaveChanges(); //update db's values
                }
                else
                {
                    //log it!
                    throw new ArgumentOutOfRangeException("Store item with given id does not exist");
                }
            }
        }
Esempio n. 9
0
    public override void ItemSelected()
    {
        int howManySelected = 0;

        for (int i = 0; i < contentRect.childCount; i++)
        {
            StoreItem t = contentRect.GetChild(i).GetComponent <StoreItem> ();
            if (t.toggle.isOn)
            {
                howManySelected++;
            }
        }

        if (howManySelected > 0)
        {
            addButton.gameObject.SetActive(false);
            removeButton.gameObject.SetActive(true);
        }
        else
        {
            addButton.gameObject.SetActive(true);
            removeButton.gameObject.SetActive(false);
        }
    }
Esempio n. 10
0
    public void InsertItem(StoreItem item)
    {
        if (!canExecute)
        {
            return;
        }

        for (int i = 0; i < inventoryItems.Length; i++)
        {
            if (inventoryItems[i] == null)
            {
                inventoryItems[i] = new InventoryItem(item, 1);
                InventoryController.GetInventoryController().AddItem(inventoryItems[i]);
                prov++;
                break;
            }
            else if (inventoryItems[i].GetName().Equals(item.name))
            {
                inventoryItems[i].IncrementQuantity();
                InventoryController.GetInventoryController().AddItem(inventoryItems[i]);
                break;
            }
        }

        if (Player.getInstance().GetPlayerCurrency() == 0)
        {
            canExecute = false;
        }
        //Código de teste para a loja (Use Control + Shift + C enquanto roda)
        //string retur = "List: \n";
        //for (int inv = 0; inv < prov; inv++)
        //{
        //    retur += inventoryItems[inv].GetName() + ": " + inventoryItems[inv].GetQuantity() + "\n";
        //}
        //Debug.Log(retur);
    }
Esempio n. 11
0
        public static List <StoreItem> GetStaticStores()
        {
            // TODO JR: table to be created to backend
            List <StoreItem> staticStoreList = new List <StoreItem>();
            StoreItem        storeItem       = new StoreItem();

            storeItem.Id    = 1;
            storeItem.Store = "Prisma";
            staticStoreList.Add(storeItem);

            StoreItem storeItem2 = new StoreItem();

            storeItem2.Id    = 2;
            storeItem2.Store = "Citymarket";
            staticStoreList.Add(storeItem2);

            StoreItem storeItem3 = new StoreItem();

            storeItem3.Id    = 3;
            storeItem3.Store = "Valkea";
            staticStoreList.Add(storeItem3);

            return(staticStoreList);
        }
Esempio n. 12
0
 void CheckCurrentItemForFilter()
 {
     if (_currentItem != null)
     {
         StoreItem gearItem = _currentItem.Object as StoreItem;
         if (gearItem.Type != _filter.ToString())
         {
             if (_currentItem != null)
             {
                 AvatarView.Instance.RemoveGear(_currentItem.Object as StoreItem);
                 _currentItem.Unselect();
                 _currentItem.SetBackground();
                 _currentItem = null;
             }
             ItemTitle.text       = "";
             ItemDescription.text = "";
             CoinsCostText.Text   = "";
             CoinsImage.Deactivate();
             GemCostText.Text = "";
             GemImage.Deactivate();
             BuyButton.Deactivate();
         }
     }
 }
        protected async Task _createObjectTest(IStorage storage)
        {
            var storeItems = new StoreItems();

            storeItems["create1"] = new TestItem()
            {
                Id = "1"
            };
            dynamic newItem2 = new StoreItem();

            newItem2.Id           = "2";
            newItem2.dyno         = "dynamicStuff";
            storeItems["create2"] = newItem2;

            await storage.Write(storeItems);

            dynamic result = await storage.Read(new string[] { "create1", "create2" });

            Assert.IsNotNull(result.create1, "create1 should not be null");
            Assert.AreEqual(result.create1.Id, "1", "strong create1.id should be 1");
            Assert.IsNotNull(result.create2, "create2 should not be null");
            Assert.AreEqual(result.create2.Id, "2", "create2.id should be 2");
            Assert.AreEqual(result.create2.dyno, "dynamicStuff", "create2.dyno should be dynoStuff");
        }
Esempio n. 14
0
    public void SetGearBonusWithoutItemsOfType(string itemType)
    {
        int healthBonus = 0;
        int speedBonus  = 0;
        int rangeBonus  = 0;

        StoreItem item = null;

        for (int i = 0; i < Database.Instance.GearList.Count; i++)
        {
            item = Database.Instance.GearList[i];

            if (Avatar.Instance.EquippedIDs.Contains(item.Name) && item.Type != itemType)
            {
                healthBonus += item.HealthBonus;
                speedBonus  += item.SpeedBonus;
                rangeBonus  += item.RangeBonus;
            }
        }

        Avatar.Instance.HealthBonus = healthBonus;
        Avatar.Instance.SpeedBonus  = speedBonus;
        Avatar.Instance.RangeBonus  = rangeBonus;
    }
        public async Task <IActionResult> AddStoreItem(StoreItem storeItem)
        {
            StoreItem receivedReservation = new StoreItem();

            using (var httpClient = new HttpClient())
            {
                StringContent content = new StringContent(JsonConvert.SerializeObject(storeItem), Encoding.UTF8, "application/json");

                using var response = await httpClient.PostAsync(localAddress, content);

                string apiResponse = await response.Content.ReadAsStringAsync();

                if (response.StatusCode == System.Net.HttpStatusCode.OK)
                {
                    receivedReservation = JsonConvert.DeserializeObject <StoreItem>(apiResponse);
                }
                else if (response.StatusCode == System.Net.HttpStatusCode.Unauthorized)
                {
                    ViewBag.Result = apiResponse;
                    return(View());
                }
            }
            return(View(receivedReservation));
        }
        private void Button_Click_SaveAll(object sender, RoutedEventArgs ev)
        {
            if (!_model.IsValid())
            {
                MessageBox.Show("ОШИБКА"); return;
            }
            StoreItem item;

            if (_isEditMode)
            {
                int id = _model.StoreItemID;

                item                       = _db.StoreItems.GetByID(id);
                item.Description           = _model.Description;
                item.AttributeProductPairs = _model.AttributeProductPairs;
                item.Price                 = _model.Price;
                item.StoreItemType         = _model.StoreItemType;
                item.Title                 = Title;

                _db.TryAction(DatabaseActions.UPDATE, item);
            }
            else
            {
                item = new StoreItem()
                {
                    Description           = _model.Description,
                    AttributeProductPairs = _model.AttributeProductPairs,
                    Price         = _model.Price,
                    StoreItemType = _model.StoreItemType,
                    Title         = _model.Title
                };
                _db.TryAction(DatabaseActions.ADD, item);
            }
            _db.SaveChanges();
            _w.LoadInfoFromDb();
        }
Esempio n. 17
0
    override public void SetParams(bool is_new, object[] parms)
    {
        base.SetParams(is_new, parms);
        _ack = parms[0] as C2G.LootCreature10Ack;
        if (parms.Length >= 2)
        {
            m_StoreItem = parms[1] as StoreItem;
        }
        else
        {
            m_StoreItem = null;
        }

        if (is_new)
        {
            ShowImmediately = false;
            Init();
        }
        else
        {
            ShowImmediately  = true;
            showNextItemTime = Time.time + delay;
        }
    }
Esempio n. 18
0
 public StoreItem Put([FromForm] StoreItem res) => repository.UpdateStoreItem(res);
Esempio n. 19
0
 private StoreItem getSellItem(long itemID, float priceAdjustment, int count, GameDataSet gameDataSet)
 {
     StoreItem storeItem = null;
     Item i = ItemFactory.getItemFromIndex(itemID, gameDataSet);
     if (i != null)
     {
         storeItem = new StoreItem();
         storeItem.item = i;
         storeItem.count = count;
         storeItem.price = (long)Math.Round(i.price  * priceAdjustment);
         storeItem.selected = 1;
         return storeItem;
     }
     return storeItem;
 }
Esempio n. 20
0
 private void UpdateText(Guid guid, StoreItem storeItem)
 {
     moneyText.text = StoreManager.Instance.AvailableCurrency.ToString();
 }
Esempio n. 21
0
    private GameObject UpdateStoreItem(StoreItem storeItem, bool isStore) {
        GameObject storeItemObject = (GameObject)Instantiate(StoreItemPrefab);

        var itemSprite = gameDataObject.assetLibrary.getSprite(storeItem.item.sheetname,storeItem.item.spriteindex);

        UIHelper.UpdateSpriteComponent(storeItemObject, "ItemImg", itemSprite);
        UIHelper.UpdateTextComponent(storeItemObject, "ItemName", storeItem.item.name);
        UIHelper.UpdateTextComponent(storeItemObject, "ItemStats", storeItem.item.ToString());

        UIHelper.UpdateTextComponent(storeItemObject, "ItemPrice", storeItem.price.ToString());
        var priceText = UIHelper.getGameObjectWithName(storeItemObject, "ItemPrice", typeof(Text)).GetComponent<Text>();
        if (isStore && storeItem.price > gameDataObject.playerGameCharacter.money)
        {
            priceText.color = Color.red;
        }

        Button buyButton = UIHelper.getGameObjectWithName(storeItemObject, "ButtonBuy", typeof(Button)).GetComponent<Button>();

        if (isStore)
        {
            buyButton.onClick.AddListener(() => BuyItem(storeItem.item.ID));
            storeItemObject.transform.SetParent(buyPanel.transform, true);
        }
        else
        {
            buyButton.onClick.AddListener(() => SellItem(storeItem.item.ID));
            UIHelper.UpdateTextComponent(buyButton.gameObject, "Text", "Sell");
            storeItemObject.transform.SetParent(sellPanel.transform, true);
        }

        storeItem.selected = 1;
        if (storeItem.count > 1)
        {
             var itemCountText = UIHelper.getGameObjectWithName(storeItemObject, "ItemCount", typeof(Text)).GetComponent<Text>();
            itemCountText.text = storeItem.selected + "/" + storeItem.count;

            Button lessButton = UIHelper.getGameObjectWithName(storeItemObject, "ButtonCountLess", typeof(Button)).GetComponent<Button>();
            lessButton.onClick.AddListener(() => ItemSelectChange(false, isStore, storeItem.item.ID));
            Button moreButton = UIHelper.getGameObjectWithName(storeItemObject, "ButtonCountMore", typeof(Button)).GetComponent<Button>();
            moreButton.onClick.AddListener(() => ItemSelectChange(true, isStore, storeItem.item.ID));
        }

        return storeItemObject;

    }
Esempio n. 22
0
    private void removeStoreItemList(StoreItem storeItem)
    {
        if (storeItem != null)
        {
            if (storeItem.count > storeItem.selected)
            {
                storeItem.count -= storeItem.selected;
                storeItem.selected = 1;
            }
            else
            {
                storeItemList.Remove(storeItem);
            }
        }

    }
Esempio n. 23
0
 public void OnStoreItemChanged(StoreItem item)
 {
     MainStoreItemChangedEvent?.Invoke(item);
 }
Esempio n. 24
0
        public bool OnCommand(Character chr, string args)
        {
            if (args == null || args == "")
            {
                chr.WriteToDisplay("Usage: impaddstore <notes+use+plus+signs> <target> <item id> <sell price> <stocked> (if stocked -1 item is always available)");
                return(false);
            }

            string[] sArgs = args.Split(" ".ToCharArray());

            if (sArgs.Length != 5)
            {
                chr.WriteToDisplay("Incorrect number of arguments. Usage: impaddstore <notes+use+plus+signs> <target> <item id> <sell price> <stocked> (if stocked -1 item is always available)");
                return(false);
            }

            Character target = GameSystems.Targeting.TargetAquisition.FindTargetInView(chr, sArgs[1], false, true);

            if (target == null)
            {
                chr.WriteToDisplay("Target not found: " + sArgs[1]);
                return(false);
            }

            if (!(target is Merchant))
            {
                chr.WriteToDisplay("Target is not a merchant.");
                return(false);
            }

            int itemID = -1;

            if (!Int32.TryParse(sArgs[2], out itemID))
            {
                chr.WriteToDisplay("Invalid item ID number: " + sArgs[2]);
                return(false);
            }

            Item item = Item.CopyItemFromDictionary(itemID);

            if (item == null)
            {
                chr.WriteToDisplay("Item ID not found in Item Catalog: " + itemID);
                return(false);
            }

            double sellPrice = 0;

            if (!Double.TryParse(sArgs[3], out sellPrice))
            {
                chr.WriteToDisplay("Invalid sell price: " + sArgs[3]);
                return(false);
            }

            int stocked = 0;

            if (!Int32.TryParse(sArgs[4], out stocked) || stocked < -1)
            {
                chr.WriteToDisplay("Invalid stocked amount: " + sArgs[4]);
                return(false);
            }

            StoreItem storeItem = new StoreItem();

            storeItem.notes     = sArgs[0].Replace("+", " ");
            storeItem.itemID    = item.itemID;
            storeItem.original  = true;
            storeItem.sellPrice = sellPrice;
            storeItem.stocked   = stocked;
            storeItem.seller    = "";
            storeItem.restock   = stocked;
            storeItem.charges   = item.charges;
            storeItem.figExp    = item.figExp;

            if (DAL.DBWorld.InsertStoreItem((target as Merchant).SpawnZoneID, storeItem) != -1)
            {
                chr.WriteToDisplay(item.notes + " inserted into store items for " + target.Name + " for " + sellPrice + ".");
                return(true);
            }

            return(false);
        }
Esempio n. 25
0
        private void ListView_ItemClick_1(object sender, ItemClickEventArgs e)
        {
            StoreItem item = (StoreItem)e.ClickedItem;

            ViewModel.TapCommand.Execute(item);
        }
Esempio n. 26
0
 public async Task<APIResult> Update(StoreItem si)
 {
     return await liapi.Update(si.id.ToString(), si, InstallationId.ToString());
 }
Esempio n. 27
0
    public void DisplayItemPurchasePanel(StoreItem item)
    {
        itemInfo = item;
        itemNameDisplay.text = item.storeItemInfo.itemName;
        itemCreditCostDisplay.text = item.storeItemInfo.creditValue.ToString();
        itemCoinCostDisplay.text = item.storeItemInfo.coinValue.ToString();
        itemQuantityAmount.text = "1";

        itemTexture.mainTexture = item.gameObject.GetComponentInChildren<UITexture>().mainTexture;

        ChangePurchaseButtonDisplay(item.storeItemInfo.creditValue, item.storeItemInfo.coinValue);
    }
Esempio n. 28
0
         private List<StoreItem> getStoreItemListFromItemIdList(List<long> itemIdList, GameDataSet gameDataSet, int count, float priceAdjustment)
         {
             List<StoreItem> storeItemList = new List<StoreItem>(); 
             foreach(long id in itemIdList){
                 var item = ItemFactory.getItemFromIndex(id, gameDataSet);
                 if (item.price > 0)
                 {
                     StoreItem tempStoreItem = new StoreItem();
                     tempStoreItem.item = item;
                     tempStoreItem.count = count;
                     tempStoreItem.price = (long)Math.Round(tempStoreItem.item.price * priceAdjustment);
                     tempStoreItem.selected = 1;

                     storeItemList.Add(tempStoreItem);
                 }
              
             }

             return storeItemList;

             
         }
Esempio n. 29
0
        private void Read()
        {
            try
            {

                // Beolvasandó dokumentumok listája
                LinkedList<XDocument> documentList = new LinkedList<XDocument>();

                // Imprortálások bekérése
                XDocument doc = XDocument.Load(System.IO.Path.Combine(this.Path, this.FileName));

                // Rekurzív függvény az importálások kifejtésére
                CheckImports(documentList, doc, Path);

                //--------------------------------------------------------------------

                // Az összes fájl feldolgozása
                foreach (XDocument xd in documentList)
                {
                    XNamespace targetNS = "";
                    XNamespace defNS = "";
                    try
                    {
                        targetNS = (string)xd.Element("definitions").Attribute("targetNamespace");
                        defNS = "";
                    }
                    catch { }
                    try
                    {
                        targetNS = (string)xd.Element("schema").Attribute("targetNamespace");
                        defNS = "";
                    }
                    catch { }
                    try
                    {
                        targetNS = (string)xd.Element(xsdNS + "schema").Attribute("targetNamespace");
                        defNS = xsdNS;
                    }
                    catch { }
                    try
                    {
                        targetNS = (string)xd.Element(wsdlNS + "definitions").Attribute("targetNamespace");
                        defNS = wsdlNS;
                    }
                    catch { }

                    if (!nsDictionary.ContainsKey(targetNS))
                    {
                        Namespace myNs = new Namespace()
                        {
                            Name = "namespace" + fileCount.ToString(),
                            Uri = targetNS.NamespaceName
                        };

                        nsDictionary.Add(targetNS, myNs);
                        fileCount++;
                    }

                    // services
                    var services = from c in xd.Descendants(wsdlNS + "service")
                                   select c;

                    foreach (XElement xe in services)
                    {
                        StoreItem coll = new StoreItem()
                        {
                            name = (string)xe.Attribute("name"),
                            definition = xe,
                            objectType = StoreItemType.service,
                            ownNS = targetNS
                        };

                        store.Add(coll);
                    }

                    // binding
                    var bindings = from c in xd.Descendants(wsdlNS + "binding")
                                   select c;

                    foreach (XElement xe in bindings)
                    {
                        StoreItem coll = new StoreItem()
                        {
                            name = (string)xe.Attribute("name"),
                            definition = xe,
                            objectType = StoreItemType.binding,
                            ownNS = targetNS
                        };

                        store.Add(coll);
                    }

                    // porttype
                    var portTypes = from c in xd.Descendants(wsdlNS + "portType")
                                    select c;

                    foreach (XElement xe in portTypes)
                    {
                        StoreItem coll = new StoreItem()
                        {
                            name = (string)xe.Attribute("name"),
                            definition = xe,
                            objectType = StoreItemType.portType,
                            ownNS = targetNS
                        };

                        store.Add(coll);
                    }

                    // message
                    var messages = from c in xd.Descendants(wsdlNS + "message")
                                   select c;

                    foreach (XElement xe in messages)
                    {
                        StoreItem coll = new StoreItem()
                        {
                            name = (string)xe.Attribute("name"),
                            definition = xe,
                            objectType = StoreItemType.message,
                            ownNS = targetNS
                        };

                        store.Add(coll);
                    }

                    //TODO: <type> és <schema> ellenőrzése a targetNamespace miatt!!!
                    var schemas = from c in xd.Descendants(xsdNS + "schema")
                                  select c;

                    foreach (XElement schema in schemas)
                    {
                        targetNS = (string)schema.Attribute("targetNamespace");

                        if (!nsDictionary.ContainsKey(targetNS))
                        {
                            Namespace myxsdNs = new Namespace()
                            {
                                Name = "namespace" + fileCount.ToString(),
                                Uri = targetNS.NamespaceName
                            };

                            nsDictionary.Add(targetNS, myxsdNs);
                            fileCount++;
                        }

                        // simpleTypes
                        var simpleTypes = from c in schema.Elements(xsdNS + "simpleType")
                                          select c;
                        //var simpleTypes = from c in xd.Descendants(xsdNS + "simpleType")
                        //                  select c;

                        foreach (XElement xe in simpleTypes)
                        {
                            StoreItem coll = new StoreItem()
                            {
                                name = (string)xe.Attribute("name"),
                                definition = xe,
                                objectType = StoreItemType.enumType,
                                ownNS = targetNS
                            };

                            store.Add(coll);
                        }

                        // complexTypes
                        //var complexTypes = from c in xd.Descendants(xsdNS + "complexType")
                        //                   select c;
                        var complexTypes = from c in schema.Elements(xsdNS + "complexType")
                                           select c;

                        foreach (XElement xe in complexTypes)
                        {

                            StoreItem coll = new StoreItem()
                            {
                                name = (string)xe.Attribute("name"),
                                definition = xe,
                                objectType = StoreItemType.complexType,
                                ownNS = targetNS

                            };

                            store.Add(coll);
                        }

                        var elements = from c in schema.Elements(xsdNS + "element")
                                       select c;

                        foreach (XElement xe in elements)
                        {
                            if (xe.Attribute("type") != null)
                            {
                                StoreItem coll = new StoreItem()
                                {
                                    name = (string)xe.Attribute("name"),
                                    definition = xe,
                                    objectType = StoreItemType.unNamedElementType,
                                    ownNS = targetNS
                                };
                                //Wr(coll.name);
                                store.Add(coll);
                            }
                            else
                            {
                                XAttribute nameAttribute = xe.Attribute("name");
                                XElement cType = xe.Element(xsdNS + "complexType");
                                XElement modifiendXe = cType;
                                modifiendXe.Add(nameAttribute);
                                StoreItem coll = new StoreItem()
                                {
                                    name = (string)modifiendXe.Attribute("name"),
                                    definition = modifiendXe,
                                    objectType = StoreItemType.complexType,
                                    ownNS = targetNS
                                };
                                //Wr(coll.name);
                                store.Add(coll);
                            }
                        }
                    }
                }
            }
            catch (Exception e)
            {
                Console.WriteLine(e.Message);
                throw;
            }
        }
Esempio n. 30
0
        bool shop_sudo(PlayerSession session_my, string[] args)
        {
            int    id           = 0;
            int    max          = 0;
            string name         = "";
            int    sell         = 0;
            int    buy          = 0;
            bool   bool_is_sell = false;
            bool   bool_is_buy  = false;

            if (session_my.IsAdmin != true)
            {
                hurt.SendChatMessage(session_my, $"{Display_message("No Permission", session_my.SteamId.ToString())}");
                return(false);
            }
            try
            {
                id   = int.Parse(args[1]);
                max  = int.Parse(args[2]);
                name = args[3];
                sell = int.Parse(args[4]);
                buy  = int.Parse(args[5]);
                if (args[6] == "true" || int.Parse(args[6]) == 1)
                {
                    bool_is_sell = true;
                }
                if (args[7] == "true" || int.Parse(args[7]) == 1)
                {
                    bool_is_buy = true;
                }
            }
            catch (Exception ex)
            {
                id           = 0;
                max          = 0;
                name         = "";
                sell         = 0;
                buy          = 0;
                bool_is_sell = false;
                bool_is_buy  = false;
            }
            if (id > 0 && store.StoreItems.ContainsKey(id) != true)
            {
                StoreItem new_item = new StoreItem(id, max, name, sell, buy, bool_is_sell, bool_is_buy);
                store.StoreItems[id] = new_item;
                hurt.SendChatMessage(session_my, $"{Display_message("Item Id", session_my.SteamId.ToString()).Replace("{id}",id.ToString())}");
                hurt.SendChatMessage(session_my, $"{Display_message("Item Name", session_my.SteamId.ToString()).Replace("{name_item}",name)}");
                hurt.SendChatMessage(session_my, $"{Display_message("Item Max In Stack", session_my.SteamId.ToString()).Replace("{stack}",max.ToString())}");
                hurt.SendChatMessage(session_my, $"{Display_message("Item Price Sell", session_my.SteamId.ToString()).Replace("{price_sell}",sell.ToString())}");
                hurt.SendChatMessage(session_my, $"{Display_message("Item Price Buy", session_my.SteamId.ToString()).Replace("{price_buy}",buy.ToString())}");
                hurt.SendChatMessage(session_my, $"{Display_message("Is Sell", session_my.SteamId.ToString()).Replace("{is_sell}",bool_is_sell.ToString())}");
                hurt.SendChatMessage(session_my, $"{Display_message("Is Buy", session_my.SteamId.ToString()).Replace("{is_buy}",bool_is_buy.ToString())}");

                SaveDataStore();
                return(true);
            }
            else if (id > 0)
            {
                var item = store.StoreItems[id];
                hurt.SendChatMessage(session_my, $"{Display_message("Item Id", session_my.SteamId.ToString()).Replace("{id}",item.id_item.ToString())}");
                hurt.SendChatMessage(session_my, $"{Display_message("Item Name", session_my.SteamId.ToString()).Replace("{name_item}",item.name_item)}");
                hurt.SendChatMessage(session_my, $"{Display_message("Item Max In Stack", session_my.SteamId.ToString()).Replace("{stack}",item.max_item.ToString())}");
                hurt.SendChatMessage(session_my, $"{Display_message("Item Price Sell", session_my.SteamId.ToString()).Replace("{price_sell}",item.price_sell.ToString())}");
                hurt.SendChatMessage(session_my, $"{Display_message("Item Price Buy", session_my.SteamId.ToString()).Replace("{price_buy}",item.price_buy.ToString())}");
                hurt.SendChatMessage(session_my, $"{Display_message("Is Sell", session_my.SteamId.ToString()).Replace("{is_sell}",item.is_sell.ToString())}");
                hurt.SendChatMessage(session_my, $"{Display_message("Is Buy", session_my.SteamId.ToString()).Replace("{is_buy}",item.is_buy.ToString())}");
                store.StoreItems[id].id_item    = id;
                store.StoreItems[id].name_item  = name;
                store.StoreItems[id].max_item   = max;
                store.StoreItems[id].price_sell = sell;
                store.StoreItems[id].price_buy  = buy;
                store.StoreItems[id].is_buy     = bool_is_buy;
                store.StoreItems[id].is_sell    = bool_is_sell;
                hurt.SendChatMessage(session_my, $"{Display_message("Item Id", session_my.SteamId.ToString()).Replace("{id}",item.id_item.ToString())}");
                hurt.SendChatMessage(session_my, $"{Display_message("Item Name", session_my.SteamId.ToString()).Replace("{name_item}",item.name_item)}");
                hurt.SendChatMessage(session_my, $"{Display_message("Item Max In Stack", session_my.SteamId.ToString()).Replace("{stack}",item.max_item.ToString())}");
                hurt.SendChatMessage(session_my, $"{Display_message("Item Price Sell", session_my.SteamId.ToString()).Replace("{price_sell}",item.price_sell.ToString())}");
                hurt.SendChatMessage(session_my, $"{Display_message("Item Price Buy", session_my.SteamId.ToString()).Replace("{price_buy}",item.price_buy.ToString())}");
                hurt.SendChatMessage(session_my, $"{Display_message("Is Sell", session_my.SteamId.ToString()).Replace("{is_sell}",item.is_sell.ToString())}");
                hurt.SendChatMessage(session_my, $"{Display_message("Is Buy", session_my.SteamId.ToString()).Replace("{is_buy}",item.is_buy.ToString())}");
                SaveDataStore();
                return(true);
            }
            else
            {
                shop_help(session_my);
                return(false);
            }
        }
Esempio n. 31
0
        public Task <StoreItem> EditStoreItemAsync(StoreItem item)
        {
            string url = "EditStoreItem";

            return(_outCalls.PostData <StoreItem>(url, item));
        }
Esempio n. 32
0
        bool buy_item(PlayerSession session, string[] args)
        {
            if (args != null && args.Length >= 2)
            {
                int    id         = 0;
                int    number     = 0;
                int    place      = 0;
                int    price      = 0;
                string name_money = "";

                name_money = Banks.Call <string>("get_name_money");
                try
                {
                    id = int.Parse(args[0]);
                }
                catch (Exception ex)
                {
                    id = FindIDItemByName(args[0]);
                }
                try
                {
                    number = int.Parse(args[1]);
                }
                catch (Exception ex)
                {
                    number = 1;
                }
                if (id > 0)
                {
                    StoreItem item = getItemByID(id);
                    if (item == null)
                    {
                        hurt.SendChatMessage(session, $"{Display_message("Item not sell", session.SteamId.ToString())}");
                        return(false);
                    }
                    else
                    {
                        if (item.is_sell == true)
                        {
                            if (number < 0)
                            {
                                number = 0;
                            }
                            if (item.max_item > 0)
                            {
                                place = number / item.max_item;
                                if (number % item.max_item > 0)
                                {
                                    place = place + 1;
                                }
                            }
                            else
                            {
                                place = number;
                            }
                            if (getNbInvPlaceFree(session) >= place)
                            {
                                price = number * item.price_sell;
                                if (Banks.Call <int>("lost_money_poket", price, session) == 1)
                                {
                                    give_item(session, item, number);
                                    hurt.SendChatMessage(session, $"{Display_message("You have buy", session.SteamId.ToString()).Replace("{number}",number.ToString()).Replace("{name_item}",item.name_item).Replace("{price}",price.ToString()).Replace("{name_money}",name_money.ToString())}");
                                }
                                else
                                {
                                    hurt.SendChatMessage(session, $"{Display_message("You no money", session.SteamId.ToString())}");
                                }
                            }
                            else
                            {
                                hurt.SendChatMessage(session, $"{Display_message("You no place", session.SteamId.ToString())}");
                            }
                            return(true);
                        }
                        else
                        {
                            hurt.SendChatMessage(session, $"{Display_message("Item not sell", session.SteamId.ToString())}");
                        }
                    }
                }
                else
                {
                    hurt.SendChatMessage(session, $"{Display_message("Item not sell", session.SteamId.ToString())}");
                }
            }
            return(false);
        }
Esempio n. 33
0
		public static IEnumerable<BattleItem> Create(StoreItem item)
		{
			return Enumerable.Repeat(item.ItemType, item.Count).Select(Create);
		}
Esempio n. 34
0
 private void addStoreItemList(StoreItem storeItem)
 {
     StoreItem matchingItem = storeItemList.Where(x => x.item.ID == storeItem.item.ID).FirstOrDefault();
     if (matchingItem != null)
     {
         matchingItem.count += storeItem.selected;
         matchingItem.selected = 1;
     }
     else
     {
        
         storeItemList.Add(copyStoreItem(storeItem));
     }
 }
Esempio n. 35
0
        /// <summary>
        /// 
        /// </summary>
        /// <param name="mailIndex"></param>
        /// <param name="command"></param>
        /// <param name="flags"></param>
        /// <returns></returns>
        public ImapCommandResult ExecuteStore(Int64 mailIndex, StoreItem command, params String[] flags)
        {
            if (flags.Length == 0) return null;

            this.ValidateState(ImapConnectionState.Authenticated, true);

            StringBuilder sb = new StringBuilder(256);
            sb.Append(this.Tag);
            sb.Append(" STORE ");
            sb.Append(mailIndex);
            sb.Append(" ");
            if (command == StoreItem.FlagsReplace)
            {
                sb.Append("FLAGS ");
            }
            else if (command == StoreItem.FlagsReplaceSilent)
            {
                sb.Append("FLAGS.SILENT ");
            }
            else if (command == StoreItem.FlagsAdd)
            {
                sb.Append("+FLAGS ");
            }
            else if (command == StoreItem.FlagsAddSilent)
            {
                sb.Append("+FLAGS.SILENT ");
            }
            else if (command == StoreItem.FlagsRemove)
            {
                sb.Append("-FLAGS ");
            }
            else if (command == StoreItem.FlagsRemoveSilent)
            {
                sb.Append("-FLAGS.SILENT ");
            }
            else
            {
                throw new ArgumentException("command");
            }
            sb.Append("(");
            for (int i = 0; i < flags.Length; i++)
            {
                sb.Append(flags[i]);
                if (i < flags.Length - 1)
                {
                    sb.Append(" ");
                }
            }
            sb.Append(")");

            return this.Execute(sb.ToString());
        }
Esempio n. 36
0
    private StoreItem copyStoreItem(StoreItem oldStoreItem)
    {
        StoreItem newStoreItem = new StoreItem()
        {
            item = ItemFactory.getItemFromIndex(oldStoreItem.item.ID, gameDataObject.gameDataSet),
            count = oldStoreItem.selected,
            price = oldStoreItem.price,
            selected = 1

        };
        return newStoreItem;
    }
Esempio n. 37
0
 public void UpdateProduct(StoreItem product)
 {
     _db.Entry(product).State = EntityState.Modified;
 }
Esempio n. 38
0
    private void LoadPlayerList()
    {
        playerItemList = new List<StoreItem>();

        var itemList = gameDataObject.playerGameCharacter.inventory.GroupBy(x => x.ID).Select(x=>x.First()).ToList();
    
        foreach (var item in itemList)
        {
            StoreItem tempStoreItem = new StoreItem();
            tempStoreItem.item = item;
            tempStoreItem.price = storeTree.getBuyPrice(item, gameDataObject.gameDataSet);
            tempStoreItem.count = gameDataObject.playerGameCharacter.inventory.Count(x => x.ID == item.ID);
            tempStoreItem.selected = 1;

            playerItemList.Add(tempStoreItem);
        }
    }
Esempio n. 39
0
        /// <summary>
        /// Handles factorys work cycle
        /// </summary>
        public override void OnNextTurn()
        {
            if (BuildQueueIndex == -1 && BuildQueue.Count > 0)
            {
                BuildQueueIndex = 0;
                BuildProgress   = 0;
                if (HasAOC)
                {
                    lastProductionMark = GameEngine.Instance.CurrentCycle + GameEngine.Instance.CurrentYear * 1000;

                    BuildProgress = -1;
                }
            }

                        #if DebugStations
            if (BuildQueueIndex != -1)
            {
                Console.WriteLine("Factory module on station '" + parent.Title + "' \r\n\thas a work cycle (Build progress " + BuildProgress.ToString() + " of " + GameEngine.Instance.ItemTemplates[BuildQueue[BuildQueueIndex].ItemId].BuildTime.ToString() + ").");
            }
                        #endif

            if (BuildQueueIndex != -1 && (GameEngine.Instance.CurrentCycle + GameEngine.Instance.CurrentYear * 1000 - lastProductionMark) >= productionPrepareTime)
            {
                if (!resourcesReady && Store != null)
                {
                    StoreItem it = GameEngine.Instance.ItemTemplates[BuildQueue[BuildQueueIndex].ItemId];

                    bool isOk = true;
                    foreach (FactoryResource res in it.Resources)
                    {
                        isOk &= Store.CheckStorage(
                            GameEngine.Instance.ItemTemplates[res.itemId].Type != ItemType.Mineral,
                            res.itemId, res.amount);
                    }

                    if (isOk)
                    {
                        foreach (FactoryResource res in it.Resources)
                        {
                            isOk &= Store.RemoveFromStorage(
                                GameEngine.Instance.ItemTemplates[res.itemId].Type != ItemType.Mineral,
                                res.itemId, res.amount);
                        }

                        resourcesReady = true;
                    }
                }

                if (resourcesReady)
                {
                    if (ProductionTeam != null)
                    {
                        BuildProgress += ProductionTeam.GetProductionValue();
                    }
                    else
                    {
                        if (HasAOC)
                        {
                            BuildProgress += 200;
                        }
                    }

                    if (BuildProgress >= GameEngine.Instance.ItemTemplates[BuildQueue[BuildQueueIndex].ItemId].BuildTime)
                    {
                        Store.AddToStorage(true, BuildQueue[BuildQueueIndex].ItemId, 1);

                                                #if DebugStations
                        if (BuildQueueIndex != -1)
                        {
                            Console.WriteLine("Item " + GameEngine.Instance.ItemTemplates[BuildQueue[BuildQueueIndex].ItemId].Title + " built.");
                        }
                                                #endif


                        if (!BuildQueue[BuildQueueIndex].Repeat)
                        {
                            GuiMenu       mnu = null;
                            GuiButtonInfo btn = null;

                            if (GameEngine.Instance.GuiMenuModule.ContainsKey("factoryMenuItems"))
                            {
                                mnu = GameEngine.Instance.GuiMenuModule["factoryMenuItems"];

                                foreach (KeyValuePair <string, GuiButtonInfo> cur in mnu.Buttons)
                                {
                                    if (((GuiButtonParamExecuteModuleMethod)cur.Value.Params["CycleQueueItem"]).methodParams[0].Value == BuildQueue[BuildQueueIndex].ItemId)
                                    {
                                        btn = cur.Value;

                                        break;
                                    }
                                }

                                btn.PictureColor = Color.Red;
                            }

                            BuildQueue.RemoveAt(BuildQueueIndex);
                        }
                        else
                        {
                            BuildQueueIndex++;
                        }

                        resourcesReady = false;

                        BuildProgress = 0;
                        if (HasAOC)
                        {
                            lastProductionMark = GameEngine.Instance.CurrentCycle + GameEngine.Instance.CurrentYear * 1000;

                            BuildProgress = -1;
                        }
                    }
                }
            }

            if (BuildQueueIndex >= BuildQueue.Count)
            {
                if (BuildQueue.Count > 0)
                {
                    BuildQueueIndex = 0;
                }
                else
                {
                    BuildQueueIndex = -1;
                }
            }
        }
Esempio n. 40
0
 public static void ChangeStoreItemStock(StoreItem storeItem, int amount)
 {
     storeItem.InStock += amount;
     StoreItemProcessor.UpdateStoreItem(storeItem);
 }
Esempio n. 41
0
        public override void OnRenderInterface(Microsoft.DirectX.Direct3D.Sprite Overlay)
        {
            GuiMenu mnu = GameEngine.Instance.GuiMenuModule["factoryMenu"];

            TextureManagerItem it;

            if (BuildQueueIndex != -1 && BuildProgress > -1)
            {
                StoreItem sit = GameEngine.Instance.ItemTemplates[BuildQueue[BuildQueueIndex].ItemId];
                GameEngine.Instance.GuiFonts["fntGui"].DXFont.DrawText(Overlay, sit.Title, new Rectangle(mnu.Location.X, mnu.Location.Y + 40, 200, 20), DrawTextFormat.Left | DrawTextFormat.VerticalCenter, Color.Green);

                if (GameEngine.Instance.GuiTextures.ContainsKey("placeholder"))
                {
                    it = GameEngine.Instance.mainTextures.GetTexture(GameEngine.Instance.GuiTextures["placeholder"].textureIdx);
                    if (it != null && it.Texture != null)
                    {
                        Overlay.Transform = Matrix.Identity;

                        Overlay.Draw(it.Texture, new Rectangle(0, 0, 200, 125), new Vector3(0, 0, 0), new Vector3(mnu.Location.X, mnu.Location.Y + 69, 0), Color.FromArgb(255, 13, 13, 13).ToArgb());
                    }
                }

                if (GameEngine.Instance.GuiTextures.ContainsKey(sit.Picture))
                {
                    it = GameEngine.Instance.mainTextures.GetTexture(GameEngine.Instance.GuiTextures[sit.Picture].textureIdx);
                    if (it != null && it.Texture != null)
                    {
                        Overlay.Transform = Matrix.Identity;

                        Overlay.Draw(it.Texture, new Rectangle(sit.TextureArea.Width * ((BuildProgress * 3) / sit.BuildTime + 1), 0, sit.TextureArea.Width, sit.TextureArea.Height), new Vector3(sit.TextureArea.Width, 0, 0), new Vector3(mnu.Location.X + 200, mnu.Location.Y + 69, 0), Color.White.ToArgb());
                    }
                }
            }

            if (HasAOC)
            {
                if (GameEngine.Instance.GuiTextures.ContainsKey("gameScreen.Production.AOC"))
                {
                    it = GameEngine.Instance.mainTextures.GetTexture(GameEngine.Instance.GuiTextures["gameScreen.Production.AOC"].textureIdx);
                    if (it != null && it.Texture != null)
                    {
                        Overlay.Transform = Matrix.Identity;

                        Overlay.Draw(it.Texture, new Rectangle(0, 0, 305, 58), new Vector3(0, 0, 0), new Vector3(mnu.Location.X + 366, mnu.Location.Y + 350, 0), Color.White.ToArgb());
                    }
                }
                // TODO: Render the real AOC blink
                if (GameEngine.Instance.GuiTextures.ContainsKey("gameScreen.Storage.ItemBlink"))
                {
                    it = GameEngine.Instance.mainTextures.GetTexture(GameEngine.Instance.GuiTextures["gameScreen.Storage.ItemBlink"].textureIdx);
                    if (it != null && it.Texture != null)
                    {
                        Overlay.Transform = Matrix.Identity;

                        Overlay.Draw(it.Texture, new Rectangle(8 + 42 * ((Environment.TickCount / 70) % 10), 8, 7, 4), new Vector3(0, 0, 0), new Vector3(mnu.Location.X + 366 + 58, mnu.Location.Y + 350 + 22, 0), Color.Red.ToArgb());
                        Overlay.Draw(it.Texture, new Rectangle(8 + 42 * ((Environment.TickCount / 70) % 10), 8, 7, 4), new Vector3(0, 0, 0), new Vector3(mnu.Location.X + 366 + 58, mnu.Location.Y + 350 + 21, 0), Color.Red.ToArgb());
                    }
                }
            }
            else
            {
                GameEngine.Instance.GuiFonts["fntGui"].DXFont.DrawText(Overlay, "LEADER", new Rectangle(mnu.Location.X + 364, mnu.Location.Y + 349, 90, 20), DrawTextFormat.Left | DrawTextFormat.VerticalCenter, Color.Red);
                GameEngine.Instance.GuiFonts["fntGui"].DXFont.DrawText(Overlay, "RANK", new Rectangle(mnu.Location.X + 364, mnu.Location.Y + 369, 90, 20), DrawTextFormat.Left | DrawTextFormat.VerticalCenter, Color.Red);
                GameEngine.Instance.GuiFonts["fntGui"].DXFont.DrawText(Overlay, "STAFF", new Rectangle(mnu.Location.X + 364, mnu.Location.Y + 389, 90, 20), DrawTextFormat.Left | DrawTextFormat.VerticalCenter, Color.Red);

                if (ProductionTeam == null)
                {
                    GameEngine.Instance.GuiFonts["fntGui"].DXFont.DrawText(Overlay, "None", new Rectangle(mnu.Location.X + 454, mnu.Location.Y + 349, 218, 20), DrawTextFormat.Left | DrawTextFormat.VerticalCenter, Color.White);
                }
                else
                {
                    GameEngine.Instance.GuiFonts["fntGui"].DXFont.DrawText(Overlay, ProductionTeam.TeamLeader, new Rectangle(mnu.Location.X + 454, mnu.Location.Y + 349, 218, 20), DrawTextFormat.Left | DrawTextFormat.VerticalCenter, Color.White);
                    GameEngine.Instance.GuiFonts["fntGui"].DXFont.DrawText(Overlay, ProductionTeam.GetTeamRank(), new Rectangle(mnu.Location.X + 454, mnu.Location.Y + 369, 218, 20), DrawTextFormat.Left | DrawTextFormat.VerticalCenter, Color.White);
                    GameEngine.Instance.GuiFonts["fntGui"].DXFont.DrawText(Overlay, ProductionTeam.TeamSize.ToString(), new Rectangle(mnu.Location.X + 454, mnu.Location.Y + 389, 218, 20), DrawTextFormat.Left | DrawTextFormat.VerticalCenter, Color.White);
                }
            }
        }
Esempio n. 42
0
 public StoreItem Post([FromBody] StoreItem res) =>
 repository.AddStoreItem(new StoreItem
 {
     ItemName = res.ItemName,
     Cost     = res.Cost
 });
Esempio n. 43
0
 public string RemoveFromCart([FromBody] StoreItem details)
 {
     HttpContext.Session.Set("active", new byte[] { 1 });
     return(GetUserActions()
            .RemoveFromCart(Guid.Parse(HttpContext.Session.Id), details.StoreID, details.ItemID));
 }
Esempio n. 44
0
 public StoreItem PutID(int id, [FromForm] StoreItem res) => repository.UpdateStoreItem(res);
Esempio n. 45
0
        public void LearningItemControllerTest()
        {
            APIResult res;
            var authapi = RestService.For<IWebAPI_Authorization>(Path.Combine(Properties.MainURL,APIControllers.MainController));

            // authorization as admin
            res = authapi.AuthorizationAsUser(
                new AuthorizationAsUserPost {
                    Login = Properties.AdminLogin,
                    Password = Properties.AdminPsw},Properties.inst_id).Result;
            Assert.IsTrue(res.Result,res.FullMessage);

            // requests rigth
            res = authapi.HasRight(new HasRightPost { Right = UserRights.Collection.Publish },Properties.inst_id).Result;
            Assert.IsTrue(res.Result,res.FullMessage);

            //var liapi = RestService.For<IOLPRestAPI<StoreItem, string>>(Path.Combine(Properties.MainURL,APIControllers.LearningItemsController));
            WebAPI_LearningItems liapi = new WebAPI_LearningItems();
            liapi.Initialization(Properties.MainURL, Guid.Parse(Properties.inst_id));

            Guid id = Guid.NewGuid();
            StoreItem li = new StoreItem { id = id, Description = "Unit testing description", Name = "Unit testing" };

            res = liapi.Delete(id).Result;
            
            // Create
            res = liapi.Create(li).Result;
            Assert.IsTrue(res.Result, res.FullMessage);

            // Update 
            string NewName = "Updated";
            li.Name = NewName;
            res = liapi.Update(li).Result;
            Assert.IsTrue(res.Result, res.FullMessage);

            // Get by id
            StoreItem getbyid = liapi.GetById(id).Result;
            Assert.IsNotNull(getbyid);
            Assert.AreEqual(li.Name, NewName, "Update error");

            // Get by error id
            StoreItemExt getbyiderr = liapi.GetById(Guid.NewGuid()).Result.Clone<StoreItem,StoreItemExt>();
            Assert.IsNull(getbyiderr);

            // Get count
            int count = liapi.GetCount().Result;
            Assert.IsTrue(count > 0,"Get count error");

            // Get list
            List<StoreItem> lst = liapi.GetCollection().Result;
            Assert.IsNotNull(lst);
            Assert.IsTrue(lst.Count > 0);


            // authorization as user
            res = authapi.AuthorizationAsUser(
                new AuthorizationAsUserPost {
                    Login = Properties.UserLogin,
                    Password = Properties.UserPsw},Properties.inst_id).Result;
            Assert.IsTrue(res.Result,res.FullMessage);

            // Create
            res = liapi.Create(li).Result;
            Assert.IsTrue(res.errorcode == APIErrorCodes.YouHaveNotRightForPublish,res.FullMessage);

            // Update 
            res = liapi.Update(li).Result;
            Assert.IsFalse(res.Result, res.FullMessage);

            // Get by id
            getbyid = null;
            getbyid = liapi.GetById(id).Result;
            Assert.IsNotNull(getbyid);
            Assert.AreEqual(li.Name, NewName, "Update error");

            // Get by error id
            getbyiderr = null;
            getbyiderr = liapi.GetById(Guid.NewGuid()).Result.Clone<StoreItem,StoreItemExt>();
            Assert.IsNull(getbyiderr);

            // Get count
            count = 0;
            count = liapi.GetCount().Result;
            Assert.IsTrue(count > 0,"Get count error");

            // Get list
            lst.Clear();
            lst = liapi.GetCollection().Result;
            Assert.IsNotNull(lst);
            Assert.IsTrue(lst.Count > 0);

            // authorization as admin
            res = authapi.AuthorizationAsUser(
                new AuthorizationAsUserPost {
                    Login = Properties.AdminLogin,
                    Password = Properties.AdminPsw},Properties.inst_id).Result;
            Assert.IsTrue(res.Result,res.FullMessage);

            // upload file tests
            res = liapi.AttachFile(id, Path.Combine(Environment.CurrentDirectory,"screenshot_01.png")).Result;
            Assert.IsTrue(res.Result, res.Message);

            res = liapi.AttachFile(id, Path.Combine(Environment.CurrentDirectory, "TextFile1.txt")).Result;
            Assert.IsTrue(res.Result, res.Message);

            res = liapi.FileExists(id, "screenshot_01.png").Result;
            Assert.IsTrue(res.Result, res.Message);

            res = liapi.FileExists(id, "TextFile1.txt").Result;
            Assert.IsTrue(res.Result, res.Message);

            res = liapi.DeleteFile(id, "screenshot_01.png").Result;
            Assert.IsTrue(res.Result, res.Message);

            res = liapi.DeleteFile(id, "TextFile1.txt").Result;
            Assert.IsTrue(res.Result, res.Message);

            res = liapi.FileExists(id, "screenshot_01.png").Result;
            Assert.IsFalse(res.Result, res.Message);

            res = liapi.DeleteRootDirectory(id).Result;
            Assert.IsTrue(res.Result, res.Message);

            // Delete
            res = liapi.Delete(id).Result;
            Assert.IsTrue(res.Result, res.FullMessage);           

        }
Esempio n. 46
0
 public StoreItemEntity MapToEntity(StoreItem model)
 {
     return(new StoreItemEntity {
         Id = model.Id, Code = model.Code, Data = model.Data, UserId = model.UserId
     });
 }
Esempio n. 47
0
 private Boolean SetMailStore(StoreItem storeItem, ImapSystemFlag value, params Int64[] mailIndexList)
 {
     return this.SetMailStore(storeItem, "\\" + value.ToStringFromEnum(), mailIndexList);
 }
Esempio n. 48
0
        public void PublishLearningItem(LearningItem LearningItem,bool UploadVideo)
        {
            APIResult res;

            pb = new ProgressBar_Model {};
            pb.Title = string.Format(Tx.T("Publish.Messages.Publishing"), LearningItem.Name);
            App.AddLongTaskProgressBar(pb);

            try
            {
                // Testing rights
                InteractiveAuthenticationAsUser();

                if (!HasRight(UserRights.Collection.Publish))
                {
                    string msg = Tx.T("Publish.Messages.NoRightForPublish");
                    throw new Exception(msg);
                }

                // Create a dat file
                string DatFile = CreateDatFile(LearningItem);

                // Create an archive
                string ArchiveFile;
                try
                {
                    ArchiveFile = CreateArchive(LearningItem);
                }
                finally
                {
                    File.Delete(DatFile);
                }

                // Create a Store item
                StoreItem si = new StoreItem
                {
                    id = LearningItem.id.guid,
                    Name = LearningItem.Name,
                    Description = LearningItem.Description,
                    YoutubeURL = LearningItem.YoutubeURL,
                    CoverFile = LearningItem.CoverFile,
                    VideoFileName = FileService.GetFileNameWithoutPath(LearningItem.VideoFileName),
                    VideoFileSize = FileService.GetFileSize(LearningItem.VideoFileName),
                    Version = LearningItem.Version
                };
                StoreItem r = WebAPI_LearningItems.GetById(si.id).Result;
                if (r != null)
                {
                    // update
                    res = WebAPI_LearningItems.Update(si).Result;
                }
                else
                {
                    // create
                    res = WebAPI_LearningItems.Create(si).Result;
                }

                if (!res.Result)
                {
                    FileService.DeleteFile(ArchiveFile);
                    throw new Exception(res.Message).Init(Tx.T("Publish.Messages.CantCreateStoreItem"), res.FullMessage);
                }

                // Upload an archive
                try
                {
                    AttachFile(LearningItem, ArchiveFile);
                }
                finally
                {
                    FileService.DeleteFile(ArchiveFile);
                }

                // Upload a cover
                string pathtocover = Path.Combine(FileService.GetPathToLearningItem(LearningItem),LearningItem.CoverFile);
                if (FileService.FileExists(pathtocover))
                {
                    AttachFile(LearningItem, pathtocover);
                }



                // Upload a video
                if (UploadVideo)
                {
                    if (!string.IsNullOrEmpty(LearningItem.VideoFileName))
                    {
                        AttachFile(LearningItem, LearningItem.VideoFileName);
                    }
                }

                LearningItem.Version++;
                EFDbContext.SaveChgs();
            }
            finally
            {
                App.RemoveLongTaskProgressBar(pb);
            }

        }
Esempio n. 49
0
 private Boolean SetMailStore(StoreItem storeItem, String value, params Int64[] mailIndexList)
 {
     this.ValidateState(ImapConnectionState.Authenticated, true);
     for (int i = 0; i < mailIndexList.Length; i++)
     {
         var rs = this.ExecuteStore(mailIndexList[i], storeItem, value);
         if (rs.Status != ImapCommandResultStatus.Ok) { return false; }
     }
     return true;
 }
Esempio n. 50
0
        public Task <StoreItem> ConfirmDeleteStoreItemAsync(StoreItem item)
        {
            string url = "ConfirmDeleteItem";

            return(_outCalls.PostData <StoreItem>(url, item));
        }
Esempio n. 51
0
 /// <summary>
 /// 
 /// </summary>
 /// <param name="mailIndex"></param>
 /// <param name="command"></param>
 /// <param name="flags"></param>
 /// <returns></returns>
 public ImapCommandResult ExecuteStore(Int64 mailIndex, StoreItem command, params ImapSystemFlag[] flags)
 {
     List<String> l = new List<string>();
     foreach (var flag in flags)
     {
         if (flag == ImapSystemFlag.Recent) throw new ArgumentException("You can't set Recent flag.Only server can set this flag.");
         l.Add("\\" + flag.ToStringFromEnum());
     }
     return this.ExecuteStore(mailIndex, command, l.ToArray());
 }