public T GetConfiguration <T>() where T : class, new()
        {
            if (typeof(T) == typeof(GatewayConfig))
            {
                GatewayConfig gatewayConfig = new GatewayConfig
                {
                    Channels = new ChannelCollection
                    {
                        new ChannelConfig
                        {
                            Address     = "http://Headquarter.mycorp.com/",
                            Default     = true,
                            ChannelType = "Http"
                        },
                        new ChannelConfig
                        {
                            Address     = "http://Headquarter.myotherdomain.com/",
                            ChannelType = "Http"
                        },
                    }
                };

                return(gatewayConfig as T);
            }

            // To in app.config for other sections not defined in this method, otherwise return null.
            return(ConfigurationManager.GetSection(typeof(T).Name) as T);
        }
Exemplo n.º 2
0
        /// <summary>
        /// Displays the gateway.
        /// </summary>
        private void DisplayGateway()
        {
            if (!string.IsNullOrEmpty(this.GatewayId))
            {
                // Retrieve and display the gateway configuration
                GatewayConfig gatewayConfig = GatewayConfig.SingleOrDefault(g => g.Id == this.GatewayId);
                if (gatewayConfig != null)
                {
                    // Display the gateway information
                    txtName.Text                = gatewayConfig.Id;
                    txtPhoneNo.Text             = gatewayConfig.OwnNumber;
                    chkConnectAtStartup.Checked = gatewayConfig.AutoConnect.Value;
                    GatewayFunction functions = (GatewayFunction)Enum.Parse(typeof(GatewayFunction), gatewayConfig.Functions.ToString());
                    if ((functions & GatewayFunction.SendMessage) == GatewayFunction.SendMessage)
                    {
                        chkSendMessage.Checked = true;
                    }
                    if ((functions & GatewayFunction.ReceiveMessage) == GatewayFunction.ReceiveMessage)
                    {
                        chkReceiveMessage.Checked = true;
                    }
                    cboLogType.Text = gatewayConfig.LogSettings;
                    chkClearLogOnConnect.Checked = gatewayConfig.ClearLogOnConnect.Value;
                    cboPort.Text                 = gatewayConfig.ComPort;
                    cboBaudRate.Text             = gatewayConfig.BaudRate;
                    cboHandshake.Text            = gatewayConfig.Handshake;
                    cboDataBits.Text             = gatewayConfig.DataBits;
                    cboParity.Text               = gatewayConfig.Parity;
                    cboStopBits.Text             = gatewayConfig.StopBits;
                    updCommandTimeout.Value      = gatewayConfig.CommandTimeout.Value;
                    updReadIntervalTimeout.Value = gatewayConfig.ReadTimeout.Value;
                    updCommandDelay.Value        = gatewayConfig.CommandDelay.Value;
                    txtSmsc.Text                 = gatewayConfig.Smsc;

                    chkUseSmscFromSim.Checked = gatewayConfig.UseSimSmsc.Value;
                    cboMessageMemory.Text     = gatewayConfig.MessageMemory;
                    cboMessageValidity.Text   = gatewayConfig.MessageValidity;
                    updSendRetry.Value        = gatewayConfig.SendRetry.Value;
                    updSendDelay.Value        = gatewayConfig.SendDelay.Value;
                    chkRequestDeliveryStatusReport.Checked = gatewayConfig.RequestStatusReport.Value;
                    chkDeleteAfterRetrieve.Checked         = gatewayConfig.DeleteAfterRetrieve.Value;

                    chkAutoArchiveMessageLog.Checked            = gatewayConfig.AutoArchiveLog.Value;
                    updArchiveMessageLogDay.Value               = gatewayConfig.AutoArchiveLogInterval.Value;
                    updArchiveMessageOlderThanDay.Value         = gatewayConfig.ArchiveOldMessageInterval.Value;
                    chkForwardArchivedMessageLogAsEmail.Checked = gatewayConfig.ForwardArchivedMessage.Value;
                    txtEmailAddress.Text = gatewayConfig.ForwardEmail;
                    chkDeleteArchivedMessageOlderThan.Checked  = gatewayConfig.DeleteArchivedMessage.Value;
                    updDeleteArchivedMessageOlderThanDay.Value = gatewayConfig.DeleteArchivedMessageInterval.Value;

                    updRefreshSignalInterval.Value = gatewayConfig.SignalRefreshInterval.Value;
                    txtPin.Text = gatewayConfig.Pin;
                    chkAutoResponseCall.Checked = gatewayConfig.AutoResponseCall.Value;
                    txtAutoResponseText.Text    = gatewayConfig.AutoResponseCallText;

                    txtName.Enabled = false;
                    this.IsUpdate   = true;
                }
            }
        }
        /// <summary>
        /// Deletes the channel.
        /// </summary>
        private void DeleteChannel()
        {
            GatewayConfig gatewayConfig = lvwChannels.SelectedObject as GatewayConfig;

            if (gatewayConfig != null)
            {
                DialogResult result = FormHelper.Confirm(string.Format(Resources.MsgConfirmDeleteGateway, gatewayConfig.Id));
                if (result == DialogResult.Yes)
                {
                    // Delete the gateway configuration
                    GatewayConfig.Delete(g => g.Id == gatewayConfig.Id);

                    /*
                     * this.lvwChannels.RemoveObject(gatewayConfig);
                     * this.lvwChannels.RefreshObjects(this.lvwChannels.SelectedObjects);
                     */

                    //this.lvwChannels.ClearObjects();
                    //ShowChannels();

                    this.lvwChannels.RemoveObjects(this.lvwChannels.SelectedObjects);

                    if (GatewayRemoved != null)
                    {
                        // Raise the event
                        GatewayEventHandlerArgs arg = new GatewayEventHandlerArgs(gatewayConfig.Id);
                        this.GatewayRemoved.BeginInvoke(this, arg, new AsyncCallback(this.AsyncCallback), null);
                    }
                }
            }
            else
            {
                FormHelper.ShowInfo(Resources.MsgGatewayMustBeSelected);
            }
        }
