Пример #1
0
        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();
        }
Пример #2
0
 public CodeGuardResultReader(
     MsSqlAuditorModel msSqlAuditor,
     StorageManager storageManager,
     ConcreteTemplateNodeDefinition concreteTemplateNode) :
     base(msSqlAuditor, storageManager, concreteTemplateNode)
 {
 }
        /// <summary>
        /// Initialize wrapper
        /// </summary>
        public static void Initialize()
        {
            _model = new MsSqlAuditorModel();
            _model.Initialize();

            _storage = _model.DefaultVaultProcessor.CurrentStorage;

            _serviceDataUpdateTimeout = _model.Settings.SystemSettings.ServiceDataUpdateTimeout;
            _serviceRunJobsTimeout    = _model.Settings.SystemSettings.ServiceRunJobsTimeout;
            _serviceStarted           = DateTime.Now;

            _scheduleJobProcessor    = new ScheduleJobProcessor(_storage);
            _connectionsManager      = new ConnectionsManager(_model);
            _scheduleSettingsManager = new ScheduleSettingsManager(_storage);

            _runningTasks          = new ConcurrentDictionary <string, string>();
            _databaseNodeInstances = new ConcurrentDictionary <long, NodeInstanceRow>();
            _serviceNodeInstances  = new ConcurrentDictionary <long, NodeInstanceRow>();

            _serviceSchedules  = new ConcurrentDictionary <long, ScheduleSettingsRow>();
            _databaseSchedules = new ConcurrentDictionary <long, ScheduleSettingsRow>();
            _connectionGroups  = new List <ConnectionGroupInfo>();

            LoadFromDB(true);
            log.DebugFormat(
                @"Active scheduled Instances:'{0}'  Active schedules: '{1}'",
                _serviceNodeInstances.Count,
                _serviceSchedules.Count
                );
        }
Пример #4
0
        private frmSettings()
        {
            this._settingsInfo = null;
            this._model        = null;

            InitializeComponent();
        }
Пример #5
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);
        }
Пример #7
0
 public RunningTaskInfoForm()
 {
     this._model       = null;
     this._mainText    = null;
     this._errorText   = null;
     this._isLoaded    = false;
     this._isNeedClose = false;
 }
 public MultiQueryResultReader(
     MsSqlAuditorModel msSqlAuditor,
     StorageManager storageManager
     ) : this()
 {
     this._msSqlAuditor   = msSqlAuditor;
     this._storageManager = storageManager;
 }
Пример #9
0
        protected NodeResultReader()
        {
            this._msSqlAuditor   = null;
            this._storageManager = null;

            this.GroupDefinition = null;
            this.TemplateNode    = null;
            this.Settings        = null;
        }
 public QueryResultDataSource(
     MsSqlAuditorModel model,
     ConcreteTemplateNodeDefinition nodeDefinition
     )
 {
     this._model          = model;
     this._nodeDefinition = nodeDefinition;
     this._queriesResult  = ReadQueriesResult();
 }
Пример #11
0
        private frmUserSettingsNode()
        {
            this._model               = null;
            this._node                = null;
            this._nodeDefinition      = null;
            this._template            = null;
            this._userSettingsManager = null;

            InitializeComponent();
        }
Пример #12
0
        public RunningTaskInfoForm(TreeTaskProgressManager progressManager, MsSqlAuditorModel model) : this()
        {
            this._model = model;

            ProgressManager = progressManager;
            InitializeComponent();

            progressManager.Changed          += ProgressManagerOnChanged;
            progressManager.EverythingIsDone += ProgressManagerOnEverythingIsDone;
        }
