public async Task LoadProfile(bool useRemoteConnection = true)
        {
            _appID = Guid.Empty;
            if (File.Exists(_localAppIdFile.LocalPath))
            {
                var document = new XmlDocument();
                document.Load(_localAppIdFile.LocalPath);

                var node = document.SelectSingleNode(@"//Config/AppID");
                if (!string.IsNullOrEmpty(node?.InnerText))
                {
                    _appID = new Guid(node.InnerText);
                }

                SubStorageName = document.SelectSingleNode(@"//Config/SubStorageName")?.InnerText;
            }

            if (_appID.Equals(Guid.Empty))
            {
                SaveProfile();
            }

            ProfilesRootFolder = new StorageDirectory(new[] { FileStorageManager.OutgoingFolderName, AppName });
            if (!await ProfilesRootFolder.Exists(useRemoteConnection))
            {
                await StorageDirectory.CreateSubFolder(new[] { FileStorageManager.OutgoingFolderName }, AppName, useRemoteConnection);
            }

            ProfileFolder = new StorageDirectory(ProfilesRootFolder.RelativePathParts.Merge(ProfileName));
            if (!await ProfileFolder.Exists(useRemoteConnection))
            {
                await StorageDirectory.CreateSubFolder(ProfilesRootFolder.RelativePathParts, ProfileName, useRemoteConnection);
            }

            SharedFolder = new StorageDirectory(ProfilesRootFolder.RelativePathParts.Merge(SharedFolderName));
            if (!await ProfileFolder.Exists(useRemoteConnection))
            {
                await StorageDirectory.CreateSubFolder(ProfilesRootFolder.RelativePathParts, SharedFolderName, useRemoteConnection);
            }

            UserDataFolder = new StorageDirectory(ProfileFolder.RelativePathParts.Merge(new[] { UserDataFolderName }));
            if (!await UserDataFolder.Exists(useRemoteConnection))
            {
                await StorageDirectory.CreateSubFolder(ProfileFolder.RelativePathParts, UserDataFolderName, useRemoteConnection);
            }

            AppSaveFolder = new StorageDirectory(ProfileFolder.RelativePathParts.Merge(SavedFilesFolderName));
            if (!await AppSaveFolder.Exists(useRemoteConnection))
            {
                await StorageDirectory.CreateSubFolder(ProfileFolder.RelativePathParts, SavedFilesFolderName, useRemoteConnection);
            }

            AppDataFolder = new StorageDirectory(new[] { FileStorageManager.IncomingFolderName, AppName, "Data" });
        }
        public virtual void LoadToggleData(StorageDirectory holderAppDataFolder)
        {
            DataFolder = new StorageDirectory(holderAppDataFolder.RelativePathParts.Merge(Id));
            if (FileStorageManager.Instance.DataState == DataActualityState.Updated ||
                FileStorageManager.Instance.UseLocalMode)
            {
                return;
            }

            AsyncHelper.RunSync(async() =>
            {
                var templateVersionFile = new StorageFile(DataFolder.RelativePathParts.Merge("version.txt"));
                if (!await templateVersionFile.Exists(true) || await templateVersionFile.IsOutOfDate())
                {
                    await DataFolder.Allocate(false);
                    if (await DataFolder.Exists(true))
                    {
                        var templateFiles = (await DataFolder.GetRemoteFiles()).ToList();
                        foreach (var templateFile in templateFiles)
                        {
                            if (templateFile.Name.Contains(".rar"))
                            {
                                var archiveFolder = new ArchiveDirectory(DataFolder.RelativePathParts.Merge(templateFile.NameOnly));
                                await archiveFolder.Download();
                            }
                            else
                            {
                                await templateFile.Download();
                            }
                        }
                    }
                }
            });
        }
        public async Task LoadSubStorageIndependentResources()
        {
            #region Local
            TempFolder = new StorageDirectory(new[]
            {
                "Temp"
            });
            if (!await TempFolder.Exists())
            {
                await StorageDirectory.CreateSubFolder(new string[] { }, "Temp");
            }

            AppSettingsFolder = new StorageDirectory(new[]
            {
                FileStorageManager.LocalFilesFolderName,
                AppProfileManager.Instance.AppSubStorageIndependentFolderName,
            });
            if (!await AppSettingsFolder.Exists())
            {
                await StorageDirectory.CreateSubFolder(new[] { FileStorageManager.LocalFilesFolderName }, AppProfileManager.Instance.AppSubStorageIndependentFolderName);
            }

            FavoriteImagesFolder = new StorageDirectory(new[]
            {
                FileStorageManager.LocalFilesFolderName,
                "image_favorites"
            });
            if (!await FavoriteImagesFolder.Exists())
            {
                await StorageDirectory.CreateSubFolder(new[] { FileStorageManager.LocalFilesFolderName }, "image_favorites");
            }

            UserListsFolder = new StorageDirectory(new[]
            {
                FileStorageManager.LocalFilesFolderName,
                "user_lists"
            });
            if (!await UserListsFolder.Exists())
            {
                await StorageDirectory.CreateSubFolder(new[] { FileStorageManager.LocalFilesFolderName }, "user_lists");
            }

            SharedSettingsFile = new StorageFile(new[]
            {
                FileStorageManager.LocalFilesFolderName,
                FileStorageManager.CommonIncomingFolderName,
                "Settings.xml"
            });
            SharedSettingsFile.AllocateParentFolder();

            AppSettingsFile = new StorageFile(new[]
            {
                FileStorageManager.LocalFilesFolderName,
                AppProfileManager.Instance.AppSubStorageIndependentFolderName,
                "Settings.xml"
            });
            AppSettingsFile.AllocateParentFolder();
            #endregion

            #region Remote
            LauncherTemplatesFolder = new ArchiveDirectory(new[]
            {
                FileStorageManager.IncomingFolderName,
                FileStorageManager.CommonIncomingFolderName,
                "LauncherTemplates"
            });
            await LauncherTemplatesFolder.Download();

            SpecialAppsFolder = new ArchiveDirectory(new[]
            {
                FileStorageManager.IncomingFolderName,
                FileStorageManager.CommonIncomingFolderName,
                "SpecialApps"
            });
            if (await SpecialAppsFolder.Exists(true))
            {
                await SpecialAppsFolder.Download();
            }
            #endregion
        }