Exemplo n.º 4
0
        private GatewayConfig GetValue(INIDocument doc)
        {
            GatewayConfig config = new GatewayConfig();

            doc.Load();
            Type clazz = config.GetType();

            foreach (INISection section in doc.Sections)
            {
                foreach (INIKey key in section.Keys)
                {
                    PropertyInfo pi    = clazz.GetProperty(key.Name);
                    object       value = key.Value;
                    if (pi.PropertyType == typeof(int))
                    {
                        value = Convert.ToInt32(value);
                    }
                    if (pi != null && !pi.PropertyType.IsGenericType)
                    {
                        pi.SetValue(config, value, null);
                    }
                }
            }
            return(config);
        }
Exemplo n.º 5
0
        public T GetConfiguration <T>() where T : class, new()
        {
            if (typeof(T) == typeof(GatewayConfig))
            {
                GatewayConfig gatewayConfig = new GatewayConfig
                {
                    Sites = new SiteCollection
                    {
                        new SiteConfig
                        {
                            Key         = "SiteA",
                            Address     = "http://SiteA.mycorp.com/",
                            ChannelType = "Http"
                        },
                        new SiteConfig
                        {
                            Key         = "SiteB",
                            Address     = "http://SiteB.mycorp.com/",
                            ChannelType = "Http"
                        }
                    }
                };

                return(gatewayConfig as T);
            }

            // To in app.config for other sections not defined in this method, otherwise return null.
            return(ConfigurationManager.GetSection(typeof(T).Name) as T);
        }
Exemplo n.º 6
0
 public MoviesServiceMock(ILogger <MoviesServiceMock> logger,
                          IShimonService shimonService,
                          IOptions <GatewayConfig> gatewayOptions)
 {
     _logger        = logger;
     _shimonService = shimonService;
     _gatewayConfig = gatewayOptions.Value;
 }
Exemplo n.º 7
0
        static void Main(string[] args)
        {
            GatewayConfig config = SystemConfigTool.Current;

            AirApplication.Prepared(config);

            Console.ReadKey(false);
        }
Exemplo n.º 8
0
        private static GatewayConfig GetConfig()
        {
            GatewayConfig result = new GatewayConfig();
            INIDocument   doc    = new INIDocument(path);

            doc.Load();
            result = new SystemConfigTool().GetValue(doc);
            return(result);
        }
Exemplo n.º 9
0
        private static void Prepared(GatewayConfig config)
        {
            //
            _listener = new GatewayTcpListener();
            _listener.ListenPort(config.ServerTcpPort, config.ClientTcpPort);

            gateway = new GatewayCommunication(_listener);
            gateway.Run();
        }
