Exemplo n.º 1
0
        /// <summary>
        /// 右键文档夹菜单事件
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void contextMenuFiles_ItemClicked(object sender, ToolStripItemClickedEventArgs e)
        {
            this.contextMenuFiles.Visible = false;
            if (e.ClickedItem.Name == "cutFileItem")
            {
                // 剪切
                cutNode = node;
                this.cutFileItem.Enabled      = false;
                this.cutItem.Enabled          = false;
                this.copyDocClassItem.Enabled = false;
                this.pasteItem.Enabled        = true;
            }
            else if (e.ClickedItem.Name == "pasteItem")
            {
                // 粘贴
                if (cutNode.Tag.GetType() == typeof(document))
                {
                    // 更新后台的数据
                    document doc = ((document)cutNode.Tag);
                    doc.document_type_id   = ((document_tree)node.Tag).id;
                    doc.document_type_name = ((document_tree)node.Tag).name;
                    // 调用接口来更新后台数据


                    //粘贴的当前节点添加
                    DevExpress.XtraTreeList.Nodes.TreeListNode tns = node.TreeList.AppendNode(doc.id, node);
                    tns.SetValue(DocName, doc.cn_name);
                    tns.SetValue(DocID, doc.id);
                    tns.SetValue(DocType, "File");
                    tns.Tag = doc;
                    //剪切的当前节点减少
                    this.treeList1.DeleteNode(cutNode);
                }
                else
                {
                    document_tree docTree = (document_tree)cutNode.Tag;
                    docTree.parent_id   = ((document_tree)node.Tag).id;
                    docTree.parent_name = ((document_tree)node.Tag).name;
                    // 调用接口来更新后台数据

                    //粘贴的当前节点添加
                    DevExpress.XtraTreeList.Nodes.TreeListNode tns = node.TreeList.AppendNode(docTree.id, node);
                    tns.SetValue(DocName, docTree.name);
                    tns.SetValue(DocID, docTree.id);
                    tns.SetValue(DocType, "Files");
                    tns.ImageIndex = 0;
                    tns.Tag        = docTree;
                    GetCentralChild(tns, docTree.id, docTree.all_name);
                    //剪切的当前节点减少
                    this.treeList1.DeleteNode(cutNode);
                }

                this.cutFileItem.Enabled      = true;
                this.cutItem.Enabled          = true;
                this.copyDocClassItem.Enabled = true;
                this.pasteItem.Enabled        = false;
            }
            else if (e.ClickedItem.Name == "copyDocClassItem")
            {
                // 复制文档分类
                this.cutFileItem.Enabled      = false;
                this.cutItem.Enabled          = false;
                this.copyDocClassItem.Enabled = false;
                this.pasteItem.Enabled        = true;
            }
            else if (e.ClickedItem.Name == "expandAllItem")
            {
                // 展开
                node.ExpandAll();
            }
            else if (e.ClickedItem.Name == "collapseAllItem")
            {
                // 折叠
                treeList1.CollapseAll();
            }
            else if (e.ClickedItem.Name == "loadingItem")
            {
                // 加载文档
                //	加载文档是指将该分类的分类和文档呈树形显示供查看其中内容;
            }
            else if (e.ClickedItem.Name == "addDocItem")
            {
                // 录入已有文档
                //	录入已有文档是指将本地已完成的文档录入到PDM系统中;
                document document = new document();
                document.document_type_id   = ((document_tree)node.Tag).id;
                document.document_type_name = ((document_tree)node.Tag).all_name;
                DocModify docModify = new DocModify(document, 1);
                if (DialogResult.OK == docModify.ShowDialog())
                {
                    DevExpress.XtraTreeList.Nodes.TreeListNode tns = node.TreeList.AppendNode(docModify.docSave.id, node);
                    tns.SetValue(DocName, docModify.docSave.cn_name);
                    tns.SetValue(DocID, docModify.docSave.id);
                    tns.SetValue(DocType, "Files");
                    tns.Tag = docModify.docSave;
                    // 修改文档成功!
                    MessageBox.Show("创建成功!");
                }
            }
            else if (e.ClickedItem.Name == "importItem")
            {
                // 批量导入文档
                //	文档批量导入是指将本地已完成的多个文档一次录入到PDM系统中;
                DocBulkImport import = new DocBulkImport((document_tree)node.Tag);
                if (DialogResult.OK == import.ShowDialog())
                {
                    // 批量导入成功!
                }
            }
            else if (e.ClickedItem.Name == "downDocItem")
            {
                // 下载
                // 打开文件夹
                FolderBrowserDialog dlg = new FolderBrowserDialog();
                if (dlg.ShowDialog() == DialogResult.OK)
                {
                    // 开启socket文件
                    SocketServer s = new SocketServer("127.0.0.1", 7774, dlg.SelectedPath + "\\");
                    s.start();
                    var files = from d in doclist where d.document_type_id != 0 && d.document_type_id == ((document_tree)node.Tag).id select d;
                    if (files.Count() < 1)
                    {
                        return;
                    }
                    List <document> list = new List <document>();
                    foreach (document st in files)
                    {
                        st.ipaddress = "127.0.0.1";
                        st.port      = 7774;
                        list.Add(st);
                    }
                    bool flag = WcfServiceLocator.Create <IDocManageTool>().downDocumentAll(list);
                    while (!(flag && s.flag))
                    {
                        System.Threading.Thread.Sleep(1000);
                    }
                    s.lisner.Stop();
                    s.TempThread.Abort();
                }
            }
            else if (e.ClickedItem.Name == "updateDocTreeStatusItem")
            {
                // 更新文档状态
                //	更新文档状态是指将该分类下文档状态已改变而显示界面上无变化时,点击改变界面显示;
            }
            else if (e.ClickedItem.Name == "grantDocItem")
            {
                // 发放文档
                //
            }
            else if (e.ClickedItem.Name == "permissionApplyDocItem")
            {
                // 申请权限
            }
            else if (e.ClickedItem.Name == "scanDocGrantRItem")
            {
                // 查看文档发放规则
            }
            else if (e.ClickedItem.Name == "addDocTreeItem")
            {
                // 增加文档分类
                document_tree doct = new document_tree();
                doct.parent_id   = ((document_tree)node.Tag).id;
                doct.parent_name = ((document_tree)node.Tag).name;
                BuildDocCategory docCat = new BuildDocCategory(doct, 1);
                if (docCat.ShowDialog() == DialogResult.OK)
                {
                    DevExpress.XtraTreeList.Nodes.TreeListNode tns = node.TreeList.AppendNode(docCat.docTree.id, node);
                    tns.SetValue(DocName, docCat.docTree.name);
                    tns.SetValue(DocID, docCat.docTree.id);
                    tns.SetValue(DocType, "Files");
                    docCat.docTree.all_name = ((document_tree)(node.Tag)).all_name + @"\" + docCat.docTree.name;
                    tns.Tag = docCat.docTree;
                    // 添加成功!
                }
            }
            else if (e.ClickedItem.Name == "updatedocTreeItem")
            {
                // 修改文档分类
                document_tree docType = new document_tree();
                docType.parent_id   = ((document_tree)node.Tag).parent_id;
                docType.parent_name = ((document_tree)node.Tag).parent_name;
                docType.id          = ((document_tree)node.Tag).id;
                docType.name        = ((document_tree)node.Tag).name;
                BuildDocCategory docCat = new BuildDocCategory(docType, 2);
                if (docCat.ShowDialog() == DialogResult.OK)
                {
                    // 修改成功!
                    ((document_tree)node.Tag).name = docCat.docTree.name;
                    node.SetValue(DocName, docCat.docTree.name);
                }
            }
            else if (e.ClickedItem.Name == "delDocTreeItem")
            {
                // 删除文档分类
                if (MessageBox.Show("确认删除?", "警告", MessageBoxButtons.OKCancel, MessageBoxIcon.Question) == DialogResult.OK)
                {
                    bool flag = WcfServiceLocator.Create <IDocManageTool>().delDocumentTree((document_tree)node.Tag);
                    if (flag)
                    {
                        // 删除文件夹
                        this.treeList1.DeleteNode(node);
                    }
                }
            }
            else if (e.ClickedItem.Name == "scanDocTypeItem")
            {
                // 查看文档分类
                document_tree docType = new document_tree();
                docType.parent_id   = ((document_tree)node.Tag).parent_id;
                docType.parent_name = ((document_tree)node.Tag).parent_name;
                docType.id          = ((document_tree)node.Tag).id;
                docType.name        = ((document_tree)node.Tag).name;
                BuildDocCategory docCat = new BuildDocCategory(docType, 3);
                docCat.ShowDialog();
            }
            else if (e.ClickedItem.Name == "execlEmportItem")
            {
                // excel导出
            }
            else if (e.ClickedItem.Name == "userImportItem")
            {
                // 自定义导出
            }
            else if (e.ClickedItem.Name == "docCountStaItem")
            {
                // 文档数量统计,统计该节点下文件的数目
                int count = GetChildNodes(node);
                MessageBox.Show("共有文档" + count + "个");
            }
        }
