示例#1
0
//JAVA TO C# CONVERTER WARNING: 'final' parameters are not available in .NET:
//ORIGINAL LINE: @Override public java.util.List<org.camunda.bpm.engine.runtime.ProcessInstance> execute(final org.camunda.bpm.engine.impl.interceptor.CommandContext commandContext)
        public virtual IList <ProcessInstance> execute(CommandContext commandContext)
        {
//JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final':
//ORIGINAL LINE: final org.camunda.bpm.engine.impl.runtime.ConditionHandler conditionHandler = commandContext.getProcessEngineConfiguration().getConditionHandler();
            ConditionHandler conditionHandler = commandContext.ProcessEngineConfiguration.ConditionHandler;
//JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final':
//ORIGINAL LINE: final org.camunda.bpm.engine.impl.runtime.ConditionSet conditionSet = new org.camunda.bpm.engine.impl.runtime.ConditionSet(builder);
            ConditionSet conditionSet = new ConditionSet(builder);

            IList <ConditionHandlerResult> results = conditionHandler.evaluateStartCondition(commandContext, conditionSet);

            foreach (ConditionHandlerResult ConditionHandlerResult in results)
            {
                checkAuthorization(commandContext, ConditionHandlerResult);
            }

            IList <ProcessInstance> processInstances = new List <ProcessInstance>();

            foreach (ConditionHandlerResult ConditionHandlerResult in results)
            {
                processInstances.Add(instantiateProcess(commandContext, ConditionHandlerResult));
            }

            return(processInstances);
        }
示例#2
0
 /// <summary>
 /// Create an instance of AccessLimitDecorator
 /// </summary>
 /// <param name="name">Name of behavior node</param>
 /// <param name="handler">user provided function to handle execution of Decorator</param>
 /// <param name="accessKey">Shared AccessKey</param>
 public AccessLimitDecorator(string name, ConditionHandler handler, AccessKey accessKey)
     : base(name, handler)
 {
     if (accessKey == null)
     {
         throw new ArgumentNullException("Accesskey is null.");
     }
     AccessKey = accessKey;
 }
 /// <summary>
 /// 获取数组中满足给定条件的第一个元素
 /// </summary>
 /// <typeparam name="T">数组类型</typeparam>
 /// <typeparam name="Ty">数组元素中的成员类型</typeparam>
 /// <param name="arr">被查找的数组</param>
 /// <param name="condHdl">返回数组元素中成员类型的方法的委托</param>
 /// <returns>返回符合条件的数组元素</returns>
 public static T Find <T>(T[] arr, ConditionHandler <T> condHdl)
 {
     foreach (var item in arr)
     {
         if (condHdl(item) == true)
         {
             return(item);
         }
     }
     return(default(T));
 }
    /// <summary>
    /// 获取数组中满足给定条件的所以元素
    /// </summary>
    /// <typeparam name="T">数组类型</typeparam>
    /// <typeparam name="Ty">数组元素中的成员类型</typeparam>
    /// <param name="arr">被查找的数组</param>
    /// <param name="condHdl">返回数组元素中成员类型的方法的委托</param>
    /// <returns>返回符合条件的一个List</returns>
    public static T[] FindAll <T>(T[] arr, ConditionHandler <T> condHdl)
    {
        List <T> resList = new List <T>();

        foreach (var item in arr)
        {
            if (condHdl(item) == true)
            {
                resList.Add(item);
            }
        }
        return(resList.ToArray());  //可变数组转换为固定数组
    }
示例#5
0
 /// <summary>
 /// Create a new UIItemSlot.
 /// </summary>
 /// <param name="position">position of slot in pixels</param>
 /// <param name="size">size of slot in pixels</param>
 /// <param name="context">context for slot</param>
 /// <param name="hoverText">hover text to show instead of context</param>
 /// <param name="parent">parent UIObject</param>
 /// <param name="conditions">checked before item is placed in slot; if null, all items are permitted</param>
 /// <param name="drawBackground">run when slot background is drawn; if null, slot is drawn with background texture</param>
 /// <param name="drawItem">run when item in slot is drawn; if null, item is drawn in center of slot</param>
 /// <param name="postDrawItem">run after item in slot is drawn; use to draw elements over the item</param>
 /// <param name="drawAsNormalSlot">draw as a normal inventory ItemSlot</param>
 /// <param name="scaleToInventory">whether to scale with the inventory</param>
 public UIItemSlot(Vector2 position, int size = 52, int context              = ItemSlot.Context.InventoryItem,
                   string hoverText           = "", UIObject parent          = null, ConditionHandler conditions = null,
                   DrawHandler drawBackground = null, DrawHandler drawItem   = null, DrawHandler postDrawItem = null,
                   bool drawAsNormalSlot      = false, bool scaleToInventory = false)
     : base(position, new Vector2(size), parent, false)
 {
     Item             = new Item();
     Context          = context;
     HoverText        = hoverText;
     Conditions       = conditions;
     DrawBackground   = drawBackground;
     DrawItem         = drawItem;
     PostDrawItem     = postDrawItem;
     DrawAsNormalSlot = drawAsNormalSlot;
     ScaleToInventory = scaleToInventory;
 }
