/// <summary> /// Параметры функции /// PARAM_LOCALE - локаль клиентского устройства /// </summary> /// <param name="Parameters">Параметры</param> /// <returns></returns> public override CFunctionResult Execute(Dictionary<string, object> Parameters) { CFunctionResult Result = new CFunctionResult(); CultureInfo ClientCulture = (Parameters.ContainsKey(CServerFunctionParams.CONST_FUNC_PARAM_LOCALE) ? CultureInfo.GetCultureInfo((int)Parameters[CServerFunctionParams.CONST_FUNC_PARAM_LOCALE]) : CultureInfo.CurrentCulture); foreach (CNotificationConfiguration Config in CFunctionExecutionEnvironment.ApplicationServerConfiguration.Notifications) { if (Config.Type == EnNotificationApplicationType.EUserInterfaceNotification) { CNotificationRequest Request = new CNotificationRequest(); Request.Date = DateTime.Now; Request.Header = CGlobalizationHelper.sGetStringResource("MSG_CALL_OFICIANT", ClientCulture); Request.ID = Guid.NewGuid(); Request.Name = CGlobalizationHelper.sGetStringResource("MSG_CALL_OFICIANT", ClientCulture); Request.Source = CFunctionExecutionEnvironment.ApplicationServerConfiguration.Name; Request.Content = CGlobalizationHelper.sGetStringResource("MSG_DEVICE_NAME", ClientCulture); CCommunicationClient.sRequestNotificationAsync(Request, Config.Address); } } Result.ErrorCode = -1; Result.ResultType = EnFunctionResultType.ESuccess; Result.InputParameters = Parameters; Result.Message = CGlobalizationHelper.sGetStringResource("ERROR_MSG_SUCCESS", ClientCulture); Result.Content = ""; return Result; }
/// <summary> /// Параметры функции /// PARAM_ORDER - заказ /// PARAM_LOCALE - локаль клиентского устройства /// </summary> /// <param name="Parameters">Параметры</param> /// <returns></returns> public override CFunctionResult Execute(Dictionary<string, object> Parameters) { CFunctionResult Result = new CFunctionResult(); CultureInfo ClientCulture = (Parameters.ContainsKey(CServerFunctionParams.CONST_FUNC_PARAM_LOCALE) ? CultureInfo.GetCultureInfo((int)Parameters[CServerFunctionParams.CONST_FUNC_PARAM_LOCALE]) : CultureInfo.CurrentCulture); CFunctionExecutionEnvironment.CurrentUser.GetPolicies(CFunctionExecutionEnvironment.sGetCurrentProvider()); CFunctionExecutionEnvironment.CurrentUser.GetSecurityRecords(CFunctionExecutionEnvironment.sGetCurrentProvider()); if (!Parameters.ContainsKey(CServerFunctionParams.CONST_FUNC_PARAM_OBJECT)) return this._compileResult(EnFunctionResultType.EError, Parameters, CGlobalizationHelper.sGetStringResource("ERROR_MSG_INPUT_ORDER_NULL", ClientCulture)); if (!CFunctionExecutionEnvironment.CurrentUser.PolicyAllowEditOrdersList()) return this._compileResult(EnFunctionResultType.EError, Parameters, CGlobalizationHelper.sGetStringResource("ERROR_MSG_USER_UNABLE_TO_EDIT_ORDERS", ClientCulture)); string OrderJSON = (string)Parameters[CServerFunctionParams.CONST_FUNC_PARAM_OBJECT]; CMenuServiceOrder Order = (CMenuServiceOrder)CSerialize.sDeserializeJSONStream(OrderJSON.ToDataStream(), typeof(CMenuServiceOrder)); if (Order == null) return this._compileResult(EnFunctionResultType.EError, Parameters, CGlobalizationHelper.sGetStringResource("ERROR_MSG_BAD_ORDER", ClientCulture)); Order.Key = CDatabaseSequence.sGetObjectKey(CFunctionExecutionEnvironment.sGetCurrentProvider()); Order.OrderInsert(CFunctionExecutionEnvironment.sGetCurrentProvider()); foreach (CNotificationConfiguration Config in CFunctionExecutionEnvironment.ApplicationServerConfiguration.Notifications) { if (Config.Type == EnNotificationApplicationType.EUserInterfaceNotification) { CNotificationRequest Request = new CNotificationRequest(); Request.Date = DateTime.Now; Request.Header = CGlobalizationHelper.sGetStringResource("MSG_MAKE_ORDER", ClientCulture); Request.ID = Guid.NewGuid(); Request.Name = CGlobalizationHelper.sGetStringResource("MSG_MAKE_ORDER", ClientCulture); Request.Source = CFunctionExecutionEnvironment.ApplicationServerConfiguration.Name; Request.Content = CGlobalizationHelper.sGetStringResource("MSG_DEVICE_NAME", ClientCulture); CCommunicationClient.sRequestNotificationAsync(Request, Config.Address); } if (Config.Type == EnNotificationApplicationType.ELocalNetworkPrinter) { /// Отправка на принтер } } Result.ErrorCode = -1; Result.ResultType = EnFunctionResultType.ESuccess; Result.InputParameters = Parameters; Result.Message = CGlobalizationHelper.sGetStringResource("ERROR_MSG_SUCCESS", ClientCulture); Result.Content = Order; return Result; }
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 IAsyncResult sRequestNotificationAsync(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(); NotificationRequestedDelegateCaller Delegate = new NotificationRequestedDelegateCaller(channel.RequestNotification); return Delegate.BeginInvoke(Request, _notificationsCallback, null); }
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; }