Exemple #1
0
 /// <summary>
 /// 执行外部方法
 /// SetVariable:
 /// https://stackoverflow.com/questions/26426955/setting-and-getting-variables-in-net-hosted-ironpython-script/45734097
 /// </summary>
 /// <param name="action">Action实体</param>
 /// <param name="delegateService">委托服务</param>
 private static void ExecutePythonMethod(ActionEntity action, IDelegateService delegateService)
 {
     try
     {
         if (action.CodeInfo != null &&
             !string.IsNullOrEmpty(action.CodeInfo.CodeText))
         {
             // var pythonScript = action.Expression;
             var pythonScript = action.CodeInfo.CodeText;         //modified by Besley in 12/26/2019, body is nodetext rather than attribute
             var engine       = Python.CreateEngine();
             var scope        = engine.CreateScope();
             var dictionary   = CompositeKeyValue(action.Arguments, delegateService);
             foreach (var item in dictionary)
             {
                 scope.SetVariable(item.Key, item.Value);
             }
             var source = engine.CreateScriptSourceFromString(pythonScript);
             source.Execute(scope);
         }
         else
         {
             throw new WorkflowException("Python脚本为空, 不能执行!");
         }
     }
     catch (System.Exception ex)
     {
         throw new WorkflowException(string.Format("执行Pythond方法出错:{0}", ex.Message));
     }
 }
 public static ActionModel Map(this ActionEntity entity)
 {
     return(entity == null ? null : new ActionModel
     {
         Name = entity.Name,
     });
 }
        protected override string GetProcessedValue()
        {
            ActionEntity         actionEntity         = new ActionEntity(_field.Lookup, Value, _connection);
            ActionEntityDataBase actionEntityDataBase = new ActionEntityDataBase(actionEntity);

            return(actionEntityDataBase.ResolveActionEntity(Value));
        }
Exemple #4
0
 /// <summary>
 /// 执行外部服务实现类
 /// </summary>
 /// <param name="action">操作</param>
 /// <param name="delegateService">委托服务类</param>
 private static void Execute(ActionEntity action, IDelegateService delegateService)
 {
     if (action.ActionType == ActionTypeEnum.Event)
     {
         if (action.ActionMethod == ActionMethodEnum.LocalService)
         {
             ExecuteLocalService(action, delegateService);
         }
         else if (action.ActionMethod == ActionMethodEnum.CSharpLibrary)
         {
             ExecuteCSharpLibraryMethod(action, delegateService);
         }
         else if (action.ActionMethod == ActionMethodEnum.WebApi)
         {
             ExecuteWebApiMethod(action, delegateService);
         }
         else if (action.ActionMethod == ActionMethodEnum.SQL)
         {
             ExecuteSQLMethod(action, delegateService);
         }
         else if (action.ActionMethod == ActionMethodEnum.StoreProcedure)
         {
             ExecuteStoreProcedureMethod(action, delegateService);
         }
         else if (action.ActionMethod == ActionMethodEnum.Python)
         {
             ExecutePythonMethod(action, delegateService);
         }
         else
         {
             throw new WorkflowException(LocalizeHelper.GetEngineMessage("actionexecutor.Execute.exception", action.ActionMethod.ToString()));
         }
     }
 }
Exemple #5
0
 /// <summary>
 /// 执行外部服务实现类
 /// </summary>
 /// <param name="action">操作</param>
 /// <param name="delegateService">委托服务类</param>
 private static void Execute(ActionEntity action, IDelegateService delegateService)
 {
     if (action.ActionType == ActionTypeEnum.Event)
     {
         if (action.ActionMethod == ActionMethodEnum.LocalService)
         {
             ExecuteLocalService(action, delegateService);
         }
         else if (action.ActionMethod == ActionMethodEnum.CSharpLibrary)
         {
             ExecuteCSharpLibraryMethod(action, delegateService);
         }
         else if (action.ActionMethod == ActionMethodEnum.WebApi)
         {
             ExecuteWebApiMethod(action, delegateService);
         }
         else if (action.ActionMethod == ActionMethodEnum.SQL)
         {
             ExecuteSQLMethod(action, delegateService);
         }
         else if (action.ActionMethod == ActionMethodEnum.StoreProcedure)
         {
             ExecuteStoreProcedureMethod(action, delegateService);
         }
         else if (action.ActionMethod == ActionMethodEnum.Python)
         {
             ExecutePythonMethod(action, delegateService);
         }
         else
         {
             throw new WorkflowException(string.Format("暂不支持的选项:{0}", action.ActionMethod.ToString()));
         }
     }
 }
        /// <summary>
        /// This function is used to delete an Action Entity from it code.
        /// </summary>
        /// <param name="code">The code of the action entity</param>
        /// <returns>True on success, false on fail.</returns>
        public static bool Delete(string code)
        {
            ActionEntity      action = new ActionEntity(code);
            DataAccessAdapter ds     = new DataAccessAdapter();

            return(ds.DeleteEntity(action));
        }
