コード例 #1
0
ファイル: LoadAsync.cs プロジェクト: FidusRewards/Fidus-app
        public async Task <ObservableCollection <History> > Load(string person, WhiteList qrcode = null)
        {
            ObservableCollection <History> Hitems;
            IEnumerable <History>          result;

            //Hitems.Clear();
            var _tablaH = (IMobileServiceSyncTable <History>)_tabla;

            if (qrcode == null)
            {
                result = await _tablaH.Where(history => history.Person == person)
                         .Take(1000).OrderByDescending(x => x.DateTime).ToEnumerableAsync();

                //if (!Utils.IsAny(result))
                //{
                //	Debug.WriteLine("Load History null -> Syncing");
                //	await InitSync();
                //	result = await _tablaH.Where(history => history.Person == person)
                //						 .Take(1000).OrderByDescending(x => x.DateTime).ToEnumerableAsync();
                //}
            }
            else
            {
                IMobileServiceTableQuery <History> _query = _tablaH.CreateQuery().Where(history => (history.ExchangeCode == qrcode.ExchangeCode) && (history.DateTime.Day == DateTime.Now.Day) && (history.Person == person));
                result = await _query.ToEnumerableAsync();
            }

            Hitems = new ObservableCollection <History>(result);

            //foreach (History item in result)
            //{

            //		Hitems.Add((History)item);

            //}

            return(Hitems);
        }
コード例 #2
0
ファイル: LoadAsync.cs プロジェクト: FidusRewards/Fidus-app
 public async Task Delete(WhiteList qrwhite)
 {
     var temptab = (IMobileServiceSyncTable <WhiteList>)_tabla;
     await temptab.DeleteAsync(qrwhite);
 }
コード例 #3
0
        public bool IsQRtempValid(WhiteList qrcode)
        {
            TimeSpan difference;
            bool     flag = false;

            if (qrcode != null)
            {
                try
                {
                    // CONSULTA DE LOS REGISTROS EN LOS QUE EL CODIGO QR SEA = AL ESCANEADO, EL ESCANEO SE HAYAN HECHO HOY
                    //  Y LA PERSONA QUE ESCANEO ES EL QUE AHORA ESTA ESCANEANDO

                    var _qrdatetime = Helpers.Settings.QRLastTimes.Split(',');
                    var _qrbranch   = Helpers.Settings.QRLastBranches.Split(',');
                    Helpers.Settings.qrdate.Clear();
                    Helpers.Settings.qrbranch.Clear();

                    if (!_qrdatetime.Contains("nada"))
                    {
                        for (int i = 0; i < _qrbranch.Count(); i++)
                        {
                            DateTime convertedDate = DateTime.SpecifyKind(
                                DateTime.Parse(_qrdatetime[i]),
                                DateTimeKind.Local);
                            if (_qrbranch[i] == qrcode.Branch)                              //_qrlastcode[i]==qrcode.ExchangeCode &&
                            {
                                difference = (DateTime.Now.ToLocalTime() - convertedDate);
                            }
                            else
                            {
                                difference = TimeSpan.Parse("01:01:00");
                            }

                            if (i > 0)
                            {
                                _qrbranch[i]   = "," + _qrbranch[i];
                                _qrdatetime[i] = "," + _qrdatetime[i];
                            }
                            Helpers.Settings.qrdate.Enqueue(_qrdatetime[i]);
                            Helpers.Settings.qrbranch.Enqueue(_qrbranch[i]);

                            if (difference.TotalHours < 1)
                            {
                                flag = true;
                            }
                        }
                        Helpers.Settings.qrdate.Enqueue("," + DateTime.Now.ToString());
                        Helpers.Settings.qrbranch.Enqueue("," + qrcode.Branch);

                        if (Helpers.Settings.qrbranch.Count > Helpers.Settings.CantQR)
                        {
                            Helpers.Settings.qrdate.Dequeue();
                            Helpers.Settings.qrbranch.Dequeue();
                        }

                        if (flag)
                        {
                            return(false);
                        }
                        else
                        {
                            return(true);
                        }
                    }

                    Helpers.Settings.qrbranch.Enqueue(qrcode.Branch);
                    Helpers.Settings.qrdate.Enqueue(DateTime.Now.ToString());
                    return(true);
                }
                catch (Exception ex)
                {
                    Debug.WriteLine("MainVM: Error en Conexíon qrcode" + ex);
                    MessagingCenter.Send(this, "NOINET");
                    return(false);
                }
            }
            return(false);
        }