Esempio n. 1
0
 public MainBatchAssets(ScanResponce scanResponce, ViewAsset Viewasset)
 {
     Master = new MenuPage();
     {
         Detail = new BatchAssets(scanResponce, Viewasset);
     }
 }
Esempio n. 2
0
 public MainManagerAssetView(ViewAsset Viewasset, ScanResponce scanResponce)
 {
     Master = new MenuPage();
     {
         Detail = new ManagerAssetView(Viewasset, scanResponce);
     }
 }
Esempio n. 3
0
        public async Task <ScanResponce> GetScanUser(string assetId)
        {
            //client.DefaultRequestHeaders.Add("X-Access-Token", Constants.token);
            //client.DefaultRequestHeaders.TryAddWithoutValidation("Content-Type", "application/json; charset=utf-8");
            string url  = Constants.uri + "/LabAsset/" + assetId;
            var    json = await client.GetStringAsync(url);

            ScanResponce response = JsonConvert.DeserializeObject <ScanResponce>(json.ToString());

            // ScanResponce response = await Task.Run(() =>
            //JsonConvert.DeserializeObject<ScanResponce>(json));
            return(response);
        }
        public BatchAssets(ScanResponce scanResponce, ViewAsset Viewasset)
        {
            InitializeComponent();
            if (scanResponce != null)
            {
                AssetEntry.Text       = scanResponce.assetId;
                DescriptionEntry.Text = scanResponce.description;
                LocationEntry.Text    = scanResponce.status;
                string quantity = scanResponce.quantity.ToString();
                QuantityEntry.Text = quantity;
                LastUpdated.Text   = scanResponce.timeLastUpdated;
                LastScanned.Text   = scanResponce.timeLastScanned;
                commentsEntry.Text = scanResponce.comment;
            }
            else
            {
            }
            if (Viewasset != null)
            {
                AssetEntry.Text       = Viewasset.assetId;
                DescriptionEntry.Text = Viewasset.description;
                LocationEntry.Text    = Viewasset.status;
                string quantity = Viewasset.quantity.ToString();
                QuantityEntry.Text = quantity;
                LastUpdated.Text   = Viewasset.timeLastUpdated;
                LastScanned.Text   = Viewasset.timeLastScanned;
                commentsEntry.Text = Viewasset.comment;
            }
            else
            {
            }

            var tapGestureRecognizer = new TapGestureRecognizer();

            tapGestureRecognizer.Tapped += (s, e) =>
            {
                try
                {
                    MasterDetailPage ParentPage = (MasterDetailPage)this.Parent;
                    ParentPage.IsPresented = (ParentPage.IsPresented == false) ? true : false;
                }
                catch (Exception ex)
                {
                    var msg = ex.Message;
                }
            };
            img.GestureRecognizers.Add(tapGestureRecognizer);
        }
 void ScanResult(ZXing.Result result)
 {
     if (IsScan == true)
     {
         Device.BeginInvokeOnMainThread(async() =>
         {
             DateTime now                     = DateTime.Now.ToLocalTime();
             QRCodeScanner.IsScanning         = false;
             Dictionary <string, string> dict = new Dictionary <string, string>();
             dict["asset"]                    = result.Text;
             //string assetId = result.Text ;
             dict["time"]  = now.ToString();
             var isSuccess = await cloudStore.ScanAsset(dict);
             if (isSuccess)
             {
                 await DisplayAlert("Alert", "Barcode scanned successfully.", "Ok");
                 ScanResponce responce = await cloudStore.GetScanUser(result.Text);
                 if (responce.assetType == "single")
                 {
                     await Navigation.PushModalAsync(new MainManagerAssetView(null, responce));
                 }
                 else
                 {
                     await Navigation.PushModalAsync(new MainBatchAssets(responce, null));
                 }
             }
             else
             {
                 await DisplayAlert("Error", "Invalid barcode.", "Ok");
                 App.Current.MainPage = new MainScanPage();
             }
         });
     }
     else
     {
         DisplayAlert("Error", "Invalid barcode.", "Ok");
         App.Current.MainPage = new MainScanPage();
     }
 }
        //void Scan_Clicked(object sender, System.EventArgs e)
        //{
        //    App.Current.MainPage = new ScannerPage();
        //}

        async void Accept_Clicked(object sender, System.EventArgs e)
        {
            IsScan = true;
            if (IsEnterManually == true && !string.IsNullOrEmpty(BarcodeEntry.Text))
            {
                DateTime now = DateTime.Now.ToLocalTime();
                Dictionary <string, string> dict = new Dictionary <string, string>();
                dict["asset"] = BarcodeEntry.Text;
                dict["time"]  = now.ToString();
                //ScanResponce isSuccess = await cloudStore.ScanAsset(dict);
                var isSuccess = await cloudStore.ScanAsset(dict);

                if (isSuccess)
                {
                    await DisplayAlert("Alert", "Barcode scanned successfully.", "Ok");

                    ScanResponce responce = await cloudStore.GetScanUser(BarcodeEntry.Text);

                    if (responce.assetType == "single")
                    {
                        await Navigation.PushModalAsync(new MainManagerAssetView(null, responce));
                    }
                    else
                    {
                        await Navigation.PushModalAsync(new MainBatchAssets(responce, null));
                    }
                }
                else
                {
                    await DisplayAlert("Error", "Invalid barcode.", "Ok");

                    App.Current.MainPage = new MainScanPage();
                }
            }
            else
            {
                DisplayAlert("Alert", "Invalid barcode.", "Ok");
            }
        }
        public ManagerAssetView(ViewAsset Viewasset, ScanResponce scanResponce)
        {
            InitializeComponent();
            var tapGestureRecognizer = new TapGestureRecognizer();

            tapGestureRecognizer.Tapped += (s, e) =>
            {
                try
                {
                    MasterDetailPage ParentPage = (MasterDetailPage)this.Parent;
                    ParentPage.IsPresented = (ParentPage.IsPresented == false) ? true : false;
                }
                catch (Exception ex)
                {
                    var msg = ex.Message;
                }
            };
            img.GestureRecognizers.Add(tapGestureRecognizer);

            // AssetEntry.Text = ScanResponce.assetId;

            if (Viewasset != null)
            {
                AssetEntry.Text       = Viewasset.assetId;
                DescriptionEntry.Text = Viewasset.description;
                StatusEntry.Text      = Viewasset.status;
                timeScannedEntry.Text = Viewasset.timeLastScanned;
                timeUpdatedEntry.Text = Viewasset.timeLastUpdated;
                commentsEntry.Text    = Viewasset.comment;
                if (Viewasset.assignee != null)
                {
                    //String[] Stringbreak = Viewasset.assignee.Split('#');
                    AsigneeEntry.Text = Viewasset.assignee;
                    assign.Text       = "Return Asset";
                    lstview.IsVisible = false;
                }
                else
                {
                }
            }

            if (scanResponce != null)
            {
                AssetEntry.Text       = scanResponce.assetId;
                DescriptionEntry.Text = scanResponce.description;
                StatusEntry.Text      = scanResponce.status;
                timeScannedEntry.Text = scanResponce.timeLastScanned;
                timeUpdatedEntry.Text = scanResponce.timeLastUpdated;
                commentsEntry.Text    = scanResponce.comment;
                if (scanResponce.assignee != null)
                {
                    String[] Stringbreak = scanResponce.assignee.Split('#');
                    AsigneeEntry.Text = Stringbreak[1];
                    assign.Text       = "Return Asset";
                    lstview.IsVisible = false;
                }
                else
                {
                }
            }



            lstview.ItemSelected += async(object sender, SelectedItemChangedEventArgs e) =>
            {
                if (e.SelectedItem == null)
                {
                    return;
                }
                Users item = (Users)e.SelectedItem;
                AsigneeEntry.Text = item.email;
                lstview.IsVisible = false;
                if (Validate = true)
                {
                    DateTime now = DateTime.Now.ToLocalTime();
                    Dictionary <string, string> dict = new Dictionary <string, string>();
                    dict["asset"]    = AssetEntry.Text;
                    dict["assignee"] = AsigneeEntry.Text;
                    dict["time"]     = now.ToString();
                    var isSuccess = await cloudStore.AssignAsset(dict);

                    if (isSuccess)
                    {
                        await DisplayAlert("Success", "Asset Assigned Successfully.", "Ok");

                        App.Current.MainPage = new MainViewAssetPage();

                        //AssetEntry.Text = string.Empty;
                        //DescriptionEntry.Text = string.Empty;
                    }
                    else
                    {
                        await DisplayAlert("Error", "Assignment Failed. Please try Again.", "Ok");

                        //AssetEntry.Text = string.Empty;
                        //DescriptionEntry.Text = string.Empty;
                    }
                    Validate = false;
                }

                ((ListView)sender).SelectedItem = null;
            };

            if (AsigneeEntry.Text == null)
            {
                AsigneeEntry.Focused += async(sender, e) =>
                {
                    try
                    {
                        var isSuccess = await cloudStore.GetUsers();

                        if (isSuccess != null)
                        {
                            lstview.ItemsSource = isSuccess;
                            lstview.IsVisible   = true;
                        }
                        else
                        {
                            await DisplayAlert("Error", "No Assignee", "Cancel", "Ok");
                        }
                    }
                    catch (Exception ex)
                    {
                    }
                };
            }
            else
            {
            }
        }