public override HotspotItems GetLookupItems(IHotspotContext context) { var solution = context.SessionContext.Solution; var currentDocument = context.ExpressionRange.Document; IProjectFile projectItem = solution.GetComponent <DocumentManager>().GetProjectFile(currentDocument); var path = projectItem.Location.FullPath; return(MacroUtil.SimpleEvaluateResult(path)); }
string GetDataByNameForMacro(string name) { try { //此处应该写具体的实现方法 return(MacroUtil.FillMarcValue(m_CurrentInpatient.NoOfFirstPage.ToString(), name, m_app.User.Id)); } catch (Exception ex) { throw ex; } }
/// <summary> /// 通过name获取对应宏的数据 /// </summary> /// <param name="name"></param> /// <returns></returns> public string GetDataByNameForMacro(string noofinpat, string name) { try { string marcValue = MacroUtil.FillMarcValue(noofinpat, name, m_App.User.Id); return(marcValue); } catch (Exception ex) { throw ex; } }
public void CanAddArgumentMacro() { var code = "sql v1{#hello<sql{#val<>}>}"; var rt = new SdmapCompiler(); rt.AddSourceCode(code); rt.AddMacro("hello", new[] { SdmapTypes.StringOrSql }, (context, ns, self, arguments) => { return(Result.Ok($"Hello " + MacroUtil.EvalToString(arguments[0], context, self).Value)); }); var result = rt.Emit("v1", "World"); Assert.Equal("Hello World", result); }
public override Result <TurnOnResult> TurnOn(OneCallContext ctx) { Enabled = true; int currentCount = ctx.Deps.Count; var result = MacroUtil.EvalToString(Emiter, ctx, ctx.Obj); bool hasMore = ctx.Deps.Count > currentCount; if (result.IsSuccess) { _finalSql = result.Value; } return(result.OnSuccess(s => new TurnOnResult { Sql = s, HasMore = hasMore })); }
/// <summary> /// Attempts to evaluate the given string, with an optional context override. /// </summary> public bool TryEvaluate(ref string ioString, MacroBank inContext = null) { int hash; if (MacroUtil.IsMacroKey(ref ioString, out hash)) { bool bSuccess; if (ioString == null) { ioString = m_Runtime.Evaluate(hash, Banks, inContext, out bSuccess); } else { ioString = m_Runtime.Evaluate(ioString, Banks, inContext, out bSuccess); } return(bSuccess); } return(true); }
// 数据保存前的处理工作 public virtual void BeforeSaveRecord(object sender, BeforeSaveRecordEventArgs e) { if (sender == null) { return; } int nRet = 0; string strError = ""; bool bChanged = false; // 对MARC记录进行处理 if (sender is MarcEditor) { // 编目批次号 string strBatchNo = this.GetFirstSubfield("998", "a"); if (string.IsNullOrEmpty(strBatchNo) == true) { string strValue = ""; // 检查本地 %catalog_batchno% 宏是否存在 // 从marceditor_macrotable.xml文件中解析宏 // return: // -1 error // 0 not found // 1 found nRet = MacroUtil.GetFromLocalMacroTable(PathUtil.MergePath(this.DetailForm.MainForm.UserDir, "marceditor_macrotable.xml"), "catalog_batchno", false, out strValue, out strError); if (nRet == -1) { e.ErrorInfo = strError; return; } if (nRet == 1 && string.IsNullOrEmpty(strValue) == false) { this.SetFirstSubfield("998", "a", strValue); bChanged = true; } } // 记录创建时间 string strCreateTime = this.GetFirstSubfield("998", "u"); if (string.IsNullOrEmpty(strCreateTime) == true) { DateTime now = DateTime.Now; strCreateTime = now.ToString("u"); this.SetFirstSubfield("998", "u", strCreateTime); bChanged = true; } // 记录创建者 string strCreator = this.GetFirstSubfield("998", "z"); if (string.IsNullOrEmpty(strCreator) == true) { strCreator = this.DetailForm.CurrentUserName; if (string.IsNullOrEmpty(strCreator) == true) { strCreator = e.CurrentUserName; } this.SetFirstSubfield("998", "z", strCreator); bChanged = true; } e.Changed = bChanged; } }
public override HotspotItems GetLookupItems(IHotspotContext context) { return(MacroUtil.SimpleEvaluateResult(Evaluate(context))); }
public override HotspotItems GetLookupItems(IHotspotContext context) { return(MacroUtil.SimpleEvaluateResult(GetServiceName(_interfaceName))); }
public void ParseOneMacro(ParseOneMacroEventArgs e) { string strName = StringUtil.Unquote(e.Macro, "%%"); // 去掉百分号 // 函数名: string strFuncName = ""; string strParams = ""; int nRet = strName.IndexOf(":"); if (nRet == -1) { strFuncName = strName.Trim(); } else { strFuncName = strName.Substring(0, nRet).Trim(); strParams = strName.Substring(nRet + 1).Trim(); } if (strName == "username") { e.Value = this.CurrentUserName; return; } string strValue = ""; string strError = ""; // 从marceditor_macrotable.xml文件中解析宏 // return: // -1 error // 0 not found // 1 found nRet = MacroUtil.GetFromLocalMacroTable( Path.Combine(Program.MainForm.UserDir, "marceditor_macrotable.xml"), strName, e.Simulate, out strValue, out strError); if (nRet == -1) { e.Canceled = true; e.ErrorInfo = strError; return; } if (nRet == 1) { e.Value = strValue; return; } if (String.Compare(strFuncName, "IncSeed", true) == 0 || String.Compare(strFuncName, "IncSeed+", true) == 0 || String.Compare(strFuncName, "+IncSeed", true) == 0) { // 种次号库名, 指标名, 要填充到的位数 string[] aParam = strParams.Split(new char[] { ',' }); if (aParam.Length != 3 && aParam.Length != 2) { strError = "IncSeed需要2或3个参数。"; goto ERROR1; } bool IncAfter = false; // 是否为先取后加 if (strFuncName[strFuncName.Length - 1] == '+') { IncAfter = true; } string strZhongcihaoDbName = aParam[0].Trim(); string strEntryName = aParam[1].Trim(); strValue = ""; LibraryChannel channel = this.GetChannel(); try { long lRet = 0; if (e.Simulate == true) { // parameters: // strZhongcihaoGroupName @引导种次号库名 !引导线索书目库名 否则就是 种次号组名 lRet = channel.GetZhongcihaoTailNumber( null, strZhongcihaoDbName, strEntryName, out strValue, out strError); if (lRet == -1) { goto ERROR1; } if (string.IsNullOrEmpty(strValue) == true) { strValue = "1"; } } else { // parameters: // strZhongcihaoGroupName @引导种次号库名 !引导线索书目库名 否则就是 种次号组名 lRet = channel.SetZhongcihaoTailNumber( null, IncAfter == true ? "increase+" : "increase", strZhongcihaoDbName, strEntryName, "1", out strValue, out strError); if (lRet == -1) { goto ERROR1; } } } finally { this.ReturnChannel(channel); } // 补足左方'0' if (aParam.Length == 3) { int nWidth = 0; try { nWidth = Convert.ToInt32(aParam[2]); } catch { strError = "第三参数应当为纯数字(表示补足的宽度)"; goto ERROR1; } e.Value = strValue.PadLeft(nWidth, '0'); } else { e.Value = strValue; } return; } e.Canceled = true; // 不能解释处理 return; ERROR1: e.Canceled = true; e.ErrorInfo = strError; }
string GetDataByNameForMacro(string name) { //此处应该写具体的实现方法 return(MacroUtil.FillMarcValue(m_CurrentInpatient.NoOfFirstPage.ToString(), name, m_App.User.Id)); }
private void FillModelMacro(XmlDocument emrDoc, string deptChangeID) { try { #region 替换文档中的宏 //获得所有宏元素列表 XmlNodeList nodes = emrDoc.GetElementsByTagName("macro"); string deptName = string.Empty; string wardName = string.Empty; string bedID = string.Empty; if (!string.IsNullOrEmpty(deptChangeID)) { DataTable dtDeptInfo = GetDeptChangeInfo(deptChangeID); if (dtDeptInfo.Rows.Count > 0) { foreach (DataColumn dc in dtDeptInfo.Columns) { switch (dc.ColumnName.ToLower()) { case "deptname": deptName = dtDeptInfo.Rows[0]["deptname"].ToString(); break; case "wardname": wardName = dtDeptInfo.Rows[0]["wardname"].ToString(); break; case "bedid": bedID = dtDeptInfo.Rows[0]["bedid"].ToString(); break; } } } } //循环每个宏元素,根据宏元素的Name属性,查询并赋值线Text属性 foreach (XmlNode node in nodes) { if (node.Attributes["name"].Value.Trim() == "科室") { node.InnerText = deptName; continue; } if (node.Attributes["name"].Value.Trim() == "病区") { node.InnerText = wardName; continue; } if (node.Attributes["name"].Value.Trim() == "床号") { node.InnerText = bedID; continue; } //if (node.Attributes["name"].Value.Trim() == "科室" && node.InnerText.Trim() != "科室") // continue; //if (node.Attributes["name"].Value.Trim() == "病区" && node.InnerText.Trim() != "病区") // continue; //if (node.Attributes["name"].Value.Trim() == "床号" && node.InnerText.Trim() != "床号") // continue; //if (node.Attributes["name"].Value.Trim() == "住院号" && node.InnerText.Trim() != "住院号") // continue; //if (node.Attributes["name"].Value.Trim() == "医师签名" && node.InnerText.Trim() != "医师签名") // continue; //if (node.Attributes["name"].Value.Trim() == "当前日期" && node.InnerText.Trim() != "当前日期") // continue; //if (node.Attributes["name"].Value.Trim() == "当前时间" && node.InnerText.Trim() != "当前时间") // continue; node.InnerText = MacroUtil.FillMarcValue(m_Inpatient.NoOfFirstPage.ToString(), node.Attributes["name"].Value, m_Host.User.Id); } #endregion } catch (Exception ex) { throw ex; } }