protected void Page_Load(object sender, EventArgs e) { if (this.IsPostBack == false) { BP.WF.Flow fl = new BP.WF.Flow(this.FK_Flow); //设置状态. if (fl.DTSWay == BP.WF.Template.FlowDTSWay.None) { this.RB_DTSWay0.Checked = true; } else { this.RB_DTSWay1.Checked = true; } //绑定数据源. BP.Sys.SFDBSrcs srcs = new BP.Sys.SFDBSrcs(); srcs.RetrieveAll(); BP.Web.Controls.Glo.DDL_BindEns(this.DDL_DBSrc, srcs, fl.DTSDBSrc); //设置自动. this.DDL_DBSrc.AutoPostBack = true; this.DDL_DBSrc.SelectedIndexChanged += new EventHandler(DDL_DBSrc_SelectedIndexChanged); //绑定表. BP.Sys.SFDBSrc src = new SFDBSrc(fl.DTSDBSrc); DataTable dt = src.GetTables(); dt = RemoveView(dt);//去除视图 BP.Web.Controls.Glo.DDL_BindDataTable(this.DDL_Table, dt, fl.DTSBTable); //设置自动. this.DDL_Table.AutoPostBack = true; this.DDL_Table.SelectedIndexChanged += new EventHandler(DDL_Table_SelectedIndexChanged); //绑定字段同步的方式. if (fl.DTSField == BP.WF.Template.DTSField.SameNames) { this.RB_DTSField0.Checked = true; } else { this.RB_DTSField1.Checked = true; } //绑定同步的时间. if (fl.DTSTime == BP.WF.Template.FlowDTSTime.AllNodeSend) { this.RB_DTSTime0.Checked = true; } if (fl.DTSTime == BP.WF.Template.FlowDTSTime.SpecNodeSend) { this.RB_DTSTime1.Checked = true; } if (fl.DTSTime == BP.WF.Template.FlowDTSTime.WhenFlowOver) { this.RB_DTSTime2.Checked = true; } } }
protected void BtnSave_Click(object sender, EventArgs e) { //执行保存. BP.WF.Flow en = new BP.WF.Flow(this.FK_Flow); if (this.RB_HandWork.Checked) { en.HisFlowRunWay = BP.WF.FlowRunWay.HandWork; } if (this.RB_SpecEmp.Checked) { en.HisFlowRunWay = BP.WF.FlowRunWay.SpecEmp; en.RunObj = this.TB_SpecEmp.Text; } if (this.RB_DataModel.Checked) { en.RunObj = this.TB_DataModel.Text; en.HisFlowRunWay = BP.WF.FlowRunWay.DataModel; } if (this.RB_InsertModel.Checked) { en.HisFlowRunWay = BP.WF.FlowRunWay.InsertModel; } en.DirectUpdate(); }
public string DTSBTable_Init() { DataSet ds = new DataSet(); //获得数据源的表. BP.Sys.SFDBSrc src = new SFDBSrc("local"); DataTable dt = src.GetTables(); dt.TableName = "Tables"; ds.Tables.Add(dt); //把节点信息放入. BP.WF.Nodes nds = new Nodes(this.FK_Flow); DataTable dtNode = nds.ToDataTableField("Nodes"); ds.Tables.Add(dtNode); // 把流程信息放入. BP.WF.Flow fl = new BP.WF.Flow(this.FK_Flow); DataTable dtFlow = fl.ToDataTableField(this.FK_Flow); ds.Tables.Add(dtFlow); return(BP.Tools.Json.DataSetToJson(ds, false)); }
/// <summary> /// 流程 /// </summary> /// <param name="fl"></param> public void BindIt(BP.WF.Flow fl) { GenerWorkFlows gwfs = new GenerWorkFlows(); QueryObject qo = new QueryObject(gwfs); qo.AddWhereInSQL(GenerWorkFlowAttr.WorkID, " SELECT WorkID FROM WF_GenerWorkFlow WHERE FK_Node IN ( SELECT FK_Node FROM WF_GenerWorkerlist WHERE FK_Emp='" + Web.WebUser.No + "' AND FK_Flow='" + fl.No + "' AND WORKID=WF_GenerWorkFlow.WORKID AND ISENABLE=1 ) "); qo.addOrderBy(GenerWorkFlowAttr.FK_Node, GenerWorkFlowAttr.WorkID); qo.DoQuery(); if (gwfs.Count == 0) { this.UCFlow1.AddMsgOfInfo("流程" + fl.Name, "没有您[" + WebUser.No + WebUser.Name + "]的当前待办工作."); } if (gwfs.Count == 1) { this.Response.Redirect("MyFlow.aspx?FK_Flow=" + fl.No + "&WorkID=" + gwfs[0].GetValByKey(GenerWorkFlowAttr.WorkID).ToString(), true); return; } this.UCFlow1.AddTable(); this.UCFlow1.AddCaptionLeft(fl.Name); this.UCFlow1.AddTR(); this.UCFlow1.AddTDTitle("IDX"); this.UCFlow1.AddTDTitle("标题"); this.UCFlow1.AddTDTitle("停留节点"); this.UCFlow1.AddTDTitle("发起日期"); // this.UCFlow1.AddTDTitle("预先警日期"); this.UCFlow1.AddTDTitle("应完成日期"); this.UCFlow1.AddTDTitle("记录人"); this.UCFlow1.AddTDTitle("工作序号"); this.UCFlow1.AddTREnd(); int i = 0; foreach (GenerWorkFlow gwf in gwfs) { i++; //this.AddTR("onmouseover='TROver(this)' onmouseout='TROut(this)' onclick=\"WinOpen('MyFlow.aspx?FK_Flow="+fl.No+"&WorkID="+dr[WorkAttr.OID ].ToString()+"' )\" " ); this.UCFlow1.AddTR("title='在列表中根据标题选择您的代办工作' onmouseover='TROver(this)' onmouseout='TROut(this)' onclick=\"javascript:window.location.href='MyFlow.aspx?FK_Flow=" + fl.No + "&WorkID=" + gwf.WorkID + "'\" "); this.UCFlow1.AddTDIdx(i); this.UCFlow1.AddTD(gwf.Title); this.UCFlow1.AddTD(gwf.NodeName); this.UCFlow1.AddTD(gwf.RDT); this.UCFlow1.AddTD(""); // this.UCFlow1.AddTD(gwf.w); // this.UCFlow1.AddTD(gwf.RDT); this.UCFlow1.AddTD(gwf.StarterName); //this.UCFlow1.AddTD(gwf.FK_Taxpayer); //this.UCFlow1.AddTD(gwf.TaxpayerName); this.UCFlow1.AddTD(gwf.WorkID); this.UCFlow1.AddTREnd(); } this.UCFlow1.AddTableEnd(); }
public string Limit_Save() { BP.WF.Flow fl = new BP.WF.Flow(this.FK_Flow); fl.StartLimitRole = (StartLimitRole)this.GetRequestValInt("StartLimitRole"); fl.StartLimitPara = this.GetRequestVal("StartLimitPara"); fl.StartLimitAlert = this.GetRequestVal("StartLimitAlert"); fl.Update(); return("保存成功."); }
/// <summary> /// 保存. /// </summary> /// <param name="sender"></param> /// <param name="e"></param> protected void BtnSave_Click(object sender, EventArgs e) { BP.WF.Flow en = new BP.WF.Flow(this.FK_Flow); en.No = this.FK_Flow; en.RetrieveFromDBSources(); if (this.RB_None.Checked) { en.StartGuideWay = BP.WF.Template.StartGuideWay.None; } if (this.RB_ByHistoryUrl.Checked) { en.StartGuidePara1 = this.TB_ByHistoryUrl.Value; en.StartGuidePara2 = ""; en.StartGuideWay = BP.WF.Template.StartGuideWay.ByHistoryUrl; } if (this.RB_SelfUrl.Checked) { en.StartGuidePara1 = this.TB_SelfURL.Value; en.StartGuidePara2 = ""; en.StartGuideWay = BP.WF.Template.StartGuideWay.BySelfUrl; } //单条模式. if (this.RB_BySQLOne.Checked) { en.StartGuidePara1 = this.TB_BySQLOne1.Value; //查询语句. en.StartGuidePara2 = this.TB_BySQLOne2.Value; //列表语句. en.StartGuideWay = BP.WF.Template.StartGuideWay.BySQLOne; } //多条-子父流程-合卷审批. if (this.RB_SubFlow.Checked) { en.StartGuidePara1 = this.TB_SubFlow1.Value; //查询语句. en.StartGuidePara2 = this.TB_SubFlow2.Value; //列表语句. en.StartGuideWay = BP.WF.Template.StartGuideWay.SubFlowGuide; } BP.WF.Template.FrmNodes fns = new BP.WF.Template.FrmNodes(int.Parse(this.FK_Flow + "01")); if (fns.Count >= 2) { if (this.RB_FrmList.Checked) { en.StartGuideWay = BP.WF.Template.StartGuideWay.ByFrms; } } en.Update(); en.DirectUpdate(); }
/// <summary> /// 获取用户已完成列表 /// </summary> /// <param name="userNo"></param> /// <returns></returns> public static string GetCompleateWork(string userNo, string[][] queryParams, int?page, int?pageSize) { UserLogin(userNo); string sql = string.Format("select * from WF_GenerWorkFlow where WFState in({0}) and Emps like '%{1}%'", "'" + (int)BP.WF.WFState.Complete + "'", "@" + userNo); DataTable table = BP.DA.DBAccess.RunSQLReturnTable(sql); table.Columns.Add("TitleUrl"); table.Columns.Add("FlowEmps"); table.Columns.Add("FlowEnderRDT"); string url = ""; foreach (DataRow row in table.Rows) { url = "/WF/WFRpt.aspx?WorkID=" + row["WorkID"] + "&FK_Flow=" + row["FK_Flow"] + "&FK_Node=" + row["FK_Node"] + "&UserNo=" + userNo; row["TitleUrl"] = url; string emps = row["Emps"] + ""; foreach (string single in emps.Split('@')) { if (!string.IsNullOrEmpty(single)) { try { row["FlowEmps"] += new BP.Port.Emp(single).Name + ";"; } catch (Exception ex) { row["FlowEmps"] += single + ";"; } } } BP.WF.Flow flow = new BP.WF.Flow(row["FK_Flow"] + ""); BP.WF.Data.GERpt rpt = flow.HisGERpt; rpt.OID = Int64.Parse(row["WorkID"] + ""); int count = rpt.RetrieveFromDBSources(); if (count > 0) { row["FlowEnderRDT"] = rpt.FlowEnderRDT; } } DataTable filterTable = FilterTable(queryParams, table); DataTable finalTable = PageTable(page, pageSize, table); string xml = WriteTableToXml(finalTable, filterTable.Rows.Count); return(xml); }
protected void Page_Load(object sender, System.EventArgs e) { this.Page.RegisterClientScriptBlock("s", "<link href='/WF/Comm/Style/Table" + BP.Web.WebUser.Style + ".css' rel='stylesheet' type='text/css' />"); string fk_flow = this.Request.QueryString["FK_Flow"]; BP.WF.Flow fl = new BP.WF.Flow(fk_flow); this.BindIt(fl); ///this.GenerLabel(this.Label1, fl.Name); // this.UCFlow1.BindWorkList(fl); }
/// <summary> /// 流程模版导入. /// </summary> /// <returns></returns> public string Imp_Done() { HttpFileCollection files = context.Request.Files; if (files.Count == 0) { return("err@请选择要上传的流程模版。"); } //设置文件名 string fileNewName = DateTime.Now.ToString("yyyyMMddHHmmssff") + "_" + System.IO.Path.GetFileName(files[0].FileName); //文件存放路径 string filePath = BP.Sys.SystemConfig.PathOfTemp + "\\" + fileNewName; files[0].SaveAs(filePath); string flowNo = this.FK_Flow; string FK_FlowSort = this.GetRequestVal("FK_Sort"); //检查流程编号 if (DataType.IsNullOrEmpty(flowNo) == false) { Flow fl = new Flow(flowNo); FK_FlowSort = fl.FK_FlowSort; } //检查流程类别编号 if (DataType.IsNullOrEmpty(FK_FlowSort)) { return("err@所选流程类别编号不存在。"); } //导入模式 BP.WF.ImpFlowTempleteModel model = (BP.WF.ImpFlowTempleteModel) this.GetRequestValInt("ImpWay"); if (model == ImpFlowTempleteModel.AsSpecFlowNo) { flowNo = this.GetRequestVal("SpecFlowNo"); } //执行导入 BP.WF.Flow flow = BP.WF.Flow.DoLoadFlowTemplate(FK_FlowSort, filePath, model, flowNo); Hashtable ht = new Hashtable(); ht.Add("FK_Flow", flow.No); ht.Add("FlowName", flow.Name); ht.Add("FK_FlowSort", flow.FK_FlowSort); ht.Add("Msg", "导入成功,流程编号为:" + flow.No + "名称为:" + flow.Name); return(BP.Tools.Json.ToJson(ht)); }
/// <summary> /// 删除一个流程模版 /// </summary> /// <param name="flowNo">流程编号</param> public static string DeleteFlowTemplete(string flowNo) { BP.WF.Flow fl1 = new BP.WF.Flow(flowNo); try { fl1.DoDelete(); return(null); } catch (Exception ex) { BP.DA.Log.DefaultLogWriteLineError("Do Method DelFlow Branch has a error , para:\t" + flowNo + ex.Message); return(ex.Message); } }
protected void Page_Load(object sender, EventArgs e) { switch (this.DoType) { case "FlowCheck": this.Title = "流程检查"; BP.WF.Flow fl = new BP.WF.Flow(this.RefNo); this.Ucsys1.AddFieldSet("流程检查信息"); this.Ucsys1.Add(fl.DoCheck()); // 流程检查信息 this.Ucsys1.AddFieldSetEnd(); break; default: this.Ucsys1.AddMsgOfInfo("错误标记", this.DoType); break; } }
protected void Page_Load(object sender, EventArgs e) { if (this.IsPostBack == false) { BP.WF.Flow en = new BP.WF.Flow(this.FK_Flow); en.No = this.FK_Flow; en.RetrieveFromDBSources(); switch (en.StartGuideWay) { case BP.WF.Template.StartGuideWay.None: //无 this.RB_None.Checked = true; break; case BP.WF.Template.StartGuideWay.ByHistoryUrl: //从开始节点Copy数据 this.RB_ByHistoryUrl.Checked = true; this.TB_ByHistoryUrl.Value = en.StartGuidePara1; break; case BP.WF.Template.StartGuideWay.BySelfUrl: //按自定义的Url this.RB_SelfUrl.Checked = true; this.TB_SelfURL.Value = en.StartGuidePara1; break; case BP.WF.Template.StartGuideWay.BySQLOne: //按照参数. this.RB_BySQLOne.Checked = true; this.TB_BySQLOne1.Value = en.StartGuidePara1; this.TB_BySQLOne2.Value = en.StartGuidePara2; break; case BP.WF.Template.StartGuideWay.ByFrms: this.RB_FrmList.Checked = true; break; case BP.WF.Template.StartGuideWay.SubFlowGuide: //子父流程多条模式- 合卷审批. this.RB_SubFlow.Checked = true; this.TB_SubFlow1.Value = en.StartGuidePara1; this.TB_SubFlow2.Value = en.StartGuidePara2; break; default: break; } } }
protected void Page_Load(object sender, EventArgs e) { switch (this.DoType) { case "FlowCheck": BP.WF.Flow fl = new BP.WF.Flow(this.RefNo); this.Ucsys1.AddFieldSet("流程检查信息"); this.Title = fl.Name + "流程检查"; string info = fl.DoCheck().Replace("@", "<BR>@"); info = info.Replace("@错误", "<font color=red><b>@错误</b></font>"); info = info.Replace("@警告", "<font color=yellow><b>@警告</b></font>"); info = info.Replace("@信息", "<font color=black><b>@信息</b></font>"); this.Ucsys1.Add(info); // 流程检查信息 this.Ucsys1.AddFieldSetEnd(); break; default: this.Ucsys1.AddMsgOfInfo("错误标记", this.DoType); break; } }
/// <summary> /// 保存文件,在这里做修改就可以了. /// </summary> public void SaveFile() { BP.Sys.FrmAttachment athDesc = new BP.Sys.FrmAttachment(this.FK_FrmAttachment); System.Web.UI.WebControls.FileUpload fu = null; //this.Pub1.FindControl("file")as System.Web.UI.WebControls.FileUpload; if (fu.HasFile == false || fu.FileName.Length <= 2) { this.Alert("请选择上传的文件."); return; } string exts = System.IO.Path.GetExtension(fu.FileName).ToLower().Replace(".", ""); //如果有上传类型限制,进行判断格式 if (athDesc.Exts == "*.*" || athDesc.Exts == "") { /*任何格式都可以上传*/ } else { if (athDesc.Exts.ToLower().Contains(exts) == false) { this.Alert("您上传的文件,不符合系统的格式要求,要求的文件格式:" + athDesc.Exts + ",您现在上传的文件格式为:" + exts); return; } } string savePath = athDesc.SaveTo; if (savePath.Contains("@") == true || savePath.Contains("*") == true) { /*如果有变量*/ savePath = savePath.Replace("*", "@"); GEEntity en = new GEEntity(athDesc.FK_MapData); en.PKVal = this.PKVal; en.Retrieve(); savePath = BP.WF.Glo.DealExp(savePath, en, null); if (savePath.Contains("@") && this.FK_Node != null) { /*如果包含 @ */ BP.WF.Flow flow = new BP.WF.Flow(this.FK_Flow); BP.WF.Data.GERpt myen = flow.HisGERpt; myen.OID = this.WorkID; myen.RetrieveFromDBSources(); savePath = BP.WF.Glo.DealExp(savePath, myen, null); } if (savePath.Contains("@") == true) throw new Exception("@路径配置错误,变量没有被正确的替换下来." + savePath); } else { //savePath = athDesc.SaveTo + "\\" + this.PKVal; } //替换关键的字串. savePath = savePath.Replace("\\\\", "\\"); savePath = Server.MapPath("~/" + savePath); try { if (System.IO.Directory.Exists(savePath) == false) System.IO.Directory.CreateDirectory(savePath); } catch (Exception ex) { throw new Exception("@创建路径出现错误,可能是没有权限或者路径配置有问题:" + Server.MapPath("~/" + savePath) + "===" + savePath + "@技术问题:" + ex.Message); } string guid = BP.DA.DBAccess.GenerGUID(); string fileName = fu.FileName.Substring(0, fu.FileName.LastIndexOf('.')); string ext = System.IO.Path.GetExtension(fu.FileName); //string realSaveTo = Server.MapPath("~/" + savePath) + "/" + guid + "." + fileName + "." + ext; //string realSaveTo = Server.MapPath("~/" + savePath) + "\\" + guid + "." + fu.FileName.Substring(fu.FileName.LastIndexOf('.') + 1); //string saveTo = savePath + "/" + guid + "." + fileName + "." + ext; string realSaveTo = savePath + "/" + guid + "." + fileName + ext; string saveTo = realSaveTo; try { fu.SaveAs(realSaveTo); } catch (Exception ex) { this.Response.Write("@文件存储失败,有可能是路径的表达式出问题,导致是非法的路径名称:" + ex.Message); return; } FileInfo info = new FileInfo(realSaveTo); FrmAttachmentDB dbUpload = new FrmAttachmentDB(); dbUpload.MyPK = guid; // athDesc.FK_MapData + oid.ToString(); dbUpload.NodeID = FK_Node.ToString(); dbUpload.FK_FrmAttachment = this.FK_FrmAttachment; if (athDesc.AthUploadWay == AthUploadWay.Inherit) { /*如果是继承,就让他保持本地的PK. */ dbUpload.RefPKVal = this.PKVal.ToString(); } if (athDesc.AthUploadWay == AthUploadWay.Interwork) { /*如果是协同,就让他是PWorkID. */ string pWorkID = BP.DA.DBAccess.RunSQLReturnValInt("SELECT PWorkID FROM WF_GenerWorkFlow WHERE WorkID=" + this.PKVal, 0).ToString(); if (pWorkID == null || pWorkID == "0") pWorkID = this.PKVal; dbUpload.RefPKVal = pWorkID; } dbUpload.FK_MapData = athDesc.FK_MapData; dbUpload.FK_FrmAttachment = this.FK_FrmAttachment; dbUpload.FileExts = info.Extension; dbUpload.FileFullName = saveTo; dbUpload.FileName = fu.FileName; dbUpload.FileSize = (float)info.Length; dbUpload.RDT = DataType.CurrentDataTimess; dbUpload.Rec = BP.Web.WebUser.No; dbUpload.RecName = BP.Web.WebUser.Name; //if (athDesc.IsNote) // dbUpload.MyNote = this.Pub1.GetTextBoxByID("TB_Note").Text; //if (athDesc.Sort.Contains(",")) // dbUpload.Sort = this.Pub1.GetDDLByID("ddl").SelectedItemStringVal; dbUpload.UploadGUID = guid; dbUpload.Insert(); }
public void DTS_Flow(BP.WF.Flow fl) { #region 读取数据. BP.Sys.MapExt me = new MapExt(); me.MyPK = "ND" + int.Parse(fl.No) + "01" + "_" + MapExtXmlList.StartFlow; int i = me.RetrieveFromDBSources(); if (i == 0) { BP.DA.Log.DefaultLogWriteLineError("没有为流程(" + fl.Name + ")的开始节点设置发起数据,请参考说明书解决."); return; } if (string.IsNullOrEmpty(me.Tag)) { BP.DA.Log.DefaultLogWriteLineError("没有为流程(" + fl.Name + ")的开始节点设置发起数据,请参考说明书解决."); return; } // 获取从表数据. DataSet ds = new DataSet(); string[] dtlSQLs = me.Tag1.Split('*'); foreach (string sql in dtlSQLs) { if (string.IsNullOrEmpty(sql)) { continue; } string[] tempStrs = sql.Split('='); string dtlName = tempStrs[0]; DataTable dtlTable = BP.DA.DBAccess.RunSQLReturnTable(sql.Replace(dtlName + "=", "")); dtlTable.TableName = dtlName; ds.Tables.Add(dtlTable); } #endregion 读取数据. #region 检查数据源是否正确. string errMsg = ""; // 获取主表数据. DataTable dtMain = BP.DA.DBAccess.RunSQLReturnTable(me.Tag); if (dtMain.Rows.Count == 0) { BP.DA.Log.DefaultLogWriteLineError("流程(" + fl.Name + ")此时无任务."); this.SetText("流程(" + fl.Name + ")此时无任务."); return; } this.SetText("@查询到(" + dtMain.Rows.Count + ")条任务."); if (dtMain.Columns.Contains("Starter") == false) { errMsg += "@配值的主表中没有Starter列."; } if (dtMain.Columns.Contains("MainPK") == false) { errMsg += "@配值的主表中没有MainPK列."; } if (errMsg.Length > 2) { this.SetText(errMsg); BP.DA.Log.DefaultLogWriteLineError("流程(" + fl.Name + ")的开始节点设置发起数据,不完整." + errMsg); return; } #endregion 检查数据源是否正确. #region 处理流程发起. string nodeTable = "ND" + int.Parse(fl.No) + "01"; int idx = 0; foreach (DataRow dr in dtMain.Rows) { idx++; string mainPK = dr["MainPK"].ToString(); string sql = "SELECT OID FROM " + nodeTable + " WHERE MainPK='" + mainPK + "'"; if (DBAccess.RunSQLReturnTable(sql).Rows.Count != 0) { this.SetText("@" + fl.Name + ",第" + idx + "条,此任务在之前已经完成。"); continue; /*说明已经调度过了*/ } string starter = dr["Starter"].ToString(); if (WebUser.No != starter) { BP.Web.WebUser.Exit(); BP.Port.Emp emp = new BP.Port.Emp(); emp.No = starter; if (emp.RetrieveFromDBSources() == 0) { this.SetText("@" + fl.Name + ",第" + idx + "条,设置的发起人员:" + emp.No + "不存在."); BP.DA.Log.DefaultLogWriteLineInfo("@数据驱动方式发起流程(" + fl.Name + ")设置的发起人员:" + emp.No + "不存在。"); continue; } WebUser.SignInOfGener(emp); } #region 给值. //System.Collections.Hashtable ht = new Hashtable(); Work wk = fl.NewWork(); string err = ""; #region 检查用户拼写的sql是否正确? foreach (DataColumn dc in dtMain.Columns) { string f = dc.ColumnName.ToLower(); switch (f) { case "starter": case "mainpk": case "refmainpk": case "tonode": break; default: bool isHave = false; foreach (Attr attr in wk.EnMap.Attrs) { if (attr.Key.ToLower() == f) { isHave = true; break; } } if (isHave == false) { err += " " + f + " "; } break; } } if (string.IsNullOrEmpty(err) == false) { throw new Exception("您设置的字段:" + err + "不存在开始节点的表单中,设置的sql:" + me.Tag); } #endregion 检查用户拼写的sql是否正确? foreach (DataColumn dc in dtMain.Columns) { wk.SetValByKey(dc.ColumnName, dr[dc.ColumnName].ToString()); } if (ds.Tables.Count != 0) { // MapData md = new MapData(nodeTable); MapDtls dtls = new MapDtls(nodeTable); foreach (MapDtl dtl in dtls) { foreach (DataTable dt in ds.Tables) { if (dt.TableName != dtl.No) { continue; } //删除原来的数据。 GEDtl dtlEn = dtl.HisGEDtl; dtlEn.Delete(GEDtlAttr.RefPK, wk.OID.ToString()); // 执行数据插入。 foreach (DataRow drDtl in dt.Rows) { if (drDtl["RefMainPK"].ToString() != mainPK) { continue; } dtlEn = dtl.HisGEDtl; foreach (DataColumn dc in dt.Columns) { dtlEn.SetValByKey(dc.ColumnName, drDtl[dc.ColumnName].ToString()); } dtlEn.RefPK = wk.OID.ToString(); dtlEn.OID = 0; dtlEn.Insert(); } } } } #endregion 给值. int toNodeID = 0; try { toNodeID = int.Parse(dr["ToNode"].ToString()); } catch { /*有可能在4.5以前的版本中没有tonode这个约定.*/ } // 处理发送信息. // Node nd =new Node(); string msg = ""; try { if (toNodeID == 0) { WorkNode wn = new WorkNode(wk, fl.HisStartNode); msg = wn.NodeSend().ToMsgOfText(); } if (toNodeID == fl.StartNodeID) { /* 发起后让它停留在开始节点上,就是为开始节点创建一个待办。*/ Int64 workID = BP.WF.Dev2Interface.Node_CreateStartNodeWork(fl.No, null, null, WebUser.No, null); if (workID != wk.OID) { throw new Exception("@异常信息:不应该不一致的workid."); } else { wk.Update(); } msg = "已经为(" + WebUser.No + ") 创建了开始工作节点. "; } BP.DA.Log.DefaultLogWriteLineInfo(msg); this.SetText("@" + fl.Name + ",第" + idx + "条,发起人员:" + WebUser.No + "-" + WebUser.Name + "已完成.\r\n" + msg); } catch (Exception ex) { this.SetText("@" + fl.Name + ",第" + idx + "条,发起人员:" + WebUser.No + "-" + WebUser.Name + "发起时出现错误.\r\n" + ex.Message); BP.DA.Log.DefaultLogWriteLineWarning(ex.Message); } } #endregion 处理流程发起. }
private void button1_Click(object sender, EventArgs e) { BP.WF.Flow fl = new BP.WF.Flow("040"); BP.WF.Dev2Interface.DTS_AutoStarterFlow(fl); }
//多附件上传方法 public void MoreAttach() { string PKVal = this.GetRequestVal("PKVal"); string attachPk = this.GetRequestVal("AttachPK"); // 多附件描述. BP.Sys.FrmAttachment athDesc = new BP.Sys.FrmAttachment(attachPk); MapData mapData = new MapData(athDesc.FK_MapData); string msg = null; GEEntity en = new GEEntity(athDesc.FK_MapData); en.PKVal = PKVal; en.Retrieve(); for (int i = 0; i < context.Request.Files.Count; i++) { HttpPostedFile file = context.Request.Files[i]; #region 文件上传的iis服务器上 or db数据库里. if (athDesc.AthSaveWay == AthSaveWay.IISServer) { string savePath = athDesc.SaveTo; if (savePath.Contains("@") == true || savePath.Contains("*") == true) { /*如果有变量*/ savePath = savePath.Replace("*", "@"); savePath = BP.WF.Glo.DealExp(savePath, en, null); if (savePath.Contains("@") && this.FK_Node != 0) { /*如果包含 @ */ BP.WF.Flow flow = new BP.WF.Flow(this.FK_Flow); BP.WF.Data.GERpt myen = flow.HisGERpt; myen.OID = this.WorkID; myen.RetrieveFromDBSources(); savePath = BP.WF.Glo.DealExp(savePath, myen, null); } if (savePath.Contains("@") == true) { throw new Exception("@路径配置错误,变量没有被正确的替换下来." + savePath); } } else { savePath = athDesc.SaveTo + "\\" + PKVal; } //替换关键的字串. savePath = savePath.Replace("\\\\", "\\"); try { savePath = context.Server.MapPath("~/" + savePath); } catch (Exception) { } try { if (System.IO.Directory.Exists(savePath) == false) { System.IO.Directory.CreateDirectory(savePath); } } catch (Exception ex) { throw new Exception("@创建路径出现错误,可能是没有权限或者路径配置有问题:" + context.Server.MapPath("~/" + savePath) + "===" + savePath + "@技术问题:" + ex.Message); } string exts = System.IO.Path.GetExtension(file.FileName).ToLower().Replace(".", ""); string guid = BP.DA.DBAccess.GenerGUID(); string fileName = file.FileName.Substring(0, file.FileName.LastIndexOf('.')); if (fileName.LastIndexOf("\\") > 0) { fileName = fileName.Substring(fileName.LastIndexOf("\\") + 1); } string ext = System.IO.Path.GetExtension(file.FileName); string realSaveTo = savePath + "\\" + guid + "." + fileName + ext; realSaveTo = realSaveTo.Replace("~", "-"); realSaveTo = realSaveTo.Replace("'", "-"); realSaveTo = realSaveTo.Replace("*", "-"); file.SaveAs(realSaveTo); //执行附件上传前事件,added by liuxc,2017-7-15 msg = mapData.DoEvent(FrmEventList.AthUploadeBefore, en, "@FK_FrmAttachment=" + athDesc.MyPK + "@FileFullName=" + realSaveTo); if (!string.IsNullOrEmpty(msg)) { BP.Sys.Glo.WriteLineError("@AthUploadeBefore事件返回信息,文件:" + file.FileName + "," + msg); try { File.Delete(realSaveTo); } catch { } //note:此处如何向前uploadify传递失败信息,有待研究 //this.Alert("上传附件错误:" + msg, true); return; } FileInfo info = new FileInfo(realSaveTo); FrmAttachmentDB dbUpload = new FrmAttachmentDB(); dbUpload.MyPK = guid; // athDesc.FK_MapData + oid.ToString(); dbUpload.NodeID = this.FK_Node.ToString(); dbUpload.FK_FrmAttachment = attachPk; dbUpload.FK_MapData = athDesc.FK_MapData; dbUpload.FK_FrmAttachment = attachPk; dbUpload.FileExts = info.Extension; #region 处理文件路径,如果是保存到数据库,就存储pk. if (athDesc.AthSaveWay == AthSaveWay.IISServer) { //文件方式保存 dbUpload.FileFullName = realSaveTo; } if (athDesc.AthSaveWay == AthSaveWay.FTPServer) { //保存到数据库 dbUpload.FileFullName = dbUpload.MyPK; } #endregion 处理文件路径,如果是保存到数据库,就存储pk. dbUpload.FileName = fileName + ext; dbUpload.FileSize = (float)info.Length; dbUpload.RDT = DataType.CurrentDataTimess; dbUpload.Rec = BP.Web.WebUser.No; dbUpload.RecName = BP.Web.WebUser.Name; dbUpload.RefPKVal = PKVal; dbUpload.FID = this.FID; //if (athDesc.IsNote) // dbUpload.MyNote = this.Pub1.GetTextBoxByID("TB_Note").Text; //if (athDesc.Sort.Contains(",")) // dbUpload.Sort = this.Pub1.GetDDLByID("ddl").SelectedItemStringVal; dbUpload.UploadGUID = guid; dbUpload.Insert(); if (athDesc.AthSaveWay == AthSaveWay.DB) { //执行文件保存. BP.DA.DBAccess.SaveFileToDB(realSaveTo, dbUpload.EnMap.PhysicsTable, "MyPK", dbUpload.MyPK, "FDB"); } //执行附件上传后事件,added by liuxc,2017-7-15 msg = mapData.DoEvent(FrmEventList.AthUploadeAfter, en, "@FK_FrmAttachment=" + dbUpload.FK_FrmAttachment + "@FK_FrmAttachmentDB=" + dbUpload.MyPK + "@FileFullName=" + dbUpload.FileFullName); if (!string.IsNullOrEmpty(msg)) { BP.Sys.Glo.WriteLineError("@AthUploadeAfter事件返回信息,文件:" + dbUpload.FileName + "," + msg); } } #endregion 文件上传的iis服务器上 or db数据库里. #region 保存到数据库 / FTP服务器上. if (athDesc.AthSaveWay == AthSaveWay.DB || athDesc.AthSaveWay == AthSaveWay.FTPServer) { string guid = DBAccess.GenerGUID(); //把文件临时保存到一个位置. string temp = SystemConfig.PathOfTemp + "" + guid + ".tmp"; try { file.SaveAs(temp); } catch (Exception ex) { System.IO.File.Delete(temp); file.SaveAs(temp); } // fu.SaveAs(temp); //执行附件上传前事件,added by liuxc,2017-7-15 msg = mapData.DoEvent(FrmEventList.AthUploadeBefore, en, "@FK_FrmAttachment=" + athDesc.MyPK + "@FileFullName=" + temp); if (string.IsNullOrEmpty(msg) == false) { BP.Sys.Glo.WriteLineError("@AthUploadeBefore事件返回信息,文件:" + file.FileName + "," + msg); try { File.Delete(temp); } catch { } throw new Exception("err@上传附件错误:" + msg); } FileInfo info = new FileInfo(temp); FrmAttachmentDB dbUpload = new FrmAttachmentDB(); dbUpload.MyPK = BP.DA.DBAccess.GenerGUID(); dbUpload.NodeID = FK_Node.ToString(); dbUpload.FK_FrmAttachment = athDesc.MyPK; dbUpload.FID = this.FID; //流程id. if (athDesc.AthUploadWay == AthUploadWay.Inherit) { /*如果是继承,就让他保持本地的PK. */ dbUpload.RefPKVal = PKVal.ToString(); } if (athDesc.AthUploadWay == AthUploadWay.Interwork) { /*如果是协同,就让他是PWorkID. */ Paras ps = new Paras(); ps.SQL = "SELECT PWorkID FROM WF_GenerWorkFlow WHERE WorkID=" + SystemConfig.AppCenterDBVarStr + "WorkID"; ps.Add("WorkID", PKVal); string pWorkID = BP.DA.DBAccess.RunSQLReturnValInt(ps, 0).ToString(); if (pWorkID == null || pWorkID == "0") { pWorkID = PKVal; } dbUpload.RefPKVal = pWorkID; } dbUpload.FK_MapData = athDesc.FK_MapData; dbUpload.FK_FrmAttachment = athDesc.MyPK; dbUpload.FileName = file.FileName; dbUpload.FileSize = (float)info.Length; dbUpload.RDT = DataType.CurrentDataTimess; dbUpload.Rec = BP.Web.WebUser.No; dbUpload.RecName = BP.Web.WebUser.Name; //if (athDesc.IsNote) // dbUpload.MyNote = this.Pub1.GetTextBoxByID("TB_Note").Text; //if (athDesc.Sort.Contains(",")) //{ // string[] strs = athDesc.Sort.Contains("@") == true ? athDesc.Sort.Substring(athDesc.Sort.LastIndexOf("@") + 1).Split(',') : athDesc.Sort.Split(','); // BP.Web.Controls.DDL ddl = this.Pub1.GetDDLByID("ddl"); // dbUpload.Sort = strs[0]; // if (ddl != null) // { // int selectedIndex = string.IsNullOrEmpty(ddl.SelectedItemStringVal) ? 0 : int.Parse(ddl.SelectedItemStringVal); // dbUpload.Sort = strs[selectedIndex]; // } //} dbUpload.UploadGUID = guid; if (athDesc.AthSaveWay == AthSaveWay.DB) { dbUpload.Insert(); //把文件保存到指定的字段里. dbUpload.SaveFileToDB("FileDB", temp); } if (athDesc.AthSaveWay == AthSaveWay.FTPServer) { /*保存到fpt服务器上.*/ FtpSupport.FtpConnection ftpconn = new FtpSupport.FtpConnection(SystemConfig.FTPServerIP, SystemConfig.FTPUserNo, SystemConfig.FTPUserPassword); string ny = DateTime.Now.ToString("yyyy_MM"); //判断目录年月是否存在. if (ftpconn.DirectoryExist(ny) == false) { ftpconn.CreateDirectory(ny); } ftpconn.SetCurrentDirectory(ny); //判断目录是否存在. if (ftpconn.DirectoryExist(athDesc.FK_MapData) == false) { ftpconn.CreateDirectory(athDesc.FK_MapData); } //设置当前目录,为操作的目录。 ftpconn.SetCurrentDirectory(athDesc.FK_MapData); //把文件放上去. ftpconn.PutFile(temp, guid + "." + dbUpload.FileExts); ftpconn.Close(); //设置路径. dbUpload.FileFullName = ny + "//" + athDesc.FK_MapData + "//" + guid + "." + dbUpload.FileExts; dbUpload.Insert(); } //执行附件上传后事件,added by liuxc,2017-7-15 msg = mapData.DoEvent(FrmEventList.AthUploadeAfter, en, "@FK_FrmAttachment=" + dbUpload.FK_FrmAttachment + "@FK_FrmAttachmentDB=" + dbUpload.MyPK + "@FileFullName=" + temp); if (!string.IsNullOrEmpty(msg)) { BP.Sys.Glo.WriteLineError("@AthUploadeAfter事件返回信息,文件:" + dbUpload.FileName + "," + msg); } } #endregion 保存到数据库. } }
public void InitToolbarOfMapRpt(BP.WF.Flow fl, BP.WF.Rpt.MapRpt currMapRpt, string RptNo, Entity en, int pageidx) { Map map = en.EnMap; this.InitByMapV2(map, 1, RptNo); //特殊处理权限. AttrSearchs searchs = map.SearchAttrs; string defVal = ""; System.Data.DataTable dt = null; foreach (AttrSearch attr in searchs) { DDL mydll = this.GetDDLByKey("DDL_" + attr.Key); if (mydll == null) { continue; } defVal = mydll.SelectedItemStringVal; mydll.Attributes["onchange"] = "DDL_mvals_OnChange(this,'" + RptNo + "','" + attr.Key + "')"; switch (attr.HisAttr.Key) { case "FK_NY": dt = DBAccess.RunSQLReturnTable("SELECT DISTINCT FK_NY FROM " + currMapRpt.PTable + " WHERE FK_NY!='' ORDER BY FK_NY"); mydll.Items.Clear(); mydll.Items.Add(new ListItem("=>月份", "all")); foreach (DataRow dr in dt.Rows) { mydll.Items.Add(new ListItem(dr[0].ToString(), dr[0].ToString())); } mydll.SetSelectItem(defVal); break; case "FlowStarter": case "FlowEnder": string sql = ""; switch (fl.HisFlowDeptDataRightCtrlType) { case FlowDeptDataRightCtrlType.MyDeptOnly: // 我的部门. sql = "SELECT No,Name FROM WF_Emp WHERE FK_Dept='" + WebUser.FK_Dept + "' AND No IN (SELECT DISTINCT FlowStarter FROM " + currMapRpt.PTable + " WHERE FlowStarter!='')"; break; case FlowDeptDataRightCtrlType.MyDeptAndBeloneToMyDeptOnly: //我的部门,或者隶属我部门下面的部门. #warning 这里有错误,怎么递归循环出来? sql = "SELECT No,Name FROM WF_Emp WHERE FK_Dept IN (SELECT FK_Dept FROM WF_DeptFlowSearch WHERE FK_Emp='" + WebUser.No + "' AND FK_Flow='" + currMapRpt.FK_Flow + "') AND No IN (SELECT DISTINCT FlowStarter FROM " + currMapRpt.PTable + " WHERE FlowStarter!='')"; break; case FlowDeptDataRightCtrlType.BySpecFlowDept: // 指定权限. sql = "SELECT No,Name FROM WF_Emp WHERE FK_Dept IN (SELECT FK_Dept FROM WF_DeptFlowSearch WHERE FK_Emp='" + WebUser.No + "' AND FK_Flow='" + currMapRpt.FK_Flow + "') AND No IN (SELECT DISTINCT FlowStarter FROM " + currMapRpt.PTable + " WHERE FlowStarter!='')"; break; case FlowDeptDataRightCtrlType.AnyoneAndAnydept: // 任何部门. sql = "SELECT No,Name FROM WF_Emp WHERE No IN (SELECT DISTINCT FlowStarter FROM " + currMapRpt.PTable + " WHERE FlowStarter!='')"; break; default: break; } dt = DBAccess.RunSQLReturnTable(sql); mydll.Items.Clear(); if (attr.Key == NDXRptBaseAttr.FlowStarter) { mydll.Items.Add(new ListItem("=>发起人", "all")); } else { mydll.Items.Add(new ListItem("=>结束人", "all")); } foreach (DataRow dr in dt.Rows) { mydll.Items.Add(new ListItem(dr[1].ToString(), dr[0].ToString())); } mydll.SetSelectItem(defVal); mydll.Attributes["onchange"] = "DDL_mvals_OnChange(this,'" + RptNo + "','" + attr.Key + "')"; break; case "FK_Dept": if (WebUser.No != "admin") { dt = DBAccess.RunSQLReturnTable("SELECT No,Name FROM Port_Dept WHERE No IN (SELECT FK_Dept FROM WF_DeptFlowSearch WHERE FK_Emp='" + WebUser.No + "' AND FK_Flow='" + currMapRpt.FK_Flow + "')"); if (dt.Rows.Count == 0) { BP.WF.Port.DeptFlowSearch dfs = new BP.WF.Port.DeptFlowSearch(); dfs.FK_Dept = WebUser.FK_Dept; dfs.FK_Emp = WebUser.No; dfs.FK_Flow = currMapRpt.FK_Flow; dfs.MyPK = WebUser.FK_Dept + "_" + WebUser.No + "_" + currMapRpt.FK_Flow; dfs.Insert(); dt = DBAccess.RunSQLReturnTable("SELECT No,Name FROM Port_Dept WHERE No IN (SELECT FK_Dept FROM WF_DeptFlowSearch WHERE FK_Emp='" + WebUser.No + "' AND FK_Flow='" + currMapRpt.FK_Flow + "')"); } mydll.Items.Clear(); foreach (DataRow dr in dt.Rows) { mydll.Items.Add(new ListItem(dr[1].ToString(), dr[0].ToString())); } } if (mydll.Items.Count >= 2) { ListItem liMvals = new ListItem("*多项组合..", "mvals"); liMvals.Attributes.CssStyle.Add("style", "color:green"); liMvals.Attributes.Add("color", "green"); liMvals.Attributes.Add("style", "color:green"); } mydll.SetSelectItem(defVal); break; default: break; } } }
/// <summary> /// 获取用户的历史发起流程 /// </summary> public static string GetEmpStartHistory(string userNo, string fk_flow, string[][] queryParams, int?page, int?pageSize) { UserLogin(userNo); BP.WF.Flow startFlow = new BP.WF.Flow(fk_flow); string sql = "SELECT * FROM " + startFlow.PTable + " WHERE FlowStarter='" + userNo + "' and WFState not in (" + (int)BP.WF.WFState.Blank + "," + (int)BP.WF.WFState.Draft + ")"; DataTable table = startFlow.RunSQLReturnTable(sql); table.Columns.Add("TitleUrl"); table.Columns.Add("WFStateText"); var url = ""; foreach (DataRow row in table.Rows) { url = "/WF/WFRpt.aspx?WorkID=" + row["OID"] + "&FK_Flow=" + fk_flow + "&FID=" + row["FID"] + "&UserNo=" + userNo; row["TitleUrl"] = url; string text = ""; switch (row["WFState"] + "") { case "2": text = "运行中"; break; case "3": text = "已完成"; break; case "4": text = "挂起"; break; case "5": text = "退回"; break; case "6": text = "移交"; break; case "7": text = "删除(逻辑)"; break; case "8": text = "加签"; break; case "9": text = "冻结"; break; case "10": text = "批处理"; break; case "11": text = "加签回复"; break; default: break; } row["WFStateText"] = text; } DataTable filterTable = FilterTable(queryParams, table); DataTable finalTable = PageTable(page, pageSize, table); string xml = WriteTableToXml(finalTable, filterTable.Rows.Count); return(xml); }
public void MoreAttach(HttpContext context, string attachPk, string workid, string fk_node, string ensNamestring, string fk_flow, string pkVal) { BP.Sys.FrmAttachment athDesc = new BP.Sys.FrmAttachment(attachPk); string savePath = athDesc.SaveTo; if (savePath.Contains("@") == true || savePath.Contains("*") == true) { /*如果有变量*/ savePath = savePath.Replace("*", "@"); GEEntity en = new GEEntity(athDesc.FK_MapData); en.PKVal = pkVal; en.Retrieve(); savePath = BP.WF.Glo.DealExp(savePath, en, null); if (savePath.Contains("@") && fk_node != null) { /*如果包含 @ */ BP.WF.Flow flow = new BP.WF.Flow(fk_flow); BP.WF.Data.GERpt myen = flow.HisGERpt; myen.OID = long.Parse(workid); myen.RetrieveFromDBSources(); savePath = BP.WF.Glo.DealExp(savePath, myen, null); } if (savePath.Contains("@") == true) { throw new Exception("@路径配置错误,变量没有被正确的替换下来." + savePath); } } else { savePath = athDesc.SaveTo + "\\" + pkVal; } //替换关键的字串. savePath = savePath.Replace("\\\\", "\\"); try { savePath = context.Server.MapPath("~/" + savePath); } catch (Exception) { savePath = savePath; } try { if (System.IO.Directory.Exists(savePath) == false) { System.IO.Directory.CreateDirectory(savePath); //System.IO.Directory.CreateDirectory(athDesc.SaveTo); } } catch (Exception ex) { throw new Exception("@创建路径出现错误,可能是没有权限或者路径配置有问题:" + context.Server.MapPath("~/" + savePath) + "===" + savePath + "@技术问题:" + ex.Message); } string exts = System.IO.Path.GetExtension(context.Request.Files[0].FileName).ToLower().Replace(".", ""); //int oid = BP.DA.DBAccess.GenerOID(); string guid = BP.DA.DBAccess.GenerGUID(); string fileName = context.Request.Files[0].FileName.Substring(0, context.Request.Files[0].FileName.LastIndexOf('.')); //string ext = fu.FileName.Substring(fu.FileName.LastIndexOf('.') + 1); string ext = System.IO.Path.GetExtension(context.Request.Files[0].FileName); //string realSaveTo = Server.MapPath("~/" + savePath) + "/" + guid + "." + fileName + "." + ext; //string realSaveTo = Server.MapPath("~/" + savePath) + "\\" + guid + "." + fu.FileName.Substring(fu.FileName.LastIndexOf('.') + 1); //string saveTo = savePath + "/" + guid + "." + fileName + "." + ext; string realSaveTo = savePath + "/" + guid + "." + fileName + ext; string saveTo = realSaveTo; try { context.Request.Files[0].SaveAs(realSaveTo); } catch (Exception ex) { throw; } FileInfo info = new FileInfo(realSaveTo); FrmAttachmentDB dbUpload = new FrmAttachmentDB(); dbUpload.MyPK = guid; // athDesc.FK_MapData + oid.ToString(); dbUpload.NodeID = fk_node.ToString(); dbUpload.FK_FrmAttachment = attachPk; dbUpload.FK_MapData = athDesc.FK_MapData; dbUpload.FK_FrmAttachment = attachPk; dbUpload.FileExts = info.Extension; dbUpload.FileFullName = saveTo; dbUpload.FileName = context.Request.Files[0].FileName; dbUpload.FileSize = (float)info.Length; dbUpload.RDT = DataType.CurrentDataTimess; dbUpload.Rec = BP.Web.WebUser.No; dbUpload.RecName = BP.Web.WebUser.Name; dbUpload.RefPKVal = pkVal; //if (athDesc.IsNote) // dbUpload.MyNote = this.Pub1.GetTextBoxByID("TB_Note").Text; //if (athDesc.Sort.Contains(",")) // dbUpload.Sort = this.Pub1.GetDDLByID("ddl").SelectedItemStringVal; dbUpload.UploadGUID = guid; dbUpload.Insert(); }
public string Do(string doWhat, string para1, bool isLogin) { // 如果admin账户登陆时有错误发生,则返回错误信息 var result = LetAdminLogin("CH", isLogin); if (string.IsNullOrEmpty(result) == false) { return(result); } switch (doWhat) { case "GenerFlowTemplete": Flow temp = new BP.WF.Flow(para1); return(null); case "GetFlowSorts": //获取所有流程类型 DataTable dtSorts = null; try { dtSorts = BP.DA.DBAccess.RunSQLReturnTable("SELECT no,name FROM WF_FlowSort"); } catch (Exception ex) { return(Newtonsoft.Json.JsonConvert.SerializeObject(new { success = false, msg = ex.Message })); } return(Newtonsoft.Json.JsonConvert.SerializeObject(new { success = true, msg = string.Empty, data = dtSorts.Rows.Cast <DataRow>().Select(dr => new { Key = dr["no"].ToString(), Value = dr["name"].ToString() }) })); case "NewSameLevelFrmSort": //创建同级别的 表单树 目录. SysFormTree frmSort = null; try { var para = para1.Split(','); frmSort = new SysFormTree(para[0]); string sameNodeNo = frmSort.DoCreateSameLevelNode().No; frmSort = new SysFormTree(sameNodeNo); frmSort.Name = para[1]; frmSort.Update(); return(null); } catch (Exception ex) { return("Do Method NewFormSort Branch has a error , para:\t" + para1 + ex.Message); } case "NewSubLevelFrmSort": //创建子级别的 表单树 目录. SysFormTree frmSortSub = null; try { var para = para1.Split(','); frmSortSub = new SysFormTree(para[0]); string sameNodeNo = frmSortSub.DoCreateSubNode().No; frmSortSub = new SysFormTree(sameNodeNo); frmSortSub.Name = para[1]; frmSortSub.Update(); return(null); } catch (Exception ex) { return("Do Method NewSubLevelFrmSort Branch has a error , para:\t" + para1 + ex.Message); } case "NewSameLevelFlowSort": //创建同级别的 流程树 目录. FlowSort fs = null; try { var para = para1.Split(','); fs = new FlowSort(para[0]); string sameNodeNo = fs.DoCreateSameLevelNode().No; fs = new FlowSort(sameNodeNo); fs.Name = para[1]; fs.Update(); return (Newtonsoft.Json.JsonConvert.SerializeObject( new { success = true, msg = string.Empty, data = fs.No })); } catch (Exception ex) { BP.DA.Log.DefaultLogWriteLineError("Do Method NewSameLevelFlowSort Branch has a error , para:\t" + para1 + ex.Message); return(Newtonsoft.Json.JsonConvert.SerializeObject(new { success = false, msg = ex.Message })); } case "NewSubFlowSort": //创建子级别的 表单树 目录. try { var para = para1.Split(','); FlowSort fsSub = new FlowSort(para[0]); string subNodeNo = fsSub.DoCreateSubNode().No; FlowSort subFlowSort = new FlowSort(subNodeNo); subFlowSort.Name = para[1]; subFlowSort.Update(); return (Newtonsoft.Json.JsonConvert.SerializeObject( new { success = true, msg = string.Empty, data = subFlowSort.No })); } catch (Exception ex) { BP.DA.Log.DefaultLogWriteLineError("Do Method NewSubFlowSort Branch has a error , para:\t" + ex.Message); return(Newtonsoft.Json.JsonConvert.SerializeObject(new { success = false, msg = ex.Message })); } case "EditFlowSort": //编辑表单树. try { var para = para1.Split(','); fs = new FlowSort(para[0]); fs.Name = para[1]; fs.Save(); return (Newtonsoft.Json.JsonConvert.SerializeObject( new { success = true, msg = string.Empty, data = fs.No })); } catch (Exception ex) { BP.DA.Log.DefaultLogWriteLineError("Do Method EditFlowSort Branch has a error , para:\t" + para1 + ex.Message); return(Newtonsoft.Json.JsonConvert.SerializeObject(new { success = false, msg = ex.Message })); } case "NewFlow": //创建新流程. Flow fl = new Flow(); try { string[] ps = para1.Split(','); if (ps.Length != 5) { throw new Exception("@创建流程参数错误"); } string fk_floSort = ps[0]; //类别编号. string flowName = ps[1]; // 流程名称. DataStoreModel dataSaveModel = (DataStoreModel)int.Parse(ps[2]); //数据保存方式。 string pTable = ps[3]; // 物理表名。 string FlowMark = ps[4]; // 流程标记. fl.DoNewFlow(fk_floSort, flowName, dataSaveModel, pTable, FlowMark); return (Newtonsoft.Json.JsonConvert.SerializeObject( new { success = true, msg = string.Empty, data = new { no = fl.No, name = fl.Name } })); } catch (Exception ex) { BP.DA.Log.DefaultLogWriteLineError("Do Method NewFlow Branch has a error , para:\t" + para1 + ex.Message); return(Newtonsoft.Json.JsonConvert.SerializeObject(new { success = false, msg = ex.Message })); } case "DelFlow": //删除流程. try { return (Newtonsoft.Json.JsonConvert.SerializeObject( new { success = true, msg = WorkflowDefintionManager.DeleteFlowTemplete(para1) })); } catch (Exception ex) { return(Newtonsoft.Json.JsonConvert.SerializeObject(new { success = false, msg = ex.Message })); } case "DelFlowSort": try { FlowSort delfs = new FlowSort(); delfs.No = para1; delfs.Delete(); return(Newtonsoft.Json.JsonConvert.SerializeObject(new { success = true })); } catch (Exception ex) { BP.DA.Log.DefaultLogWriteLineError("Do Method DelFlowSort Branch has a error , para:\t" + para1 + ex.Message); return(Newtonsoft.Json.JsonConvert.SerializeObject(new { success = false, msg = ex.Message })); } case "DelNode": try { if (!string.IsNullOrEmpty(para1)) { BP.WF.Node delNode = new BP.WF.Node(int.Parse(para1)); delNode.Delete(); } else { throw new Exception("@参数错误:" + para1); } } catch (Exception ex) { return("err:" + ex.Message); } return(null); case "GetSettings": return(SystemConfig.AppSettings[para1]); case "SaveFlowFrm": //保存独立表单. Entity en = null; try { AtPara ap = new AtPara(para1); string enName = ap.GetValStrByKey("EnName"); string pk = ap.GetValStrByKey("PKVal"); en = ClassFactory.GetEn(enName); en.ResetDefaultVal(); if (en == null) { throw new Exception("无效的类名:" + enName); } if (string.IsNullOrEmpty(pk) == false) { en.PKVal = pk; en.RetrieveFromDBSources(); } foreach (string key in ap.HisHT.Keys) { if (key == "PKVal") { continue; } en.SetValByKey(key, ap.HisHT[key].ToString().Replace('^', '@')); } en.Save(); return(en.PKVal as string); } catch (Exception ex) { if (en != null) { en.CheckPhysicsTable(); } return("Error:" + ex.Message); } case "ChangeNodeType": var p = para1.Split(','); try { if (p.Length != 3) { throw new Exception("@修改节点类型参数错误"); } //var sql = "UPDATE WF_Node SET Icon='{0}' WHERE FK_Flow='{1}' AND NodeID='{2}'"; var sql = "UPDATE WF_Node SET RunModel={0} WHERE FK_Flow='{1}' AND NodeID={2}"; DBAccess.RunSQL(string.Format(sql, p[0], p[1], p[2])); return(Newtonsoft.Json.JsonConvert.SerializeObject(new { success = true })); } catch (Exception ex) { return(Newtonsoft.Json.JsonConvert.SerializeObject(new { success = false, msg = ex.Message })); } case "ChangeNodeIcon": p = para1.Split(','); try { if (p.Length != 3) { throw new Exception("@修改节点图标参数错误"); } var sql = "UPDATE WF_Node SET Icon='{0}' WHERE FK_Flow='{1}' AND NodeID={2}"; DBAccess.RunSQL(string.Format(sql, p[0], p[1], p[2])); return(Newtonsoft.Json.JsonConvert.SerializeObject(new { success = true })); } catch (Exception ex) { return(Newtonsoft.Json.JsonConvert.SerializeObject(new { success = false, msg = ex.Message })); } default: throw new Exception("@没有约定的执行标记:" + doWhat); } }
public string Do(string doWhat, string para1, bool isLogin) { // 如果admin账户登陆时有错误发生,则返回错误信息 var result = LetAdminLogin("CH", isLogin); if (string.IsNullOrEmpty(result) == false) { return(result); } switch (doWhat) { case "GenerFlowTemplete": Flow temp = new BP.WF.Flow(para1); return(null); case "NewFrmSort": BP.Sys.FrmSort frmSort = null; try { frmSort = new FrmSort(); frmSort.No = "01"; frmSort.Name = para1; frmSort.No = frmSort.GenerNewNo; frmSort.Insert(); return(null); } catch (Exception ex) { return("Do Method NewFlowSort Branch has a error , para:\t" + para1 + ex.Message); } case "NewFlowSort": BP.WF.FlowSort fs = null; try { fs = new FlowSort(); fs.Name = para1; fs.No = fs.GenerNewNo; fs.Insert(); return(fs.No); } catch (Exception ex) { BP.DA.Log.DefaultLogWriteLineError("Do Method NewFlowSort Branch has a error , para:\t" + para1 + ex.Message); return(null); } case "EditFlowSort": try { var para = para1.Split(','); fs = new FlowSort(para[0]); fs.Name = para[1]; fs.Save(); return(fs.No); } catch (Exception ex) { BP.DA.Log.DefaultLogWriteLineError("Do Method EditFlowSort Branch has a error , para:\t" + para1 + ex.Message); return(null); } case "NewFlow": Flow fl = new Flow(); try { string[] ps = para1.Split(','); if (ps.Length != 5) { throw new Exception("@创建流程参数错误"); } string fk_floSort = ps[0]; string flowName = ps[1]; DataStoreModel dataSaveModel = (DataStoreModel)int.Parse(ps[2]); string pTable = ps[3]; string flowCode = ps[4]; fl.DoNewFlow(fk_floSort, flowName, dataSaveModel, pTable, flowCode); return(fl.No + ";" + fl.Name); } catch (Exception ex) { BP.DA.Log.DefaultLogWriteLineError("Do Method NewFlow Branch has a error , para:\t" + para1 + ex.Message); return(ex.Message); } case "DelFlow": BP.WF.Flow fl1 = new BP.WF.Flow(para1); try { fl1.DoDelete(); return(null); } catch (Exception ex) { BP.DA.Log.DefaultLogWriteLineError("Do Method DelFlow Branch has a error , para:\t" + para1 + ex.Message); return(ex.Message); } case "DelLable": BP.WF.LabNote ln = new BP.WF.LabNote(para1); try { ln.Delete(); } catch (Exception ex) { BP.DA.Log.DefaultLogWriteLineError("Do Method DelLable Branch has a error , para:\t" + para1 + ex.Message); } return(null); case "DelFlowSort": try { FlowSort delfs = new FlowSort(para1); delfs.Delete(); } catch (Exception ex) { BP.DA.Log.DefaultLogWriteLineError("Do Method DelFlowSort Branch has a error , para:\t" + para1 + ex.Message); } return(null); case "NewNode": try { BP.WF.Flow fl11 = new BP.WF.Flow(para1); BP.WF.Node node = new BP.WF.Node(); node.FK_Flow = ""; node.X = 0; node.Y = 0; node.Insert(); } catch (Exception ex) { BP.DA.Log.DefaultLogWriteLineError("Do Method NewNode Branch has a error , para:\t" + para1 + ex.Message); } return(null); case "DelNode": try { if (!string.IsNullOrEmpty(para1)) { BP.WF.Node delNode = new BP.WF.Node(int.Parse(para1)); delNode.Delete(); } } catch (Exception ex) { BP.DA.Log.DefaultLogWriteLineError("Do Method DelNode Branch has a error , para:\t" + para1 + ex.Message); } return(null); case "NewLab": BP.WF.LabNote lab = new BP.WF.LabNote();; try { lab.FK_Flow = para1; lab.MyPK = BP.DA.DBAccess.GenerOID().ToString(); lab.Insert(); } catch (Exception ex) { BP.DA.Log.DefaultLogWriteLineError("Do Method NewLab Branch has a error , para:\t" + para1 + ex.Message); } return(lab.MyPK); case "DelLab": try { BP.WF.LabNote dellab = new BP.WF.LabNote(); dellab.MyPK = para1; dellab.Delete(); } catch (Exception ex) { BP.DA.Log.DefaultLogWriteLineError("Do Method DelLab Branch has a error , para:\t" + para1 + ex.Message); } return(null); case "GetSettings": return(SystemConfig.AppSettings[para1]); case "GetFlows": string sqls = "SELECT NO,NAME FROM WF_FlowSort"; sqls += "@SELECT No,Name,FK_FlowSort FROM WF_Flow"; return(RunSQLReturnTableS(sqls)); case "SaveFlowFrm": Entity en = null; try { AtPara ap = new AtPara(para1); string enName = ap.GetValStrByKey("EnName"); string pk = ap.GetValStrByKey("PKVal"); en = ClassFactory.GetEn(enName); en.ResetDefaultVal(); if (en == null) { throw new Exception("无效的类名:" + enName); } if (string.IsNullOrEmpty(pk) == false) { en.PKVal = pk; en.RetrieveFromDBSources(); } foreach (string key in ap.HisHT.Keys) { if (key == "PKVal") { continue; } en.SetValByKey(key, ap.HisHT[key].ToString().Replace('^', '@')); } en.Save(); return(en.PKVal as string); } catch (Exception ex) { if (en != null) { en.CheckPhysicsTable(); } return("Error:" + ex.Message); } case "ReleaseToFTP": // 暂时注释,下次更新ftp功能时会得新编译 。 //var args = para1.Split(','); //var binaryData = Convert.FromBase64String(args[1]); //var imageFilePath = Server.MapPath(System.Web.HttpContext.Current.Request.ApplicationPath) + "/Temp/" + args[0] + ".jpg"; //if (File.Exists(imageFilePath)) //{ // File.Delete(imageFilePath); //} //System.IO.Directory.CreateDirectory( // Server.MapPath(System.Web.HttpContext.Current.Request.ApplicationPath) + "/Temp"); //var stream = new System.IO.FileStream(imageFilePath, FileMode.OpenOrCreate, FileAccess.ReadWrite); //stream.Write(binaryData, 0, binaryData.Length); //stream.Close(); //var xmlFilePath = FlowTemplete_Gener(args[0], true); //string remoteDr = "/" + ConfigurationSettings.AppSettings["UserIdentifier"];; //var ftp = new FtpConnection(); //try //{ // string ftpIP = ConfigurationSettings.AppSettings["FTPServerIP"]; // string email = ConfigurationSettings.AppSettings["FTPUserEmail"]; // Session session = new Session(); // session.Server = ftpIP; // session.Connect("anonymous", "*****@*****.**"); // ftp.Connect(ftpIP, "anonymous", email); // remoteDr = remoteDr; // if(!ftp.DirectoryExist(remoteDr)) // { // ftp.CreateDirectory(remoteDr); // } // ftp.SetCurrentDirectory(remoteDr); // ftp.PutFile(imageFilePath, remoteDr); // return string.Empty;//上传成功 //} //catch (Exception err) //{ // return err.Message;//上传失败 //} //finally //{ // ftp.Close(); //} return(string.Empty); default: throw null; } }
protected void Page_Load(object sender, EventArgs e) { this.Response.ContentEncoding = System.Text.UTF8Encoding.UTF8; this.Request.ContentEncoding = System.Text.UTF8Encoding.UTF8; #region 功能执行. if (this.DoType == "Del") { FrmAttachmentDB delDB = new FrmAttachmentDB(); delDB.MyPK = this.DelPKVal == null ? this.MyPK : this.DelPKVal; delDB.DirectDelete(); } if (this.DoType == "Down") { FrmAttachmentDB downDB = new FrmAttachmentDB(); downDB.MyPK = this.DelPKVal == null ? this.MyPK : this.DelPKVal; downDB.Retrieve(); string downpath = GetRealPath(downDB.FileFullName); BP.Sys.PubClass.DownloadFile(downpath, downDB.FileName); this.WinClose(); return; } if (this.DoType == "WinOpen") { FrmAttachmentDB downDB = new FrmAttachmentDB(); downDB.MyPK = this.MyPK; downDB.Retrieve(); Response.ContentType = "Application/pdf"; string downpath = GetRealPath(downDB.FileFullName); Response.WriteFile(downpath); Response.End(); return; } #endregion 功能执行. #region 处理权限控制. BP.Sys.FrmAttachment athDesc = new BP.Sys.FrmAttachment(); athDesc.MyPK = this.FK_FrmAttachment; if (this.FK_Node == null || this.FK_Flow == null) { athDesc.RetrieveFromDBSources(); } else { #region 判断是否可以查询出来,如果查询不出来,就可能是公文流程。 athDesc.MyPK = this.FK_FrmAttachment; if (athDesc.RetrieveFromDBSources() == 0 && string.IsNullOrEmpty(this.FK_Flow) == false) { /*如果没有查询到它,就有可能是公文多附件被删除了.*/ athDesc.MyPK = this.FK_FrmAttachment; athDesc.NoOfObj = "DocMultiAth"; athDesc.FK_MapData = this.FK_MapData; athDesc.Exts = "*.*"; //存储路径. athDesc.SaveTo = "/DataUser/UploadFile/"; athDesc.IsNote = false; //不显示note字段. athDesc.IsVisable = false; // 让其在form 上不可见. //位置. athDesc.X = (float)94.09; athDesc.Y = (float)333.18; athDesc.W = (float)626.36; athDesc.H = (float)150; //多附件. athDesc.UploadType = AttachmentUploadType.Multi; athDesc.Name = "公文多附件(系统自动增加)"; athDesc.SetValByKey("AtPara", "@IsWoEnablePageset=1@IsWoEnablePrint=1@IsWoEnableViewModel=1@IsWoEnableReadonly=0@IsWoEnableSave=1@IsWoEnableWF=1@IsWoEnableProperty=1@IsWoEnableRevise=1@IsWoEnableIntoKeepMarkModel=1@FastKeyIsEnable=0@IsWoEnableViewKeepMark=1@FastKeyGenerRole=@IsWoEnableTemplete=1"); athDesc.Insert(); //有可能在其其它的节点上没有这个附件,所以也要循环增加上它. BP.WF.Nodes nds = new BP.WF.Nodes(this.FK_Flow); foreach (BP.WF.Node nd in nds) { athDesc.FK_MapData = "ND" + nd.NodeID; athDesc.MyPK = athDesc.FK_MapData + "_" + athDesc.NoOfObj; if (athDesc.IsExits == true) { continue; } athDesc.Insert(); } //重新查询一次,把默认值加上. athDesc.RetrieveFromDBSources(); } #endregion 判断是否可以查询出来,如果查询不出来,就可能是公文流程。 #region 处理权限方案。 /*首先判断是否具有权限方案*/ string at = BP.Sys.SystemConfig.AppCenterDBVarStr; Paras ps = new BP.DA.Paras(); ps.SQL = "SELECT FrmSln FROM WF_FrmNode WHERE FK_Node=" + at + "FK_Node AND FK_Flow=" + at + "FK_Flow AND FK_Frm=" + at + "FK_Frm"; ps.Add("FK_Node", this.FK_Node); ps.Add("FK_Flow", this.FK_Flow); ps.Add("FK_Frm", this.FK_MapData); DataTable dt = DBAccess.RunSQLReturnTable(ps); if (dt.Rows.Count == 0) { athDesc.RetrieveFromDBSources(); } else { int sln = int.Parse(dt.Rows[0][0].ToString()); if (sln == 0) { athDesc.RetrieveFromDBSources(); } else { int result = athDesc.Retrieve(FrmAttachmentAttr.FK_MapData, this.FK_MapData, FrmAttachmentAttr.FK_Node, this.FK_Node, FrmAttachmentAttr.NoOfObj, this.Ath); if (result == 0) /*如果没有定义,就获取默认的.*/ { athDesc.RetrieveFromDBSources(); } // throw new Exception("@该流程表单在该节点("+this.FK_Node+")使用的是自定义的权限控制,但是没有定义该附件的权限。"); } } #endregion 处理权限方案。 } BP.Sys.FrmAttachmentDBs dbs = new BP.Sys.FrmAttachmentDBs(); if (athDesc.HisCtrlWay == AthCtrlWay.PWorkID) { string pWorkID = BP.DA.DBAccess.RunSQLReturnValInt("SELECT PWorkID FROM WF_GenerWorkFlow WHERE WorkID=" + this.PKVal, 0).ToString(); if (pWorkID == null || pWorkID == "0") { pWorkID = this.PKVal; } if (athDesc.AthUploadWay == AthUploadWay.Inherit) { /* 继承模式 */ BP.En.QueryObject qo = new BP.En.QueryObject(dbs); qo.AddWhere(FrmAttachmentDBAttr.RefPKVal, pWorkID); qo.addOr(); qo.AddWhere(FrmAttachmentDBAttr.RefPKVal, int.Parse(this.PKVal)); qo.addOrderBy("RDT"); qo.DoQuery(); } if (athDesc.AthUploadWay == AthUploadWay.Interwork) { /*共享模式*/ dbs.Retrieve(FrmAttachmentDBAttr.RefPKVal, pWorkID); } } else { int num = dbs.Retrieve(FrmAttachmentDBAttr.FK_FrmAttachment, this.FK_FrmAttachment, FrmAttachmentDBAttr.RefPKVal, this.PKVal, "RDT"); if (num == 0 && this.IsCC == "1") { CCList cc = new CCList(); int nnn = cc.Retrieve(CCListAttr.FK_Node, this.FK_Node, CCListAttr.WorkID, this.WorkID, CCListAttr.CCTo, WebUser.No); if (cc.NDFrom != 0) { this._fk_node = cc.NDFrom; dbs.Retrieve(FrmAttachmentDBAttr.FK_FrmAttachment, this.FK_FrmAttachmentExt, FrmAttachmentDBAttr.FK_MapData, "ND" + cc.NDFrom, FrmAttachmentDBAttr.RefPKVal, this.WorkID.ToString()); //重新设置文件描述。 athDesc.Retrieve(FrmAttachmentAttr.FK_MapData, this.FK_MapData, FrmAttachmentAttr.NoOfObj, "DocMultiAth"); } } } #endregion 处理权限控制. #region 生成表头表体. this.Title = athDesc.Name; #region 如果图片显示. if (athDesc.FileShowWay == FileShowWay.Pict) { /* 如果是图片轮播,就在这里根据数据输出轮播的html代码.*/ if (dbs.Count == 0 && athDesc.IsUpload == true) { /*没有数据并且,可以上传,就转到上传的界面上去.*/ this.Response.Redirect("AttachmentUploadImg.aspx?1=1" + this.RequestParas, true); return; } if (dbs.Count != 0) { /*有数据,就输出.*/ this.Pub1.Add("<div class='slideBox' id='" + athDesc.MyPK + "' style='width:" + athDesc.W + "px;height:" + athDesc.H + "px; position:relative; overflow:hidden;'>"); this.Pub1.Add("<ul class='items'> "); foreach (FrmAttachmentDB db in dbs) { if (BP.DA.DataType.IsImgExt(db.FileExts) == false) { continue; } if (athDesc.IsDelete != false) { if (athDesc.IsDelete == true) { this.Pub1.Add("<li> <a title='" + db.MyNote + "'><img src = '" + db.FileFullName + "' width=" + athDesc.W + " height=" + athDesc.H + "/></a> | <a href=\"javascript:Del('" + this.FK_FrmAttachment + "','" + this.PKVal + "','" + db.MyPK + "')\">删除</a></li>"); } else if (athDesc.IsDeleteInt == 2) { if (db.Rec.Equals(WebUser.No)) { this.Pub1.Add("<li> <a title='" + db.MyNote + "'><img src = '" + db.FileFullName + "' width=" + athDesc.W + " height=" + athDesc.H + "/></a> | <a href=\"javascript:Del('" + this.FK_FrmAttachment + "','" + this.PKVal + "','" + db.MyPK + "')\">删除</a></li>"); } } else { this.Pub1.Add("<li> <a title='" + db.MyNote + "'><img src = '" + db.FileFullName + "' width=" + athDesc.W + " height=" + athDesc.H + "/></a> </li>"); } } else { this.Pub1.Add("<li> <a title='" + db.MyNote + "'><img src = '" + db.FileFullName + "' width=" + athDesc.W + " height=" + athDesc.H + "/></a> </li>"); } } this.Pub1.Add("</ul>"); this.Pub1.Add("</div>"); this.Pub1.Add("<script>$(function(){$('#" + athDesc.MyPK + "').slideBox({duration : 0.3,easing : 'linear',delay : 5,hideClickBar : false,clickBarRadius : 10});})</script>"); } if (athDesc.IsUpload == true) { /*可以上传,就显示上传的按钮.. */ this.Pub1.Add("<a href='AttachmentUploadImg.aspx?1=1" + this.RequestParas + "' >上传</a>"); } return; } #endregion 如果图片显示. float athWidth = athDesc.W - 20; // 执行装载模版. if (dbs.Count == 0 && athDesc.IsWoEnableTemplete == true) { /*如果数量为0,就检查一下是否有模版如果有就加载模版文件.*/ string templetePath = BP.Sys.SystemConfig.PathOfDataUser + "AthTemplete\\" + athDesc.NoOfObj.Trim(); if (Directory.Exists(templetePath) == false) { Directory.CreateDirectory(templetePath); } /*有模版文件夹*/ DirectoryInfo mydir = new DirectoryInfo(templetePath); FileInfo[] fls = mydir.GetFiles(); if (fls.Length == 0) { throw new Exception("@流程设计错误,该多附件启用了模版组件,模版目录:" + templetePath + "里没有模版文件."); } foreach (FileInfo fl in fls) { if (System.IO.Directory.Exists(athDesc.SaveTo) == false) { System.IO.Directory.CreateDirectory(athDesc.SaveTo); } int oid = BP.DA.DBAccess.GenerOID(); string saveTo = athDesc.SaveTo + "\\" + oid + "." + fl.Name.Substring(fl.Name.LastIndexOf('.') + 1); if (saveTo.Contains("@") == true || saveTo.Contains("*") == true) { /*如果有变量*/ saveTo = saveTo.Replace("*", "@"); if (saveTo.Contains("@") && this.FK_Node != null) { /*如果包含 @ */ BP.WF.Flow flow = new BP.WF.Flow(this.FK_Flow); BP.WF.Data.GERpt myen = flow.HisGERpt; myen.OID = this.WorkID; myen.RetrieveFromDBSources(); saveTo = BP.WF.Glo.DealExp(saveTo, myen, null); } if (saveTo.Contains("@") == true) { throw new Exception("@路径配置错误,变量没有被正确的替换下来." + saveTo); } } fl.CopyTo(saveTo); FileInfo info = new FileInfo(saveTo); FrmAttachmentDB dbUpload = new FrmAttachmentDB(); dbUpload.CheckPhysicsTable(); dbUpload.MyPK = athDesc.FK_MapData + oid.ToString(); dbUpload.NodeID = FK_Node.ToString(); dbUpload.FK_FrmAttachment = this.FK_FrmAttachment; if (athDesc.AthUploadWay == AthUploadWay.Inherit) { /*如果是继承,就让他保持本地的PK. */ dbUpload.RefPKVal = this.PKVal.ToString(); } if (athDesc.AthUploadWay == AthUploadWay.Interwork) { /*如果是协同,就让他是PWorkID. */ string pWorkID = BP.DA.DBAccess.RunSQLReturnValInt("SELECT PWorkID FROM WF_GenerWorkFlow WHERE WorkID=" + this.PKVal, 0).ToString(); if (pWorkID == null || pWorkID == "0") { pWorkID = this.PKVal; } dbUpload.RefPKVal = pWorkID; } dbUpload.FK_MapData = athDesc.FK_MapData; dbUpload.FK_FrmAttachment = this.FK_FrmAttachment; dbUpload.FileExts = info.Extension; dbUpload.FileFullName = saveTo; dbUpload.FileName = fl.Name; dbUpload.FileSize = (float)info.Length; dbUpload.RDT = DataType.CurrentDataTime; dbUpload.Rec = BP.Web.WebUser.No; dbUpload.RecName = BP.Web.WebUser.Name; //if (athDesc.IsNote) // dbUpload.MyNote = this.Pub1.GetTextBoxByID("TB_Note").Text; //if (athDesc.Sort.Contains(",")) // dbUpload.Sort = this.Pub1.GetDDLByID("ddl").SelectedItemStringVal; dbUpload.Insert(); dbs.AddEntity(dbUpload); } //BP.Sys.FrmAttachmentDBs dbs = new BP.Sys.FrmAttachmentDBs(); } #region 处理权限问题. // 处理权限问题, 有可能当前节点是可以上传或者删除,但是当前节点上不能让此人执行工作。 bool isDel = athDesc.IsDeleteInt == 0 ? false : true; bool isUpdate = athDesc.IsUpload; if (isDel == true || isUpdate == true) { if (this.WorkID != 0 && string.IsNullOrEmpty(this.FK_Flow) == false && this.FK_Node != 0) { isDel = BP.WF.Dev2Interface.Flow_IsCanDoCurrentWork(this.FK_Flow, this.FK_Node, this.WorkID, WebUser.No); if (isDel == false) { isUpdate = false; } } } #endregion 处理权限问题. if (athDesc.FileShowWay == FileShowWay.Free) { this.Pub1.AddTable("border='0' cellspacing='0' cellpadding='0' style='width:" + athWidth + "px'"); foreach (FrmAttachmentDB db in dbs) { this.Pub1.AddTR(); if (CanEditor(db.FileExts)) { if (athDesc.IsWoEnableWF) { this.Pub1.AddTD("<a href=\"javascript:OpenOfiice('" + this.FK_FrmAttachment + "','" + this.WorkID + "','" + db.MyPK + "','" + this.FK_MapData + "','" + this.Ath + "','" + this.FK_Node + "')\"><img src='../Img/FileType/" + db.FileExts + ".gif' border=0 onerror=\"src='../Img/FileType/Undefined.gif'\" />" + db.FileName + "</a>"); } else { this.Pub1.AddTD("<a href=\"javascript:OpenView('" + this.PKVal + "','" + db.MyPK + "')\"><img src='../Img/FileType/" + db.FileExts + ".gif' border=0 onerror=\"src='../Img/FileType/Undefined.gif'\" />" + db.FileName + "</a>"); } } else if (DataType.IsImgExt(db.FileExts) || db.FileExts.ToUpper() == "PDF" || db.FileExts.ToUpper() == "CEB") { this.Pub1.AddTD("<a href=\"javascript:OpenView('" + this.PKVal + "','" + db.MyPK + "')\"><img src='../Img/FileType/" + db.FileExts + ".gif' border=0 onerror=\"src='../Img/FileType/Undefined.gif'\" />" + db.FileName + "</a>"); } else { this.Pub1.AddTD("<a href='AttachmentUpload.aspx?DoType=Down&MyPK=" + db.MyPK + "' target=_blank ><img src='../Img/FileType/" + db.FileExts + ".gif' border=0 onerror=\"src='../Img/FileType/Undefined.gif'\" />" + db.FileName + "</a>"); } if (athDesc.IsDownload) { this.Pub1.AddTD("<a href=\"javascript:Down('" + this.FK_FrmAttachment + "','" + this.PKVal + "','" + db.MyPK + "')\">下载</a>"); } else { this.Pub1.AddTD(""); } if (this.IsReadonly != "1") { if (athDesc.IsDelete != false) { if (athDesc.IsDelete == true) { this.Pub1.AddTD("style='border:0px'", "<a href=\"javascript:Del('" + this.FK_FrmAttachment + "','" + this.PKVal + "','" + db.MyPK + "')\">删除</a>"); } else if (athDesc.IsDeleteInt == 2) { if (db.Rec.Equals(WebUser.No)) { this.Pub1.AddTD("style='border:0px'", "<a href=\"javascript:Del('" + this.FK_FrmAttachment + "','" + this.PKVal + "','" + db.MyPK + "')\">删除</a>"); } } else { this.Pub1.AddTD(""); } } else { this.Pub1.AddTD(""); } } else { this.Pub1.AddTD(""); this.Pub1.AddTD(""); } this.Pub1.AddTREnd(); } AddFileUpload(isUpdate, athDesc); this.Pub1.AddTableEnd(); return; } this.Pub1.AddTable("border='0' cellspacing='0' cellpadding='0' style='width:" + athWidth + "px'"); if (athDesc.IsShowTitle == true) { this.Pub1.AddTR("style='border:0px'"); this.Pub1.AddTDTitleExt("序号"); if (athDesc.Sort.Contains(",")) { this.Pub1.AddTD("style='background:#f4f4f4; font-size:12px; padding:3px;'", "类别"); } this.Pub1.AddTDTitleExt("文件名"); this.Pub1.AddTDTitleExt("大小KB"); this.Pub1.AddTDTitleExt("上传时间"); this.Pub1.AddTDTitleExt("上传人"); this.Pub1.AddTDTitleExt("操作"); this.Pub1.AddTREnd(); } int i = 0; StringBuilder picHtml = new StringBuilder(); foreach (FrmAttachmentDB db in dbs) { i++; this.Pub1.AddTR(); this.Pub1.AddTDIdx(i); if (athDesc.Sort.Contains(",")) { this.Pub1.AddTD(db.Sort); } // this.Pub1.AddTDIdx(i++); if (athDesc.IsDownload) { if (athDesc.IsWoEnableWF && CanEditor(db.FileExts)) { this.Pub1.AddTD("<a href=\"javascript:OpenOfiice('" + this.FK_FrmAttachment + "','" + this.WorkID + "','" + db.MyPK + "','" + this.FK_MapData + "','" + this.Ath + "','" + this.FK_Node + "')\"><img src='../Img/FileType/" + db.FileExts + ".gif' border=0 onerror=\"src='../Img/FileType/Undefined.gif'\" />" + db.FileName + "</a>"); } else if (db.FileExts.ToUpper() == "TXT" || db.FileExts.ToUpper() == "JPG" || db.FileExts.ToUpper() == "JPEG" || db.FileExts.ToUpper() == "GIF" || db.FileExts.ToUpper() == "PNG" || db.FileExts.ToUpper() == "BMP" || db.FileExts.ToUpper() == "PDF" || db.FileExts.ToUpper() == "CEB") { this.Pub1.AddTD("<a href=\"javascript:OpenView('" + this.PKVal + "','" + db.MyPK + "')\"><img src='../Img/FileType/" + db.FileExts + ".gif' border=0 onerror=\"src='../Img/FileType/Undefined.gif'\" />" + db.FileName + "</a>"); } else { this.Pub1.AddTD("<a href='AttachmentUpload.aspx?DoType=Down&MyPK=" + db.MyPK + "' target=_blank ><img src='../Img/FileType/" + db.FileExts + ".gif' border=0 onerror=\"src='../Img/FileType/Undefined.gif'\" />" + db.FileName + "</a>"); } } else { this.Pub1.AddTD("<img src='../Img/FileType/" + db.FileExts + ".gif' border=0 onerror=\"src='../Img/FileType/Undefined.gif'\" />" + db.FileName); } this.Pub1.AddTD(db.FileSize); this.Pub1.AddTD(db.RDT); this.Pub1.AddTD(db.RecName); //输出操作部分. this.Pub1.AddTDBegin(); if (athDesc.IsDownload) { this.Pub1.Add("<a href=\"javascript:Down('" + this.FK_FrmAttachment + "','" + this.PKVal + "','" + db.MyPK + "')\">下载</a>"); } if (this.IsReadonly != "1") { string op = null; if (isDel == true) { if (athDesc.IsDelete == true) { op = " <a href=\"javascript:Del('" + this.FK_FrmAttachment + "','" + this.PKVal + "','" + db.MyPK + "')\">删除</a>"; } else if (athDesc.IsDeleteInt == 2) { if (db.Rec.Equals(WebUser.No)) { op = " <a href=\"javascript:Del('" + this.FK_FrmAttachment + "','" + this.PKVal + "','" + db.MyPK + "')\">删除</a>"; } } } this.Pub1.Add(op); } this.Pub1.AddTDEnd(); this.Pub1.AddTREnd(); } if (i == 0) { this.Pub1.AddTR(); this.Pub1.AddTD("0"); if (athDesc.Sort.Contains(",")) { this.Pub1.AddTD("  "); } this.Pub1.AddTD("style='width:100px'", "<span style='color:red;' >上传附件</span>"); this.Pub1.AddTD("  "); this.Pub1.AddTD("  "); this.Pub1.AddTD("  "); this.Pub1.AddTD("  "); this.Pub1.AddTREnd(); } AddFileUpload(isUpdate, athDesc); this.Pub1.AddTableEnd(); #endregion 生成表头表体. }
protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { string flowNo = this.Request.QueryString["FK_Flow"]; BP.WF.Flow fl = new BP.WF.Flow(); fl.No = flowNo; fl.RetrieveFromDBSources(); this.TB_Alert.Text = fl.StartLimitAlert; //限制规则提示. switch (fl.StartLimitRole) { case StartLimitRole.None: //不限制. this.RB_None.Checked = true; break; case StartLimitRole.Day: //天. this.RB_ByTime.Checked = true; this.DDL_ByTime.SelectedValue = "0"; this.TB_Alert.Text = fl.StartLimitAlert; this.TB_ByTimePara.Text = fl.StartLimitPara; break; case StartLimitRole.Week: //周. this.RB_ByTime.Checked = true; this.DDL_ByTime.SelectedValue = "1"; this.TB_Alert.Text = fl.StartLimitAlert; this.TB_ByTimePara.Text = fl.StartLimitPara; break; case StartLimitRole.Month: //月份. this.RB_ByTime.Checked = true; this.DDL_ByTime.SelectedValue = "2"; this.TB_Alert.Text = fl.StartLimitAlert; this.TB_ByTimePara.Text = fl.StartLimitPara; break; case StartLimitRole.JD: //月份. this.RB_ByTime.Checked = true; this.DDL_ByTime.SelectedValue = "3"; this.TB_Alert.Text = fl.StartLimitAlert; this.TB_ByTimePara.Text = fl.StartLimitPara; break; case StartLimitRole.Year: //年度. this.RB_ByTime.Checked = true; this.DDL_ByTime.SelectedValue = "4"; this.TB_Alert.Text = fl.StartLimitAlert; this.TB_ByTimePara.Text = fl.StartLimitPara; break; case StartLimitRole.ColNotExit: //发起的列不能重复,(多个列可以用逗号分开). this.RB_ColNotExit.Checked = true; this.TB_ColNotExit_Fields.Text = fl.StartLimitPara; break; case StartLimitRole.ResultIsZero: //小于等于0. this.RB_SQL.Checked = true; this.DDL_SQL.SelectedIndex = 0; this.TB_SQL_Para.Text = fl.StartLimitPara; break; case StartLimitRole.ResultIsNotZero: //大于 0 . this.RB_SQL.Checked = true; this.DDL_SQL.SelectedIndex = 1; this.TB_SQL_Para.Text = fl.StartLimitPara; break; default: break; } } }
protected void Save() { string flowNo = this.Request.QueryString["FK_Flow"]; BP.WF.Flow fl = new BP.WF.Flow(flowNo); fl.StartLimitAlert = this.TB_Alert.Text; //限制提示信息 if (this.RB_None.Checked) { fl.StartLimitRole = StartLimitRole.None; } if (this.RB_ByTime.Checked) { if (this.DDL_ByTime.SelectedIndex == 0)//一人一天一次 { fl.StartLimitRole = StartLimitRole.Day; fl.StartLimitPara = this.TB_ByTimePara.Text; } if (this.DDL_ByTime.SelectedIndex == 1)//一人一周一次 { fl.StartLimitRole = StartLimitRole.Week; fl.StartLimitPara = this.TB_ByTimePara.Text; } if (this.DDL_ByTime.SelectedIndex == 2)//一人一月一次 { fl.StartLimitRole = StartLimitRole.Month; fl.StartLimitPara = this.TB_ByTimePara.Text; } if (this.DDL_ByTime.SelectedIndex == 3)//一人一季一次 { fl.StartLimitRole = StartLimitRole.JD; fl.StartLimitPara = this.TB_ByTimePara.Text; fl.DirectUpdate(); } if (this.DDL_ByTime.SelectedIndex == 4)//一人一年一次 { fl.StartLimitRole = StartLimitRole.Year; fl.StartLimitPara = this.TB_ByTimePara.Text; } } if (this.RB_ColNotExit.Checked)//按照发起字段不能重复规则 { fl.StartLimitRole = StartLimitRole.ColNotExit; fl.StartLimitPara = this.TB_ColNotExit_Fields.Text; } if (this.RB_SQL.Checked == true) { //字段参数. fl.StartLimitPara = this.TB_SQL_Para.Text; //选择的模式. if (this.DDL_SQL.SelectedIndex == 0) { fl.StartLimitRole = StartLimitRole.ResultIsZero; } if (this.DDL_SQL.SelectedIndex == 1) { fl.StartLimitRole = StartLimitRole.ResultIsNotZero; } } fl.Update(); }