public CodeGuardResultReader(
			MsSqlAuditorModel              msSqlAuditor,
			StorageManager                 storageManager,
			ConcreteTemplateNodeDefinition concreteTemplateNode) :
			base(msSqlAuditor, storageManager, concreteTemplateNode)
		{
		}
		public MultiQueryResultReader(
			MsSqlAuditorModel msSqlAuditor,
			StorageManager    storageManager
		) : this()
		{
			this._msSqlAuditor   = msSqlAuditor;
			this._storageManager = storageManager;
		}
		protected NodeResultReader()
		{
			this._msSqlAuditor   = null;
			this._storageManager = null;

			this.GroupDefinition = null;
			this.TemplateNode    = null;
			this.Settings        = null;
		}
		public ReadonlyStorageManager(
			MsSqlAuditorModel model,
			string            currentDbFile,
			string            historicDbFile,
			string            reportDbFile
		)
		{
			this._storageManager = new StorageManager(
				model,
				false,
				currentDbFile,
				historicDbFile,
				reportDbFile
			);
		}
		protected NodeResultReader(
			MsSqlAuditorModel              msSqlAuditor,
			StorageManager                 storageManager,
			ConcreteTemplateNodeDefinition concreteTemplateNode
		) : this()
		{
			this._msSqlAuditor   = msSqlAuditor;
			this._storageManager = storageManager;

			if (concreteTemplateNode != null)
			{
				this.GroupDefinition = concreteTemplateNode.Group;
				this.TemplateNode    = concreteTemplateNode.TemplateNode;

				if (msSqlAuditor != null && msSqlAuditor.TemplateSettings != null && concreteTemplateNode.Connection != null)
				{
					this.Settings = msSqlAuditor.TemplateSettings.UserSettings.FirstOrDefault(
						i => i.TemplateName == concreteTemplateNode.Connection.TemplateFileName
							&& i.Connection.ParentKey == TemplateNode.IdsHierarchy
					);
				}
			}
		}
		public MetaResultReader(
			MsSqlAuditorModel              msSqlAuditor,
			StorageManager                 storageManager,
			ConnectionGroupInfo            connectionGroup,
			ConcreteTemplateNodeDefinition concreteTemplateNode
		) : base(
				msSqlAuditor,
				storageManager,
				concreteTemplateNode
			)
		{
			this._instances = new List<InstanceInfo>();

			if (base.GroupDefinition.Instance != null)
			{
				this._instances.Add(base.GroupDefinition.Instance);
			}
			else
			{
				this._instances.AddRange(connectionGroup.Connections.Where(info => info.IsEnabled));
			}

			this._histTable = ReadHistTable(connectionGroup, concreteTemplateNode);
		}
        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
                                );
                        }
                    }
                }
            }
        }
 public MultiQueryResultReader()
 {
     this._msSqlAuditor   = null;
     this._storageManager = null;
 }
		public MultiQueryResultReader()
		{
			this._msSqlAuditor   = null;
			this._storageManager = null;
		}
		public void Initialize()
		{
			StorageManager manager = new StorageManager(this, this._filesProvider, true);

			manager.InitializeDataBases();

			this._storageManager = manager;
			this._dbFs = new DbFS(this._filesProvider.GetDbFsFileName());
		}
		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
							);
						}
					}
				}
			}
		}