/// <summary> /// ccform 的api. /// </summary> /// <param name="sender"></param> /// <param name="e"></param> protected void Page_Load(object sender, EventArgs e) { if (WebUser.NoOfRel == null) { this.Pub1.AddFieldSet("ERR", "用户登录信息丢失."); return; } string fk_mapdata = this.Request.QueryString["FK_MapData"]; string oid = this.Request.QueryString["OID"]; MapData md = new MapData(); md.No = fk_mapdata; if (md.RetrieveFromDBSources() == 0) { this.Pub1.AddFieldSetRed("错误", "表单编号错误:" + md.No); } if (md.HisFrmType != FrmType.Url) { /*处理表单装载前事件.*/ GEEntity entity = md.HisGEEn; entity.PKVal = oid; entity.RetrieveFromDBSources(); entity.ResetDefaultVal(); //执行一次装载前填充. string msg = md.FrmEvents.DoEventNode(FrmEventList.FrmLoadBefore, entity); if (string.IsNullOrEmpty(msg) == false) { this.Pub1.AddFieldSetRed("错误", "错误" + msg); return; } } switch (md.HisFrmType) { case FrmType.FreeFrm: this.Response.Redirect("Frm.aspx?FK_MapData=" + fk_mapdata + "&OID=" + oid, true); break; case FrmType.Column4Frm: this.Response.Redirect("FrmFix.aspx?FK_MapData=" + fk_mapdata + "&OID=" + oid, true); break; case FrmType.SLFrm: // this.Response.Redirect("SLFrm.aspx?FK_MapData=" + fk_mapdata + "&OID=" + oid, true); break; case FrmType.Url: // 如果是一个超链接 string url = md.PTable; url = url.Replace("@OID", oid); url = url.Replace("@PK", oid); this.Response.Redirect(url, true); break; default: break; } }
/// <summary> /// 执行 /// </summary> /// <returns>返回执行结果</returns> public string DoMethod_ExeSQL() { MethodFunc func = new MethodFunc(this.MyPK); string doc = func.MethodDoc_SQL; GEEntity en = new GEEntity(func.FrmID, this.WorkID); doc = BP.WF.Glo.DealExp(doc, en, null); //替换里面的内容. try { DBAccess.RunSQLs(doc); if (func.MsgSuccess.Equals("")) { func.MsgSuccess = "执行成功."; } return(func.MsgSuccess); } catch (Exception ex) { if (func.MsgErr.Equals("")) { func.MsgErr = "执行失败(DoMethod_ExeSQL)."; } return("err@" + func.MsgErr + " @ " + ex.Message); } }
protected void Btn_Save_Click(object sender, EventArgs e) { try { if (this.FK_MapData.Replace("ND", "") == this.FK_Node.ToString()) { this.SaveNode(); return; } MapData md = new MapData(this.FK_MapData); GEEntity en = md.HisGEEn; en.SetValByKey("OID", this.OIDPKVal); int i = en.RetrieveFromDBSources(); en = this.UCEn1.Copy(en) as GEEntity; FrmEvents fes = md.FrmEvents; //new FrmEvents(this.FK_MapData); fes.DoEventNode(FrmEventList.SaveBefore, en); if (i == 0) { en.Insert(); } else { en.Update(); } fes.DoEventNode(FrmEventList.SaveAfter, en); //this.Response.Redirect("Frm.aspx?OID=" + en.GetValStringByKey("OID") + "&FK_Node=" + this.FK_Node + "&FID=" + this.FID + "&FK_MapData=" + this.FK_MapData, true); } catch (Exception ex) { this.UCEn1.AddMsgOfWarning("error:", ex.Message); } }
/// <summary> /// 生成实体 /// </summary> /// <param name="ds"></param> /// <returns></returns> public GEEntity GenerGEEntityByDataSet(DataSet ds) { // New 它的实例. GEEntity en = this.HisGEEn; // 它的table. DataTable dt = ds.Tables[this.No]; //装载数据. en.Row.LoadDataTable(dt, dt.Rows[0]); // dtls. MapDtls dtls = this.MapDtls; foreach (MapDtl item in dtls) { DataTable dtDtls = ds.Tables[item.No]; GEDtls dtlsEn = new GEDtls(item.No); foreach (DataRow dr in dtDtls.Rows) { // 产生它的Entity data. GEDtl dtl = (GEDtl)dtlsEn.GetNewEntity; dtl.Row.LoadDataTable(dtDtls, dr); //加入这个集合. dtlsEn.AddEntity(dtl); } //加入到他的集合里. en.Dtls.Add(dtDtls); } return(en); }
/// <summary> /// 生成单据根据 /// </summary> /// <param name="templeteFile">模板文件</param> /// <param name="saveToFile"></param> /// <param name="mainDT"></param> /// <param name="dtls"></param> public void MakeDocByDataSet(string templeteFile, string saveToPath, string saveToFileName, DataTable mainDT, DataSet dtlsDS) { string valMain = DBAccess.RunSQLReturnString("SELECT NO FROM SYS_MapData"); this.HisGEEntity = new GEEntity(valMain); this.HisGEEntity.Row.LoadDataTable(mainDT, mainDT.Rows[0]); this.AddEn(this.HisGEEntity); //增加一个主表。 if (dtlsDS != null) { foreach (DataTable dt in dtlsDS.Tables) { string dtlID = DBAccess.RunSQLReturnString("SELECT NO FROM SYS_MapDtl "); GEDtls dtls = new GEDtls(dtlID); foreach (DataRow dr in dt.Rows) { GEDtl dtl = dtls.GetNewEntity as GEDtl; dtl.Row.LoadDataTable(dt, dr); dtls.AddEntity(dtl); } this.AddDtlEns(dtls); //增加一个明晰。 } } this.MakeDoc(templeteFile, saveToPath, saveToFileName, "", false); }
private string GetMainPage(string workID, string flow, string node, string name) { string jsonData = "{"; Flow myFlow = new Flow(flow); string pTable = myFlow.PTable; if (string.IsNullOrEmpty(pTable)) { pTable = "ND" + int.Parse(flow) + "Rpt"; } Node nd = new Node(node); Work wk = nd.HisWork; wk.OID = int.Parse(workID); wk.Retrieve(); wk.ResetDefaultVal(); GEEntity ndxxRpt = new GEEntity(pTable); ndxxRpt.PKVal = workID; ndxxRpt.Retrieve(); ndxxRpt.Copy(wk); //执行序列化 // string jsonData = JsonConvert.SerializeObject(wk.Row); // jsonData = jsonData.Substring(1, jsonData.Length - 2); //加入他的明细表. List <Entities> al = wk.GetDtlsDatasOfList(); if (!name.Equals("MainPage")) { foreach (Entities singlEntities in al) { if (singlEntities.GetNewEntity.ToString() == name) { jsonData += "\"jsonDtl\":" + JsonConvert.SerializeObject(singlEntities.ToDataTableField()) + "}"; break; } } } else { //把数据赋值给wk. wk.Row = ndxxRpt.Row; string tempJson = JsonConvert.SerializeObject(wk.Row); jsonData = tempJson; } return(jsonData); }
void btn_Click(object sender, EventArgs e) { GEEntitys rpts = (GEEntitys)BP.DA.ClassFactory.GetEns(this.EnsName); GEEntity rpt = (GEEntity)rpts.GetNewEntity; Flow fl = new Flow(this.FK_Flow); Button btn = (Button)sender; if (btn.ID == "Btn_Excel") { QueryObject qo = new QueryObject(rpts); qo.AddWhere(WorkAttr.Rec, WebUser.No); qo.addAnd(); if (BP.SystemConfig.AppCenterDBType == DBType.Access) { qo.AddWhere("Mid(RDT,1,10) >='" + this.DT_F + "' AND Mid(RDT,1,10) <='" + this.DT_T + "' "); } else { qo.AddWhere("" + BP.SystemConfig.AppCenterDBSubstringStr + "(RDT,1,10) >='" + this.DT_F + "' AND " + BP.SystemConfig.AppCenterDBSubstringStr + "(RDT,1,10) <='" + this.DT_T + "' "); } this.Pub2.BindPageIdx(qo.GetCount(), this.PageSize, this.PageIdx, "?FK_Flow=" + this.FK_Flow + "&EnsName=" + this.EnsName); qo.DoQuery(); try { //this.ExportDGToExcel(ens.ToDataTableDescField(), this.HisEn.EnDesc); this.ExportDGToExcel(rpts.ToDataTableDesc(), fl.Name); } catch (Exception ex) { try { this.ExportDGToExcel(rpts.ToDataTableDescField(), fl.Name); } catch { this.ToErrorPage("数据没有正确导出可能的原因之一是:系统管理员没正确的安装Excel组件,请通知他,参考安装说明书解决。@系统异常信息:" + ex.Message); } } return; } this.Session["DF"] = this.Pub1.GetTextBoxByID("TB_F").Text; this.Session["DT"] = this.Pub1.GetTextBoxByID("TB_T").Text; this.Response.Redirect("FlowSearchMyWork.aspx?FK_Flow=" + this.FK_Flow + "&EnsName=" + this.EnsName, true); }
/// <summary> /// 生成报表 /// </summary> /// <param name="templeteFilePath">模版路径</param> /// <param name="ds">数据源</param> /// <returns>生成单据的路径</returns> public static void Frm_GenerBill(string templeteFullFile, string saveToDir, string saveFileName, BillFileType fileType, DataSet ds, string fk_mapData) { MapData md = new MapData(fk_mapData); GEEntity entity = md.GenerGEEntityByDataSet(ds); BP.Pub.RTFEngine rtf = new BP.Pub.RTFEngine(); rtf.HisEns.Clear(); rtf.EnsDataDtls.Clear(); rtf.HisEns.AddEntity(entity); var dtls = entity.Dtls; foreach (var item in dtls) { rtf.EnsDataDtls.Add(item); } rtf.MakeDoc(templeteFullFile, saveToDir, saveFileName, null, false); }
/// <summary> /// 在表单ID=ND101事件. /// </summary> public void ND101() { #region 当表单保存前. if (this.FK_Event == FrmEventList.FrmLoadBefore) { /* 当表单装载前. */ } #endregion 当表单保存前. #region 当表单装载后. if (this.FK_Event == FrmEventList.FrmLoadAfter) { /* 当表单装载后. */ } #endregion 当表单装载后. #region 当表单保存前. if (this.FK_Event == FrmEventList.SaveBefore) { /* 当表单保存前. */ } #endregion 当表单保存前. #region 当表单保存后. if (this.FK_Event == FrmEventList.SaveAfter) { throw new Exception(""); /* 当表单保存后. */ GEEntity en = new GEEntity(this.FK_MapData, this.OID); string rdt = en.GetValStrByKey("RDT"); string fid = this.Request.QueryString["FID"]; string rec = en.GetValStrByKey("Rec"); //访问数据库案例。 int result = BP.DA.DBAccess.RunSQL("DELETE WF_Emp WHERE 1=2 "); DataTable dt = BP.DA.DBAccess.RunSQLReturnTable("SELECT * FROM WF_Emp"); } #endregion 当表单保存后. }
/// <summary> /// 执行保存 /// </summary> /// <returns></returns> public string MyDict_SaveIt() { //执行保存. GEEntity rpt = new GEEntity(this.FrmID, this.WorkID); rpt = BP.Sys.PubClass.CopyFromRequest(rpt, context.Request) as GEEntity; Hashtable ht = GetMainTableHT(); foreach (string item in ht.Keys) { rpt.SetValByKey(item, ht[item]); } rpt.OID = this.WorkID; rpt.SetValByKey("BillState", (int)BillState.Editing); rpt.Update(); string str = BP.Frm.Dev2Interface.SaveWork(this.FrmID, this.WorkID); return(str); }
/// <summary> /// 生成单据根据 /// </summary> /// <param name="templeteFile">模板文件</param> /// <param name="saveToFile"></param> /// <param name="mainDT"></param> /// <param name="dtls"></param> public void MakeDocByDataSet(string templeteFile, string saveToPath, string saveToFileName, DataTable mainDT, DataSet dtlsDS) { this.HisGEEntity = new GEEntity("ND101"); this.HisGEEntity.Row.LoadDataTable(mainDT, mainDT.Rows[0]); this.AddEn(this.HisGEEntity); //增加一个主表。 if (dtlsDS != null) { foreach (DataTable dt in dtlsDS.Tables) { GEDtls dtls = new GEDtls("ND101Dtl1"); foreach (DataRow dr in dt.Rows) { GEDtl dtl = dtls.GetNewEntity as GEDtl; dtl.Row.LoadDataTable(dt, dr); dtls.AddEntity(dtl); } this.AddDtlEns(dtls); //增加一个明晰。 } } this.MakeDoc(templeteFile, saveToPath, saveToFileName, "", false); }
void btn_Click(object sender, EventArgs e) { MapDtls dtl2s = new MapDtls(); dtl2s.Delete(MapDtlAttr.FK_MapData, this.MyPK); Nodes nds = new Nodes(BP.WF.Glo.GenerFlowNo(this.MyPK)); foreach (BP.WF.Node nd in nds) { if (nd.IsEndNode == false) { continue; } MapDtls dtls = new MapDtls("ND" + nd.NodeID); int i = 0; foreach (MapDtl dtl in dtls) { if (this.Pub1.GetCBByID("CB_" + dtl.No).Checked == false) { continue; } i++; // 生成从表让其可以在单个数据里显示他们。 MapDtl dtlNew = new MapDtl(); dtlNew.Copy(dtl); dtlNew.No = this.MyPK + i; dtlNew.FK_MapData = this.MyPK; dtlNew.GroupID = this.Pub1.GetDDLByID("DDL_" + dtl.No).SelectedItemIntVal; dtlNew.Insert(); // 删除原来的数据。 MapAttrs attrsDtl = new MapAttrs(); attrsDtl.Delete(MapAttrAttr.FK_MapData, dtlNew.No); // 复制到新的数据表里。 MapAttrs attrs = new MapAttrs(dtl.No); foreach (MapAttr attr in attrs) { MapAttr attrN = new MapAttr(); attrN.Copy(attr); attrN.FK_MapData = dtlNew.No; attrN.Insert(); } Cash.Map_Cash.Remove(dtlNew.No); #region 制成 主表.让其可以查询。 // 处理主表。 MapData md = new MapData(); md.Copy(dtlNew); md.No = "ND" + int.Parse(this.FK_Flow) + "RptDtl" + i.ToString(); md.Save(); // 删除原来的属性。 attrs.Delete(MapAttrAttr.FK_MapData, md.No); // 删除分组。 GroupField gfBase = new GroupField(); gfBase.Delete(GroupFieldAttr.EnName, md.No); // 增加基本信息分组。 gfBase.EnName = md.No; gfBase.Lab = md.Name; gfBase.Idx = 99; gfBase.Insert(); //生成基本信息属性。 foreach (MapAttr attr in attrs) { MapAttr attrN = new MapAttr(); attrN.Copy(attr); attrN.FK_MapData = md.No; attrN.GroupID = gfBase.OID; attrN.Insert(); } MapAttrs attrNs = new MapAttrs(md.No); // 对个别字段进行处理。 foreach (MapAttr attr in attrNs) { switch (attr.KeyOfEn) { case StartWorkAttr.FK_Dept: continue; //if (attr.UIContralType != UIContralType.DDL) //{ //attr.UIBindKey = "BP.Port.Depts"; //attr.UIContralType = UIContralType.DDL; //attr.LGType = FieldTypeS.FK; //attr.UIVisible = true; //// if (gfs.Contains(attr.GroupID) == false) //attr.GroupID = gfBase.OID;// gfs[0].GetValIntByKey("OID"); //attr.Update(); //// } break; case "FK_NY": //attr.Delete(); ////if (attr.UIContralType != UIContralType.DDL) ////{ //attr.UIBindKey = "BP.Pub.NYs"; //attr.UIContralType = UIContralType.DDL; //attr.LGType = FieldTypeS.FK; //attr.UIVisible = true; //// if (gfs.Contains(attr.GroupID) == false) //attr.GroupID = gfBase.OID; // gfs[0].GetValIntByKey("OID"); //attr.Update(); break; case "Rec": attr.UIBindKey = "BP.Port.Emps"; attr.UIContralType = UIContralType.DDL; attr.LGType = FieldTypeS.FK; attr.UIVisible = true; attr.Name = "最后处理人"; attr.GroupID = gfBase.OID; attr.Update(); break; default: break; } } // 生成流程基本信息属性。 GroupField gfFlow = new GroupField(); gfFlow.EnName = md.No; gfFlow.Idx = 0; gfFlow.Lab = "流程信息"; gfFlow.Insert(); MapAttr attrFlow = new BP.Sys.MapAttr(); attrFlow = new BP.Sys.MapAttr(); attrFlow.FK_MapData = md.No; attrFlow.HisEditType = EditType.UnDel; attrFlow.KeyOfEn = "Title"; attrFlow.Name = "标题"; attrFlow.MyDataType = BP.DA.DataType.AppString; attrFlow.UIContralType = UIContralType.TB; attrFlow.LGType = FieldTypeS.Normal; attrFlow.UIVisible = true; attrFlow.UIIsEnable = true; attrFlow.UIIsLine = true; attrFlow.MinLen = 0; attrFlow.MaxLen = 1000; attrFlow.IDX = -100; attrFlow.GroupID = gfFlow.OID; attrFlow.Insert(); attrFlow.FK_MapData = md.No; attrFlow.HisEditType = EditType.UnDel; attrFlow.KeyOfEn = "FlowStarter"; attrFlow.Name = "发起人"; //"发起人"; attrFlow.MyDataType = BP.DA.DataType.AppString; attrFlow.UIContralType = UIContralType.DDL; attrFlow.UIBindKey = "BP.Port.Emps"; attrFlow.LGType = FieldTypeS.FK; attrFlow.UIVisible = true; attrFlow.UIIsEnable = false; attrFlow.UIIsLine = false; attrFlow.MaxLen = 20; attrFlow.MinLen = 0; attrFlow.Insert(); attrFlow = new BP.Sys.MapAttr(); attrFlow.FK_MapData = md.No; attrFlow.HisEditType = EditType.UnDel; attrFlow.KeyOfEn = "FlowStarterDept"; attrFlow.Name = "发起人部门"; attrFlow.MyDataType = BP.DA.DataType.AppString; attrFlow.UIContralType = UIContralType.DDL; attrFlow.UIBindKey = "BP.Port.Depts"; attrFlow.LGType = FieldTypeS.FK; attrFlow.UIVisible = true; attrFlow.UIIsEnable = false; attrFlow.MaxLen = 20; attrFlow.MinLen = 0; attrFlow.Insert(); attrFlow = new BP.Sys.MapAttr(); attrFlow.FK_MapData = md.No; attrFlow.HisEditType = EditType.UnDel; attrFlow.KeyOfEn = "FlowEmps"; attrFlow.Name = "参与人"; // attrFlow.MyDataType = BP.DA.DataType.AppString; attrFlow.UIContralType = UIContralType.TB; attrFlow.LGType = FieldTypeS.Normal; attrFlow.UIVisible = true; attrFlow.UIIsEnable = true; attrFlow.UIIsLine = false; attrFlow.MinLen = 0; attrFlow.MaxLen = 1000; attrFlow.IDX = -100; attrFlow.GroupID = gfFlow.OID; attrFlow.Insert(); attrFlow = new BP.Sys.MapAttr(); attrFlow.FK_MapData = md.No; attrFlow.HisEditType = EditType.UnDel; attrFlow.KeyOfEn = "FlowStartRDT"; attrFlow.Name = "发起时间"; // attrFlow.MyDataType = BP.DA.DataType.AppDateTime; attrFlow.UIContralType = UIContralType.TB; attrFlow.LGType = FieldTypeS.Normal; attrFlow.UIVisible = true; attrFlow.UIIsEnable = true; attrFlow.UIIsLine = false; attrFlow.MinLen = 0; attrFlow.MaxLen = 1000; attrFlow.IDX = -100; attrFlow.GroupID = gfFlow.OID; attrFlow.Insert(); attrFlow = new BP.Sys.MapAttr(); attrFlow.FK_MapData = md.No; attrFlow.HisEditType = EditType.UnDel; attrFlow.KeyOfEn = "FlowNY"; attrFlow.Name = "隶属年月"; attrFlow.MyDataType = BP.DA.DataType.AppString; attrFlow.UIContralType = UIContralType.DDL; attrFlow.UIBindKey = "BP.Pub.NYs"; attrFlow.LGType = FieldTypeS.FK; attrFlow.UIVisible = true; attrFlow.UIIsEnable = false; attrFlow.MaxLen = 20; attrFlow.MinLen = 0; attrFlow.Insert(); attrFlow = new BP.Sys.MapAttr(); attrFlow.FK_MapData = md.No; attrFlow.HisEditType = EditType.UnDel; attrFlow.KeyOfEn = "MyNum"; attrFlow.Name = "条"; // attrFlow.MyDataType = BP.DA.DataType.AppInt; attrFlow.DefVal = "1"; attrFlow.UIContralType = UIContralType.TB; attrFlow.LGType = FieldTypeS.Normal; attrFlow.UIVisible = false; attrFlow.UIIsEnable = false; attrFlow.UIIsLine = false; attrFlow.IDX = -101; attrFlow.GroupID = gfFlow.OID; if (attrFlow.IsExits == false) { attrFlow.Insert(); } // 清除缓存的map. Cash.Map_Cash.Remove(md.No); //检查主表的正确性。 GEEntity ge = new GEEntity(md.No); ge.CheckPhysicsTable(); #endregion 制成 主表.让其可以查询。 } } this.WinClose(); }
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(); }
private string GetDataByType(string fk_flow, string fk_node, string workID, string getType) { FrmNodes fns = new FrmNodes(fk_flow, int.Parse(fk_node)); string result = "{"; if (getType != "MainPage") { foreach (FrmNode fn in fns) { MapDtls mdtls = new MapDtls(fn.FK_Frm); foreach (MapDtl dtl in mdtls) { if (dtl.PTable.Equals(getType)) { GEDtls ens = new GEDtls(dtl.No); ens.Retrieve(GEDtlAttr.RefPK, workID); result += "\"" + dtl.PTable + "\":" + JsonConvert.SerializeObject(ens.ToDataTableField()) + "}"; break; } } } } else { foreach (FrmNode fn in fns) { GEEntity ge = new GEEntity(fn.FK_Frm, workID); string tempJson = JsonConvert.SerializeObject(ge.Row); tempJson = tempJson.TrimStart('{'); tempJson = tempJson.TrimEnd('}'); result += tempJson + ","; } result = result.TrimEnd(',') + "}"; } //foreach (FrmNode fn in fns) //{ // if (fn.FK_Frm == name) // { // GEEntity ge = new GEEntity(fn.FK_Frm, workID); // if (getType == "MainPage") // { // result = JsonConvert.SerializeObject(ge.Row); // } // else // { // result = JsonConvert.SerializeObject(ge.Row); // result = result.Substring(0, result.Length - 1); // MapDtls mdtls = new MapDtls(fn.FK_Frm); // foreach (MapDtl dtl in mdtls) // { // if (dtl.PTable.Equals(getType)) // { // GEDtls ens = new GEDtls(dtl.No); // ens.Retrieve(GEDtlAttr.RefPK, workID); // result += ",\"" + dtl.PTable + "\":" + // JsonConvert.SerializeObject(ens.ToDataTableField()) + "}"; // break; // } // } // } // break; // } //} return(result); }
/// <summary> /// 打印单据 /// </summary> /// <param name="func"></param> public void PrintDocV2(BillTemplate func) { string billInfo = ""; Node nd = new Node(this.FK_Node); Work wk = nd.HisWork; wk.OID = this.WorkID; wk.Retrieve(); wk.ResetDefaultVal(); string file = DateTime.Now.Year + "_" + WebUser.FK_Dept + "_" + func.No + "_" + WorkID + ".doc"; BP.Pub.RTFEngine rtf = new BP.Pub.RTFEngine(); string[] paths; string path; try { #region 生成单据 rtf.HisEns.Clear(); rtf.EnsDataDtls.Clear(); if (func.NodeID == 0) { } else { //WorkNodes wns = new WorkNodes(); //if (nd.HisRunModel == RunModel.FL // || nd.HisRunModel == RunModel.FHL // || nd.HisRunModel == RunModel.HL) // wns.GenerByFID(nd.HisFlow, this.WorkID); //else // wns.GenerByWorkID(nd.HisFlow, this.WorkID); //把流程主表数据放入里面去. GEEntity ndxxRpt = new GEEntity("ND" + int.Parse(nd.FK_Flow) + "Rpt"); ndxxRpt.PKVal = this.WorkID; ndxxRpt.Retrieve(); ndxxRpt.Copy(wk); //把数据赋值给wk. wk.Row = ndxxRpt.Row; rtf.HisGEEntity = wk; //加入他的明细表. List <Entities> al = wk.GetDtlsDatasOfList(); foreach (Entities ens in al) { rtf.AddDtlEns(ens); } //rtf.AddEn(wk); ////if (wns.Count == 0) //// works = nd.HisWorks; ////else //// works = wns.GetWorks; //foreach (Work mywk in works) //{ // if (mywk.OID == 0) // continue; // rtf.AddEn(mywk); // rtf.ensStrs += ".ND" + mywk.NodeID; //} } paths = file.Split('_'); path = paths[0] + "/" + paths[1] + "/" + paths[2] + "/"; string billUrl = BP.WF.Glo.CCFlowAppPath + "DataUser/Bill/" + path + file; if (func.HisBillFileType == BillFileType.PDF) { billUrl = billUrl.Replace(".doc", ".pdf"); billInfo += "<img src='/WF/Img/FileType/PDF.gif' /><a href='" + billUrl + "' target=_blank >" + func.Name + "</a>"; } else { billInfo += "<img src='/WF/Img/FileType/doc.gif' /><a href='" + billUrl + "' target=_blank >" + func.Name + "</a>"; } path = BP.WF.Glo.FlowFileBill + DateTime.Now.Year + "\\" + WebUser.FK_Dept + "\\" + func.No + "\\"; // path = Server.MapPath(path); if (System.IO.Directory.Exists(path) == false) { System.IO.Directory.CreateDirectory(path); } rtf.MakeDoc(func.Url + ".rtf", path, file, func.ReplaceVal, false); #endregion #region 转化成pdf. if (func.HisBillFileType == BillFileType.PDF) { string rtfPath = path + file; string pdfPath = rtfPath.Replace(".doc", ".pdf"); try { BP.WF.Glo.Rtf2PDF(rtfPath, pdfPath); } catch (Exception ex) { billInfo = ex.Message; //this.addMsg("RptError", "产生报表数据错误:" + ex.Message); } } #endregion #region 保存单据 Bill bill = new Bill(); bill.MyPK = wk.FID + "_" + wk.OID + "_" + nd.NodeID + "_" + func.No; bill.FID = wk.FID; bill.WorkID = wk.OID; bill.FK_Node = wk.NodeID; bill.FK_Dept = WebUser.FK_Dept; bill.FK_Emp = WebUser.No; bill.Url = billUrl; bill.RDT = DataType.CurrentDataTime; bill.FullPath = path + file; bill.FK_NY = DataType.CurrentYearMonth; bill.FK_Flow = nd.FK_Flow; bill.FK_BillType = func.FK_BillType; bill.Emps = rtf.HisGEEntity.GetValStrByKey("Emps"); bill.FK_Starter = rtf.HisGEEntity.GetValStrByKey("Rec"); bill.StartDT = rtf.HisGEEntity.GetValStrByKey("RDT"); bill.Title = rtf.HisGEEntity.GetValStrByKey("Title"); bill.FK_Dept = rtf.HisGEEntity.GetValStrByKey("FK_Dept"); try { bill.Save(); } catch { bill.Update(); } #endregion } catch (Exception ex) { BP.WF.DTS.InitBillDir dir = new BP.WF.DTS.InitBillDir(); dir.Do(); path = BP.WF.Glo.FlowFileBill + DateTime.Now.Year + "\\" + WebUser.FK_Dept + "\\" + func.No + "\\"; string msgErr = "@" + string.Format("生成单据失败,请让管理员检查目录设置") + "[" + BP.WF.Glo.FlowFileBill + "]。@Err:" + ex.Message + " @File=" + file + " @Path:" + path; billInfo += "@<font color=red>" + msgErr + "</font>"; throw new Exception(msgErr + "@其它信息:" + ex.Message); } this.Pub1.AddFieldSet("打印单据"); this.Pub1.AddUL(); this.Pub1.AddLi(billInfo); this.Pub1.AddULEnd(); this.Pub1.AddFieldSetEnd(); return; }
protected void Page_Load(object sender, EventArgs e) { #warning 没有缓存经常预览与设计不一致 if (this.Request.QueryString["IsTest"] == "1") { BP.SystemConfig.DoClearCash_del(); } if (this.Request.QueryString["IsLoadData"] == "1") { this.UCEn1.IsLoadData = true; } MapData md = new MapData(); md.No = this.FK_MapData; if (md.RetrieveFromDBSources() == 0 && md.Name.Length > 3) { if (md.HisFrmType == FrmType.Url) { this.Response.Redirect(md.PTable, true); return; } /* 没有找到此map. */ MapDtl dtl = new MapDtl(this.FK_MapData); GEDtl dtlEn = dtl.HisGEDtl; dtlEn.SetValByKey("OID", this.FID); if (dtlEn.EnMap.Attrs.Count < 2) { md.RepairMap(); this.Response.Redirect(this.Request.RawUrl, true); return; } int i = dtlEn.RetrieveFromDBSources(); string[] paras = this.RequestParas.Split('&'); foreach (string str in paras) { if (string.IsNullOrEmpty(str) || str.Contains("=") == false) { continue; } string[] kvs = str.Split('='); dtlEn.SetValByKey(kvs[0], kvs[1]); } if (md.HisFrmType == FrmType.CCForm) { this.UCEn1.BindCCForm(dtlEn, this.FK_MapData, !this.IsEdit); } if (md.HisFrmType == FrmType.Column4Frm) { this.UCEn1.BindCCForm(dtlEn, this.FK_MapData, !this.IsEdit); } this.AddJSEvent(dtlEn); } else { GEEntity en = md.HisGEEn; int pk = this.OID; if (this.Request.QueryString["NodeID"] != null) { /*说明是流程调用它.*/ Node nd = new Node(int.Parse(this.Request.QueryString["NodeID"])); if (nd.HisRunModel == RunModel.SubThread && nd.HisSubThreadType == SubThreadType.UnSameSheet && this.FK_MapData != "ND" + nd.NodeID) { /*如果是子线程, 并且是异表单节点.*/ pk = this.FID; // 是子线程,并且是异表单的子线程,并且不是节点表单。这样设置是为了到合流点上能够按FID进行表单数据汇总. } } en.SetValByKey("OID", pk); if (en.EnMap.Attrs.Count < 2) { md.RepairMap(); this.Response.Redirect(this.Request.RawUrl, true); return; } int i = en.RetrieveFromDBSources(); if (i == 0) { en.DirectInsert(); } string[] paras = this.RequestParas.Split('&'); foreach (string str in paras) { if (string.IsNullOrEmpty(str) || str.Contains("=") == false) { continue; } string[] kvs = str.Split('='); en.SetValByKey(kvs[0], kvs[1]); } en.ResetDefaultVal(); if (en.ToString() == "0") { en.SetValByKey("OID", pk); } this.OIDPKVal = pk; this.UCEn1.BindCCForm(en, this.FK_MapData, !this.IsEdit); this.AddJSEvent(en); } Session["Count"] = null; this.Btn_Save.Click += new EventHandler(Btn_Save_Click); this.Btn_Save.Visible = this.IsEdit; this.Btn_Save.Enabled = this.IsEdit; this.Btn_Save.BackColor = System.Drawing.Color.White; this.Btn_Print.Visible = this.IsPrint; this.Btn_Print.Enabled = this.IsPrint; this.Btn_Print.Attributes["onclick"] = "window.showModalDialog('./CCForm/Print.aspx?FK_Node=" + this.FK_Node + "&FID=" + this.FID + "&FK_MapData=" + this.FK_MapData + "&WorkID=" + this.OID + "', '', 'dialogHeight: 350px; dialogWidth:450px; center: yes; help: no'); return false;"; }
/// <summary> /// 获取从表数据,用于显示dtl.htm /// </summary> /// <param name="frmID">表单ID</param> /// <param name="pkval">主键</param> /// <param name="atParas">参数</param> /// <param name="specDtlFrmID">指定明细表的参数,如果为空就标识主表数据,否则就是从表数据.</param> /// <returns>数据</returns> public static DataSet GenerDBForCCFormDtl(string frmID, MapDtl dtl, int pkval, string atParas) { //数据容器,就是要返回的对象. DataSet myds = new DataSet(); //映射实体. MapData md = new MapData(frmID); //实体. GEEntity wk = new GEEntity(frmID); wk.OID = pkval; if (wk.RetrieveFromDBSources() == 0) { wk.Insert(); } //把参数放入到 En 的 Row 里面。 if (DataType.IsNullOrEmpty(atParas) == false) { AtPara ap = new AtPara(atParas); foreach (string key in ap.HisHT.Keys) { try { if (wk.Row.ContainsKey(key) == true) //有就该变. { wk.Row[key] = ap.GetValStrByKey(key); } else { wk.Row.Add(key, ap.GetValStrByKey(key)); //增加他. } } catch (Exception ex) { throw new Exception(key); } } } #region 加载从表表单模版信息. DataTable Sys_MapDtl = dtl.ToDataTableField("Sys_MapDtl"); myds.Tables.Add(Sys_MapDtl); //明细表的表单描述 DataTable Sys_MapAttr = dtl.MapAttrs.ToDataTableField("Sys_MapAttr"); myds.Tables.Add(Sys_MapAttr); //明细表的配置信息. DataTable Sys_MapExt = dtl.MapExts.ToDataTableField("Sys_MapExt"); myds.Tables.Add(Sys_MapExt); #region 把从表的- 外键表/枚举 加入 DataSet. MapExts mes = dtl.MapExts; MapExt me = null; foreach (DataRow dr in Sys_MapAttr.Rows) { string lgType = dr["LGType"].ToString(); //不是枚举/外键字段 if (lgType.Equals("0")) { continue; } string uiBindKey = dr["UIBindKey"].ToString(); var mypk = dr["MyPK"].ToString(); #region 枚举字段 if (lgType.Equals("1")) { // 如果是枚举值, 判断是否存在. if (myds.Tables.Contains(uiBindKey) == true) { continue; } string mysql = "SELECT IntKey AS No, Lab as Name FROM Sys_Enum WHERE EnumKey='" + uiBindKey + "' ORDER BY IntKey "; DataTable dtEnum = DBAccess.RunSQLReturnTable(mysql); dtEnum.TableName = uiBindKey; dtEnum.Columns[0].ColumnName = "No"; dtEnum.Columns[1].ColumnName = "Name"; myds.Tables.Add(dtEnum); continue; } #endregion #region 外键字段 string UIIsEnable = dr["UIIsEnable"].ToString(); if (UIIsEnable.Equals("0")) //字段未启用 { continue; } // 检查是否有下拉框自动填充。 string keyOfEn = dr["KeyOfEn"].ToString(); #region 处理下拉框数据范围. for 小杨. me = mes.GetEntityByKey(MapExtAttr.ExtType, MapExtXmlList.AutoFullDLL, MapExtAttr.AttrOfOper, keyOfEn) as MapExt; if (me != null) //有范围限制时 { string fullSQL = me.Doc.Clone() as string; fullSQL = fullSQL.Replace("~", ","); fullSQL = BP.WF.Glo.DealExp(fullSQL, wk, null); DataTable dt = DBAccess.RunSQLReturnTable(fullSQL); dt.TableName = uiBindKey; dt.Columns[0].ColumnName = "No"; dt.Columns[1].ColumnName = "Name"; myds.Tables.Add(dt); continue; } #endregion 处理下拉框数据范围. // 判断是否存在. if (myds.Tables.Contains(uiBindKey) == true) { continue; } myds.Tables.Add(BP.Sys.PubClass.GetDataTableByUIBineKey(uiBindKey)); #endregion 外键字段 } #endregion 把从表的- 外键表/枚举 加入 DataSet. #endregion 加载从表表单模版信息. #region 把主表数据放入. if (BP.Sys.SystemConfig.IsBSsystem == true) { // 处理传递过来的参数。 foreach (string k in System.Web.HttpContext.Current.Request.QueryString.AllKeys) { wk.SetValByKey(k, System.Web.HttpContext.Current.Request.QueryString[k]); } } //重设默认值. wk.ResetDefaultVal(); //增加主表数据. DataTable mainTable = wk.ToDataTableField(md.No); mainTable.TableName = "MainTable"; myds.Tables.Add(mainTable); #endregion 把主表数据放入. #region 把从表的数据放入. GEDtls dtls = new GEDtls(dtl.No); QueryObject qo = null; try { qo = new QueryObject(dtls); switch (dtl.DtlOpenType) { case DtlOpenType.ForEmp: // 按人员来控制. qo.AddWhere(GEDtlAttr.RefPK, pkval); qo.addAnd(); qo.AddWhere(GEDtlAttr.Rec, WebUser.No); break; case DtlOpenType.ForWorkID: // 按工作ID来控制 qo.AddWhere(GEDtlAttr.RefPK, pkval); break; case DtlOpenType.ForFID: // 按流程ID来控制. qo.AddWhere(GEDtlAttr.FID, pkval); break; } } catch (Exception ex) { dtls.GetNewEntity.CheckPhysicsTable(); throw ex; } //条件过滤. if (dtl.FilterSQLExp != "") { string[] strs = dtl.FilterSQLExp.Split('='); qo.addAnd(); qo.AddWhere(strs[0], strs[1]); } //增加排序. // qo.addOrderByDesc( dtls.GetNewEntity.PKField ); //从表 DataTable dtDtl = qo.DoQueryToTable(); //查询所有动态SQL查询类型的字典表记录 SFTable sftable = null; DataTable dtsftable = null; DataRow[] drs = null; SFTables sftables = new SFTables(); sftables.Retrieve(SFTableAttr.SrcType, (int)SrcType.SQL); // 为明细表设置默认值. MapAttrs dtlAttrs = new MapAttrs(dtl.No); foreach (MapAttr attr in dtlAttrs) { #region 修改区分大小写. if (BP.DA.DBType.Oracle == SystemConfig.AppCenterDBType) { foreach (DataColumn dr in dtDtl.Columns) { var a = attr.KeyOfEn; var b = dr.ColumnName; if (attr.KeyOfEn.ToUpper().Equals(dr.ColumnName)) { dr.ColumnName = attr.KeyOfEn; continue; } if (attr.LGType == FieldTypeS.Enum || attr.LGType == FieldTypeS.FK) { if (dr.ColumnName.Equals(attr.KeyOfEn.ToUpper() + "TEXT")) { dr.ColumnName = attr.KeyOfEn + "Text"; } } } foreach (DataRow dr in dtDtl.Rows) { //本身是大写的不进行修改 if (DataType.IsNullOrEmpty(dr[attr.KeyOfEn] + "")) { dr[attr.KeyOfEn] = dr[attr.KeyOfEn.ToUpper()]; dr[attr.KeyOfEn.ToUpper()] = null; } } } #endregion 修改区分大小写. //处理增加动态SQL查询类型的下拉框选中值Text值,added by liuxc,2017-9-22 if (attr.LGType == FieldTypeS.FK && attr.UIIsEnable == false) { sftable = sftables.GetEntityByKey(attr.UIBindKey) as SFTable; if (sftable != null) { dtsftable = sftable.GenerHisDataTable; //为Text赋值 foreach (DataRow dr in dtDtl.Rows) { drs = dtsftable.Select("No='" + dr[attr.KeyOfEn] + "'"); if (drs.Length == 0) { continue; } dr[attr.KeyOfEn + "Text"] = drs[0]["Name"]; } } } //处理它的默认值. if (attr.DefValReal.Contains("@") == false) { continue; } foreach (DataRow dr in dtDtl.Rows) { dr[attr.KeyOfEn] = attr.DefVal; } } dtDtl.TableName = "DBDtl"; //修改明细表的名称. myds.Tables.Add(dtDtl); //加入这个明细表, 如果没有数据,xml体现为空. #endregion 把从表的数据放入. //放入一个空白的实体,用与获取默认值. GEDtl dtlBlank = dtls.GetNewEntity as GEDtl; dtlBlank.ResetDefaultVal(); myds.Tables.Add(dtlBlank.ToDataTableField("Blank")); return(myds); }
/// <summary> /// 仅获取表单数据 /// </summary> /// <param name="frmID">表单ID</param> /// <param name="pkval">主键</param> /// <param name="atParas">参数</param> /// <param name="specDtlFrmID">指定明细表的参数,如果为空就标识主表数据,否则就是从表数据.</param> /// <returns>数据</returns> public static DataSet GenerDBForVSTOExcelFrmModel(string frmID, object pkval, string atParas, string specDtlFrmID = null) { //如果是一个实体类. if (frmID.Contains("BP.")) { // 执行map同步. Entities ens = BP.En.ClassFactory.GetEns(frmID + "s"); Entity en = ens.GetNewEntity; en.DTSMapToSys_MapData(); return(GenerDBForVSTOExcelFrmModelOfEntity(frmID, pkval, atParas, specDtlFrmID = null)); //上面这行代码的解释(2017-04-25): //若不加上这行,代码执行到“ MapData md = new MapData(frmID); ”会报错: //@没有找到记录[表单注册表 Sys_MapData, [ 主键=No 值=BP.LI.BZQX ]记录不存在,请与管理员联系, 或者确认输入错误.@在Entity(BP.Sys.MapData)查询期间出现错误@ 在 BP.En.Entity.Retrieve() 位置 D:\ccflow\Components\BP.En30\En\Entity.cs:行号 1051 //即使加上: //frmID = frmID.Substring(0, frmID.Length - 1); //也会出现该问题 //2017-04-25 15:26:34:new MapData(frmID)应传入“BZQX”,但考虑到 GenerDBForVSTOExcelFrmModelOfEntity()运行稳定,暂不采用『统一执行下方代码』的方案。 } //数据容器,就是要返回的对象. DataSet myds = new DataSet(); //映射实体. MapData md = new MapData(frmID); //实体. GEEntity wk = new GEEntity(frmID); wk.OID = int.Parse(pkval.ToString()); if (wk.RetrieveFromDBSources() == 0) { wk.Insert(); } //加载事件. md.DoEvent(FrmEventList.FrmLoadBefore, wk, null); //把参数放入到 En 的 Row 里面。 if (DataType.IsNullOrEmpty(atParas) == false) { AtPara ap = new AtPara(atParas); foreach (string key in ap.HisHT.Keys) { if (wk.Row.ContainsKey(key) == true) //有就该变. { wk.Row[key] = ap.GetValStrByKey(key); } else { wk.Row.Add(key, ap.GetValStrByKey(key)); //增加他. } } } //属性. MapExt me = null; DataTable dtMapAttr = null; MapExts mes = null; #region 表单模版信息.(含主、从表的,以及从表的枚举/外键相关数据). //增加表单字段描述. string sql = "SELECT * FROM Sys_MapData WHERE No='" + frmID + "' "; DataTable dt = BP.DA.DBAccess.RunSQLReturnTable(sql); dt.TableName = "Sys_MapData"; myds.Tables.Add(dt); //增加表单字段描述. sql = "SELECT * FROM Sys_MapAttr WHERE FK_MapData='" + frmID + "' "; dt = BP.DA.DBAccess.RunSQLReturnTable(sql); dt.TableName = "Sys_MapAttr"; myds.Tables.Add(dt); //增加从表信息. sql = "SELECT * FROM Sys_MapDtl WHERE FK_MapData='" + frmID + "' "; dt = BP.DA.DBAccess.RunSQLReturnTable(sql); dt.TableName = "Sys_MapDtl"; myds.Tables.Add(dt); //主表的配置信息. sql = "SELECT * FROM Sys_MapExt WHERE FK_MapData='" + frmID + "'"; dt = BP.DA.DBAccess.RunSQLReturnTable(sql); dt.TableName = "Sys_MapExt"; myds.Tables.Add(dt); #region 加载 从表表单模版信息.(含 从表的枚举/外键相关数据) foreach (MapDtl item in md.MapDtls) { #region 返回指定的明细表的数据. if (DataType.IsNullOrEmpty(specDtlFrmID) == true) { } else { if (item.No != specDtlFrmID) { continue; } } #endregion 返回指定的明细表的数据. //明细表的主表描述 sql = "SELECT * FROM Sys_MapDtl WHERE No='" + item.No + "'"; dt = BP.DA.DBAccess.RunSQLReturnTable(sql); dt.TableName = "Sys_MapDtl_For_" + (string.IsNullOrWhiteSpace(item.Alias) ? item.No : item.Alias); myds.Tables.Add(dt); //明细表的表单描述 sql = "SELECT * FROM Sys_MapAttr WHERE FK_MapData='" + item.No + "'"; dtMapAttr = BP.DA.DBAccess.RunSQLReturnTable(sql); dtMapAttr.TableName = "Sys_MapAttr_For_" + (string.IsNullOrWhiteSpace(item.Alias) ? item.No : item.Alias); myds.Tables.Add(dtMapAttr); //明细表的配置信息. sql = "SELECT * FROM Sys_MapExt WHERE FK_MapData='" + item.No + "'"; dt = BP.DA.DBAccess.RunSQLReturnTable(sql); dt.TableName = "Sys_MapExt_For_" + (string.IsNullOrWhiteSpace(item.Alias) ? item.No : item.Alias); myds.Tables.Add(dt); #region 从表的 外键表/枚举 mes = new MapExts(item.No); foreach (DataRow dr in dtMapAttr.Rows) { string lgType = dr["LGType"].ToString(); //不是枚举/外键字段 if (lgType.Equals("0")) { continue; } string uiBindKey = dr["UIBindKey"].ToString(); var mypk = dr["MyPK"].ToString(); #region 枚举字段 if (lgType.Equals("1")) { // 如果是枚举值, 判断是否存在. if (myds.Tables.Contains(uiBindKey) == true) { continue; } string mysql = "SELECT IntKey AS No, Lab as Name FROM Sys_Enum WHERE EnumKey='" + uiBindKey + "' ORDER BY IntKey "; DataTable dtEnum = DBAccess.RunSQLReturnTable(mysql); dtEnum.TableName = uiBindKey; myds.Tables.Add(dtEnum); continue; } #endregion string UIIsEnable = dr["UIIsEnable"].ToString(); if (UIIsEnable.Equals("0")) //字段未启用 { continue; } #region 外键字段 // 检查是否有下拉框自动填充。 string keyOfEn = dr["KeyOfEn"].ToString(); #region 处理下拉框数据范围. for 小杨. me = mes.GetEntityByKey(MapExtAttr.ExtType, MapExtXmlList.AutoFullDLL, MapExtAttr.AttrOfOper, keyOfEn) as MapExt; if (me != null) //有范围限制时 { string fullSQL = me.Doc.Clone() as string; fullSQL = fullSQL.Replace("~", ","); fullSQL = BP.WF.Glo.DealExp(fullSQL, wk, null); dt = DBAccess.RunSQLReturnTable(fullSQL); dt.TableName = mypk; myds.Tables.Add(dt); continue; } #endregion 处理下拉框数据范围. else //无范围限制时 { // 判断是否存在. if (myds.Tables.Contains(uiBindKey) == true) { continue; } myds.Tables.Add(BP.Sys.PubClass.GetDataTableByUIBineKey(uiBindKey)); } #endregion 外键字段 } #endregion 从表的 外键表/枚举 } #endregion 加载 从表表单模版信息.(含 从表的枚举/外键相关数据) #endregion 表单模版信息.(含主、从表的,以及从表的枚举/外键相关数据). #region 主表数据 if (BP.Sys.SystemConfig.IsBSsystem == true) { // 处理传递过来的参数。 foreach (string k in System.Web.HttpContext.Current.Request.QueryString.AllKeys) { wk.SetValByKey(k, System.Web.HttpContext.Current.Request.QueryString[k]); } } // 执行表单事件.. string msg = md.DoEvent(FrmEventList.FrmLoadBefore, wk); if (DataType.IsNullOrEmpty(msg) == false) { throw new Exception("err@错误:" + msg); } //重设默认值. wk.ResetDefaultVal(); //执行装载填充. me = new MapExt(); if (me.Retrieve(MapExtAttr.ExtType, MapExtXmlList.PageLoadFull, MapExtAttr.FK_MapData, frmID) == 1) { //执行通用的装载方法. MapAttrs attrs = new MapAttrs(frmID); MapDtls dtls = new MapDtls(frmID); wk = BP.WF.Glo.DealPageLoadFull(wk, me, attrs, dtls) as GEEntity; } //增加主表数据. DataTable mainTable = wk.ToDataTableField(md.No); mainTable.TableName = "MainTable"; myds.Tables.Add(mainTable); #endregion 主表数据 #region 从表数据 foreach (MapDtl dtl in md.MapDtls) { #region 返回指定的明细表的数据. if (DataType.IsNullOrEmpty(specDtlFrmID) == true) { } else { if (dtl.No != specDtlFrmID) { continue; } } #endregion 返回指定的明细表的数据. GEDtls dtls = new GEDtls(dtl.No); QueryObject qo = null; try { qo = new QueryObject(dtls); switch (dtl.DtlOpenType) { case DtlOpenType.ForEmp: // 按人员来控制. qo.AddWhere(GEDtlAttr.RefPK, pkval); qo.addAnd(); qo.AddWhere(GEDtlAttr.Rec, WebUser.No); break; case DtlOpenType.ForWorkID: // 按工作ID来控制 qo.AddWhere(GEDtlAttr.RefPK, pkval); break; case DtlOpenType.ForFID: // 按流程ID来控制. qo.AddWhere(GEDtlAttr.FID, pkval); break; } } catch { dtls.GetNewEntity.CheckPhysicsTable(); } //条件过滤. if (dtl.FilterSQLExp != "") { string[] strs = dtl.FilterSQLExp.Split('='); qo.addAnd(); qo.AddWhere(strs[0], strs[1]); } //从表 DataTable dtDtl = qo.DoQueryToTable(); // 为明细表设置默认值. MapAttrs dtlAttrs = new MapAttrs(dtl.No); foreach (MapAttr attr in dtlAttrs) { //处理它的默认值. if (attr.DefValReal.Contains("@") == false) { continue; } foreach (DataRow dr in dtDtl.Rows) { dr[attr.KeyOfEn] = attr.DefVal; } } dtDtl.TableName = string.IsNullOrWhiteSpace(dtl.Alias) ? dtl.No : dtl.Alias; //edited by liuxc,2017-10-10.如果有别名,则使用别名,没有则使用No myds.Tables.Add(dtDtl); //加入这个明细表, 如果没有数据,xml体现为空. } #endregion 从表数据 #region 主表的 外键表/枚举 dtMapAttr = myds.Tables["Sys_MapAttr"]; mes = md.MapExts; foreach (DataRow dr in dtMapAttr.Rows) { string uiBindKey = dr["UIBindKey"].ToString(); string myPK = dr["MyPK"].ToString(); string lgType = dr["LGType"].ToString(); if (lgType.Equals("1")) { // 如果是枚举值, 判断是否存在., if (myds.Tables.Contains(uiBindKey) == true) { continue; } string mysql = "SELECT IntKey AS No, Lab as Name FROM Sys_Enum WHERE EnumKey='" + uiBindKey + "' ORDER BY IntKey "; DataTable dtEnum = DBAccess.RunSQLReturnTable(mysql); dtEnum.TableName = uiBindKey; myds.Tables.Add(dtEnum); continue; } if (lgType.Equals("2") == false) { continue; } string UIIsEnable = dr["UIIsEnable"].ToString(); if (UIIsEnable.Equals("0")) { continue; } // 检查是否有下拉框自动填充。 string keyOfEn = dr["KeyOfEn"].ToString(); string fk_mapData = dr["FK_MapData"].ToString(); #region 处理下拉框数据范围. for 小杨. me = mes.GetEntityByKey(MapExtAttr.ExtType, MapExtXmlList.AutoFullDLL, MapExtAttr.AttrOfOper, keyOfEn) as MapExt; if (me != null) { string fullSQL = me.Doc.Clone() as string; fullSQL = fullSQL.Replace("~", ","); fullSQL = BP.WF.Glo.DealExp(fullSQL, wk, null); dt = DBAccess.RunSQLReturnTable(fullSQL); dt.TableName = myPK; //可能存在隐患,如果多个字段,绑定同一个表,就存在这样的问题. myds.Tables.Add(dt); continue; } #endregion 处理下拉框数据范围. dt = BP.Sys.PubClass.GetDataTableByUIBineKey(uiBindKey); dt.TableName = uiBindKey; myds.Tables.Add(dt); } #endregion 主表的 外键表/枚举 //返回生成的dataset. return(myds); }
private string GetDtlCount(string workID, string flow, string node) { Flow myFlow = new Flow(flow); string pTable = myFlow.PTable; if (string.IsNullOrEmpty(pTable)) { pTable = "ND" + int.Parse(flow) + "Rpt"; } Node nd = new Node(node); Work wk = nd.HisWork; wk.OID = int.Parse(workID); wk.Retrieve(); wk.ResetDefaultVal(); GEEntity ndxxRpt = new GEEntity(pTable); ndxxRpt.PKVal = workID; ndxxRpt.Retrieve(); ndxxRpt.Copy(wk); //把数据赋值给wk. wk.Row = ndxxRpt.Row; //string jsonData = null; //执行序列化 // string jsonData = JsonConvert.SerializeObject(wk.Row); // jsonData = jsonData.Substring(1, jsonData.Length - 2); //加入他的明细表. List <Entities> al = wk.GetDtlsDatasOfList(); List <TempEntity> tempName = new List <TempEntity>(); foreach (Entities singleEntities in al) { tempName.Add(new TempEntity() { Name = singleEntities.GetNewEntity.ToString() }); } return(JsonConvert.SerializeObject(tempName)); //if (al.Count > 1) //{ // foreach (Entities ens in al) // { // string dtlJson = JsonConvert.SerializeObject(ens.ToDataTableField()); // var index = al.IndexOf(ens); // jsonData += ",\"jsonDtl" + index + "\":" + dtlJson; // } //} //else //{ // jsonData = JsonConvert.SerializeObject(wk.Row); // jsonData = jsonData.Substring(0, jsonData.Length - 1); // jsonData += ",\"jsonDtl\":" + JsonConvert.SerializeObject(al[0].ToDataTableField()); // jsonData += "}"; //} }
protected void Page_Load(object sender, EventArgs e) { #region 属性 string sealName = null; #endregion 属性 #warning 没有缓存经常预览与设计不一致 MapData md = new MapData(); md.No = this.FK_MapData; if (this.Request.QueryString["IsTest"] == "1") { md.RepairMap(); BP.Sys.SystemConfig.DoClearCash_del(); } if (this.Request.QueryString["IsLoadData"] == "1") { this.UCEn1.IsLoadData = true; } if (md.RetrieveFromDBSources() == 0 && md.Name.Length > 3) { /*如果没有找到,就可能是 dtl 。*/ if (md.HisFrmType == FrmType.Url || md.HisFrmType == FrmType.SLFrm) { string no = Request.QueryString["NO"]; string urlParas = "OID=" + this.OID + "&NO=" + no + "&WorkID=" + this.WorkID + "&FK_Node=" + this.FK_Node + "&UserNo=" + WebUser.No + "&SID=" + this.SID; /*如果是URL.*/ if (md.Url.Contains("?") == true) { this.Response.Redirect(md.Url + "&" + urlParas, true); } else { this.Response.Redirect(md.Url + "?" + urlParas, true); } return; } /* 没有找到此map. */ MapDtl dtl = new MapDtl(this.FK_MapData); GEDtl dtlEn = dtl.HisGEDtl; dtlEn.SetValByKey("OID", this.FID); if (dtlEn.EnMap.Attrs.Count <= 0) { md.RepairMap(); this.Response.Redirect(this.Request.RawUrl, true); return; } int i = dtlEn.RetrieveFromDBSources(); string[] paras = this.RequestParas.Split('&'); foreach (string str in paras) { if (string.IsNullOrEmpty(str) || str.Contains("=") == false) { continue; } string[] kvs = str.Split('='); dtlEn.SetValByKey(kvs[0], kvs[1]); } Width = md.MaxRight + md.MaxLeft * 2 + 10 + ""; if (float.Parse(Width) < 500) { Width = "900"; } Height = md.MaxEnd > md.FrmH ? md.MaxEnd + "" : md.FrmH + ""; if (float.Parse(Height) <= 800) { Height = "800"; } this.UCEn1.Add("<div id=divCCForm style='width:" + Width + "px;height:" + Height + "px' >"); if (md.HisFrmType == FrmType.FreeFrm) { this.UCEn1.BindCCForm(dtlEn, this.FK_MapData, !this.IsEdit, 0, this.IsLoadData); } if (md.HisFrmType == FrmType.Column4Frm) { this.UCEn1.BindCCForm(dtlEn, this.FK_MapData, !this.IsEdit, 0, this.IsLoadData); } this.AddJSEvent(dtlEn); this.UCEn1.Add("</div>"); } else { /*如果没有找到,就可能是dtl。*/ if (md.HisFrmType == FrmType.Url || md.HisFrmType == FrmType.SLFrm) { string no = Request.QueryString["NO"]; string urlParas = "OID=" + this.OID + "&NO=" + no + "&WorkID=" + this.WorkID + "&FK_Node=" + this.FK_Node + "&IsEdit=" + this.IsEdit.ToString() + "&UserNo=" + WebUser.No + "&SID=" + this.SID; /*如果是URL.*/ if (md.Url.Contains("?") == true) { this.Response.Redirect(md.Url + "&" + urlParas, true); } else { this.Response.Redirect(md.Url + "?" + urlParas, true); } return; } if (md.HisFrmType == FrmType.WordFrm) { string no = Request.QueryString["NO"]; string urlParas = "OID=" + this.OID + "&NO=" + no + "&WorkID=" + this.WorkID + "&FK_Node=" + this.FK_Node + "&UserNo=" + WebUser.No + "&SID=" + this.SID + "&FK_MapData=" + this.FK_MapData + "&OIDPKVal=" + this.OIDPKVal + "&FID=" + this.FID + "&FK_Flow=" + this.FK_Flow; /*如果是URL.*/ string requestParas = this.RequestParas; string[] parasArrary = this.RequestParas.Split('&'); foreach (string str in parasArrary) { if (string.IsNullOrEmpty(str) || str.Contains("=") == false) { continue; } string[] kvs = str.Split('='); if (urlParas.Contains(kvs[0])) { continue; } urlParas += "&" + kvs[0] + "=" + kvs[1]; } if (md.Url.Contains("?") == true) { this.Response.Redirect("FrmWord.aspx?1=2" + "&" + urlParas, true); } else { this.Response.Redirect("FrmWord.aspx" + "?" + urlParas, true); } return; } if (md.HisFrmType == FrmType.ExcelFrm) { this.Response.Redirect("FrmExcel.aspx?1=2" + this.RequestParas, true); return; } GEEntity en = md.HisGEEn; #region 求出 who is pk 值. int pk = this.OID; string nodeid = this.FK_Node.ToString(); if (nodeid != "0" && string.IsNullOrEmpty(this.FK_Flow) == false) { /*说明是流程调用它, 就要判断谁是表单的PK.*/ FrmNode fn = new FrmNode(this.FK_Flow, this.FK_Node, this.FK_MapData); switch (fn.WhoIsPK) { case WhoIsPK.FID: pk = this.FID; if (pk == 0) { throw new Exception("@没有接收到参数FID"); } break; case WhoIsPK.CWorkID: /*延续流程ID*/ pk = this.CWorkID; if (pk == 0) { throw new Exception("@没有接收到参数CWorkID"); } break; case WhoIsPK.PWorkID: /*父流程ID*/ pk = this.PWorkID; if (pk == 0) { throw new Exception("@没有接收到参数PWorkID"); } break; case WhoIsPK.OID: default: break; } } en.SetValByKey("OID", pk); #endregion 求出pk 值. if (en.EnMap.Attrs.Count <= 0) { md.RepairMap(); //让他刷新一下,重新进入. this.Response.Redirect(this.Request.RawUrl, true); return; } //检查实体数据是否存在,并重新设置默认值 if (en.RetrieveFromDBSources() == 0) { en.ResetDefaultValAllAttr(); try { en.DirectInsert(); } catch (Exception ex) { md.RepairMap(); en.CheckPhysicsTable(); throw new Exception("@装载出现错误:如果是第一次出现该错误,请刷新一次,系统有可能自动修复了。技术信息:" + ex.Message); } } string[] paras = this.RequestParas.Split('&'); foreach (string str in paras) { if (string.IsNullOrEmpty(str) || str.Contains("=") == false) { continue; } string[] kvs = str.Split('='); en.SetValByKey(kvs[0], kvs[1]); } if (en.ToString() == "0") { en.SetValByKey("OID", pk); } this.OIDPKVal = pk; #region 处理表单权限控制方案 Width = md.FrmW.ToString();//md.MaxRight + md.MaxLeft * 2 + 10 + ""; if (float.Parse(Width) < 500) { Width = "900"; } Height = md.MaxEnd > md.FrmH ? md.MaxEnd + "" : md.FrmH + ""; if (float.Parse(Height) <= 800) { Height = "800"; } this.UCEn1.Add("<div id=divCCForm style='width:" + Width + "px;height:" + Height + "px' >"); if (nodeid != null) { this.UCEn1.FK_Node = this.FK_Node; /*处理表单权限控制方案*/ this.HisFrmNode = new FrmNode(); int ii = this.HisFrmNode.Retrieve(FrmNodeAttr.FK_Frm, this.FK_MapData, FrmNodeAttr.FK_Node, int.Parse(nodeid)); if (ii == 0 || this.HisFrmNode.FrmSln == 0) { /*说明没有配置,或者方案编号为默认就不用处理,*/ this.UCEn1.BindCCForm(en, this.FK_MapData, !this.IsEdit, 0, this.IsLoadData); } else { FrmFields fls = new FrmFields(this.FK_MapData, this.HisFrmNode.FrmSln); //求出集合. MapAttrs mattrs = new MapAttrs(this.FK_MapData); foreach (FrmField item in fls) { foreach (MapAttr attr in mattrs) { if (attr.KeyOfEn != item.KeyOfEn) { continue; } if (item.IsSigan) { item.UIIsEnable = false; } if (attr.SignType == SignType.CA) { long workId = Convert.ToInt64(this.OID); FrmField keyOfEn = new FrmField(); QueryObject info = new QueryObject(keyOfEn); info.AddWhere(FrmFieldAttr.FK_Node, this.FK_Node); info.addAnd(); info.AddWhere(FrmFieldAttr.FK_MapData, attr.FK_MapData); info.addAnd(); info.AddWhere(FrmFieldAttr.KeyOfEn, attr.KeyOfEn); info.addAnd(); info.AddWhere(MapAttrAttr.UIIsEnable, "1"); if (info.DoQuery() > 0) { sealName = en.GetValStrByKey(attr.KeyOfEn); } } attr.UIIsEnable = item.UIIsEnable; attr.UIVisible = item.UIVisible; attr.IsSigan = item.IsSigan; attr.DefValReal = item.DefVal; } } #region 设置默认值. if (this.IsEdit == true) { bool isHave = false; foreach (MapAttr attr in mattrs) { //if (attr.UIIsEnable) // continue; if (attr.DefValReal.Contains("@") == false) { continue; } en.SetValByKey(attr.KeyOfEn, attr.DefVal); isHave = true; } if (isHave) { en.DirectUpdate(); //让其直接更新. } } #endregion 设置默认值. //按照当前方案绑定表单. /* * 修改说明:如果是自定义方案,就不要装载填充了. */ ////是否要重新装载数据. bool isLoadData = this.IsLoadData; if (this.HisFrmNode.IsEnableLoadData == true) { /*如果允许启用.*/ } else { isLoadData = false; } this.UCEn1.BindCCForm(en, md, mattrs, this.FK_MapData, !this.IsEdit, Int64.Parse(Width), isLoadData); #region 检查必填项 string scriptCheckFrm = ""; scriptCheckFrm += "\t\n<script type='text/javascript' >"; scriptCheckFrm += "\t\n function CheckFrmSlnIsNull(){ "; scriptCheckFrm += "\t\n var isPass = true;"; scriptCheckFrm += "\t\n var alloweSave = true;"; scriptCheckFrm += "\t\n var erroMsg = '提示信息:';"; //表单权限设置为必填项 //查询出来,需要不为空的 Paras ps = new Paras(); ps.SQL = "SELECT KeyOfEn, Name FROM Sys_FrmSln WHERE FK_MapData=" + ps.DBStr + "FK_MapData AND FK_Node=" + ps.DBStr + "FK_Node AND IsNotNull=" + ps.DBStr + "IsNotNull"; ps.Add(FrmFieldAttr.FK_MapData, this.FK_MapData); ps.Add(FrmFieldAttr.FK_Node, this.FK_Node); ps.Add(FrmFieldAttr.IsNotNull, 1); //查询 System.Data.DataTable dtKeys = DBAccess.RunSQLReturnTable(ps); // 检查数据是否完整. foreach (System.Data.DataRow dr in dtKeys.Rows) { string key = dr[0].ToString(); string name = dr[1].ToString(); BP.Web.Controls.TB TB_NotNull = this.UCEn1.GetTBByID("TB_" + key); if (TB_NotNull != null) { scriptCheckFrm += "\t\n try{ "; scriptCheckFrm += "\t\n var element = document.getElementById('" + TB_NotNull.ClientID + "');"; //验证输入的正则格式 scriptCheckFrm += "\t\n if(element && element.readOnly == true) return;"; scriptCheckFrm += "\t\n isPass = EleSubmitCheck(element,'.{1}','" + name + ",不能为空。');"; scriptCheckFrm += "\t\n if(isPass == false){"; scriptCheckFrm += "\t\n alloweSave = false;"; scriptCheckFrm += "\t\n erroMsg += '" + name + ",不能为空。';"; scriptCheckFrm += "\t\n }"; scriptCheckFrm += "\t\n } catch(e) { "; scriptCheckFrm += "\t\n alert(e.name + e.message); return false;"; scriptCheckFrm += "\t\n } "; } } scriptCheckFrm += "\t\n return alloweSave; } "; scriptCheckFrm += "\t\n</script>"; #endregion //检查必填项 this.UCEn1.Add(scriptCheckFrm); } } else { this.UCEn1.BindCCForm(en, this.FK_MapData, !this.IsEdit, 0, this.IsLoadData); } this.UCEn1.Add("</div>"); #endregion if (!IsPostBack) { if (md.IsHaveCA) { #region 检查是否有ca签名. //if (md.IsHaveCA == true) //{ // if (string.IsNullOrEmpty(sealName)) // sealName = WebUser.No; // string basePath = Server.MapPath("~/DataUser/Siganture/" + WorkID); // if (!System.IO.Directory.Exists(basePath)) // { // System.IO.Directory.CreateDirectory(basePath); // } // // basePath = "C:\\"; // this.TB_SealFile.Text = basePath + "\\" + sealName + ".jpg"; // #region 获取存储的 签名信息 // BP.Tools.WFSealData sealData = new BP.Tools.WFSealData(); // sealData.RetrieveByAttrAnd(BP.Tools.WFSealDataAttr.OID, WorkID, BP.Tools.WFSealDataAttr.FK_Node, FK_Node); // //sealData.RetrieveFromDBSources(); // if (!string.IsNullOrEmpty(sealData.SealData)) // { // this.TB_SealData.Text = sealData.SealData; // } // #endregion // //this.TB_SealData.Text = en.GetValStringByKey("SealData"); //} #endregion 检查是否有ca签名. } } this.AddJSEvent(en); } Session["Count"] = null; this.Btn_Save.Visible = this.HisFrmNode.IsEdit; this.Btn_Save.Enabled = this.HisFrmNode.IsEdit; this.Btn_Save.BackColor = System.Drawing.Color.White; Node curNd = new Node(); curNd.NodeID = this.FK_Node; curNd.RetrieveFromDBSources(); if (curNd.FormType == NodeFormType.SheetTree) { this.Btn_Save.Visible = true; this.Btn_Save.Enabled = true; this.Btn_Print.Enabled = false; this.Btn_Print.Visible = false; } else { this.Btn_Print.Visible = this.HisFrmNode.IsPrint; this.Btn_Print.Enabled = this.HisFrmNode.IsPrint; this.Btn_Print.Attributes["onclick"] = "window.open('Print.aspx?FK_Node=" + this.FK_Node + "&FID=" + this.FID + "&FK_MapData=" + this.FK_MapData + "&WorkID=" + this.OID + "', '', 'dialogHeight: 350px; dialogWidth:450px; center: yes; help: no'); return false;"; } }
protected void Btn_Save_Click(object sender, EventArgs e) { try { MapData md = new MapData(this.FK_MapData); //判断与节点编号相同,并且是节点表单类型才可以保存 if (this.FK_MapData.Replace("ND", "") == this.FK_Node.ToString() && md.AppType == "1") { this.SaveNode(); return; } GEEntity en = md.HisGEEn; en.SetValByKey("OID", this.OIDPKVal); int i = en.RetrieveFromDBSources(); en = this.UCEn1.Copy(en) as GEEntity; FrmEvents fes = md.FrmEvents; //new FrmEvents(this.FK_MapData); fes.DoEventNode(FrmEventList.SaveBefore, en); //#region 检查是否有ca签名. //if (md.IsHaveCA == true) //{ // if (!string.IsNullOrEmpty(this.TB_SealData.Text)) // { // BP.Tools.WFSealData sealData = new BP.Tools.WFSealData(); // sealData.RetrieveByAttrAnd(BP.Tools.WFSealDataAttr.OID, WorkID, BP.Tools.WFSealDataAttr.FK_Node, FK_Node); // if (string.IsNullOrEmpty(sealData.OID)) // { // sealData.MyPK = DBAccess.GenerGUID(); // sealData.OID = WorkID; // sealData.FK_Node = FK_Node.ToString(); // sealData.SealData = this.TB_SealData.Text; // sealData.RDT = DataType.CurrentDataTime; // sealData.FK_MapData = this.FK_MapData; // sealData.Insert(); // } // else // { // sealData.SealData = this.TB_SealData.Text; // sealData.RDT = DataType.CurrentDataTime; // sealData.Update(); // } // byte[] data = System.Convert.FromBase64String(TB_SingData.Text); // if (data.Length != 0) // { // System.IO.MemoryStream MS = new System.IO.MemoryStream(data); // System.Drawing.Bitmap image = new System.Drawing.Bitmap(MS); // image.Save(TB_SealFile.Text, System.Drawing.Imaging.ImageFormat.Jpeg); // } // } //} //#endregion 检查是否有ca签名. if (i == 0) { en.Insert(); } else { en.Update(); } fes.DoEventNode(FrmEventList.SaveAfter, en); //this.Response.Redirect("Frm.aspx?OID=" + en.GetValStringByKey("OID") + "&FK_Node=" + this.FK_Node + "&FID=" + this.FID + "&FK_MapData=" + this.FK_MapData, true); } catch (Exception ex) { this.UCEn1.AddMsgOfWarning("error:", ex.Message); } }
public string NewFrmGuide_Create() { MapData md = new MapData(); md.Name = this.GetRequestVal("TB_Name"); md.No = DataType.ParseStringForNo(this.GetRequestVal("TB_No"), 100); md.HisFrmTypeInt = this.GetRequestValInt("DDL_FrmType"); //表单的物理表. if (md.HisFrmType == BP.Sys.FrmType.Url || md.HisFrmType == BP.Sys.FrmType.Entity) { md.PTable = this.GetRequestVal("TB_PTable"); } else { md.PTable = DataType.ParseStringForNo(this.GetRequestVal("TB_PTable"), 100); } //数据表模式。 @周朋 需要翻译. md.PTableModel = this.GetRequestValInt("DDL_PTableModel"); //@李国文 需要对比翻译. string sort = this.GetRequestVal("FK_FrmSort"); if (DataType.IsNullOrEmpty(sort) == true) { sort = this.GetRequestVal("DDL_FrmTree"); } md.FK_FrmSort = sort; md.FK_FormTree = sort; md.AppType = "0";//独立表单 md.DBSrc = this.GetRequestVal("DDL_DBSrc"); if (md.IsExits == true) { return("err@表单ID:" + md.No + "已经存在."); } switch (md.HisFrmType) { //自由,傻瓜,SL表单不做判断 case BP.Sys.FrmType.FreeFrm: case BP.Sys.FrmType.FoolForm: break; case BP.Sys.FrmType.Url: case BP.Sys.FrmType.Entity: md.Url = md.PTable; break; //如果是以下情况,导入模式 case BP.Sys.FrmType.WordFrm: case BP.Sys.FrmType.ExcelFrm: break; default: throw new Exception("未知表单类型."); } md.Insert(); //增加上OID字段. BP.Sys.CCFormAPI.RepareCCForm(md.No); BP.Frm.EntityType entityType = (EntityType)this.GetRequestValInt("EntityType"); #region 如果是单据. if (entityType == EntityType.FrmBill) { BP.Frm.FrmBill bill = new FrmBill(md.No); bill.EntityType = EntityType.FrmBill; bill.BillNoFormat = "ccbpm{yyyy}-{MM}-{dd}-{LSH4}"; //设置默认的查询条件. bill.SetPara("IsSearchKey", 1); bill.SetPara("DTSearchWay", 0); bill.Update(); bill.CheckEnityTypeAttrsFor_Bill(); } #endregion 如果是单据. #region 如果是实体 EnityNoName . if (entityType == EntityType.FrmDict) { BP.Frm.FrmDict entityDict = new FrmDict(md.No); entityDict.BillNoFormat = "3"; //编码格式.001,002,003. entityDict.BtnNewModel = 0; //设置默认的查询条件. entityDict.SetPara("IsSearchKey", 1); entityDict.SetPara("DTSearchWay", 0); entityDict.EntityType = EntityType.FrmDict; entityDict.Update(); entityDict.CheckEnityTypeAttrsFor_EntityNoName(); } #endregion 如果是实体 EnityNoName . //创建表与字段. GEEntity en = new GEEntity(md.No); en.CheckPhysicsTable(); if (md.HisFrmType == BP.Sys.FrmType.WordFrm || md.HisFrmType == BP.Sys.FrmType.ExcelFrm) { /*把表单模版存储到数据库里 */ return("url@../../Comm/RefFunc/En.htm?EnName=BP.WF.Template.MapFrmExcel&PKVal=" + md.No); } if (md.HisFrmType == BP.Sys.FrmType.Entity) { return("url@../../Comm/Ens.htm?EnsName=" + md.PTable); } if (md.HisFrmType == BP.Sys.FrmType.FreeFrm) { return("[email protected]?FK_MapData=" + md.No); } return("url@../FoolFormDesigner/Designer.htm?IsFirst=1&FK_MapData=" + md.No); }
public void PrintBill() { BP.WF.Node nd = new BP.WF.Node(this.FK_Node); string path = ApplicationPath + "\\DataUser\\CyclostyleFile\\FlowFrm\\" + nd.FK_Flow + "\\" + nd.NodeID + "\\"; if (System.IO.Directory.Exists(path) == false) { this.Pub1.AddMsgOfWarning("获取模版错误", "模版文件没有找到。" + path); return; } string[] fls = System.IO.Directory.GetFiles(path); string file = fls[int.Parse(this.BillIdx)]; file = file.Replace(ApplicationPath + @"DataUser\CyclostyleFile", ""); FileInfo finfo = new FileInfo(file); string tempName = finfo.Name.Split('.')[0]; string tempNameChinese = finfo.Name.Split('.')[1]; string toPath = ApplicationPath + @"DataUser\Bill\FlowFrm\" + DateTime.Now.ToString("yyyyMMdd") + "\\"; if (System.IO.Directory.Exists(toPath) == false) { System.IO.Directory.CreateDirectory(toPath); } // string billFile = toPath + "\\" + tempName + "." + this.FID + ".doc"; string billFile = toPath + "\\" + Server.UrlDecode(tempNameChinese) + "." + this.WorkID + ".doc"; BP.Pub.RTFEngine engine = new BP.Pub.RTFEngine(); if (tempName.ToLower() == "all") { /* 说明要从所有的流程表单上取数据.*/ FrmNodes fns = new FrmNodes(this.FK_Flow, this.FK_Node); foreach (FrmNode fn in fns) { GEEntity ge = new GEEntity(fn.FK_Frm, this.WorkID); engine.AddEn(ge); MapDtls mdtls = new MapDtls(fn.FK_Frm); foreach (MapDtl dtl in mdtls) { GEDtls enDtls = dtl.HisGEDtl.GetNewEntities as GEDtls; enDtls.Retrieve(GEDtlAttr.RefPK, this.WorkID); engine.EnsDataDtls.Add(enDtls); } } // 增加主表. GEEntity myge = new GEEntity("ND" + nd.NodeID, this.WorkID); engine.AddEn(myge); MapDtls mymdtls = new MapDtls("ND" + nd.NodeID); foreach (MapDtl dtl in mymdtls) { GEDtls enDtls = dtl.HisGEDtl.GetNewEntities as GEDtls; enDtls.Retrieve(GEDtlAttr.RefPK, this.WorkID); engine.EnsDataDtls.Add(enDtls); } // engine.MakeDoc(file, toPath, tempName + "." + this.WorkID + ".doc", null, false); engine.MakeDoc(file, toPath, Server.UrlDecode(tempNameChinese) + "." + this.WorkID + ".doc", null, false); } else { // 增加主表. GEEntity myge = new GEEntity(tempName, this.WorkID); engine.HisGEEntity = myge; engine.AddEn(myge); MapDtls mymdtls = new MapDtls(tempName); foreach (MapDtl dtl in mymdtls) { GEDtls enDtls = dtl.HisGEDtl.GetNewEntities as GEDtls; enDtls.Retrieve(GEDtlAttr.RefPK, this.WorkID); engine.EnsDataDtls.Add(enDtls); } //engine.MakeDoc(file, toPath, tempName + "." + this.FID + ".doc", null, false); engine.MakeDoc(file, toPath, Server.UrlDecode(tempNameChinese) + "." + this.WorkID + ".doc", null, false); } #region 保存单据,以方便查询. Bill bill = new Bill(); bill.MyPK = this.FID + "_" + this.WorkID + "_" + this.FK_Node + "_" + this.BillIdx; bill.WorkID = this.WorkID; bill.FK_Node = this.FK_Node; bill.FK_Dept = WebUser.FK_Dept; bill.FK_Emp = WebUser.No; bill.Url = "/DataUser/Bill/FlowFrm/" + DateTime.Now.ToString("yyyyMMdd") + "/" + Server.UrlDecode(tempNameChinese) + "." + this.WorkID + ".doc"; bill.FullPath = toPath + file; bill.RDT = DataType.CurrentDataTime; bill.FK_NY = DataType.CurrentYearMonth; bill.FK_Flow = this.FK_Flow; if (this.WorkID != 0) { GenerWorkFlow gwf = new GenerWorkFlow(); gwf.WorkID = this.WorkID; if (gwf.RetrieveFromDBSources() == 1) { bill.Emps = gwf.Emps; bill.FK_Starter = gwf.Starter; bill.StartDT = gwf.RDT; bill.Title = gwf.Title; bill.FK_Dept = gwf.FK_Dept; } } try { bill.Insert(); } catch { bill.Update(); } #endregion BP.Sys.PubClass.OpenWordDocV2(billFile, tempNameChinese + ".doc"); }
//多附件上传方法 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 保存到数据库. } }
protected void Page_Load(object sender, EventArgs e) { Flow fl = new Flow(this.FK_Flow); this.Page.Title = fl.Name; GEEntitys rpts = (GEEntitys)BP.DA.ClassFactory.GetEns(this.EnsName); GEEntity rpt = (GEEntity)rpts.GetNewEntity; QueryObject qo = new QueryObject(rpts); try { qo.AddWhere(GERptAttr.FlowEmps, " LIKE ", "'%@" + WebUser.No + "%'"); qo.addAnd(); qo.AddWhere("" + BP.SystemConfig.AppCenterDBSubstringStr + "(RDT,1,10) >='" + this.DT_F + "' AND " + BP.SystemConfig.AppCenterDBSubstringStr + "(RDT,1,10) <='" + this.DT_T + "' "); this.Pub2.BindPageIdx(qo.GetCount(), this.PageSize, this.PageIdx, "FlowSearchMyWork.aspx?EnsName=" + this.EnsName + "&FK_Flow=" + this.FK_Flow); qo.DoQuery("OID", this.PageSize, this.PageIdx); } catch (Exception ex) { if (this.Request.QueryString["error"] == null) { fl.CheckRpt(); this.Response.Redirect(this.Request.RawUrl + "&error=1", true); return; } throw ex; } // this.Response.Write(qo.SQL); // 生成页面数据。 Attrs attrs = BP.WF.Glo.AttrsOfRpt; // rpt.EnMap.Attrs; int colspan = 2; foreach (Attr attr in attrs) { if (attr.UIVisible == false) { continue; } colspan++; } this.Pub1.AddTable("width='100%' align=left "); this.Pub1.AddCaptionLeft("流程查询:" + fl.Name); this.Pub1.AddTRSum(); this.Pub1.Add("<TD colspan=" + colspan + " class=ToolBar><b>发生日期 从:</b>"); TextBox tb = new TextBox(); tb.ID = "TB_F"; tb.Columns = 10; tb.Text = this.DT_F; tb.Attributes["onfocus"] = "WdatePicker();"; this.Pub1.Add(tb); this.Pub1.AddB(" 到:"); tb = new TextBox(); tb.ID = "TB_T"; tb.Text = this.DT_T; tb.Columns = 10; this.Pub1.Add(tb); this.Pub1.AddB(" "); Button btn = new Button(); btn.Text = "查询"; btn.CssClass = "Btn"; btn.ID = "Btn_Search"; btn.Click += new EventHandler(btn_Click); tb.Attributes["onfocus"] = "WdatePicker();"; this.Pub1.Add(btn); btn = new Button(); btn.Text = "导出Excel"; btn.CssClass = "Btn"; btn.ID = "Btn_Excel"; btn.Click += new EventHandler(btn_Click); this.Pub1.Add(btn); this.Pub1.Add(" </TD>"); this.Pub1.AddTREnd(); this.Pub1.AddTR(); this.Pub1.AddTDTitle("序"); foreach (Attr attr in attrs) { if (attr.UIVisible == false) { continue; } this.Pub1.AddTDTitle("nowarp=true", attr.Desc); } this.Pub1.AddTDTitle("nowarp=true", "操作"); this.Pub1.AddTREnd(); int idx = 0; bool is1 = false; foreach (GEEntity en in rpts) { idx++; is1 = this.Pub1.AddTR(is1); this.Pub1.AddTD(idx); foreach (Attr attr in attrs) { if (attr.UIVisible == false) { continue; } if (attr.Key == "Title") { this.Pub1.AddTD("<a href=\"./../WF/WFRpt.aspx?WorkID=" + en.GetValIntByKey("OID") + "&FID=" + en.GetValByKey("FID") + "&FK_Flow=" + this.FK_Flow + "\" target=bk >" + en.GetValStrByKey(attr.Key) + "</a>"); continue; } if (attr.Key == "WFState") { switch (en.GetValIntByKey(attr.Key)) { case 0: this.Pub1.AddTD("进行中"); break; case 1: this.Pub1.AddTD("完成"); break; } continue; } switch (attr.MyDataType) { case DataType.AppBoolean: this.Pub1.AddTD(en.GetValBoolStrByKey(attr.Key)); break; case DataType.AppFloat: case DataType.AppDouble: this.Pub1.AddTD(en.GetValFloatByKey(attr.Key)); break; case DataType.AppInt: if (attr.UIContralType == UIContralType.DDL) { this.Pub1.AddTD(en.GetValRefTextByKey(attr.Key)); } else { this.Pub1.AddTD(en.GetValIntByKey(attr.Key)); } break; case DataType.AppMoney: this.Pub1.AddTDMoney(en.GetValDecimalByKey(attr.Key)); break; default: this.Pub1.AddTD(en.GetValStringByKey(attr.Key)); break; } } this.Pub1.AddTD("<a href=\"./../WF/WFRpt.aspx?WorkID=" + en.GetValIntByKey("OID") + "&FID=" + en.GetValByKey("FID") + "&FK_Flow=" + this.FK_Flow + "\" target=bk >报告</a>-<a href=\"./../WF/Chart.aspx?WorkID=" + en.GetValIntByKey("OID") + "&FID=" + en.GetValByKey("FID") + "&FK_Flow=" + this.FK_Flow + "\" target=bk >轨迹</a>"); this.Pub1.AddTREnd(); } this.Pub1.AddTRSum(); this.Pub1.AddTD(""); foreach (Attr attr in attrs) { if (attr.UIVisible == false) { continue; } this.Pub1.AddTD(); continue; } this.Pub1.AddTD(); this.Pub1.AddTREnd(); this.Pub1.AddTableEnd(); }
/// <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 PrintBill() { BP.WF.Node nd = new BP.WF.Node(this.FK_Node); string path = ApplicationPath + "\\DataUser\\CyclostyleFile\\FlowFrm\\" + nd.FK_Flow + "\\" + nd.NodeID + "\\"; if (System.IO.Directory.Exists(path) == false) { } string[] fls = System.IO.Directory.GetFiles(path); string file = fls[int.Parse(this.BillIdx)]; file = file.Replace(ApplicationPath + @"DataUser\CyclostyleFile", ""); FileInfo finfo = new FileInfo(file); string tempName = finfo.Name.Split('.')[0]; string tempNameChinese = finfo.Name.Split('.')[1]; string toPath = ApplicationPath + @"DataUser\Bill\FlowFrm\" + DateTime.Now.ToString("yyyyMMdd") + "\\"; if (System.IO.Directory.Exists(toPath) == false) { System.IO.Directory.CreateDirectory(toPath); } string billFile = toPath + "\\" + tempName + "." + this.FID + ".doc"; BP.Rpt.RTF.RTFEngine engine = new BP.Rpt.RTF.RTFEngine(); if (tempName.ToLower() == "all") { FrmNodes fns = new FrmNodes(this.FK_Node); foreach (FrmNode fn in fns) { GEEntity ge = new GEEntity(fn.FK_Frm, this.WorkID); engine.AddEn(ge); MapDtls mdtls = new MapDtls(tempName); foreach (MapDtl dtl in mdtls) { GEDtls enDtls = dtl.HisGEDtl.GetNewEntities as GEDtls; enDtls.Retrieve(GEDtlAttr.RefPK, this.WorkID); engine.EnsDataDtls.Add(enDtls); } } // 增加主表. GEEntity myge = new GEEntity("ND" + nd.NodeID, this.WorkID); engine.AddEn(myge); MapDtls mymdtls = new MapDtls("ND" + nd.NodeID); foreach (MapDtl dtl in mymdtls) { GEDtls enDtls = dtl.HisGEDtl.GetNewEntities as GEDtls; enDtls.Retrieve(GEDtlAttr.RefPK, this.WorkID); engine.EnsDataDtls.Add(enDtls); } engine.MakeDoc(file, toPath, tempName + "." + this.WorkID + ".doc", null, false); } else { // 增加主表. GEEntity myge = new GEEntity(tempName, this.FID); engine.HisGEEntity = myge; engine.AddEn(myge); MapDtls mymdtls = new MapDtls(tempName); foreach (MapDtl dtl in mymdtls) { GEDtls enDtls = dtl.HisGEDtl.GetNewEntities as GEDtls; enDtls.Retrieve(GEDtlAttr.RefPK, this.WorkID); engine.EnsDataDtls.Add(enDtls); } engine.MakeDoc(file, toPath, tempName + "." + this.FID + ".doc", null, false); } BP.PubClass.OpenWordDocV2(billFile, tempNameChinese + ".doc"); }
/// <summary> /// 执行SQL /// </summary> /// <returns></returns> public string DoMethodPara_ExeSQL() { MethodFunc func = new MethodFunc(this.MyPK); string doc = func.MethodDoc_SQL; GEEntity en = new GEEntity(func.FrmID, this.WorkID); doc = BP.WF.Glo.DealExp(doc, en, null); //替换里面的内容. #region 替换参数变量. MapAttrs attrs = new MapAttrs(); attrs.Retrieve(MapAttrAttr.FK_MapData, this.MyPK); foreach (MapAttr item in attrs) { if (item.UIContralType == UIContralType.TB) { doc = doc.Replace("@" + item.KeyOfEn, this.GetRequestVal("TB_" + item.KeyOfEn)); continue; } if (item.UIContralType == UIContralType.DDL) { doc = doc.Replace("@" + item.KeyOfEn, this.GetRequestVal("DDL_" + item.KeyOfEn)); continue; } if (item.UIContralType == UIContralType.CheckBok) { doc = doc.Replace("@" + item.KeyOfEn, this.GetRequestVal("CB_" + item.KeyOfEn)); continue; } if (item.UIContralType == UIContralType.RadioBtn) { doc = doc.Replace("@" + item.KeyOfEn, this.GetRequestVal("RB_" + item.KeyOfEn)); continue; } } #endregion 替换参数变量. #region 开始执行SQLs. try { DBAccess.RunSQLs(doc); if (func.MsgSuccess.Equals("")) { func.MsgSuccess = "执行成功."; } return(func.MsgSuccess); } catch (Exception ex) { if (func.MsgErr.Equals("")) { func.MsgErr = "执行失败."; } return("err@" + func.MsgErr + " @ " + ex.Message); } #endregion 开始执行SQLs. return("err@" + func.MethodDocTypeOfFunc + ",执行的类型没有解析."); }