示例#6
0
        public void TestMethod()
        {
            List <SourceLine> source    = new List <SourceLine>();
            List <SourceLine> processed = new List <SourceLine>();

            ConditionHandler condHandler = new ConditionHandler(_testController);

            source.Add(new SourceLine {
                Instruction = ".if", Operand = "3 < 4"
            });
            source.Add(new SourceLine {
                Instruction = "lda", Operand = "#$03"
            });
            source.Add(new SourceLine {
                Instruction = ".else"
            });
        }
        /// <summary>
        ///     Initializes static members of the <see cref="FlowQueryHelper" /> class.
        /// </summary>
        static FlowQueryHelper()
        {
            ExpressionHandlerLock = new object();

            CustomExpressionHandlers = new Dictionary <ExpressionType, HashSet <IExpressionHandler> >();

            DefaultExpressionHandlers = new Dictionary <ExpressionType, HashSet <IExpressionHandler> >();

            AddCallHandler(new AsHandler());
            AddCallHandler(new SimpleMethodCallHandler(Projections.Avg, "Average"));
            AddCallHandler(new LikeHandler());
            AddCallHandler(new CountDistinctHandler());
            AddCallHandler(new SimpleMethodCallHandler(Projections.Count, "Count"));
            AddCallHandler(new SimpleMethodCallHandler(Projections.GroupProperty, "GroupBy"));
            AddCallHandler(new SimpleMethodCallHandler(Projections.Max, "Max"));
            AddCallHandler(new SimpleMethodCallHandler(Projections.Min, "Min"));
            AddCallHandler(new ProjectHandler());
            AddCallHandler(new RoundHandler());
            AddCallHandler(new SubqueryHandler());
            AddCallHandler(new SubstringHandler());
            AddCallHandler(new SimpleMethodCallHandler(Projections.Sum, "Sum"));
            AddCallHandler(new TrimHandler());
            AddCallHandler(new TrimEndHandler());
            AddCallHandler(new TrimStartHandler());

            var conditionHandler = new ConditionHandler();

            ConditionHandler.SupportedExpressionTypes.ForEach(x => AddHandler(x, conditionHandler));

            var arithmeticHandler = new ArithmeticHandler();

            ArithmeticHandler.SupportExpressionTypes.ForEach(x => AddHandler(x, arithmeticHandler));

            AddHandler(ExpressionType.Add, new ConcatenationHandler());
            AddHandler(ExpressionType.Coalesce, new CoalesceHandler());
            AddHandler(ExpressionType.Conditional, new ConditionalHandler());
            AddHandler(ExpressionType.Convert, new ConvertHandler());
            AddHandler(ExpressionType.Lambda, new LambdaHandler());
            AddHandler(ExpressionType.MemberAccess, new MemberAccessHandler());
            AddHandler(ExpressionType.MemberInit, new MemberInitHandler());
            AddHandler(ExpressionType.New, new NewHandler());
        }
示例#8
0
        private void CheckWinConditionNew(int move)
        {
            board[move]       = activePlayer;
            conditionHandler  = new ConditionHandler(CheckCol);
            conditionHandler += CheckDiagonal;
            conditionHandler += CheckRow;

            Delegate[] checkMethods = conditionHandler.GetInvocationList();

            foreach (ConditionHandler method in checkMethods)
            {
                if (method(move, activePlayer))
                {
                    Console.WriteLine(activePlayer + " has won");
                    gameOver = true;
                    return;
                }
            }
            if (gameOver == false && turn == 9)
            {
                Console.WriteLine("It´s a draw!");
                gameOver = true;
            }
        }
 public NUnitTestConditionHandler()
 {
     Handler = new ConditionHandler();
 }
 public Condition2(ConditionHandler ch, GetValue1Handler gvh1, GetValue2Handler gvh2)
     : this(ch)
 {
     this.gvh1 = gvh1;
     this.gvh2 = gvh2;
 }
 public Condition2(ConditionHandler ch, T1 value1, T2 value2)
     : this(ch)
 {
     this.value1 = value1;
     this.value2 = value2;
 }
 private Condition2(ConditionHandler ch)
 {
     this.ch = ch;
 }
 public Condition1(ConditionHandler ch, GetValueHandler gvh)
 {
     this.ch  = ch;
     this.gvh = gvh;
 }
 public Condition1(ConditionHandler ch, T value)
 {
     this.ch    = ch;
     this.value = value;
 }
 public Condition0(ConditionHandler ch)
 {
     this.ch = ch;
 }