Пример #13
0
        /// <summary>
        /// Load template from Xml-file
        /// </summary>
        /// <param name="model">Model mssql auditor.</param>
        /// <param name="document">XML document.</param>
        /// <param name="connectionGroup"></param>
        /// <returns>List of templates</returns>
        public static TemplateNodeInfo LoadFromXml(MsSqlAuditorModel model, XmlDocument document, out string startupTemplateId, out Stack <string> startupTemplateInfoIdStack)
        {
            var    serializer = new XmlSerializer(typeof(Template));
            var    root       = new TemplateNodeInfo();
            string templateId = null;

            //
            // #248 - fix memory leaks during XML files processing
            //
            // var nodeReader = new XmlNodeReader(document);
            root.Locales = new List <TemplateNodeLocaleInfo>();

            using (var nodeReader = new XmlNodeReader(document))
            {
                using (var xmlReader = XmlReader.Create(nodeReader, XmlUtils.GetXmlReaderSettings()))
                {
                    var wrapper = (Template)serializer.Deserialize(xmlReader);

                    root.MainFormWindowTitle = wrapper.MainFormWindowTitle;
                    root.TreeTitle           = wrapper.TreeTitle;
                    root.Childs       = wrapper.Infos;
                    templateId        = wrapper.Id;
                    startupTemplateId = wrapper.StartupTemplateId;

                    foreach (var localeInfo in wrapper.Locales)
                    {
                        root.Locales.Add(new TemplateNodeLocaleInfo()
                        {
                            Language     = localeInfo.Language,
                            Text         = localeInfo.Text,
                            TemplateFile = localeInfo.TemplateFile
                        });
                    }

                    root.TemplateId          = templateId;
                    root.Queries             = new List <TemplateNodeQueryInfo>();
                    root.GroupQueries        = wrapper.GroupQueries ?? new List <TemplateNodeQueryInfo>();
                    root.ConnectionQueries   = new List <TemplateNodeQueryInfo>();
                    root.SqlCodeGuardQueries = new List <TemplateNodeSqlGuardQueryInfo>();

                    startupTemplateInfoIdStack = new Stack <string>();

                    if (!String.IsNullOrEmpty(startupTemplateId))
                    {
                        SetupStartupTemplateNodeIdStack(wrapper.Infos, startupTemplateInfoIdStack, startupTemplateId);
                    }
                }
            }

            NormalizeTemplateNode(root);
            root.Init(templateId, model);

            return(root);
        }
		/// <summary>
		/// Load template from Xml-file
		/// </summary>
		/// <param name="model">Model mssql auditor.</param>
		/// <param name="document">XML document.</param>
		/// <param name="connectionGroup"></param>
		/// <returns>List of templates</returns>
		public static TemplateNodeInfo LoadFromXml(MsSqlAuditorModel model, XmlDocument document, out string startupTemplateId, out Stack<string> startupTemplateInfoIdStack)
		{
			var    serializer = new XmlSerializer(typeof(Template));
			var    root       = new TemplateNodeInfo();
			string templateId = null;

			//
			// #248 - fix memory leaks during XML files processing
			//
			// var nodeReader = new XmlNodeReader(document);
			root.Locales = new List<TemplateNodeLocaleInfo>();

			using (var nodeReader = new XmlNodeReader(document))
			{
				using (var xmlReader = XmlReader.Create(nodeReader, XmlUtils.GetXmlReaderSettings()))
				{
					var wrapper = (Template)serializer.Deserialize(xmlReader);

					root.MainFormWindowTitle = wrapper.MainFormWindowTitle;
					root.TreeTitle           = wrapper.TreeTitle;
					root.Childs              = wrapper.Infos;
					templateId               = wrapper.Id;
					startupTemplateId        = wrapper.StartupTemplateId;

					foreach (var localeInfo in wrapper.Locales)
					{
						root.Locales.Add(new TemplateNodeLocaleInfo()
						{
							Language     = localeInfo.Language,
							Text         = localeInfo.Text,
							TemplateFile = localeInfo.TemplateFile
						});
					}

					root.TemplateId          = templateId;
					root.Queries             = new List<TemplateNodeQueryInfo>();
					root.GroupQueries        = wrapper.GroupQueries ?? new List<TemplateNodeQueryInfo>();
					root.ConnectionQueries   = new List<TemplateNodeQueryInfo>();
					root.SqlCodeGuardQueries = new List<TemplateNodeSqlGuardQueryInfo>();

					startupTemplateInfoIdStack = new Stack<string>();

					if (!String.IsNullOrEmpty(startupTemplateId))
					{
						SetupStartupTemplateNodeIdStack(wrapper.Infos, startupTemplateInfoIdStack, startupTemplateId);
					}
				}
			}

			NormalizeTemplateNode(root);
			root.Init(templateId, model);

			return root;
		}
        public CreateDirectConnectionDialog(MsSqlAuditorModel model)
        {
            this._model              = model;
            this._storage            = this._model.DefaultVaultProcessor.CurrentStorage;
            this._connectionsManager = new ConnectionsManager(model);

            SetLocale();

            InitializeComponent();
            InitializeEventHandlers();
            InitializeBindings();
        }
        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 StorageManager(
     MsSqlAuditorModel model,
     FilesProvider filesProvider,
     bool updateHistory
     ) : this(
         model,
         updateHistory,
         filesProvider.GetCurrentDbFileName(),
         filesProvider.GetHistoricDbFileName(),
         filesProvider.GetReportDbFileName()
         )
 {
 }
 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;
 }
 public ReadonlyStorageManager(
     MsSqlAuditorModel model,
     string currentDbFile,
     string historicDbFile,
     string reportDbFile
     )
 {
     this._storageManager = new StorageManager(
         model,
         false,
         currentDbFile,
         historicDbFile,
         reportDbFile
         );
 }
Пример #20
0
        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());
            }
        }
Пример #21
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
                    );
            }
        }
        internal static IStorageManager GetReadonlyVaultProcessor(MsSqlAuditorModel model, string inMsd, string inMsh, string inMsr)
        {
            if (inMsd == null)
            {
                return(new StorageManager(
                           model,
                           true,
                           model.FilesProvider.GetTempCurrentDbFileName(),
                           inMsh,
                           inMsr
                           ));
            }

            return(new ReadonlyStorageManager(
                       model,
                       inMsd,
                       inMsh,
                       inMsr
                       ));
        }
Пример #24
0
        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
                );
        }
        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();
        }
Пример #26
0
        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
                        );
                }
            }
        }
Пример #27
0
        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);
                }
            }
        }
Пример #28
0
        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);
        }
		public QueryConnectionFactory(MsSqlAuditorModel model)
		{
			this._model = model;
		}
 /// <summary>
 /// Initializes the object ConnectionData.
 /// </summary>
 /// <param name="model">Model SqlAuditor.</param>
 /// <param name="connectionGroup">Info group connection.</param>
 public ConnectionData(MsSqlAuditorModel model, ConnectionGroupInfo connectionGroup)
     : this(model)
 {
     ConnectionGroup = connectionGroup;
     ReloadTemplate();
 }
 private ConnectionData(MsSqlAuditorModel model)
 {
     this.CreationDateTime = DateTime.Now;
     this._model           = model;
 }
		/// <summary>
		/// Check template database type.
		/// </summary>
		/// <param name="model">Model mssql auditor.</param>
		/// <param name="template">Template.</param>
		/// <param name="selectedSource">Selected db source.</param>
		/// <returns>If template available.</returns>
		public static bool CheckFromXml(MsSqlAuditorModel model, Template template, QuerySource selectedSource)
		{
			return template.DBType == selectedSource;
		}
 public StorageSerializer(MsSqlAuditorModel model, ConnectionTabControl connectionTabControl)
 {
     this._model = model;
     this._connectionTabControl = connectionTabControl;
     this._dateSuffix           = DateTime.Now.ToString("s").Replace(":", "-");
 }