Ejemplo n.º 1
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);
        }
Ejemplo n.º 2
0
        public override Log Load(string dataSource)
        {
            //dataSource = ConvertFromAccess97(dataSource);

            var log = new LogMeter(dataSource);

            try {
                using (OleDbConnection connection = new OleDbConnection(DataServices.BuildJetConnectionString(dataSource, true))) {
                    connection.Open();
                    using (OleDbCommand command = new OleDbCommand()) {
                        command.Connection = connection;

                        log.FileName = dataSource;
                        log.Customer = AddCustomer(command);
                        log.Meter    = AddMeter(command);
                        log.Flows    = AddFlows(command, TimeSpan.FromSeconds(log.Meter.StorageInterval.GetValueOrDefault()), log);

                        if (log.Flows.Count > 0)
                        {
                            log.StartTime = log.Flows[0].StartTime;
                            log.EndTime   = log.Flows[log.Flows.Count - 1].EndTime;
                        }
                    }

                    log.Update();
                    return(log);
                }
            } 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 logger format");
                }
                else if (ex.Message.Contains("Cannot open a database created with a previous version of your application"))
                {
                    throw new Exception("The Microsoft Access 2007 Runtime is not properly installed on this system. Historically, this error has occured when Access 2010 or later has been run on this system.\r\n\r\nPlease review the " + TwAssembly.Title() + " System Requirements and reinstall/repair the Access 2007 Runtime.\r\n\r\n The original error message was: " + ex.Message);
                }
                else
                {
                    throw;
                }
            } catch (InvalidOperationException ex) {
                if (ex.Message.Contains("provider is not registered"))
                {
                    throw new Exception("The Microsoft Access 2007 Runtime is not installed on this system.\r\n\r\nPlease review the " + TwAssembly.Title() + " System Requirements and install the Access 2007 Runtime.\r\n\r\n(" + ex.Message + ")");
                }
                else
                {
                    throw;
                }
            }
        }