Example #1
0
        public static void Update()
        {
            var instance = AppSettings.Instance;

            var version = instance[KEY];

            if (version == null || version != VALUE)
            {
                return;
            }

            var databases = DatabaseInfo.GetAll();

            foreach (var db in databases)
            {
                var details = db.Details;
                if (details.Source != DatabaseUpdater.DROPBOX_UPDATER)
                {
                    continue;
                }

                if (details.Type == SourceTypes.Synchronizable)
                {
                    continue;
                }

                details.Type = SourceTypes.Synchronizable;
                db.SaveDetails();
            }

            instance[KEY] = VALUE;
        }
Example #2
0
        private void ListDatabases(string tile)
        {
            var dispatcher = Dispatcher;
            var databases  = DatabaseInfo.GetAll();

            var open = tile == null ? null
                : databases.FirstOrDefault(
                x => x.Folder == tile);

            if (open != null)
            {
                dispatcher.BeginInvoke(
                    () => Open(open, true));

                return;
            }

            foreach (var db in databases)
            {
                db.LoadDetails();
            }

            var items = databases
                        .Where(x => x.Details != null)
                        .Select(x => new DatabaseItem(x))
                        .OrderBy(x => x.Name)
                        .ToList();

            foreach (var item in items)
            {
                var local = item;
                dispatcher.BeginInvoke(() =>
                {
                    UpdateItem(local, null);
                    _items.Add(local);
                });
            }

            var hasUpdatables = items
                                .Any(x => x.CanUpdate);

            dispatcher.BeginInvoke(() =>
                                   _mnuUpdateAll.IsEnabled = hasUpdatables);
        }
Example #3
0
        private void ListDatabases(string tile, string syncdb)
        {
            var dispatcher = Dispatcher;
            var databases  = DatabaseInfo.GetAll();

            var open = tile == null ? null
                : databases.FirstOrDefault(
                x => x.Folder == tile);

            if (open != null)
            {
                dispatcher.BeginInvoke(
                    () => Open(open, true));

                return;
            }

            foreach (var db in databases)
            {
                db.LoadDetails();
            }

            var items = databases
                        .Where(x => x.Details != null)
                        .Select(x => new DatabaseItem(x))
                        .OrderBy(x => x.Name)
                        .ToList();

            foreach (var item in items)
            {
                var local = item;
                dispatcher.BeginInvoke(() =>
                {
                    UpdateItem(local, null);
                    _items.Add(local);
                });
            }

            var hasUpdatables = items
                                .Any(x => x.CanUpdate);

            dispatcher.BeginInvoke(() =>
                                   _RefreshButton.IsEnabled = hasUpdatables);

            if (syncdb != null)
            {
                foreach (var db in items)
                {
                    var test = (DatabaseInfo)db.Info;
                    if (test.Folder == syncdb)
                    {
                        db.IsUpdating = true;
                    }
                }
                var udbi = databases.FirstOrDefault(x => x.Folder == syncdb);
                var udb  = new DatabaseItem(udbi);
                Update(udb);
            }

            var UpdateAbleDBs = items
                                .Where(x => x.CanUpdate);

            // AutoUpdate
            if (!_fAppLoaded)
            {
                _fAppLoaded = true;
                dispatcher.BeginInvoke(() =>
                {
                    if (hasUpdatables)
                    {
                        _RefreshButton.IsEnabled = true;

                        if (AppSettings.Instance.AutoUpdate)
                        {
                            if (AppSettings.Instance.AutoUpdateWLAN)
                            {
                                if (DeviceNetworkInformation.IsWiFiEnabled)
                                {
                                    foreach (var uDB in UpdateAbleDBs)
                                    {
                                        Update(uDB);
                                    }
                                }
                            }
                            else
                            {
                                foreach (var uDB in UpdateAbleDBs)
                                {
                                    Update(uDB);
                                }
                            }
                        }
                    }
                    else
                    {
                        _RefreshButton.IsEnabled = false;
                    }
                });
            }
        }