//--------------------------------------------------------------------------- #endregion //--------------------------------------------------------------------------- #region Constructors //--------------------------------------------------------------------------- /// <summary> /// Конструктор /// </summary> public File() { _Number = 0; _Description = String.Empty; _Device = null; _RecordsCollection = new RecordsCollection(); }
public void ReplaceMachineRecrod(MachineRecord r, RecordsCollection recordsCollection) { if (r != null) { IMongoCollection <MachineRecord> collection; if (recordsCollection == RecordsCollection.Normal) { var filter = Builders <MachineRecord> .Filter.Eq(e => e.id, r.id); collection = _database.GetCollection <MachineRecord>(Collections.machine_records.ToString()); collection.ReplaceOne(filter, r); } else if (recordsCollection == RecordsCollection.Others) { var filter = Builders <MachineRecord> .Filter.Eq(e => e.id, r.id); collection = _database.GetCollection <MachineRecord>(Collections.machine_records_other.ToString()); collection.ReplaceOne(filter, r); } else { throw new ArgumentException(); } } }
public IEnumerable <MachineRecord> GetAllReports(RecordsCollection collectionType, string serialNumber = null) { string col = RecordsCollection.Normal.ToString(); switch (collectionType) { case RecordsCollection.Normal: col = Collections.machine_records.ToString(); break; case RecordsCollection.Others: col = Collections.machine_records_other.ToString(); break; case RecordsCollection.Both: return(GetAllReports(RecordsCollection.Normal, serialNumber).Concat(GetAllReports(RecordsCollection.Others, serialNumber))); } IMongoCollection <MachineRecord> mongoCollection = _database.GetCollection <MachineRecord>(col); if (string.IsNullOrEmpty(serialNumber)) { return(mongoCollection.Find(emptyFilter => true).ToList()); } FilterDefinition <MachineRecord> filter = Builders <MachineRecord> .Filter.Eq(e => e.serial_number, serialNumber); return(mongoCollection.Find(filter).ToList()); }
//--------------------------------------------------------------------------- /// <summary> /// Конструктор /// </summary> /// <param name="number">Номер файла</param> /// <param name="description">Описание файла</param> public File(UInt16 number, String description) { Number = number; if (description == null) { _Description = String.Empty; } else { _Description = description; } _Device = null; _RecordsCollection = new RecordsCollection(); }
//static public List<Client> getAllClients() //{ // MongoCollection<Client> collection = database.GetCollection<Client>(Collections.clients.ToString()); // MongoCursor<Client> all = collection.FindAll(); // List<Client> list = new List<Client>(); // foreach (Client c in all) // { // list.Add(c); // } // return list; //} static internal List <MachineRecord> GetAllReports(RecordsCollection collectionType) { switch (collectionType) { case RecordsCollection.Normal: return(GetMachineRecordList(database.GetCollection <MachineRecord>(Collections.machine_records.ToString()))); case RecordsCollection.Others: return(GetMachineRecordList(database.GetCollection <MachineRecord>(Collections.machine_records_other.ToString()))); case RecordsCollection.Both: List <MachineRecord> list = GetAllReports(RecordsCollection.Normal); list.AddRange(GetAllReports(RecordsCollection.Others)); return(list); default: throw new ArgumentOutOfRangeException(nameof(collectionType), collectionType, null); } }
public static List <MachineRecord> GetReports(string serial_number, RecordsCollection collectionType) { switch (collectionType) { case RecordsCollection.Normal: return(GetReportsCollection( database.GetCollection <MachineRecord>(Collections.machine_records.ToString()), serial_number)); case RecordsCollection.Others: return(GetReportsCollection( database.GetCollection <MachineRecord>(Collections.machine_records_other.ToString()), serial_number)); case RecordsCollection.Both: List <MachineRecord> list = GetReports(serial_number, RecordsCollection.Normal); list.AddRange(GetReports(serial_number, RecordsCollection.Others)); return(list); default: throw new ArgumentOutOfRangeException(nameof(collectionType), collectionType, null); } }
public void AddUpdateExecutionRecord(ExecutionRecordClass rec) { try { Application.Current.Dispatcher.Invoke(delegate { ExecutionRecordClass r = RecordsCollection.FirstOrDefault <ExecutionRecordClass>(record => record.ExecutionLineID == rec.ExecutionLineID); if (r != null) { r.MM = rec.MM; r.Sent = rec.Sent; r.Name = rec.Name; r.Type = rec.Type; OnPropertyChanged("RecordsCollection"); } else { RecordsCollection.Add(rec); OnPropertyChanged("RecordsCollection"); } }); } catch (Exception ex) { Console.WriteLine("Unmanaged error. " + ex.Message); } }