예제 #1
0
        public override View OnCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState)
        {
            // Use this to return your custom view for this Fragment
            // return inflater.Inflate(Resource.Layout.YourFragment, container, false);
            MainScreen = (MainScreen)Activity;
            var _root = inflater.Inflate(Resource.Layout.enterDataFt, container, false);

            EftMessage = _root.FindViewById <TextView>(Resource.Id.eftmessage);
            RS         = new ReadingStatus();
            //edittext to enter data
            //ElData = _root.FindViewById<EditText>(Resource.Id.data);
            //ElData.KeyPress += ElData_KeyPress;
            //ElData.ClearFocus();

            //scanner intent

            sScanner.RegisterScannerActivity(Activity, _root, true, Silent: true);
            sScanner.AfterReceive += Scanner_AfterReceive;

            //ElData.RequestFocus();
            //end

            //var _query = await Values.SQLidb.db.QueryAsync<QueryResult>("Select 'test', 10 ");//Rack, count(*) from ScannedData group by Rack order by idreg desc limit 3");
            SetMessage(RS.MessageStatus);
            hFt.Clear();
            tFt.Clear();
            hFt.t1.Text = string.Format("User: {0}", Values.PendingDataReading.UserCode);
            hFt.t2.Text = string.Format("Session: {0}", Values.PendingDataReading.SessionID);
            //var oldElements = Values.SQLidb.db.Table<ScannedData>().OrderBy(t => t.TrollLocation).ToListAsync().Result;
            var _order = 1;

            Values.PendingDataReading.Readings.ForEach(o =>
            {
                DataReading data = new DataReading()
                {
                    SequenceNumber = o.SequenceNumber, VINNr = o.VINNr, PartnumberSeqLabel = o.PartnumberSeqLabel, PartnumberLabel = o.PartnumberLabel, Batch = o.Batch, TrollLocation = o.TrollLocation, Qty = o.Qty
                };
                tFt.FillData(_order, data);
                _order++;
                //hFt.t3.Text = $"Trolley: {o.TrollLocation.Substring(0, 3)}";
            });
            //RS.CurrentGap = $"g{ o.TrollLocation.Substring(4, 2)}";
            //RS.CurrentData.SequenceNumber = o.SequenceNumber;
            try
            {
                var lastGap = tFt.Trolley.Gaps.Where(o => o.Value.Data.PartnumberSeqLabel != "").OrderBy(o => o.Value.Order).First();
                RS.CurrentGap = lastGap.Value.Data.TrollLocation.Substring(4, 2);
                RS.CurrentData.SequenceNumber = lastGap.Value.Data.SequenceNumber;
            } catch
            {
                RS.CurrentGap = "01";
                RS.CurrentData.SequenceNumber = tFt.Trolley.Gaps.Values.Where(o => o.Order == 1).First().Data.SequenceNumber;
            }

            return(_root);
        }
예제 #2
0
 public void FillData(DataReading data, Context context = null)
 {
     Data = (DataReading)data.Clone();
     if (context != null)
     {
         if (data.Qty == 0)
         {
             SetStatus(GapStatus.ERROR, context);
         }
         else
         {
             SetStatus(GapStatus.FILLED, context);
         }
         Visual.Text = Data.SequenceNumber;
     }
 }
예제 #3
0
        //SQL Commands
        public async Task <CPendingDataReading> CheckUnclosedSessions()
        {
            SendMessage("Searching for non closed sessions with this device");
            var _result = new CPendingDataReading();

            using (var _rs = new XMLRS($"Select IdSession,xusr from SequencingSessionCab where dbo.CheckFlag(flags,'CLOSED')=0 and datediff(MINUTE,xfec,getdate())<120 and ScannerID='{Values.MyDeviceInfo.DeviceCode}' order by xfec desc", Conn))
            {
                await _rs.OpenAsync();

                if (_rs.RecordCount != 0)
                {
                    SendMessage($"Found unclosed session {_rs["IdSession"]}");
                    _result.SessionID = _rs["IdSession"].ToString();
                    _result.UserCode  = _rs["xusr"].ToString();
                    using (var det = new XMLRS($"Select SequenceNumber,TicketVIN,TicketPartnumber,LabelPartnumber,LabelExtraData from SequencingSessionDet where IdSession='{_result.SessionID}' order by Line", Conn))
                    {
                        await det.OpenAsync();

                        while (!det.EOF)
                        {
                            var _d    = new DataReading();
                            var extra = det["LabelExtraData"].ToString();
                            _d.SequenceNumber     = det["SequenceNumber"].ToString();
                            _d.Batch              = extra != "" ? extra.Split('|')[0].Split(':')[1] : "";
                            _d.PartnumberLabel    = det["LabelPartnumber"].ToString();
                            _d.PartnumberSeqLabel = det["TicketPartnumber"].ToString();
                            _d.VINNr              = det["TicketVIN"].ToString();
                            _d.TrollLocation      = extra != "" ? extra.Split('|')[1].Split(':')[1] : "";
                            _d.Qty = 1;
                            _result.Readings.Add(_d);
                            SendMessage($"Found Sequence {_d.SequenceNumber}");
                            det.MoveNext();
                        }
                    }
                }
                else
                {
                    SendMessage("No pending sessions found.");
                    return(null);
                }
            }
            return(_result);
        }
