public void DoLogin() { progressDialog = ProgressDialog.Show(this, "Please wait...", "Checking For Updates...", true); new Thread(new ThreadStart(delegate { //NotificationSystem.ShowNotification(this); string IpAdress = GetIp(); IPAddress[] addresses = Dns.GetHostAddresses(Dns.GetHostName()); string ipAddress = string.Empty; if (addresses != null && addresses[0] != null) { ipAddress = addresses[0].ToString(); } else { ipAddress = null; } var android_id = Android.Provider.Settings.Secure.GetString(ContentResolver, Android.Provider.Settings.Secure.AndroidId); try { WMSScanner.LoginResult lr = Constants._service.Login_Login(Operator, OperatorPass, Company, CompanyPass, "D", ipAddress, android_id, "Android Scanner", ""); if (lr.LoggedInCorrectly == true) { try { WMSScanner.DataTableResult dtr = Constants._service.CachScannerVariables(lr.WMSGuid); if (dtr.Successful == true) { Update_Variables.NotFoundCode = dtr.ResultDT.Rows[0]["SettingValue"].ToString().Trim(); Update_Variables.Trolly = dtr.ResultDT.Rows[0]["Trolley"].ToString().Trim(); Update_Variables.MustScanPassword = dtr.ResultDT.Rows[0]["MustScanPass"].ToString().Trim(); Update_Variables.WMSWarehouse = dtr.ResultDT.Rows[0]["WMSWarehouse"].ToString().Trim(); Update_Variables.AutoReplace = dtr.ResultDT.Rows[0]["AutoReplace"].ToString().Trim(); Update_Variables.Company = Company; Update_Variables.MustCheckoutInsertPalletNumbering = dtr.ResultDT.Rows[0]["UsePalletNumberingOnCheckout"].ToString().Trim(); Update_Variables.MustFillLeadingZerosSalesOrder = bool.Parse(dtr.ResultDT.Rows[0]["MustFillLeadingZerosSalesOrder"].ToString().Trim()); Update_Variables.MustFillLeadingZerosInvoice = bool.Parse(dtr.ResultDT.Rows[0]["MustFillLeadingZerosInvoice"].ToString().Trim()); Update_Variables.MustFillLeadingZerosPO = bool.Parse(dtr.ResultDT.Rows[0]["MustFillLeadingZerosPO"].ToString().Trim()); Update_Variables.MustFillLeadingZerosSalesOrderAmount = int.Parse(dtr.ResultDT.Rows[0]["MustFillLeadingZerosSalesOrderAmount"].ToString()); Update_Variables.MustFillLeadingZerosInvoiceAmount = int.Parse(dtr.ResultDT.Rows[0]["MustFillLeadingZerosInvoiceAmount"].ToString()); Update_Variables.MustFillLeadingZerosPOAmount = int.Parse(dtr.ResultDT.Rows[0]["MustFillLeadingZerosPOAmount"].ToString()); } WMSScanner.DataTableResult mustScanResult = Constants._service.CachScannerMustScan(lr.WMSGuid); if (mustScanResult.Successful == true) { Update_Variables.MustScanItems = mustScanResult.ResultDT; } /*Will Exclude this for now testing still needs to be done*/ //WriteFiles(username, "", ""); Constants.CompanyPassword = ""; Constants.Password = ""; Constants.Operator = Operator.Trim(); Update_Variables.WMSGuid = new Guid(lr.WMSGuid); Update_Variables.SysproGuid = lr.SysproGuid; RunOnUiThread(() => Toast.MakeText(this, "Logged in to WMS Mobile Scanner.", ToastLength.Long).Show()); //we need to set the operator as active for today WMSScanner.BoolResult activeflaged = Constants._service.Android_Update_Operator_Active_Flag(Update_Variables.WMSGuid.ToString()); if (activeflaged.Successful == false) { RunOnUiThread(() => progressDialog.Cancel()); ViewDialog alert = new ViewDialog(); RunOnUiThread(() => alert.showDialog(this, activeflaged.Message)); return; } //StartService(new Intent(this, typeof(CheckPickActivity))); /*Start the WMS Check For New Assignment Notification*/ RunOnUiThread(() => progressDialog.Cancel()); var ScannerMenu = new Intent(this, typeof(MainActivity));/*New Main Activity*/ StartActivity(ScannerMenu); } catch (Exception ex) { RunOnUiThread(() => progressDialog.Cancel()); RunOnUiThread(() => Toast.MakeText(this, ex.Message.ToString(), ToastLength.Long)); } } else { RunOnUiThread(() => progressDialog.Hide()); ViewDialog alert = new ViewDialog(); RunOnUiThread(() => alert.showDialog(this, lr.Message + "Could not log in")); } } catch (Exception ex) { RunOnUiThread(() => progressDialog.Hide()); ViewDialog alert = new ViewDialog(); RunOnUiThread(() => alert.showDialog(this, ex.Message)); } })).Start(); }
public override async void OnBindViewHolder(RecyclerView.ViewHolder holder, int position) { var simpleHolder = holder as WMSViewHolder; simpleHolder.mBoundString = mValues[position].Name; simpleHolder.mActionName.Text = mValues[position].Name; simpleHolder.mActionText.Text = mValues[position].Value; simpleHolder.mActionDescription.Text = mValues[position].SuggestedItemValue; simpleHolder.mbtnUp.Click += delegate { /*nothing right now*/ }; simpleHolder.mActionText.KeyPress += (object sender, View.KeyEventArgs e) => { e.Handled = false; if (e.Event.Action == KeyEventActions.Down && e.KeyCode == Keycode.Enter) { simpleHolder.mbtnCheck.PerformClick(); //your logic here e.Handled = true; } }; simpleHolder.mbtnCheck.Click += delegate(object sender, EventArgs e) { var progressDialog = ProgressDialog.Show(context, "", "Processing", true); new System.Threading.Thread(new System.Threading.ThreadStart(delegate { //add the text to the item EditText mActionText = simpleHolder.mActionText; act.RunOnUiThread(() => { string currentinvoice = mActionText.Text; var founditem = tripdetails.Find(prod => prod._invoice == currentinvoice); if (founditem != null) { //now we do our other validations here for (int i = 0; i < tripdetails.Count; i++) { if (tripdetails[i]._invoice.Contains(currentinvoice)) { if (FirstItem == true) { WMSScanner.BoolResult addfirstitemtowms = Constants._service.Android_Update_FirstScanDate(Update_Variables.WMSGuid.ToString(), JobNo, founditem._salesorder); if (addfirstitemtowms.Successful == false) { Android.Support.V7.App.AlertDialog.Builder alert = new Android.Support.V7.App.AlertDialog.Builder(act); alert.SetTitle("Error"); alert.SetMessage(addfirstitemtowms.Message); alert.SetPositiveButton("OK", (senderAlert, args) => { }); Dialog dialog = alert.Create(); dialog.Show(); FirstItem = true; progressDialog.Hide(); return; } //post to wms that use can be locked to an order FirstItem = false; } tripdetails.RemoveAt(i); WMSScanner.BoolResult SalesOrderTrip = Constants._service.Android_Update_Operator_SalesOrder_On_Trip(Update_Variables.WMSGuid.ToString(), JobNo, founditem._salesorder); if (SalesOrderTrip.Successful == false) { Android.Support.V7.App.AlertDialog.Builder alert = new Android.Support.V7.App.AlertDialog.Builder(act); alert.SetTitle("Error"); alert.SetMessage(SalesOrderTrip.Message); alert.SetPositiveButton("OK", (senderAlert, args) => { }); Dialog dialog = alert.Create(); dialog.Show(); FirstItem = false; progressDialog.Hide(); return; } break; } } if (tripdetails.Count == 0) { //this was the last item //scan it out and post it to WMS WMSScanner.BoolResult LastScan = Constants._service.Android_Update_EndScanDate(Update_Variables.WMSGuid.ToString(), JobNo, founditem._salesorder); if (LastScan.Successful == false) { Android.Support.V7.App.AlertDialog.Builder alert = new Android.Support.V7.App.AlertDialog.Builder(act); alert.SetTitle("Error"); alert.SetMessage(LastScan.Message); alert.SetPositiveButton("OK", (senderAlert, args) => { }); Dialog dialog = alert.Create(); dialog.Show(); FirstItem = false; progressDialog.Hide(); return; } Android.Support.V7.App.AlertDialog.Builder completed = new Android.Support.V7.App.AlertDialog.Builder(act); completed.SetTitle("WMS POD"); completed.SetMessage("Sales Order Completed"); completed.SetPositiveButton("OK", (senderAlert, args) => { }); Dialog completeddialog = completed.Create(); completeddialog.Show(); /*Android Seems To Cache These Values*/ FirstItem = true; progressDialog.Hide(); act.Finish(); MainActivity.ReleadData(); } _adapter.NotifyDataSetChanged(); mActionText.Text = ""; progressDialog.Hide(); } else { Android.Support.V7.App.AlertDialog.Builder completed = new Android.Support.V7.App.AlertDialog.Builder(act); completed.SetTitle("WMS POD"); completed.SetMessage("Invoice not on Sales Order"); completed.SetPositiveButton("OK", (senderAlert, args) => { }); Dialog completeddialog = completed.Create(); completeddialog.Show(); _adapter.NotifyDataSetChanged(); mActionText.Text = ""; progressDialog.Hide(); } }); /*open camera screen*/ })).Start(); }; }