private static void Main(string[] args) { const string clientId = "clientId"; const string clientSecret = "clientSecret"; try { var host = new ApiHost(new BasicAuth(clientId, clientSecret)); var messageApi = new MessagingApi(host); MessageResponse msg = messageApi.SendQuickMessage("DevUniverse", "+233207110652", "Welcome to planet Hubtel!", true); Console.WriteLine(msg.Status); } catch (Exception e) { if (e.GetType() == typeof(HttpRequestException)) { var ex = e as HttpRequestException; if (ex != null && ex.HttpResponse != null) { Console.WriteLine("Error Status Code " + ex.HttpResponse.Status); } } throw; } Console.ReadKey(); }
private void btnAppStart_Click(object sender, EventArgs e) { try { //监听API StartAPISocket(); if (apiHost == null) { Task t = new Task(new Action(() => { apiHost = new ApiHost(); apiHost.StartServices(); // apiHost.ConnectService(); DataTable table = apiHost.DtSericer; DataTable dt = table; if (dt != null) { // labTest.Text = "WCF启动成功"; } })); t.Start(); } } catch (Exception ex) { WriteExceptionLog(ex); } }
public void CampaignSms(CampaignDto model) { // var phoneNumbers = from p in _db.Donors //select new { p.Phone }; string clientId = _config.GetValue <string>("Sms:ClientId"); string clientSecret = _config.GetValue <string>("Sms:ClientSecret"); StringBuilder builder = new StringBuilder(); builder.Append("Donor Trace Campaign"); builder.AppendLine(); builder.Append("Organization: " + " " + model.Organization); builder.AppendLine(); builder.Append("Description: " + " " + model.Description); builder.AppendLine(); builder.Append("Location: " + " " + model.Location); builder.AppendLine(); builder.Append("Date: " + " " + model.EventDate); var host = new ApiHost(new BasicAuth(clientId, clientSecret)); var messageApi = new MessagingApi(host); // foreach (var p in phoneNumbers) // { MessageResponse msg = messageApi.SendQuickMessage("Donor Trace", "0242229571", builder.ToString(), true); //} // return Ok(); }
public void HubtrlMessage(string num, string info) { const string clientId = "eesuojtu"; const string clientSecret = "shfgzcjx "; //try //{ var host = new ApiHost(new BasicAuth(clientId, clientSecret)); var messageApi = new MessagingApi(host); MessageResponse msg = messageApi.SendQuickMessage("COCA-COLA", num, info, true); Console.WriteLine(msg.Status); //} //catch (Exception e) //{ // if (e.GetType() == typeof(HttpRequestException)) // { // var ex = e as HttpRequestException; // if (ex != null && ex.HttpResponse != null) // { // Console.WriteLine("Error Status Code " + ex.HttpResponse.Status); // } // } // throw; //} //Console.ReadKey(); }
public Launcher() { InitializeComponent(); host = new ApiHost(); host.StartHost(); }
public SharificabusService([NotNull] ILog log, [NotNull] ApiHost apiHost) { _log = log ?? throw new ArgumentNullException(nameof(log)); _apiHost = apiHost ?? throw new ArgumentNullException(nameof(apiHost)); InitializeComponent(); }
private static void Main(string[] args) { const string clientId = "hqikydyh"; const string clientSecret = "kakdxpvd"; try { var host = new ApiHost(new BasicAuth(clientId, clientSecret)); var messageApi = new MessagingApi(host); MessageResponse msg = messageApi.SendQuickMessage("Arsene", "+233247063817", "Hello Big Bro!", true); Console.WriteLine(msg.Status); } catch (Exception e) { if (e.GetType() == typeof(HttpRequestException)) { var ex = e as HttpRequestException; if (ex != null && ex.HttpResponse != null) { Console.WriteLine("Error Status Code " + ex.HttpResponse.Status); } } throw; } Console.ReadKey(); }
public Launcher() { InitializeComponent(); try { // This currently is designed to throw errors so we can // see what errors are common in production host = new ApiHost(); host.StartHost(); Configuration configuration = ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel.None); baseURL = configuration.AppSettings.Settings["BaseURL"].Value; computerKey = configuration.AppSettings.Settings["ComputerKey"].Value; } catch (Exception e) { if (e.InnerException.Message.Contains(":8099")) { MessageBox.Show("Port 8099 is already in use. Perhapse the launcher is already running, or running as another user?"); } else { MessageBox.Show(e.ToString()); } throw(e); // this gets eaten by the startup of the app but it does STOP the app } txtUrl.Text = baseURL; txtComputerKey.Text = computerKey; this.WindowState = FormWindowState.Minimized; }
private static void Main(string[] args) { const string clientId = "mcjntyvj"; const string clientSecret = "csidlcvn"; try { var host = new ApiHost(new BasicAuth(clientId, clientSecret)); var messageApi = new MessagingApi(host); MessageResponse msg = messageApi.SendQuickMessage("BPCI", "+233274323816", "Welcome to BPCI HQ!", false); Console.WriteLine(msg.Status); } catch (Exception e) { if (e.GetType() == typeof(HttpRequestException)) { var ex = e as HttpRequestException; if (ex != null && ex.HttpResponse != null) { Console.WriteLine("Error Status Code " + ex.HttpResponse.Status); } } throw; } Console.ReadKey(); }
public void SetUp() { var host = new ApiHost(); host.Initialize(); _client = host.CreateTestClient(); BaseAddress = host.BaseAddress; }
public void SendBulkSMS() { var host = new ApiHost(new BasicAuth(ClientCredentials.GetClientId(), ClientCredentials.GetSecret())); var messageApi = new MessagingApi(host); MessageResponse msg = messageApi.SendQuickMessage(MessageId, Phone, MessageBody, RegisteredDelivery); Console.WriteLine("Message Sent Successfully to " + Phone); }
public ApiUseForwardedHeaders() { ApiHost = new ApiHost(IdentityServerHost, "scope1", useForwardedHeaders: true); ApiHost.InitializeAsync().Wait(); BffHost = new BffHost(IdentityServerHost, ApiHost, "spa", useForwardedHeaders: false); BffHost.InitializeAsync().Wait(); }
public static Task SendSms(string phoneNumber, string message) { var clientId = ConfigurationManager.AppSettings["ClientId"]; var clientSecret = ConfigurationManager.AppSettings["ClientSecret"]; var host = new ApiHost(new BasicAuth(clientId, clientSecret)); new MessagingApi(host).SendQuickMessage(ConfigurationManager.AppSettings["SenderName"], phoneNumber, message, true); return(Task.FromResult(0)); }
public Service(ILoggerConfiguration config, IScheduleHelper scheduleHelper, ApiHost api) { _config = config; _scheduleHelper = scheduleHelper; _api = api; InitializeComponent(); ServiceConfiguration(); }
protected override void RegisterContainer(IServiceProvider services) { base.RegisterContainer(services); var cfg = new ApiConfig() { }; var apiHost = new ApiHost(cfg) .WithContainer(Container); }
public int doSMSJob() { string formattedPhone = ""; var host = new ApiHost(new BasicAuth(ClientCredentials.GetClientId(), ClientCredentials.GetSecret())); if (MessageLogger.EnableLogging == true) { MessageLogger.LogStatus(MessageLogger.LogPath, "Starting New Batch............................................................."); MessageLogger.LogStatus(MessageLogger.LogPath, "Establishing Server Connection"); } var messageApi = new MessagingApi(host); foreach (var phone in Phone.PhoneNumbers) { if (MessageLogger.EnableLogging == true) { MessageLogger.LogStatus(MessageLogger.LogPath, "Sending to........ " + phone); } //Remove 0 and add +233 to the beginning of the phone numbers if (Phone.FormatLocal == true) { formattedPhone = Phone.Validate(phone); } //checking the Ghanaian standard mobile length if (phone.Length < 10) { // log unsent message to outBox MessageLogger.logOutbox(formattedPhone, "Rejected due to length < 10"); continue; } else { try { MessageResponse msge = messageApi.SendQuickMessage(MessageId, formattedPhone, MessageBody, RegisteredDelivery); MessageLogger.logSent(formattedPhone, "Successful"); } catch (Exception e) { MessageLogger.logOutbox(formattedPhone, "rejected due to server error !"); //pass control to the next iteration of the enclosing foreach statement continue; } } } //returns number of sent >1 when successful return(MessageLogger.sent.Count); }
protected override void RegisterContainer(IServiceProvider services) { base.RegisterContainer(services); var ext = services.GetService <IExternalInjected>(); var cfg = new ApiConfig() { }; var apiHost = new ApiHost(cfg) .WithContainer(Container); }
protected override void RegisterContainer(IApplicationBuilder app) { base.RegisterContainer(app); var cfg = new ApiConfig() { }; var apiHost = new ApiHost(cfg) .WithContainer(Container); var env = app.ApplicationServices.GetService <IWebHostEnvironment>(); }
public Launcher() { InitializeComponent(); host = new ApiHost(); host.StartHost(); string baseURL = ConfigurationManager.AppSettings["BaseURL"]; string computerKey = ConfigurationManager.AppSettings["ComputerKey"]; txtUrl.Text = baseURL; txtComputerKey.Text = computerKey; }
protected Fixture() { var config = ConfigLoader.Load("appsettings.tests.json"); _connectionString = config.GetSection("Database").GetValue <string>("ConnectionString"); DatabaseCreator.CreateIfNotExists(_connectionString).Wait(); DatabaseCleanup.ClearDatabase(_connectionString); TimeProvider = new MockTimeProvider(); _host = ApiHost.CreateWebHost(config, services => services.AddSingleton <ITimeProvider>(TimeProvider)); _host.Start(); }
public ApiResult Connect(ApiHost host) { var data = new StringBuilder(_resultCapacity); var error = new StringBuilder(_errorCapacity); TdxMarketApi.TdxL2Hq_Connect(host.IPAddress, host.Port, data, error); return(new ApiResult { Result = error.Length == 1, Data = data.ToString(), Error = error.ToString() }); }
public HostFixture() { HostAddress = $"http://localhost:{ApiHostPort}"; AppConfiguration = LoadConfig("appsettings-integration-tests.json"); var dbConfig = AppConfiguration.GetSection(ConfigKeys.Database).Get <DatabaseConfig>(); DatabaseCreator.CreateIfNotExists(dbConfig).Wait(); Host = ApiHost.CreateHost(AppConfiguration, ApiHostPort); Host.Start(); }
protected override void RegisterContainer(IApplicationBuilder app) { base.RegisterContainer(app); var cfg = new ApiConfig() { }; var apiHost = new ApiHost(cfg) .WithContainer(Container); var lifetime = app.ApplicationServices.GetRequiredService <IHostApplicationLifetime>(); lifetime.ApplicationStopped.Register(() => Container.Dispose()); }
/// <summary> /// </summary> /// <param name="host"> /// <see cref="ApiHost" /> /// </param> protected AbstractApi(ApiHost host) { Host = host; string baseUrl = Host.SecuredConnection ? "https://" : "http://"; baseUrl += Host.Hostname; if (Host.Port > 0) baseUrl += ":" + Host.Port; if (!Host.ContextPath.IsEmpty()) baseUrl += "/" + Host.ContextPath; RestClient = new BasicRestClient(baseUrl, Host.EnabledConsoleLog); // Add additional headers to process requests RestClient.RequestHeaders.Add("Authorization", Host.Auth.GetCredentials()); RestClient.ConnectionTimeout = Host.Timeout; RestClient.ReadWriteTimeout = Host.Timeout; }
public ActionResult Index() { var host = new ApiHost() { ApiName = "api/product/productlist", Domain = "http://localhost:8860/", }; var res = XcHttpClient.Post <string, Response <List <ProductDto> > >(host, null).Result; if (res.Head.IsSuccess) { return(View(res.Content)); } return(View(new List <ProductDto>())); }
/// <summary> /// </summary> /// <param name="host"> /// <see cref="ApiHost" /> /// </param> protected AbstractApi(ApiHost host) { Host = host; // string baseUrl = Host.SecuredConnection ? "https://" : "http://"; string baseUrl = Host.BaseUrl; // if (Host.Port > 0) baseUrl += ":" + Host.Port; // if (!Host.ContextPath.IsEmpty()) baseUrl += "/" + Host.ContextPath; RestClient = new BasicRestClient(baseUrl, Host.EnabledConsoleLog); // Add additional headers to process requests RestClient.RequestHeaders.Add("Authorization", Host.Auth.GetCredentials()); RestClient.ConnectionTimeout = Host.Timeout; RestClient.ReadWriteTimeout = Host.Timeout; }
static void Process(CommandOptions options) { try { int listeningPort = options.Port; var fg = Console.ForegroundColor; ApiHost.Start(new ConsoleResultPrinter(consoleLock, new ResultFileWriter(options.Directory, consoleLock)), listeningPort); Console.WriteLine($"Awaiting collection results on port {listeningPort}"); Console.WriteLine("Hit ENTER to exit"); Console.ReadLine(); Console.WriteLine(); Console.ForegroundColor = fg; } catch (Exception ex) { Console.WriteLine($"Error: {ex.Message}"); } }
public Launcher() { InitializeComponent(); host = new ApiHost(); host.StartHost(); Configuration configuration = ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel.None); baseURL = configuration.AppSettings.Settings["BaseURL"].Value; computerKey = configuration.AppSettings.Settings["ComputerKey"].Value; txtUrl.Text = baseURL; txtComputerKey.Text = computerKey; this.WindowState = FormWindowState.Minimized; }
protected override void OnStart(string[] args) { Log.Info("Loading Configuration..."); Bootstrapper .With.StructureMap() .LookForTypesIn.ReferencedAssemblies().Including.Assembly(Assembly.GetAssembly(typeof(DataCollectorContainer))) .Start(); _container = (IContainer)Bootstrapper.Container; Log.Info("Starting DataCollector..."); Log.Info("Starting DataCollector API..."); _apiHost = _container.GetInstance <ApiHost>(); _apiHost.Run(); }
public async Task <IActionResult> Sms(SmsDto sms) { string clientId = _config.GetValue <string>("Sms:ClientId"); string clientSecret = _config.GetValue <string>("Sms:ClientSecret"); StringBuilder builder = new StringBuilder(); builder.Append("You have been registered on the Donor Trace Mobile App"); var host = new ApiHost(new BasicAuth(clientId, clientSecret)); var messageApi = new MessagingApi(host); MessageResponse msg = messageApi.SendQuickMessage("Donor Trace", sms.To, builder.ToString(), false); return(Ok(msg.Status)); }
public void SendSms(OfficerDto officer) { string clientId = _config.GetValue <string>("Sms:ClientId"); string clientSecret = _config.GetValue <string>("Sms:ClientSecret"); StringBuilder builder = new StringBuilder(); builder.Append("You have been registered on the Donor Trace Mobile App"); builder.AppendLine(); builder.Append("Username: "******" " + officer.UserName); builder.AppendLine(); builder.Append("Password: "******" " + officer.Password); var host = new ApiHost(new BasicAuth(clientId, clientSecret)); var messageApi = new MessagingApi(host); MessageResponse msg = messageApi.SendQuickMessage("Donor Trace", officer.ContactNo, builder.ToString(), true); }