public void SaveData( string outputFolder, bool saveCurrentDb, bool saveHistoricDb, ISerializationCancellationToken canceller ) { string currentDb = this.GetCurrentDbPath(outputFolder); string historicDb = this.GetHistoricDbPath(outputFolder); string reportDb = this.GetReportDbPath(outputFolder); if (File.Exists(currentDb)) { File.Delete(currentDb); } foreach (PostBuildSqliteDb postBuildDb in this._model.Settings.SystemSettings.PostBuildSQLiteDbs) { string historicDbFileName = string.Format(historicDb, postBuildDb.FileName); if (File.Exists(historicDbFileName)) { File.Delete(historicDbFileName); } } if (saveCurrentDb) { if (this._connectionTabControl != null) { this.SaveSrcData(currentDb, reportDb, canceller); } else { CheckCancellation(canceller); this.BackupCurrent(currentDb); CheckCancellation(canceller); this.BackupReport(reportDb); } } CheckCancellation(canceller); if (saveHistoricDb) { foreach (HistoryStorage historyStorage in this._model.DefaultVaultProcessor.HistoryStorage) { string histStorageName = Path.GetFileName(historyStorage.FileName); this.BackupHistoric( historyStorage, string.Format(historicDb, histStorageName) ); } } }
public void SaveData( string outputFolder, bool saveCurrentDb, bool saveHistoricDb, ISerializationCancellationToken canceller ) { string currentDb = this.GetCurrentDbPath(outputFolder); string historicDb = this.GetHistoricDbPath(outputFolder); string reportDb = this.GetReportDbPath(outputFolder); if (File.Exists(currentDb)) { File.Delete(currentDb); } foreach (PostBuildSqliteDb postBuildDb in this._model.Settings.SystemSettings.PostBuildSQLiteDbs) { string historicDbFileName = string.Format(historicDb, postBuildDb.FileName); if (File.Exists(historicDbFileName)) { File.Delete(historicDbFileName); } } if (saveCurrentDb) { if (this._connectionTabControl != null) { this.SaveSrcData(currentDb, reportDb, canceller); } else { CheckCancellation(canceller); this.BackupCurrent(currentDb); CheckCancellation(canceller); this.BackupReport(reportDb); } } CheckCancellation(canceller); if (saveHistoricDb) { foreach (HistoryStorage historyStorage in this._model.DefaultVaultProcessor.HistoryStorage) { string histStorageName = Path.GetFileName(historyStorage.FileName); this.BackupHistoric( historyStorage, string.Format(historicDb, histStorageName) ); } } }
private void CheckCancellation(ISerializationCancellationToken canceller) { if (canceller == null) { throw new ArgumentNullException("canceller"); } if (canceller.CancellationPending) { throw new OperationCanceledException(); } }
private void SaveSrcData( string currentDb, string reportDb, ISerializationCancellationToken canceller ) { ConnectionData connectionData; StorageManager backupStorageManager = new StorageManager( this._model, false, currentDb, null, reportDb); backupStorageManager.InitializeDataBases(); CheckCancellation(canceller); IEnumerable <ConcreteTemplateNodeDefinition> nodes = this._connectionTabControl.GetCurrentTree(out connectionData); if (nodes != null) { IList <ConcreteTemplateNodeDefinition> nodeList = nodes as IList <ConcreteTemplateNodeDefinition> ?? nodes.ToList(); if (nodeList.Any()) { ConnectionGroupInfo sourceConnection = connectionData.ConnectionGroup; ConnectionGroupInfo destConnection = sourceConnection.CopyXmlContent(); destConnection.Identity = backupStorageManager.CurrentStorage.ConnectionGroupDirectory.GetId(destConnection); Dictionary <TemplateNodeInfo, TemplateNodeInfo> clonesDict = new Dictionary <TemplateNodeInfo, TemplateNodeInfo>(); ConnectionData destConnectionData = new ConnectionData(this._model, destConnection); TemplateNodeInfo nodesRoot = nodeList.First().TemplateNode.GetRootPatent(); TemplateNodeInfo clonedNodesRoot = nodesRoot.CloneNotSavedTree(clonesDict, destConnectionData); CheckCancellation(canceller); backupStorageManager.CurrentStorage.NodeInstances.SaveTree(clonedNodesRoot); CheckCancellation(canceller); foreach (ConcreteTemplateNodeDefinition concreteTemplateNode in nodeList) { CheckCancellation(canceller); MultyQueryResultInfo queriesResult = this._model.DefaultVaultProcessor.ReadCurrentResult( sourceConnection, concreteTemplateNode ); CheckCancellation(canceller); TemplateNodeInfo templateNode = concreteTemplateNode.TemplateNode; if (queriesResult != null) { backupStorageManager.SerializeData( clonesDict[templateNode], queriesResult ); } } } } }
private void CheckCancellation(ISerializationCancellationToken canceller) { if (canceller == null) { throw new ArgumentNullException("canceller"); } if (canceller.CancellationPending) { throw new OperationCanceledException(); } }
private void SaveSrcData( string currentDb, string reportDb, ISerializationCancellationToken canceller ) { ConnectionData connectionData; StorageManager backupStorageManager = new StorageManager( this._model, false, currentDb, null, reportDb); backupStorageManager.InitializeDataBases(); CheckCancellation(canceller); IEnumerable<ConcreteTemplateNodeDefinition> nodes = this._connectionTabControl.GetCurrentTree(out connectionData); if (nodes != null) { IList<ConcreteTemplateNodeDefinition> nodeList = nodes as IList<ConcreteTemplateNodeDefinition> ?? nodes.ToList(); if (nodeList.Any()) { ConnectionGroupInfo sourceConnection = connectionData.ConnectionGroup; ConnectionGroupInfo destConnection = sourceConnection.CopyXmlContent(); destConnection.Identity = backupStorageManager.CurrentStorage.ConnectionGroupDirectory.GetId(destConnection); Dictionary<TemplateNodeInfo, TemplateNodeInfo> clonesDict = new Dictionary<TemplateNodeInfo, TemplateNodeInfo>(); ConnectionData destConnectionData = new ConnectionData(this._model, destConnection); TemplateNodeInfo nodesRoot = nodeList.First().TemplateNode.GetRootPatent(); TemplateNodeInfo clonedNodesRoot = nodesRoot.CloneNotSavedTree(clonesDict, destConnectionData); CheckCancellation(canceller); backupStorageManager.CurrentStorage.NodeInstances.SaveTree(clonedNodesRoot); CheckCancellation(canceller); foreach (ConcreteTemplateNodeDefinition concreteTemplateNode in nodeList) { CheckCancellation(canceller); MultyQueryResultInfo queriesResult = this._model.DefaultVaultProcessor.ReadCurrentResult( sourceConnection, concreteTemplateNode ); CheckCancellation(canceller); TemplateNodeInfo templateNode = concreteTemplateNode.TemplateNode; if (queriesResult != null) { backupStorageManager.SerializeData( clonesDict[templateNode], queriesResult ); } } } } }