Beispiel #1
0
        private void UpdateWifiStatus()
        {
            ImageView imgWifiWarning = FindViewById <ImageView>(Resource.Id.imgMainWifiWarning);
            TextView  txtWifiWarning = FindViewById <TextView>(Resource.Id.txtMainWifiWarning);

            NetworkStatusMonitor nm = new NetworkStatusMonitor();

            nm.UpdateNetworkStatus();

            if (nm.State == NetworkState.ConnectedWifi)
            {
                wifiConnected             = true;
                imgWifiWarning.Visibility = ViewStates.Invisible;
                txtWifiWarning.Visibility = ViewStates.Invisible;
            }
            else
            {
                wifiConnected             = false;
                imgWifiWarning.Visibility = ViewStates.Visible;
                txtWifiWarning.Visibility = ViewStates.Visible;
            }
        }
        protected override void OnCreate(Bundle savedInstanceState)
        {
            base.OnCreate(savedInstanceState);

            // Create your application here

            SetContentView(Resource.Layout.layout_scannersetup);

            TextView txtAppVersion           = FindViewById <TextView>(Resource.Id.txtSettings_AppVersion);
            TextView txtScannerID            = FindViewById <TextView>(Resource.Id.txtSettings_ScannerNum);
            TextView txtWiFi                 = FindViewById <TextView>(Resource.Id.txtSettings_WiFiStatus);
            TextView txtDateTime             = FindViewById <TextView>(Resource.Id.txtSettings_DateTime);
            TextView txtFoxScanSvcAppVersion = FindViewById <TextView>(Resource.Id.txtSettings_ServiceVersion);
            TextView txtSerialTC20           = FindViewById <TextView>(Resource.Id.txtSettings_SerialTC20);
            TextView txtSerialRFD2000        = FindViewById <TextView>(Resource.Id.txtSettings_SerialRFD2000);
            Spinner  spnStores               = FindViewById <Spinner>(Resource.Id.spinnerSettingsStore);
            Button   btnRegister             = FindViewById <Button>(Resource.Id.btnSettings_Register);
            Button   btnExitSave             = FindViewById <Button>(Resource.Id.btnSettings_Exit);

            serialNoRFD2000 = Intent.GetStringExtra("serialRFD2000");

            scannerID = mcTools.GetScannerID();

            if (scannerID > 0)
            {
                txtScannerID.SetTextColor(Android.Graphics.Color.Black);
                txtScannerID.Text = scannerID.ToString();
            }
            else
            {
                txtScannerID.SetTextColor(Android.Graphics.Color.ParseColor("#F75555"));
                txtScannerID.Text = "Not Assigned";
            }

            txtSerialTC20.Text = serialNoTC20;
            if (serialNoRFD2000 == "")
            {
                txtSerialRFD2000.Text = "--------------";
            }
            else
            {
                txtSerialRFD2000.Text = serialNoRFD2000;
            }

            txtAppVersion.Text = "(app version 1." + Constants.CurrentVersion + ")";
            txtDateTime.Text   = DateTime.Now.ToLongDateString() + "  " + DateTime.Now.ToShortTimeString();

            NetworkStatusMonitor nm = new NetworkStatusMonitor();

            nm.UpdateNetworkStatus();

            int position = LoadStoreList();  // Load all stores from FoxStoreInfo table into spinner

            if (position > 0)
            {
                spnStores.SetSelection(position);
            }

            if (nm.State == NetworkState.ConnectedWifi)
            {
                wifiConnected = true;
                txtWiFi.SetTextColor(Android.Graphics.Color.Green);
                txtWiFi.Text = "Connected";

                // Display FoxScannerSvc version #

                FoxScannerSvc.FoxScannerSvc foxSql = new FoxScannerSvc.FoxScannerSvc();
                txtFoxScanSvcAppVersion.SetTextColor(Android.Graphics.Color.Black);

                try
                {
                    txtFoxScanSvcAppVersion.Text = "1." + foxSql.GetFoxScanSvcVersion();
                    foxSvcConnected = true;
                }
                catch (Exception exSvc)
                {
                    foxSvcConnected = false;
                }
            }
            else
            {
                wifiConnected = false;
                txtWiFi.SetTextColor(Android.Graphics.Color.ParseColor("#F75555"));
                txtWiFi.Text = "Not Connected!";

                txtFoxScanSvcAppVersion.SetTextColor(Android.Graphics.Color.ParseColor("#F75555"));
                txtFoxScanSvcAppVersion.Text = "???";
            }

            btnRegister.Click += BtnRegister_Click;
            btnExitSave.Click += BtnExitSave_Click;
        }