示例#16
0
 /// <summary>
 /// 获取消息发送的初始条件
 /// </summary>
 /// <param name="verif"></param>
 /// <returns></returns>
 public string GetShowCondition(string verif)
 {
     return(ConditionHandler.RecoverDisplayCondition(verif));
 }
示例#17
0
 public Condition(ConditionHandler condition)
 {
     _condition = condition;
 }
示例#18
0
 /// <summary>
 /// Create an instance of Decorator
 /// </summary>
 /// <param name="name">Name of behavior</param>
 /// <param name="handler">user provided function to handle execution of Decorator</param>
 public Decorator(string name, ConditionHandler handler)
     : base(name, BehaviorType.Decorator)
 {
     this._Handler  = handler;
     this.NeverFail = false;
 }
示例#19
0
 /// <summary>
 /// Create an instance of Condition
 /// </summary>
 /// <param name="name">Name of Behavior</param>
 /// <param name="handler">function to handle execution of action</param>
 public Condition(string name, ConditionHandler handler)
     : base(name, BehaviorType.Condition)
 {
     this._Handler = handler;
     Reverse       = false;
 }
 public WaitForConditionCommand(ConditionHandler condition, bool shouldPauseGame = false, float lifeTime = float.MaxValue) :
     base(shouldPauseGame, lifeTime)
 {
     Condition += condition;
 }
示例#21
0
        /// <summary>
        /// 提交定时任务请求
        /// </summary>
        /// <param name="accidSet"></param>
        /// <param name="accIdCount"></param>
        /// <param name="MobileTitle"></param>
        /// <param name="PubTitle"></param>
        /// <param name="EmailTitle"></param>
        /// <param name="SmsContent"></param>
        /// <param name="MobileContent"></param>
        /// <param name="PubContent"></param>
        /// <param name="EmailContent"></param>
        /// <param name="remark"></param>
        /// <param name="verif"></param>
        /// <returns></returns>
        public string AddSpecTimeSendingTask(string accidSet, int accIdCount, DateTime date, string MobileTitle = "", string PubTitle = "", string EmailTitle = "",
                                             string SmsContent = "", string MobileContent = "", string PubContent = "", string EmailContent = "", string remark = "", string verif = "")
        {
            #region 设定定时的时间处理

            DateTime dt = DateTime.Now;

            if (dt > date)
            {
                return("0");
            }
            TimeSpan ts = date - dt;

            string minuteSpan = ts.Minutes.ToString();

            #endregion

            ConditionSettingModel.SettingModel model = new ConditionSettingModel.SettingModel();

            if (!string.IsNullOrEmpty(PubContent))
            {
                PubContent = Server.UrlDecode(PubContent);
            }
            if (!string.IsNullOrEmpty(EmailContent))
            {
                EmailContent = Server.UrlDecode(EmailContent);
            }
            if (!string.IsNullOrEmpty(MobileContent))
            {
                MobileContent = Server.UrlDecode(MobileContent);
            }

            ManageUserModel uM    = (ManageUserModel)Session["logUser"];
            int             uid   = uM.UserID;
            string          uName = uM.Name;

            model.Verification = verif;
            model.Operator     = uid;
            model.Remark       = remark;
            model.SendingDate  = date;
            model.AccIdSet     = accidSet;
            model.AccIdCount   = accIdCount;

            model.EmailTitle    = model.EmailTitle;
            model.EmailContent  = EmailContent;
            model.SmsContent    = SmsContent;
            model.MobileTitle   = MobileTitle;
            model.MobileContent = MobileContent;
            model.PubTitle      = PubTitle;
            model.PubContent    = PubContent;

            model.SendingType = 1;
            model.SourceType  = 3;

            int setId = ConditionHandler.AddTaskSetting(model);

            if (setId == 0)
            {
                return("-1");
            }
            else
            {
                //添加任务成功后更新状态
                ConditionHandler.SetTaskActive(setId);
            }

            MessageSysControl.SetTask(setId, 1, minuteSpan);

            return("1");
        }
