public static DASDataTable ExecuteQueryForDataTable(this DAS connection, string query) { var table = new DASDataTable(connection); connection.FillDataTable(table, query); return(table); }
protected Database(string password, string username) { _userName = username; _password = password; //create a default DAS in case the Connect was not called... DatabaseObject = new DAS(); }
public void FromDomainObject(DAS.Domain.GoDaddy.Users.GoDaddyAccount account) { AccountID = account.AccountId; GoDaddyUsername = account.Username; GoDaddyPassword = account.Password; Verified = account.Verified; UserID = account.UserID; }
private void convertDataBaseSchemaTo56(DAS database) { //CREATION OF TABLE TAB_TEMPLATE_REFERENCES database.ExecuteSQL("CREATE TABLE TAB_TEMPLATE_REFERENCES (TEMPLATE_TYPE TEXT(50) NOT NULL, NAME TEXT(255) NOT NULL, REFERENCE_TEMPLATE_TYPE TEXT(50) NOT NULL, REFERENCE_NAME TEXT(255) NOT NULL , CONSTRAINT TEMPLATES_PK PRIMARY KEY(TEMPLATE_TYPE, NAME,REFERENCE_TEMPLATE_TYPE, REFERENCE_NAME))"); //CREATION OF INDEXES //CREATION OF REFERENTIAL INTEGRITY database.ExecuteSQL("ALTER TABLE TAB_TEMPLATE_REFERENCES ADD CONSTRAINT RI_TEMPLATE_REFERENCES_1 FOREIGN KEY (TEMPLATE_TYPE,NAME) REFERENCES TAB_TEMPLATES (TEMPLATE_TYPE,NAME) ON UPDATE CASCADE ON DELETE CASCADE"); database.ExecuteSQL("ALTER TABLE TAB_TEMPLATE_REFERENCES ADD CONSTRAINT RI_TEMPLATE_REFERENCES_2 FOREIGN KEY (REFERENCE_TEMPLATE_TYPE,REFERENCE_NAME) REFERENCES TAB_TEMPLATES (TEMPLATE_TYPE,NAME) ON UPDATE CASCADE ON DELETE CASCADE"); }
//@@ Open the external calibrated leak @@// public static void Open_Extleak(int slotNum) { try { DAS.WriteLine("ROUTE:CLOSE (@11{0})", slotNum); } catch (Exception) { throw; } }
//@@ Close External Calibrated leak @@// public static void Close_Extleak(int slotNum) { try { DAS.WriteLine("ROUTE:OPEN (@11{0})", slotNum); } catch (Exception) { throw; } }
private bool needsConverstion(DAS database, string queryToExecute) { try { database.CreateAndFillDataTable(queryToExecute); return(false); } catch (OleDbException) { return(true); } }
//@@ Power ON the UUT @@// public static void DAS_Power_ON(string slotNum) { try { // before power ON make sure that all 4 relays is open DAS_Power_OFF(slotNum); Thread.Sleep(2000); DAS.WriteLine("ROUTe:CLOSE " + Channel); slotNum = null; } catch (Exception) { throw; } }
public void Connect(string databasePath) { //clear any open connection if already open Cleanup(); if (DatabaseObject == null) { DatabaseObject = new DAS(); } if (!FileExists(databasePath)) { throw new Exception($"File does not exist{databasePath}"); } DatabaseObject.Connect(databasePath, _userName, _password, GetProvider()); }
// @@ Measure the DC voltage drop between the black and red wire of the chasis fan connector. The acceptable range is 22.8V ~ 25.2V @@ // public static string Measure_DCV(string channel) { try { DAS.WriteLine("MEASure:VOLT:DC? (@ " + channel + ")"); Thread.Sleep(2000); string retval = DAS.Read(); return(retval); } catch (Exception) { throw; } }
//@@ Measure Resistance between ground blade and test port metal @@// public static string Measure_Resistance(int switching, string res_range) { try { DAS.WriteLine("MEASure:RES? " + res_range + ", (@" + (Res_channel + switching) + ")"); Thread.Sleep(2000); string reading = DAS.Read(); return(reading); } catch (Exception) { throw; } }
private void convertDataBaseSchemaTo53(DAS database) { //SAVE TEMPLATES database.ExecuteSQL("SELECT * INTO SAVED_TEMPLATES FROM TAB_TEMPLATES"); //DROP OLD SCHEMA //DROP OF REFERENTIAL INTEGRITY //DROP OF CONSTRAINT RI_BUILDING_BLOCK_TYPE_METADATA_1 database.ExecuteSQL("ALTER TABLE TAB_BUILDING_BLOCK_TYPE_METADATA DROP CONSTRAINT RI_BUILDING_BLOCK_TYPE_METADATA_1"); //DROP OF CONSTRAINT RI_TEMPLATES_1 database.ExecuteSQL("ALTER TABLE TAB_TEMPLATES DROP CONSTRAINT RI_TEMPLATES_1"); //DROP OF CONSTRAINT RI_TEMPLATE_METADATA_1 database.ExecuteSQL("ALTER TABLE TAB_TEMPLATE_METADATA DROP CONSTRAINT RI_TEMPLATE_METADATA_1"); //DROP OF CONSTRAINT RI_TEMPLATE_METADATA_2 database.ExecuteSQL("ALTER TABLE TAB_TEMPLATE_METADATA DROP CONSTRAINT RI_TEMPLATE_METADATA_2"); //DROP OF CHECK CONSTRAINTS database.ExecuteSQL("ALTER TABLE TAB_TEMPLATE_METADATA DROP CONSTRAINT TEMPLATE_METADATA_C1"); database.ExecuteSQL("ALTER TABLE TAB_TEMPLATES DROP CONSTRAINT TEMPLATES_C1"); //DROP ALL TABLES database.ExecuteSQL("DROP TABLE TAB_BUILDING_BLOCK_TYPES"); database.ExecuteSQL("DROP TABLE TAB_BUILDING_BLOCK_TYPE_METADATA"); database.ExecuteSQL("DROP TABLE TAB_TEMPLATES"); database.ExecuteSQL("DROP TABLE TAB_TEMPLATE_METADATA"); //CREATE NEW SCHEMA //CREATION OF DATABASE SCHEMA TemplateDB //CREATION OF TABLES //CREATION OF TABLE TAB_OBJECT_TYPES database.ExecuteSQL("CREATE TABLE TAB_TEMPLATE_TYPES (TEMPLATE_TYPE TEXT(50) NOT NULL, CONSTRAINT TEMPLATE_TYPES_PK PRIMARY KEY (TEMPLATE_TYPE))"); //CREATION OF TABLE TAB_TEMPLATES database.ExecuteSQL("CREATE TABLE TAB_TEMPLATES (TEMPLATE_TYPE TEXT(50) NOT NULL, NAME TEXT(255) NOT NULL, DESCRIPTION MEMO, XML MEMO NOT NULL, CONSTRAINT TEMPLATES_PK PRIMARY KEY(TEMPLATE_TYPE, NAME))"); //CREATION OF INDEXES //CREATION OF REFERENTIAL INTEGRITY database.ExecuteSQL("ALTER TABLE TAB_TEMPLATES ADD CONSTRAINT RI_TEMPLATES_1 FOREIGN KEY (TEMPLATE_TYPE) REFERENCES TAB_TEMPLATE_TYPES (TEMPLATE_TYPE) ON UPDATE CASCADE"); //RESTORE SAVED TEMPLATES database.ExecuteSQL("INSERT INTO TAB_TEMPLATE_TYPES (TEMPLATE_TYPE) SELECT DISTINCT s.BUILDING_BLOCK_TYPE FROM SAVED_TEMPLATES s"); database.ExecuteSQL("INSERT INTO TAB_TEMPLATES (TEMPLATE_TYPE, NAME, DESCRIPTION, XML) SELECT s.BUILDING_BLOCK_TYPE, s.NAME, s.DESCRIPTION, s.XML FROM SAVED_TEMPLATES s"); //DROP TEMPORARY TABLE database.ExecuteSQL("DROP TABLE SAVED_TEMPLATES"); }
// Hairus added to get more accurate resistance measurement. /// <summary> /// To configure resistance measurement range and resolution for specific channel /// </summary> /// <param name="channel">Channel to be configured</param> /// <param name="range">Resistance range</param> /// <param name="resolution">Resolution</param> public static double Measure_Resistance(int channel, string range, string resolution) { try { int finalChannel = Res_channel + channel; //DAS.WriteLine("ROUTE:SCAN (@)"); DAS.WriteLine("CONF:RES {0},{1},(@{2})", range, resolution, finalChannel); //DAS.WriteLine("ROUT:SCAN (@{0})", channel); //Thread.Sleep(3000); DAS.WriteLine("ROUT:CHAN:DELAY 5"); DAS.WriteLine("INIT"); DAS.WriteLine("FETCH?"); var reading = DAS.ReadNumberAsDouble(); return(reading); } catch (Exception) { throw; } }
//@@ Power OFF the UUT @@// public static void DAS_Power_OFF(string slotNum) { try { string channel = string.Empty; if (slotNum == "1") { channel = "(@101,102,103,104)"; DAS.WriteLine("ROUTe:OPEN " + channel); } else { channel = "(@105,106,107,108)"; DAS.WriteLine("ROUTe:OPEN " + channel); } //DAS.WriteLine("ROUTe:OPEN " + Channel); slotNum = null; } catch (Exception) { throw; } }
private void addReferencesToTemplate(Template template, DAS connection, List <string> loadedReferenceNames = null) { DASDataTable dataTable = null; loadedReferenceNames = loadedReferenceNames ?? new List <string>(); try { addTemplateNameParameter(template.Name, connection); var sqlQuery = string.Format("SELECT ref.{2}, ref.{3} FROM {4} ref WHERE ref.{0} = '{5}' AND ref.{1}={6}", TemplateReferenceTable.Columns.TEMPLATE_TYPE, TemplateReferenceTable.Columns.NAME, TemplateReferenceTable.Columns.REFERENCE_TEMPLATE_TYPE, TemplateReferenceTable.Columns.REFERENCE_NAME, TemplateReferenceTable.NAME, template.TemplateType, _pName); dataTable = connection.ExecuteQueryForDataTable(sqlQuery); } finally { removeNameParameter(connection); } foreach (DASDataRow row in dataTable) { var reference = loadTemplateBy(template.DatabaseType, row.StringAt(TemplateReferenceTable.Columns.REFERENCE_NAME), row.StringAt(TemplateReferenceTable.Columns.REFERENCE_TEMPLATE_TYPE), connection); template.References.Add(reference); if (loadedReferenceNames.Contains(reference.Name)) { continue; } loadedReferenceNames.Add(reference.Name); addReferencesToTemplate(reference, connection, loadedReferenceNames); } }
public DAS.Domain.Users.User SaveAccount(DAS.Domain.Users.User account) { var existingAccountsd = Context.Users.ToList(); var existingAccount = Context.Users.FirstOrDefault(x => x.Username == account.Username); if (existingAccount == null) { var newUser = new Users() { AccessLevel = 0, Password = account.Password, ReceiveEmails = false, UseAccountForSearch = true, UserID = account.AccountID, Username = account.Username }; Context.Users.Add(newUser); Context.Save(); return account; } return new DAS.Domain.Users.User { AccountID = existingAccount.UserID, Password = existingAccount.Password, Username = existingAccount.Username }; }
public static DataRow ExecuteQueryForSingleRowOrNull(this DAS connection, string query) { var rows = ExecuteQueryForDataTable(connection, query).Rows; return(rows.Count() > 0 ? rows.ItemByIndex(0) : null); }
public static DataRow ExecuteQueryForSingleRow(this DAS connection, string query) { return(ExecuteQueryForDataTable(connection, query).Rows.ItemByIndex(0)); }
/// <summary> /// This is the constructor of this class. /// </summary> public DASDataTable(DAS DAS) { m_DAS = DAS; m_Columns = new DASDataColumnCollection(base.Columns); m_Rows = new DASDataRowCollection(base.Rows); }
private static void removeNameParameter(DAS connection) { connection.RemoveParameter(_pName); }
private static void addTemplateNameParameter(string templateName, DAS connection) { connection.AddParameter(_pName, templateName, DAS.ParameterModes.PARM_IN, DAS.ServerTypes.STRING); }
private Template loadTemplateBy(TemplateDatabaseType templateDatabaseType, string templateName, string templateType, DAS connection) { try { addTemplateNameParameter(templateName, connection); var sqlQuery = string.Format("SELECT t.{2} FROM {3} t WHERE t.{0} = '{4}' AND t.{1}={5}", TemplateTable.Columns.TEMPLATE_TYPE, TemplateTable.Columns.NAME, TemplateTable.Columns.DESCRIPTION, TemplateTable.NAME, templateType, _pName); var row = connection.ExecuteQueryForSingleRow(sqlQuery); return(new Template { DatabaseType = templateDatabaseType, TemplateType = EnumHelper.ParseValue <TemplateType>(templateType), Name = templateName, Description = row.StringAt(TemplateTable.Columns.DESCRIPTION) }); } finally { removeNameParameter(connection); } }
private bool needsConversionTo53Format(DAS database) { return(needsConverstion(database, "SELECT COUNT(*) FROM TAB_TEMPLATE_TYPES")); }
public ProteinExpressionQueries(IProteinExpressionDatabase database) { _databaseObject = database.DatabaseObject; }
public GeneExpressionQueries(IGeneExpressionDatabase database) { _databaseObject = database.DatabaseObject; }
//@@ Measure resistance between line blade and neutral blade. The acceptable range is based on model number of the UUT. @@// public static Boolean Measure_Res_LB_NB_ON(string modelnumber, string res_range) { Boolean status = false; DAS.Timeout = 10000; try { //115V, PR02 and PD03 if (modelnumber == "VSPR021" || modelnumber == "VSPD030") { DAS.WriteLine("MEASure:RES? " + res_range + ", (@" + (Res_channel + 4) + ")"); Thread.Sleep(2000); string reading = DAS.Read(); if (Convert.ToDouble(reading) >= 2.0 && Convert.ToDouble(reading) <= 15.0) { status = true; } else { throw new Exception("Measured value out of acceptable range."); } } //230V, PR02 and PD03 else if (modelnumber == "VSPR022" || modelnumber == "VSPD032") { DAS.WriteLine("MEASure:RES? " + res_range + ", (@" + (Res_channel + 4) + ")"); Thread.Sleep(2000); string reading = DAS.Read(); if (Convert.ToDouble(reading) >= 9.2 && Convert.ToDouble(reading) <= 60.0) { status = true; } else { throw new Exception("Measured value out of acceptable range."); } } //115V, MR15 and BR15 else if (modelnumber == "VSMR151" || modelnumber == "VSBR151") { DAS.WriteLine("MEASure:RES? " + res_range + ", (@" + (Res_channel + 4) + ")"); Thread.Sleep(2000); string reading = DAS.Read(); if (Convert.ToDouble(reading) >= 1.0 && Convert.ToDouble(reading) <= 5.0) { status = true; } else { throw new Exception("Measured value out of acceptable range."); } } //230V, MR15 and BR15 else if (modelnumber == "VSMR152" || modelnumber == "VSBR152") { DAS.WriteLine("MEASure:RES? " + res_range + ", (@" + (Res_channel + 4) + ")"); Thread.Sleep(2000); string reading = DAS.Read(); if (Convert.ToDouble(reading) >= 3.2 && Convert.ToDouble(reading) <= 15.0) { status = true; } else { throw new Exception("Measured value out of acceptable range."); } } //115V, MD15, MD30, BD15 and BD30 else if (modelnumber == "VSMD301" || modelnumber == "VSBD301" || modelnumber == "G8601-64004" || modelnumber == "G8602-64004") { DAS.WriteLine("MEASure:RES? " + res_range + ", (@" + (Res_channel + 4) + ")"); Thread.Sleep(2000); string reading = DAS.Read(); if (Convert.ToDouble(reading) >= 0.5 && Convert.ToDouble(reading) <= 1.2) { status = true; } else { throw new Exception("Measured value out of acceptable range."); } } //230V, MD15, MD30, BD15 and BD30 else if (modelnumber == "VSMD302" || modelnumber == "VSBD302" || modelnumber == "G8601-64005" || modelnumber == "G8602-64005") { DAS.WriteLine("MEASure:RES? " + res_range + ", (@" + (Res_channel + 4) + ")"); Thread.Sleep(2000); string reading = DAS.Read(); if (Convert.ToDouble(reading) >= 1.0 && Convert.ToDouble(reading) <= 10.0) { status = true; } else { throw new Exception("Measured value out of acceptable range."); } } else { throw new Exception("Unknown model number."); } } catch (Exception) { throw; } return(status); }
public void SaveGodaddyAccount(DAS.Domain.GoDaddy.Users.GoDaddyAccount account) { var acc = new GoDaddyAccount(); var godaddy = Context.GoDaddyAccount.ToList(); acc.FromDomainObject(account); var existingAccount = Context.GoDaddyAccount.FirstOrDefault(x => x.GoDaddyUsername == account.Username); if (existingAccount != null) { acc.AccountID = Context.Users.First(x=>x.Username == account.Username).UserID; Context.GoDaddyAccount.AddOrUpdate(acc); } else { existingAccount = new GoDaddyAccount { GoDaddyPassword = account.Password, Verified = account.Verified, GoDaddyUsername = account.Username, AccountID = account.AccountId, UserID = account.UserID }; Context.GoDaddyAccount.AddOrUpdate(existingAccount); } Context.Save(); }