public CodeGuardResultReader(
			MsSqlAuditorModel              msSqlAuditor,
			StorageManager                 storageManager,
			ConcreteTemplateNodeDefinition concreteTemplateNode) :
			base(msSqlAuditor, storageManager, concreteTemplateNode)
		{
		}
Esempio n. 2
0
		private frmSettings()
		{
			this._settingsInfo = null;
			this._model        = null;

			InitializeComponent();
		}
		public InternalSqliteConnectionDialog(MsSqlAuditorModel model)
		{
			this._model              = model;
			this._storage            = model.DefaultVaultProcessor.CurrentStorage;
			this._connectionsManager = new ConnectionsManager(model);
			this._loginManager       = new LoginManager(this._storage);
			this._templateManager    = new TemplateManager(this._storage);
			this._templates          = TemplateNodesLoader.GetTemplates();

			InitializeComponent();

			List<BindingWrapper<ConnectionType>> connectionTypes = this._model.ConnectionTypes;

			this.dataTypeBindingSource.DataSource = connectionTypes;
			this.dataTypeBindingSource.DataMember = "Item";
			this.cmbDataType.DataSource           = dataTypeBindingSource.DataSource;

			this.cmbDataType.SelectionChangeCommitted += this.cmbDataType_SelectedIndexChanged;

			this.cmbConnectionGroup.SelectionChangeCommitted += this.cmbConnectionGroup_SelectedIndexChanged;
			this.cmbServerInstance.SelectionChangeCommitted  += this.cmbServerInstance_SelectedIndexChanged;
			this.cmbTemplate.SelectionChangeCommitted        += this.cmbTemplate_SelectedIndexChanged;
			this.cmbLogin.SelectionChangeCommitted           += this.cmbLogin_SelectedIndexChanged;

			if (connectionTypes.Count > 0)
			{
				UpdateConnectionGroupList();
			}

			UpdateButtonsState();
		}
Esempio n. 4
0
		/// <summary>
		/// Default constructor
		/// </summary>
		/// <param name="model">Model</param>
		public frmSettings(MsSqlAuditorModel model) : this()
		{
			this._model = model;

			cmbInterfaceLang.Items.AddRange(_model.Settings.SystemSettings.AvailableUiLanguages.ToArray());
			cmbReportLang.Items.AddRange(_model.Settings.SystemSettings.AvailableReportLanguages.ToArray());
		}
		public ConnectionsManager(MsSqlAuditorModel model)
		{
			CurrentStorage storage = model.DefaultVaultProcessor.CurrentStorage;

			this._groupManager    = new ConnectionGroupManager(storage);
			this._instanceManager = new ServerInstanceManager(storage);
			this._loginManager    = new LoginManager(storage);
		}
		public MultiQueryResultReader(
			MsSqlAuditorModel msSqlAuditor,
			StorageManager    storageManager
		) : this()
		{
			this._msSqlAuditor   = msSqlAuditor;
			this._storageManager = storageManager;
		}
		public RunningTaskInfoForm()
		{
			this._model       = null;
			this._mainText    = null;
			this._errorText   = null;
			this._isLoaded    = false;
			this._isNeedClose = false;
		}
		public QueryResultDataSource(
			MsSqlAuditorModel              model,
			ConcreteTemplateNodeDefinition nodeDefinition
		)
		{
			this._model          = model;
			this._nodeDefinition = nodeDefinition;
			this._queriesResult  = ReadQueriesResult();
		}
		protected NodeResultReader()
		{
			this._msSqlAuditor   = null;
			this._storageManager = null;

			this.GroupDefinition = null;
			this.TemplateNode    = null;
			this.Settings        = null;
		}
		private frmUserSettingsNode()
		{
			this._model               = null;
			this._node                = null;
			this._nodeDefinition      = null;
			this._template            = null;
			this._userSettingsManager = null;

			InitializeComponent();
		}
		public RunningTaskInfoForm(TreeTaskProgressManager progressManager, MsSqlAuditorModel model) : this()
		{
			this._model = model;

			ProgressManager = progressManager;
			InitializeComponent();

			progressManager.Changed += ProgressManagerOnChanged;
			progressManager.EverythingIsDone += ProgressManagerOnEverythingIsDone;
		}
		public CreateDirectConnectionDialog(MsSqlAuditorModel model)
		{
			this._model              = model;
			this._storage            = this._model.DefaultVaultProcessor.CurrentStorage;
			this._connectionsManager = new ConnectionsManager(model);

			SetLocale();

			InitializeComponent();
			InitializeEventHandlers();
			InitializeBindings();
		}
