Example #1
0
        private static async Task Resize()
        {
            while (true)
            {
                UiView.CheckResize();
                StateKeeper.CheckIfStateHasToBeSaved();

                if (UiNotifications.HasItemToShow())
                {
                    UiView.Render();
                }

                await Task.Delay(1000);
            }
        }
Example #2
0
        public static async Task SaveToBlobAsync(this byte[] src, SettingsModel model)
        {
            if (model.BlobConnectionString == null)
            {
                return;
            }

            try
            {
                var blobStorage = new AzureBlobStorage(model.BlobConnectionString);
                var filename    = DateTime.UtcNow.ToString("s");

                await blobStorage.SaveBlobAsync("secrets", filename, src);
            }
            catch (Exception)
            {
                UiNotifications.Notify(ConsoleColor.Red, ConsoleColor.White, "Did not backup to blob", 5);
            }
        }
Example #3
0
        public static void SaveState()
        {
            var stateModel = new StateModel
            {
                Notebooks = NotebooksRepository.Get(),
                Pages     = PagesRepository.Get(),
                Content   = PageContentRepository.GetAll()
            };

            var json = Newtonsoft.Json.JsonConvert.SerializeObject(stateModel);

            var settingsModel = GetSettingsModel();

            var dataToSave = json.Encrypt(settingsModel);

            File.WriteAllBytes(settingsModel.File, dataToSave);

            UiNotifications.Notify(ConsoleColor.Red, ConsoleColor.Black, "Saved to Disk...", 5);

            Task.Run(() => dataToSave.SaveToBlobAsync(settingsModel));
        }