示例#1
0
        public ImportPQWindow()
        {
            PQDataCollection = new ObservableCollection <PQData>();
            _downloadedPqs   = new List <DownloadedPQInfo>();

            DataContext = this;
            InitializeComponent();

            Dispatcher.BeginInvoke(new Action(async() => {
                Core.ApplicationData.Instance.BeginActiviy();
                try
                {
                    if (!string.IsNullOrEmpty(Core.Settings.Default.LiveAPIDownloadedPQs))
                    {
                        string[] lines = Core.Settings.Default.LiveAPIDownloadedPQs.Split(new char[] { '\r', '\n' }, StringSplitOptions.RemoveEmptyEntries);
                        foreach (string l in lines)
                        {
                            string[] parts      = l.Split('|');
                            DownloadedPQInfo dp = new DownloadedPQInfo();
                            dp.Guid             = Guid.Parse(parts[0]);
                            dp.DownloadedAt     = DateTime.Parse(parts[1]);
                            if (dp.DownloadedAt >= DateTime.Now.AddDays(-7))
                            {
                                _downloadedPqs.Add(dp);
                            }
                        }
                        setLiveAPIDownloadedPQs();
                    }
                    using (var api = new LiveAPI.GeocachingLiveV6())
                    {
                        var resp = await api.Client.GetPocketQueryListAsync(api.Token);
                        if (resp.Status.StatusCode == 0)
                        {
                            foreach (var r in resp.PocketQueryList)
                            {
                                PQDataCollection.Add(new PQData(r));
                            }
                        }
                        else
                        {
                            Core.ApplicationData.Instance.Logger.AddLog(this, Core.Logger.Level.Error, resp.Status.StatusMessage);
                        }
                    }
                    foreach (var p in PQDataCollection)
                    {
                        if ((from a in _downloadedPqs where a.Guid == p.LiveAPIData.GUID select a).FirstOrDefault() == null)
                        {
                            listItems.SelectedItems.Add(p);
                        }
                    }
                }
                catch (Exception e)
                {
                    Core.ApplicationData.Instance.Logger.AddLog(this, e);
                }
                Core.ApplicationData.Instance.EndActiviy();
            }));
        }
示例#2
0
        public ImportPQWindow()
        {
            PQDataCollection = new ObservableCollection<PQData>();
            _downloadedPqs = new List<DownloadedPQInfo>();

            DataContext = this;
            InitializeComponent();

            Dispatcher.BeginInvoke(new Action(async ()=>{
                Core.ApplicationData.Instance.BeginActiviy();
                try
                {
                    if (!string.IsNullOrEmpty(Core.Settings.Default.LiveAPIDownloadedPQs))
                    {
                        string[] lines = Core.Settings.Default.LiveAPIDownloadedPQs.Split(new char[] { '\r', '\n' }, StringSplitOptions.RemoveEmptyEntries);
                        foreach(string l in lines)
                        {
                            string[] parts = l.Split('|');
                            DownloadedPQInfo dp = new DownloadedPQInfo();
                            dp.Guid = Guid.Parse(parts[0]);
                            dp.DownloadedAt = DateTime.Parse(parts[1]);
                            if (dp.DownloadedAt >= DateTime.Now.AddDays(-7))
                            {
                                _downloadedPqs.Add(dp);
                            }
                        }
                        setLiveAPIDownloadedPQs();
                    }
                    using (var api = new LiveAPI.GeocachingLiveV6())
                    {
                        var resp = await api.Client.GetPocketQueryListAsync(api.Token);
                        if (resp.Status.StatusCode==0)
                        {
                            foreach(var r in resp.PocketQueryList)
                            {
                                PQDataCollection.Add(new PQData(r));
                            }
                        }
                        else
                        {
                            Core.ApplicationData.Instance.Logger.AddLog(this, Core.Logger.Level.Error, resp.Status.StatusMessage);
                        }
                    }
                    foreach(var p in PQDataCollection)
                    {
                        if ((from a in _downloadedPqs where a.Guid == p.LiveAPIData.GUID select a).FirstOrDefault() == null)
                        {
                            listItems.SelectedItems.Add(p);
                        }
                    }
                }
                catch(Exception e)
                {
                    Core.ApplicationData.Instance.Logger.AddLog(this, e);
                }
                Core.ApplicationData.Instance.EndActiviy();
            }));
        }
示例#3
0
        private void updateProcessedPq(Guid pqguid)
        {
            DownloadedPQInfo dp = (from a in _downloadedPqs where a.Guid == pqguid select a).FirstOrDefault();

            if (dp == null)
            {
                dp      = new DownloadedPQInfo();
                dp.Guid = pqguid;
                _downloadedPqs.Add(dp);
            }
            dp.DownloadedAt = DateTime.Now;
            setLiveAPIDownloadedPQs();
        }
示例#4
0
 private void updateProcessedPq(Guid pqguid)
 {
     DownloadedPQInfo dp = (from a in _downloadedPqs where a.Guid == pqguid select a).FirstOrDefault();
     if (dp == null)
     {
         dp = new DownloadedPQInfo();
         dp.Guid = pqguid;
         _downloadedPqs.Add(dp);
     }
     dp.DownloadedAt = DateTime.Now;
     setLiveAPIDownloadedPQs();
 }