protected override bool ActionGenuine(out string errorInfo) { string itemName = GetInitParamValue(PN_ItemName) as string; bool initVal = Convert.ToBoolean(GetInitParamValue(PN_InitValue)); IJFDataPool sysPool = JFHubCenter.Instance.DataPool; if (sysPool.ContainItem(PN_ItemName)) { if (sysPool.GetItemType(itemName) == typeof(bool)) { errorInfo = "Sucess"; return(true); } else { errorInfo = "系统数据池已存在数据项:\"" + itemName + "\",类型:" + sysPool.GetItemType(itemName).Name; return(false); } } if (!sysPool.RegistItem(PN_ItemName, typeof(bool), initVal)) { errorInfo = "注册bool数据项失败!"; return(false); } errorInfo = "Success"; return(true); }
public override JFParamDescribe GetInitParamDescribe(string name) { if (name == PN_SysPoolItemName) { IJFDataPool sysDataPool = JFHubCenter.Instance.DataPool; List <string> boolItemNames = new List <string>(); string[] allItemNames = sysDataPool.AllItemKeys; if (null != allItemNames) { foreach (string itName in allItemNames) { if (sysDataPool.GetItemType(itName) == typeof(bool)) { boolItemNames.Add(itName); } } } return(JFParamDescribe.Create(PN_SysPoolItemName, typeof(string), JFValueLimit.Options, boolItemNames.ToArray())); } return(base.GetInitParamDescribe(name)); }
/// <summary> /// 将数据池项更新到界面上 /// </summary> void AdjustPoolItem() { if (InvokeRequired) { Invoke(new Action(AdjustPoolItem)); return; } bool isTimerFlushEnabled = timerFlush.Enabled; timerFlush.Enabled = false; chkAutoUpdate.Checked = false; panelSingleItems.Controls.Clear(); panelCollectionItems.Controls.Clear(); _lstUcSingleItems.Clear(); _lstChkSingleDisableUpdates.Clear(); _lstBtSingleWrites.Clear(); _lstUcCollectItems.Clear(); _lstChkCollectDisableUpdates.Clear(); _lstBtCollectWrites.Clear(); if (null == _dataPool) { lbInfo.Text = "数据池未设置"; btAdjust.Enabled = false; btRead.Enabled = false; btAdjust.Enabled = false; chkAutoUpdate.Enabled = false; return; } lbInfo.Text = ""; btAdjust.Enabled = true; btRead.Enabled = true; btAdjust.Enabled = true; chkAutoUpdate.Enabled = true; string[] singleItemNames = _dataPool.AllItemKeys; if (null != singleItemNames) { foreach (string itemName in singleItemNames) { Type t = _dataPool.GetItemType(itemName); object val; bool isOK = _dataPool.GetItemValue(itemName, out val); if (!isOK) //测试中才会用到 { MessageBox.Show("获取SingleItem值失败,ItemName = " + itemName); } UcJFParamEdit uc = new UcJFParamEdit(); uc.Height = 23; uc.IsHelpVisible = false; uc.SetParamDesribe(JFParamDescribe.Create(itemName, t, JFValueLimit.NonLimit, null)); uc.SetParamValue(val); CheckBox chkDisableUpdate = new CheckBox(); chkDisableUpdate.Text = "停更"; Button btSingleWrite = new Button(); btSingleWrite.Text = "写入"; btSingleWrite.Click += OnSingleItemWriteButtonClick; _lstUcSingleItems.Add(uc); _lstChkSingleDisableUpdates.Add(chkDisableUpdate); _lstBtSingleWrites.Add(btSingleWrite); panelSingleItems.Controls.Add(uc); panelSingleItems.Controls.Add(chkDisableUpdate); panelSingleItems.Controls.Add(btSingleWrite); } TableLayoutRowStyleCollection styles = panelSingleItems.RowStyles; foreach (RowStyle style in styles) { // Set the row height to 20 pixels. style.SizeType = SizeType.Absolute; style.Height = 25; } } string[] collectItemNames = _dataPool.AllListKeys; if (null != collectItemNames) { foreach (string itemName in collectItemNames) { Type elementType = _dataPool.GetListElementType(itemName); Type lstType = typeof(List <>).MakeGenericType(elementType); //动态获取数组类型 /*List<object>*/ object itemVal = _dataPool.LockList(itemName); _dataPool.UnlockList(itemName); //var itemValRealy = JFConvertExt.ChangeType(itemVal, lstType); UcJFParamEdit uc = new UcJFParamEdit(); uc.Height = 50; uc.IsHelpVisible = false; uc.SetParamDesribe(JFParamDescribe.Create(itemName, lstType, JFValueLimit.NonLimit, null)); uc.SetParamValue(itemVal); uc.SetParamValue(null); CheckBox chkDisableUpdate = new CheckBox(); chkDisableUpdate.Text = "停更"; Button btCollectWrite = new Button(); btCollectWrite.Text = "写入"; btCollectWrite.Click += OnCollectItemWriteButtonClick; _lstUcCollectItems.Add(uc); _lstChkCollectDisableUpdates.Add(chkDisableUpdate); _lstBtCollectWrites.Add(btCollectWrite); panelCollectionItems.Controls.Add(uc); panelCollectionItems.Controls.Add(chkDisableUpdate); panelCollectionItems.Controls.Add(btCollectWrite); } TableLayoutRowStyleCollection styles = panelCollectionItems.RowStyles; foreach (RowStyle style in styles) { // Set the row height to 20 pixels. style.SizeType = SizeType.Absolute; style.Height = 55; } } chkAutoUpdate.Checked = false; if (isTimerFlushEnabled) { chkAutoUpdate.Checked = true; timerFlush.Enabled = true; } else { chkAutoUpdate.Checked = false; } }
protected override bool ActionGenuine(out string errorInfo) { if (null == _owner) { errorInfo = "Method's owner Flow is null"; //异常 return(false); } string locItemName = GetInitParamValue(PN_LocPoolItemName) as string; if (!_owner.DataPool.ContainsKey(locItemName)) { errorInfo = "动作流数据池中未包含数据项项名:\"" + locItemName + "\""; return(false); } string sysItemName = GetInitParamValue(PN_SysPoolItemName) as string; object locVal = _owner.DataPool[locItemName]; IJFDataPool sysDataPool = JFHubCenter.Instance.DataPool; if (!sysDataPool.ContainItem(sysItemName))//注册并写入新值 { if (!sysDataPool.RegistItem(sysItemName, _owner.TypePool[locItemName], locVal)) { errorInfo = string.Format("向系统数据池写入/注册 失败,SysItemName = {0},Type = {1},Value = {2}", sysItemName, _owner.TypePool[locItemName].Name, locVal.ToString()); return(false); } } else //覆盖写入 { if (!sysDataPool.SetItemValue(sysItemName, locVal)) { errorInfo = string.Format("向系统数据池写入 失败,SysItemName = {0},本地类型 = {1}, 系统类型:{2},Value = {3}", sysItemName, _owner.TypePool[locItemName].Name, sysDataPool.GetItemType(sysItemName).Name, locVal.ToString()); return(false); } } errorInfo = "Success"; return(true); }