public void UpdateTile()
        {
            if (IsLowMemDevice)
                return;

            using (var context = new DataStoreContext())
            {
                var day = context.NextCollectionDay;

                if (!day.Bins.Any())
                    return;

                new TileExporter().Export(day);

                var tile  = ShellTile.ActiveTiles.First();
                tile.Update(new FlipTileData
                           {
                               Title                = "",
                               BackContent          = "",
                               BackgroundImage      = new Uri("isostore:/Shared/ShellContent/StandardTile.jpg", UriKind.Absolute),
                               SmallBackgroundImage = new Uri("isostore:/Shared/ShellContent/SmallTile.jpg",    UriKind.Absolute),
                               WideBackgroundImage  = new Uri("isostore:/Shared/ShellContent/WideTile.jpg",     UriKind.Absolute),
                           });
            }
        }
 void Create(DataStoreContext store)
 {
     store.CreateDatabase();
     var schemaUpdater = store.CreateDatabaseSchemaUpdater();
     schemaUpdater.DatabaseSchemaVersion = CURRENT_VERSION;
     schemaUpdater.Execute();
 }
Exemple #3
0
        public MainVM()
        {
            using (var context = new DataStoreContext())
            {
                var days = context.CollectionDays;
                if (days.Any())
                    Days = days.Take(3).Select(x => new DayVM(x)).ToArray();

                Bins = context.RubbishBins.Select(x => new RubbishBinVM(x)).ToArray();
            }
        }
Exemple #4
0
 public BinEditVM(int id)
     : this()
 {
     using (var store = new DataStoreContext())
     {
         var bin      = store.RubbishBins.First(x => x.Id == id);
         BinType      = new BinTypeVM(bin.BinType);
         OriginDate   = bin.OriginDate;
         WeekInterval = bin.Interval / 7;
     }
     EditType = "EDIT";
     Id       = id;
 }
Exemple #5
0
        public void Delete()
        {
            using (var store = new DataStoreContext())
            {
                var bin = store.RubbishBins.FirstOrDefault(x => x.Id == Id);
                if (bin != null)
                {
                    store.RubbishBins.DeleteOnSubmit(bin);
                    store.SubmitChanges();
                }
            }

            new LiveTileUpdater().UpdateTile();
            Status.SetAction("Delete successfully.", true);
        }
        public void Upgrade(DataStoreContext store)
        {
            if (!store.DatabaseExists())
            {
                Create(store);
                return;
            }

            var schema  = store.CreateDatabaseSchemaUpdater();
            int version = schema.DatabaseSchemaVersion;

            switch (version)
            {
                case 0 : store.DeleteDatabase(); Create(store); break;

                default : return;
            }

            schema.DatabaseSchemaVersion = CURRENT_VERSION;
            schema.Execute();
        }
Exemple #7
0
        public void Save()
        {
            using (var store = new DataStoreContext())
            {
                var bin = store.RubbishBins.FirstOrDefault(x => x.Id == Id);
                if (bin != null)
                {
                    store.RubbishBins.DeleteOnSubmit(bin);
                    store.SubmitChanges();
                }

                bin = new RubbishBin
                {
                    BinType    = BinType.Key,
                    OriginDate = OriginDate,
                    Interval   = WeekInterval * 7
                };
                store.RubbishBins.InsertOnSubmit(bin);
                store.SubmitChanges();
            }

            new LiveTileUpdater().UpdateTile();
            Status.SetAction("Saved successfully.", true);
        }