示例#22
0
 public NUnitTestConditionHandler()
 {
     Controller = new TestController();
     Handler    = new ConditionHandler(Controller);
 }
示例#23
0
        /// <summary>
        /// 提交循环任务请求
        /// </summary>
        /// <param name="modelStr"></param>
        /// <param name="accidSet"></param>
        /// <param name="accIdCount"></param>
        /// <param name="MobileTitle"></param>
        /// <param name="PubTitle"></param>
        /// <param name="EmailTitle"></param>
        /// <param name="SmsContent"></param>
        /// <param name="MobileContent"></param>
        /// <param name="PubContent"></param>
        /// <param name="EmailContent"></param>
        /// <param name="remark"></param>
        /// <param name="verif"></param>
        /// <param name="cronExp"></param>
        /// <returns></returns>
        public string AddRecurringTask(string modelStr, string accidSet, int accIdCount, string MobileTitle = "", string PubTitle = "", string EmailTitle = "",
                                       string SmsContent = "", string MobileContent = "", string PubContent = "", string EmailContent = "", string remark = "", string verif = "", string cronExp = "", string sendMark = "")
        {
            ConditionSettingModel.SettingModel model = new ConditionSettingModel.SettingModel();

            #region 处理循环筛选条件

            string sqlSet = MessageSysControl.RegenerateSql(modelStr, verif);

            if (string.IsNullOrEmpty(sqlSet))
            {
                return("-1");
            }

            #endregion

            if (!string.IsNullOrEmpty(PubContent))
            {
                PubContent = Server.UrlDecode(PubContent);
            }
            if (!string.IsNullOrEmpty(EmailContent))
            {
                EmailContent = Server.UrlDecode(EmailContent);
            }
            if (!string.IsNullOrEmpty(MobileContent))
            {
                MobileContent = Server.UrlDecode(MobileContent);
            }

            //如果选定本次需要发送则执行提交批次的逻辑
            if (!string.IsNullOrEmpty(sendMark))
            {
                MessageSysControl.PreparePushingMsg(accidSet, accIdCount, 2, MobileTitle, PubTitle, EmailTitle, SmsContent, MobileContent,
                                                    PubContent, EmailContent, remark, verif, "");
            }


            #region 设定循环的Cron表达式处理
            #endregion

            ManageUserModel uM    = (ManageUserModel)Session["logUser"];
            int             uid   = uM.UserID;
            string          uName = uM.Name;

            model.Verification = verif;
            model.Operator     = uid;
            model.Remark       = remark;
            //model.SendingDate = date;
            model.AccIdSet   = accidSet;
            model.AccIdCount = accIdCount;

            model.EmailTitle    = model.EmailTitle;
            model.EmailContent  = EmailContent;
            model.SmsContent    = SmsContent;
            model.MobileTitle   = MobileTitle;
            model.MobileContent = MobileContent;
            model.PubTitle      = PubTitle;
            model.PubContent    = PubContent;

            model.SqlSet = sqlSet;
            model.RecurringSendingCron = cronExp;

            model.SendingType = 2;
            model.SourceType  = 4;
            model.SendingDate = DateTime.Now;

            int setId = ConditionHandler.AddTaskSetting(model);

            if (setId == 0)
            {
                return("-1");
            }
            else
            {
                //添加任务成功后更新状态
                ConditionHandler.SetTaskActive(setId);
            }

            //MessageSysControl.ExcuteRecurringTask(setId);
            MessageSysControl.SetTask(setId, 2, cronExp);

            return("1");
        }
 public UIDyeItemSlot(Vector2 position, int size = 52, int context = 0, string hoverText = "", UIObject parent = null, ConditionHandler conditions = null, DrawHandler drawBackground = null, DrawHandler drawItem = null, DrawHandler postDrawItem = null, bool drawAsNormalSlot = false, bool scaleToInventory = false) : base(position, size, context, hoverText, parent, conditions, drawBackground, drawItem, postDrawItem, drawAsNormalSlot, scaleToInventory)
 {
 }
 public Condition2(ConditionHandler ch, T1 value1, GetValue2Handler gvh2)
     : this(ch)
 {
     this.value1 = value1;
     this.gvh2   = gvh2;
 }
 public Condition2(ConditionHandler ch, GetValue1Handler gvh1, T2 value2)
     : this(ch)
 {
     this.gvh1   = gvh1;
     this.value2 = value2;
 }
示例#27
0
 public void AddTransition(ConditionHandler cond, U transitToState)
 {
     TransitionList.Add(new Transition <U> {
         conditions = new ConditionHandler[] { cond }, nextState = transitToState
     });
 }