예제 #1
0
        /// <summary>
        /// 构造最终对象的Json字符串
        /// </summary>
        /// <param name="arguments">参数列表</param>
        /// <param name="delegateService">委托服务</param>
        /// <returns>Json字符串</returns>
        private static string CompositeJsonValue(string arguments, IDelegateService delegateService)
        {
            var jsonValue = string.Empty;
            var arguValue = string.Empty;
            var arguList  = arguments.Split(',');

            var strBuilder = new StringBuilder(256);

            foreach (var name in arguList)
            {
                if (strBuilder.ToString() != string.Empty)
                {
                    strBuilder.Append(",");
                }

                arguValue = delegateService.GetVariableThroughly(name);
                arguValue = FormatJsonStringIfSimple(arguValue);
                strBuilder.Append(string.Format("{0}:{1}", name, arguValue));
            }

            if (strBuilder.ToString() != string.Empty)
            {
                jsonValue = string.Format("{{{0}}}", strBuilder.ToString());
            }
            return(jsonValue);
        }
예제 #2
0
        /// <summary>
        /// 构造可变数值列表
        /// </summary>
        /// <param name="arguments">参数列表</param>
        /// <param name="delegateService">委托服务</param>
        /// <returns>参数列表</returns>
        private static object[] CompositeParameterValues(string arguments, IDelegateService delegateService)
        {
            var arguList = arguments.Split(',');

            object[] valueArray = new object[arguList.Length];
            for (var i = 0; i < arguList.Length; i++)
            {
                valueArray[i] = delegateService.GetVariableThroughly(arguList[i]);
            }
            return(valueArray);
        }
예제 #3
0
 /// <summary>
 /// 执行外部方法
 /// </summary>
 /// <param name="service">Action实体</param>
 /// <param name="delegateService">委托服务</param>
 private static void ExecuteWebApiMethod(ServiceEntity service, IDelegateService delegateService)
 {
     try
     {
         object result = null;
         if (service.SubMethod == SubMethodEnum.HttpGet)
         {
             var jsonGetValue  = delegateService.GetVariableThroughly(service.Arguments);
             var url           = string.Format("{0}/{1}", service.Expression, jsonGetValue);
             var httpGetClient = HttpClientHelper.CreateHelper(url);
             result = httpGetClient.Get();
         }
         else if (service.SubMethod == SubMethodEnum.HttpPost)
         {
             string url = service.Expression;
             var    httpClientHelper = HttpClientHelper.CreateHelper(url);
             var    jsonValue        = CompositeJsonValue(service.Arguments, delegateService);
             var    httpPostClient   = HttpClientHelper.CreateHelper(url);
             result = httpClientHelper.Post(jsonValue);
         }
         else if (service.SubMethod == SubMethodEnum.HttpPut)
         {
             string url = service.Expression;
             var    httpClientHelper = HttpClientHelper.CreateHelper(url);
             var    jsonValue        = CompositeJsonValue(service.Arguments, delegateService);
             var    httpPostClient   = HttpClientHelper.CreateHelper(url);
             result = httpClientHelper.Put(jsonValue);
         }
         else if (service.SubMethod == SubMethodEnum.HttpDelete)
         {
             var jsonGetValue  = delegateService.GetVariableThroughly(service.Arguments);
             var url           = string.Format("{0}/{1}", service.Expression, jsonGetValue);
             var httpGetClient = HttpClientHelper.CreateHelper(url);
             result = httpGetClient.Delete();
         }
     }
     catch (System.Exception ex)
     {
         throw new WorkflowException(LocalizeHelper.GetEngineMessage("actionexecutor.ExecuteWebApi.exception", ex.Message));
     }
 }
예제 #4
0
        /// <summary>
        /// 构造最终对象的Json字符串
        /// </summary>
        /// <param name="arguments">参数列表</param>
        /// <param name="delegateService">委托服务</param>
        /// <returns>字典列表</returns>
        private static IDictionary <string, string> CompositeKeyValue(string arguments, IDelegateService delegateService)
        {
            var dictionary = new Dictionary <string, string>();
            var arguValue  = string.Empty;
            var arguList   = arguments.Split(',');

            foreach (var name in arguList)
            {
                arguValue = delegateService.GetVariableThroughly(name);
                dictionary.Add(name, arguValue);
            }
            return(dictionary);
        }
예제 #5
0
        /// <summary>
        /// 构造最终对象的Json字符串
        /// </summary>
        /// <param name="arguments">参数列表</param>
        /// <param name="delegateService">委托服务</param>
        /// <returns>动态参数列表</returns>
        private static DynamicParameters CompositeSqlParametersValue(string arguments, IDelegateService delegateService)
        {
            DynamicParameters parameters = new DynamicParameters();

            var arguValue = string.Empty;
            var arguList  = arguments.Split(',');

            foreach (var name in arguList)
            {
                arguValue = delegateService.GetVariableThroughly(name);
                parameters.Add(string.Format("@{0}", name), arguValue);
            }
            return(parameters);
        }