Example #1
0
        private bool IsUltraRare(TwilioConfig twilo, PokemonData pkmn)
        {
            // If no Pokemon are set, do not send text messages
            if (twilo.PokemonIds.Count == 0)
            {
                return(false);
            }

            // Check if Pokemon is in list of allowed IDs
            if (!twilo.PokemonIds.Contains(pkmn.Id))
            {
                return(false);
            }

            // Send text message if Unown, Azelf, etc
            if (pkmn.Id.IsRarePokemon())
            {
                return(true);
            }

            // Send text message if 100% Gible, Deino, and Axew
            if (Filters.MatchesIV(pkmn.IV, twilo.MinimumIV))
            {
                return(true);
            }

            return(false);
        }
Example #2
0
        public TwilioClient(IOptions <TwilioConfig> twilioConfig, System.Net.Http.HttpClient httpClient)
        {
            _twilioConfig = twilioConfig.Value;

            _innerClient = new TwilioRestClient(
                _twilioConfig.AccountSid,
                _twilioConfig.AuthToken,
                httpClient: new SystemNetHttpClient(httpClient));
        }
Example #3
0
        public static bool SendSmsMessage(string body, TwilioConfig config, string toPhoneNumber)
        {
            if (!config.Enabled)
            {
                // Twilio text message notifications not enabled
                return(false);
            }

            TwilioClient.Init(config.AccountSid, config.AuthToken);
            var message = MessageResource.Create(
                body: body,
                from: new PhoneNumber($"+1{config.FromNumber}"),
                to: new PhoneNumber($"+1{toPhoneNumber}")
                );

            //_logger.Debug($"Response: {message}");
            return(message.ErrorCode == null);
        }
Example #4
0
        public void InitializeTest()
        {
            _twilioConfig = new TwilioConfig()
            {
                AccountSid      = "YOUR-ACCOUNT-SID",
                AuthToken       = "YOUR-AUTH-TOKEN",
                FromPhoneNumber = "YOUR-TWILIO-PHONE-NUMBER"
            };

            _storageConfig = new StorageConfig()
            {
                ConnectionString = "YOUR-AZURE-STORAGE-CONNECTIONSTRING",
                Folder           = "images"
            };

            _images = new Dictionary <string, string>()
            {
                { "TestImage1.jpg", "Images\\TestImage1.jpg" },
                { "TestImage21.jpg", "Images\\TestImage2.jpg" }
            };
        }
 public TwilioInputAdapter(TwilioConfig config)
 {
     this.config = config;
 }
 public TextMessageClient(ITwilioRestClient twilioClient, IOptions <TwilioConfig> twilioConfig)
 {
     _twilioClient = twilioClient;
     _twilioConfig = twilioConfig.Value;
 }
 public TwilioService(TwilioConfig twilioConfig, IStorageService storageService)
 {
     _twilioConfig   = twilioConfig;
     _storageService = storageService;
 }
Example #8
0
 public TwilioClient(IOptions <TwilioConfig> options)
 {
     config = options.Value;
     client = new TwilioRestClient(config.AccountSid, config.AuthToken);
 }
Example #9
0
 public SmsController(IOptions <TwilioConfig> config, ILoggerFactory loggerFactory)
 {
     _config = config.Value;
     _logger = loggerFactory.CreateLogger <SmsController>();
 }
Example #10
0
 public SMSsService(DbContext context, ISMSsServise SMSRepository, IOptions <TwilioConfig> TwilioConfig) : base()
 {
     this._twilioConfig  = TwilioConfig.Value;
     this._SMSRepository = SMSRepository;
 }
