/// <summary> /// 生成文件. /// </summary> /// <returns></returns> private string MakeFullFileFromFtp() { string pathOfTemp = SystemConfig.PathOfTemp; if (System.IO.Directory.Exists(pathOfTemp) == false) { System.IO.Directory.CreateDirectory(pathOfTemp); } string tempFile = pathOfTemp + System.Guid.NewGuid() + "." + this.FileExts; // string tempFile = SystemConfig.PathOfTemp + + this.FileName; try { if (System.IO.File.Exists(tempFile) == true) { System.IO.File.Delete(tempFile); } } catch { // tempFile = SystemConfig.PathOfTemp + System.Guid.NewGuid() + this.FileName; } FtpSupport.FtpConnection conn = new FtpSupport.FtpConnection(SystemConfig.FTPServerIP, SystemConfig.FTPUserNo, SystemConfig.FTPUserPassword); conn.GetFile(this.FileFullName, tempFile, false, System.IO.FileAttributes.Archive); return(tempFile); }
/// <summary> /// 打开流程 /// </summary> /// <param name="para"></param> public void DoOpenFlow(AtPara para) { string fk_flow = para.GetValStrByKey("FK_Flow"); int workid = para.GetValIntByKey("WorkID"); int fk_node = para.GetValIntByKey("FK_Node"); if (WebUser.WorkID == workid && WebUser.FK_Node == fk_node) { if (MessageBox.Show("当前流程已经打开,您想重新加载吗?", "提示", MessageBoxButtons.YesNo, MessageBoxIcon.Question, MessageBoxDefaultButton.Button2) == DialogResult.No) { this.webBrowser1.GoBack(); return; } } string file = Glo.PathOfTInstall + workid + "@" + WebUser.No + ".doc"; if (File.Exists(file) == false) { try { FtpSupport.FtpConnection conn = Glo.HisFtpConn; if (conn.DirectoryExist("/DocFlow/" + fk_flow + "/" + workid)) { conn.SetCurrentDirectory("/DocFlow/" + fk_flow + "/" + workid); conn.GetFile(workid + ".doc", file, true, FileAttributes.Archive); conn.Close(); } else { throw new Exception("@没有找到文件,流程文件丢失错误。"); } } catch (Exception ex) { MessageBox.Show("@打开公文错误@技术信息:" + ex.Message + "@流程编号:" + WebUser.FK_Flow); return; } } WebUser.FK_Flow = fk_flow; WebUser.FK_Node = fk_node; WebUser.WorkID = workid; WebUser.RetrieveWFNode(WebUser.FK_Node); /*如果存在这个文件,就激活它。*/ WebUser.WriterIt(StartFlag.DoOpenFlow, fk_flow, fk_node, workid); this.OpenDoc(file, false); this.Close(); }
/// <summary> /// 发起流程 /// </summary> /// <param name="para"></param> public void DoStartFlow(AtPara para) { string fk_flow = para.GetValStrByKey("FK_Flow"); string workid = para.GetValStrByKey("WorkID"); string file = Glo.PathOfTInstall + workid + "@" + WebUser.No + ".doc"; if (File.Exists(file) == false) { try { FtpSupport.FtpConnection conn = Glo.HisFtpConn; if (conn.DirectoryExist("/DocFlow/" + fk_flow + "/" + workid)) { conn.SetCurrentDirectory("/DocFlow/" + fk_flow + "/" + workid); if (conn.FileExist(WebUser.FK_Node + "@" + WebUser.No + ".doc")) { conn.GetFile(WebUser.FK_Node + "@" + WebUser.No + ".doc", file, true, FileAttributes.Archive); } else { file = null; } } else { file = null; } conn.Close(); } catch (Exception ex) { MessageBox.Show("@流程设计错误,没有为该流程维护公文模板。@技术信息:" + ex.Message + "@流程编号:" + WebUser.FK_Flow); return; } } WebUser.FK_Flow = fk_flow; WebUser.WorkID = int.Parse(workid); /*如果存在这个文件,就激活它。*/ WebUser.WriterIt(StartFlag.DoNewFlow, fk_flow, int.Parse(fk_flow + "01"), int.Parse(workid)); this.OpenDoc(file, false); this.Close(); }
public void DoOpenDoc(AtPara para) { string fk_flow = para.GetValStrByKey("FK_Flow"); int workid = para.GetValIntByKey("WorkID"); int fk_node = para.GetValIntByKey("FK_Node"); string file = Glo.PathOfTInstall + workid + "@" + WebUser.No + ".doc"; if (File.Exists(file) == false) { try { FtpSupport.FtpConnection conn = Glo.HisFtpConn; if (conn.DirectoryExist("/DocFlow/" + fk_flow + "/" + workid)) { conn.SetCurrentDirectory("/DocFlow/" + fk_flow + "/" + workid); conn.GetFile(workid + ".doc", file, true, FileAttributes.Archive); conn.Close(); } else { throw new Exception("@没有找到文件,流程错误。"); } } catch (Exception ex) { MessageBox.Show("@打开公文错误@技术信息:" + ex.Message + "@流程编号:" + WebUser.FK_Flow); return; } } WebUser.FK_Flow = fk_flow; WebUser.FK_Node = fk_node; WebUser.WorkID = workid; WebUser.RetrieveWFNode(WebUser.FK_Node); /*如果存在这个文件,就激活它。*/ WebUser.WriterIt(StartFlag.DoOpenDoc, fk_flow, fk_node, workid); this.OpenDoc(file, false); this.HisRibbon1.SetState(); this.Close(); }
/// <summary> /// 按照模板生成公文 /// </summary> /// <param name="para"></param> public void DoStartFlowByTemple(AtPara para) { string fk_flow = para.GetValStrByKey("FK_Flow"); // 下载流程模板 FtpSupport.FtpConnection conn = Glo.HisFtpConn; string file = Glo.PathOfTInstall + fk_flow + "@" + DateTime.Now.ToString("MM月dd日hh时mm分ss秒") + ".doc"; try { conn.SetCurrentDirectory("/DocFlowTemplete/"); if (conn.FileExist(fk_flow + ".doc") == false) { throw new Exception("@没有为公文启动设置模板。"); } conn.GetFile(fk_flow + ".doc", file, true, FileAttributes.Archive); conn.Close(); } catch (Exception ex) { conn.Close(); file = null; MessageBox.Show("@异常信息:" + ex.Message + "\t\n@流程编号:" + WebUser.FK_Flow + "\t\n@可能的原因如下:1,设计人员没有正确的设置ftp服务器。 \t\n2,没有该流程的公文模板。"); } WebUser.WorkID = 0; WebUser.FK_Flow = fk_flow; WebUser.FK_Node = int.Parse(fk_flow + "01"); WebUser.RetrieveWFNode(WebUser.FK_Node); this.HisRibbon1.SetState(); WebUser.WriterIt(StartFlag.DoNewFlow, fk_flow, int.Parse(fk_flow + "01"), 0); this.OpenDoc(file, false); this.Close(); }
public string FtpMethod(string doType, string v1, string v2, string v3) { try { FtpSupport.FtpConnection conn = new FtpSupport.FtpConnection("192.168.1.138", "administrator", "jiaozi"); switch (doType) { case "ShareFrm": /*共享模板*/ MapData md = new MapData(); DataSet ds = md.GenerHisDataSet(); string file = BP.SystemConfig.PathOfTemp + v1 + "_" + v2 + "_" + DateTime.Now.ToString("MM-dd hh-mm") + ".xml"; ds.WriteXml(file); conn.SetCurrentDirectory("/"); conn.SetCurrentDirectory("/Upload.Form/"); conn.SetCurrentDirectory(v3); conn.PutFile(file, md.Name + ".xml"); conn.Close(); return(null); case "GetDirs": // return "@01.日常办公@02.人力资源@03.其它类"; conn.SetCurrentDirectory(v1); FtpSupport.Win32FindData[] dirs = conn.FindFiles(); conn.Close(); string dirsStr = ""; foreach (FtpSupport.Win32FindData dir in dirs) { dirsStr += "@" + dir.FileName; } return(dirsStr); case "GetFls": conn.SetCurrentDirectory(v1); FtpSupport.Win32FindData[] fls = conn.FindFiles(); conn.Close(); string myfls = ""; foreach (FtpSupport.Win32FindData fl in fls) { myfls += "@" + fl.FileName; } return(myfls); case "LoadTempleteFile": string fileFtpPath = v1; conn.SetCurrentDirectory("/Form.表单模版/"); conn.SetCurrentDirectory(v3); /*下载文件到指定的目录: */ string tempFile = BP.SystemConfig.PathOfTemp + "\\" + v2 + ".xml"; conn.GetFile(v1, tempFile, false, FileAttributes.Archive, FtpSupport.FtpTransferType.Ascii); return(this.LoadFrmTempleteFile(tempFile, v2, true, true)); default: return(null); } } catch (Exception ex) { return("Error:" + ex.Message); } }