public static object sExecuteFunction(string FunctionID, string ServerAddress, EnFunctionResultFormat ResultFormat, Dictionary<string, object> Parameters) { object R = null; Parameters.Add(CServerFunctionParams.CONST_FUNC_PARAM_FUNC_ID, FunctionID); BasicHttpBinding binding = new BasicHttpBinding(); binding.MaxBufferPoolSize = Int32.MaxValue; binding.MaxReceivedMessageSize = Int32.MaxValue; binding.MaxBufferSize = Int32.MaxValue; binding.TransferMode = TransferMode.Streamed; binding.ReaderQuotas.MaxArrayLength = Int32.MaxValue; binding.ReaderQuotas.MaxBytesPerRead = Int32.MaxValue; binding.ReaderQuotas.MaxStringContentLength = Int32.MaxValue; binding.ReaderQuotas.MaxDepth = 32; EndpointAddress address = new EndpointAddress(ServerAddress); ChannelFactory<IApplicationServer> factory = new ChannelFactory<IApplicationServer>(binding, address); IApplicationServer channel = factory.CreateChannel(); string ParametersJSON = _getParametersJSON(Parameters); try { R = channel.ExecuteFunction(ParametersJSON, (int)ResultFormat); } catch (EndpointNotFoundException Ex) { R = new CNotificationResponse() { Content = Ex.Message, ErrorCode = -2, Message = CGlobalizationHelper.sGetStringResource("ERROR_MSG_SERVICE_UNAVAILABLE", CultureInfo.CurrentCulture), Name = "Notification Response" }; } catch (CommunicationException Ex) { R = new CNotificationResponse() { Content = Ex.Message, ErrorCode = -2, Message = CGlobalizationHelper.sGetStringResource("ERROR_MSG_COMMUNICATION_CLIENT_ERROR", CultureInfo.CurrentCulture), Name = "Notification Response" }; } return R; }
public static IAsyncResult sExecuteFunctionAsync(string FunctionID, string ServerAddress, EnFunctionResultFormat ResultFormat, Dictionary<string, object> Parameters) { Parameters.Add(CServerFunctionParams.CONST_FUNC_PARAM_FUNC_ID, FunctionID); BasicHttpBinding binding = new BasicHttpBinding(); binding.MaxBufferPoolSize = Int32.MaxValue; binding.MaxReceivedMessageSize = Int32.MaxValue; binding.MaxBufferSize = Int32.MaxValue; binding.TransferMode = TransferMode.Streamed; binding.ReaderQuotas.MaxArrayLength = Int32.MaxValue; binding.ReaderQuotas.MaxBytesPerRead = Int32.MaxValue; binding.ReaderQuotas.MaxStringContentLength = Int32.MaxValue; binding.ReaderQuotas.MaxDepth = 32; EndpointAddress address = new EndpointAddress(ServerAddress); ChannelFactory<IApplicationServer> factory = new ChannelFactory<IApplicationServer>(binding, address); IApplicationServer channel = factory.CreateChannel(); FunctionExecutedDelegateCaller Delegate = new FunctionExecutedDelegateCaller(channel.ExecuteFunction); string ParametersJSON = _getParametersJSON(Parameters); return Delegate.BeginInvoke(ParametersJSON, (int)ResultFormat, _functionsCallback, null); }