Beispiel #1
0
        /// <summary>
        /// Create a new workspace having the credentials specified and insert
        /// it in the workspace manager, with the current task Stop.
        /// </summary>
        public static Workspace CreateWorkspace(KwsCredentials creds)
        {
            try
            {
                // Clear the public flag if we already have a public workspace.
                if (Cd.PublicKwsID != 0)
                {
                    creds.PublicFlag = false;
                }

                // Get a new internal ID.
                UInt64 internalID = Cd.NextKwsInternalID++;

                // Register the worskpace in the workspace manager.
                KwsCoreData kwsCd = new KwsCoreData();
                kwsCd.Credentials = creds;
                Workspace kws = new Workspace();
                kws.Relink(internalID, kwsCd);
                AdjustPublicKwsID();

                // Insert the workspace in the workpace list in the database.
                LocalDbBroker.AddKwsToKwsList(kws.InternalID, kws.Cd.Credentials.KwsName);

                // The WM state has changed.
                Wm.OnStateChange(WmStateChange.Permanent);

                return(kws);
            }

            catch (Exception ex)
            {
                KBase.HandleException(ex, true);
                return(null);
            }
        }
Beispiel #2
0
 private void SaveLocation(Point loc)
 {
     if (loc.Equals(Wm.Cd.VncOverlayLoc))
     {
         return;
     }
     Wm.Cd.VncOverlayLoc = loc;
     Wm.OnStateChange(WmStateChange.Internal);
 }
Beispiel #3
0
        /// <summary>
        /// Remove the workspace object from the workspace manager. Used by the
        /// WM state machine.
        /// </summary>
        public static void RemoveWorkspace(Workspace kws)
        {
            try
            {
                WmKcd kcd = kws.Kcd;

                // Make sure the state is valid.
                Debug.Assert(KwsTree.ContainsKey(kws.InternalID));
                if (kcd != null)
                {
                    Debug.Assert(kcd.KwsTree.ContainsKey(kws.InternalID));
                    Debug.Assert(!kcd.KwsConnectTree.ContainsKey(kws.InternalID));
                }

                // Unregister the workspace from the workspace manager.
                KwsTree.Remove(kws.InternalID);
                if (KwsRemoveTree.ContainsKey(kws.InternalID))
                {
                    KwsRemoveTree.Remove(kws.InternalID);
                }
                if (kcd != null)
                {
                    kcd.CancelKwsKcdQuery(kws);
                    kcd.KwsTree.Remove(kws.InternalID);
                    RemoveKcdIfNoRef(kcd);
                }
                AdjustPublicKwsID();

                // Delete the workspace data.
                kws.PrepareToRemove();
                foreach (KwsApp app in kws.AppTree.Values)
                {
                    app.PrepareToRemove();
                }

                // The WM state has changed.
                Wm.OnStateChange(WmStateChange.Permanent);
            }

            catch (Exception ex)
            {
                KBase.HandleException(ex, true);
            }
        }
Beispiel #4
0
        /// <summary>
        /// Update and return the freshness time.
        /// </summary>
        public UInt64 UpdateFreshnessTime()
        {
            DateTime now       = DateTime.Now;
            Int64    offset    = (Int64)(now - FreshnessDate).TotalMilliseconds;
            Int64    maxOffset = 24 * 60 * 60 * 1000;

            if (offset < 0)
            {
                offset = 0;
            }
            else if (offset > maxOffset)
            {
                offset = maxOffset;
            }
            FreshnessDate  = now;
            FreshnessTime += (UInt64)offset;
            Wm.OnStateChange(WmStateChange.Internal);
            return(FreshnessTime);
        }
Beispiel #5
0
        /// <summary>
        /// Import the workspace folder list specified.
        /// </summary>
        public static void ImportFolderList(List <WmKwsFolder> folderList)
        {
            // Import the missing folders. Update the ET blob of existing folders.
            foreach (WmKwsFolder f in folderList)
            {
                bool foundFlag = false;
                foreach (WmKwsFolder g in Wm.Cd.KwsFolderList)
                {
                    if (g.FullPath == f.FullPath)
                    {
                        foundFlag = true;
                        g.EtBlob  = f.EtBlob;
                        break;
                    }
                }
                if (!foundFlag)
                {
                    Wm.Cd.KwsFolderList.Add(f);
                }
            }

            // The WM state has changed.
            Wm.OnStateChange(WmStateChange.Permanent);
        }