Exemplo n.º 1
0
        public static int ExportLogToTwdb(List <string> files, Disaggregator disaggregator)
        {
            var twdbAdapter     = CreateAnalysisAdapter("dummy.twdb") as ArffAnalysisAdapter;
            var factory         = new LogAdapterFactory();
            int countFilesSaved = 0;

            foreach (var file in files)
            {
                var logAdapter = factory.GetAdapter(file) as LogAdapter;
                if (logAdapter != null)
                {
                    var log = logAdapter.Load(file);

                    var classifier = new NullClassifier();

                    disaggregator.Log = log;
                    Events events = disaggregator.Disaggregate();

                    var analysis = new AnalysisDatabase(file, events, log);
                    classifier.Classify(analysis);

                    analysis.UpdateFixtureSummaries();

                    twdbAdapter.Save(System.IO.Path.ChangeExtension(file, TwEnvironment.ArffAnalysisExtension), analysis, true);
                    countFilesSaved++;
                }
            }
            return(countFilesSaved);
        }
Exemplo n.º 2
0
        public Analysis Load(string dataSource)
        {
            var analysis = new AnalysisDatabase(dataSource);

            try {
                using (OleDbConnection connection = new OleDbConnection(DataServices.BuildJetConnectionString(dataSource, true))) {
                    connection.Open();
                    analysis.FixtureProfiles = LoadFixtureProfiles(connection);
                    analysis.Events          = LoadEvents(connection, analysis.FixtureProfiles, GetInterval(connection));
                }
            } catch (System.Data.OleDb.OleDbException ex) {
                if (ex.Message.Contains("Could not find file"))
                {
                    throw new Exception("Could not find file");
                }
                else if (ex.Message.Contains("Unrecognized database format"))
                {
                    throw new Exception("Unrecognized analysis format");
                }
                else
                {
                    throw;
                }
            } catch (InvalidOperationException ex) {
                if (ex.Message.Contains("provider is not registered"))
                {
                    throw new Exception("The MS 2007 Office System Driver is not installed on this system.\r\n\r\nPlease review System Requirements and Installation Troubleshooting.\r\n\r\n(" + ex.Message + ")");
                }
                else
                {
                    throw;
                }
            }
            return(analysis);
        }
Exemplo n.º 3
0
        AnalysisPanel LoadLogAndClassify(string fileName, bool showAnalyzer)
        {
            var classifier    = new NullClassifier();
            var disaggregator = new Tw4PostTrickleMergeMidnightSplitDisaggregator();

            Mouse.OverrideCursor = Cursors.Wait;

            Log log = TwServices.CreateLog(fileName);

            disaggregator.Log = log;
            Events events = disaggregator.Disaggregate();

            events.UpdateLinkedList();

            var analysis = new AnalysisDatabase(fileName, events, log);

            classifier.Classify(analysis);

            analysis.UpdateFixtureSummaries();

            var analysisPanel = CreateAnalysisPanel(analysis, fileName, disaggregator, showAnalyzer, GetViewportSeconds(), EventsViewer.VolumeTen);

            Mouse.OverrideCursor = null;
            return(analysisPanel);
        }
Exemplo n.º 4
0
        public Analysis Load(string dataSource)
        {
            string[] lines = System.IO.File.ReadAllLines(dataSource);

            if (IsOldVersion(lines))
            {
                throw new Exception("Please migrate the analysis file " + dataSource + " to version " + TwAssembly.Version() + " or later.");
            }

            double twConversionFactor = GetTwConversionFactor(lines);

            Attributes = LoadAttributes(lines);

            LogMeter log = LoadLog(lines);

            FixtureProfiles fixtureProfiles = LoadFixtureProfiles(lines);

            Events events = LoadEvents(lines);

            LoadFlows(lines, events);

            events.UpdateVolume();

            var analysis = new AnalysisDatabase(dataSource, events, log, fixtureProfiles);

            analysis.Events.ConversionFactor = twConversionFactor;
            analysis.Events.UpdateChannel();
            analysis.Events.UpdateSuperPeak();
            analysis.Events.UpdateLinkedList();
            analysis.Events.UpdateOriginalVolume();

            return(analysis);
        }
Exemplo n.º 5
0
        void BackupSave(AnalysisDatabase analysis)
        {
//            string arffFile = TwFile.GetBackupArffFileToSave(analysis.DataSourceDirectoryName, analysis.KeyCode);
            string arffFile = TwFile.GetBackupArffFileToSave(".", analysis.KeyCode);

            if (arffFile == null || arffFile.Length == 0)
            {
                return;
            }

            var analysisAdapter = new ArffAnalysisAdapter();

            analysisAdapter.Save(arffFile, analysis, true);
            analysis.Events.IsBackupDirty = false;
        }
Exemplo n.º 6
0
        void BackupSave(TabItem tabItem)
        {
            AnalysisPanel analysisPanel = tabItem.Content as AnalysisPanel;

            if (analysisPanel == null)
            {
                return;
            }

            Analysis         analysis         = analysisPanel.Analysis;
            AnalysisDatabase analysisDatabase = analysis as AnalysisDatabase;

            if (analysisDatabase == null)
            {
                return;
            }

            BackupSave(analysisDatabase);
        }