Ejemplo n.º 1
0
 /// <summary>
 /// Adds record to storage
 /// </summary>
 /// <param name="time"></param>
 /// <param name="data"></param>
 /// <returns></returns>
 public bool AddRecord(DateTime time, AtomRec data)
 {
     if (_storageObjectInfo.FileRecords.ContainsKey(time))
     {
         return(false);
     }
     _storageObjectInfo.FileRecords.Add(time, data);
     return(true);
 }
Ejemplo n.º 2
0
        public void SaveData(string objectName, DateTime time, bool isRecordCorrect, int pulseCount1, int pulseCount2,
                             int pulseCount3, int status, int statusX)
        {
            var objInfo = _namedRecs[objectName];
            var record  = new AtomRec {
                IsRecordCorrect = isRecordCorrect,
                PulseCount1     = pulseCount1,
                PulseCount2     = pulseCount2,
                PulseCount3     = pulseCount3,
                Status          = status,
                StatusX         = status
            };

            if (objInfo.AddRecord(time, record))
            {
                var fileLine = (time.Year - 2000).ToString("d2") +
                               time.Month.ToString("d2") +
                               time.Day.ToString("d2") +
                               time.Hour.ToString("d2") +
                               time.Minute.ToString("d2") + "\t" +
                               isRecordCorrect + "\t" +
                               pulseCount1 + "\t" +
                               pulseCount2 + "\t" +
                               pulseCount3 + "\t" +
                               status + "\t" +
                               statusX + "\t" +
                               DateTime.Now.ToString("yyyy.MM.dd-HH:mm:ss");
                using (var sw = File.AppendText(GetObjectFilePath(objectName))) {
                    sw.WriteLine(fileLine);
                    sw.Close();
                }
            }
            else
            {
                Log.Log("Record was not added to storage while trying to save data, but it's may be okay");
            }
        }