/// <summary> /// 根据文档类型,查询文档的扩展属性 /// </summary> /// <returns></returns> public document_type getDocumentProperty(document doc) { document_type doctype = new document_type(); List<doc_attached_property> docProList = new List<doc_attached_property>(); doc_attached_property dp1 = new doc_attached_property(); dp1.en_name = "Docdep"; dp1.cn_name = "文档部门"; dp1.is_user_define = ""; dp1.is_display = true; dp1.display_width = "100"; dp1.input_type = ""; dp1.data_type = "字符型"; dp1.default_value = "测试001"; dp1.data_length = "100"; dp1.order = "1"; docProList.Add(dp1); doc_attached_property dp2 = new doc_attached_property(); dp2.en_name = "wordsize"; dp2.cn_name = "文档大小"; dp2.is_user_define = ""; dp2.is_display = false; dp2.display_width = "100"; dp2.data_type = "数值型"; dp2.default_value = "测试002"; dp2.data_length = "80"; dp2.order = "2"; docProList.Add(dp2); doc_attached_property dp3 = new doc_attached_property(); dp3.en_name = "wordsize"; dp3.cn_name = "文档大小"; dp3.is_user_define = ""; dp3.is_display = true; dp3.display_width = "100"; dp3.data_type = "数值型"; dp3.default_value = "测试002"; dp3.data_length = "80"; dp3.order = "2"; docProList.Add(dp3); doc_attached_property dp4 = new doc_attached_property(); dp4.en_name = "column4"; dp4.cn_name = "文档扩展属性1"; dp4.is_user_define = "是"; dp4.is_display = true; dp4.display_width = "100"; dp4.order = "4"; dp4.input_type = "SEL"; List<doc_combobox_value> selectvlaue = new List<doc_combobox_value>(); doc_combobox_value v1 = new doc_combobox_value(); v1.value = "1000"; doc_combobox_value v2 = new doc_combobox_value(); v2.value = "2000"; selectvlaue.Add(v1); selectvlaue.Add(v2); dp4.ComboxValue = selectvlaue; docProList.Add(dp4); doctype.DocProperty = docProList; return doctype; }
/// <summary> /// 下载文档 /// </summary> /// <param name="doc"></param> /// <returns></returns> public bool downDocument(document doc) { // 获取后台文件,发送到前台 Client client = new Client(doc.ipaddress,doc.port,doc.cn_name+"."+doc.format_name,doc.physical_file_location); //client.start(); client.StartSend(); return true; }
public List<document> GetAllDocument() { var docList = new List<document>(); var doc = new document { id = 1, cn_name = "文档测试数据1", version = "1.0", number = "201403131601", status = "未归档", dense_name = "测试", valid_time = "2014-03-25", in_valid_time = "2014-03-28" }; docList.Add(doc); doc = new document { id = 2, cn_name = "文档测试数据2", version = "1.1", number = "201403131602", status = "已归档", dense_name = "测试", valid_time = "2014-03-22", in_valid_time = "2014-03-31" }; docList.Add(doc); return docList; }
private void simpleButton1_Click(object sender, EventArgs e) { this.labelControl12.Text = "0"; document document = new document(); document.number = this.textEdit1.Text; document.version = this.textEdit2.Text; document.cn_name = this.textEdit3.Text; document.document_type_name = this.textEdit4.Text; document.create_user_name = this.buttonEdit1.Text; document.abstract_content = this.textEdit5.Text; document.key = this.textEdit6.Text; // 调用查询,查询数据集 List<document> list = WcfServiceLocator.Create<IDocGrantManage>().scanDocumentWithGrant(document); if (list == null) { this.labelControl12.Text = "0"; // 返回结果,绑定到datagrid this.gridControl1.DataSource = null; } else { if (checkEdit18.Checked) { gridColumn1.ColumnEdit = repositoryItemPictureEdit1; gridColumn1.FieldName = "format_pic"; System.Drawing.Image image1 = View_Winform.DocManage.DocManageTool.DocManageRes.Calendar_16x16; System.Drawing.Image image2 = View_Winform.DocManage.DocManageTool.DocManageRes.Ribbon_Close_16x16; for (int i = 0; i < list.Count; i++) { if ("txt".Equals(list[i].format_name)) { list[i].format_pic = ImageToByteArr(image1); } else { list[i].format_pic = ImageToByteArr(image2); } } } else { gridColumn1.ColumnEdit = null ; gridColumn1.FieldName = "format_name"; } this.labelControl12.Text = list.Count.ToString(); // 返回结果,绑定到datagrid this.gridControl1.DataSource = list; } this.gridControl1.RefreshDataSource(); }
/// <summary> /// 绑定实体数据 /// </summary> private void bingData() { // 查询关联信息 try { document = WcfServiceLocator.Create<IDocManageTool>().getDocumentByKey(document); this.Text = "修改文档属性"; this.txtDocNumber.Text = document.number; this.txtEnName.Text = document.en_name; this.txtDocName.Text = document.cn_name; this.txtDocVersion.Text = document.version; this.txtDocFormat.Text = document.format_name; this.txtModifyCount.Text = document.modify_count; this.txtModifyTime.Text = document.modify_date.ToShortDateString(); this.txtDocPage.Text = document.doc_page; this.txtDocModel.Text = document.doc_template_name; this.txtValidTime.Text = document.valid_time; this.txtInValidTime.Text = document.in_valid_time; this.txtRemark.Text = document.remark; this.txtAbstract.Text = document.abstract_content; this.txtKey.Text = document.key; this.cbxDocDense.SelectedText = document.dense_name; this.txtDocCategory.Text = document.doc_template_name; // 绑定已有文档 if (document.sub_document != null && document.sub_document.Count != 0) { this.DocManage_DocManageTool_DocModify_RelevanceDocList_TreeList.DataSource = document.sub_document; this.DocManage_DocManageTool_DocModify_RelevanceDocList_TreeList.RefreshDataSource(); } // 绑定扩展属性 if (docPropertyList != null && docPropertyList.Count != 0) { Type t = typeof(document); // 获取扩展属性的值 foreach (doc_attached_property p in docPropertyList) { // 获取控件的文本框值 object obj = t.GetProperty("column" + p.order).GetValue(document, null); this.DocManagement_DocModify_tabContr_AdditionalInfor.Controls.Find(p.en_name, true)[0].Text = obj == null ? null : obj.ToString() ; } } } catch (Exception ex) { Console.WriteLine(ex.Message); } }
/// <summary> /// 查询事件 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void btnScan_Click(object sender, EventArgs e) { try { // 获取查询条件 document docQuery = new document(); // 点击查询 List<PDM_Entity.DocManage.document> list = WcfServiceLocator.Create<IDocManageTool>().getDocument(docQuery); //if (this.checkEdit1.Checked) //{ // // 如果是缩列图 // DevExpress.XtraEditors.Repository.RepositoryItemPictureEdit repositoryItemPictureEditUser = new DevExpress.XtraEditors.Repository.RepositoryItemPictureEdit(); // repositoryItemPictureEditUser.Name = "repositoryItemPictureEditUser"; // this.gridColumn2.ColumnEdit = repositoryItemPictureEditUser; // this.gridColumn2.FieldName = "format_pic"; // //System.Drawing.Image image1 = View_Winform.DocManage.DocManageTool.DocManageRes.Calendar_16x16; // //System.Drawing.Image image2 = View_Winform.DocManage.DocManageTool.DocManageRes.Ribbon_Close_16x16; // for (int i = 0; i < list.Count(); i++) // { // if ("txt".Equals(list[i].format_name)) // { // //list[i].format_pic = ImageToByteArr(image1); // } // else // { // //list[i].format_pic = ImageToByteArr(image2); // } // } //} //else //{ // this.gridColumn2.ColumnEdit = null; // this.gridColumn2.FieldName = "format_name"; //} this.gridControl1.DataSource = list; this.gridControl1.RefreshDataSource(); } catch (Exception ex) { Console.WriteLine(ex.Message); } }
/// <summary> /// 添加文档按钮 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void btnAdd_Click(object sender, EventArgs e) { OpenFileDialog open = new OpenFileDialog(); open.InitialDirectory = "c://"; open.Filter = "所有文件|*.*"; open.RestoreDirectory = true; open.FilterIndex = 1; if (open.ShowDialog() == DialogResult.OK) { // 增加一条文档信息 //String fName = open.FileName; String fname = open.SafeFileName; document doc = new document(); doc.cn_name = fname.Substring(0, fname.Length - fname.LastIndexOf(".")+2); doc.format_name = fname.Substring(fname.LastIndexOf(".") + 1, fname.Length - fname.LastIndexOf(".") - 1); doc.version = this.DocManagement_DocModify_TextEidt_DocVersion.Text; doc.physical_file_location = open.FileName; docList.Add(doc); this.gridControl1.DataSource = docList; this.gridControl1.RefreshDataSource(); } }
/// <summary> /// 自定义扩展列 /// </summary> private void extendPropertyGen() { // 自动加载扩展的列 try { document doc = new document(); doc.document_type_id = docType.id; doc.document_type_name = docType.name; document_type doctype = WcfServiceLocator.Create<IDocPropertyBuild>().getDocumentProperty(doc); docPropertyList = doctype.DocProperty; int Location_y = 10; int actlocation = 0; for (int i = 0; i < docPropertyList.Count; i++) { doc_attached_property docp = docPropertyList[i]; if (!docp.is_display) continue; if (actlocation % 2 == 0) { // 为第一列 LabelControl lbk1 = new LabelControl(); lbk1.Name = "lbk1" + i; lbk1.Text = docp.cn_name + ":"; lbk1.Size = new System.Drawing.Size(60, 15); lbk1.Location = new System.Drawing.Point(25, Location_y); this.xtraTabPage2.Controls.Add(lbk1); if (docp.input_type == "SEL") { ComboBoxEdit cbx1 = new ComboBoxEdit(); // 添加下拉框的值 foreach (doc_combobox_value boxvalue in docp.ComboxValue) { cbx1.Properties.Items.Add(boxvalue.value); } cbx1.Name = docp.en_name; cbx1.Size = new System.Drawing.Size(280, 20); cbx1.Location = new System.Drawing.Point(108, Location_y - 4); this.xtraTabPage2.Controls.Add(cbx1); } else { TextEdit txtk1 = new TextEdit(); txtk1.Name = docp.en_name; txtk1.Size = new System.Drawing.Size(280, 20); txtk1.Location = new System.Drawing.Point(108, Location_y - 4); this.xtraTabPage2.Controls.Add(txtk1); } } else { // 为第二列 LabelControl lbk2 = new LabelControl(); lbk2.Name = "lbk2" + i; lbk2.Text = docp.cn_name + ":"; lbk2.Size = new System.Drawing.Size(60, 15); lbk2.Location = new System.Drawing.Point(412, Location_y); this.xtraTabPage2.Controls.Add(lbk2); if (docp.input_type == "SEL") { ComboBoxEdit cbx1 = new ComboBoxEdit(); // 添加下拉框的值 foreach (doc_combobox_value boxvalue in docp.ComboxValue) { cbx1.Properties.Items.Add(boxvalue.value); } cbx1.Name = docp.en_name; cbx1.Size = new System.Drawing.Size(280, 20); cbx1.Location = new System.Drawing.Point(108, Location_y - 4); this.xtraTabPage2.Controls.Add(cbx1); } else { TextEdit txtk2 = new TextEdit(); txtk2.Name = docp.en_name; txtk2.Size = new System.Drawing.Size(264, 20); txtk2.Location = new System.Drawing.Point(500, Location_y - 4); this.xtraTabPage2.Controls.Add(txtk2); } Location_y = Location_y + 30; } actlocation++; } } catch (Exception ex) { Console.WriteLine(ex.Message); } }
/// <summary> /// 查询历史记录 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void btnScan_Click(object sender, EventArgs e) { try { if (checkEdit1.Checked) { // 根据发放设置查询条件,进行查询 doc_grant_setting doc_grant_setting = new doc_grant_setting(); doc_grant_setting.grant_user = this.textEdit1.Text; doc_grant_setting.grant_user = this.textEdit2.Text; doc_grant_setting.valid_time = this.textEdit7.Text; grantSettingList = WcfServiceLocator.Create<IDocGrantManage>().getGrantSetting(doc_grant_setting); dgcGrant.DataSource = grantSettingList; } else { // 根据文档查询条件,进行查询 document doc = new document(); doc.number = this.textEdit3.Text; doc.version = this.textEdit4.Text; doc.cn_name = this.textEdit5.Text; doc.create_user_name = this.textEdit6.Text; grantSettingList = WcfServiceLocator.Create<IDocGrantManage>().getGrantSettingByDoc(doc); dgcGrant.DataSource = grantSettingList; } dgcGrant.RefreshDataSource(); } catch (Exception ex) { } }
/// <summary> /// add by lijun 2014.2.20 /// 页面加载 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void DocPropertyBuild_Load(object sender, EventArgs e) { // 自动加载列 try { document doc = new document(); document_type doctype = WcfServiceLocator.Create<IDocPropertyBuild>().getDocumentProperty(doc); list = doctype.DocProperty; this.gridDocProperty.DataSource = list; } catch (Exception ex) { Console.WriteLine(ex.Message); } }
/// <summary> /// 判断是文件夹还是文件点击 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void treeList1_MouseDown(object sender, MouseEventArgs e) { if (e.Button == MouseButtons.Right) { DevExpress.XtraTreeList.TreeListHitInfo hInfo = this.treeList1.CalcHitInfo(new Point(e.X, e.Y)); if (hInfo.HitInfoType == DevExpress.XtraTreeList.HitInfoType.Cell) //在单元格上右击了 { if (hInfo.Node.Tag.GetType() == typeof(document_tree)) { this.treeList1.ContextMenuStrip = this.contextMenuFiles; node = hInfo.Node; // 粘贴按钮不可用 //pasteItem.Enabled = false; } else { this.treeList1.ContextMenuStrip = this.contextMenuFile; node = hInfo.Node; selTreeNode = (document)hInfo.Node.Tag; } } } }
/// <summary> /// 文档管理器查询文档 /// </summary> /// <returns></returns> public List<document> getDocument(document doc) { document D1 = new document(); D1.cn_name = "文档1"; D1.create_user_name = "李俊"; D1.dense_name = "绝密"; D1.valid_time = "2013-01-12"; D1.remark = "备注"; D1.status = "有效"; D1.format_name = "doc"; D1.version = "0001"; document D2 = new document(); D2.cn_name = "文档2"; D2.create_user_name = "李俊1"; D2.create_date = DateTime.Parse("2013-01-01"); D2.modify_count = "0"; D2.modify_date = DateTime.Parse("2013-01-01"); D2.modify_user_name = "李俊1"; D2.doc_page = "A4"; D2.dense_name = "保密"; D2.valid_time = "2013-01-01"; D2.in_valid_time = "2013-01-12"; D2.remark = "备注"; D2.status = "有效"; D2.format_name = "txt"; D2.version = "0002"; D2.abstract_content = "备注"; D2.en_name = "wendang2"; D2.number = "00002"; D2.key = "文档 设计文档 车轮"; D2.doc_template_id = 1; D2.doc_template_name = "需求设计文档"; D2.column1 = "12"; D2.column2 = "23"; D2.column3 = "34"; List<document> list = new List<document>(); list.Add(D1); list.Add(D2); return list; }
/// <summary> /// 自定义构造函数 /// </summary> /// <param name="doc"></param> /// <param name="actionType"></param> public DocModify(document doc, int actionType) { InitializeComponent(); this.actionType = actionType; this.document = doc; }
/// <summary> /// 更新文档 /// </summary> /// <param name="doc"></param> /// <returns></returns> public document updateDocument(document doc) { return doc; }
/// <summary> /// 删除文档 /// </summary> /// <param name="doc"></param> /// <returns></returns> public bool delDocument(document doc) { return true; }
/// <summary> /// 插入文档 /// </summary> /// <param name="doc"></param> /// <returns></returns> public document insertDocument(document doc) { String filePath = @"g:\"; Random rand = new Random(); string newfilename = filePath + DateTime.Now.Year.ToString() + DateTime.Now.Month.ToString() + "m" + DateTime.Now.Day.ToString() + "d" + DateTime.Now.Second.ToString() + DateTime.Now.Minute.ToString() + DateTime.Now.Millisecond.ToString() + "a" + rand.Next(1000).ToString() + doc.cn_name+"." + doc.format_name; doc.ipaddress = "127.0.0.1"; doc.port = 7775; // 插入数据库 return doc; }
/// <summary> /// 查询关联文档 /// </summary> /// <param name="doc"></param> /// <returns></returns> public List<document> getSubDocument(document doc) { document d = new document(); d.number = "111111"; d.cn_name = "文档1"; d.version = "00"; d.document_type_name = "A1"; document d1 = new document(); d1.number = "2222"; d1.cn_name = "文档2"; d1.version = "01"; d1.document_type_name = "B1"; List<document> list = new List<document>(); list.Add(d); list.Add(d1); return list; }
/// <summary> /// 根据doc的key,查询出doc详细信息(零件/包含文档) /// </summary> /// <param name="doc"></param> /// <returns></returns> public document getDocumentByKey(document doc) { document d = new document(); d.number = "111111"; d.cn_name = "文档1"; d.version = "00"; d.document_type_name = "A1"; document d1 = new document(); d1.number = "2222"; d1.cn_name = "文档2"; d1.version = "01"; d1.document_type_name = "B1"; List<document> list = new List<document>(); list.Add(d); list.Add(d1); doc.sub_document = list; return doc; }
/// <summary> /// 保存按钮 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void btnSave_Click(object sender, EventArgs e) { //Document doc = new Document(); docSave = document; // 获取基本属性 docSave.number = this.txtDocNumber.Text; docSave.en_name = this.txtEnName.Text; docSave.cn_name = this.txtDocName.Text; docSave.version = this.txtDocVersion.Text; docSave.format_name = this.txtDocFormat.Text; docSave.modify_count = this.txtModifyCount.Text; //docSave.modify_date = DateTime.Parse( this.txtModifyTime.Text); docSave.doc_page = this.txtDocPage.Text; docSave.doc_template_name = this.txtDocModel.Text; docSave.valid_time = this.txtValidTime.Text; docSave.in_valid_time = this.txtInValidTime.Text; docSave.abstract_content = this.txtAbstract.Text; docSave.remark = this.txtRemark.Text; docSave.key = this.txtKey.Text; docSave.dense_name = this.cbxDocDense.SelectedText; // 获取扩展属性的值 foreach (doc_attached_property p in docPropertyList) { // 获取控件的文本框值 String text = this.DocManagement_DocModify_tabContr_AdditionalInfor.Controls.Find(p.en_name, true)[0].Text; Type t = typeof(document); t.GetProperty("column" + p.order).SetValue(docSave, text, null); } // 添加包含文档 docSave.sub_document = hashDocList; if (actionType == 2 || actionType == 4) { } else { Random rand = new Random(); //生成文件 string genfile = DateTime.Today.ToString("yyyyMMddhhmmssfffffff") + rand.Next(1000).ToString() + "." + docSave.format_name; // 从后台获取ip地址和端口号,发文件发送到后台保存起来。 Client c = new Client(txtDocUpload.Text,genfile, docSave.ipaddress, docSave.port); c.start(); //插入数据库 docSave = WcfServiceLocator.Create<IDocManageTool>().insertDocument(docSave); } if (docSave != null) { docSave.id= 10; MessageBox.Show("更新成功!"); DialogResult = DialogResult.OK; this.Close(); } }
/// <summary> /// 查询所有的文档,构建文档树 /// </summary> /// <returns></returns> public List<document> getAllDocument() { List<document> doclist = new List<document>(); document D2 = new document(); D2.cn_name = "文档3"; D2.create_user_name = "李俊1"; D2.create_date = DateTime.Parse("2013-01-01"); D2.modify_count = "0"; D2.modify_date = DateTime.Parse("2013-01-01"); D2.modify_user_name = "李俊1"; D2.doc_page = "A4"; D2.dense_name = "保密"; D2.valid_time = "2013-01-01"; D2.in_valid_time = "2013-01-12"; D2.remark = "备注"; D2.status = "有效"; D2.format_name = "xls"; D2.version = "0002"; D2.abstract_content = "备注"; D2.en_name = "wendang2"; D2.number = "00002"; D2.key = "文档 设计文档 车轮"; D2.doc_template_id = 1; D2.doc_template_name = "需求设计文档"; D2.column1 = "12"; D2.column2 = "23"; D2.column3 = "34"; D2.document_type_id = 3; D2.physical_file_location = "g:\\12.xls"; document D3 = new document(); D3.cn_name = "文档2"; D3.create_user_name = "李俊1"; D3.create_date = DateTime.Parse("2013-01-01"); D3.modify_count = "0"; D3.modify_date = DateTime.Parse("2013-01-01"); D3.modify_user_name = "李俊1"; D3.doc_page = "A4"; D3.dense_name = "保密"; D3.valid_time = "2013-01-01"; D3.in_valid_time = "2013-01-12"; D3.remark = "备注"; D3.status = "有效"; D3.format_name = "xls"; D3.version = "0002"; D3.abstract_content = "备注"; D3.en_name = "wendang2"; D3.number = "00002"; D3.key = "文档 设计文档 车轮"; D3.doc_template_id = 1; D3.doc_template_name = "需求设计文档"; D3.column1 = "12"; D3.column2 = "23"; D3.column3 = "34"; D3.document_type_id = 3; D3.physical_file_location = "g:\\11.xls"; doclist.Add(D2); doclist.Add(D3); return doclist; }
/// <summary> /// 查看关联文档按钮 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void DocManage_DocManageTool_DocModify_RelevanceDocQuery_SimpleButton_Click(object sender, EventArgs e) { try { // 查找关联文档 document doc = new document(); doc.cn_name = this.DocManage_DocManageTool_RelevanceDocModify_DocName_TextEdit.Text; doc.number = this.DocManage_DocManageTool_RelevanceDocModify_DocNumber_TextEdit.Text; doc.version = this.DocManage_DocManageTool_RelevanceDocModify_DocRelease_TextEdit.Text; doc.create_user_id = String.IsNullOrEmpty(this.DocManage_DocManageTool_DocModify_Creater_ButtonEdit.Text) ? -1 : int.Parse(this.DocManage_DocManageTool_DocModify_Creater_ButtonEdit.Text); doc.modify_user_id = String.IsNullOrEmpty(this.DocManage_DocManageTool_DocModify_Modifier_ButtonEdit.Text) ? -1 : int.Parse(this.DocManage_DocManageTool_DocModify_Modifier_ButtonEdit.Text); scanDocList = WcfServiceLocator.Create<IDocManageTool>().getSubDocument(doc); hashDocList = new List<document>(); this.DocManage_DocManageTool_DocModify_RelevanceDocQueryValue_GridControl.DataSource = scanDocList; this.DocManage_DocManageTool_DocModify_RelevanceDocQueryValue_GridControl.RefreshDataSource(); this.DocManage_DocManageTool_DocModify_RelevanceDocList_TreeList.DataSource = hashDocList; this.DocManage_DocManageTool_DocModify_RelevanceDocList_TreeList.RefreshDataSource(); } catch(Exception ex) { Console.WriteLine(ex.Message); } }
/// <summary> /// 查询 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void btnScan_Click(object sender, EventArgs e) { try { this.gridControl1.DataSource = null; this.labelControl12.Text = "0"; document d = new document(); grantDocList = WcfServiceLocator.Create<IDocGrantManage>().scanDocumentWithGrant(d); gridColumn1.ColumnEdit = repositoryItemPictureEdit1; gridColumn1.FieldName = "format_pic"; System.Drawing.Image image1 = View_Winform.DocManage.DocManageTool.DocManageRes.Calendar_16x16; System.Drawing.Image image2 = View_Winform.DocManage.DocManageTool.DocManageRes.Ribbon_Close_16x16; for (int i = 0; i < grantDocList.Count; i++) { if ("txt".Equals(grantDocList[i].format_name)) { grantDocList[i].format_pic = ImageToByteArr(image1); } else { grantDocList[i].format_pic = ImageToByteArr(image2); } } if (grantDocList != null) { this.gridControl1.DataSource = grantDocList; this.labelControl12.Text = grantDocList.Count.ToString(); } this.gridControl1.RefreshDataSource(); } catch (Exception ex) { MessageBox.Show(ex.Message); } }
/// <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 + "个"); } }
/// <summary> /// 查看文档发放设置 /// </summary> /// <param name="doc_grant"></param> /// <returns></returns> public List<doc_grant_setting> getGrantSetting(doc_grant_setting doc_grant) { List<doc_grant_setting> grantSetting = new List<doc_grant_setting>(); doc_grant_setting dg1 = new doc_grant_setting(); dg1.id = 1; dg1.grant_by_user = "******"; dg1.grant_type = "人员"; dg1.grant_user = "******"; dg1.in_valid_time = "2013-01-02"; dg1.valid_time = "2013-01-01"; dg1.permission_type_name = "控件浏览"; dg1.valid = "1"; grantSetting.Add(dg1); doc_grant_setting dg2 = new doc_grant_setting(); dg2.id = 1; dg2.grant_by_user = "******"; dg2.grant_type = "人员"; dg2.grant_user = "******"; dg2.in_valid_time = "2013-01-02"; dg2.valid_time = "2013-01-01"; dg2.permission_type_name = "控件浏览"; dg2.valid = "1"; grantSetting.Add(dg2); document D2 = new document(); D2.cn_name = "文档2"; D2.create_user_name = "李俊1"; D2.create_date = DateTime.Parse("2013-01-01"); D2.modify_count = "0"; D2.modify_date = DateTime.Parse("2013-01-01"); D2.modify_user_name = "李俊1"; D2.doc_page = "A4"; D2.dense_name = "保密"; D2.valid_time = "2013-01-01"; D2.in_valid_time = "2013-01-12"; D2.remark = "备注"; D2.status = "有效"; D2.format_name = "txt"; D2.version = "0002"; D2.abstract_content = "备注"; D2.en_name = "wendang2"; D2.number = "00002"; D2.key = "文档 设计文档 车轮"; D2.doc_template_id = 1; D2.doc_template_name = "需求设计文档"; D2.column1 = "12"; D2.column2 = "23"; D2.column3 = "34"; List<document> docList = new List<document>(); docList.Add(D2); dg1.document_list = docList; document D3 = new document(); D3.cn_name = "文档3"; D3.create_user_name = "李俊1"; D3.create_date = DateTime.Parse("2013-01-01"); D3.modify_count = "0"; D3.modify_date = DateTime.Parse("2013-01-01"); D3.modify_user_name = "李俊1"; D3.doc_page = "A4"; D3.dense_name = "保密"; D3.valid_time = "2013-01-01"; D3.in_valid_time = "2013-01-12"; D3.remark = "备注"; D3.status = "有效"; D3.format_name = "txt"; D3.version = "0002"; D3.abstract_content = "备注"; D3.en_name = "wendang2"; D3.number = "00002"; D3.key = "文档 设计文档 车轮"; D3.doc_template_id = 1; D3.doc_template_name = "需求设计文档"; D3.column1 = "12"; D3.column2 = "23"; D3.column3 = "34"; List<document> docList1 = new List<document>(); docList1.Add(D3); dg2.document_list = docList1; return grantSetting; }