Exemplo n.º 10
0
        public Gateway(GatewayConfig config, IAuthenticator authenticator)
        {
            _webMessageSocket = new WebMessageSocket();
            _authenticator    = authenticator;
            _gatewayConfig    = config;

            eventHandlers     = GetEventHandlers();
            operationHandlers = GetOperationHandlers();

            PrepareSocket();
        }
        /// <summary>
        /// Gateways the form_ gateway added.
        /// </summary>
        /// <param name="sender">The sender.</param>
        /// <param name="e">The e.</param>
        private void gatewayForm_GatewayAdded(object sender, GatewayEventHandlerArgs e)
        {
            GatewayConfig newChannel = GatewayConfig.SingleOrDefault(g => g.Id == e.GatewayId);

            this.lvwChannels.AddObject(newChannel);
            if (GatewayAdded != null)
            {
                // Raise the event
                GatewayEventHandlerArgs arg = new GatewayEventHandlerArgs(e.GatewayId);
                this.GatewayAdded.BeginInvoke(this, arg, new AsyncCallback(this.AsyncCallback), null);
            }
        }
        /// <summary>
        /// Invoked when a gateway is updated
        /// </summary>
        /// <param name="sender">The sender.</param>
        /// <param name="e">The e.</param>
        private void gatewayForm_GatewayUpdated(object sender, GatewayEventHandlerArgs e)
        {
            GatewayConfig updatedChannel = GatewayConfig.SingleOrDefault(g => g.Id == e.GatewayId);

            // Refresh the list view
            RefreshView();

            if (GatewayUpdated != null)
            {
                // Raise the event
                GatewayEventHandlerArgs arg = new GatewayEventHandlerArgs(e.GatewayId);
                this.GatewayUpdated.BeginInvoke(this, arg, new AsyncCallback(this.AsyncCallback), null);
            }
        }
        /// <summary>
        /// Handles the SelectedIndexChanged event of the cboChannel control.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="System.EventArgs"/> instance containing the event data.</param>
        private void cboChannel_SelectedIndexChanged(object sender, EventArgs e)
        {
            string selectedChannel = cboChannel.Text;
            string[] values = selectedChannel.Split(new string[] { GuiHelper.FieldSplitter }, StringSplitOptions.RemoveEmptyEntries);
            selectedChannel = string.Empty;
            for (int i = 0; i < values.Length - 1; i++)
            {
                selectedChannel += values[i];
            }

            GatewayConfig gw = GatewayConfig.SingleOrDefault(g => g.Id == selectedChannel);
            if (gw != null)
                txtFrom.Text = gw.OwnNumber;            
        }
        /// <summary>
        /// Checks the channels.
        /// </summary>
        private void CheckChannels()
        {
            try
            {
                List <ChannelStatusView> channels = new List <ChannelStatusView>();
                while (true)
                {
                    channels.Clear();
                    foreach (GatewayConfig gwConfig in GatewayConfig.All().OrderBy(gw => gw.Id))
                    {
                        try
                        {
                            EventAction action = new EventAction(StringEnum.GetStringValue(EventNotificationType.QueryGatewayStatus));
                            action.ActionType = EventAction.Synchronous;
                            action.Values.Add(EventParameter.GatewayId, gwConfig.Id);
                            EventResponse response = RemotingHelper.NotifyEvent(ServiceEventListenerUrl, action);

                            ChannelStatusView channel = new ChannelStatusView();
                            channel.Name = gwConfig.Id;
                            channel.Port = gwConfig.ComPort;

                            if (StringEnum.GetStringValue(EventNotificationResponse.Failed).Equals(response.Status))
                            {
                                channel.Status = StringEnum.GetStringValue(GatewayStatus.Stopped);
                            }
                            else
                            {
                                channel.Status         = response.Results[EventParameter.GatewayStatus];
                                channel.Operator       = response.Results[EventParameter.GatewayOperator];
                                channel.SignalStrength = response.Results[EventParameter.GatewaySignalStrength];
                            }

                            channels.Add(channel);
                        }
                        catch (Exception ex)
                        {
                            log.Error(string.Format("Error checking channel - [{0}]", gwConfig.Id));
                            log.Error(ex.Message, ex);
                        }
                    }
                    RefreshView(channels);
                    Thread.Sleep(ChannelPollingInterval);
                }
            }
            catch (Exception ex)
            {
                log.Error(ex.Message, ex);
            }
        }
