/// <summary>
        /// Funkcja odpowiadajaca za widok skanowania danego srodka trwalego i wyniku skanowania
        /// </summary>
        /// <param name="result">wynik poprzedniego skanowania</param>
        private async void ZXingScannerView_OnScanResult(Result result)
        {
            if (previus != null && (result.Text == previus.Text || ListContainItem(result.Text)))
            {
                Device.BeginInvokeOnMainThread(async() =>
                {
                    await ShowPopup("Już zeskanowano ten przedmiot!");
                });

                return;
            }

            string[] positions;
            int      AssetId;

            try
            {
                positions = result.Text.Split('-');
                AssetId   = Convert.ToInt32(positions[1]);
            }
            catch (Exception)
            {
                Device.BeginInvokeOnMainThread(async() =>
                {
                    await ShowPopup("Zły format kodu");
                });

                return;
            }

            AssetInfoEntity assetInfo = await api.getAssetInfo(AssetId);

            if (assetInfo == null)
            {
                Device.BeginInvokeOnMainThread(async() =>
                {
                    await ShowPopup("Nieznany obiekt");
                });

                return;
            }

            ScanAsset(assetInfo);

            scanningUpdate.Update(AllPositions);

            scannedItem.Add(result.Text);

            previus = result;

            UpdateCounter();
        }
Beispiel #2
0
        public async Task GetAssetInfoTest_AssetNotInAnyReport()
        {
            AssetInfoEntity expected = new AssetInfoEntity
            {
                id   = 33,
                type = new AssetTypeEntity {
                    id = 3, letter = 'm', name = "monitor"
                },
                room = null
            };

            Assert.AreEqual(expected, await apiController.getAssetInfo(33));
        }
Beispiel #3
0
        public async Task GetAssetInfoTest(int id, int typeId, char typeLetter, string typeName, int roomId, string roomName, int buildingId, string buildingName)
        {
            AssetTypeEntity assetTypeEntity = new AssetTypeEntity {
                id = typeId, letter = typeLetter, name = typeName
            };
            BuildingEntity buildingEntity = new BuildingEntity {
                id = buildingId, name = buildingName
            };
            RoomEntity roomEntity = new RoomEntity {
                id = roomId, name = roomName, building = buildingEntity
            };
            AssetInfoEntity expected = new AssetInfoEntity {
                id = id, type = assetTypeEntity, room = roomEntity
            };

            Assert.AreEqual(expected, await apiController.getAssetInfo(id));
        }
        /// <summary>
        /// Funkcja odpowiadajaca za rozpoczecie skanowania danego srodka trwalego
        /// </summary>
        /// <param name="assetInfo">encja informacji o srodku trwalym</param>
        private void ScanAsset(AssetInfoEntity assetInfo)
        {
            try
            {
                if (assetInfo.room == null || assetInfo.room.id != Room.id)
                {
                    // Nowy asset

                    AllPositions.Add(new ScanPosition(assetInfo, assetInfo.room, Room));

                    Device.BeginInvokeOnMainThread(async() =>
                    {
                        await ShowPopup("Zeskanowano przedmiot z innej sali");
                    });
                }
                else
                {
                    // Zapisz jako zeskanowany

                    AllPositions.Find(x => x.ScannedId == assetInfo.id).ItemMoved();

                    Device.BeginInvokeOnMainThread(async() =>
                    {
                        await ShowPopup();
                    });
                }
            }
            catch (Exception)
            {
                Device.BeginInvokeOnMainThread(async() =>
                {
                    await ShowPopup("Wystąpił błąd");
                });

                return;
            }
        }
Beispiel #5
0
        public async Task GetAssetInfoTest_NotExist(int id)
        {
            AssetInfoEntity assetInfo = await apiController.getAssetInfo(id);

            Assert.AreEqual(null, assetInfo);
        }