コード例 #1
0
        public static void ViewFile(DESecureFile file, string fileName, string className, DELProcessInfoForCLT processArgs, bool deleteAllowed, IBizItem bizItem, DEBrowser browser, bool isShowFileList)
        {
            CurViewFilePath = fileName;
            if (bizItem != null)
            {
                switch (PLGrantPerm.Agent.CanDoObjectOperation(ClientData.LogonUser.Oid, bizItem.MasterOid, bizItem.ClassName, PLGrantPerm.ToPermString(PLMBOOperation.BOView), bizItem.SecurityLevel, bizItem.Phase, bizItem.RevNum))
                {
                case 0:
                    MessageBoxPLM.Show("您没有浏览该对象源文件的权限。", "浏览源文件", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                    return;

                case 2:
                    MessageBoxPLM.Show("当前对象在流程中,您没有浏览该对象源文件的权限。", "浏览源文件", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                    return;
                }
                if (Path.GetExtension(fileName).ToUpper() == ".GXT")
                {
                    switch (PLGrantPerm.Agent.CanDoObjectOperation(ClientData.LogonUser.Oid, bizItem.MasterOid, bizItem.ClassName, PLGrantPerm.ToPermString(PLMBOOperation.BODownload), bizItem.SecurityLevel, bizItem.Phase, bizItem.RevNum))
                    {
                    case 0:
                        MessageBoxPLM.Show("您没有下载该对象源文件的权限。", "编辑源文件", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                        return;

                    case 2:
                        MessageBoxPLM.Show("当前对象在流程中,您没有下载该对象源文件的权限。", "编辑源文件", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                        return;
                    }
                }
            }
            FileBrowseWay      innerBrowser = FileBrowseWay.InnerBrowser;
            string             title        = "文件浏览";
            BrowserDisplayRule rule         = null;

            if (Path.GetExtension(fileName).ToUpper() == ".GXT")
            {
                rule = new BrowserDisplayRule {
                    IsEdit      = IsEditGxt,
                    OnlyBrowser = IsOnlyBrowser
                };
                if (IsEditGxt)
                {
                    title = "文件编辑";
                }
                rule.Item     = bizItem as DEBusinessItem;
                IsEditGxt     = false;
                IsOnlyBrowser = false;
            }
            try
            {
                if (browser == null)
                {
                    innerBrowser = UIBrowser.GetBrowser(file.FileOid, fileName, file.FileType, out browser);
                }
                else
                {
                    innerBrowser = browser.IsInnerBrowser ? FileBrowseWay.InnerBrowser : FileBrowseWay.OpenProcess;
                }
            }
            catch (Exception exception)
            {
                PrintException.Print(exception, title);
                return;
            }
            if (innerBrowser == FileBrowseWay.InnerBrowser)
            {
                FrmViewFile file2 = null;
                Form        form  = FormManager.GetForm(PLMFormType.ViewFile, file.FileOid);
                if ((form != null) && (form is FrmViewFile))
                {
                    file2 = (FrmViewFile)form;
                    if (bizItem != null)
                    {
                        file2.Text = bizItem.Id + "[" + ModelContext.MetaModel.GetClassLabel(bizItem.ClassName) + "] - " + title;
                        file2.SetStatusText(GetSecureFile(bizItem, file.FileOid));
                    }
                    else
                    {
                        file2.Text = Path.GetFileName(fileName) + " - " + title;
                    }
                }
                else
                {
                    try
                    {
                        file2 = new FrmViewFile();
                        if (bizItem != null)
                        {
                            file2.Text = bizItem.Id + "[" + ModelContext.MetaModel.GetClassLabel(bizItem.ClassName) + "] - " + title;
                            file2.SetStatusText(GetSecureFile(bizItem, file.FileOid));
                        }
                        else
                        {
                            file2.Text = Path.GetFileName(fileName) + " - " + title;
                        }
                    }
                    catch (Exception exception2)
                    {
                        PrintException.Print(exception2, MessageBoxIcon.Exclamation);
                        return;
                    }
                    file2.SetManaged(PLMFormType.ViewFile, file.FileOid);
                }
                file2.SetInput(bizItem, file, isShowFileList, processArgs, className);
                file2.Show();
                file2.Activate();
                string deleteFilePath = null;
                if (deleteAllowed)
                {
                    deleteFilePath = Path.GetDirectoryName(fileName);
                }
                UIBrowser.OpenFileWithBrowser(file.FileOid, fileName, file2.panelBrowser, innerBrowser, browser, deleteFilePath, rule, bizItem);
            }
            else
            {
                UIBrowser.OpenFileWithBrowser(file.FileOid, fileName, null, innerBrowser, browser, Path.GetDirectoryName(fileName), bizItem);
            }
        }
コード例 #2
0
        private void combFiles_SelectedIndexChanged(object sender, EventArgs e)
        {
            DESecureFile  selectedItem;
            string        str;
            bool          flag;
            FileBrowseWay way;

            if (this.combFiles.SelectedItem != null)
            {
                if (this.IsMarkUpMode)
                {
                    MessageBox.Show("当前文件处于批注状态,请先保存批注或者退出批注状态再操作!", "提示");
                    this.combFiles.SelectedIndexChanged -= new EventHandler(this.combFiles_SelectedIndexChanged);
                    this.combFiles.SelectedIndex         = this.LastSelectedIndex;
                    this.combFiles.SelectedIndexChanged += new EventHandler(this.combFiles_SelectedIndexChanged);
                    return;
                }
                if (this._bizItem == null)
                {
                    return;
                }
                selectedItem           = this.combFiles.SelectedItem as DESecureFile;
                this.LastSelectedIndex = this.combFiles.SelectedIndex;
                if (this._bizItem.FileList.GetFileByFileOid(selectedItem.FileOid) == null)
                {
                    return;
                }
                if (Path.GetExtension(selectedItem.FileName).ToUpper() == ".GXT")
                {
                    switch (PLGrantPerm.Agent.CanDoObjectOperation(ClientData.LogonUser.Oid, this._bizItem.MasterOid, this._bizItem.ClassName, PLGrantPerm.ToPermString(PLMBOOperation.BODownload), this._bizItem.SecurityLevel, this._bizItem.Phase, this._bizItem.RevNum))
                    {
                    case 0:
                        MessageBoxPLM.Show("您没有下载该对象源文件的权限。", "编辑源文件", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                        return;

                    case 2:
                        MessageBoxPLM.Show("当前对象在流程中,您没有下载该对象源文件的权限。", "编辑源文件", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                        return;
                    }
                }
                DESecureFile relationFileForBrowse = ViewFileHelper.GetRelationFileForBrowse(this._bizItem.Iteration, selectedItem);
                if (relationFileForBrowse != null)
                {
                    selectedItem = relationFileForBrowse;
                }
                ArrayList files = PLFileService.Agent.GetFiles(selectedItem.FileOid);
                if ((files != null) && (files.Count > 0))
                {
                    DEFile file3 = files[0] as DEFile;
                    if (file3 != null)
                    {
                        int num2 = Convert.ToInt32((long)(file3.OriginalSize / 0x100000L));
                        if ((num2 > 50) && (MessageBoxPLM.Show("您当前要浏览的源文件为" + num2.ToString() + "M,浏览会花费较长时间,您确认要继续吗?", "浏览源文件", MessageBoxButtons.OKCancel, MessageBoxIcon.Exclamation, MessageBoxDefaultButton.Button2) == DialogResult.Cancel))
                        {
                            return;
                        }
                    }
                }
                str = string.Empty;
                string path = string.Empty;
                flag = false;
                if (FileEvent.fileOperEvent != null)
                {
                    FileEvent.fileOperEvent(OperEventType.Before, "ClaRel_BROWSE", selectedItem.FileOid);
                }
                bool editable = this._bizItem.CanEdit(ClientData.LogonUser.Oid);
                if (!selectedItem.InLocalHost)
                {
                    try
                    {
                        str = ViewFileHelper.DownloadFileByDir(this._bizItem.Iteration, selectedItem, null, ClientData.UserGlobalOption, false, true, "ClaRel_BROWSE");
                    }
                    catch (Exception exception4)
                    {
                        if (editable)
                        {
                            MessageBoxPLM.Show("无法从文件服务器获取源文件,原因是:" + exception4.Message, "浏览源文件", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                        }
                        else
                        {
                            MessageBoxPLM.Show("无法从文件服务器获取源文件,原因是:" + exception4.Message, "浏览源文件", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                        }
                        return;
                    }
                    switch (str)
                    {
                    case null:
                    case "":
                        return;
                    }
                    if (!File.Exists(str))
                    {
                        MessageBoxPLM.Show("指定的文件索引不存在,可能是文件没有正确上载。", "浏览源文件", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                        return;
                    }
                    flag = true;
                    goto Label_04DE;
                }
                if (selectedItem.InCurrentHost)
                {
                    path = selectedItem.Location;
                    str  = selectedItem.Location + @"\" + selectedItem.FileName;
                    if (!File.Exists(str))
                    {
                        if (DialogResult.Yes == MessageBoxPLM.Show("在指定路径下没有找到该文件,无法浏览!可能是文件路径发生变化,或已被删除。是否尝试从服务器获取文件?", "浏览源文件", MessageBoxButtons.YesNo, MessageBoxIcon.Question))
                        {
                            try
                            {
                                ViewFileHelper.DownLoadFile(this._bizItem.Iteration, selectedItem, path, ClientData.UserGlobalOption, editable, "ClaRel_BROWSE", this._bizItem);
                                goto Label_04DE;
                            }
                            catch (Exception exception)
                            {
                                if (editable)
                                {
                                    MessageBoxPLM.Show("无法从文件服务器获取源文件,原因是:" + exception.Message, "浏览源文件", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                                }
                                else
                                {
                                    MessageBoxPLM.Show("无法从文件服务器获取源文件,原因是:" + exception.Message, "浏览源文件", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                                }
                            }
                        }
                        return;
                    }
                    try
                    {
                        if (ClientData.LogonUser.Oid != selectedItem.UserOid)
                        {
                            str = ViewFileHelper.DownLoadFile(this._bizItem.Iteration, selectedItem, null, ClientData.UserGlobalOption, true, "ClaRel_BROWSE", this._bizItem);
                        }
                        if (!File.Exists(str))
                        {
                            MessageBoxPLM.Show("无法从文件服务器获取源文件,原因是:源文件未上载", "浏览源文件", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                            return;
                        }
                        goto Label_04DE;
                    }
                    catch (Exception exception2)
                    {
                        if (editable)
                        {
                            MessageBoxPLM.Show("无法从文件服务器获取源文件,原因是:" + exception2.Message, "浏览源文件", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                        }
                        else
                        {
                            MessageBoxPLM.Show("无法从文件服务器获取源文件,原因是:" + exception2.Message, "浏览源文件", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                        }
                        return;
                    }
                }
                if (DialogResult.Yes == MessageBoxPLM.Show("文件存在于他人机器上。是否尝试从服务器获取文件?", "浏览源文件", MessageBoxButtons.YesNo, MessageBoxIcon.Question))
                {
                    try
                    {
                        str = ViewFileHelper.DownLoadFile(this._bizItem.Iteration, selectedItem, null, ClientData.UserGlobalOption, editable, "ClaRel_BROWSE", this._bizItem);
                        if (str == null)
                        {
                            MessageBoxPLM.Show("无法从文件服务器获取源文件,原因是:文件未上载", "浏览源文件", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                            return;
                        }
                        goto Label_04DE;
                    }
                    catch (Exception exception3)
                    {
                        if (editable)
                        {
                            MessageBoxPLM.Show("无法从文件服务器获取源文件,原因是:" + exception3.Message, "浏览源文件", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                        }
                        else
                        {
                            MessageBoxPLM.Show("无法从文件服务器获取源文件,原因是:" + exception3.Message, "浏览源文件", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                        }
                        return;
                    }
                }
            }
            return;

Label_04DE:
            way = FileBrowseWay.InnerBrowser;
            string             title = "文件浏览";
            BrowserDisplayRule rule  = null;

            if (Path.GetExtension(str).ToUpper() == ".GXT")
            {
                rule = new BrowserDisplayRule {
                    IsEdit      = IsEditGxt,
                    OnlyBrowser = IsOnlyBrowser
                };
                if (IsEditGxt)
                {
                    title = "文件编辑";
                }
                rule.Item     = this._bizItem;
                IsEditGxt     = false;
                IsOnlyBrowser = false;
            }
            DEBrowser browser = null;

            try
            {
                way = UIBrowser.GetBrowser(selectedItem.FileOid, str, selectedItem.FileType, out browser);
            }
            catch (Exception exception5)
            {
                PrintException.Print(exception5, title);
                return;
            }
            if (way == FileBrowseWay.InnerBrowser)
            {
                string deleteFilePath = null;
                if (flag)
                {
                    deleteFilePath = Path.GetDirectoryName(str);
                }
                UIBrowser.OpenFileWithBrowser(selectedItem.FileOid, str, this.panelBrowser, way, browser, deleteFilePath, rule, this._bizItem);
            }
            else
            {
                UIBrowser.OpenFileWithBrowser(selectedItem.FileOid, str, null, way, browser, Path.GetDirectoryName(str), this._bizItem);
            }
        }