예제 #1
0
        private void CommandManager_Clicked(object sender, EventArgs e)
        {
            CodeFunctionHandler codeFunctionHandler = new CodeFunctionHandler();
            //var parameters = new List<object>();
            //parameters.Add(new CommandFunctionParam(editArea, AgentUICoreMediator.GetAgentUICoreMediator.GetRequester()));
            DP_DataRepository data = null;

            if (EditArea is I_EditEntityAreaOneData)
            {
                data = (EditArea as I_EditEntityAreaOneData).GetDataList().FirstOrDefault();
            }
            else if (EditArea is I_EditEntityAreaMultipleData)
            {
                data = (EditArea as I_EditEntityAreaMultipleData).GetSelectedData().FirstOrDefault();
            }
            if (data != null)
            {
                var result = codeFunctionHandler.GetCodeFunctionResult(AgentUICoreMediator.GetAgentUICoreMediator.GetRequester(), EntityCommandDTO.CodeFunctionID, data);
                if (result.Exception != null)
                {
                    AgentUICoreMediator.GetAgentUICoreMediator.UIManager.ShowInfo("خطا", result.Exception.Message, Temp.InfoColor.Red);
                }
            }
            else
            {
                AgentUICoreMediator.GetAgentUICoreMediator.UIManager.ShowInfo("داده ای انتخاب نشده است");
            }
        }