Exemplo n.º 15
0
        private static void ReadGatewayConfig(XmlNode node)
        {
            int portNo1  = GetAttrInt(node, "portNo1");
            int portNo2  = GetAttrInt(node, "portNo2");
            int multiply = GetAttrIntOpt(node, "multiply", 1);
            int portIncr = (Math.Abs(portNo2 - portNo1) == 1) ? 2 : 1;

            for (int i = 0; i < multiply; i++)
            {
                GatewayConfig c = new GatewayConfig();
                c.portNo1 = portNo1 + i * portIncr;
                c.portNo2 = portNo2 + i * portIncr;
                gatewayConfigs.Add(c);
            }
        }
Exemplo n.º 16
0
        public Gateway(GatewayConfig config, IAuthenticator authenticator)
        {
            CreateSocket();
            _compressed = new MemoryStream();
            if (UseCompression)
            {
                _decompressor = new DeflateStream(_compressed, CompressionMode.Decompress);
            }

            _authenticator    = authenticator;
            _gatewayConfig    = config;
            eventHandlers     = GetEventHandlers();
            operationHandlers = GetOperationHandlers();

            //       PrepareSocket();
        }
Exemplo n.º 17
0
        public Gateway(IServiceProvider serviceProvider, GatewayConfig config, IAuthenticator authenticator)
        {
            ServiceProvider = serviceProvider;
            Logger          = serviceProvider.GetService <ILogger <Gateway> >();

            CreateSocket();
            _compressed = new MemoryStream();
            if (UseCompression)
            {
                _decompressor = new DeflateStream(_compressed, CompressionMode.Decompress);
            }

            _authenticator    = authenticator;
            _gatewayConfig    = config;
            eventHandlers     = GetEventHandlers();
            operationHandlers = GetOperationHandlers();
        }
        /// <summary>
        /// Edits the channel.
        /// </summary>
        private void EditChannel()
        {
            object obj = lvwChannels.SelectedObject;

            if (obj != null)
            {
                GatewayConfig gwConfig = obj as GatewayConfig;

                frmGateway gatewayForm = new frmGateway();
                gatewayForm.GatewayUpdated += new UpdateGatewayEventHandler(gatewayForm_GatewayUpdated);
                gatewayForm.GatewayId       = gwConfig.Id;

                DialogResult result = gatewayForm.ShowDialog();
                //if (result == DialogResult.OK)
                // Autoresize
                //this.lvwChannels.AutoResizeColumn(0, ColumnHeaderAutoResizeStyle.ColumnContent);
            }
        }
        /// <summary>
        /// Shows the channels.
        /// </summary>
        private void ShowChannels()
        {
            lvwChannels.BeginUpdate();

            this.olvColumn1.ImageGetter = delegate(object row)
            {
                return(1);
            };
            this.olvColumn1.AspectGetter = delegate(object x) { return(((GatewayConfig)x).Id); };
            this.olvColumn2.AspectGetter = delegate(object x) { return(((GatewayConfig)x).ComPort); };
            this.olvColumn3.AspectGetter = delegate(object x) { return(((GatewayConfig)x).BaudRate); };
            this.olvColumn4.AspectGetter = delegate(object x) { return(Resources.MsgTypeSms); };
            this.olvColumn5.AspectGetter = delegate(object x) { return(Resources.ProtocolTypeGsm); };

            lvwChannels.SetObjects(GatewayConfig.All());
            //lvwChannels.AutoResizeColumn(0, ColumnHeaderAutoResizeStyle.ColumnContent);
            //lvwChannels.AutoResizeColumn(2, ColumnHeaderAutoResizeStyle.HeaderSize);

            lvwChannels.EndUpdate();
        }
