Esempio n. 1
0
        public static void Relink(WmDeserializer ds)
        {
            Cd = ds.WmCd;
            WmSm.Relink();
            KcdBroker.OnEvent            += WmSm.HandleKcdBrokerNotification;
            KmodBroker.OnThreadCollected += WmSm.OnThreadCollected;
            EAnpBroker.OnClose           += WmSm.OnThreadCollected;
            EAnpBroker.OnChannelOpen     += WmEAnp.HandleChannelOpen;

            foreach (UInt64 internalID in ds.KwsCdList.Keys)
            {
                Workspace   kws   = new Workspace();
                KwsCoreData kwsCd = ds.KwsCdList[internalID];
                kws.Relink(internalID, kwsCd);
            }

            AdjustPublicKwsID();
        }
Esempio n. 2
0
        public static void Relink(WmDeserializer ds)
        {
            Cd = ds.WmCd;
            WmSm.Relink();
            KcdBroker.OnEvent += WmSm.HandleKcdBrokerNotification;
            KmodBroker.OnThreadCollected += WmSm.OnThreadCollected;
            EAnpBroker.OnClose += WmSm.OnThreadCollected;
            EAnpBroker.OnChannelOpen += WmEAnp.HandleChannelOpen;

            foreach (UInt64 internalID in ds.KwsCdList.Keys)
            {
                Workspace kws = new Workspace();
                KwsCoreData kwsCd = ds.KwsCdList[internalID];
                kws.Relink(internalID, kwsCd);
            }

            AdjustPublicKwsID();
        }
Esempio n. 3
0
        /// <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;
        }
Esempio n. 4
0
        /// <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);
        }