コード例 #1
0
        private void BindFileTreeData(TreeGridView tgv, DataType.FileType fileType)
        {
            //this.tvFileList.Nodes.Clear();
            tgv.Nodes.Clear();
            IDocFileListService service = ServiceContainer.GetService <IDocFileListService>();

            dtDocFile = service.GetDocFileDataTableByDCID(Document.DOCID, fileType.ToString());

            //  Font boldFont = new Font(tvFileList.DefaultCellStyle.Font, FontStyle.Bold);
            Font boldFont = new Font(tgv.DefaultCellStyle.Font, FontStyle.Bold);

            //    DataView dv = new DataView(dt);
            node = new TreeGridNode();
            // dv.RowFilter = "[PARENT]=" + parentId;
            //foreach (DataRowView dr in dv)
            //{
            //    if (parentId == "0")
            //    {
            // node = tvFileList.Nodes.Add(Document.DOCNO, "", "", "", "", "", "", "");
            node = tgv.Nodes.Add(Document.DOCNO, "", "", "", "", "", "", "");
            node.DefaultCellStyle.Font = boldFont;

            // BindChildNode(node, (string)dr["PHYSICALID"]);
            HYDocumentMS.IFileHelper file = new FileHelper();
            foreach (DataRow dr in dtDocFile.Rows)
            {
                node.Nodes.Add(dr["DFL_FILE_NAME"].ToString(), file.getDocumentAllPathByPathID(dr["DFL_FILE_CHILD_PATH"].ToString()),
                               dr["DFL_VER_LATEST"].ToString(),
                               dr["CHECKINFLG"].ToString(), dr["CHECKINDATE"].ToString(), dr["CHECKOUTFLG"].ToString(),
                               dr["CHECKOUTDATE"].ToString(), dr["DFL_ID"].ToString());
                node.Expand();
            }
        }