예제 #4
0
        public async Task <CPendingDataReading> CreateNewSession(string system, string customerService, string cod3, string userCode, string serial)
        {
            SendMessage("Creating new session.");
            var _result = new CPendingDataReading();
            int _minSeq;
            int _maxSeq;
            var _sp = new SPXML(Conn, "pSequencingSessionCabAdd");

            //_sp.AddParameterValue("msg", _msg);
            _sp.AddParameterValue("System", system);
            _sp.AddParameterValue("CustomerService", customerService);
            _sp.AddParameterValue("COD3", cod3);
            _sp.AddParameterValue("UserCode", userCode);
            _sp.AddParameterValue("DeviceSerial", serial);
            await _sp.ExecuteAsync();

            if (_sp.LastMsg.Substring(0, 2) != "OK")
            {
                SendError($"Error returned by SQL Server:\n {_sp.LastMsg}");
                return(_result);
            }
            _result.SessionID = _sp.LastMsg.Substring(3);
            _result.UserCode  = userCode;
            _minSeq           = _sp.Parameters["@MinSequence"].Value.ToInt();
            _maxSeq           = _sp.Parameters["@MaxSequence"].Value.ToInt();
            SendMessage($"New session created {_result.SessionID}");
            SendMessage($"Assigning sequences from {_minSeq} to {_maxSeq}");
            for (int i = _minSeq; i <= _maxSeq; i++)
            {
                var _d = new DataReading();
                _d.SequenceNumber = i.ToString();
                _result.Readings.Add(_d);
            }

            return(_result);
        }
예제 #5
0
        public async Task Add(string reading)
        {
            if (Context == null)
            {
                throw new Exception("Context not set");
            }
            Processing = true;
            cData _data;

            //CLOSE CODE
            if (reading == Values.CloseCode)
            {
                //set alert for executing the task
                bool dialogResult = await AlertDialogHelper.ShowAsync(Context, "Confirm Close Session", "This will close current session. Are you sure?", "Close Session", "Cancel");

                if (!dialogResult)
                {
                    ((Activity)Context).RunOnUiThread(() =>
                    {
                        Toast.MakeText(Context, "Cancelled!", ToastLength.Short).Show();
                    });
                    Processing = false;
                    return;
                }
                _data = new DataCloseSession()
                {
                    Context = Context, Data = reading
                };
                if (await _data.doCheckings())
                {
                    dataList.Add(_data);
                    //after close code we insert all reading from previous rack
                    Values.dFt.SetMessage("Waiting for the pending data to be transmitted");
                    foreach (var r in dataList.Where(r => r.Status == dataStatus.READ || r.Status == dataStatus.WARNING))
                    {
                        await r.ToDB();
                    }
                    Values.sFt.UpdateInfo();
                    //await Values.iFt.pushInfo("Waiting for the pending data to be transmitted");
                    while (true)
                    {
                        //SpinWait.SpinUntil(() => Values.SQLidb.pendingData && (monitor.State == NetworkState.ConnectedData || monitor.State == NetworkState.ConnectedWifi));
                        await Task.Delay(1000);

                        if (Values.SQLidb.db.Table <ScannedData>().Where(r => r.Transmitted == false).CountAsync().Result == 0)//(Values.sFt.ReadQtyReceived == Values.sFt.ReadQtyTransmitted && Values.sFt.CheckQtyReceived == Values.sFt.CheckQtyTransmitted)
                        {
                            break;
                        }
                    }

                    await Values.EmptyDatabase();

                    //clear info, debug and status fragments
                    Values.iFt.Clear();
                    Values.dFt.Clear();
                    Values.sFt.Clear();
                    Values.hFt.Clear();
                    Values.gDatos.User     = "";
                    Values.gDatos.Password = "";
                    Values.Session         = "";
                    dataList.Clear();
                    position = -1;
                    //change to enter order fragment
                    var intent = new Intent(Context, typeof(MainActivity));
                    ((MainScreen)Context).StartActivityForResult(intent, 1);
                    //Context.Dispose();
                    Processing = false;
                    return;
                }
            }
            else
            //NEW READING QTY
            if (reading.IsNumeric())
            {
                if (position > -1 && Current() is DataReading)
                {
                    DataReading _r = (DataReading)Current();
                    _r.Qty = reading.ToInt();
                    await _r.doCheckings();
                }
                else
                {
                    cSounds.Error(Context);
                    Processing = false;
                    return;
                }
                cSounds.Scan(Context);
                Current().UpdateCurrent();
                Processing = false;
                return;
            }
        }