Ejemplo n.º 4
0
        public async Task Load()
        {
            #region Local
            TempFolder = new StorageDirectory(new[]
            {
                "Temp"
            });
            if (!await TempFolder.Exists())
            {
                await StorageDirectory.CreateSubFolder(new string[] { }, "Temp");
            }

            AppSettingsFolder = new StorageDirectory(new[]
            {
                FileStorageManager.LocalFilesFolderName,
                AppProfileManager.Instance.AppSubStorageDependentFolderName,
            });
            if (!await AppSettingsFolder.Exists())
            {
                await StorageDirectory.CreateSubFolder(new[] { FileStorageManager.LocalFilesFolderName }, AppProfileManager.Instance.AppSubStorageIndependentFolderName);
            }

            AppSettingsFile = new StorageFile(new[]
            {
                FileStorageManager.LocalFilesFolderName,
                AppProfileManager.Instance.AppSubStorageIndependentFolderName,
                "Settings.xml"
            });
            AppSettingsFile.AllocateParentFolder();
            #endregion

            #region Remote
            AppConfigFile = new StorageFile(new[]
            {
                FileStorageManager.IncomingFolderName,
                AppProfileManager.Instance.AppSubStorageIndependentFolderName,
                "AppSettings",
                "Config.xml"
            });
            await AppConfigFile.Download();

            TabsConfigFile = new StorageFile(new[]
            {
                FileStorageManager.IncomingFolderName,
                AppProfileManager.Instance.AppSubStorageIndependentFolderName,
                "AppSettings",
                "TabNames.xml"
            });
            await TabsConfigFile.Download();

            WatchedProcessesFile = new StorageFile(new[]
            {
                FileStorageManager.IncomingFolderName,
                AppProfileManager.Instance.AppSubStorageIndependentFolderName,
                "AppSettings",
                "HideList.xml"
            });
            await WatchedProcessesFile.Download();

            MaintenanceConfigFile = new StorageFile(new[]
            {
                FileStorageManager.IncomingFolderName,
                AppProfileManager.Instance.AppSubStorageIndependentFolderName,
                "AppSettings",
                "maintenance.xml"
            });
            if (await MaintenanceConfigFile.Exists(true))
            {
                await MaintenanceConfigFile.Download();
            }

            PatchUpdaterConfigFile = new StorageFile(new[]
            {
                FileStorageManager.IncomingFolderName,
                AppProfileManager.Instance.AppSubStorageIndependentFolderName,
                "AppSettings",
                "sfx_update.xml"
            });
            if (await PatchUpdaterConfigFile.Exists(true))
            {
                await PatchUpdaterConfigFile.Download();
            }

            UpdaterConfigFile = new StorageFile(new[]
            {
                FileStorageManager.IncomingFolderName,
                AppProfileManager.Instance.AppSubStorageIndependentFolderName,
                "AppSettings",
                "updater.xml"
            });
            if (await UpdaterConfigFile.Exists(true))
            {
                await UpdaterConfigFile.Download();
            }

            NoSyncConfigFile = new StorageFile(new[]
            {
                FileStorageManager.IncomingFolderName,
                AppProfileManager.Instance.AppSubStorageIndependentFolderName,
                "Resources",
                "NoSync.xml"
            });
            if (await NoSyncConfigFile.Exists(true))
            {
                await NoSyncConfigFile.Download();
            }

            SyncFormColorConfigFile = new StorageFile(new[]
            {
                FileStorageManager.IncomingFolderName,
                AppProfileManager.Instance.AppSubStorageIndependentFolderName,
                "Resources",
                "sync_color.xml"
            });
            if (await SyncFormColorConfigFile.Exists(true))
            {
                await SyncFormColorConfigFile.Download();
            }

            IconFile = new StorageFile(new[]
            {
                FileStorageManager.IncomingFolderName,
                AppProfileManager.Instance.AppSubStorageIndependentFolderName,
                "Resources",
                "icon.ico"
            });
            if (await IconFile.Exists(true))
            {
                await IconFile.Download();
            }

            LoginLogoFile = new StorageFile(new[]
            {
                FileStorageManager.IncomingFolderName,
                AppProfileManager.Instance.AppSubStorageIndependentFolderName,
                "Resources",
                "app_logo.png"
            });
            if (await LoginLogoFile.Exists(true))
            {
                await LoginLogoFile.Download();
            }

            SplashLogoFile = new StorageFile(new[]
            {
                FileStorageManager.IncomingFolderName,
                AppProfileManager.Instance.AppSubStorageIndependentFolderName,
                "Resources",
                "splash_logo.png"
            });
            if (await SplashLogoFile.Exists(true))
            {
                await SplashLogoFile.Download();
            }

            SyncFormCloseImageFile = new StorageFile(new[]
            {
                FileStorageManager.IncomingFolderName,
                AppProfileManager.Instance.AppSubStorageIndependentFolderName,
                "Resources",
                "ProgressCancel.png"
            });
            if (await SyncFormCloseImageFile.Exists(true))
            {
                await SyncFormCloseImageFile.Download();
            }

            UndockFormImageFile = new StorageFile(new[]
            {
                FileStorageManager.IncomingFolderName,
                AppProfileManager.Instance.AppSubStorageIndependentFolderName,
                "Resources",
                "undock_arrow.png"
            });
            if (await UndockFormImageFile.Exists(true))
            {
                await UndockFormImageFile.Download();
            }

            DockRegularImageFile = new StorageFile(new[]
            {
                FileStorageManager.IncomingFolderName,
                AppProfileManager.Instance.AppSubStorageIndependentFolderName,
                "Resources",
                "dock_arrow_ribbon.png"
            });
            if (await DockRegularImageFile.Exists(true))
            {
                await DockRegularImageFile.Download();
            }

            DockFloaterImageFile = new StorageFile(new[]
            {
                FileStorageManager.IncomingFolderName,
                AppProfileManager.Instance.AppSubStorageIndependentFolderName,
                "Resources",
                "dock_arrow_floater.png"
            });
            if (await DockFloaterImageFile.Exists(true))
            {
                await DockFloaterImageFile.Download();
            }

            ExpandFormImageFile = new StorageFile(new[]
            {
                FileStorageManager.IncomingFolderName,
                AppProfileManager.Instance.AppSubStorageIndependentFolderName,
                "Resources",
                "undocked_expand.png"
            });
            if (await ExpandFormImageFile.Exists(true))
            {
                await ExpandFormImageFile.Download();
            }

            CollapseFormImageFile = new StorageFile(new[]
            {
                FileStorageManager.IncomingFolderName,
                AppProfileManager.Instance.AppSubStorageIndependentFolderName,
                "Resources",
                "undocked_collapse.png"
            });
            if (await CollapseFormImageFile.Exists(true))
            {
                await CollapseFormImageFile.Download();
            }

            FloaterLogoFile = new StorageFile(new[]
            {
                FileStorageManager.IncomingFolderName,
                AppProfileManager.Instance.AppSubStorageIndependentFolderName,
                "Resources",
                "collapsed_undocked_logo.png"
            });
            if (await FloaterLogoFile.Exists(true))
            {
                await FloaterLogoFile.Download();
            }

            FloaterCancelImageFile = new StorageFile(new[]
            {
                FileStorageManager.IncomingFolderName,
                AppProfileManager.Instance.AppSubStorageIndependentFolderName,
                "Resources",
                "undockedCancel.png"
            });
            if (await FloaterCancelImageFile.Exists(true))
            {
                await FloaterCancelImageFile.Download();
            }

            SharedAssembliesFolder = new ArchiveDirectory(new[]
            {
                FileStorageManager.IncomingFolderName,
                FileStorageManager.CommonIncomingFolderName,
                "SharedAssemblies"
            });
            if (await SharedAssembliesFolder.Exists(true))
            {
                await SharedAssembliesFolder.DownloadTo(SharedAssemblyHelper.SharedAssemblyLocationPath);
            }

            SpecialAppsFolder = new ArchiveDirectory(new[]
            {
                FileStorageManager.IncomingFolderName,
                FileStorageManager.CommonIncomingFolderName,
                "SpecialApps"
            });
            if (await SpecialAppsFolder.Exists(true))
            {
                await SpecialAppsFolder.Download();
            }

            DataFolder = new ArchiveDirectory(new[]
            {
                FileStorageManager.IncomingFolderName,
                AppProfileManager.Instance.AppSubStorageIndependentFolderName,
                "Data",
            });

            SyncFilesFolder = new ArchiveDirectory(new[]
            {
                FileStorageManager.IncomingFolderName,
                AppProfileManager.Instance.AppSubStorageIndependentFolderName,
                "Data",
                "SyncFiles"
            });
            if (await SyncFilesFolder.Exists(true))
            {
                await SyncFilesFolder.Download();
            }

            CloudFilesFolder = new StorageDirectory(new[]
            {
                FileStorageManager.IncomingFolderName,
                FileStorageManager.CommonIncomingFolderName,
                "CloudFiles",
            });
            #endregion

            #region Make local copy
            if (NoSyncConfigFile.ExistsLocal())
            {
                File.Copy(NoSyncConfigFile.LocalPath, Path.Combine(AppRootFolderPath, Path.GetFileName(NoSyncConfigFile.LocalPath)), true);
            }
            if (UpdaterConfigFile.ExistsLocal())
            {
                File.Copy(UpdaterConfigFile.LocalPath, Path.Combine(AppRootFolderPath, Path.GetFileName(UpdaterConfigFile.LocalPath)), true);
            }
            if (SyncFormColorConfigFile.ExistsLocal())
            {
                File.Copy(SyncFormColorConfigFile.LocalPath, Path.Combine(AppRootFolderPath, Path.GetFileName(SyncFormColorConfigFile.LocalPath)), true);
            }
            if (IconFile.ExistsLocal())
            {
                File.Copy(IconFile.LocalPath, Path.Combine(AppRootFolderPath, Path.GetFileName(IconFile.LocalPath)), true);
            }
            if (LoginLogoFile.ExistsLocal())
            {
                File.Copy(LoginLogoFile.LocalPath, Path.Combine(AppRootFolderPath, Path.GetFileName(LoginLogoFile.LocalPath)), true);
            }
            if (SyncFormCloseImageFile.ExistsLocal())
            {
                File.Copy(SyncFormCloseImageFile.LocalPath, Path.Combine(AppRootFolderPath, Path.GetFileName(SyncFormCloseImageFile.LocalPath)), true);
            }
            #endregion
        }