internal void Initialize(string lineName) { // 個々のInitialize InfoGroups.ForEach(f => f.Initialize()); CachesBySettings = new PlcMemoryCaches(InfoGroups.Select(s => s.OptimizedTriggers).SelectMany(sm => sm)); InfoGroups.ForEach(f => f.PostInitialize(CachesBySettings)); // 速度向上用 if (AsUpdateSQL) { //SqlCommand = DbConsumer.GetSqlCommandAsUpdateOrInsert(TableName, lineName, InsertTargets); SqlCommand = DbConsumer.GetSqlCommandAsUpdate(TableName, lineName, InsertTargets); // MergeだとLockの可能性があるのでUpdateOnlyとした } else { SqlCommand = DbConsumer.GetSqlCommandAsInsert(TableName, lineName, InsertTargets); } }
private bool disposedValue = false; // 重複する呼び出しを検出するには protected virtual void Dispose(bool disposing) { if (!disposedValue) { if (disposing) { Settings = null; CancellationTokenSource = null; PlcWatchers = null; RecipeWatcher = null; DbConsumer = null; } // アンマネージ リソース (アンマネージ オブジェクト) を解放し、下のファイナライザーをオーバーライドします。 // 大きなフィールドを null に設定します。 disposedValue = true; } }
public void Start() { Settings.LoggerSettings.Initialize(); CancellationTokenSource = new CancellationTokenSource(); var storingData = new BlockingCollection <IQueueingData>(); // データをDBへ突っ込む部分 DbConsumer = new DbConsumer(storingData, CancellationTokenSource.Token); // Recipe監視 RecipeWatcher = new RecipeWatcher(storingData, Settings.LoggerSettings.LineName, Settings.LoggerSettings.WatchingRecipeFolderPath); // Plc監視 var factory = new ClkLibHelperFactory(Settings.LoggerSettings.NetworkNo, Settings.LoggerSettings.NodeNo, Settings.LoggerSettings.UnitNo); // ClkLib のHandle番号管理。実HandleはC-Lib 内 PlcWatchers = Settings.LoggerSettings.PlcAccesss.Where(w => w.IsEnable).Select(f => new PlcWatcher(storingData, CancellationTokenSource.Token, factory.GetHelper(), f)); // start DbConsumer.Start(); RecipeWatcher.Start(); PlcWatchers.ToList().ForEach(f => f.Start()); }