protected override void Dispose(bool disposing) { if (disposing) { db.Dispose(); } base.Dispose(disposing); }
protected virtual void Dispose(bool disposing) { if (!this.disposed) { if (disposing) { context.Dispose(); } } this.disposed = true; }
private static void UpdateION() { lock (OPCObjects.OPCLocker) { lock (OPCObjects.SQLLocker) { using (var context = new MyDBContext()) { var entitys = context.Ion.Where(e => e.Id == 1); foreach (var entity in entitys) { entity.Anod_I = OPCObjects.IonOutputFeedBack.Anod_I; entity.Anod_I_SP = OPCObjects.IonInputSetPoint.Anod_I_SP; entity.Anod_P = OPCObjects.IonOutputFeedBack.Anod_P; entity.Anod_P_SP = OPCObjects.IonInputSetPoint.Anod_P_SP; entity.Anod_U = OPCObjects.IonOutputFeedBack.Anod_U; entity.Anod_U_SP = OPCObjects.IonInputSetPoint.Anod_U_SP; entity.Heat_I = OPCObjects.IonOutputFeedBack.Heat_I; entity.Heat_I_SP = OPCObjects.IonInputSetPoint.Heat_I_SP; entity.Heat_P = OPCObjects.IonOutputFeedBack.Heat_P; entity.Heat_P_SP = OPCObjects.IonInputSetPoint.Heat_P_SP; entity.Heat_U = OPCObjects.IonOutputFeedBack.Heat_U; entity.Heat_U_SP = OPCObjects.IonInputSetPoint.Heat_U_SP; entity.icAuto_mod = OPCObjects.IonInputCommnd.Auto_mod; entity.icManual_Start = OPCObjects.IonInputCommnd.Manual_Start; entity.icManual_Stop = OPCObjects.IonInputCommnd.Manual_Stop; entity.icReset_error = OPCObjects.IonInputCommnd.Reset_error; entity.icStart = OPCObjects.IonInputCommnd.Start; entity.icStop = OPCObjects.IonInputCommnd.Stop; entity.sAuto_mode = OPCObjects.IonStatus.Auto_mode; entity.sEmergancy_Stop = OPCObjects.IonStatus.Emergancy_Stop; entity.sFailure = OPCObjects.IonStatus.Failure; entity.sFilament_Failure = OPCObjects.IonStatus.Filament_Failure; entity.sInterlock = OPCObjects.IonStatus.Interlock; entity.sOther_Failure = OPCObjects.IonStatus.Other_Failure; entity.sPower_Failure = OPCObjects.IonStatus.Power_Failure; entity.sPower_on = OPCObjects.IonStatus.Power_on; entity.sPower_Stop = OPCObjects.IonStatus.Power_Stop; entity.sRepeat_Failure = OPCObjects.IonStatus.Repeat_Failure; entity.sTemperature_Failure = OPCObjects.IonStatus.Temperature_Failure; entity.sTemperature_Stop = OPCObjects.IonStatus.Temperature_Stop; entity.sTurn_off = OPCObjects.IonStatus.Turn_off; entity.sTurn_On = OPCObjects.IonStatus.Turn_On; context.Update(entity); } context.SaveChanges(); context.Dispose(); } } } }
public static void AddOperatoAction(string Login, string Action) { lock (OPCObjects.SQLLocker) { using (var context = new MyDBContext()) { var action = new OperatorLog { Login = Login, Action = Action, dateTime = DateTime.Now }; context.operatorLogs.Add(action); context.SaveChanges(); context.Dispose(); } } }
private static void UpdateCamPrepTable(object obj) { var objects = OPCObjects.createObjects(); var opclocking = objects.getOPCLocker(); lock (opclocking) { var CamPrepOPC = objects.get_camPrepare(); var locking = obj; lock (locking) { using (var context = new MyDBContext()) { var camprepobject = context.CamPrepTable.Where(e => e.Id == 1); foreach (var cam in camprepobject) { cam.Access = CamPrepOPC.Access; cam.Finally_pressure = CamPrepOPC.Finally_pressure; cam.Open_FVV_B_pressure = CamPrepOPC.Open_FVV_B_pressure; cam.Open_SHV_pressure = CamPrepOPC.Open_SHV_pressure; cam.Return_ERROR = CamPrepOPC.Return_ERROR; cam.Stage_0_Cam_prepare_Complite = CamPrepOPC.Stage_0_Cam_prepare_Complite; cam.Stage_0_Cam_prepare_Stage = CamPrepOPC.Stage_0_Cam_prepare_Stage; context.Update(cam); Console.WriteLine("Node Name = {0}", cam.Name); Console.WriteLine("In DB we sent ={0}", cam.Open_FVV_B_pressure); Console.WriteLine("In OPC Value ={0}", CamPrepOPC.Open_FVV_B_pressure); } context.SaveChanges(); context.Dispose(); } Console.WriteLine("CHECK DB"); } } }
private static void UpdateIntValue() { lock (OPCObjects.OPCLocker) { lock (OPCObjects.SQLLocker) { using (var context = new MyDBContext()) { foreach (var intvalue in OPCObjects.IntValues) { var entitys = context.IntValue.Where(e => e.Path == intvalue.Path.ToString()); foreach (var entity in entitys) { entity.Value = intvalue.Value; context.IntValue.Update(entity); } } context.SaveChanges(); context.Dispose(); } } } }
private static void UpdateStopFVPTable() { lock (OPCObjects.OPCLocker) { lock (OPCObjects.SQLLocker) { using (var context = new MyDBContext()) { var opcstopfvp = Objects.OPCObjects.createObjects().GetStopFVP(); var stopfvpvalues = context.StopFVP.Where(e => e.Id == 1); foreach (var sf in stopfvpvalues) { sf.Access = opcstopfvp.Access; sf.Stage_3_Done = opcstopfvp.Stage_3_Done; sf.Stage_3_Return = opcstopfvp.Stage_3_Return; context.Update(sf); } context.SaveChanges(); context.Dispose(); } } } }
private static void UpdateCrioPumpStartTable() { lock (OPCObjects.OPCLocker) { lock (OPCObjects.SQLLocker) { using (var context = new MyDBContext()) { var opcriopumpstart = Objects.OPCObjects.createObjects().GetCrioPumpStart(); var criopumpsstart = context.CrioPumpStart.Where(e => e.Id == 1); foreach (var cp in criopumpsstart) { cp.Return_error = opcriopumpstart.Return_error; cp.Stage_0_CompliteP = opcriopumpstart.Stage_0_CompliteP; cp.Stage_0_Stage = opcriopumpstart.Stage_0_Stage; cp.Temperature_SP = opcriopumpstart.Temperature_SP; context.Update(cp); } context.SaveChanges(); context.Dispose(); } } } }
private static void UpdateStopCrioTable() { lock (OPCObjects.OPCLocker) { lock (OPCObjects.SQLLocker) { using (var context = new MyDBContext()) { var opcstopcriotable = Objects.OPCObjects.createObjects().GetStopCrio(); var stopcriovalues = context.StopCrio.Where(e => e.Id == 1); foreach (var sc in stopcriovalues) { sc.Access = opcstopcriotable.Access; sc.Stage_2_done = opcstopcriotable.Stage_2_done; sc.Stage_2_Return = opcstopcriotable.Stage_2_Return; sc.Stage_2_Stage = opcstopcriotable.Stage_2_Stage; context.Update(sc); } context.SaveChanges(); context.Dispose(); } } } }
protected override void Dispose(bool disposing) { base.Dispose(disposing); _context.Dispose(); }
public void Dispose() { dataContext.Dispose(); }
public void Dispose() { Context.Dispose(); }
public MainWindow() { Common.Logging.LogManager.Adapter = new NLogLoggerFactoryAdapter(new Common.Logging.Configuration.NameValueCollection()); //make sure we can connect to the database CheckDBConnection(); //set the log directory SetLogDirectory(); //set the connection string DBUtils.SetConnectionString(); InitializeComponent(); DataContext = this; //load datagrid layout string layoutFile = AppDomain.CurrentDomain.BaseDirectory + "GridLayout.xml"; if (File.Exists(layoutFile)) { try { InstrumentsGrid.DeserializeLayout(File.ReadAllText(layoutFile)); } catch { } } LogMessages = new ObservableCollection <LogEventInfo>(); //target is where the log managers send their logs, here we grab the memory target which has a Subject to observe var target = LogManager.Configuration.AllTargets.Single(x => x.Name == "myTarget") as MemoryTarget; //we subscribe to the messages and send them all to the LogMessages collection if (target != null) { target.Messages.Subscribe(msg => LogMessages.Add(msg)); } //build the instruments grid context menu //we want a button for each BarSize enum value in the UpdateFreqSubMenu menu foreach (int value in Enum.GetValues(typeof(BarSize))) { var button = new MenuItem { Header = Regex.Replace(((BarSize)value).ToString(), "([A-Z])", " $1").Trim(), Tag = (BarSize)value }; button.Click += UpdateHistoricalDataBtn_ItemClick; ((MenuItem)Resources["UpdateFreqSubMenu"]).Items.Add(button); } //create metadata db if it doesn't exist var entityContext = new MyDBContext(); entityContext.Database.Initialize(false); //seed the datasources no matter what, because these are added frequently Seed.SeedDatasources(entityContext); //check for any exchanges, seed the db with initial values if nothing is found if (!entityContext.Exchanges.Any()) { Seed.DoSeed(); } //create data db if it doesn't exist var dataContext = new DataDBContext(); dataContext.Database.Initialize(false); dataContext.Dispose(); //build the tags menu var allTags = entityContext.Tags.ToList(); BuildTagContextMenu(allTags); //build session templates menu BuildSetSessionTemplateMenu(); Instruments = new ObservableCollection <Instrument>(); var mgr = new InstrumentManager(); var instrumentList = mgr.FindInstruments(entityContext); foreach (Instrument i in instrumentList) { Instruments.Add(i); } //create brokers RealTimeBroker = new RealTimeDataBroker(); HistoricalBroker = new HistoricalDataBroker(); //create the various servers _realTimeServer = new RealTimeDataServer(Properties.Settings.Default.rtDBPubPort, Properties.Settings.Default.rtDBReqPort, RealTimeBroker); _instrumentsServer = new InstrumentsServer(Properties.Settings.Default.instrumentServerPort); _historicalDataServer = new HistoricalDataServer(Properties.Settings.Default.hDBPort, HistoricalBroker); //and start them _realTimeServer.StartServer(); _instrumentsServer.StartServer(); _historicalDataServer.StartServer(); //we also need a client to make historical data requests with _client = new QDMSClient.QDMSClient( "SERVERCLIENT", "localhost", Properties.Settings.Default.rtDBReqPort, Properties.Settings.Default.rtDBPubPort, Properties.Settings.Default.instrumentServerPort, Properties.Settings.Default.hDBPort); _client.Connect(); _client.HistoricalDataReceived += _client_HistoricalDataReceived; ActiveStreamGrid.ItemsSource = RealTimeBroker.ActiveStreams; //create the scheduler ISchedulerFactory schedulerFactory = new StdSchedulerFactory(); _scheduler = schedulerFactory.GetScheduler(); _scheduler.JobFactory = new DataUpdateJobFactory(HistoricalBroker); _scheduler.Start(); //Grab jobs and schedule them JobsManager.ScheduleJobs(_scheduler, entityContext.DataUpdateJobs.Include(t => t.Instrument).Include(t => t.Tag).ToList()); entityContext.Dispose(); ShowChangelog(); }
public void Dispose() { Db?.Dispose(); }
public MainWindow() { Common.Logging.LogManager.Adapter = new NLogLoggerFactoryAdapter(new Common.Logging.Configuration.NameValueCollection()); //make sure we can connect to the database CheckDBConnection(); //set the log directory SetLogDirectory(); //set the connection string DBUtils.SetConnectionString(); //set EF configuration, necessary for MySql to work DBUtils.SetDbConfiguration(); InitializeComponent(); DataContext = this; //load datagrid layout string layoutFile = AppDomain.CurrentDomain.BaseDirectory + "GridLayout.xml"; if (File.Exists(layoutFile)) { try { InstrumentsGrid.DeserializeLayout(File.ReadAllText(layoutFile)); } catch { } } LogMessages = new ConcurrentNotifierBlockingList <LogEventInfo>(); //target is where the log managers send their logs, here we grab the memory target which has a Subject to observe var target = LogManager.Configuration.AllTargets.Single(x => x.Name == "myTarget") as MemoryTarget; //Log unhandled exceptions AppDomain.CurrentDomain.UnhandledException += AppDomain_CurrentDomain_UnhandledException; //we subscribe to the messages and send them all to the LogMessages collection if (target != null) { target.Messages.Subscribe(msg => LogMessages.TryAdd(msg)); } //build the instruments grid context menu //we want a button for each BarSize enum value in the UpdateFreqSubMenu menu foreach (int value in Enum.GetValues(typeof(BarSize))) { var button = new MenuItem { Header = Regex.Replace(((BarSize)value).ToString(), "([A-Z])", " $1").Trim(), Tag = (BarSize)value }; button.Click += UpdateHistoricalDataBtn_ItemClick; ((MenuItem)Resources["UpdateFreqSubMenu"]).Items.Add(button); } //create metadata db if it doesn't exist var entityContext = new MyDBContext(); entityContext.Database.Initialize(false); //seed the datasources no matter what, because these are added frequently Seed.SeedDatasources(entityContext); //check for any exchanges, seed the db with initial values if nothing is found if (!entityContext.Exchanges.Any()) { Seed.DoSeed(); } //create data db if it doesn't exist var dataContext = new DataDBContext(); dataContext.Database.Initialize(false); dataContext.Dispose(); //create quartz db if it doesn't exist QuartzUtils.InitializeDatabase(Settings.Default.databaseType); //build the tags menu var allTags = entityContext.Tags.ToList(); BuildTagContextMenu(allTags); //build session templates menu BuildSetSessionTemplateMenu(); Instruments = new ObservableCollection <Instrument>(); var instrumentRepo = new InstrumentRepository(entityContext); var instrumentList = instrumentRepo.FindInstruments().Result; foreach (Instrument i in instrumentList) { Instruments.Add(i); } //create brokers var cfRealtimeBroker = new ContinuousFuturesBroker(new QDMSClient.QDMSClient( "RTDBCFClient", "127.0.0.1", Properties.Settings.Default.rtDBReqPort, Properties.Settings.Default.rtDBPubPort, Properties.Settings.Default.hDBPort, Properties.Settings.Default.httpPort, Properties.Settings.Default.apiKey, useSsl: Properties.Settings.Default.useSsl), connectImmediately: false); var cfHistoricalBroker = new ContinuousFuturesBroker(new QDMSClient.QDMSClient( "HDBCFClient", "127.0.0.1", Properties.Settings.Default.rtDBReqPort, Properties.Settings.Default.rtDBPubPort, Properties.Settings.Default.hDBPort, Properties.Settings.Default.httpPort, Properties.Settings.Default.apiKey, useSsl: Properties.Settings.Default.useSsl), connectImmediately: false); var localStorage = DataStorageFactory.Get(); RealTimeBroker = new RealTimeDataBroker(cfRealtimeBroker, localStorage, new IRealTimeDataSource[] { //new Xignite(Properties.Settings.Default.xigniteApiToken), //new Oanda(Properties.Settings.Default.oandaAccountId, Properties.Settings.Default.oandaAccessToken), new IB(Properties.Settings.Default.ibClientHost, Properties.Settings.Default.ibClientPort, Properties.Settings.Default.rtdClientIBID), //new ForexFeed(Properties.Settings.Default.forexFeedAccessKey, ForexFeed.PriceType.Mid) }); HistoricalBroker = new HistoricalDataBroker(cfHistoricalBroker, localStorage, new IHistoricalDataSource[] { new Yahoo(), new FRED(), //new Forexite(), new IB(Properties.Settings.Default.ibClientHost, Properties.Settings.Default.ibClientPort, Properties.Settings.Default.histClientIBID), new Quandl(Properties.Settings.Default.quandlAuthCode), new BarChart(Properties.Settings.Default.barChartApiKey) }); var countryCodeHelper = new CountryCodeHelper(entityContext.Countries.ToList()); EconomicReleaseBroker = new EconomicReleaseBroker("FXStreet", new[] { new fx.FXStreet(countryCodeHelper) }); //create the various servers _realTimeServer = new RealTimeDataServer(Properties.Settings.Default.rtDBPubPort, Properties.Settings.Default.rtDBReqPort, RealTimeBroker); _historicalDataServer = new HistoricalDataServer(Properties.Settings.Default.hDBPort, HistoricalBroker); //and start them _realTimeServer.StartServer(); _historicalDataServer.StartServer(); //we also need a client to make historical data requests with _client = new QDMSClient.QDMSClient( "SERVERCLIENT", "localhost", Properties.Settings.Default.rtDBReqPort, Properties.Settings.Default.rtDBPubPort, Properties.Settings.Default.hDBPort, Properties.Settings.Default.httpPort, Properties.Settings.Default.apiKey, useSsl: Properties.Settings.Default.useSsl); _client.Connect(); _client.HistoricalDataReceived += _client_HistoricalDataReceived; ActiveStreamGrid.ItemsSource = RealTimeBroker.ActiveStreams; //create the scheduler var quartzSettings = QuartzUtils.GetQuartzSettings(Settings.Default.databaseType); ISchedulerFactory schedulerFactory = new StdSchedulerFactory(quartzSettings); _scheduler = schedulerFactory.GetScheduler(); _scheduler.JobFactory = new JobFactory(HistoricalBroker, Properties.Settings.Default.updateJobEmailHost, Properties.Settings.Default.updateJobEmailPort, Properties.Settings.Default.updateJobEmailUsername, Properties.Settings.Default.updateJobEmailPassword, Properties.Settings.Default.updateJobEmailSender, Properties.Settings.Default.updateJobEmail, new UpdateJobSettings( noDataReceived: Properties.Settings.Default.updateJobReportNoData, errors: Properties.Settings.Default.updateJobReportErrors, outliers: Properties.Settings.Default.updateJobReportOutliers, requestTimeouts: Properties.Settings.Default.updateJobTimeouts, timeout: Properties.Settings.Default.updateJobTimeout, toEmail: Properties.Settings.Default.updateJobEmail, fromEmail: Properties.Settings.Default.updateJobEmailSender), localStorage, EconomicReleaseBroker); _scheduler.Start(); //Take jobs stored in the qmds db and move them to the quartz db - this can be removed in the next version MigrateJobs(entityContext, _scheduler); var bootstrapper = new CustomBootstrapper( DataStorageFactory.Get(), EconomicReleaseBroker, HistoricalBroker, RealTimeBroker, Properties.Settings.Default.apiKey); var uri = new Uri((Settings.Default.useSsl ? "https" : "http") + "://localhost:" + Properties.Settings.Default.httpPort); var host = new NancyHost(bootstrapper, uri); host.Start(); entityContext.Dispose(); ShowChangelog(); }
protected override void Dispose(bool disposing) { db.Dispose(); }
public MainWindow() { Common.Logging.LogManager.Adapter = new NLogLoggerFactoryAdapter(new Common.Logging.Configuration.NameValueCollection()); //make sure we can connect to the database CheckDBConnection(); //set the log directory SetLogDirectory(); //set the connection string DBUtils.SetConnectionString(); //set EF configuration, necessary for MySql to work DBUtils.SetDbConfiguration(); InitializeComponent(); //load datagrid layout string layoutFile = AppDomain.CurrentDomain.BaseDirectory + "GridLayout.xml"; if (File.Exists(layoutFile)) { try { InstrumentsGrid.DeserializeLayout(File.ReadAllText(layoutFile)); } catch { } } //Log unhandled exceptions AppDomain.CurrentDomain.UnhandledException += AppDomain_CurrentDomain_UnhandledException; //build the instruments grid context menu //we want a button for each BarSize enum value in the UpdateFreqSubMenu menu foreach (int value in Enum.GetValues(typeof(BarSize))) { var button = new MenuItem { Header = Regex.Replace(((BarSize)value).ToString(), "([A-Z])", " $1").Trim(), Tag = (BarSize)value }; button.Click += UpdateHistoricalDataBtn_ItemClick; ((MenuItem)Resources["UpdateFreqSubMenu"]).Items.Add(button); } //create metadata db if it doesn't exist var entityContext = new MyDBContext(); entityContext.Database.Initialize(false); //seed the datasources no matter what, because these are added frequently Seed.SeedDatasources(entityContext); //check for any exchanges, seed the db with initial values if nothing is found if (!entityContext.Exchanges.Any() || (ApplicationDeployment.IsNetworkDeployed && ApplicationDeployment.CurrentDeployment.IsFirstRun)) { Seed.DoSeed(); } //create data db if it doesn't exist var dataContext = new DataDBContext(); dataContext.Database.Initialize(false); dataContext.Dispose(); //create quartz db if it doesn't exist QuartzUtils.InitializeDatabase(Settings.Default.databaseType); //build the tags menu var allTags = entityContext.Tags.ToList(); BuildTagContextMenu(allTags); //build session templates menu BuildSetSessionTemplateMenu(); entityContext.Dispose(); //we also need a client to make historical data requests with _client = new QDMSClient.QDMSClient( "SERVERCLIENT", "localhost", Properties.Settings.Default.rtDBReqPort, Properties.Settings.Default.rtDBPubPort, Properties.Settings.Default.hDBPort, Properties.Settings.Default.httpPort, Properties.Settings.Default.apiKey, useSsl: Properties.Settings.Default.useSsl); _client.HistoricalDataReceived += _client_HistoricalDataReceived; _client.Error += (s, e) => _clientLogger.Error(e.ErrorMessage); //Create ViewModel ViewModel = new MainViewModel(_client, DialogCoordinator.Instance); DataContext = ViewModel; ShowChangelog(); }
public void Dispose() { context?.Dispose(); }
protected override void Dispose(bool disposing) { _context.Dispose(); }
public virtual void Dispose() { MyContext.Dispose(); }