コード例 #1
0
 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();
     }
 }