Esempio n. 13
0
        /// <summary>
        /// Init node after load
        /// </summary>
        /// <param name="templateId"></param>
        /// <param name="model">Model</param>
        public void Init(string templateId, MsSqlAuditorModel model)
        {
            this._model      = model;
            this._templateId = templateId;

            foreach (var child in Childs)
            {
                child.Parent = this;
                child.Owner  = this;
                child.Init(templateId, model);
            }
        }
		public NodeDataProvider(
			MsSqlAuditorModel              model,
			ConcreteTemplateNodeDefinition nodeDefinition
		)
		{
			this._nodeDefinition = nodeDefinition;
			this._dataSource     = new QueryResultDataSource(model, nodeDefinition);

			IQueryResultXmlTransformer transformer = new QueryResultXmlTransformer();

			XmlDocument = transformer.Transform(this._dataSource);
		}
		public static IConnectionStringDialog CreateDialog(QuerySource querySource, MsSqlAuditorModel model)
		{
			switch (querySource)
			{
				case QuerySource.MSSQL:
					return new CommonConnectionStringDialog();
				case QuerySource.SQLite:
					return new InternalSqliteConnectionDialog(model);
				case QuerySource.NetworkInformation:
					return new NetworkInformationConnectionDialog();
				default:
					return new NonSqlDataConnectionDialog();
			}
		}
		public StorageSerializationInfo(
			MsSqlAuditorModel    model,
			ConnectionTabControl tabControl,
			string               outputPath,
			bool                 saveCurrentDatabase,
			bool                 saveHistoricDatabase
		)
		{
			this.Model                = model;
			this.TabControl           = tabControl;
			this.OutputFolder         = outputPath;
			this.SaveCurrentDatabase  = saveCurrentDatabase;
			this.SaveHistoricDatabase = saveHistoricDatabase;
		}
Esempio n. 17
0
 /// <summary>
 /// Default constructor
 /// </summary>
 public FilesProvider()
 {
     this._model = null;
     this._tempDocsFolderCache            = new Dictionary <string, string>();
     this.StartUpFolder                   = Application.StartupPath;
     this.SystemSettingsFileName          = null;
     this.UserSettingDefaultFileName      = null;
     this.LocaleFileName                  = null;
     this.UserDocsAppFolder               = null;
     this.UserDocsAppFolderLastOnly       = null;
     this._ConnectionFileNameFormatString = "MSSQLServerAuditor.Connections.{0}.xml";
     this.ConnectionsFileNamePattern      = string.Format(this._ConnectionFileNameFormatString, "*");
     this._OfflineDataTempFolder          = "Offline";
 }
Esempio n. 18
0
		/// <summary>
		/// Default constructor
		/// </summary>
		public FilesProvider()
		{
			this._model                          = null;
			this._tempDocsFolderCache            = new Dictionary<string, string>();
			this.StartUpFolder                   = Application.StartupPath;
			this.SystemSettingsFileName          = null;
			this.UserSettingDefaultFileName      = null;
			this.LocaleFileName                  = null;
			this.UserDocsAppFolder               = null;
			this.UserDocsAppFolderLastOnly       = null;
			this._ConnectionFileNameFormatString = "MSSQLServerAuditor.Connections.{0}.xml";
			this.ConnectionsFileNamePattern      = string.Format(this._ConnectionFileNameFormatString, "*");
			this._OfflineDataTempFolder          = "Offline";
		}
		public ReadonlyStorageManager(
			MsSqlAuditorModel model,
			string            currentDbFile,
			string            historicDbFile,
			string            reportDbFile
		)
		{
			this._storageManager = new StorageManager(
				model,
				false,
				currentDbFile,
				historicDbFile,
				reportDbFile
			);
		}
