/// <summary> /// Initializes a new instance of the <see cref="UPCRMDataStore"/> class. /// </summary> /// <param name="baseDirectoryPath"> /// The base directory path. /// </param> /// <param name="fileName"> /// Name of the file. /// </param> /// <param name="recreate"> /// if set to <c>true</c> [recreate]. /// </param> /// <param name="isUpdateCrm"> /// if set to <c>true</c> [is update CRM]. /// </param> /// <param name="configStore"> /// The configuration store. /// </param> public UPCRMDataStore( string baseDirectoryPath, string fileName, bool recreate, bool isUpdateCrm, IConfigurationUnitStore configStore) { this.BaseDirectoryPath = baseDirectoryPath; this.isUpdateCrm = isUpdateCrm; this.databaseFilename = Path.Combine(this.BaseDirectoryPath, fileName); if (recreate) { var platformService = SimpleIoc.Default.GetInstance <IPlatformService>(); if (platformService.StorageProvider.FileExists(this.databaseFilename)) { Exception error = null; platformService.StorageProvider.TryDelete(databaseFilename, out error); if (error != null) { Logger.LogError(error); } } } var db = CRMDatabase.Create(isUpdateCrm, this.databaseFilename); this.DatabaseInstance = db; if (configStore.ConfigValueIsSetDefaultValue("System.DisplayFixCatBySortInfo", true)) { this.DatabaseInstance.FixedCatSortBySortInfoAndCode = true; } if (recreate && !this.UpdateDDL()) { return; } this.AddVirtualLinks(); this.Reps = new UPCRMReps(); this.VirtualInfoAreaCache = new UPVirtualInfoAreaCache(); this.Disable86326 = configStore.ConfigValueIsSet("Disable.86326"); }
/// <summary> /// Builds the page. /// </summary> private void BuildPage() { IConfigurationUnitStore configStore = ConfigurationUnitStore.DefaultStore; UPMDataSyncPage page = new UPMDataSyncPage(null); if (ServerSession.CurrentSession == null) { return; } UPSyncManager syncManager = ServerSession.CurrentSession.SyncManager; page.LastSyncDate = syncManager.LastSyncDate; page.CanStartIncrementalSync = true; this.syncMessage = string.Empty; if (syncManager.FullSyncRunning) { this.syncMessage = LocalizedString.Localize( LocalizationKeys.TextGroupBasic, LocalizationKeys.KeyBasicSyncOrganizerFullSyncRunningMessage); page.CanStartIncrementalSync = false; } else if (syncManager.IncrementalSyncRunning) { this.syncMessage = LocalizedString.Localize( LocalizationKeys.TextGroupBasic, LocalizationKeys.KeyBasicSyncOrganizerIncrementalSyncRunningMessage); page.CanStartIncrementalSync = false; } else if (syncManager.UpSyncRunning) { this.syncMessage = LocalizedString.Localize( LocalizationKeys.TextGroupBasic, LocalizationKeys.KeyBasicSyncOrganizerUpSyncRunningMessage); page.CanStartIncrementalSync = false; } else if (syncManager.MetadataSyncRunning) { this.syncMessage = LocalizedString.Localize( LocalizationKeys.TextGroupBasic, LocalizationKeys.KeyBasicSyncOrganizerConfigurationSyncRunningMessage); page.CanStartIncrementalSync = false; } else if (syncManager.ResourcesSyncRunning) { this.syncMessage = "Resources Sync is running"; page.CanStartIncrementalSync = false; } page.CanPerformConfigurationSync = configStore.ConfigValueIsSetDefaultValue("Sync.ConfigOnOff", true); page.CanPerformLanguageChange = configStore.ConfigValueIsSetDefaultValue("Sync.LanguageOnOff", true); page.FullSyncRequirementStatus = syncManager.FullSyncRequirementStatus; switch (page.FullSyncRequirementStatus) { case FullSyncRequirementStatus.Recommended: DateTime blockOnlineAccessDate = DateExtensions.AddTimeSpanToUtcNow(syncManager.TimeIntervalFromNowUntilOfflineOnline()); page.FullSyncRequirementStatusText = string.Format( LocalizedString.Localize( LocalizationKeys.TextGroupBasic, LocalizationKeys.KeyBasicSyncOrganizerFullSyncRecommendedWarningMessage).ToDotnetStringFormatTemplate(), blockOnlineAccessDate.ToString("d")); break; case FullSyncRequirementStatus.MandatoryForOnlineAccess: DateTime blockAccessDate = DateExtensions.AddTimeSpanToUtcNow(syncManager.TimeIntervalFromNowUntilBlock()); page.FullSyncRequirementStatusText = string.Format( LocalizedString.Localize( LocalizationKeys.TextGroupBasic, LocalizationKeys.KeyBasicSyncOrganizerFullSyncMandatoryForOnlineErrorMessage).ToDotnetStringFormatTemplate(), blockAccessDate.ToString("d")); break; default: page.FullSyncRequirementStatusText = string.Empty; break; } this.TopLevelElement = page; this.BuildSyncMessage(); }