コード例 #2
0
        /// <summary>
        /// 查看文件
        /// </summary>
        /// <param name="tgv"></param>
        /// <param name="fileType"></param>
        private void ViewFile(TreeGridView tgv, DataType.FileType fileType)
        {
            int rowIndex = tgv.CurrentCell.RowIndex;


            if (rowIndex <= 0)
            {
                MessageBox.Show("请选择文件", "提示信息", MessageBoxButtons.OK, MessageBoxIcon.Information);
                return;
            }
            else
            {
                //  dr["DFL_FILE_NAME"].ToString()
                DataGridViewRow row = tgv.Rows[rowIndex];
                //   string ff = row.Cells[0].Value.ToString();

                HYDocumentMS.IFileHelper file = new FileHelper();
                Boolean bl = file.isHasAuth(DataType.AuthParmsType.View, LoginInfo.LoginID, row.Cells["DFL_ID"].Value.ToString());
                if (bl == false)
                {
                    MessageBox.Show("你没有权限查看此文件!", "提示信息", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    return;
                }

                String      fileName = Path.ChangeExtension(row.Cells["DFL_FILE_NAME"].Value.ToString(), "swf");
                string      viewPath = System.Configuration.ConfigurationManager.AppSettings["viewFilePath"].ToString();
                ViewFileFrm fileView = new ViewFileFrm();
                fileView.FileName = fileName;
                //fileView.ViewFilePathAndName = @"D:\swf\Java网络编程精解.swf";
                fileView.ViewFilePath = viewPath;
                fileView.ShowDialog();
            }
        }
コード例 #3
0
        /// <summary>
        /// checkin文件
        /// </summary>
        /// <param name="tgv"></param>
        /// <param name="fileType"></param>
        private void CheckInFile(TreeGridView tgv, DataType.FileType fileType)
        {
            int rowIndex = tgv.CurrentCell.RowIndex;

            if (rowIndex <= 0)
            {
                MessageBox.Show("请选择文件", "提示信息", MessageBoxButtons.OK, MessageBoxIcon.Information);
                return;
            }
            DataGridViewRow row           = tgv.Rows[rowIndex];
            String          Id            = row.Cells["DFL_ID"].Value.ToString();
            DOC_FILE_LIST   docFileEntity = _docFileListService.GetDocFileEntityByDCID(Id);

            // HYPDM.Entities.PDM_PHYSICAL_FILE physicalfile = _physicalService.GetPhysicalFile(Id, "");
            HYDocumentMS.IFileHelper file = new FileHelper();
            Boolean bl = file.isHasAuth(DataType.AuthParmsType.CheckIn, LoginInfo.LoginID, row.Cells["DFL_ID"].Value.ToString());

            if (bl == false)
            {
                MessageBox.Show("你没有权限检入此文件!", "提示信息", MessageBoxButtons.OK, MessageBoxIcon.Information);
                return;
            }
            if (docFileEntity == null)
            {
                return;
            }
            if (docFileEntity.CHECKOUTFLG == "N")
            {
                MessageBox.Show("文件名【" + docFileEntity.DFL_FILE_NAME + "】" + "\n" + "不为检出状态,不能进行检入操作!", "提示信息", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                return;
            }
            else
            {
                HYPDM.WinUI.Document.CheckInForm form = new HYPDM.WinUI.Document.CheckInForm();
                form.DocFileEntity = docFileEntity;

                if (form.ShowDialog() == DialogResult.OK)
                {
                    if (form.FileServerAckReult1)
                    {
                        docFileEntity.CHECKINFLG     = "Y";
                        docFileEntity.CHECKINDATE    = System.DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
                        docFileEntity.CHECKOUTFLG    = "N";
                        docFileEntity.DFL_VER_LATEST = "V" + DateTime.Now.ToString("yyyyMMddHHmmss");
                        docFileEntity.LASTUPDATEDATE = System.DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
                        docFileEntity.LASTUPDATEUSER = LoginInfo.LoginID;
                        docFileEntity.Save();

                        VersionSave("1", docFileEntity);
                        MessageBox.Show("文件检入成功!", "提示信息", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    }
                    else
                    {
                        this.DialogResult = DialogResult.No;
                        MessageBox.Show("文件检入失败", "提示信息", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    }
                }
            }
        }
コード例 #4
0
        //private void btnCancel_Click(object sender, EventArgs e)
        //{
        //    CheckOutCancel(this.tvFileList, DataType.FileType.ProcessFile);

        //}

        /// <summary>
        /// 取消检出
        /// </summary>
        /// <param name="tgv"></param>
        /// <param name="fileType"></param>
        private void CheckOutCancel(TreeGridView tgv, DataType.FileType fileType)
        {
            int rowIndex = tgv.CurrentCell.RowIndex;


            if (rowIndex <= 0)
            {
                MessageBox.Show("请选择文件", "提示信息", MessageBoxButtons.OK, MessageBoxIcon.Information);
                return;
            }

            DataGridViewRow row           = tgv.Rows[rowIndex];
            String          Id            = row.Cells["DFL_ID"].Value.ToString();
            DOC_FILE_LIST   docFileEntity = _docFileListService.GetDocFileEntityByDCID(Id);

            if (docFileEntity.CREATEUSER.ToString() != LoginInfo.LoginID.ToString())
            {
                MessageBox.Show("当前不为文件的检出用户,不能进行取消动作!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning, MessageBoxDefaultButton.Button1);
                return;
            }

            if (docFileEntity == null)
            {
                return;
            }

            docFileEntity.CHECKOUTFLG    = "N";
            docFileEntity.CHECKINFLG     = "Y";
            docFileEntity.LASTUPDATEUSER = LoginInfo.LoginID;
            docFileEntity.LASTUPDATEDATE = System.DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");

            try
            {
                docFileEntity.Save();
                VersionSave("qx", docFileEntity);
                MessageBox.Show("文件检出取消成功", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message.ToString());
                return;
            }
            finally
            {
            }
        }
コード例 #5
0
        /// <summary>
        /// 删除文件
        /// </summary>
        private void delFile(TreeGridView tgv, DataType.FileType fileType)
        {
            int rowIndex = tgv.CurrentCell.RowIndex;


            if (rowIndex <= 0)
            {
                MessageBox.Show("请选择文件", "提示信息", MessageBoxButtons.OK, MessageBoxIcon.Information);
                return;
            }
            HYDocumentMS.IFileHelper file = new FileHelper();
            Boolean bl = file.isHasAuth(DataType.AuthParmsType.Delete, LoginInfo.LoginID, tgv.CurrentRow.Cells["DFL_ID"].Value.ToString());

            if (bl == false)
            {
                MessageBox.Show("你没有权限删除此文件!", "提示信息", MessageBoxButtons.OK, MessageBoxIcon.Information);
                return;
            }

            if (MessageBox.Show("所选择的文件将被删除,是否确定?", "提示信息", MessageBoxButtons.YesNo, MessageBoxIcon.Information) == DialogResult.Yes)
            {
                DataGridViewRow row   = tgv.Rows[rowIndex];
                string          dflID = row.Cells["DFL_ID"].Value.ToString();
                //var file = _physicalService.GetPhysicalFile(Id, "");
                // IDocFileListService serv = new DocFileListService();
                if (_docFileListService.delDocFileByDFLID(dflID))
                {
                    MessageBox.Show("删除成功", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information, MessageBoxDefaultButton.Button1);
                }
                else
                {
                    MessageBox.Show("删除失败", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning, MessageBoxDefaultButton.Button1);
                }
                this.BindTreeData();
                //serv.
                //file.Delete();
                //  MessageBox.Show("所选择的文件已被删除!", "提示信息", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
        }
コード例 #6
0
        //private void btnFileDown_Click(object sender, EventArgs e)
        //{
        //    ///工艺文件下载
        //    downLoadFile(this.tvFileList, DataType.FileType.ProcessFile);
        //}

        /// <summary>
        /// 文件下载
        /// </summary>
        private void downLoadFile(TreeGridView tgv, DataType.FileType fileType)
        {
            TreeGridNode node       = null;//当前选择的节点
            String       serverpath = "";

            node = new TreeGridNode();
            //node = this.tvFileList.CurrentNode;
            node = tgv.CurrentNode;
            int index = node.RowIndex;

            if (index <= 0)
            {
                MessageBox.Show("请选择需要下载的文件" + "(" + index + ")", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                return;
            }
            if (tgv.CurrentRow == null)
            {
                MessageBox.Show("请选择需要下载的文件", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
            else
            {
                HYDocumentMS.IFileHelper file = new FileHelper();

                Boolean bl = file.isHasAuth(DataType.AuthParmsType.DownLoad, LoginInfo.LoginID, tgv.CurrentRow.Cells["DFL_ID"].Value.ToString());
                if (bl == false)
                {
                    MessageBox.Show("你没有权限下载此文件!", "提示信息", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    return;
                }

                SaveFileDialog saveDialog = new SaveFileDialog();
                saveDialog.FileName = node.Cells[0].Value.ToString();
                saveDialog.Filter   = @"Text Files (*.txt)|*.txt|All Files (*.*)|*.*";
                DialogResult res = saveDialog.ShowDialog();
                if (DialogResult.OK == res)
                {
                    string clientSaveFileAndPath = saveDialog.FileName.ToString();
                    //MessageBox.Show(clientSavepath);


                    // MessageBox.Show(index.ToString());
                    if (index > 0) //取消第一行
                    {
                        serverpath = node.Cells[1].Value.ToString() + node.Cells[0].Value.ToString();
                        //  MessageBox.Show(serverpath);

                        //FileSockClient.DownLoadFileSocketClient downSocket = new FileSockClient.DownLoadFileSocketClient(serverpath, @"C:\\" + node.Cells[0].Value.ToString());
                        FileSockClient.DownLoadFileSocketClient downSocket = new FileSockClient.DownLoadFileSocketClient(serverpath, clientSaveFileAndPath);
                        if (!downSocket.AckStatus)
                        {
                            return;
                        }
                        else
                        {
                            MessageBox.Show("下载成功,保存路径:" + "\n" + clientSaveFileAndPath, "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                        }
                    }
                    else
                    {
                        MessageBox.Show("请选择需要下载的文件" + "(" + index + ")", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    }
                }
            }
            //  this.tvFileList.CurrentRow
        }
コード例 #7
0
        /// <summary>
        /// 检出文件
        /// </summary>
        /// <param name="tgv"></param>
        /// <param name="fileType"></param>
        private void CheckOut(TreeGridView tgv, DataType.FileType fileType)
        {
            int rowIndex = tgv.CurrentCell.RowIndex;


            if (rowIndex <= 0)
            {
                MessageBox.Show("请选择文件", "提示信息", MessageBoxButtons.OK, MessageBoxIcon.Information);
                return;
            }


            DataGridViewRow row = tgv.Rows[rowIndex];

            HYDocumentMS.IFileHelper file = new FileHelper();
            Boolean bl = file.isHasAuth(DataType.AuthParmsType.CheckOut, LoginInfo.LoginID, row.Cells["DFL_ID"].Value.ToString());

            if (bl == false)
            {
                MessageBox.Show("你没有权限检出此文件!", "提示信息", MessageBoxButtons.OK, MessageBoxIcon.Information);
                return;
            }

            String        Id            = row.Cells["DFL_ID"].Value.ToString();
            DOC_FILE_LIST docFileEntity = _docFileListService.GetDocFileEntityByDCID(Id);

            // HYPDM.Entities.PDM_PHYSICAL_FILE physicalfile = _physicalService.GetPhysicalFile(Id, "");
            if (docFileEntity == null)
            {
                return;
            }
            if (docFileEntity.CHECKOUTFLG == "Y")
            {
                MessageBox.Show("当前文档已被检出,不能再次检出,请等待检出人检入!", "提示信息", MessageBoxButtons.OK, MessageBoxIcon.Information);
                return;
            }
            HYPDM.WinUI.Document.DetectionForm form = new HYPDM.WinUI.Document.DetectionForm();
            form.DocFileEntity = docFileEntity;

            if (form.ShowDialog() == DialogResult.OK)
            {
                if (form.FileServerAckResult)
                {
                    docFileEntity.CHECKOUTFLG    = "Y";
                    docFileEntity.CHECKINFLG     = "N";
                    docFileEntity.CHECKOUTDATE   = System.DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
                    docFileEntity.LASTUPDATEDATE = System.DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
                    docFileEntity.LASTUPDATEUSER = LoginInfo.LoginID;
                    docFileEntity.Save();
                }
                else
                {
                    MessageBox.Show("文件检出失败", "提示信息", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    return;
                }
                try
                {
                    VersionSave("0", docFileEntity);
                    MessageBox.Show("文件检出成功!", "提示信息", MessageBoxButtons.OK, MessageBoxIcon.Information);
                }
                catch (Exception ex)
                {
                    MessageBox.Show(ex.Message.ToString());
                }
                finally
                {
                    // MessageBox.Show("文件检出成功!", "提示信息", MessageBoxButtons.OK, MessageBoxIcon.Information);
                }
            }
        }
コード例 #8
0
        //private DataTable dt;

        ///// <summary>
        ///// 查看文件
        ///// </summary>
        ///// <param name="sender"></param>
        ///// <param name="e"></param>
        //private void btnView_Click(object sender, EventArgs e)
        //{

        //    ViewFile(this.tvFileList, DataType.FileType.ProcessFile);
        //}
        ///// <summary>
        ///// 工艺文件注册
        ///// </summary>
        ///// <param name="sender"></param>
        ///// <param name="e"></param>
        //private void btnRegPhysicalFile_Click(object sender, EventArgs e)
        //{
        //    //注册工艺文件
        //    RegFile(DataType.FileType.ProcessFile);
        //}
        ///// <summary>
        ///// 删除文件
        ///// </summary>
        ///// <param name="sender"></param>
        ///// <param name="e"></param>
        //private void btnDel_Click(object sender, EventArgs e)
        //{
        //    delFile(this.tvFileList, DataType.FileType.ProcessFile);
        //}
        ///// <summary>
        ///// 检入
        ///// </summary>
        ///// <param name="sender"></param>
        ///// <param name="e"></param>
        //private void btnCheckIN_Click(object sender, EventArgs e)
        //{
        //    CheckInFile(this.tvFileList, DataType.FileType.ProcessFile);
        //}
        ///// <summary>
        ///// 检出
        ///// </summary>
        ///// <param name="sender"></param>
        ///// <param name="e"></param>
        //private void btnCheckOut_Click(object sender, EventArgs e)
        //{
        //    CheckOut(this.tvFileList, DataType.FileType.ProcessFile);
        //}
        /// <summary>
        /// 物理文件注册
        /// </summary>
        /// <param name="fileType"></param>
        private void RegFile(DataType.FileType fileType)
        {
            string   savePath     = "";
            string   savePathID   = "";//保存的目标路径的id
            ListView listViewFile = null;

            HYPDM.WinUI.Document.AddFileFrm frm = new HYPDM.WinUI.Document.AddFileFrm();
            if (frm.ShowDialog() == DialogResult.OK)
            {
                //将需要添加的文件信息返回来
                //fileList
                //savePath
                listViewFile = frm.ListViewFile;
                savePath     = frm.SaveFilepath; //从弹出窗体返回来的保存路径
                savePathID   = frm.SavePathID;   //保存的目标路径的id
                // MessageBox.Show(savePath);
                //   FileSockClient.UpLoadFileSocketClient sock = null;
                //DataEntityQuery<DOC_FILE_LIST> query = DataEntityQuery<DOC_FILE_LIST>.Create();
                DOC_FILE_LIST file = new DOC_FILE_LIST();
                String        path = "";
                foreach (ListViewItem item in listViewFile.Items)
                {
                    // MessageBox.Show(item.Text.ToString());

                    //var path = ofdFile.FileName;
                    path = item.Text.ToString();

                    // IDocFileListService _fileService = ServiceContainer.GetService<DocFileListService>();
                    try
                    {
                        //FileSockClient.UpLoadFileSocketClient sock = new FileSockClient.UpLoadFileSocketClient(path, @"D:\\PDM文件服务器根目录");
                        FileSockClient.UpLoadFileSocketClient uploadSocket = new FileSockClient.UpLoadFileSocketClient(path, savePath);
                        if (!uploadSocket.AckStatus)
                        {
                            return;
                        }
                        // MessageBox.Show("文件添加成功==文件目录" + @"E:\\PDM文件服务器根目录");
                    }
                    catch (Exception ex)
                    {
                        MessageBox.Show("文件添加失败==文件目录" + savePath + "===" + ex.Message.ToString());
                    }
                    finally
                    {
                    }
                    try
                    {
                        file.DFL_ID              = Guid.NewGuid().ToString();
                        file.DFL_FILE_NAME       = path.Substring(path.LastIndexOf(@"\") + 1);
                        file.DFL_FILE_EXTEND     = path.Substring(path.LastIndexOf(@".") + 1);
                        file.DFL_FILE_CHILD_PATH = savePathID;
                        file.DEL_FLAG            = "N";
                        //file.DFL_VER_LATEST = "V" + DateTime.Now.ToString("yyyyMMddHHmmss");
                        file.DFL_VER_LATEST = new HYDocumentMS.FileHelper().getNewVer("V");
                        file.DOCID          = Document.DOCID; //与文档表关联主键
                        file.CREATEDATE     = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
                        file.CREATEUSER     = LoginInfo.LoginID;
                        file.LASTUPDATEDATE = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
                        file.LASTUPDATEUSER = LoginInfo.LoginID;
                        file.CHECKOUTFLG    = "N";
                        file.CHECKINFLG     = "Y";
                        // query.Save(file);
                        //query.Insert(file);
                        file.FILE_TYPE = fileType.ToString();
                        file.Save();
                        MessageBox.Show("图纸注册成功,文件目录" + savePath, "提示", MessageBoxButtons.OK, MessageBoxIcon.Information, MessageBoxDefaultButton.Button1);
                    }
                    catch (Exception ex)
                    {
                        MessageBox.Show("图纸注册失败【注册到数据库失败】," + ex.Message.ToString(), "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning, MessageBoxDefaultButton.Button1);
                        return;
                    }

                    this.BindTreeData();
                }
            }
        }