Esempio n. 20
0
		/// <summary>
		/// Constructor with parameters
		/// </summary>
		/// <param name="model">Model</param>
		/// <param name="cancellationToken">Cancellation token</param>
		public SqlProcessor(
			MsSqlAuditorModel model,
			CancellationToken cancellationToken
		) : this()
		{
			this._model             = model;
			this._cancellationToken = cancellationToken;

#if (PROXY_CONNECTION)
			this._queryConnectionFactory =
				new CachingQueryConnectionFactory(
					new QueryConnectionFactory(this._model)
			);
#else
			this._queryConnectionFactory = new QueryConnectionFactory(this._model);
#endif
		}
Esempio n. 21
0
        public bool?IsAvailableForDatabase(MsSqlAuditorModel sqlAuditor)
        {
            if (TemplateNode.ConnectionQueries.Count > 0)
            {
                return(true);
            }

            CurrentStorage storage = sqlAuditor.GetVaultProcessor(Connection).CurrentStorage;
            int            timeout = sqlAuditor.Settings.SqlTimeout;

            List <InstanceVersion> versions =
                Connection.Connections.Select(cnn =>
            {
                try
                {
                    return(cnn.InitServerProperties(storage, timeout).Version);
                }
                catch (Exception ex)
                {
                    log.Error("Error in get version.", ex);

                    return(new InstanceVersion());
                }
            }
                                              ).ToList();

            List <QuerySource> queriesTypes = Connection.Connections.Select(x => x.Type).ToList();

            if (TemplateNode.Queries.Count == 0)
            {
                return(true);
            }

            return(TemplateNode.Queries.Any(x =>
            {
                List <QueryInfo> queries =
                    sqlAuditor.GetQueryByTemplateNodeQueryInfo(x)
                    .Where(y => queriesTypes.Contains(y.Source) || y.Source == QuerySource.SQLite)
                    .ToList();

                return versions.Distinct().Any(
                    version => queries.Any(
                        queryInfo => queryInfo.Items.GetQueryItemForVersion(version) != null));
            }));
        }
Esempio n. 22
0
 /// <summary>
 /// Template node information.
 /// </summary>
 public TemplateNodeInfo()
 {
     this._templateId                   = null;
     this._locales                      = null;
     this._childs                       = null;
     this._queries                      = null;
     this._groupQueries                 = null;
     this._connectionQueries            = null;
     this._sqlCodeGuardQueries          = null;
     this._idsHierarchyCache            = null;
     this._templateNodeId               = null;
     this._defaultDatabaseAttributeName = null;
     this._mainFormWindowTitle          = null;
     this._treeTitle                    = null;
     this._model = null;
     this.ShowNumberOfRecords      = true;
     this.HideEmptyResultDatabases = false;
 }
		/// <summary>
		/// Template node information.
		/// </summary>
		public TemplateNodeInfo()
		{
			this._templateId                   = null;
			this._locales                      = null;
			this._childs                       = null;
			this._queries                      = null;
			this._groupQueries                 = null;
			this._connectionQueries            = null;
			this._sqlCodeGuardQueries          = null;
			this._idsHierarchyCache            = null;
			this._templateNodeId               = null;
			this._defaultDatabaseAttributeName = null;
			this._mainFormWindowTitle          = null;
			this._treeTitle                    = null;
			this._model                        = null;
			this.ShowNumberOfRecords           = true;
			this.HideEmptyResultDatabases      = false;
		}
