// Чтение из таблицы "Входной_буфер" значения самой ранней записи, добавляет в таблицу "В работе" public Result AddNewProduct(out InpProduct productOut) { productOut = null; // Подключение Result result = ConnectDb(_dbPath, out DbCore db); if (result.Error != ResultEnum.No_Error) { return(result); } // Чтение из таблицы "Входной_буфер InpProduct product = null; try { InpBufferTbl tbl = new InpBufferTbl(db); product = tbl.ExtractFirstItem(); // Добавение датчика из таблицы "В работе". Необязательная операция InpToWorkTable(product, db); } catch (Exception e) { result = new Result(ResultEnum.Err_Data_Moves, e); } db.Disconnect(); productOut = product; return(result); }
public Result AlarmClearSystem() { // Подключение Result result = ConnectDb(_dbPath, out DbCore db); if (result.Error != ResultEnum.No_Error) { return(result); } try { InpBufferTbl inpTbl = new InpBufferTbl(db); OutBuffer outTbl = new OutBuffer(db); while (true) { InpProduct product = inpTbl.ExtractFirstItem(); if (product == null) { break; } outTbl.AddProduct(DateTime.Now, product.SN, AlarmSystemErrNymber); } // Очистка таблицы "В работе", необязательная операция ClearWorkTable(db); } catch (Exception e) { result = new Result(ResultEnum.Err_Data_Moves, e); } db.Disconnect(); return(result); }
public InpProduct ExtractRow(string SN) { InpProduct product = GetRow(SN); DeleteRow("[Серийный номер]", base.AddQuotes(SN)); return(product); }
private InpProduct RowToClass(string[] row) { InpProduct inpBuffer = new InpProduct(); inpBuffer.Date = base.DateTimeFromAccess(row[0]); inpBuffer.SN = row[1]; inpBuffer.Device = row[2]; inpBuffer.Name = row[3]; return(inpBuffer); }
public InpProduct ExtractFirstItem() { InpProduct firstItem = this.GetFirstItem(); if (firstItem == null) { return(null); } this.DeleteRow("Номер", AddQuotes(firstItem.SN)); return(firstItem); }
private void InpToWorkTable(InpProduct product, DbCore db) { try { WorkTable workTabl = new WorkTable(db); workTabl.WriteRow(product); } catch (Exception e) { string message = e.Message; //Необязательная операция, добавить в лог программы, если ошибка } }
public InpProduct GetRow(string SN) { string[] strRow = this.ReadRow("[Серийный номер]", AddQuotes(SN)); if (strRow == null) { return(null); } InpProduct product = new InpProduct { Date = base.DateTimeFromAccess(strRow[0]), SN = strRow[1], Device = strRow[2], Name = strRow[3] }; return(product); }
public void WriteRow(InpProduct row) { string[] strRow = this.ReadRow("[Серийный номер]", AddQuotes(row.SN)); if (strRow != null) { DeleteRow("[Серийный номер]", AddQuotes(row.SN)); } else { strRow = new string[4]; } strRow[0] = DateTimeToAccessFormat(row.Date); strRow[1] = AddQuotes(row.SN); strRow[2] = AddQuotes(row.Device); strRow[3] = AddQuotes(row.Name); base.WriteRow(NameTable, strRow); }
private InpProduct GetFirstItem() { List <InpProduct> table = this.GetTable(); if (table == null) { return(null); } if (table.Count == 0) { return(null); } InpProduct firstItem = table[0]; foreach (InpProduct item in table) { if (item.Date < firstItem.Date) { firstItem = item; } } return(firstItem); }