Example #11
0
        static void Main(string[] args)
        {
            string      instanceName    = ConfigurationManager.AppSettings["StreamInsight_Instance"];
            string      applicationName = ConfigurationManager.AppSettings["StreamInsight_Application"];
            IDisposable signalrServer;

            using (Server cepServer = Server.Create(instanceName))
            {
                if (cepServer.Applications.ContainsKey(applicationName))
                {
                    cepServer.Applications[applicationName].Delete();
                }

                Console.WriteLine("StreamInsight Server Up");

                ServiceHost host = new ServiceHost(cepServer.CreateManagementService());
                host.AddServiceEndpoint(typeof(IManagementService), new WSHttpBinding(SecurityMode.Message),
                                        ConfigurationManager.AppSettings["StreamInsight_ServiceHost"]);

                host.Open();

                Console.WriteLine(string.Format("StreamInsight ServiceHost online: [{0}]", ConfigurationManager.AppSettings["StreamInsight_ServiceHost"]));

                string url = ConfigurationManager.AppSettings["SignalR_Base_Url"];
                signalrServer = WebApp.Start <SignalRConfig>(url);

                Console.WriteLine(string.Format("SignalR Self-Hosted Server online: [{0}]", ConfigurationManager.AppSettings["SignalR_Base_Url"]));

                Application cepApplication = cepServer.CreateApplication(applicationName);

                TwilioConfig   config         = ReadTwilioConfig();
                RabbitMQConfig rabbitMQConfig = GetRabbitMQConfig();

                var twilioInput = cepApplication.DefineStreamable <CallEventType>(typeof(TwilioMonitoringFactory), config, EventShape.Point, null);

                var rabbitMQInput = cepApplication.DefineStreamable <CallEventType>(typeof(RabbitMQMonitoringFactory), rabbitMQConfig, EventShape.Point, null);

                //var allCalls = from call in twilioInput
                //               select call;

                //var abc = from win in twilioInput.TumblingWindow(TimeSpan.FromSeconds(1))
                //          select new CallSummary
                //          {
                //            TotalCalls = win.Count()
                //          };

                var allCalls2 = from call in rabbitMQInput
                                select call;

                //var abc2 = from win in rabbitMQInput.TumblingWindow(TimeSpan.FromSeconds(10))
                //           select new CallSummary
                //           {
                //             TotalCalls = win.Count()
                //           };

                var callsByType =
                    from call in rabbitMQInput
                    group call by call.EventType into groups
                    from abc in groups.TumblingWindow(TimeSpan.FromSeconds(5))
                    select new CallSummary
                {
                    TotalCalls = abc.Count(),
                    EventType  = groups.Key
                };

                //var callsByLocation = from call in rabbitMQInput
                //                      group call by call.Location into groups
                //                      from a in groups.TumblingWindow(TimeSpan.FromSeconds(5))
                //                      select new CallLocationSummary
                //                      {
                //                        Location = groups.Key,
                //                        Total = a.Count()
                //                      };

                var byConsoleSink = cepApplication.DefineStreamableSink <CallEventType>(typeof(ConsoleOutputFactory),
                                                                                        GetConsoleOutputConfig(QueryType.ByCall), EventShape.Point, StreamEventOrder.ChainOrdered);

                var byConsoleSummarySink = cepApplication.DefineStreamableSink <CallSummary>(typeof(ConsoleOutputFactory),
                                                                                             GetConsoleOutputConfig(QueryType.ByTotal), EventShape.Point, StreamEventOrder.ChainOrdered);

                var bySignalrSink = cepApplication.DefineStreamableSink <CallSummary>(typeof(SignalROutputFactory),
                                                                                      GetConsoleOutputConfig(QueryType.ByTotal), EventShape.Point, StreamEventOrder.ChainOrdered);

                var bySignalrLocationSummarySink = cepApplication.DefineStreamableSink <CallLocationSummary>(typeof(SignalROutputFactory),
                                                                                                             GetConsoleOutputConfig(QueryType.ByLocationSummary), EventShape.Point, StreamEventOrder.ChainOrdered);

                var bySignalrRawCallSink = cepApplication.DefineStreamableSink <CallEventType>(typeof(SignalROutputFactory),
                                                                                               GetConsoleOutputConfig(QueryType.ByCall), EventShape.Point, StreamEventOrder.ChainOrdered);

                //using (allCalls.Bind(byConsoleSink)
                //  .With(abc.Bind(byConsoleSummarySink))
                //  .With(abc2.Bind(bySignalrSink))
                //  .Run())
                //using (abc2.Bind(bySignalrSink)
                //  .Run())
                using (callsByType.Bind(bySignalrSink)
                       //.With(callsByLocation.Bind(bySignalrLocationSummarySink))
                       .With(allCalls2.Bind(bySignalrRawCallSink))
                       .Run())
                {
                    Console.WriteLine("----------------------------------------------------------------");
                    Console.WriteLine("Client is running, press Enter to exit the client");
                    Console.WriteLine("----------------------------------------------------------------");
                    Console.WriteLine(" ");
                    Console.ReadLine();
                }

                host.Close();
                signalrServer.Dispose();
            }
        }