Пример #1
0
        protected override void OnStartup(StartupEventArgs e)
        {
            base.OnStartup(e);

            SharedCodeWithDll sharedCode = new SharedCodeWithDll();

            MainDll.App.Initialize(sharedCode);

            SettingsM.Instance.Load(MainDll.App.Config);

            switch (SettingsM.Instance.SaveBackupIn)
            {
            case BackupsSaveLocation.File:
                BackupsConfigFile.Instance.Load();
                BackupsM.Instance.Load(BackupsConfigFile.Instance);
                break;

            case BackupsSaveLocation.RESTService:
                RESTBackups   restBackups = new RESTBackups();
                Task <string> task        = restBackups.GetBackupsAsync();
                try
                {
                    task.Wait();
                    BackupsM.Instance.Load(task.Result);
                }
                catch (Exception ex)
                {
                    string innerEx = ex.InnerException != null ? " inner ex:<" + ex.InnerException.Message + ">" : "";
                    Log.main.Add(new Mess(LogType.ERR, "", "GetBackupsAsync return exception:<" + ex.Message + ">" + innerEx));
                }
                break;

            case BackupsSaveLocation.Db:
                break;

            default:
                Log.main.Add(new Mess(LogType.ERR, "", "Received unexpected value for SettingsM.Instance.SaveBackupIn:<" + SettingsM.Instance.SaveBackupIn.ToString() + ">"));
                break;
            }
            var wndMain = new WndMainV();

            wndMain.Show();
        }
Пример #2
0
        private void SaveBackups()
        {
            switch (SettingsM.Instance.SaveBackupIn)
            {
            case BackupsSaveLocation.File:
                this.Save(BackupsConfigFile.Instance);
                BackupsConfigFile.Instance.SaveOnFile(false);
                break;

            case BackupsSaveLocation.RESTService:
                string serialization = "";
                if (Serialize.SerializeInText(this, ref serialization) == false)
                {
                    return;
                }
                RESTBackups restBackups = new RESTBackups();
                //restBackups.PutBackupsAsync(serialization);

                Task put = restBackups.PutBackupsAsync(serialization);
                //await put;
                try { put.Wait(); }
                catch (Exception ex)
                {
                    if (ex.InnerException != null)
                    {
                        throw ex.InnerException;
                    }
                    else
                    {
                        throw ex;
                    }
                }
                break;

            case BackupsSaveLocation.Db:
                break;

            default:
                Log.main.Add(new Mess(LogType.ERR, "", $"Received unexpected value for SettingsM.Instance.SaveBackupIn:<{SettingsM.Instance.SaveBackupIn}>"));
                break;
            }
        }