public static void Do(Action <TableAdapter <T> > action) { using (TableAdapter <T> adapter = TableAdapter <T> .Open(new object[0])) { action(adapter); } }
public static T Read(params object[] args) { using (TableAdapter <T> adapter = TableAdapter <T> .Open()) { return(adapter.Read(args)); } }
public static double GetLambdaValue(Node item) { DbConnection.Initialise(StringConnection); Int64 ID = item.ID_Type; string col = "ID_Type"; { if (ID == 0) { if (item.ID_Scroll == 0) { ID = item.ID_Class; col = "ID_Class"; } else { ID = item.ID_Scroll; col = "ID_Scroll"; } } } using (var value = TableAdapter <Lambda> .Open()) return(value.Select().Where(Where.Equal(col, Convert.ToInt64(ID))).ToList()[0].Value * Math.Pow(10, -6)); }
public virtual void Save() { using (TableAdapter <T> adapter = TableAdapter <T> .Open(new object[0])) { adapter.CreateUpdate(new object[] { this }); } }
public static void Delete(params object[] args) { using (TableAdapter <T> adapter = TableAdapter <T> .Open()) { adapter.Delete(args); } }
public static string GetDefDesign(Node item) { DbConnection.Initialise(StringConnection); using (var rows = TableAdapter <Class> .Open()) { return(rows.Select().First(tbl => (tbl.ID == item.ID_Class)).DefDesign); } }
public IList <ProductCategory> SelectList() { using (DbConnection conn = new DbConnection()) { using (TableAdapter <ProductCategory> adapter = TableAdapter <ProductCategory> .Open()) { return(adapter.Select().ToList()); } } }
public IList <SensorType> SelectList() { using (DbConnection conn = new DbConnection()) { using (TableAdapter <SensorType> adapter = TableAdapter <SensorType> .Open()) { return(adapter.Select().ToList()); } } }
public IList <DataFilter> SelectList() { using (DbConnection conn = new DbConnection()) { using (TableAdapter <DataFilter> adapter = TableAdapter <DataFilter> .Open()) { return(adapter.Select().ToList()); } } }
public IList <ExtractValueName> SelectList() { using (DbConnection conn = new DbConnection()) { using (TableAdapter <ExtractValueName> adapter = TableAdapter <ExtractValueName> .Open()) { return(adapter.Select().ToList()); } } }
public static T Read(params object[] args) { T t; using (TableAdapter <T> adapter = TableAdapter <T> .Open(new object[0])) { t = adapter.Read(args); } return(t); }
public IList <PacketsToSend> SelectAllCacheDataPackets() { using (DbConnection conn = new DbConnection()) { using (TableAdapter <PacketsToSend> adapter = TableAdapter <PacketsToSend> .Open()) { return(adapter.Select().ToList()); } } }
public IList <FormulaInfo> SelectList() { using (DbConnection conn = new DbConnection()) { using (TableAdapter <FormulaInfo> adapter = TableAdapter <FormulaInfo> .Open()) { return(adapter.Select().ToList()); } } }
public System.Collections.Generic.IList <TableFieldInfo> SelectList() { using (DbConnection conn = new DbConnection()) { using (TableAdapter <TableFieldInfo> adapter = TableAdapter <TableFieldInfo> .Open()) { return(adapter.Select().ToList()); } } }
public IList <ExtractionConfig> SelectConfigs() { using (DbConnection conn = new DbConnection()) { using (TableAdapter <ExtractionConfig> adapter = TableAdapter <ExtractionConfig> .Open()) { return(adapter.Select().ToList()); } } }
public static TReturn Get <TReturn>(Func <TableAdapter <T>, TReturn> action) where TReturn : class { TReturn tReturn; using (TableAdapter <T> adapter = TableAdapter <T> .Open(new object[0])) { tReturn = action(adapter); } return(tReturn); }
public virtual int Save() { using (TableAdapter <T> adapter = TableAdapter <T> .Open()) { Int64 i = adapter.CreateUpdate(this); if (i > 0) { return((int)i); } return(0); } }
public static string GetName(Int64 ID) { DbConnection.Initialise(StringConnection); /* List<Scroll> row; * using (var name = TableAdapter<Scroll>.Open()) * row = name.Select().Where(tbl => tbl.ID == Convert.ToInt64(ID)).ToList(); * if (row == null) * return null; * else * return row[0].Name;*/ using (var name = TableAdapter <Scroll> .Open()) return(name.Select().FirstOrDefault(tbl => tbl.ID == Convert.ToInt64(ID)).Name); }
public bool DeleteAllCacheDataPackets() { using (DbConnection conn = new DbConnection()) { using (TableAdapter <PacketsToSend> adapter = TableAdapter <PacketsToSend> .Open()) { try { adapter.DeleteAll(); return(true); } catch { return(false); } } } }
public static ObservableCollection <DataBase.Coefficient> GetCoefficients(Node item, double temperature) { DbConnection.Initialise(StringConnection); ObservableCollection <DataBase.Coefficient> k; using (var adapter = TableAdapter <Coefficient> .Open()) { k = new ObservableCollection <DataBase.Coefficient>(); var rows = adapter.Select().Where(tbl => (tbl.ID_Type == item.ID_Type) || ( (tbl.ID_Type == null) && (tbl.ID_Scroll == item.ID_Scroll)) || ( (tbl.ID_Type == null) && (tbl.ID_Scroll == null) && (tbl.ID_Class == item.ID_Class))).ToList(); for (int i = 0; i < rows.Count; i++) { if ((rows[i].ID_KIndex != 2) && (rows[i].ID_KIndex != 3)) { k.Add(new DataBase.Coefficient(rows[i].ID_KIndex)); } } k = new ObservableCollection <DataBase.Coefficient>(k.Distinct()); } using (var adapter = TableAdapter <Info> .Open()) for (int i = 0; i < k.Count; i++) { k[i].Info = adapter.Select().Where(tbl => tbl.ID_KIndex == Convert.ToInt64(k[i].ID_KIndex)).ToList(); } using (var adapter = TableAdapter <KIndex> .Open()) for (int i = 0; i < k.Count; i++) { var row = adapter.Select().First(tbl => tbl.ID == Convert.ToInt64(k[i].ID_KIndex)); k[i].Name = row.Name; k[i].ParamName = row.ParamName; k[i].ParamDiscription = row.ParamDiscription; k[i].Discription = row.Discription; k[i].ID = item; k[i].Temperature = temperature; } return(k); }
public static List <Node> GetItems() { DbConnection.Initialise(StringConnection); var nodes = new List <Node>(); using (var adapter = TableAdapter <Class> .Open()) { foreach (var rows in adapter.Select()) { var row = (Class)rows; nodes.Add(new Node() { ID_Class = row.ID, Name = row.Name, DefDesign = row.DefDesign }); } } return(nodes); }
public static ObservableCollection <Node> GetItems(int ID_Class) { DbConnection.Initialise(StringConnection); var nodes = new ObservableCollection <Node>(); using (var adapter = TableAdapter <Scroll> .Open()) { foreach (var rows in adapter.Select().Where(tbl => tbl.ID_Class == Convert.ToInt64(ID_Class))) { var row = (Scroll)rows; nodes.Add(new Node() { ID_Class = ID_Class, ID_Scroll = row.ID, Name = row.Name }); } } return(nodes); }
public static DataBase.Coefficient GetCoefficient(long idOfIndex) { DbConnection.Initialise(StringConnection); var k = new DataBase.Coefficient(); using (var adapter = TableAdapter <Info> .Open()) k.Info = adapter.Select().Where(tbl => tbl.ID_KIndex == Convert.ToInt64(idOfIndex)).ToList(); using (var adapter = TableAdapter <KIndex> .Open()) { var row = adapter.Select().First(tbl => tbl.ID == Convert.ToInt64(idOfIndex)); k.Name = row.Name; k.ParamName = row.ParamName; k.ParamDiscription = row.ParamDiscription; k.Discription = row.Discription; k.ID_KIndex = idOfIndex; } return(k); }
public static string GetMathModel(Node item) { DbConnection.Initialise(StringConnection); List <MathModels> MathModel = null; using (var rows = TableAdapter <MathModels> .Open()) { MathModel = rows.Select().Where(tbl => (tbl.ID_Class == item.ID_Class) && (tbl.ID_Scroll == item.ID_Scroll) && (tbl.ID_Type == item.ID_Type)).ToList(); if (MathModel.Count == 0) { MathModel = rows.Select().Where(tbl => (tbl.ID_Class == item.ID_Class) && (tbl.ID_Scroll == item.ID_Scroll)).ToList(); } } return(MathModel[0].MathModel); }
public T Get() { using (TableAdapter <T> adapter = TableAdapter <T> .Open()) { // Create //adapter.CreateUpdate(1, "Hello world!"); // Read T value = adapter.Select().First(); return((T)Convert.ChangeType(value, typeof(T))); //// Update //row.Test = "Cheese"; //adapter.CreateUpdate(row); //// Delete //adapter.Delete(row1); } //return value; }
public static string GetName(Int64 ID) { DbConnection.Initialise(StringConnection); /* List<Type> row; * using (var name = TableAdapter<Type>.Open()) * row = name.Select().Where(tbl => tbl.ID == Convert.ToInt64(ID)).ToList(); * if (row.Count == 0) * return null; * * return row[0].Name;*/ try { using (var name = TableAdapter <Type> .Open()) return(name.Select().FirstOrDefault(tbl => tbl.ID == Convert.ToInt64(ID)).Name); } catch (Exception) { return(null); } }
public static double GetCoefficientValue(DataBase.Coefficient coeff) { DbConnection.Initialise(StringConnection); Int64 infoId = 0; double value = 0; List <Coefficient> rows; Double.TryParse(coeff.SelectedParamValue, out value); if (coeff.Info.Count != 0) { using (var adapter = TableAdapter <Info> .Open()) infoId = adapter.Select().First(tbl => (tbl.ID_KIndex == coeff.ID_KIndex) && (tbl.Discription == coeff.SelectedParamValue)).ID; } Node item = coeff.ID; using (var adapter = TableAdapter <Tables.Coefficient> .Open()) rows = adapter.Select().Where(tbl => (tbl.ID_KIndex == coeff.ID_KIndex) && ((tbl.ID_Type == item.ID_Type) || ( (tbl.ID_KIndex == coeff.ID_KIndex) && (tbl.ID_Type == null) && (tbl.ID_Scroll == item.ID_Scroll)) || ( (tbl.ID_KIndex == coeff.ID_KIndex) && (tbl.ID_Type == null) && (tbl.ID_Scroll == null) && (tbl.ID_Class == item.ID_Class)) )).ToList(); if (infoId != 0) { foreach (var row in rows) { if (row.Info == infoId) { return(row.Value); } } } if (rows.FirstOrDefault(r => r.MathModel != null) != null) { Kmodel m; using (var adapter = TableAdapter <Kmodel> .Open()) m = adapter.Select().FirstOrDefault(tbl => (tbl.ID_KIndex == coeff.ID_KIndex) && ((tbl.ID_Type == item.ID_Type) || ( (tbl.ID_KIndex == coeff.ID_KIndex) && (tbl.ID_Type == null) && (tbl.ID_Scroll == item.ID_Scroll)) || ( (tbl.ID_KIndex == coeff.ID_KIndex) && (tbl.ID_Type == null) && (tbl.ID_Scroll == null) && (tbl.ID_Class == item.ID_Class)) )); if (m == null) { m = new Kmodel(); } ExpressionContext context = new ExpressionContext(); context.Imports.AddType(typeof(Math)); List <string> s = context.Variables.Keys.ToList(); context.Variables["A"] = m.A; context.Variables["Ns"] = m.Ns; context.Variables["B"] = m.B; context.Variables["Nt"] = m.Nt; context.Variables["G"] = m.G; context.Variables["t"] = coeff.Temperature; context.Variables["H"] = m.H; context.Variables["value"] = value; context.Variables["J"] = m.J; IDynamicExpression eDynamic = context.CompileDynamic(rows[0].MathModel); var x = (double)eDynamic.Evaluate(); return(x); } if (rows.FirstOrDefault(r => (r.ParamMin != 0) || (r.ParamMax != 0)) != null) { foreach (var row in rows) { if ((row.ParamMax == 0) && (row.ParamMin > 0)) { row.ParamMax = double.MaxValue; } if ((row.ParamMin <= value) && (value < row.ParamMax)) { return(row.Value); } } } if (rows.FirstOrDefault(r => r.ParamFix != 0) != null) { foreach (var row in rows) { if (row.ParamFix != value) { return(row.Value); } } } return(value); }