示例#1
0
        public void saveFile(IRimRecords records, String dbFilename)
        {
            logger.LogStatus("Saving database to " + dbFilename);
            setProgress("Saving database to " + dbFilename);
            IRimRecord r = records.FindRecord(RECORD_DATABASE);
            int fc = r.fields.Count;
            if (fc < 2) return;

            IRimFields fds = r.fields.FindFields(FIELD_TYPE_DATA);
            IEnumerator enu = fds.GetEnumerator();
            FileStream fs = File.Open(dbFilename + ".tmp", FileMode.Create);
            BinaryWriter bw = new BinaryWriter(fs);
            while (enu.MoveNext())
            {
                IRimField f = (IRimField)enu.Current;
                bw.Write((byte[])f.value);
            }
            bw.Close();
            fs.Close();
            File.Replace(dbFilename + ".tmp", dbFilename, dbFilename + ".bak");
        }
示例#2
0
 public StatusMessage getStatusMessage(IRimRecords records)
 {
     setProgress("Receiving status message");
     IRimRecord r = records.FindRecord(RECORD_MESSAGE);
     IRimField f = r.fields.FindField(FIELD_RC);
     StatusMessage sm = new StatusMessage();
     sm.rc = BitConverter.ToInt32((byte[])f.value, 0);
     f = r.fields.FindField(FIELD_MSG);
     sm.msg = System.Text.Encoding.ASCII.GetString((byte[])f.value);
     return sm;
 }