Beispiel #1
0
        private async void OnCodesScanned(ScanSession session)
        {
            session.StopScanning();


            var firstCode = session.NewlyRecognizedCodes.First();
            var text      = String.Format("{0} ({1})", firstCode.Data, firstCode.SymbologyString.ToUpper());

            //if (await Application.Current.MainPage.DisplayAlert("Are you sure to include it in the collection", $"You have scanned {text}", "Yes", "No"))
            //{
            if (!Products.Any(p => p.BarCode == text))
            {
                Products.Insert(0, new Product()
                {
                    BarCode = text, Units = 1
                });
            }
            else
            {
                var product = _products.Single(p => p.BarCode == text);
                _products.Remove(product);
                product.Units++;
                Products.Insert(0, product);
            }
            //}

            //await ScanditService.BarcodePicker.StartScanningAsync(false);
        }
Beispiel #2
0
        private static ScanSession CreateScanSessionEntryPrivate(TenantUserSession tenantUserSession, string name, string description, ContextTenant context)
        {
            if (context == null)
            {
                throw (new ArgumentNullException("context"));
            }
            if (string.IsNullOrEmpty(name.Trim()))
            {
                throw (new Exception("Name is required"));
            }
            if (context.ScanSessions.Any(x => x.Name.ToLower().Trim() == name.ToLower().Trim()))
            {
                throw new Exception("Scan Session with same name already exists. Please select a unique name.");
            }

            ScanSession scanSession = new ScanSession();

            scanSession.DateTimeCreated = DateTime.UtcNow;
            scanSession.Description     = description;
            scanSession.Guid            = Guid.NewGuid();
            scanSession.Name            = name;
            scanSession.UserId          = tenantUserSession.User.Id;
            var scan = context.ScanSessions.Add(scanSession);

            context.SaveChanges();
            return(scan);
        }
Beispiel #3
0
        void ProcessScanResults(ScanSession session)
        {
            if (session == null)
            {
                return;
            }

            if (session.NewlyRecognizedCodes != null && session.NewlyRecognizedCodes.Any())
            {
                var firstCode = session.NewlyRecognizedCodes.First();

                session.StopScanning();

                // Because this event handler is called from an scanner-internal thread,
                // you must make sure to dispatch to the main thread for any UI work.
                Device.BeginInvokeOnMainThread(async() =>
                {
                    ScanditService.BarcodePicker.DidScan -= ProcessScanResults;
                    if (firstCode != null)
                    {
                        // This delay is needed because the app will crash if we too quickly transition to another page when the scanner is closing
                        // This gives time for this page to load before going to item details page
                        await Task.Delay(200);

                        await ScanSearch(firstCode);
                    }
                });
            }
            else
            {
                session.StopScanning();
            }
        }
