コード例 #1
0
        public frmCodeFunction(int codeFunctionID, Enum_CodeFunctionParamType codeFunctionParamType, bool?showInFormula = null)
        {
            InitializeComponent();
            ShowInFormula = showInFormula;
            //    EntityID = entityID;
            CodeFunctionParamType = codeFunctionParamType;
            SetCombos();
            //ExpectedReturnType = expectedReturnType;
            if (CodeFunctionParamType == Enum_CodeFunctionParamType.ManyDataItems)
            {
                lblExpectedParameter.Text   = typeof(ProxyLibrary.CodeFunctionParamManyDataItems).ToString();
                lblExpectedReturnValue.Text = typeof(FunctionResult).ToString();
            }
            else if (CodeFunctionParamType == Enum_CodeFunctionParamType.OneDataItem)
            {
                lblExpectedParameter.Text   = typeof(ProxyLibrary.CodeFunctionParamOneDataItem).ToString();
                lblExpectedReturnValue.Text = typeof(FunctionResult).ToString();
            }
            else if (CodeFunctionParamType == Enum_CodeFunctionParamType.KeyColumns)
            {
                lblExpectedParameter.Text   = "Primitive params";
                lblExpectedReturnValue.Text = typeof(FunctionResult).ToString();
            }
            ////else if (CodeFunctionParamType == Enum_CodeFunctionParamType.CommandFunction)
            ////{
            ////    lblExpectedParameter.Text = typeof(CommandFunctionParam).ToString();
            ////    lblExpectedReturnValue.Text = typeof(CommandFunctionResult).ToString();
            ////}
            else if (CodeFunctionParamType == Enum_CodeFunctionParamType.LetterFunction)
            {
                lblExpectedParameter.Text   = typeof(ProxyLibrary.LetterFunctionParam).ToString();
                lblExpectedReturnValue.Text = typeof(FunctionResult).ToString();
            }
            else if (CodeFunctionParamType == Enum_CodeFunctionParamType.LetterConvert)
            {
                lblExpectedParameter.Text   = typeof(ProxyLibrary.LetterFunctionParam).ToString();
                lblExpectedReturnValue.Text = typeof(ProxyLibrary.LetterConvertToExternalResult).ToString();
            }
            //Catalog = catalog;
            //if (CodeFunctionParamType != Enum_CodeFunctionParamType.KeyColumns)
            //    HideColumn();
            //else
            //    SetColumnSource();

            if (codeFunctionID == 0)
            {
                Message = new CodeFunctionDTO();
            }
            else
            {
                GetCodeFuntion(codeFunctionID);
            }
        }
コード例 #2
0
 private LetterConvertToExternalResult GetLetterSendingCodeFunctionResult(CodeFunctionDTO codeFunction, List <object> parameters)
 {
     try
     {
         var result = ReflectionHelper.CallMethod(codeFunction.Path, codeFunction.ClassName, codeFunction.FunctionName, parameters.ToArray());
         return((LetterConvertToExternalResult)result);
     }
     catch (Exception ex)
     {
         LetterConvertToExternalResult result = new LetterConvertToExternalResult();
         result.Exception = ex;
         return(result);
     }
 }
コード例 #3
0
 private FunctionResult GetCodeFunctionResult(CodeFunctionDTO codeFunction, List <object> parameters)
 {
     //FunctionResult result = new FunctionResult();
     try
     {
         return((FunctionResult)ReflectionHelper.CallMethod(codeFunction.Path, codeFunction.ClassName, codeFunction.FunctionName, parameters.ToArray()));
     }
     catch (Exception ex)
     {
         FunctionResult result = new FunctionResult();
         result.Exception = ex;
         return(result);
     }
     // return result;
 }
コード例 #4
0
        public CodeFunctionDTO ToCodeFunctionDTO(CodeFunction item, bool withColumns)
        {
            BizColumn       bizColumn = new BizColumn();
            CodeFunctionDTO result    = new CodeFunctionDTO();

            result.ID        = item.ID;
            result.ClassName = item.ClassName;
            //result.Catalog = item.Catalog;
            //if (item.TableDrivedEntityID != null)
            //    result.EntityID = item.TableDrivedEntityID.Value;
            result.FunctionName     = item.FunctionName;
            result.Name             = item.Name;
            result.ParamType        = (Enum_CodeFunctionParamType)item.Type;
            result.RetrunType       = item.ReturnType;
            result.RetrunDotNetType = Type.GetType(item.ReturnType);
            //if (item.ValueCustomType != null)
            //    result.ValueCustomType = (ValueCustomType)item.ValueCustomType;
            result.Path = item.Path;
            if (withColumns)
            {
                result.Parameters = ToCodeFunctionParameterDTO(item);
            }
            return(result);
        }