Exemplo n.º 20
0
 public ClientConfig()
 {
     Identify = new Identify
     {
         IsCompress = true,
         Properties = new IdentifyProperties
         {
             OS      = Environment.OSVersion.Platform.ToString(),
             Browser = "DiscordCs",
             Device  = "DiscordCs"
         },
         LargeThreshold = 50,
         Presence       = new PresenceStatusUpdate
         {
             Status = PresenceStatus.Online
         },
         Intents = IdentifyIntent.Default,
         IsGuildSubscriptions = false
     };
     GatewayConfig = new GatewayConfig
     {
         BaseUrl  = "wss://gateway.discord.gg",
         Version  = 8,
         Encoding = "json"
     };
     Gateway = new GatewayContext();
     Logger  = new Logger
     {
         Level = LoggingLevel.Warning
     };
     CacheContext = new CacheContext(new CacheConfig
     {
     });
     RestConfig = new RestConfig
     {
         BaseUrl = "https://discord.com",
         Version = 8
     };
     Rest = new RestContext();
 }
 /// <summary>
 /// Shows the messages.
 /// </summary>
 public void RefreshView()
 {
     if (this.lvwChannels.InvokeRequired)
     {
         SetListCallback callback = new SetListCallback(RefreshView);
         this.Invoke(callback);
     }
     else
     {
         GatewayConfig selectedConfig = lvwChannels.SelectedObject as GatewayConfig;
         lvwChannels.BeginUpdate();
         lvwChannels.ClearObjects();
         lvwChannels.SetObjects(GatewayConfig.All());
         //lvwChannels.AutoResizeColumn(0, ColumnHeaderAutoResizeStyle.ColumnContent);
         //lvwChannels.AutoResizeColumn(2, ColumnHeaderAutoResizeStyle.HeaderSize);
         if (selectedConfig != null)
         {
             lvwChannels.SelectObject(selectedConfig);
         }
         lvwChannels.EndUpdate();
         lvwChannels.Refresh();
     }
 }
Exemplo n.º 22
0
        public void Init()
        {
            var config = new GatewayConfig {
                MerchantId     = "heartlandgpsandbox",
                AccountId      = "api",
                SharedSecret   = "secret",
                RebatePassword = "******",
                RefundPassword = "******",
                ServiceUrl     = "https://api.sandbox.realexpayments.com/epage-remote.cgi"
            };

            ServicesContainer.ConfigureService(config);

            config.AccountId = "apidcc";
            ServicesContainer.ConfigureService(config, "dcc");

            card = new CreditCardData {
                Number         = "4111111111111111",
                ExpMonth       = 12,
                ExpYear        = 2025,
                Cvn            = "123",
                CardHolderName = "Joe Smith"
            };
        }
Exemplo n.º 23
0
 public HostedService(GatewayConfig config)
 {
     _config = config;
     ServicesContainer.ConfigureService(config);
 }
Exemplo n.º 24
0
        // This method gets called by the runtime. Use this method to add services to the container.
        public void ConfigureServices(IServiceCollection services)
        {
            //configure snakecase request/response
            services.AddControllers().AddJsonOptions(
                options =>
            {
                options.JsonSerializerOptions.PropertyNamingPolicy =
                    SnakeCaseNamingPolicy.Instance;
            });

            //automapper
            var mapperConfiguration = new MapperConfiguration(
                cfg => { cfg.AddProfile(new CustomerMapper()); }
                );

            //configuration mongo and gateway
            var settings = new ConnectionMongoSettings();

            Configuration.GetSection("ConnectionMongoSettings").Bind(settings);

            var gatewayConfig = new GatewayConfig();

            Configuration.GetSection("GatewayConfig").Bind(gatewayConfig);

            var seqConfig = new SeqConfig();

            Configuration.GetSection("SeqConfig").Bind(seqConfig);

            Console.WriteLine(settings.ConnectionString);
            Console.WriteLine(gatewayConfig.Url);
            Console.WriteLine(gatewayConfig.SecretKey);

            // connection mongo and create request
            services.AddSingleton <IMongoDatabase>(_ =>
            {
                var client = new MongoClient(settings.ConnectionString);
                return(client.GetDatabase(settings.DatabaseName));
            });

            services.AddSingleton <IRestRequest>(_ =>
            {
                var request = new RestRequest();

                request.AddHeader("Content-Type", "application/json");
                return(request);
            });

            services.AddSingleton <IRestClient>(_ =>
            {
                var restClient           = new RestClient(gatewayConfig.Url + "/{endpoint}");
                restClient.Authenticator = new HttpBasicAuthenticator(gatewayConfig.SecretKey, "");
                return(restClient);
            });

            //restSharp
            SimpleJson.CurrentJsonSerializerStrategy = new SnakeJsonSerializerStrategy();

            // seq log
            services.AddSingleton <ILogInfo>(_ =>
            {
                var seq = new LoggerConfiguration()
                          .WriteTo.Console()
                          .WriteTo.Seq(seqConfig.Url)
                          .CreateLogger();

                return(new LogInfo(seq));
            });

            //service core
            services.AddScoped <ICustomerService, CustomerService>();

            //services infra
            services.AddSingleton <IGatewayCustomerService, CustomerServiceInfra>(container =>
            {
                var restRequest = (IRestRequest)container.GetService(typeof(IRestRequest));
                var restClient  = (IRestClient)container.GetService(typeof(IRestClient));
                var logInfo     = (ILogInfo)container.GetService(typeof(ILogInfo));

                return(new CustomerServiceInfra(restRequest, restClient, mapperConfiguration, logInfo));
            });

            //repositories
            services.AddScoped <ICustomerRepository, CustomerRepository>();

            //heathCheck
            services
            .AddHealthChecks()
            .AddMongoDb(settings.ConnectionString, name: "MongoCheck", timeout: TimeSpan.FromSeconds(2))
            .AddUrlGroup(
                options =>
            {
                options.AddUri(new Uri($"{gatewayConfig.Url}/customers"));
                options.UseHttpMethod(Post);
                options.ExpectHttpCodes(200, 401);
            },
                "MundipaggGatewayCheck",
                timeout: TimeSpan.FromSeconds(10)
                );

            //doc swagger
            services.AddSwaggerGen(container =>
            {
                container.SwaggerDoc("v1", new OpenApiInfo {
                    Title = "My API", Version = "v1"
                });
            }
                                   );
        }
