Esempio n. 1
0
        /// <summary>
        /// Updates database if the original source text file still exists and has
        /// been modified. All series data is replaced with the source file contents
        /// </summary>
        private void Update()
        {
            if (m_db == null)
            {
                return;
            }
            Logger.WriteLine("Checking series " + Name + " (" + ID + ") for updates");
            string dir       = Path.GetDirectoryName(m_db.DataSource);
            bool   canUpdate = CanUpdateFromFile(ConnectionString, dir);

            if (canUpdate)
            {
                string fileName = ConnectionStringUtility.GetToken(ConnectionString, "FileName", "");
                if (!Path.IsPathRooted(fileName))
                {
                    fileName = Path.Combine(dir, fileName);
                }
                Logger.WriteLine("Updating: File has changed " + fileName);
                TextSeries ts = TextSeries.ReadFromFile(fileName);

                ConnectionString = ts.ConnectionString;
                ConnectionString = ConnectionStringUtility.MakeFileNameRelative(ConnectionString, m_db.DataSource);
                m_db.SaveProperties(this); // last write time needs to be updated.
                m_db.SaveTimeSeriesTable(ID, ts, DatabaseSaveOptions.DeleteAllExisting);
            }
        }
Esempio n. 2
0
        public static TextSeries ReadFromFile(string fileName)
        {
            TextSeries s = new TextSeries(fileName);

            s.Read();
            return(s);
        }