Esempio n. 24
0
		public frmAboutBox(MsSqlAuditorModel model)
		{
			this._model = model;

			InitializeComponent();

			Text = string.Format(GetLocalizedText("captionText"), CurrentAssembly.ProcessName);

			tbProductName.Text       = CurrentAssembly.Product;
			tbRelease.Text           = AppVersionHelper.CurrentAppVersionType.ToString();
			tbVersion.Text           = CurrentAssembly.Version;
			tbCopyright.Text         = CurrentAssembly.Copyright;
			tbCompanyName.Text       = CurrentAssembly.Company;
			tbEmail.Text             = Program.Model.Settings.SystemSettings.SupportEmail;
			tbURL.Text               = Program.Model.Settings.SystemSettings.SupportUrl;
			tbSQLiteFolder.Text      = this.SQLiteFolder;
			tbUserDocsAppFolder.Text = this.UserDocsAppFolder;
			tbProcessId.Text         = Process.GetCurrentProcess().Id.ToString();
		}
        /// <summary>
        /// Constructor
        /// </summary>
        /// <param name="model">MSSQLAuditor model</param>
        public WebServerManager(MsSqlAuditorModel model)
        {
            int    tryCount         = 10;
            bool   webServerStarted = false;
            Random rnd              = new Random();

            this._model    = model;
            _webServerPort = Consts.DefaultWebServerPort;

            for (int i = 0; i < tryCount; i++)
            {
                try
                {
                    this._frontend = new WebServerFrontend(_webServerPort, ProcessRequest);

                    log.InfoFormat("Web-server started at port:'{0}'",
                        _webServerPort
                    );

                    webServerStarted = true;

                    break;
                }
                catch (Exception ex)
                {
                    log.ErrorFormat("Unable to start web-server at port:'{0}'.Error:'{1}'",
                        _webServerPort,
                        ex
                    );
                }

                _webServerPort = 10000 + rnd.Next(50000);
            }

            if (!webServerStarted)
            {
                log.ErrorFormat(
                    "Unable to start web-server for '{0}' times",
                    tryCount
                );
            }
        }
		public EditDirectConnectionDialog(
			MsSqlAuditorModel   model,
			ConnectionGroupInfo connectionGroup
		)
		{
			this._model = model;

			CurrentStorage storage   = this._model.DefaultVaultProcessor.CurrentStorage;
			this._connectionsManager = new ConnectionsManager(model);

			this._connectionGroup = connectionGroup;
			this._updatesMade     = false;

			SetLocale();

			InitializeComponent();
			InitializeEventHandlers();
			InitializeBindings();

			UpdateControlsState();
		}
		public frmUserSettingsNode(MsSqlAuditorModel model, TreeNode node) : this()
		{
			if (node == null)
			{
				throw new ArgumentNullException("node");
			}

			this._node           = node;
			this._nodeDefinition = node.Tag as ConcreteTemplateNodeDefinition;

			if (this._nodeDefinition == null)
			{
				throw new ArgumentException("Template is not specified for the node.");
			}

			this._model               = model;
			this._template            = GetUserSettings();
			this._userSettingsManager = new UserSettingsManager(
				this._model.Settings.InterfaceLanguage
			);
		}
		/// <summary>
		/// Constructor
		/// </summary>
		/// <param name="model">Using model</param>
		/// <param name="connectionsAsNodes">All connection (even single one) will be represented
		/// as top level node of tree navigation view</param>
		public ConnectionTabControl(
			MsSqlAuditorModel model,
			bool              isDisableStatusLine,
			bool              isDisableNavigationPanel,
			bool              connectionsAsNodes = true
		) : this()
		{
			this._model                 = model;
			this._model.SettingsChanged += ModelSettingsChanged;

			this._jobProcessor    = new ScheduleJobProcessor(
				this._model.DefaultVaultProcessor.CurrentStorage
			);

			this.ConnectionsAsNodes = connectionsAsNodes;

			treeTemplate.DrawMode = TreeViewDrawMode.OwnerDrawText;

			this._isDisableNavigationPanel = isDisableNavigationPanel;

			SetSettings(isDisableStatusLine);
		}
		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
					);
				}
			}
		}
		private ConnectionTabControl()
		{
			this._connections                  = new List<ConnectionData>();
			this._model                        = null;
			this._isDisableNavigationPanel     = false;
			this._template                     = null;
			this._runningProcessFormClosedTime = DateTime.MinValue;
			this._runningTaskInfoForm          = null;
			this._reportViewCanceler           = null;
			this._jobProcessor                 = null;
			this._allEmailTask                 = new List<EmailNotificationTask>();
			this._pageBuffer                   = new TabPageBuffer();

			InitializeComponent();
			BuildImageList();

			txtXml.Padding = new Padding(0);

			if (!Program.Model.Settings.ShowXML)
			{
				tcBrowse.TabPages.Remove(tpXml);
			}
		}
		protected void RunSelectConnectionDialog(MsSqlAuditorModel model)
		{
			BindingWrapper<ConnectionType> connectionWrapper = cmbDataBaseType.SelectedItem as BindingWrapper<ConnectionType>;

			if (connectionWrapper != null)
			{
				ConnectionType connectionType = connectionWrapper.Item;
				QuerySource    querySource;

				if (!Enum.TryParse(connectionType.Id, true, out querySource))
				{
					return;
				}

				IConnectionStringDialog dialog = ConnectionStringDialogFactory.CreateDialog(
					querySource,
					model
				);

				if (dialog.ShowDialog() == DialogResult.OK)
				{
					DbConnectionStringBuilder builder = GetConnectionStringBuilder(
						querySource,
						dialog.ConnectionString,
						dialog.IsOdbc
					);

					InstanceInfo newInstance = InstanceInfoResolver.ResolveInstance(
						builder,
						dialog.IsOdbc,
						querySource
					);

					SelectInstance(newInstance);
				}
			}
		}
		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);
		}
		/// <summary>
		/// Default constructor
		/// </summary>
		/// <param name="model">Used model</param>
		public VisualizeProcessor(MsSqlAuditorModel model)
		{
			this._model = model;
		}