Beispiel #3
0
        protected override void OnCreate(Bundle savedInstanceState)
        {
            base.OnCreate(savedInstanceState);

            // Create your application here

            SetContentView(Resource.Layout.layout_getEmployee);

            LinearLayout lRoot = FindViewById <LinearLayout>(Resource.Id.layoutrootemp);

            lRoot.Click += delegate
            {
                DismissKeyboard();
            };

            nextAction    = Intent.GetStringExtra("nextAction");
            toFrom        = Intent.GetStringExtra("toFrom");
            storeName     = Intent.GetStringExtra("storeName");
            destStoreCode = Intent.GetStringExtra("destStoreCode");

            var btnEmpBack   = FindViewById <Button>(Resource.Id.btnEmpBack);
            var btnEmpNext   = FindViewById <Button>(Resource.Id.btnEmpNext);
            var btnClear     = FindViewById <Button>(Resource.Id.btnEmpClear);
            var txtEmpNo     = FindViewById <TextView>(Resource.Id.txtEmpNo);
            var txtSearching = FindViewById <TextView>(Resource.Id.txtEmpInstruct);

            Button btn0 = FindViewById <Button>(Resource.Id.btnEmp0);
            Button btn1 = FindViewById <Button>(Resource.Id.btnEmp1);
            Button btn2 = FindViewById <Button>(Resource.Id.btnEmp2);
            Button btn3 = FindViewById <Button>(Resource.Id.btnEmp3);
            Button btn4 = FindViewById <Button>(Resource.Id.btnEmp4);
            Button btn5 = FindViewById <Button>(Resource.Id.btnEmp5);
            Button btn6 = FindViewById <Button>(Resource.Id.btnEmp6);
            Button btn7 = FindViewById <Button>(Resource.Id.btnEmp7);
            Button btn8 = FindViewById <Button>(Resource.Id.btnEmp8);
            Button btn9 = FindViewById <Button>(Resource.Id.btnEmp9);

            btn0.Click += delegate { empNo += "0"; txtEmpNo.Text = empNo; };
            btn1.Click += delegate { empNo += "1"; txtEmpNo.Text = empNo; };
            btn2.Click += delegate { empNo += "2"; txtEmpNo.Text = empNo; };
            btn3.Click += delegate { empNo += "3"; txtEmpNo.Text = empNo; };
            btn4.Click += delegate { empNo += "4"; txtEmpNo.Text = empNo; };
            btn5.Click += delegate { empNo += "5"; txtEmpNo.Text = empNo; };
            btn6.Click += delegate { empNo += "6"; txtEmpNo.Text = empNo; };
            btn7.Click += delegate { empNo += "7"; txtEmpNo.Text = empNo; };
            btn8.Click += delegate { empNo += "8"; txtEmpNo.Text = empNo; };
            btn9.Click += delegate { empNo += "9"; txtEmpNo.Text = empNo; };

            btnClear.Click += delegate { empNo = ""; txtEmpNo.Text = "####"; };

            btnEmpBack.Click += delegate
            {
                this.Finish();
            };

            btnEmpNext.Click += delegate
            {
                txtSearching.Text = "Looking up employee...";
                txtSearching.SetTextColor(Android.Graphics.Color.ParseColor("#FF0033BB"));

                if (empNo == "")
                {
                    Toast.MakeText((this.ApplicationContext), "Enter employee #", ToastLength.Long).Show();
                }
                else
                {
                    // =============================================================================================================================
                    // We need to check wifi. It is possible that user okay'd scanning w/o wifi. If so, capture the empno, but skip verification
                    // =============================================================================================================================

                    NetworkStatusMonitor nm = new NetworkStatusMonitor();
                    nm.UpdateNetworkStatus();

                    if (nm.State == NetworkState.ConnectedWifi)
                    {
                        txtSearching.Visibility = ViewStates.Visible;
                        ThreadPool.QueueUserWorkItem(state =>
                        {
                            string empName = GetEmployeeNameFromNum(empNo);

                            RunOnUiThread(() => VerifyEmpName(empNo, empName));
                        });
                    }
                    else
                    {
                        LaunchNextActivity();
                    }
                }
            };
        } // OnCreate()
        public void ScanResult(Intent intent)
        {
            //  Output the scanned barcode on the screen.  Bear in mind older JB devices will use the legacy DW parameters on unbranded devices.
            String decodedSource = intent.GetStringExtra(Resources.GetString(
                                                             Resource.String.datawedge_intent_key_source));
            String barCode = intent.GetStringExtra(Resources.GetString(
                                                       Resource.String.datawedge_intent_key_data));
            String decodedLabelType = intent.GetStringExtra(Resources.GetString(
                                                                Resource.String.datawedge_intent_key_label_type));

            //TextView scanSourceTxt = FindViewById<TextView> (Resource.Id.txtScanScource);
            //TextView scanDataTxt = FindViewById<TextView> (Resource.Id.txtScanData);
            //TextView scanLabelTypeTxt = FindViewById<TextView> (Resource.Id.txtScanDecoder);
            //scanSourceTxt.Text = "Scan Source: " + decodedSource;
            //scanDataTxt.Text = "Scan Data: " + decodedData;
            //scanLabelTypeTxt.Text = "Scan Decoder: " + decodedLabelType;


            if (storeCode != "")
            {
                TextView txtBarcode = FindViewById <TextView>(Resource.Id.txtBarcode);
                barCode         = BarcodeStrip9(barCode);
                txtBarcode.Text = barCode;

                if (BarcodeValid(barCode))
                {
                    ///////////////////////////////////
                    // Pull Last Sold / Consol Data
                    ///////////////////////////////////

                    NetworkStatusMonitor nm = new NetworkStatusMonitor();
                    nm.UpdateNetworkStatus();

                    dataLastSoldResult = "";
                    dataMDResult       = "";
                    InitResultFields();

                    if (nm.State == NetworkState.ConnectedWifi)
                    {
                        Message msg = new Message();
                        dataHandler = new DataRetrievalHandler(this);
                        msg         = dataHandler.ObtainMessage();

                        // Display progress bar

                        ProgressDialog progBar = new ProgressDialog(this);

                        progBar.SetCancelable(false);
                        progBar.SetTitle("Retrieving data");
                        progBar.SetIcon(Resource.Drawable.iconChill64);
                        progBar.SetMessage("One moment please...");
                        progBar.SetProgressStyle(ProgressDialogStyle.Spinner);
                        progBar.Show();

                        var thread = new System.Threading.Thread(new ThreadStart(delegate
                        {
                            try
                            {
                                FoxScannerSvc.FoxScannerSvc foxScannerSvc = new FoxScannerSvc.FoxScannerSvc();
                                dataLastSoldResult = foxScannerSvc.GetLastSoldInfo(barCode);
                                dataMDResult       = foxScannerSvc.GetMarkdownsVendor(barCode.Substring(0, 3), storeCode);

                                RunOnUiThread(() =>
                                {
                                    progBar.Dismiss();
                                });
                                msg.Arg1 = 0;
                                dataHandler.SendMessage(msg);
                            }
                            catch (Exception ex)
                            {
                                RunOnUiThread(() =>
                                {
                                    progBar.Dismiss();
                                });
                                msg.Arg1 = 1;
                                dataHandler.SendMessage(msg);
                            }
                        }));

                        thread.Start();
                    }
                    else
                    {
                        var builder = new Android.App.AlertDialog.Builder(this);
                        builder.SetTitle("WiFi NOT Connected!!");
                        builder.SetIcon(Resource.Drawable.iconWarning64);
                        builder.SetMessage("WiFi is not connected. Please connect WiFi and try again.");
                        builder.SetPositiveButton("OK", (s, e2) =>
                        {
                            // Goto transfer data w/ nextActivity = "SCANOPTIONS"
                        }
                                                  );
                        builder.Create().Show();
                    }
                }
                else
                {
                    var builder = new Android.App.AlertDialog.Builder(this);
                    builder.SetTitle("Invalid Barcode!!");
                    builder.SetIcon(Resource.Drawable.iconWarning64);
                    builder.SetMessage("The barcode scanned is not recognized as a valid Fox's barcode.");
                    builder.SetPositiveButton("OK", (s, e2) =>
                    {
                        // Goto transfer data w/ nextActivity = "SCANOPTIONS"
                    }
                                              );
                    builder.Create().Show();
                }
            }
            else
            {
                var builder = new Android.App.AlertDialog.Builder(this);
                builder.SetTitle("Scanner NOT Registered!");
                builder.SetIcon(Resource.Drawable.iconWarning64);
                builder.SetMessage("The scanner must be registered before this utility can be used.");
                builder.SetPositiveButton("OK", (s, e2) =>
                {
                    // Goto transfer data w/ nextActivity = "SCANOPTIONS"
                }
                                          );
                builder.Create().Show();
            }
        }
