예제 #1
0
        private string CreateJsonData(WfApplicationRuntimeParameters context)
        {
            string result = string.Empty;

            if (_SvcOperationDef.Params.Count > 0)
            {
                Dictionary <string, object> jsonDict = new Dictionary <string, object>();

                Dictionary <string, object> headers = new Dictionary <string, object>();

                foreach (string key in this.Headers.AllKeys)
                {
                    headers[key] = this.Headers[key];
                }

                jsonDict["__Headers"]            = headers;
                jsonDict["__ConnectionMappings"] = this.ConnectionMappings;

                foreach (var item in this._SvcOperationDef.Params)
                {
                    if (item.Type == WfSvcOperationParameterType.RuntimeParameter)
                    {
                        var paraName = item.Value != null?item.Value.ToString() : string.Empty;

                        if (paraName.IsNullOrEmpty())
                        {
                            paraName = item.Name;               //流程运行时参数名与方法参数名相同
                        }
                        var paramValue = context.GetValueRecursively <object>(paraName, null);

                        if (paramValue == null)
                        {
                            throw new ArgumentException("未能在CurrentProcess.ApplicationRuntimeParameters中找到参数" + paraName);
                        }

                        jsonDict.Add(item.Name, paramValue);
                    }
                    else
                    {
                        jsonDict.Add(item.Name, item.GetDeserializedValue());
                    }
                }

                WfConverterHelper.RegisterConverters();

                result = JSONSerializerExecute.Serialize(jsonDict);
            }

            return(result);
        }
예제 #2
0
        internal static string GetCurrentAdministrativeUnitCodeName(IWfProcess process)
        {
            WfApplicationRuntimeParameters runtimeParameters = null;

            if (WfApplicationParametersContext.Current != null)
            {
                runtimeParameters = WfApplicationParametersContext.Current.ApplicationRuntimeParameters;
            }

            if (runtimeParameters == null && process != null)
            {
                runtimeParameters = process.ApplicationRuntimeParameters;
            }

            return(runtimeParameters.GetValueRecursively(AdministrativeUnitParameterName, string.Empty));
        }
예제 #3
0
        /// <summary>
        /// 构造请求字符串
        /// </summary>
        /// <param name="context"></param>
        /// <returns></returns>
        private string CreateQueryString(WfApplicationRuntimeParameters context)
        {
            StringBuilder result = new StringBuilder();

            foreach (var item in this._SvcOperationDef.Params)
            {
                if (result.Length > 0)
                {
                    result.Append("&");
                }

                result.Append(HttpUtility.UrlEncode(item.Name));
                result.Append("=");

                if (item.Type == WfSvcOperationParameterType.RuntimeParameter)
                {
                    var paraName = item.Value != null?item.Value.ToString() : "";

                    if (string.IsNullOrEmpty(paraName))
                    {
                        paraName = item.Name;           //流程运行时参数名与方法参数名相同
                    }
                    string paraVal = context.GetValueRecursively(paraName, string.Empty);

                    result.Append(HttpUtility.UrlEncode(paraVal));
                }
                else
                {
                    if (item.Value != null)
                    {
                        result.Append(HttpUtility.UrlEncode(item.Value.ToString()));
                    }
                }
            }

            return(result.ToString());
        }