Esempio n. 34
0
        /// <summary>
        /// Constructor with model
        /// </summary>
        /// <param name="model">Model</param>
        public FilesProvider(MsSqlAuditorModel model) : this()
        {
            this._model = model;

            if (this._model != null)
            {
                this.SystemSettingsFileName = Path.Combine(
                    this.StartUpFolder,
                    CurrentAssembly.ProcessNameBase + ".SystemSettings.xml"
                    );

                this.UserSettingDefaultFileName = Path.Combine(
                    this.StartUpFolder,
                    CurrentAssembly.ProcessNameBase + ".UserSettings.xml"
                    );

                this.LocaleFileName = Path.Combine(
                    this.StartUpFolder,
                    CurrentAssembly.ProcessNameBase + ".i18n.xml"
                    );
            }

            var systemSetting = SettingsLoader.GetSystemSetting(this.SystemSettingsFileName);

            if (systemSetting != null && !string.IsNullOrEmpty(systemSetting.UserDocsAppFolder))
            {
                this.UserDocsAppFolder = Path.Combine(
                    Environment.GetFolderPath(Environment.SpecialFolder.Personal),
                    systemSetting.UserDocsAppFolder
                    );

                this.UserDocsAppFolderLastOnly = systemSetting.UserDocsAppFolder;
            }
            else
            {
                if (this._model != null)
                {
                    this.UserDocsAppFolder = Path.Combine(
                        Environment.GetFolderPath(Environment.SpecialFolder.Personal),
                        CurrentAssembly.ProcessNameBase
                        );

                    this.UserDocsAppFolderLastOnly = CurrentAssembly.ProcessNameBase;
                }
            }

            if (this.UserDocsAppFolder != null)
            {
                if (!Directory.Exists(this.UserDocsAppFolder))
                {
                    Directory.CreateDirectory(this.UserDocsAppFolder);
                }
            }

            var fileSystemWatcher = new FileSystemWatcher(this.StartUpFolder)
            {
                IncludeSubdirectories = true,
                EnableRaisingEvents   = true
            };

            fileSystemWatcher.Changed += FileSystemWatcherChanged;
            fileSystemWatcher.Created += FileSystemWatcherChanged;
            fileSystemWatcher.Deleted += FileSystemWatcherChanged;
            fileSystemWatcher.Renamed += FileSystemWatcherChanged;

            var fileUserWatcher = new FileSystemWatcher(this.UserDocsAppFolder)
            {
                IncludeSubdirectories = false,
                EnableRaisingEvents   = true
            };

            fileUserWatcher.Changed += FileUserWatcherChanged;
            fileUserWatcher.Created += FileUserWatcherChanged;
            fileUserWatcher.Deleted += FileUserWatcherChanged;
            fileUserWatcher.Renamed += FileUserWatcherChanged;

            var tempDocsWatcher = new FileSystemWatcher(GetTempDocsFolder())
            {
                IncludeSubdirectories = true,
                EnableRaisingEvents   = true
            };

            tempDocsWatcher.Changed += FileUserWatcherChanged;
            tempDocsWatcher.Created += FileUserWatcherChanged;
            tempDocsWatcher.Deleted += FileUserWatcherChanged;
            tempDocsWatcher.Renamed += FileUserWatcherChanged;
        }
Esempio n. 35
0
 public GetFileCommand(MsSqlAuditorModel model)
     : base(model)
 {
 }