Exemplo n.º 25
0
        /// <inheritdoc/>
        public async Task <bool> InitializeGateway([NotNull] string accessToken)
        {
            BasicRestFactory      restFactory    = new BasicRestFactory();
            IGatewayConfigService gatewayService = restFactory.GetGatewayConfigService();

            try
            {
                GatewayConfig gatewayConfig = await gatewayService.GetGatewayConfig();

                IAuthenticator authenticator = new DiscordAuthenticator(accessToken);
                Gateway = new DiscordAPI.Gateway.Gateway(_serviceProvider, gatewayConfig, authenticator);
            }
            catch
            {
                Messenger.Default.Send(new ConnectionStatusMessage(ConnectionStatus.Failed));
                return(false);
            }

            Gateway.Ready             += Gateway_Ready;
            Gateway.GuildMembersChunk += GatewayGuildMembersChunk;
            Gateway.GuildSynced       += Gateway_GuildSynced;

            Gateway.GuildCreated += Gateway_GuildCreated;
            Gateway.GuildDeleted += Gateway_GuildDeleted;
            Gateway.GuildUpdated += Gateway_GuildUpdated;

            Gateway.MessageCreated += Gateway_MessageCreated;
            Gateway.MessageDeleted += Gateway_MessageDeleted;
            Gateway.MessageUpdated += Gateway_MessageUpdated;
            Gateway.MessageAck     += Gateway_MessageAck;

            Gateway.MessageReactionAdded      += Gateway_MessageReactionAdded;
            Gateway.MessageReactionRemoved    += Gateway_MessageReactionRemoved;
            Gateway.MessageReactionRemovedAll += Gateway_MessageReactionRemovedAll;

            Gateway.GuildMemberListUpdated += Gateway_GuildMemberListUpdated;

            Gateway.ChannelCreated      += Gateway_ChannelCreated;
            Gateway.ChannelDeleted      += Gateway_ChannelDeleted;
            Gateway.GuildChannelUpdated += Gateway_GuildChannelUpdated;

            Gateway.TypingStarted += Gateway_TypingStarted;

            Gateway.PresenceUpdated          += Gateway_PresenceUpdated;
            Gateway.UserNoteUpdated          += Gateway_UserNoteUpdated;
            Gateway.UserGuildSettingsUpdated += Gateway_UserGuildSettingsUpdated;
            Gateway.UserSettingsUpdated      += Gateway_UserSettingsUpdated;

            Gateway.VoiceServerUpdated += Gateway_VoiceServerUpdated;
            Gateway.VoiceStateUpdated  += Gateway_VoiceStateUpdated;

            Gateway.RelationShipAdded   += Gateway_RelationShipAdded;
            Gateway.RelationShipRemoved += Gateway_RelationShipRemoved;
            Gateway.RelationShipUpdated += Gateway_RelationShipUpdated;

            Gateway.SessionReplaced += Gateway_SessionReplaced;
            Gateway.InvalidSession  += Gateway_InvalidSession;
            Gateway.GatewayClosed   += Gateway_GatewayClosed;

            if (await ConnectWithRetryAsync(3))
            {
                _analyticsService.Log(Constants.Analytics.Events.Connected);
                Messenger.Default.Send(new ConnectionStatusMessage(ConnectionStatus.Connected));
                Messenger.Default.Register <ChannelNavigateMessage>(this, async m =>
                {
                    if (!m.Guild.IsDM)
                    {
                        await Gateway.SubscribeToGuildLazy(
                            m.Channel.GuildId,
                            new Dictionary <string, IEnumerable <int[]> >
                        {
                            {
                                m.Channel.Model.Id,
                                new List <int[]>
                                {
                                    new[] { 0, 99 },
                                }
                            },
                        });
                    }
                });
                Messenger.Default.Register <GuildNavigateMessage>(this, async m =>
                {
                    if (!m.Guild.IsDM)
                    {
                        if (previousGuildId != null)
                        {
                            await Gateway.SubscribeToGuildLazy(
                                previousGuildId,
                                new Dictionary <string, IEnumerable <int[]> > {
                            });
                        }

                        previousGuildId = m.Guild.Model.Id;
                    }
                    else
                    {
                        previousGuildId = null;
                    }
                });
                Messenger.Default.Register <GatewayRequestGuildMembersMessage>(this, async m =>
                {
                    await Gateway.RequestGuildMembers(m.GuildIds, m.Query, m.Limit, m.Presences, m.UserIds);
                });
                Messenger.Default.Register <GatewayUpdateGuildSubscriptionsMessage>(this, async m =>
                {
                    await Gateway.SubscribeToGuildLazy(m.GuildId, m.Channels, m.Members);
                });
            }

            return(true);
        }
