public DeviceVM(Device dev, DeviceBatchContext context) : base(context) { TheDevice = dev; PopulateTestConditions(); PopulatePixelsDict(); GenerateDataVMsFromChildren(); }
private async Task <MainWindowViewModel> InitializeAsync() { return(await Task.Run(async() => { Trace.AutoFlush = true; var sysname = System.Environment.MachineName; if (sysname == "JAKE-PC") { ConfigurationManager.AppSettings.Set("BatchTestSystem", "BTS1"); } else if (sysname == "DESKTOP-GQQ0M3J") { ConfigurationManager.AppSettings.Set("BatchTestSystem", "BTS2"); } Debug.WriteLine("sysname: " + sysname); await InstrumentService.CreateCoordinatorAsync(); await OriginService.CreateControllerAsync(); await DataProcessingService.CreateLEDCalculatorAsync(); if (Debugger.IsAttached) { Properties.Settings.Default.Reset(); } var dBConnectionManager = new DBConnectionManager(); ctx = new DeviceBatchContext(); Task[] initTasks = new Task[2]; initTasks[0] = LoadDirectoryTreeView(); initTasks[1] = UpdateIPAddress(); await Task.WhenAll(initTasks); Trace.TraceInformation("Initialized MainWindowViewModel"); return this; }).ConfigureAwait(false)); }
void CheckForDBConnection() { try { //check to see if connectionstring will open connection with db var config = ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel.None); var connectionStringsSection = (ConnectionStringsSection)config.GetSection("connectionStrings"); var connstring = connectionStringsSection.ConnectionStrings["ServerConnectionString"].ConnectionString; Debug.WriteLine("connectionString from configmanager is: " + connstring); bool dumbBool = false; //var efconfig = ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel.None,); using (ctx = new DeviceBatchContext(connstring)) { Debug.WriteLine("ctx.Database.Connection.ConnectionString: " + ctx.Database.Connection.ConnectionString); if (ctx.Database.Exists()) { Debug.WriteLine("ctx.Database.Exists()==true"); var firstDevBatch = ctx.DeviceBatches.First(); Debug.WriteLine("Successfully opened DB connection. First DevBatch.Name is " + firstDevBatch.Name); } else { Debug.WriteLine("ctx.Database.Exists()==false"); ctx.Dispose(); dumbBool = true; //PromptForDBCredentials(); } } if (dumbBool) { PromptForDBCredentials(); CheckForDBConnection(); } //ctx.Database.Connection.ConnectionString = connstring; //ctx.Database.Connection.Open(); } catch (SqlException e) { Debug.WriteLine("SqlException: " + e.ToString()); //ctx.Dispose(); //System.Windows.MessageBox.Show(e.ToString()); //ctx.Database.Connection.Close(); PromptForDBCredentials(); CheckForDBConnection(); } catch (Exception e) { Debug.WriteLine("Exception: " + e.ToString()); //ctx.Dispose(); PromptForDBCredentials(); CheckForDBConnection(); } }
private async Task <SingleDeviceScanVM> InitializeAsync(Device dev, DeviceBatchContext context) { return(await Task.Run(() => { TheDeviceVM = new DeviceVM(dev, ctx); RunVoltageSweepCommand = AsyncCommand.Create(token => ScanPixelAndProcessData(token)); TheLJVScanSummaryVM = new LJVScanSummaryVM(ctx); TheLJVScanSummaryVM.TheLJVScanSummary.Device = ctx.Devices.Where(x => x.DeviceId == TheDeviceVM.TheDevice.DeviceId).First(); TheLJVScanSummaryVM.TheLJVScanSummary.TestCondition = TheScanSpec.TestCondition; string bts = ConfigurationManager.AppSettings.Get("BatchTestSystem"); if (bts == "BTS2") { TheImagingControl = InstrumentService.LJVScanCoordinator.TheImagingControl; } return this; })); }
public static Task <SingleDeviceScanVM> CreateAsync(Device dev, DeviceBatchContext context) { var ret = new SingleDeviceScanVM(); return(ret.InitializeAsync(dev, context)); }
public CrudVMBase(DeviceBatchContext context) { System.Diagnostics.Debug.WriteLine("CrudVMBase instantiated"); ctx = context; }
protected CrudVMBase(string connString = "ServerConnectionString") { ctx = new DeviceBatchContext(); ctx.Database.Connection.ConnectionString = ConfigurationManager.ConnectionStrings[connString].ConnectionString; }
public LJVScanSummaryVM(DeviceBatchContext context) : base(context) { System.Diagnostics.Debug.WriteLine("LJVScanSummaryVM instantiated"); TheLJVScanSummary = new DeviceLJVScanSummary(); }