protected override void DoWork(TreeNode treeNode)
        {
            views.NodeWapper folder = GetData <views.NodeWapper>(treeNode);
            if (null == folder)
            {
                return;
            }

            Form dlg = CreateForm();

reTry:
            if (DialogResult.OK != dlg.ShowDialog())
            {
                return;
            }

            views.NodeWapper newFolder = new views.NodeWapper(GetResult(dlg));
            newFolder.Parent = folder.Id;
            try
            {
                using (IDbSession session = _sessionFactory.NewSession())
                    using (TransactionScope transactionScope = new TransactionScope(session))
                    {
                        session.Insert(_statement, newFolder.GetInstance());
                        transactionScope.VoteCommit();
                    }

                views.TreePage mailPage = treeNode.TreeView as views.TreePage;
                if (null != mailPage)
                {
                    mailPage.InsertNode(treeNode.Nodes, mailPage.CreateNode(newFolder));
                }
                return;
            }
            catch (Exception exception)
            {
                Utils.ShowMsgBox(exception);
            }
            goto reTry;
        }
Example #2
0
        protected override void DoWork(TreeNode treeNode)
        {
            views.NodeWapper folder = GetData <views.NodeWapper>(treeNode);
            if (null == folder)
            {
                return;
            }

            Form dlg = CreateForm(folder.Id);

reTry:
            if (DialogResult.OK != dlg.ShowDialog())
            {
                return;
            }

            object newFolder = GetResult(dlg);

            try
            {
                using (IDbSession session = _sessionFactory.NewSession())
                    using (TransactionScope transactionScope = new TransactionScope(session))
                    {
                        session.Update(_statement, newFolder);
                        transactionScope.VoteCommit();
                    }
            }
            catch (Exception exception)
            {
                Utils.ShowMsgBox(exception);
                goto reTry;
            }

            views.TreePage mailPage = treeNode.TreeView as views.TreePage;
            if (null != mailPage)
            {
                mailPage.BeginUpdate();
                try
                {
                    views.TreePage.ContentNode newFolderNode = mailPage.CreateNode(new views.NodeWapper(newFolder));
                    mailPage.InsertNode((null == treeNode.Parent) ? mailPage.Nodes : treeNode.Parent.Nodes
                                        , newFolderNode);
                    TreeNode[] treeNodes = new TreeNode[treeNode.Nodes.Count];
                    treeNode.Nodes.CopyTo(treeNodes, 0);

                    treeNode.Remove();
                    foreach (TreeNode n in treeNodes)
                    {
                        newFolderNode.Nodes.Add(n);
                    }

                    mailPage.SelectedNode = newFolderNode;
                }
                catch (Exception exception)
                {
                    Utils.ShowMsgBox(exception);
                }
                finally
                {
                    mailPage.EndUpdate();
                }
            }
        }