示例#1
0
    private bool ImportTraceFile()
    {
        List <ImportTraceFileInfo> importTraceFileInfoList = new List <ImportTraceFileInfo>();

        string fileName;

        if (ConfigHandler.UseExtendedEvents == "False" || _databaseOperation.GetSqlServerVersion() < 11)
        {
            fileName = string.Format(@"{0}\{1}.trc", ConfigHandler.RecordTraceFileDir.Replace("'", "''"), ConfigHandler.TraceFileName);
        }
        else
        {
            fileName = string.Format(@"{0}\{1}*.xel", ConfigHandler.RecordTraceFileDir.Replace("'", "''"), ConfigHandler.TraceFileName);
        }

        string fileSize = GetFileSize();

        importTraceFileInfoList.Add(new ImportTraceFileInfo(fileName, fileSize));

        ImportTraceFileForm form = new ImportTraceFileForm();

        form.Initialize(_databaseOperation, importTraceFileInfoList);
        form.ShowDialog();

        bool success = form.GetSuccess();

        return(success);
    }
示例#2
0
    private bool StartImport()
    {
        OutputHandler.WriteToLog(string.Format("Starting import. Number of Trace Files to import: {0}", traceFileListView.CheckedItems.Count));

        ConfigHandler.ImportStartTime = DateTime.Now;

        List <ImportTraceFileInfo> importTraceFileInfoList = new List <ImportTraceFileInfo>();

        if (_traceFileDir.EndsWith("\\"))
        {
            _traceFileDir = _traceFileDir.Substring(0, _traceFileDir.Length - 1);
        }

        for (int i = traceFileListView.CheckedItems.Count - 1; i >= 0; i--)
        {
            string fileName = string.Format(@"{0}\{1}", _traceFileDir, traceFileListView.CheckedItems[i].SubItems[2].Text);
            string fileSize = traceFileListView.CheckedItems[i].SubItems[3].Text;
            importTraceFileInfoList.Add(new ImportTraceFileInfo(fileName, fileSize));
            _lastImportedFiles.Add(fileName);
        }

        ImportTraceFileForm form = new ImportTraceFileForm();

        form.Initialize(_databaseOperation, importTraceFileInfoList);

        if (GenericHelper.IsUserInteractive())
        {
            form.ShowDialog();
        }

        ConfigHandler.ImportEndTime = DateTime.Now;

        bool success = form.GetSuccess();

        OutputHandler.WriteToLog(string.Format("Import success: {0}", success));

        return(success);
    }