/// <summary> /// The fsync command allows us to flush all pending writes to datafiles. More importantly, it also provides a lock option that makes backups easier. /// </summary> /// <param name="db">The db.</param> /// <param name="asynchronous">if set to <c>true</c> return immediately, regardless of completion status.</param> /// <param name="shouldLock">if set to <c>true</c> will lock the database until it is subsequently unlocked.</param> /// <returns></returns> public static int fsync(this IAdminOperations db, bool asynchronous, bool shouldLock) { DBQuery query = new DBQuery() { {"fsync", 1}, }; if (asynchronous) query.Add("async", true); if (shouldLock) query.Add("lock", true); IDBObject res = db.ExecuteCommand(query); res.ThrowIfResponseNotOK("fsync failed"); return res.GetAsInt("numFiles"); }
/// <summary> /// Copy an entire database from one name on one server to another name on another server. /// </summary> /// <param name="db">The db.</param> /// <param name="fromDatabase">From database.</param> /// <param name="toDatabase">To database.</param> public static void copydb(this IAdminOperations db, IDatabase fromDatabase, IDatabase toDatabase) { DBQuery query = new DBQuery() { {"copydb", 1}, {"fromdb", fromDatabase.Name}, {"todb", toDatabase.Name }, }; if (!fromDatabase.Server.Equals(db.Server)) query.Add("fromhost", fromDatabase.Server.Uri.Authority); IDBObject response = db.ExecuteCommand(query); response.ThrowIfResponseNotOK("copydb failed"); }
public ActionResult AddNews([Bind(Include = "Headline,Body,Author,Image")] Article article, HttpPostedFileBase upload) { var news = new QueryResult { Headline = article.Headline, Body = article.Body, Author = article.Author }; if (upload != null && upload.ContentLength > 0) { using (var reader = new System.IO.BinaryReader(upload.InputStream)) { news.Image = reader.ReadBytes(upload.ContentLength); } } database.Add(news); return(RedirectToAction("Index", "Home")); }