Exemple #7
0
        public bool UpdateAction(int ActionId, ActionEntity actionEntity)
        {
            var success = false;

            if (actionEntity != null)
            {
                using (var scope = new TransactionScope())
                {
                    var action = _unitOfWork.ActionRepository.GetByID(ActionId);
                    if (actionEntity != null)
                    {
                        action.MenuId     = actionEntity.MenuId;
                        action.Name       = actionEntity.Name;
                        action.Remarks    = actionEntity.Remarks;
                        action.IsActive   = actionEntity.IsActive;
                        action.ModifiedBy = actionEntity.ModifiedBy;
                        action.ModifiedOn = DateTime.Now;
                        _unitOfWork.ActionRepository.Update(action);
                        _unitOfWork.Save();
                        scope.Complete();
                        success = true;
                    }
                }
            }
            return(success);
        }
Exemple #8
0
 public ProcessEntity(string _targetDWID, string _id, ActionEntity action, string _infoID)
 {
     this.TargetDWID = _targetDWID;
     this.ID         = _id;
     this.InfoID     = _infoID;
     this.Action     = action;
 }
Exemple #9
0
        /// <summary>
        /// 执行插件方法
        /// </summary>
        /// <param name="action">Action实体</param>
        /// <param name="delegateService">委托服务</param>
        private static void ExecuteCSharpLibraryMethod(ActionEntity action, IDelegateService delegateService)
        {
            try
            {
                //取出当前应用程序执行路径
                var  methodInfo          = action.MethodInfo;
                var  assemblyFullName    = methodInfo.AssemblyFullName;
                var  methodName          = methodInfo.MethodName;
                var  executingPath       = ConfigHelper.GetExecutingDirectory();
                var  pluginAssemblyName  = string.Format("{0}\\{1}\\{2}.dll", executingPath, "plugin", assemblyFullName);
                var  pluginAssemblyTypes = Assembly.LoadFile(pluginAssemblyName).GetTypes();
                Type outerClass          = pluginAssemblyTypes
                                           .Single(t => !t.IsInterface && t.FullName == methodInfo.TypeFullName);
                //object instance = Activator.CreateInstance(outerClass, parameters.ConstructorParameters);
                object instance = Activator.CreateInstance(outerClass);
                System.Reflection.MethodInfo mi = outerClass.GetMethod(methodName);

                object[] methodParams = null;
                if (!string.IsNullOrEmpty(action.Arguments.Trim()))
                {
                    methodParams = CompositeParameterValues(action.Arguments, delegateService);
                }
                var result = mi.Invoke(instance, methodParams);
            }
            catch (System.Exception ex)
            {
                throw new WorkflowException(string.Format("执行C#组件方法出错:{0}", ex.Message));
            }
        }
Exemple #10
0
 public void Dispose()
 {
     Add      = null;
     Remove   = null;
     length   = 0;
     entities = new int[EngineSettings.MinEntities];
     OnDispose();
 }
        public void DependOnAction()
        {
            ActionEntity action = Factory.GetActionEntity();

            bool result = TestObject.AddDependency(action);

            Assert.IsTrue(result, "Should be able to depend on Realisation entities.");
        }
        /// <summary>
        /// This function is used to change the Code of an Action Entity
        /// </summary>
        /// <param name="oldcode">The old code of the Action Entity.</param>
        /// <param name="newcode">The new code of the Action Entity.</param>
        /// <returns></returns>
        public static bool ChangeCode(string oldcode, string newcode)
        {
            ActionEntity action = new ActionEntity(oldcode);

            action.Code = newcode;
            DataAccessAdapter ds = new DataAccessAdapter();

            return(ds.SaveEntity(action));
        }
