public ITrendsRunTarget Create(string connectionString, IProject project, trend_categories trendCategory, ITimeService timeService) { var npgsqlConnectionFactory = new NpgsqlConnectionFactory(connectionString); var repositoryFactory = new TrendsRepositoryFactory( npgsqlConnectionFactory, trendCategory.id, trendCategory.trend_tags.Select(t => t.id).ToArray()); using (var repository = repositoryFactory.Create()) { repository.EnsureTables(); } return new TrendsRunTarget( trendCategory, new NotificationReporter(timeService) { LifeTime = TimeSpan.FromTicks(0) }, repositoryFactory, project, timeService, new TrendTableSelector()); }
public TrendsRunTarget( trend_categories trendCategory, INotificationReporter reporter, ITrendsRepositoryFactory repositoryFactory, IProject project, ITimeService timeService, ITrendTableSelector tableSelector) { _name = string.Format("{0} \"{1}\"", Res.Trends, trendCategory.name); _timeToStore = trendCategory.time_to_store.HasValue ? new TimeSpan(trendCategory.time_to_store.Value) as TimeSpan? : null; foreach (var t in trendCategory.trend_tags.ToArray()) { Func<bool> triggerValueGetter; if (t.dig_tags == null) { triggerValueGetter = () => true; } else { var trIoDevId = t.dig_tags.io_devices.id; var trId = t.dig_tags.id; triggerValueGetter = () => project.IoDeviceRunTargets[trIoDevId].GetDigitalValue(trId) == true; } var ioDeviceId = t.num_tags.io_devices.id; var tagId = t.num_tags.id; var trendInfo = new TrendTagInfo( t.id, triggerValueGetter, () => project.IoDeviceRunTargets[ioDeviceId].GetNumericValue(tagId)); _trendsInfo.Add(t.id, trendInfo); } _reporter = reporter; _repositoryFactory = repositoryFactory; _timeService = timeService; _tableSelector = tableSelector; }
/// <summary> /// Create a new trend_categories object. /// </summary> /// <param name="id">Initial value of the id property.</param> /// <param name="name">Initial value of the name property.</param> /// <param name="period">Initial value of the period property.</param> public static trend_categories Createtrend_categories(global::System.Int32 id, global::System.String name, global::System.Int64 period) { trend_categories trend_categories = new trend_categories(); trend_categories.id = id; trend_categories.name = name; trend_categories.period = period; return trend_categories; }
/// <summary> /// Deprecated Method for adding a new object to the trend_categories EntitySet. Consider using the .Add method of the associated ObjectSet<T> property instead. /// </summary> public void AddTotrend_categories(trend_categories trend_categories) { base.AddObject("trend_categories", trend_categories); }