예제 #2
0
        //public FunctionResult CalculateFormula(int formulaID, DP_DataView dataItem, DR_Requester requester, List<int> usedFormulaIDs = null)
        //{
        //    //DP_DataRepository data = new DP_DataRepository(mainDataItem.TargetEntityID, mainDataItem.TargetEntityAlias);
        //    //data.Properties = mainDataItem.Properties;
        //    return CalculateFormula(formulaID,dataItem, requester, usedFormulaIDs);
        //}
        public FunctionResult CalculateFormula(int formulaID, DP_BaseData dataItem, DR_Requester requester, List <int> usedFormulaIDs = null)
        {
            FunctionResult result       = null;
            var            formula      = bizFormula.GetFormula(requester, formulaID, true);
            var            mainDataItem = GetMainDateItem(requester, dataItem);

            if (formula.FormulaType == FormulaType.Linear)
            {
                var linearFormula = bizFormula.GetLinearFormula(requester, formulaID, false);
                result = CalculateFormula(linearFormula.FormulaText, mainDataItem, requester, usedFormulaIDs);
            }
            else
            {
                if (formula.FormulaType == FormulaType.CodeFunctionEntity)
                {
                    CodeFunctionHandler codeFunctionHandler = new CodeFunctionHandler();
                    result = codeFunctionHandler.GetCodeFunctionEntityResult(requester, formula.CodeFunctionEntityID, mainDataItem);
                }
                else if (formula.FormulaType == FormulaType.CodeFunction)
                {
                    CodeFunctionHandler codeFunctionHandler = new CodeFunctionHandler();
                    result = codeFunctionHandler.GetCodeFunctionResult(requester, formula.CodeFunctionID, mainDataItem);
                }
                else if (formula.FormulaType == FormulaType.DatabaseFunctionEntity)
                {
                    DatabaseFunctionHandler databaseFunctionHandler = new DatabaseFunctionHandler();
                    result = databaseFunctionHandler.GetDatabaseFunctionValue(requester, formula.DatabaseFunctionEntityID, mainDataItem);
                }
            }
            result.FormulaUsageParemeters = GetFormulaUsageParemeters(requester, formula, mainDataItem);

            return(result);
        }
        public void DoBeforeDeleteActionActivities(DR_Requester requester, List <EditQueryResultItem> items)
        {
            BizBackendActionActivity bizActionActivity = new BizBackendActionActivity();

            foreach (var editQuertyResult in items.Where(x => x.QueryItem.QueryType == Enum_QueryItemType.Delete))
            {
                var queryItem        = editQuertyResult.QueryItem;
                var actionActivities = bizActionActivity.GetActionActivities(queryItem.TargetEntity.ID, new List <Enum_EntityActionActivityStep>()
                {
                    Enum_EntityActionActivityStep.BeforeDelete
                }, true, true);
                CodeFunctionHandler codeFunctionHelper = new CodeFunctionHandler();
                foreach (var entityActionActivity in actionActivities)
                {
                    if (entityActionActivity.CodeFunctionID != 0)
                    {
                        var resultFunction = codeFunctionHelper.GetCodeFunctionResult(requester, entityActionActivity.CodeFunctionID, queryItem.DataItem);
                        if (resultFunction.Exception != null)
                        {
                            editQuertyResult.BeforeSaveActionActivitiesResult   = Enum_DR_SimpleResultType.ExceptionThrown;
                            editQuertyResult.BeforeSaveActionActivitiesMessage += resultFunction.Exception.Message;
                            return;
                        }
                    }
                }
            }
        }
        public void DoAfterEditActionActivities(DR_Requester requester, List <EditQueryResultItem> items)
        {
            BizBackendActionActivity bizActionActivity = new BizBackendActionActivity();

            foreach (var editQuertyResult in items.Where(x => x.QueryItem.QueryType == Enum_QueryItemType.Insert || x.QueryItem.QueryType == Enum_QueryItemType.Update))
            {
                var queryItem = editQuertyResult.QueryItem;
                if (queryItem.QueryType == Enum_QueryItemType.Insert || queryItem.QueryType == Enum_QueryItemType.Update)
                {
                    var actionActivities = bizActionActivity.GetActionActivities(queryItem.DataItem.TargetEntityID, new List <Enum_EntityActionActivityStep>()
                    {
                        Enum_EntityActionActivityStep.AfterSave
                    }, false, true);
                    CodeFunctionHandler     codeFunctionHelper      = new CodeFunctionHandler();
                    DatabaseFunctionHandler databaseFunctionHandler = new DatabaseFunctionHandler();
                    foreach (var entityActionActivity in actionActivities)
                    {
                        if (entityActionActivity.CodeFunctionID != 0)
                        {
                            var resultFunction = codeFunctionHelper.GetCodeFunctionResult(requester, entityActionActivity.CodeFunctionID, queryItem.DataItem);
                            if (resultFunction.Exception != null)
                            {
                                editQuertyResult.AfterSaveActionActivitiesResult   = Enum_DR_SimpleResultType.ExceptionThrown;
                                editQuertyResult.AfterSaveActionActivitiesMessage += resultFunction.Exception.Message;
                            }
                        }
                        else if (entityActionActivity.DatabaseFunctionEntityID != 0)
                        {
                            ////اصلاح شود و با خصوصیات صدا زده شود یا حداقل لیست خصوصیات ارسال شود چون بهتره ارتباط
                            var resultFunction = databaseFunctionHandler.GetDatabaseFunctionValue(requester, entityActionActivity.DatabaseFunctionEntityID, queryItem.DataItem);
                            if (resultFunction.Exception != null)
                            {
                                editQuertyResult.AfterSaveActionActivitiesResult   = Enum_DR_SimpleResultType.ExceptionThrown;
                                editQuertyResult.AfterSaveActionActivitiesMessage += resultFunction.Exception.Message;
                            }
                        }
                    }
                }
            }
            foreach (var editQuertyResult in items.Where(x => x.QueryItem.QueryType == Enum_QueryItemType.Delete))
            {
                var queryItem        = editQuertyResult.QueryItem;
                var actionActivities = bizActionActivity.GetActionActivities(queryItem.TargetEntity.ID, new List <Enum_EntityActionActivityStep>()
                {
                    Enum_EntityActionActivityStep.AfterDelete
                }, false, true);
                CodeFunctionHandler     codeFunctionHelper      = new CodeFunctionHandler();
                DatabaseFunctionHandler databaseFunctionHandler = new DatabaseFunctionHandler();
                foreach (var entityActionActivity in actionActivities)
                {
                    if (entityActionActivity.CodeFunctionID != 0)
                    {
                        var resultFunction = codeFunctionHelper.GetCodeFunctionResult(requester, entityActionActivity.CodeFunctionID, queryItem.DataItem);
                        if (resultFunction.Exception != null)
                        {
                            editQuertyResult.AfterSaveActionActivitiesResult   = Enum_DR_SimpleResultType.ExceptionThrown;
                            editQuertyResult.AfterSaveActionActivitiesMessage += resultFunction.Exception.Message;
                        }
                    }
                    else if (entityActionActivity.DatabaseFunctionEntityID != 0)
                    {
                        var resultFunction = databaseFunctionHandler.GetDatabaseFunctionValue(requester, entityActionActivity.DatabaseFunctionEntityID, queryItem.DataItem);
                        if (resultFunction.Exception != null)
                        {
                            editQuertyResult.AfterSaveActionActivitiesResult   = Enum_DR_SimpleResultType.ExceptionThrown;
                            editQuertyResult.AfterSaveActionActivitiesMessage += resultFunction.Exception.Message;
                        }
                    }
                }
            }
            //    var deleteResult = new DR_ResultDelete();
            //new DeleteRequestManager().DoAfterDeleteActionActivities(requester, queryItems.Where(x => x.QueryType == Enum_QueryItemType.Delete), deleteResult);
            //result.Message += deleteResult.Message;
        }