public async Task <List <SPartNumber> > GetServicePartnumbers(string service) { var _result = new List <SPartNumber>(); SendMessage("Getting partnumbers"); using (var _rs = new XMLRS($"select partnumber,prefix,base,suffix from logistica..referencias where servicio='{service}' and dbo.CheckFlag(flags,'OBS')=0", Conn)) { await _rs.OpenAsync(); SendMessage("@@startprogress", _rs.RecordCount.ToString()); //ProgressChecks.Indeterminate = false; //ProgressChecks.Max = _rs.RecordCount; //ProgressChecks.Progress = 0; foreach (var r in _rs.Rows) { //await Values.SQLidb.db.InsertAsync(new Referencias { partnumber = _rs["partnumber"].ToString(), pnBase = _rs["base"].ToString(), pnPrefix = _rs["prefix"].ToString(), pnSuffix = _rs["suffix"].ToString() }); var _part = new SPartNumber() { Base = _rs["base"].ToString(), Prefix = _rs["prefix"].ToString(), Suffix = _rs["suffix"].ToString() }; SendMessage("@@progressplus"); SendMessage(_part.PartNumber); _result.Add(_part); _rs.MoveNext(); } //ProgressChecks.Indeterminate = true; //Values.sFt.CheckQtyTotal= _rs.Rows.Count; //Values.sFt.UpdateInfo(); } SendMessage("Done"); SendMessage("@@endprogress"); return(_result); }
//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); }