Exemplo n.º 2
0
        /// <summary>
        /// 右键文档夹菜单事件
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void contextMenuFiles_ItemClicked(object sender, ToolStripItemClickedEventArgs e)
        {
            this.contextMenuFiles.Visible = false;
            if (e.ClickedItem.Name == "cutFileItem")
            {
                // 剪切
                cutNode = node;
                this.cutFileItem.Enabled = false;
                this.cutItem.Enabled = false;
                this.copyDocClassItem.Enabled = false;
                this.pasteItem.Enabled = true;
            }
            else if (e.ClickedItem.Name == "pasteItem")
            {
                // 粘贴
                if (cutNode.Tag.GetType() == typeof(document))
                {
                    // 更新后台的数据
                    document doc = ((document)cutNode.Tag);
                    doc.document_type_id = ((document_tree)node.Tag).id;
                    doc.document_type_name = ((document_tree)node.Tag).name;
                    // 调用接口来更新后台数据

                    //粘贴的当前节点添加
                    DevExpress.XtraTreeList.Nodes.TreeListNode tns = node.TreeList.AppendNode(doc.id, node);
                    tns.SetValue(DocName, doc.cn_name);
                    tns.SetValue(DocID, doc.id);
                    tns.SetValue(DocType, "File");
                    tns.Tag = doc;
                    //剪切的当前节点减少
                    this.treeList1.DeleteNode(cutNode);
                }
                else
                {
                    document_tree docTree = (document_tree)cutNode.Tag;
                    docTree.parent_id = ((document_tree)node.Tag).id;
                    docTree.parent_name = ((document_tree)node.Tag).name;
                    // 调用接口来更新后台数据

                    //粘贴的当前节点添加
                    DevExpress.XtraTreeList.Nodes.TreeListNode tns = node.TreeList.AppendNode(docTree.id, node);
                    tns.SetValue(DocName, docTree.name);
                    tns.SetValue(DocID, docTree.id);
                    tns.SetValue(DocType, "Files");
                    tns.ImageIndex = 0;
                    tns.Tag = docTree;
                    GetCentralChild(tns, docTree.id, docTree.all_name);
                    //剪切的当前节点减少
                    this.treeList1.DeleteNode(cutNode);
                }

                this.cutFileItem.Enabled = true;
                this.cutItem.Enabled = true;
                this.copyDocClassItem.Enabled = true;
                this.pasteItem.Enabled = false;
            }
            else if (e.ClickedItem.Name == "copyDocClassItem")
            {
                // 复制文档分类
                this.cutFileItem.Enabled = false;
                this.cutItem.Enabled = false;
                this.copyDocClassItem.Enabled = false;
                this.pasteItem.Enabled = true;
            }
            else if (e.ClickedItem.Name == "expandAllItem")
            {
                // 展开
                node.ExpandAll();
            }
            else if (e.ClickedItem.Name == "collapseAllItem")
            {
                // 折叠
                treeList1.CollapseAll();
            }
            else if (e.ClickedItem.Name == "loadingItem")
            {
                // 加载文档
                //	加载文档是指将该分类的分类和文档呈树形显示供查看其中内容;
            }
            else if (e.ClickedItem.Name == "addDocItem")
            {
                // 录入已有文档
                //	录入已有文档是指将本地已完成的文档录入到PDM系统中;
                document document = new document();
                document.document_type_id = ((document_tree)node.Tag).id;
                document.document_type_name = ((document_tree)node.Tag).all_name;
                DocModify docModify = new DocModify(document, 1);
                if (DialogResult.OK == docModify.ShowDialog())
                {
                    DevExpress.XtraTreeList.Nodes.TreeListNode tns = node.TreeList.AppendNode(docModify.docSave.id, node);
                    tns.SetValue(DocName, docModify.docSave.cn_name);
                    tns.SetValue(DocID, docModify.docSave.id);
                    tns.SetValue(DocType, "Files");
                    tns.Tag = docModify.docSave;
                    // 修改文档成功!
                    MessageBox.Show("创建成功!");
                }

            }
            else if (e.ClickedItem.Name == "importItem")
            {
                // 批量导入文档
                //	文档批量导入是指将本地已完成的多个文档一次录入到PDM系统中;
                DocBulkImport import = new DocBulkImport((document_tree)node.Tag);
                if (DialogResult.OK == import.ShowDialog())
                {
                    // 批量导入成功!
                }
            }
            else if (e.ClickedItem.Name == "downDocItem")
            {
                // 下载
                // 打开文件夹
                FolderBrowserDialog dlg = new FolderBrowserDialog();
                if (dlg.ShowDialog() == DialogResult.OK)
                {
                    // 开启socket文件
                    SocketServer s = new SocketServer("127.0.0.1", 7774, dlg.SelectedPath + "\\");
                    s.start();
                    var files = from d in doclist where d.document_type_id != 0 && d.document_type_id == ((document_tree)node.Tag).id select d;
                    if (files.Count() < 1) return;
                    List<document> list = new List<document>();
                    foreach (document st in files)
                    {
                        st.ipaddress = "127.0.0.1";
                        st.port = 7774;
                        list.Add(st);
                    }
                    bool flag = WcfServiceLocator.Create<IDocManageTool>().downDocumentAll(list);
                    while (!(flag && s.flag))
                    {
                        System.Threading.Thread.Sleep(1000);
                    }
                    s.lisner.Stop();
                    s.TempThread.Abort();
                }
            }
            else if (e.ClickedItem.Name == "updateDocTreeStatusItem")
            {
                // 更新文档状态
                //	更新文档状态是指将该分类下文档状态已改变而显示界面上无变化时,点击改变界面显示;
            }
            else if (e.ClickedItem.Name == "grantDocItem")
            {
                // 发放文档
                //
            }
            else if (e.ClickedItem.Name == "permissionApplyDocItem")
            {
                // 申请权限
            }
            else if (e.ClickedItem.Name == "scanDocGrantRItem")
            {
                // 查看文档发放规则
            }
            else if (e.ClickedItem.Name == "addDocTreeItem")
            {
                // 增加文档分类
                document_tree doct = new document_tree();
                doct.parent_id = ((document_tree)node.Tag).id;
                doct.parent_name = ((document_tree)node.Tag).name;
                BuildDocCategory docCat = new BuildDocCategory(doct, 1);
                if (docCat.ShowDialog() == DialogResult.OK)
                {
                    DevExpress.XtraTreeList.Nodes.TreeListNode tns = node.TreeList.AppendNode(docCat.docTree.id, node);
                    tns.SetValue(DocName, docCat.docTree.name);
                    tns.SetValue(DocID, docCat.docTree.id);
                    tns.SetValue(DocType, "Files");
                    docCat.docTree.all_name = ((document_tree)(node.Tag)).all_name + @"\" + docCat.docTree.name;
                    tns.Tag = docCat.docTree;
                    // 添加成功!
                }
            }
            else if (e.ClickedItem.Name == "updatedocTreeItem")
            {
                // 修改文档分类
                document_tree docType = new document_tree();
                docType.parent_id = ((document_tree)node.Tag).parent_id;
                docType.parent_name = ((document_tree)node.Tag).parent_name;
                docType.id = ((document_tree)node.Tag).id;
                docType.name = ((document_tree)node.Tag).name;
                BuildDocCategory docCat = new BuildDocCategory(docType, 2);
                if (docCat.ShowDialog() == DialogResult.OK)
                {
                    // 修改成功!
                    ((document_tree)node.Tag).name = docCat.docTree.name;
                    node.SetValue(DocName, docCat.docTree.name);
                }
            }
            else if (e.ClickedItem.Name == "delDocTreeItem")
            {
                // 删除文档分类
                if (MessageBox.Show("确认删除?", "警告", MessageBoxButtons.OKCancel, MessageBoxIcon.Question) == DialogResult.OK)
                {
                    bool flag = WcfServiceLocator.Create<IDocManageTool>().delDocumentTree((document_tree)node.Tag);
                    if (flag)
                    {
                        // 删除文件夹
                        this.treeList1.DeleteNode(node);
                    }
                }
            }
            else if (e.ClickedItem.Name == "scanDocTypeItem")
            {
                // 查看文档分类
                document_tree docType = new document_tree();
                docType.parent_id = ((document_tree)node.Tag).parent_id;
                docType.parent_name = ((document_tree)node.Tag).parent_name;
                docType.id = ((document_tree)node.Tag).id;
                docType.name = ((document_tree)node.Tag).name;
                BuildDocCategory docCat = new BuildDocCategory(docType, 3);
                docCat.ShowDialog();

            }
            else if (e.ClickedItem.Name == "execlEmportItem")
            {
                // excel导出

            }
            else if (e.ClickedItem.Name == "userImportItem")
            {
                // 自定义导出

            }
            else if (e.ClickedItem.Name == "docCountStaItem")
            {
                // 文档数量统计,统计该节点下文件的数目
                int count = GetChildNodes(node);
                MessageBox.Show("共有文档" + count + "个");
            }
        }