Beispiel #5
0
        private void BtnTransfer_Click(object sender, EventArgs e)
        {
            Button btnTransfer = FindViewById <Button>(Resource.Id.btnxFerData);

            btnTransfer.Enabled = false;

            // Check WiFi status first

            NetworkStatusMonitor nm = new NetworkStatusMonitor();

            nm.UpdateNetworkStatus();

            if (nm.State == NetworkState.ConnectedWifi)
            {
                // Transfer Data

                Message msg = new Message();
                xFerHandler = new xFerEventHandler(this);
                msg         = xFerHandler.ObtainMessage();

                // Display progress bar

                ProgressDialog progBar = new ProgressDialog(this);

                progBar.SetCancelable(false);
                progBar.SetTitle("Transferring Data");
                progBar.SetIcon(Resource.Drawable.iconChill64);
                progBar.SetMessage("One moment please...");
                progBar.SetProgressStyle(ProgressDialogStyle.Spinner);
                progBar.Show();

                var thread = new System.Threading.Thread(new ThreadStart(delegate
                {
                    int scannerID = mcTools.GetScannerID();

                    // Create data list

                    List <FoxProduct> foxProducts = db.ExecQuery_FoxProduct(Constants.DBFilename, "select * from FoxProduct order by FoxSKU, epcLast6", ref dbError);

                    if (foxProducts == null)
                    {
                        resultxFer = "Failed to create foxProducts export list. Failed to read table.";
                        msg.Arg1   = 1;
                    }
                    else
                    {
                        if (foxProducts.Count > 0)
                        {
                            // Create data string to send

                            RunOnUiThread(() =>
                            {
                                progBar.SetTitle("Transferring Data...");
                                progBar.SetIcon(Resource.Drawable.iconChill64);
                                progBar.SetProgressStyle(ProgressDialogStyle.Horizontal);
                                progBar.Progress = 0;
                                progBar.Max      = foxProducts.Count;
                                progBar.SetMessage("Exporting inventory records...");
                            });

                            string scannerData = "";

                            for (int recordCT = 0; recordCT < foxProducts.Count; recordCT++)
                            {
                                // Data to be transferred in format {EmpNo},{EPC},{Qty},{ActionWOtherLoc},{NewConsol},{OtherStoreCode},{DateTimeScanned}|
                                scannerData += foxProducts[recordCT].EmployeeID + ",";
                                scannerData += foxProducts[recordCT].EPC + ",";
                                scannerData += foxProducts[recordCT].Qty.ToString() + ",";
                                scannerData += foxProducts[recordCT].ActionWOtherLoc + ",";
                                scannerData += foxProducts[recordCT].NewConsol + ",";
                                scannerData += foxProducts[recordCT].OtherStoreCode + ",";
                                scannerData += foxProducts[recordCT].DateTimeScanned;

                                if (recordCT < (foxProducts.Count - 1))
                                {
                                    scannerData += "|";
                                }

                                RunOnUiThread(() =>
                                {
                                    progBar.Progress = recordCT;
                                });
                            }

                            RunOnUiThread(() =>
                            {
                                progBar.SetProgressStyle(ProgressDialogStyle.Spinner);
                                progBar.SetMessage("Just a few more seconds...");
                            });

                            FoxScannerSvc.FoxScannerSvc foxScannerSvc = new FoxScannerSvc.FoxScannerSvc();
                            resultxFer = foxScannerSvc.UploadRFIDInvScans(scannerID.ToString(), scannerData, foxProducts.Count);

                            if (resultxFer != "")
                            {
                                string[] resultValues = resultxFer.Split('|');

                                if (resultValues[0] == "[SUCCESS]")
                                {
                                    string batchNo       = resultValues[1];
                                    int unitsTransferred = foxProducts.Count;

                                    int unitsIN  = Convert.ToInt32(db.ExecQuery_Scalar(Constants.DBFilename, "select count(Qty) from FoxProduct where Qty > 0", ref dbError));
                                    int unitsOUT = Convert.ToInt32(db.ExecQuery_Scalar(Constants.DBFilename, "select count(Qty) from FoxProduct where Qty < 0", ref dbError));
                                    int unitsOH  = Convert.ToInt32(db.ExecQuery_Scalar(Constants.DBFilename, "select count(Qty) from FoxProduct where Qty = 0", ref dbError));

                                    // ====================================
                                    // Write batch Info to <xferLog>
                                    // ====================================

                                    string sqlBatch = "";

                                    if (unitsIN > 0)
                                    {
                                        string empNo = db.ExecQuery_Scalar(Constants.DBFilename, "select EmployeeID from FoxProduct where Qty > 0 limit 1", ref dbError);

                                        sqlBatch += @"insert into XFerLog (BatchNo, Units, InvType, EmpNo, TransferDate) values
                                        ('" + batchNo + "'," + unitsIN.ToString() + ",'IN','" + empNo + "','" + DateTime.Now.ToShortDateString() + " " + DateTime.Now.ToLongTimeString() + "');";
                                    }

                                    if (unitsOUT > 0)
                                    {
                                        string empNo = db.ExecQuery_Scalar(Constants.DBFilename, "select EmployeeID from FoxProduct where Qty < 0 limit 1", ref dbError);

                                        sqlBatch += @"insert into XFerLog (BatchNo, Units, InvType, EmpNo, TransferDate) values
                                        ('" + batchNo + "'," + unitsOUT.ToString() + ",'OUT','" + empNo + "','" + DateTime.Now.ToShortDateString() + " " + DateTime.Now.ToLongTimeString() + "');";
                                    }

                                    if (unitsOH > 0)
                                    {
                                        string empNo = db.ExecQuery_Scalar(Constants.DBFilename, "select EmployeeID from FoxProduct where Qty = 0 limit 1", ref dbError);

                                        sqlBatch += @"insert into XFerLog (BatchNo, Units, InvType, EmpNo, TransferDate) values
                                        ('" + batchNo + "'," + unitsOH.ToString() + ",'OH','" + empNo + "','" + DateTime.Now.ToShortDateString() + " " + DateTime.Now.ToLongTimeString() + "');";
                                    }

                                    db.ExecWriteSQLiteBatch(Constants.DBFilename, sqlBatch, ref dbError);

                                    // =======================================
                                    // Wipeout <FoxProduct>
                                    // =======================================

                                    if (db.ExecWriteSQLite(Constants.DBFilename, "delete from FoxProduct", ref dbError))
                                    {
                                        msg.Arg1 = 0;
                                    }
                                    else
                                    {
                                        // Notify user that data xferred, but needs to be deleted from scanner
                                    }
                                }
                                else
                                {
                                    msg.Arg1 = 1;
                                }
                            }
                            else
                            {
                                msg.Arg1 = 1;
                            }
                        }
                        else
                        {
                            msg.Arg1 = 0;
                        }
                    }

                    RunOnUiThread(() =>
                    {
                        progBar.Dismiss();
                    });

                    xFerHandler.SendMessage(msg);
                }));

                thread.Start();
            }
            else
            {
                var builder = new Android.App.AlertDialog.Builder(this);
                builder.SetTitle("WiFi NOT Connected!!");
                builder.SetIcon(Resource.Drawable.iconWarning64);
                builder.SetMessage("WiFi is not connected. Please connect WiFi and try again.");
                builder.SetPositiveButton("OK", (s, e2) =>
                {
                    // Goto transfer data w/ nextActivity = "SCANOPTIONS"
                }
                                          );
                builder.Create().Show();
            }
        } // Transfer_Click()