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); }
public async Task <DeviceInfo> GetDeviceInfo(string deviceSerial) { //SendMessage("Getting device info."); var _result = new DeviceInfo(); _result.Serial = deviceSerial; try { using (var _rs = new XMLRS($"Select CM,Code, MainCOD3, TypeFLAGS from Sistemas..ItemsCab where Serial='{deviceSerial}'", Values.gDatos)) { await _rs.OpenAsync(); if (_rs.RecordCount == 0) { //SendError("Device not found in Espack Inventory."); return(_result); } _result.CM = _rs["CM"].ToString(); _result.DeviceCOD3 = _rs["MainCOD3"].ToString(); _result.DeviceCode = _rs["Code"].ToString(); _result.flags = _rs["TypeFLAGS"].ToString(); //SendMessage($"Device found {_result.CM} assigned to {_result.DeviceCOD3} warehouse"); } return(_result); } catch (Exception ex) { Context context = Android.App.Application.Context; Toast.MakeText(context, $"Semurió!:{ex.Message}", ToastLength.Long).Show(); return(_result); } }
private async Task getDataFromServer() { //Dismiss Keybaord InputMethodManager imm = (InputMethodManager)Activity.GetSystemService(Context.InputMethodService); //get location int _progress = 0; Values.iFt.SetMessage("Getting Sequence Numbers table"); //data from RacksBlocks table using (var _rs = new XMLRS($"select distinct SequenceNumber,TicketVIN,TicketPartnumber from SequencingSessionDet where CONVERT(varchar(10),xfec,103)=CONVERT(varchar(10),getdate(),103) order by SequenceNumber", Values.gDatos)) { await _rs.OpenAsync();/* * Values.sFt.socksProgress.Indeterminate = false; * Values.sFt.socksProgress.Max = _rs.RecordCount / 5; * Values.sFt.socksProgress.Progress = 0; */ foreach (var r in _rs.Rows) { await Values.SQLidb.db.InsertAsync(new Tickets { SequenceNumber = r["SequenceNumber"].ToString(), TicketVIN = r["TicketVIN"].ToString(), TicketPartnumber = r["TicketPartnumber"].ToString(), }); //_progress++; //if (_progress % 5 == 0) // Values.sFt.socksProgress.Progress++; } } //Values.sFt.socksProgress.Indeterminate = true; Values.iFt.SetMessage("Done"); /* * Values.iFt.pushInfo("Getting PartnumberRacks table"); * //data from RacksBlocks table * using (var _rs = new XMLRS(string.Format("Select p.Rack,Partnumber,MinBoxes,MaxBoxes,p.flags from LOGISTICA..PartnumbersRacks p inner join LOGISTICA..RacksBlocks r on r.Rack=p.Rack where p.service='{0}' and dbo.CheckFlag(r.flags,'OBS')=0", Values.gService), Values.gDatos)) * { * await _rs.OpenAsync(); * Values.sFt.socksProgress.Indeterminate = false; * Values.sFt.socksProgress.Max = _rs.RecordCount / 5; * Values.sFt.socksProgress.Progress = 0; * foreach (var r in _rs.Rows) * { * await Values.SQLidb.db.InsertAsync(new PartnumbersRacks { Rack = r["Rack"].ToString(), Partnumber = r["Partnumber"].ToString(), MinBoxes = r["MinBoxes"].ToInt(), MaxBoxes = r["MaxBoxes"].ToInt() }); * _progress++; * if (_progress % 5 == 0) * Values.sFt.socksProgress.Progress++; * } * } * Values.sFt.socksProgress.Indeterminate = true; * Values.iFt.pushInfo("Done loading database data"); */ Values.elIntent = new Intent(Activity, typeof(DataTransferManager)); Activity.StartService(Values.elIntent); DataTransferManager.Active = true; }
//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); }
public async Task <DeviceInfo> GetDeviceInfo(string deviceSerial) { SendMessage("Getting device info."); var _result = new DeviceInfo(); _result.Serial = deviceSerial; using (var _rs = new XMLRS($"Select CM,Code, MainCOD3 from Sistemas..ItemsCab where Serial='{deviceSerial}'", Conn)) { await _rs.OpenAsync(); if (_rs.RecordCount == 0) { SendError("Device not found in Espack Inventory."); return(_result); } _result.CM = _rs["CM"].ToString(); _result.DeviceCOD3 = _rs["MainCOD3"].ToString(); _result.DeviceCode = _rs["Code"].ToString(); SendMessage($"Device found {_result.CM} assigned to {_result.DeviceCOD3} warehouse"); } return(_result); }
//method to get all the data from sql server private async Task getDataFromServer() { //Dismiss Keybaord InputMethodManager imm = (InputMethodManager)Activity.GetSystemService(Context.InputMethodService); //get location if android >= 5.1 /* * if (Values.GEO) * { * var androindVersion = Android.OS.Build.VERSION.SdkInt; * if (androindVersion >= BuildVersionCodes.LollipopMr1) * { * * * using (var rs = new XMLRS("Select CMP_INTEGER from Datos_Empresa where Codigo='LOC_TIME'", Values.gDatos)) * { * await rs.OpenAsync(); * if (rs.RecordCount != 0) * Values.LocTime = rs["CMP_INTEGER"].ToInt(); * } * var request = new GeolocationRequest(GeolocationAccuracy.High, TimeSpan.FromSeconds(30)); * var ini = await Geolocation.GetLastKnownLocationAsync(); * Location location = null; * //try * //{ * // location = await Geolocation.GetLocationAsync(request); * //} * //catch (Exception ex) * //{ * // Console.WriteLine(ex.Message); * //} * if (location != null) * { * var _locData = new DataLocation() { Accuracy = location.Accuracy, Course = location.Course, Altitude = location.Altitude, Latitude = location.Latitude, Longitude = location.Longitude, Speed = location.Speed, Timestamp = location.Timestamp }; * await _locData.ToDB(); * } * Activity.StartService(new Intent(Activity, typeof(LocatorService))); * LocatorService.Active = true; * } * } */ imm.HideSoftInputFromWindow(orderNumberET.WindowToken, 0); int _progress = 0; if (Values.gOrderNumber != 0) { Values.iFt.pushInfo("Getting Label Data"); //data from labels for checkng using (var _rs = new XMLRS(string.Format("select numero,partnumber,qty,cajas,rack,Modulo from etiquetas where Numero_orden={0} and Tipo='PEQ'", Values.gOrderNumber), Values.gDatos)) { await _rs.OpenAsync(); Values.sFt.socksProgress.Indeterminate = false; Values.sFt.socksProgress.Max = _rs.RecordCount / 5; Values.sFt.socksProgress.Progress = 0; foreach (var r in _rs.Rows) { await Values.SQLidb.db.InsertAsync(new Labels { Serial = r["numero"].ToString(), Partnumber = r["partnumber"].ToString(), qty = r["qty"].ToInt(), boxes = r["cajas"].ToInt(), rack = r["rack"].ToString(), mod = r["Modulo"].ToString() }); _progress++; if (_progress % 5 == 0) { Values.sFt.socksProgress.Progress++; } } Values.sFt.socksProgress.Indeterminate = true; //Values.sFt.CheckQtyTotal= _rs.Rows.Count; //Values.sFt.UpdateInfo(); } Values.iFt.pushInfo("Done"); } Values.iFt.pushInfo("Getting RacksBlocks table"); //data from RacksBlocks table using (var _rs = new XMLRS(string.Format("select Block,Rack from RacksBlocks where service='{0}' and dbo.CheckFlag(flags,'OBS')=0", Values.gService), Values.gDatos)) { await _rs.OpenAsync(); Values.sFt.socksProgress.Indeterminate = false; Values.sFt.socksProgress.Max = _rs.RecordCount / 5; Values.sFt.socksProgress.Progress = 0; foreach (var r in _rs.Rows) { await Values.SQLidb.db.InsertAsync(new RacksBlocks { Block = r["Block"].ToString(), Rack = r["Rack"].ToString() }); _progress++; if (_progress % 5 == 0) { Values.sFt.socksProgress.Progress++; } } } Values.sFt.socksProgress.Indeterminate = true; Values.iFt.pushInfo("Done"); Values.iFt.pushInfo("Getting PartnumberRacks table"); //data from RacksBlocks table // [dvalles] 20220513: Added isnull to the alternate column so it doesn't raise an error later. When the column gets a null value, the column is not created in the SQLidb object string _prquery = $"Select p.Rack,Partnumber,MinBoxes,MaxBoxes,p.flags,alternate=isnull(dbo.fObtenerValor(ExtraData,'ALTREAD'),'') from PartnumbersRacks p inner join RacksBlocks r on r.Rack=p.Rack where p.service='{Values.gService}' " + #if DEBUG $"and r.Block='{Values.gBlock}' " + #endif $"and dbo.CheckFlag(r.flags,'OBS')=0"; using (var _rs = new XMLRS(_prquery, Values.gDatos)) { await _rs.OpenAsync(); Values.sFt.socksProgress.Indeterminate = false; Values.sFt.socksProgress.Max = _rs.RecordCount / 5; Values.sFt.socksProgress.Progress = 0; foreach (var r in _rs.Rows) { await Values.SQLidb.db.InsertAsync(new PartnumbersRacks { Rack = r["Rack"].ToString(), Partnumber = r["Partnumber"].ToString(), MinBoxes = r["MinBoxes"].ToInt(), MaxBoxes = r["MaxBoxes"].ToInt(), alternate = r["alternate"].ToString() }); _progress++; if (_progress % 5 == 0) { Values.sFt.socksProgress.Progress++; } } } Values.sFt.socksProgress.Indeterminate = true; Values.iFt.pushInfo("Done loading database data"); Values.elIntent = new Intent(Activity, typeof(DataTransferManager)); Activity.StartService(Values.elIntent); DataTransferManager.Active = true; ((MainScreen)Activity).changeOrderToEnterDataFragments(); }
//method to get all the data from sql server private async Task getDataFromServer() { //Dismiss Keybaord InputMethodManager imm = (InputMethodManager)Activity.GetSystemService(Context.InputMethodService); imm.HideSoftInputFromWindow(orderNumberET.WindowToken, 0); int _progress = 0; if (Values.gOrderNumber != 0) { Values.iFt.pushInfo("Getting Label Data"); //data from labels for checkng using (var _rs = new XMLRS(string.Format("select numero,partnumber,qty,cajas,rack,Modulo from etiquetas where Numero_orden={0} and Tipo='PEQ'", Values.gOrderNumber), Values.gDatos)) { await _rs.OpenAsync(); Values.sFt.socksProgress.Indeterminate = false; Values.sFt.socksProgress.Max = _rs.RecordCount / 5; Values.sFt.socksProgress.Progress = 0; foreach (var r in _rs.Rows) { await Values.SQLidb.db.InsertAsync(new Labels { Serial = r["numero"].ToString(), Partnumber = r["partnumber"].ToString(), qty = r["qty"].ToInt(), boxes = r["cajas"].ToInt(), rack = r["rack"].ToString(), mod = r["Modulo"].ToString() }); _progress++; if (_progress % 5 == 0) { Values.sFt.socksProgress.Progress++; } } Values.sFt.socksProgress.Indeterminate = true; //Values.sFt.CheckQtyTotal= _rs.Rows.Count; //Values.sFt.UpdateInfo(); } Values.iFt.pushInfo("Done"); } Values.iFt.pushInfo("Getting RacksBlocks table"); //data from RacksBlocks table using (var _rs = new XMLRS(string.Format("select Block,Rack from RacksBlocks where service='{0}' and dbo.CheckFlag(flags,'OBS')=0", Values.gService), Values.gDatos)) { await _rs.OpenAsync(); Values.sFt.socksProgress.Indeterminate = false; Values.sFt.socksProgress.Max = _rs.RecordCount / 5; Values.sFt.socksProgress.Progress = 0; foreach (var r in _rs.Rows) { await Values.SQLidb.db.InsertAsync(new RacksBlocks { Block = r["Block"].ToString(), Rack = r["Rack"].ToString() }); _progress++; if (_progress % 5 == 0) { Values.sFt.socksProgress.Progress++; } } } Values.sFt.socksProgress.Indeterminate = true; Values.iFt.pushInfo("Done"); Values.iFt.pushInfo("Getting PartnumberRacks table"); //data from RacksBlocks table using (var _rs = new XMLRS(string.Format("Select p.Rack,Partnumber,MinBoxes,MaxBoxes,p.flags from PartnumbersRacks p inner join RacksBlocks r on r.Rack=p.Rack where p.service='{0}' and dbo.CheckFlag(r.flags,'OBS')=0", Values.gService), Values.gDatos)) { await _rs.OpenAsync(); Values.sFt.socksProgress.Indeterminate = false; Values.sFt.socksProgress.Max = _rs.RecordCount / 5; Values.sFt.socksProgress.Progress = 0; foreach (var r in _rs.Rows) { await Values.SQLidb.db.InsertAsync(new PartnumbersRacks { Rack = r["Rack"].ToString(), Partnumber = r["Partnumber"].ToString(), MinBoxes = r["MinBoxes"].ToInt(), MaxBoxes = r["MaxBoxes"].ToInt() }); _progress++; if (_progress % 5 == 0) { Values.sFt.socksProgress.Progress++; } } } Values.sFt.socksProgress.Indeterminate = true; Values.iFt.pushInfo("Done loading database data"); Values.elIntent = new Intent(Activity, typeof(DataTransferManager)); Activity.StartService(Values.elIntent); DataTransferManager.Active = true; ((MainScreen)Activity).changeOrderToEnterDataFragments(); }