Ejemplo n.º 1
0
 //设置默认COMMAND 和 ACTION
 private void setRangeDefault()
 {
     foreach (XRange range in ranges.Values)
     {
         if (range.cfg.CRUDP.Contains("R") && (range.getCommandByEvent(SysEvent.Btn_Search) == null || !range.getCommandByEvent(SysEvent.Btn_Search).ContainsKey(0)))
         {//当配置CRUDP中包含R 并且 SEARCH按钮未绑定事件 时,设置默认SEARCH COMMAND,并且绑定在 SEARCH按钮上
             CommandCfg cmdSearch = MakeDefaultCMD("Btn_Search", range.Name, "R");
             ActionCfg  actSearch = MakeDefaultAct(cmdSearch.CommandName, range.Name, "R", "SQL_Search");
             initCommand(cmdSearch);
             initAction(actSearch);
         }
         if (range.cfg.CRUDP.Contains("C") && range.getCommandByEvent(SysEvent.Btn_New) == null)
         {//当配置CRUDP中包含C 并且NEW按钮未绑定事件 时,设置默认INSERT COMMAND,并且绑定在 NEW 按钮上
             CommandCfg cmdInsert = MakeDefaultCMD("Btn_New", range.Name, "C");
             ActionCfg  actInsert = MakeDefaultAct(cmdInsert.CommandName, range.Name, "C", "SQL_Insert");
             initCommand(cmdInsert);
             initAction(actInsert);
         }
         if (range.cfg.CRUDP.Contains("U") && range.getCommandByEvent(SysEvent.Btn_Edit) == null)
         {//当配置CRUDP中包含U 并且EDIT按钮未绑定事件 时,设置默认UPDATE COMMAND,并且绑定在 EDIT 按钮上
             CommandCfg cmdUpdate = MakeDefaultCMD("Btn_Edit", range.Name, "U");
             ActionCfg  actUpdate = MakeDefaultAct(cmdUpdate.CommandName, range.Name, "U", "SQL_Update");
             initCommand(cmdUpdate);
             initAction(actUpdate);
         }
         if (range.cfg.CRUDP.Contains("D") && range.getCommandByEvent(SysEvent.Btn_Delete) == null)
         {//当配置CRUDP中包含D 并且DELETE按钮未绑定事件 时,设置默认DELETE COMMAND,并且绑定在 DELETE 按钮上
             CommandCfg cmdDelete = MakeDefaultCMD("Btn_Delete", range.Name, "D");
             ActionCfg  actDelete = MakeDefaultAct(cmdDelete.CommandName, range.Name, "D", "SQL_Delete");
             initCommand(cmdDelete);
             initAction(actDelete);
         }
     }
 }
Ejemplo n.º 2
0
 //初始化接口
 public virtual void init(ActionCfg cfg, XApp app)
 {
     this.cfg        = cfg;
     this.ActionName = cfg.ActionName;
     try
     {
         this.actionSeq = int.Parse(cfg.ActSeq);
     }
     catch
     {
         AlertUtil.Show("error", String.Format("Action {0} Seq设置异常,设置值为{1}", ActionName, cfg.ActSeq));
     }
     try
     {
         if (cfg.SRange.Length > 0)
         {
             sRange = app.getRangeByName(cfg.SRange);
         }
         if (cfg.DRange.Length > 0)
         {
             dRange = app.getRangeByName(cfg.DRange);
         }
     }
     catch (Exception)
     {
         MessageBox.Show("Action:" + ActionName + "的sRange、dRange配置错误!");
         return;
     }
 }
Ejemplo n.º 3
0
        //设置默认ACTION 配置
        private ActionCfg MakeDefaultAct(String cmdName, String rangename, String crudp, String actionType)
        {
            ActionCfg cfg = new ActionCfg();

            cfg.ActionName      = "dft_act_" + rangename + "_" + crudp;//默认为dfg_act_+RANGE名+_+C/R/U/D/P标志
            cfg.ActionDesc      = "";
            cfg.ActionStatement = "";
            cfg.ActionType      = actionType;
            cfg.ActSeq          = "1";//默认ACTION SEQ = 1
            cfg.CommandName     = cmdName;
            cfg.CRUDP           = crudp;
            cfg.DRange          = rangename;
            cfg.SRange          = rangename;
            return(cfg);
        }
Ejemplo n.º 4
0
        public static XAction MakeAction(ActionCfg cfg, XApp app)
        {
            XAction action   = null;
            String  nametype = cfg.ActionType;

            nametype = "XSheet.v2.Data.XSheetAction.Action" + nametype;
            //XNamedTable
            try
            {
                Type type = Type.GetType(nametype, true);
                action = (XAction)Activator.CreateInstance(type);
                action.init(cfg, app);
            }
            catch (Exception e)
            {
                Console.WriteLine(e.ToString());
                System.Windows.Forms.MessageBox.Show("Action类型不存在,设置的类型为:" + cfg.ActionType + "\n" + e.ToString());
            }
            return(action);
        }
Ejemplo n.º 5
0
        //根据ActionCfg初始化单个Action
        private void initAction(ActionCfg cfg)
        {
            XAction action = ActionFactory.MakeAction(cfg, this);

            if (action == null)
            {
                statu = SysStatu.Error;
                return;
            }
            XCommand cmd = getCommandByName(cfg.CommandName);

            try
            {
                action.cmd = cmd;
                cmd        = getCommandByName(cfg.CommandName);
                cmd.actions.Add(action.actionSeq, action);
            }
            catch (Exception)
            {
                MessageBox.Show("Action:" + action.ActionName + "与命令:" + cfg.CommandName + "绑定失败,请检查Action配置是否正确!");
                return;
            }
            this.actions.Add(action.ActionName, action);
        }