/////////////////////// // Command handlers. // /////////////////////// /// <summary> /// Export workspaces. /// </summary> private void HandleExportKws(AnpMsg cmd, AnpMsg res) { int i = 0; UInt64 kwsID = cmd.Elements[i++].UInt64; String destPath = cmd.Elements[i++].String; WmKwsImportExport.ExportKws(destPath, kwsID); }
/// <summary> /// Import workspaces. /// </summary> private void HandleImportKws(AnpMsg cmd, AnpMsg res) { int i = 0; String credString = cmd.Elements[i++].String; XmlDocument doc = new XmlDocument(); doc.LoadXml(credString); WmKwsImportExport.ImportKwsListFromXmlDoc(doc); }
/// <summary> /// Import the workspace list specified. /// </summary> public static void ImportKwsList(String path) { try { WmKwsImportExport.ImportKwsListFromFile(path); } catch (Exception ex) { KBase.HandleException(ex); } }
/// <summary> /// Enter the main mode of the KWM. Return true if the application /// must continue. /// </summary> private static bool EnterMainMode() { // Perform early linking. Wm.LocalDbBroker.Relink(Wm.LocalDb); // FIXME. #if true // Open a temporary console. ConsoleWindow foo = new ConsoleWindow(); foo.Show(); foo.OnConsoleClosing += delegate(Object sender, EventArgs args) { WmSm.RequestStop(); }; // Create an empty database. Wm.LocalDb.DeleteDb(); Wm.LocalDb.OpenOrCreateDb(KwmPath.GetKwmDbPath()); Wm.LocalDbBroker.InitDb(); WmDeserializer ds = new WmDeserializer(); ds.Deserialize(); Debug.Assert(ds.Ex == null); #else // Open or create the database. Wm.LocalDb.OpenOrCreateDb(KwmPath.GetKwmDbPath()); Wm.LocalDbBroker.InitDb(); // Try to deserialize. WmDeserializer ds = new WmDeserializer(); ds.Deserialize(); // The deserialization failed. if (ds.Ex != null) { // If the user doesn't want to recover, bail out. if (!TellUserAboutDsrFailure()) { return(false); } // Backup, delete and recreate a database. BackupDb(); Wm.LocalDb.DeleteDb(); Wm.LocalDb.OpenOrCreateDb(KwmPath.GetKwmDbPath()); Wm.LocalDbBroker.InitDb(); // Retry to deserialize. ds = new WmDeserializer(); ds.Deserialize(); if (ds.Ex != null) { throw ds.Ex; } // Set the next internal workspace ID to a high value based on // the date to avoid conflicts with old KFS directories. ds.WmCd.NextKwsInternalID = (UInt64)(DateTime.Now - new DateTime(2010, 1, 1)).TotalSeconds; } #endif // Relink the workspace manager object graphs. Wm.Relink(ds); // Open the lingering database transaction. Wm.LocalDb.BeginTransaction(); // Serialize the WM state that has changed. Wm.Serialize(); // Export the workspaces, then exit. if (ExportKwsPath != "") { WmKwsImportExport.ExportKws(ExportKwsPath, 0); return(false); } // Set the handle to the message window. SetKwmHandle(MsgWindow.Handle); // Pass the hand to the WM state machine. WmSm.RequestStart(); return(true); }