Пример #1
0
        void ChangeSelector(object o)
        {
            string newSelector = o as string;

            try
            {
                Codice.Client.Commands.TreeContent treeContent =
                    mPlasticApi.GetSelectorContent(newSelector);

                if (treeContent == null)
                {
                    mLog.ErrorFormat("Can't load selector [{0}]", newSelector);
                    return;
                }

                WorkspaceContent newContent = CreateWorkspaceContentFromSelector.Create(
                    DateTime.Now, treeContent);

                Node newTree = MergeWorkspaceTree.MergeNewTreeWithPrivates(
                    DateTime.Now, newContent.GetTree(), GetRoot());

                lock (this)
                {
#warning check the csetId
                    mWorkspaceContent.ChangeTree(newTree);
                }

                mLog.InfoFormat("Selector correctly changed to {0}", newSelector);
            }
            catch (Exception e)
            {
                mLog.ErrorFormat("Can't load selector [{0}]. Error loading {1}",
                                 newSelector, e.Message);
            }
        }
Пример #2
0
        void ReloadWkTree(object o)
        {
            uint nodeId = (uint)o;

            int handle = -1;
            WorkspaceContent newContent = null;

            try
            {
                handle = mLocalFiles.OpenFile(
                    nodeId,
                    "plastic.wktree.data",
                    FileAccess.Read,
                    FileShare.Read,
                    FileMode.Open,
                    FileOptions.None);

                FileStream st = mHandles.GetStream(handle);

                newContent = DeserializeWorkspaceContentAsPlasticDriveTree.Deserialize(
                    DateTime.Now, st);
            }
            catch (Exception e)
            {
                mLog.ErrorFormat("ReloadWkTree found error: {0}", e.Message);

                return;
            }
            finally
            {
                if (handle != -1)
                {
                    mHandles.Close(handle);
                }
            }

            try
            {
                mLocalFiles.Delete(nodeId);

                Node newTree = MergeWorkspaceTree.MergeNewTreeWithPrivates(
                    DateTime.Now, newContent.GetTree(), GetRoot());

                lock (this)
                {
#warning check the csetId
                    mWorkspaceContent.ChangeTree(newTree);
                }

                mLog.Info("plastic.wktree reloaded from disk");
            }
            catch (Exception e)
            {
                mLog.ErrorFormat("Error in ReloadWkTree {0}", e.Message);
            }
        }