/// <summary> /// Получить экземпляры этого класса для определенного типа дефекта /// </summary> /// <param name="cDefect"></param> /// <param name="cGrConstr"></param> /// <returns></returns> internal static List <Ais7DefectParamValue> ReturnDefectParameters(int cDefect, int cGrConstr) { // Запрос получения списка параметров дефекта var query = "select * from s_defparamvalue " + "left outer join s_defparam on s_defparam.c_defparam=s_defparamvalue.c_defparam " + "left outer join s_unit_dimension on s_unit_dimension.c_unit_dimen=s_defparamvalue.c_unit_dimen " + $"where c_defect={cDefect} and c_gr_constr={cGrConstr} " + "order by c_unit_dimen, n"; // Получения таблицы var reader = SqliteReader.SelectQueryReader(query, out var conn); var defectParameters = new List <Ais7DefectParamValue>(); // Пока есть строки - читаем if (reader != null && reader.HasRows) { while (reader.Read()) { var parameter = new Ais7DefectParamValue { Name = reader.GetString(reader.GetOrdinal("N_DEFPARAM")), Category = !reader.IsDBNull(reader.GetOrdinal("CATEGORY")) ? reader.GetInt16(reader.GetOrdinal("CATEGORY")) : (short)(-1), CDefParam = reader.GetInt16(reader.GetOrdinal("C_DEFPARAM")), IsQual = reader.IsDBNull(reader.GetOrdinal("C_UNIT_DIMEN")), B = !reader.IsDBNull(reader.GetOrdinal("B")) ? reader.GetInt16(reader.GetOrdinal("B")) : (short)-1, D = !reader.IsDBNull(reader.GetOrdinal("D")) ? reader.GetInt16(reader.GetOrdinal("D")) : (short)-1, R = !reader.IsDBNull(reader.GetOrdinal("R")) ? reader.GetInt16(reader.GetOrdinal("R")) : (short)-1, G = !reader.IsDBNull(reader.GetOrdinal("B")) && reader.GetBoolean(reader.GetOrdinal("B")), ValueStart = !reader.IsDBNull(reader.GetOrdinal("MIN_VALUE")) ? reader.GetDouble(reader.GetOrdinal("MIN_VALUE")) : double.NaN, ValueEnd = !reader.IsDBNull(reader.GetOrdinal("MAX_VALUE")) ? reader.GetDouble(reader.GetOrdinal("MAX_VALUE")) : double.NaN, MinParamValue = !reader.IsDBNull(reader.GetOrdinal("MIN_V")) ? reader.GetDouble(reader.GetOrdinal("MIN_V")) : 0, MaxParamValue = !reader.IsDBNull(reader.GetOrdinal("MAX_V")) ? reader.GetDouble(reader.GetOrdinal("MAX_V")) : double.MaxValue, SnUnit = !reader.IsDBNull(reader.GetOrdinal("SN_UNIT_DIME")) ? reader.GetString(reader.GetOrdinal("SN_UNIT_DIME")) : null }; parameter.B1 = parameter.B; parameter.D1 = parameter.D; parameter.R1 = parameter.R; parameter.G1 = parameter.G; defectParameters.Add(parameter); } } // Закрываем подключение к БД reader?.Close(); conn.Close(); return(defectParameters); }
/// <inheritdoc /> /// <summary> /// Перечень конструкций для данной ноды /// </summary> /// <param name="cIsso"></param> /// <returns></returns> public override Ais7ConstrItem[] ConstrList(int cIsso) { // Если у нас нет номеров конструкций if (!IsForConstr) { return new Ais7ConstrItem[] { } } ; var ttName = TableName; var cc = new List <Ais7ConstrItem>(); var forceToMake = false; var constrName = NGrConstr; if (allAvailableTables.ToList().IndexOf(TableName) != -1) { ttName = "I_PS"; constrName = "Пролетное строение"; forceToMake = true; } if (!forceToMake && (ParentNode == null || ParentNode.ParentNode != null)) { return ParentNode != null?ParentNode.ConstrList(cIsso) : new Ais7ConstrItem[] { } } ; var driver = Ais7DataTableDriver.Create(ttName); SqliteConnection conn = null; SqliteDataReader dataReader = null; try { dataReader = SqliteReader.SelectQueryReader(driver.GetSql($"c_isso={cIsso}"), out conn); if (!dataReader.HasRows) { return(cc.ToArray()); } while (dataReader.Read()) { cc.Add(Ais7ConstrItem.Create(constrName, dataReader.GetInt16(0))); } } catch (SQLiteException ex) { Debug.WriteLine($"Ошибка при получении списка конструктивов: {ex.Message}, StackTrace: {ex.StackTrace}"); } finally { dataReader?.Close(); dataReader?.Dispose(); conn?.Close(); conn?.Dispose(); } return(cc.ToArray()); }
public TableItemsResponse Items(TableItemsRequest request) { TableItemsResponse response = new TableItemsResponse(); ServerRepository serverRepository = new ServerRepository(); var serverEntity = serverRepository.GetServer(request.ServerName); if (serverEntity == null) { response.Message = "服务器不存在"; return(response); } OpenDBResult openDBResult = TheReaderBase.GetConnection(serverEntity); if (openDBResult.Status != 0) { response.Status = openDBResult.Status; response.Message = openDBResult.Message; return(response); } using (var conn = openDBResult.Connection) { switch (serverEntity.ServerType) { case ServerTypeConstant.Mysql: { var entityList = MysqlReader.GetTableEntityList(conn as MySqlConnection, serverEntity.MysqlDBName); response.TableList = entityList.Select(v => new SchemaTableVo { Name = v.Name }).ToList(); } break; case ServerTypeConstant.Sqlite: { var entityList = SqliteReader.GetTableEntityList(conn as SQLiteConnection); response.TableList = entityList.Select(v => new SchemaTableVo { Name = v.Name }).ToList(); } break; default: { response.Message = "不支持的数据库类型"; return(response); } } } response.Status = 1; return(response); }
public App() { // dependency injection, class needs these things later var reader = new SqliteReader(); var vm = new MainWindowViewModel(reader); this.MainWindow = new MainWindow(vm); MainWindow.Show(); }
/// <summary> /// 取得所有欄位名稱 /// </summary> /// <returns></returns> public string[] GetNames() { string[] res = new string[FieldCount]; for (int i = 0; i < res.Length; i++) { res[i] = SqliteReader.GetName(i); } return(res); }
public Ais7DefectParamValue(int cDefParam) { var query = "select p.c_defparam, N_DEFPARAM, CATEGORY, case when pv.c_unit_dimen='' then 1 else 0 end as IsQual, SN_UNIT_DIME " + "from S_DEFPARAM p left outer join S_DEFPARAMVALUE pv on pv.C_DEFPARAM = p.C_DEFPARAM " + $"left outer join S_UNIT_DIMENSION u on u.C_UNIT_DIMEN = pv.c_unit_dimen where p.C_DEFPARAM={cDefParam} limit 1"; var reader = SqliteReader.SelectQueryReader(query, out var conn); if (reader != null && reader.HasRows) { reader.Read(); Name = reader.GetString(reader.GetOrdinal("N_DEFPARAM")); Category = reader["CATEGORY"] == DBNull.Value ? (short)-1 : Convert.ToInt16(reader["CATEGORY"]); IsQual = Convert.ToInt32(reader["IsQual"]) == 1; SnUnit = IsQual ? "" : Convert.ToString(reader["SN_UNIT_DIME"]); } reader?.Close(); conn.Close(); }
internal ILogReaderV2 GetLogReaderV2Repository() { ILogReaderV2 repo = null; switch (_config.LoggerType) { case LoggingTypeModel.LogOutputType.TextFile: return(null); case LoggingTypeModel.LogOutputType.SQL: repo = new SqlReader(); break; case LoggingTypeModel.LogOutputType.SQLite: repo = new SqliteReader(); break; default: throw new ArgumentOutOfRangeException(); } return(repo); }
public double LoadProperty(SqliteReader reader, int index) { return(reader.ColumnDouble(index)); }
public float LoadProperty(SqliteReader reader, int index) { return((float)reader.ColumnDouble(index)); }
public ushort LoadProperty(SqliteReader reader, int index) { return(unchecked ((ushort)reader.ColumnInt64(index))); }
public int LoadProperty(SqliteReader reader, int index) { return(reader.ColumnInt32(index)); }
public long LoadProperty(SqliteReader reader, int index) { return(reader.ColumnInt64(index)); }
public ulong LoadProperty(SqliteReader reader, int index) { var n = unchecked ((ulong)reader.ColumnInt64(index)); return(n); }
/// <summary> /// 取得所有資料 /// </summary> /// <returns></returns> public object[] GetValues() { object[] res = new object[FieldCount]; SqliteReader.GetValues(res); return(res); }
public T?LoadProperty(SqliteReader reader, int index) { if (reader.IsNull(index)) { return(default);
public string LoadProperty(SqliteReader reader, int index) { return(reader.ColumnText(index) ?? string.Empty); }
public byte[] LoadProperty(SqliteReader reader, int index) { return(reader.ColumnBlob(index).ToArray()); }
public sbyte LoadProperty(SqliteReader reader, int index) { var result = unchecked ((sbyte)reader.ColumnInt64(index)); return(result); }
public byte LoadProperty(SqliteReader reader, int index) { return(unchecked ((byte)reader.ColumnInt64(index))); }