public bool SendBackUp(MyData db) { try { if (!IsConnected) { return(false); } } catch { return(false); } var tmp = Path.GetTempFileName(); try { if (db == null) { SendData("backup", "act", "set").Trim().StartsWith("err"); } else { db.Save(tmp, compressed: true); SendFile("backup", tmp, "act", "set").Trim(); } return(true); } catch { return(false); } finally { try { File.Delete(tmp); } catch { } } }
public void Save(string fileName, bool evenIfEmptye = false, DateTime?start = null, DateTime?end = null, bool compressed = false) { if (ReadOnlyMode) { return; } if (evenIfEmptye || !IsEmpty()) { Serialize(fileName + ".tmp", this, compressed); if (start == null && end == null) { SafelyRename(fileName + ".tmp", fileName); } else { var db = new MyData(); // a clone of data db.Load(fileName + ".tmp", start, end); db.Save(fileName, evenIfEmptye, compressed: compressed); } } }