示例#1
0
        private void lvEvent_SelectedIndexChanged(object sender, EventArgs e)
        {
            try
            {
                //if (_isLoading) return;
                if (lvEvent.SelectedItems.Count <= 0)
                {
                    return;
                }

                listEventActions.Items.Clear();

                string eventName = lvEvent.SelectedItems[0].Text;

                if (_events.ContainsKey(eventName) == false)
                {
                    return;
                }

                EventActionReleation ea = _events[eventName];
                if (ea == null)
                {
                    return;
                }

                foreach (KeyValuePair <string, ActionItem> act in ea.Actions)
                {
                    string exeModuleName = "当前窗体模块";
                    if (act.Value.IsParentModule)
                    {
                        exeModuleName = "父级窗体模块";
                    }

                    string dataModuleName = "当前窗体模块";
                    if (act.Value.IsParentModuleData)
                    {
                        dataModuleName = "父级窗体模块";
                    }

                    ListViewItem lvi = listEventActions.Items.Add(new ListViewItem(new string[] { act.Key.Split('.')[0], exeModuleName, act.Value.ActName,
                                                                                                  act.Value.RequestDataName, dataModuleName, act.Value.ActTag }, 0));

                    lvi.Tag = act.Value;
                }
            }
            catch (Exception ex)
            {
                MsgBox.ShowException(ex, this);
            }
        }
        protected bool DoBindActions(EventActionReleation ea, object sender, object eventArgs = null)
        {
            if (_relateBizModules.Count <= 0)
            {
                return(true);
            }

            string moduleName = "";
            string methodName = "";

            foreach (KeyValuePair <string, ActionItem> act in ea.Actions)
            {
                moduleName = act.Key.Split('.')[0];
                methodName = act.Key.Split('.')[1];

                ISysDesign exeModule = null;
                if (act.Value.IsParentModule)
                {
                    if (_relateBizModules.ParentWindowBizModules == null)
                    {
                        exeModule = null;
                    }
                    else
                    {
                        if (_relateBizModules.ParentWindowBizModules.ContainsKey(moduleName))
                        {
                            exeModule = _relateBizModules.ParentWindowBizModules[moduleName];
                        }
                    }
                }
                else
                {
                    if (_relateBizModules.ContainsKey(moduleName))
                    {
                        exeModule = _relateBizModules[moduleName];
                    }
                }

                if (exeModule == null)
                {
                    if (MessageBox.Show("[" + moduleName + "] 未能加载,不能执行该模块方法, 是否继续后续执行?", "提示", MessageBoxButtons.YesNo) == DialogResult.No)
                    {
                        return(false);
                    }
                    else
                    {
                        continue;
                    }
                }

                ActionItem ai = act.Value;

                IBizDataItems bizDatas = null;
                if (string.IsNullOrEmpty(ai.RequestDataName) == false)
                {
                    bizDatas = GetDataItem(_moduleName, ai, ai.RequestDataName);
                    if (bizDatas == null)
                    {
                        return(false);
                    }

                    bizDatas.DataName = ai.RequestDataName;
                }

                //SetDataToAttach(bizDatas);

                if (bizDatas != null && ai.RequestAttachDataNames != null)
                {
                    foreach (string requestDataName in ai.RequestAttachDataNames)
                    {
                        IBizDataItems curRequestData = GetDataItem(_moduleName, ai, requestDataName);

                        curRequestData.DataName = requestDataName;

                        bizDatas.AttachDatas.Add(curRequestData);
                    }
                }


                //如果返回False则终止后续执行
                if (exeModule.ExecuteAction(_moduleName, this, sender, act.Value.ActName, act.Value.ActTag, bizDatas, eventArgs) == false)
                {
                    return(false);
                }
            }

            return(true);
        }