Beispiel #4
0
 private void Picker_DidScan(ScanSession session)
 {
     foreach (Barcode barcode in session.NewlyRecognizedCodes)
     {
         barcodeCamera.Scanned?.Execute(barcode.Data);
         session.RejectCode(barcode);
     }
 }
        private void OnDidScan(ScanSession session)
        {
            var firstCode = session.NewlyRecognizedCodes.First();
            var message   = "";

            if (session.NewlyRecognizedCodes.Count() == 1)
            {
                message = firstCode.Data;
            }
            else if (session.NewlyRecognizedCodes.Count() > 1)
            {
                var secondCode = session.NewlyRecognizedCodes.ElementAt(1);
                message = secondCode.Data;
            }

            // Because this event handler is called from an scanner-internal thread,
            // you must make sure to dispatch to the main thread for any UI work.
            Device.BeginInvokeOnMainThread(() =>
            {
                var check = models.Any(x => x.Barcode == message);
                if (!check)
                {
                    BottonText         = "Last scan: " + message;
                    BarcodeModel model = new BarcodeModel()
                    {
                        Barcode = message,
                        TagsStr = TagsStr,
                        Icon    = Cloud
                    };

                    if (Tags != null)
                    {
                        foreach (var item in Tags)
                        {
                            model.Tags.Add(item);
                        }
                    }
                    models.Add(model);
                    if (PageName == ViewTypeEnum.PalletizeView.ToString())
                    {
                        ScannerToPalletAssign scannerToPalletAssign = new ScannerToPalletAssign
                        {
                            Barcode = models.LastOrDefault().Barcode
                        };
                        MessagingCenter.Send(scannerToPalletAssign, "ScannerToPalletAssign");
                    }
                    try
                    {
                        Loader.Toast("Last scan: " + message);
                    }
                    catch { }
                }
            });
        }
        void OnDidScan(ScanSession session)
        {
            // guaranteed to always have at least one element, so we don't have to
            // check the size of the NewlyRecognizedCodes array.
            var firstCode = session.NewlyRecognizedCodes.First();
            var message   = string.Format("Code Scanned:\n {0}\n({1})", firstCode.Data, firstCode.SymbologyString.ToUpper());

            // Because this event handler is called from an scanner-internal thread,
            // you must make sure to dispatch to the main thread for any UI work.
            Device.BeginInvokeOnMainThread(() => this.ResultLabel.Text = message);
            session.StopScanning();
        }
Beispiel #7
0
        private void button1_Click(object sender, EventArgs e)
        {
            FolderBrowserDialog FBD = new FolderBrowserDialog();

            FBD.ShowNewFolderButton = false;
            if (FBD.ShowDialog() == DialogResult.OK)
            {
                ScanSession session = new ScanSession(@FBD.SelectedPath, "User");

                ScanReport report = session.getReport();
                foreach (var s in report.listThread)
                {
                    string[] f = s.Split(' ');
                    listBox1.Items.Add("Расположение файла" + f[0] + "\tИмя вируса:" + f[1]);
                }
                report.SaveResult();
            }
        }
Beispiel #8
0
        private static ScanSession ScanSessionEntryFinalizePrivate(TenantUserSession tenantUserSession, long scanSessionId, ContextTenant context)
        {
            if (context == null)
            {
                throw (new ArgumentNullException("context"));
            }
            if (scanSessionId <= 0)
            {
                throw (new Exception("Unable to find the following scan session"));
            }

            ScanSession scanSession = context.ScanSessions.Where(x => x.Id == scanSessionId).FirstOrDefault();

            if (scanSession != null)
            {
                throw (new Exception("Unable to find the following scan session"));
            }
            scanSession.Finalized = true;
            scanSession           = context.ScanSessions.Add(scanSession);
            context.SaveChanges();
            return(scanSession);
        }
Beispiel #9
0
        void OnDidScan(ScanSession session)
        {
            var firstCode = session.NewlyRecognizedCodes.First();
            var message   = "";

            if (session.NewlyRecognizedCodes.Count() == 1)
            {
                message = string.Format("Code Scanned:\n {0}\n({1})", firstCode.Data,
                                        firstCode.SymbologyString.ToUpper());
            }
            else if (session.NewlyRecognizedCodes.Count() > 1)
            {
                var secondCode = session.NewlyRecognizedCodes.ElementAt(1);
                message = string.Format("Codes Scanned:\n {0}\n({1})\n {2}\n({3})",
                                        firstCode.Data,
                                        firstCode.SymbologyString.ToUpper(),
                                        secondCode.Data,
                                        secondCode.SymbologyString.ToUpper());
            }
            // Because this event handler is called from an scanner-internal thread,
            // you must make sure to dispatch to the main thread for any UI work.
            Device.BeginInvokeOnMainThread(() => this.ResultLabel.Text = message);
            session.StopScanning();
        }
 private async void BarcodePickerOnDidScan(ScanSession session)
 {
     RecognizedCode = session.NewlyRecognizedCodes.LastOrDefault()?.Data;
     await ScanditService.BarcodePicker.StopScanningAsync();
 }