Exemplo n.º 26
0
        public Secure3dServiceTests()
        {
            GatewayConfig config = new GatewayConfig {
                MerchantId               = "myMerchantId",
                AccountId                = "ecom3ds",
                SharedSecret             = "secret",
                MethodNotificationUrl    = "https://www.example.com/methodNotificationUrl",
                ChallengeNotificationUrl = "https://www.example.com/challengeNotificationUrl",
                Secure3dVersion          = Secure3dVersion.Any,
            };

            ServicesContainer.ConfigureService(config);

            // create card data
            card = new CreditCardData {
                Number         = "4263970000005262",
                ExpMonth       = 12,
                ExpYear        = 2025,
                CardHolderName = "John Smith"
            };

            // stored card
            stored = new RecurringPaymentMethod(
                "20190809-Realex",
                "20190809-Realex-Credit"
                );

            // shipping address
            shippingAddress = new Address {
                StreetAddress1 = "Apartment 852",
                StreetAddress2 = "Complex 741",
                StreetAddress3 = "no",
                City           = "Chicago",
                PostalCode     = "5001",
                State          = "IL",
                CountryCode    = "840"
            };

            // billing address
            billingAddress = new Address {
                StreetAddress1 = "Flat 456",
                StreetAddress2 = "House 789",
                StreetAddress3 = "no",
                City           = "Halifax",
                PostalCode     = "W5 9HR",
                CountryCode    = "826"
            };

            // browser data
            browserData = new BrowserData {
                AcceptHeader        = "text/html,application/xhtml+xml,application/xml;q=9,image/webp,img/apng,*/*;q=0.8",
                ColorDepth          = ColorDepth.TWENTY_FOUR_BITS,
                IpAddress           = "123.123.123.123",
                JavaEnabled         = true,
                Language            = "en",
                ScreenHeight        = 1080,
                ScreenWidth         = 1920,
                ChallengeWindowSize = ChallengeWindowSize.WINDOWED_600X400,
                Timezone            = "0",
                UserAgent           = "Mozilla/5.0 (Windows NT 6.1; Win64, x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/70.0.3538.110 Safari/537.36"
            };
        }
        /// <summary>
        /// Setups the message settings.
        /// </summary>
        public void SetupMessageSettings()
        {   
            // First option is any channels
            if (cboChannel.Items.Count > 0)
                cboChannel.Items.Clear();
            cboChannel.Items.Add(Resources.AnyChannels);

            // Load all channels
            foreach (GatewayConfig g in GatewayConfig.All().OrderBy(gw => gw.Id))
            {
                cboChannel.Items.Add(string.Join(GuiHelper.FieldSplitter, new string[]{g.Id, g.ComPort}));
            }
            cboChannel.SelectedIndex = 0;

            // Load message format
            cboMessageFormat.Items.Clear();
            StringEnum e = new StringEnum(typeof(MessageFormat));    
            foreach (string s in e.GetStringValues())
            {
                cboMessageFormat.Items.Add(s);
            }
            cboMessageFormat.SelectedIndex = 0;

            // Load message status report
            cboStatusReport.Items.Clear();
            e = new StringEnum(typeof(MessageStatusReport));
            foreach (string s in e.GetStringValues())
            {
                cboStatusReport.Items.Add(s);
            }
            cboStatusReport.SelectedIndex = 0;
   
            // Load message type
            cboMessageType.Items.Clear();
            e = new StringEnum(typeof(OutgoingMessageType));
            foreach (string s in e.GetStringValues())
            {
                cboMessageType.Items.Add(s);
            }
            cboMessageType.SelectedIndex = 0;

            // Load priority
            cboPriority.Items.Clear();
            cboPriority.Items.AddRange(EnumMatcher.MessagePriority.Keys.ToArray());
            cboPriority.SelectedIndex = 1;

            cboMessageClass.Items.Clear();
            cboMessageClass.Items.AddRange(EnumMatcher.MessageClass.Keys.ToArray());
            cboMessageClass.SelectedIndex = 0;

            npdQuantity.Value = 1;
            dtpScheduleTime.Value = DateTime.Now;
            //txtMessageContent.Text = string.Empty;

            // WAP push signal
            cboWapPushSignal.Items.Clear();
            cboWapPushSignal.Items.AddRange(EnumMatcher.ServiceIndication.Keys.ToArray());
            cboWapPushSignal.SelectedIndex = 0;

            if (this.Message != null)
            {
                PresetMessageDetails(this.Message);
            }
        }
