Ejemplo n.º 1
0
        /// <summary>
        /// Run the history import, one chunk at a time if necessary
        /// </summary>
        private void RunHistoryImport()
        {
            using (ETCMDataContext context = new ETCMDataContext())
            {
                DateTime? lastImport = null;
                DateTime now, historyStart, historyEnd;
                do
                {
                    now = DateTime.Now;

                    // Get the last import time
                    ETCMProperty lastImportProp = (from e in context.ETCMProperties
                                                   where e.PropertyName == LAST_IMPORT_PROPERTY
                                                   select e).SingleOrDefault();
                    if (lastImportProp != null)
                        lastImport = DateTime.Parse(lastImportProp.PropertyValue); ;

                    // Determine the start time of the history query
                    historyStart = lastImport ?? PTExporter.PT_CREATED_DATE;

                    // Determine the end time of the history query
                    historyEnd = now;
                    if (now - historyStart > PTExporter.MAX_HISTORY)
                    {
                        logger.Debug("The history from " + historyStart.ToString() + " to " + now + " is too long, limiting.");
                        historyEnd = historyStart.Add(PTExporter.MAX_HISTORY);
                    }

                    logger.Info("Importing history from timeframe (" + historyStart.ToString() + " - " + historyEnd.ToString() + ").");
                    // Run the export, and if there is history to export, import it
                    if (exporter.Run(historyStart, historyEnd))
                        importer.Run();

                    // Update the last import time
                    if (lastImportProp == null)
                    {
                        lastImportProp = new ETCMProperty();
                        context.ETCMProperties.InsertOnSubmit(lastImportProp);
                    }
                    lastImportProp.PropertyValue = historyEnd.ToString();
                    context.SubmitChanges();

                } while (historyEnd < now);
            }
        }
Ejemplo n.º 2
0
 partial void UpdateETCMProperty(ETCMProperty instance);
Ejemplo n.º 3
0
 partial void DeleteETCMProperty(ETCMProperty instance);
Ejemplo n.º 4
0
 partial void InsertETCMProperty(ETCMProperty instance);