Exemple #13
0
        /// <summary>
        /// Loads the data from the stream. Written in "WriteTo".
        /// </summary>
        public static ActionEntity CreateFrom(System.IO.BinaryReader reader)
        {
            ActionEntity entity = new ActionEntity
            {
                Qualifier = (ActionQualifier)reader.ReadInt32(),
                Action    = reader.ReadString()
            };

            return(entity);
        }
        /// <summary>
        /// This function is used to update an Action Entity.
        /// </summary>
        /// <param name="code">The code of the Action Entity.</param>
        /// <param name="name">The name of the Action Entity.</param>
        /// <returns>True on success, false on fail.</returns>
        public static bool Update(string code, string name)
        {
            ActionEntity action = new ActionEntity(code);

            action.IsNew = false;
            action.Name  = name;
            DataAccessAdapter ds = new DataAccessAdapter();

            return(ds.SaveEntity(action));
        }
        /// <summary>
        /// This function is used to insert a Action Entity in the storage area.
        /// </summary>
        /// <param name="code">Code of this action</param>
        /// <param name="name">Name of this action.</param>
        /// <returns>True if success, False on fail.</returns>
        public static bool Insert(string code, string name)
        {
            ActionEntity action = new ActionEntity();

            action.Code = code;
            action.Name = name;
            DataAccessAdapter ds = new DataAccessAdapter();

            return(ds.SaveEntity(action));
        }
 public async Task AddAction(string gameId, string playerId, IAction action)
 {
     var item = new ActionEntity
     {
         GameId = gameId,
         UserId = playerId,
         Action = action,
     };
     var value = JsonConvert.SerializeObject(item);
     await _redisDb.ListRightPushAsync(gameId, value);
 }
Exemple #17
0
        /// <summary>
        /// Actionを追加する
        /// </summary>
        /// <param name="boardId">ボードID</param>
        /// <param name="actionList">Actionのリスト</param>
        public async Task AddActionListAsync(int boardId, List <ActionItem> actionList)
        {
            CloudTable table = this.Client.GetTableReference(TblAction);

            foreach (var actionItem in actionList)
            {
                var            emp      = new ActionEntity(boardId, actionItem.Title, actionItem.Description, actionItem.Assigned, actionItem.Period);
                TableOperation insertOp = TableOperation.InsertOrReplace(emp);
                await table.ExecuteAsync(insertOp);
            }
        }
 public int Post([FromBody] ActionEntity actionEntity)
 {
     try
     {
         return(_actionServices.CreateAction(actionEntity));
     }
     catch (Exception ex)
     {
         throw new ApiDataException(1000, "Action Not Found", HttpStatusCode.NotFound);
     }
 }
Exemple #19
0
 /// <summary>
 /// 执行CSHARP方法
 /// </summary>
 /// <param name="action">Action实体</param>
 /// <param name="delegateService">委托服务</param>
 private static void ExecuteCSharpCodeMethod(ActionEntity action, IDelegateService delegateService)
 {
     try
     {
         ;
     }
     catch (System.Exception ex)
     {
         throw new WorkflowException(string.Format("执行CSharp脚本出错:{0}", ex.Message));
     }
 }
        public Result Insert(ActionEntity entity)
        {
            var con   = new DapperConnectionManager();
            var query = new QueryEntity();

            query.Entity = entity;
            query.Query  = @"INSERT INTO Actions (Text, Title, Type) VALUES(@Text, @Title, @Type)";
            var result = con.InsertQuery(query);

            result.Message = result.Success ? "The action has been created" : "An error occurred";
            return(result);
        }
        public Result Update(ActionEntity entity)
        {
            var con   = new DapperConnectionManager();
            var query = new QueryEntity();

            query.Entity = entity;
            query.Query  = @"UPDATE Actions set Text = @Text, Title = @Title, Type=@Type Where ActionId = @ActionId";
            var result = con.ExecuteQuery(query);

            result.Message = result.Success ? "The action has been updated" : "An error occurred";
            result.Entity  = entity.ActionId;
            return(result);
        }
Exemple #22
0
    protected override void OnValidate()
    {
        base.OnValidate();

        ActionEntity script = target as ActionEntity;

        if (script == null)
        {
            return;
        }

        script.name += script.targEntity.EntityName();
    }
        void LoadOperation_ActionCompleted(object sender, EventArgs e)
        {
            ActionEntityList.Clear();
            LoadOperation loadOperation = sender as LoadOperation;

            foreach (ProductManager.Web.Model.action action in loadOperation.Entities)
            {
                ActionEntity actionEntity = new ActionEntity();
                actionEntity.Action = action;
                actionEntity.Update();
                ActionEntityList.Add(actionEntity);
            }
            UpdateRoleAndRoleAction();
        }
        /// <summary>
        /// This method is used to retreive a single ActionEntity by it Primary Key
        /// </summary>
        /// <param name="code">The code</param>
        /// <returns>An entity if found, null if nothing found.</returns>
        public static ActionEntity SelectSingle(string code)
        {
            ActionEntity      action = new ActionEntity(code);
            DataAccessAdapter ds     = new DataAccessAdapter();

            if (ds.FetchEntity(action) == true)
            {
                return(action);
            }
            else
            {
                return(null);
            }
        }
 /// <summary>
 /// 执行外部服务实现类
 /// </summary>
 /// <param name="action">操作</param>
 /// <param name="delegateService">委托服务类</param>
 private static void Execute(ActionEntity action, IDelegateService delegateService)
 {
     if (action.ActionType == ActionTypeEnum.Event)
     {
         if (action.ActionMethod == ActionMethodEnum.LocalMethod)
         {
             ExecuteLocalMethod(action, delegateService);
         }
         else
         {
             throw new WorkflowException(string.Format("社区版暂不支持的选项:{0}", action.ActionMethod.ToString()));
         }
     }
 }