Exemplo n.º 28
0
 public TCPMasterComponent(GatewayConfig gateway, MysqlMethod mysql)
 {
     InitializeComponent();
     GatewayConfig = gateway;
     MysqlMethod   = mysql;
 }
Exemplo n.º 29
0
 public GiftService(GatewayConfig config, string configName = "default")
 {
     ServicesContainer.ConfigureService(config, configName);
 }
Exemplo n.º 30
0
 static GatewayTransaction()
 {
     Config = Configure.GetConfigSection<GatewayConfig>();
 }
Exemplo n.º 31
0
        static void Main(string[] args)
        {
            try
            {
                Logger.CurrentLogger = null;
                Logger.defaultlogger = new Logger("SagaGateway.log");
                AppDomain.CurrentDomain.UnhandledException += new UnhandledExceptionEventHandler(CurrentDomain_UnhandledException);
                Console.CancelKeyPress += new ConsoleCancelEventHandler(ShutingDown);
                bool cpvalid = true;
                Console.ForegroundColor = ConsoleColor.Yellow;
                Console.WriteLine("======================================================================");
                Console.ForegroundColor = ConsoleColor.Cyan;
                Console.WriteLine("            Saga Gateway Server - Internal Beta Version               ");
                Console.WriteLine("             (C)2007 The Saga Project Development Team                ");
                Console.ForegroundColor = ConsoleColor.Yellow;
                Console.WriteLine("======================================================================");
                Console.ResetColor();
                Logger.ShowInfo("Starting Initialization...", null);
                lcfg = new GatewayConfig();
                Logger.defaultlogger.LogLevel = (Logger.LogContent)lcfg.LogLevel;
                GatewayClientManager.Instance.Start();
                ControlPanelClientManager.Instance.Start();
                if (!ControlPanelClientManager.Instance.StartNetwork(50000))
                {
                    Logger.ShowWarning("Cannot listen on port 50000 for CP!", null);
                    cpvalid = false;
                }
                Global.clientMananger = (ClientManager)GatewayClientManager.Instance;
                Init();

                if (!GatewayClientManager.Instance.StartNetwork(lcfg.Port))
                {
                    Logger.ShowError("Cannot listen on port: " + lcfg.Port, null);
                    Logger.ShowWarning("Shutting down in 20sec.", null);
                    System.Threading.Thread.Sleep(20000);
                    return;
                }

                Logger.ShowInfo("Accepting clients.", null);

                while (true)
                {
                    // keep the connections to the database servers alive
                    // let new clients (max 10) connect
                    GatewayClientManager.Instance.NetworkLoop(10);
                    if (cpvalid) ControlPanelClientManager.Instance.NetworkLoop(10);
                    // sleep 1ms
                    System.Threading.Thread.Sleep(1);
                }
            }
            catch (Exception ex)
            {
                Logger.ShowError(ex, null);
            }
        }
Exemplo n.º 32
0
 static GatewayTransaction()
 {
     Config = Configure.GetConfigSection <GatewayConfig>();
 }