/// <summary> /// 执行if框 /// </summary> /// <param name="box"></param> /// <returns></returns> protected void DoIfFunction(ItemBox box, WriteStreamCallBack wrs, IScriptLayout ml) { ScriptInput si = new ScriptInput(); foreach (var item in box.InputDatas) { if (item.PIEnum != ParaItemEnum.INPUT) { si.SetValue(item.Name, GetValue(item as ParatItem)); } } //检测是否需要断点停止 checkScriptRunForStopPoint(box, si, null); if (Convert.ToBoolean(si.GetFirst())) { RunningFunction((box as ItemBox).Children[0], wrs, ml); } else { RunningFunction((box as ItemBox).Children[1], wrs, ml); } si.Dispose(); si = null; }
/// <summary> /// 设置值 /// </summary> /// <param name="ib"></param> /// <param name="sm"></param> /// <returns></returns> protected static IItemBox DoFunction(ItemBox itembox, ScriptObjectManager sm, WriteStreamCallBack wrs) { LineItemBox ib = itembox as LineItemBox; if (ib.BoxType == ItemBoxEnum.IF) { ScriptInput si = new ScriptInput(); //si.WriteStream += wrs; foreach (var item in ib.InputDatas) { if (item.PIEnum != ParaItemEnum.OUTPUT && item.PIEnum != ParaItemEnum.INPUT && item.PIEnum != ParaItemEnum.NULL) { si.SetValue(item.Name, getValue(item as ParatItem, sm)); } } if (Convert.ToBoolean(si.GetFirst())) { return(ib.Next(0)); } else { return(ib.Next(1)); } } else if (ib.BoxType == ItemBoxEnum.SET) { ScriptOutput so = new ScriptOutput(); so.SetValue(ib.InputDatas[1].Name, getValue(ib.InputDatas[1] as ParatItem, sm)); //so.SetValue(ib.InputDatas[1].Name, ib.InputDatas[1].Value); sm.SetValue(ib.Id, so); return(ib.Next(0)); } else { ScriptInput si = new ScriptInput(); si.WriteStream += wrs; foreach (var item in ib.InputDatas) { if (item.PIEnum != ParaItemEnum.OUTPUT && item.PIEnum != ParaItemEnum.INPUT && item.PIEnum != ParaItemEnum.NULL) { si.SetValue(item.Name, getValue(item as ParatItem, sm)); } } ScriptOutput so = (ib as ItemBox).DoScriptFunction(si); if (so != null) { sm.SetValue(ib.Id, so); } return(ib.Next(0)); } }
/// <summary> /// 做循环 /// </summary> /// <param name="box"></param> /// <returns></returns> protected void DoWhileFunction(ItemBox box, WriteStreamCallBack wrs, IScriptLayout ml) { ItemBox sbox = box as ItemBox; if (box.InputDatas.Count == 1) { if (box.InputDatas[0].PIEnum == ParaItemEnum.BOOL) { ScriptInput si = GetFunctionInput(box); //检测是否需要断点停止 checkScriptRunForStopPoint(box, si, null); while (true) { if (Convert.ToBoolean(si.GetFirst())) { RunningFunction(box, wrs, ml); } else { return; } si.Dispose(); si = null; si = GetFunctionInput(box); } } else if (box.InputDatas[0].PIEnum == ParaItemEnum.DATETIME) { ScriptInput si = GetFunctionInput(box); //检测是否需要断点停止 checkScriptRunForStopPoint(box, si, null); while (true) { if (Convert.ToDateTime(si.GetFirst()) > DateTime.Now) { RunningFunction(box, wrs, ml); } else { return; } si.Dispose(); si = null; si = GetFunctionInput(box); } } } else { ScriptInput si = GetFunctionInput(box); while (true) { int idxs = Convert.ToInt32(si.GetFirst()); int idxe = Convert.ToInt32(si.GetSecond()); int boxidx = GetWhileBoxIdx(sbox, idxs); //if (box.IsHasBreakPoint) //{ // ScriptOutput so = new ScriptOutput(); // so.SetValue("Idx", boxidx); // ScriptBreakPoint?.Invoke(box, si, so); //} //检测是否需要断点停止 checkScriptRunForStopPoint(box, si, null); if (boxidx > idxe) { return; } else { RunningFunction(box, wrs, ml); } si.Dispose(); si = null; si = GetFunctionInput(box); } } }
public static ScriptOutput DelyTime(ScriptInput idx) { Thread.Sleep(Convert.ToInt32(idx.GetFirst())); return(null); }