Example #1
0
    private void TraceRecordingForm_FormClosing(object sender, FormClosingEventArgs e)
    {
        if (_checkingAccessRights)
        {
            e.Cancel = true;
            return;
        }

        if (_traceRunning)
        {
            string text = "Recording in progress.\r\n\r\nAbort operation?";

            if (ConfigHandler.UseTranslation)
            {
                text = Translator.GetText("abortRecording");
            }

            DialogResult result = OutputHandler.Show(text, GenericHelper.ApplicationName, MessageBoxButtons.YesNo, MessageBoxIcon.Information);

            if (result.ToString() == "Yes")
            {
                _databaseOperation.StopDeleteTrace();
                TraceFileHandler.DeleteTraceFile(true, _databaseOperation);
            }
            else
            {
                e.Cancel = true;
            }
        }
    }
Example #2
0
    private void TraceRecordingForm_FormClosing(object sender, FormClosingEventArgs e)
    {
        if (_checkingAccessRights)
        {
            e.Cancel = true;
            return;
        }

        if (_traceRunning)
        {
            DialogResult result = MessageBox.Show("Recording in progress.\r\n\r\nAbort operation?", GenericHelper.ApplicationName, MessageBoxButtons.YesNo, MessageBoxIcon.Information);

            if (result.ToString() == "Yes")
            {
                _databaseOperation.StopDeleteTrace();
                _anythingRecorded = false;

                TraceFileHandler.DeleteTraceFile(true, _databaseOperation);
            }
            else
            {
                e.Cancel = true;
            }
        }
    }