コード例 #5
0
        public int UpdateCodeFunctions(CodeFunctionDTO CodeFunction)
        {
            using (var projectContext = new DataAccess.MyProjectEntities())
            {
                var dbCodeFunction = projectContext.CodeFunction.FirstOrDefault(x => x.ID == CodeFunction.ID);
                if (dbCodeFunction == null)
                {
                    dbCodeFunction = new DataAccess.CodeFunction();
                }
                dbCodeFunction.ID = CodeFunction.ID;
                //if (CodeFunction.EntityID != 0)
                //{
                //    if (!dbCodeFunction.CodeFunction_TableDrivedEntity.Any(x => x.TableDrivedEntityID == CodeFunction.EntityID))
                //    {
                //        dbCodeFunction.CodeFunction_TableDrivedEntity.Add(new CodeFunction_TableDrivedEntity() { TableDrivedEntityID = CodeFunction.EntityID, ShowInFormula = CodeFunction.ShowInFormula });
                //    }
                //}
                //    dbCodeFunction.TableDrivedEntityID = CodeFunction.EntityID;
                //else
                //    dbCodeFunction.TableDrivedEntityID = null;
                //dbCodeFunction.ValueCustomType = (short)CodeFunction.ValueCustomType;

                dbCodeFunction.Name      = CodeFunction.Name;
                dbCodeFunction.ClassName = CodeFunction.ClassName;
                dbCodeFunction.Path      = CodeFunction.Path;
                dbCodeFunction.Type      = (short)CodeFunction.ParamType;
                //dbCodeFunction.Catalog = CodeFunction.Catalog;
                dbCodeFunction.FunctionName = CodeFunction.FunctionName;
                dbCodeFunction.ReturnType   = CodeFunction.RetrunType;
                //var entityRelation = dbCodeFunction.CodeFunction_TableDrivedEntity.FirstOrDefault(x => x.TableDrivedEntityID == CodeFunction.EntityID);
                //if(entityRelation==null)
                //{
                //    entityRelation = new CodeFunction_TableDrivedEntity();
                //    entityRelation.TableDrivedEntityID = CodeFunction.EntityID;
                //    dbCodeFunction.CodeFunction_TableDrivedEntity.Add(entityRelation);
                //}

                if (dbCodeFunction.ID == 0)
                {
                    projectContext.CodeFunction.Add(dbCodeFunction);
                }

                var listParams = CodeFunction.Parameters.Select(x => x.ParameterName).ToList();
                var removelist = dbCodeFunction.CodeFunctionParameter.Where(x => !listParams.Contains(x.ParamName)).ToList();
                foreach (var removeItem in removelist)
                {
                    var removeItemUsedList = removeItem.CodeFunction_TableDrivedEntity_Parameters.ToList();
                    foreach (var removeUsedItem in removeItemUsedList)
                    {
                        removeItem.CodeFunction_TableDrivedEntity_Parameters.Remove(removeUsedItem);
                    }
                    projectContext.CodeFunctionParameter.Remove(removeItem);
                }
                foreach (var column in CodeFunction.Parameters)
                {
                    CodeFunctionParameter dbColumn = dbCodeFunction.CodeFunctionParameter.FirstOrDefault(x => x.ParamName == column.ParameterName);
                    if (dbColumn == null)
                    {
                        dbColumn = new DataAccess.CodeFunctionParameter();
                        dbCodeFunction.CodeFunctionParameter.Add(dbColumn);
                    }
                    dbColumn.ParamName = column.ParameterName;
                    dbColumn.DataType  = column.DataType;


                    //if (column.ColumnID != 0)
                    //{
                    //    var parameterUsed = dbColumn.CodeFunction_TableDrivedEntity_Parameters.FirstOrDefault(x => x.CodeFunction_TableDrivedEntity == entityRelation && x.ColumnID == column.ColumnID);
                    //    if(parameterUsed==null)
                    //    {
                    //        parameterUsed = new CodeFunction_TableDrivedEntity_Parameters();
                    //        parameterUsed.ColumnID = column.ColumnID;
                    //        parameterUsed.CodeFunctionParameter = dbColumn;
                    //        parameterUsed.CodeFunction_TableDrivedEntity = entityRelation;
                    //        dbColumn.CodeFunction_TableDrivedEntity_Parameters.Add(parameterUsed);
                    //    }
                    //}
                }

                //var codeFunctionEntity = dbCodeFunction.CodeFunction_TableDrivedEntity.FirstOrDefault(x => x.TableDrivedEntityID == CodeFunction.EntityID);
                //if (codeFunctionEntity == null)
                //{
                //    codeFunctionEntity = new CodeFunction_TableDrivedEntity();
                //    dbCodeFunction.CodeFunction_TableDrivedEntity.Add(codeFunctionEntity);
                //}


                projectContext.SaveChanges();

                return(dbCodeFunction.ID);
            }
        }