Exemple #26
0
 /// <summary>
 /// 执行外部方法
 /// </summary>
 /// <param name="action">Action实体</param>
 /// <param name="delegateService">委托服务</param>
 private static void ExecuteLocalService(ActionEntity action, IDelegateService delegateService)
 {
     try
     {
         //先获取具体实现类
         var instance = ReflectionHelper.GetSpecialInstance <IExternalService>(action.Expression);
         //再调用基类可执行方法
         var exterableInstance = instance as IExternable;
         exterableInstance.Executable(delegateService);
     }
     catch (System.Exception ex)
     {
         throw new WorkflowException(LocalizeHelper.GetEngineMessage("actionexecutor.ExecuteLocalService.exception", ex.Message));
     }
 }
Exemple #27
0
 /// <summary>
 /// 执行外部方法
 /// </summary>
 /// <param name="action">Action实体</param>
 /// <param name="delegateService">委托服务</param>
 private static void ExecuteStoreProcedureMethod(ActionEntity action, IDelegateService delegateService)
 {
     try
     {
         var parameters    = CompositeSqlParametersValue(action.Arguments, delegateService);
         var procedureName = action.Expression;
         var session       = delegateService.GetSession();
         var repository    = new Repository();
         repository.ExecuteProc(session.Connection, procedureName, parameters, session.Transaction);
     }
     catch (System.Exception ex)
     {
         throw new WorkflowException(string.Format("执行StoreProcedure方法出错:{0}", ex.Message));
     }
 }
 public bool Put([FromBody] ActionEntity actionEntity)
 {
     try
     {
         if (actionEntity.ActionId > 0)
         {
             return(_actionServices.UpdateAction(actionEntity.ActionId, actionEntity));
         }
     }
     catch (Exception ex)
     {
         throw new ApiDataException(1000, "Action not found", HttpStatusCode.NotFound);
     }
     return(false);
 }
 /// <summary>
 /// 执行外部方法
 /// </summary>
 /// <param name="action">Action实体</param>
 /// <param name="delegateService">委托服务</param>
 private static void ExecuteLocalMethod(ActionEntity action, IDelegateService delegateService)
 {
     try
     {
         //先获取具体实现类
         var instance = ReflectionHelper.GetSpecialInstance <IExternalService>(action.Expression);
         //再调用基类可执行方法
         var exterableInstance = instance as IExternable;
         exterableInstance.Executable(delegateService);
     }
     catch (System.Exception ex)
     {
         throw new WorkflowException(string.Format("执行LocalMethod出错:{0}", ex.Message));
     }
 }
        public IEnumerable <ActionEntity> GetAllWORequestActions()
        {
            List <ActionEntity> actionList = new List <ActionEntity>();

            IEnumerable <WOaction> wOActionsList = dbPrisma.WOaction.Where(x => x.wr.Equals("1"));

            foreach (var woAction in wOActionsList)
            {
                ActionEntity actionEntity = new ActionEntity();
                actionEntity.ActionCode  = woAction.woaction_code;
                actionEntity.Description = woAction.descr;
                actionList.Add(actionEntity);
            }

            return(actionList);
        }
        internal static ActionEntity ConvertActionEntity(IPolicyResponseAction actionInfo)
        {
            if (actionInfo.Properties.ContainsKey("ExceptionAction") && actionInfo.Properties["ExceptionAction"] == "True" && !actionInfo.Processed)
                return null;

            ActionEntity ae = new ActionEntity();
            ae.ActionName = actionInfo.Name;
            ae.ActionOverriden = actionInfo.Overridden;
            ae.ActionProcessed = actionInfo.Processed;
            ae.ActionType = actionInfo.Type;

            List<ActionPropertyEntity> aList = new List<ActionPropertyEntity>();
            if (actionInfo.ActionPropertyCollection != null && actionInfo.ActionPropertyCollection.Count > 0)
            {
                foreach (IActionPropertyResponse apr in actionInfo.ActionPropertyCollection)
                {
                    if (!string.IsNullOrEmpty(apr.Value))
                    {
                        ActionPropertyEntity ape = new ActionPropertyEntity();
                        ape.Name = apr.Name;
                        ape.PropertyValue = apr.Value;
                        aList.Add(ape);
                    }
                }
            }
            ae.ActionProperties = aList.ToArray();
            return ae;
        }