private void ApplyConventions(GoModel model)
        {
            foreach (var convention in _conventions)
            {
                convention.Apply(model);
            }

            foreach (var type in model.Types)
            {
                foreach (var typeModelConvention in type.Attributes.OfType <ITypeModelConvention>())
                {
                    typeModelConvention.Apply(type);
                }

                foreach (var methodModel in type.Methods)
                {
                    foreach (var methodModelConvention in methodModel.Attributes.OfType <IMethodModelConvention>())
                    {
                        methodModelConvention.Apply(methodModel);
                    }

                    foreach (var parameterModel in methodModel.Parameters)
                    {
                        foreach (var parameterModelConvention in parameterModel.Attributes.OfType <IParameterModelConvention>())
                        {
                            parameterModelConvention.Apply(parameterModel);
                        }
                    }
                }
            }
        }
示例#2
0
        public static GoModel Build(IEnumerable <Type> types)
        {
            var goModel = new GoModel();

            Build(goModel, types);

            return(goModel);
        }
示例#3
0
 public static void Build(GoModel goModel, IEnumerable <Type> types)
 {
     foreach (var type in types)
     {
         var model = CreateModel(type);
         model.Go = goModel;
         goModel.Types.Add(model);
     }
 }
示例#4
0
            public void Apply(GoModel model)
            {
                if (model == null)
                {
                    throw new ArgumentNullException(nameof(model));
                }

                var types = model.Types.ToArray();

                foreach (var type in types)
                {
                    _typeModelConvention.Apply(type);
                }
            }
示例#5
0
            public void Apply(GoModel model)
            {
                if (model == null)
                {
                    throw new ArgumentNullException(nameof(model));
                }
                var types = model.Types.ToArray();

                foreach (var type in types)
                {
                    var methods = type.Methods.ToArray();
                    foreach (var method in methods)
                    {
                        _methodModelConvention.Apply(method);
                    }
                }
            }
示例#6
0
        public GoModel GetDataByStream(int idStream)
        {
            var result = new GoModel();

            result.nodeKeyProperty = "id";
            result.nodeDataArray   = (this.context.WF_STATE.Where(x => x.WF_ID == idStream)
                                      .Select(x => new NodeItem()
            {
                text = x.STATE_NAME,
                id = x.ID,
                loc = x.LOCATION
            })).ToList();
            var lstStep = this.context.WF_STEP.Where(x => x.WF_ID == idStream).ToList();

            foreach (var item in lstStep.ToList())
            {
                if (item.IS_RETURN == true)
                {
                    var backStep = new WF_STEP();
                    backStep.STATE_BEGIN = item.STATE_END;
                    backStep.STATE_END   = item.STATE_BEGIN;
                    //backStep.NAME = "Trả về - " + item.NAME;
                    backStep.NAME = "Trả về";
                    lstStep.Add(backStep);
                }
            }
            result.linkDataArray = (lstStep
                                    .Select(x => new StepItem()
            {
                from = x.STATE_BEGIN.Value,
                text = x.NAME,
                to = x.STATE_END.Value
            })).ToList();

            return(result);
        }
示例#7
0
        public JsonResult SaveLocation(GoModel data)
        {
            var result           = new JsonResultBO(true);
            var WF_STATEBusiness = Get <WF_STATEBusiness>();

            try
            {
                if (data.nodeDataArray != null && data.nodeDataArray.Any())
                {
                    foreach (var item in data.nodeDataArray)
                    {
                        var state = WF_STATEBusiness.Find(item.id);
                        state.LOCATION = item.loc;
                        WF_STATEBusiness.Save(state);
                    }
                }
            }
            catch
            {
                result.Status  = false;
                result.Message = "Không cập nhật được dữ liệu";
            }
            return(Json(result));
        }
示例#8
0
        public static IList <MethodDescriptor> Build(GoModel model)
        {
            var descriptors = new List <MethodDescriptor>();

            foreach (var typeModel in model.Types)
            {
                var goAttribute = typeModel.Attributes.OfType <GoAttribute>().SingleOrDefault();
                if (goAttribute == null)
                {
                    continue;
                }
                foreach (var methodModel in typeModel.Methods)
                {
                    var goRequestAttribute = methodModel.Attributes.OfType <GoRequestAttribute>().SingleOrDefault();
                    if (goRequestAttribute == null)
                    {
                        continue;
                    }

                    var interceptorDescriptors = model
                                                 .Interceptors
                                                 .Concat(typeModel.Interceptors)
                                                 .Concat(methodModel.Interceptors)
                                                 .Select(i => new InterceptorDescriptor(i))
                                                 .OrderBy(i => i.Order)
                                                 .ToArray();

                    var baseUrl = goAttribute.Url;
                    var path    = goRequestAttribute.Path;

                    if (baseUrl.EndsWith("/") && path.StartsWith("/"))
                    {
                        baseUrl = baseUrl.Substring(0, baseUrl.Length - 1);
                    }
                    if (!baseUrl.EndsWith("/") && !path.StartsWith("/"))
                    {
                        path = path.Insert(0, "/");
                    }

                    var uri = baseUrl + path;

                    var returnType = methodModel.Method.ReturnType;

                    if (returnType.IsGenericType && typeof(Task).IsAssignableFrom(returnType))
                    {
                        returnType = returnType.GenericTypeArguments[0];
                    }

                    var methodDescriptor = new MethodDescriptor
                    {
                        ClienType = typeModel.Type,
                        Codec     = methodModel.Codec,
                        InterceptorDescriptors = interceptorDescriptors,
                        Method      = goRequestAttribute.Method,
                        MethodInfo  = methodModel.Method,
                        ReturnType  = returnType,
                        UrlTemplate = new TemplateString(uri, TemplateUtilities.GetVariables(uri))
                    };

                    var parameterModels = new List <ParameterDescriptor>(methodModel.Parameters.Count);
                    foreach (var parameterModel in methodModel.Parameters)
                    {
                        var parameterTarget     = GetParameterTarget(methodDescriptor, parameterModel);
                        var parameterDescriptor = new ParameterDescriptor
                        {
                            Name           = parameterModel.ParameterName,
                            ParameterType  = parameterModel.ParameterInfo.ParameterType,
                            FormattingInfo = new ParameterFormattingInfo
                            {
                                FormatterName = GetFormatterName(parameterModel),
                                FormatterType = parameterModel.Attributes.OfType <CustomFormatterAttribute>().LastOrDefault()?.FormatterType,
                                Target        = parameterTarget
                            }
                        };

                        parameterModels.Add(parameterDescriptor);
                    }

                    methodDescriptor.Parameters = parameterModels;

                    descriptors.Add(methodDescriptor);
                }
            }

            return(descriptors);
        }