public CNotificationResponse RequestNotification(CNotificationRequest Request) { CNotificationResponse R = new CNotificationResponse(); if (OnNotificationArrived == null) { R.ID = Guid.NewGuid(); R.ErrorCode = -2; R.Name = "Notification Response"; R.Message = CGlobalizationHelper.sGetStringResource("ERROR_MSG_UNABLE_SHOW_NOTIFICATION", CultureInfo.CurrentCulture); R.Content = CGlobalizationHelper.sGetStringResource("ERROR_MSG_UNABLE_SHOW_NOTIFICATION", CultureInfo.CurrentCulture); return R; } OnNotificationArrived(Request); R.ID = Guid.NewGuid(); R.ErrorCode = -1; R.Name = "Notification Response"; R.Message = CGlobalizationHelper.sGetStringResource("ERROR_MSG_SHOW_NOTIFICATION", CultureInfo.CurrentCulture); R.Content = CGlobalizationHelper.sGetStringResource("ERROR_MSG_SHOW_NOTIFICATION", CultureInfo.CurrentCulture); return R; }
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; }
static void CCommunicationClient_OnNotificationRequested(CNotificationResponse Result) { var i = 0; }
public static CNotificationResponse sRequestNotification(CNotificationRequest Request, string ServerAddress) { CNotificationResponse R = null; 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<INotificationServer> factory = new ChannelFactory<INotificationServer>(binding, address); INotificationServer channel = factory.CreateChannel(); try { R = channel.RequestNotification(Request); } 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; }