Example #3
0
    private void StopButton_Click(object sender, EventArgs e)
    {
        bool success = _databaseOperation.StopDeleteTrace();

        _traceRunning      = false;
        progressBar1.Style = ProgressBarStyle.Blocks;

        if (success)
        {
            TaskCollection taskCollection = TraceFileHandler.ImportTrace(_databaseOperation.GetTraceRecordingData());

            if (taskCollection.Tasks.Count > 0)
            {
                foreach (Task task in taskCollection.Tasks)
                {
                    task.Name = TaskHelper.GetNewItemName(task.Name);
                    TaskHelper.TaskCollection.Tasks.Add(task);
                }

                _anythingRecorded = true;
            }
            else
            {
                MessageBox.Show("No tasks recorded.", GenericHelper.ApplicationName, MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
        }

        TraceFileHandler.DeleteTraceFile(true, _databaseOperation);

        Close();
    }
Example #4
0
    private bool StartTracing()
    {
        bool success = _databaseOperation.StopDeleteTrace();

        if (!success)
        {
            return(false);
        }

        success = TraceFileHandler.CheckTraceFileDirectoryRights();

        if (!success)
        {
            return(false);
        }

        success = TraceFileHandler.DeleteTraceFile(true, _databaseOperation);

        if (!success)
        {
            return(false);
        }

        success = BeginTracing();
        return(success);
    }
Example #5
0
    private void CheckTraceFileDirWorker_DoWork(object sender, DoWorkEventArgs e)
    {
        bool success;

        if (!Directory.Exists(ConfigHandler.RecordTraceFileDir))
        {
            success = false;

            string text = "Trace File Directory does not exist.\r\n\r\nIf you are reading from a remote server to a local drive, please use a UNC path and make sure the server has read access to your network share and the SQL Server Service Account has read access to the share.";

            if (ConfigHandler.UseTranslation)
            {
                text = Translator.GetText("traceFileSecurityInfo");
            }

            OutputHandler.Show(text, GenericHelper.ApplicationName, MessageBoxButtons.OK, MessageBoxIcon.Information);
        }
        else
        {
            _databaseOperation.SetShowErrorForm(false);

            success = BeginTracing();

            if (success)
            {
                string traceFile = null;

                if (Directory.GetFiles(ConfigHandler.RecordTraceFileDir, string.Format("{0}*.*", ConfigHandler.TraceFileName)).Length > 0)
                {
                    traceFile = Directory.GetFiles(ConfigHandler.RecordTraceFileDir, string.Format("{0}*.*", ConfigHandler.TraceFileName))[0];
                }

                if (traceFile == null || !File.Exists(traceFile))
                {
                    success = false;

                    string text = "Insufficient rights to Trace File Directory.\r\n\r\nIf you are connection to a remote SQL Server, please use UNC path and make sure the server has write access to your network share.\r\n\r\nTrace File Directory can be set in the Preferences menu.";

                    if (ConfigHandler.UseTranslation)
                    {
                        text = Translator.GetText("traceRights");
                    }

                    OutputHandler.Show(text, GenericHelper.ApplicationName, MessageBoxButtons.OK, MessageBoxIcon.Warning);
                }
            }

            _databaseOperation.StopDeleteTrace();
            TraceFileHandler.DeleteTraceFile(false, _databaseOperation);
        }

        e.Result = success;
    }
Example #6
0
    private void StopButton_Click(object sender, EventArgs e)
    {
        bool success = _databaseOperation.StopDeleteTrace();

        _traceRunning      = false;
        progressBar1.Style = ProgressBarStyle.Blocks;

        if (success)
        {
            success = ImportTraceFile();
            TraceFileHandler.DeleteTraceFile(true, _databaseOperation);
        }

        _success = success;
        Close();
    }
Example #7
0
    private void CheckTraceFileDirWorker_DoWork(object sender, DoWorkEventArgs e)
    {
        GenericHelper.ShowErrorMessageForm = false;

        bool success = BeginTracing();

        if (success)
        {
            string[] traceFiles = Directory.GetFiles(ConfigHandler.TraceFileDirectory, string.Format("{0}*.*", TaskHelper.TraceFileName));

            if (traceFiles.Length == 0 || !File.Exists(traceFiles[0]))
            {
                success = false;
                MessageBox.Show("Insufficient rights to Trace File Directory.\r\n\r\nIf you are connecting to a remote SQL Server, please use UNC path and make sure the server has write access to your network share.\r\n\r\nTrace File Directory can be set in the Preferences menu.", GenericHelper.ApplicationName, MessageBoxButtons.OK, MessageBoxIcon.Warning);
            }
        }

        _databaseOperation.StopDeleteTrace();
        TraceFileHandler.DeleteTraceFile(false, _databaseOperation);

        e.Result = success;
    }
    private bool DoWork(RunWorkerArgument arg)
    {
        if (GenericHelper.IsUserInteractive())
        {
            if (ConfigHandler.UseTranslation)
            {
                _worker.ReportProgress(-2, Translator.GetText("preparing"));
            }
            else
            {
                _worker.ReportProgress(-2, "Preparing...");
            }
        }

        arg.DatabaseOperation.CreateTempTable();
        ConfigHandler.TempTableCreated = true;

        if (GenericHelper.IsUserInteractive())
        {
            if (ConfigHandler.UseTranslation)
            {
                _worker.ReportProgress(-2, Translator.GetText("importingFiles"));
            }
            else
            {
                _worker.ReportProgress(-2, "Importing file(s)...");
            }
        }

        OutputHandler.WriteToLog("Importing file(s)...");

        arg.DatabaseOperation.DisableColumnStoreIndex();
        arg.DatabaseOperation.StopFullTextPopulation();

        bool success = true;

        for (int i = 0; i < arg.ImportTraceFileInfoList.Count; i++)
        {
            if (GenericHelper.IsUserInteractive())
            {
                _worker.ReportProgress(-1, new ProgressObject(i + 1, arg.ImportTraceFileInfoList.Count, arg.ImportTraceFileInfoList[i]));
            }

            OutputHandler.WriteToLog(string.Format("{0}/{1} ({2} - {3})", i + 1, arg.ImportTraceFileInfoList.Count, Path.GetFileName(arg.ImportTraceFileInfoList[i].FileName), GetSizeValue(arg.ImportTraceFileInfoList[i].FileSize)));

            success = TraceFileHandler.ImportTraceFile(arg.DatabaseOperation, arg.ImportTraceFileInfoList[i].FileName);

            if (!success)
            {
                break;
            }
        }

        if (success)
        {
            OutputHandler.WriteToLog("Importing file(s): Completed");
        }

        if (GenericHelper.IsUserInteractive())
        {
            if (ConfigHandler.UseTranslation)
            {
                _worker.ReportProgress(-2, Translator.GetText("creatingIndexes"));
            }
            else
            {
                _worker.ReportProgress(-2, "Creating indexes...");
            }
        }

        OutputHandler.WriteToLog("Creating indexes...");

        arg.DatabaseOperation.CreateIndexes();

        if (GenericHelper.IsUserInteractive())
        {
            if (ConfigHandler.UseTranslation)
            {
                _worker.ReportProgress(-2, Translator.GetText("populatingFullText"));
            }
            else
            {
                _worker.ReportProgress(-2, "Populating full text catalog...");
            }
        }

        OutputHandler.WriteToLog("Populating full text catalog...");

        arg.DatabaseOperation.StartFullTextPopulation();

        return(success);
    }