public void OnSetServiceModelPath() { OnSaveModel(); BackgroundWorker bgWorker = new BackgroundWorker(); bgWorker.DoWork += (s, e) => { ChannelFactory <IServiceCommunicator> channelFactory = null; try { NetTcpBinding ServiceBinding = new NetTcpBinding(); ServiceBinding.Security.Mode = SecurityMode.None; channelFactory = new ChannelFactory <IServiceCommunicator>(ServiceBinding, new EndpointAddress(ServicePath)); IServiceCommunicator Service = channelFactory.CreateChannel(); Service.SetActiveModelPath(ActiveModelPath); channelFactory.Close(); } catch (Exception ex) { if (channelFactory != null) { channelFactory.Abort(); } } }; bgWorker.RunWorkerAsync(); }
private void CheckLicenseStatus(object sender, DoWorkEventArgs e) { ChannelFactory <IServiceCommunicator> channelFactory = null; try { NetTcpBinding ServiceBinding = new NetTcpBinding(); ServiceBinding.Security.Mode = SecurityMode.None; channelFactory = new ChannelFactory <IServiceCommunicator>(ServiceBinding, new EndpointAddress(ServicePath)); IServiceCommunicator Service = channelFactory.CreateChannel(); e.Result = Service.GetStartTime(); channelFactory.Close(); ServiceRunning = true; } catch (Exception ex) { ServiceRunning = false; if (channelFactory != null) { channelFactory.Abort(); } } }
public void TestPostBatchInvalidPostStatus() { IAuthorizationStrategy basicAuthStrategy = MockAuthStrategy(); IServiceCommunicator serviceCommunicator = MockServiceCommunicator(); IStamprApiClient stamprApiClient = new StamprApiClient.StamprApiClient("http://no", _username, _password, serviceCommunicator, basicAuthStrategy); Assert.Throws <ArgumentException>(() => stamprApiClient.CreateBatch(1, "", Status.archive)); }
public void TestGetConfigAllUnsuccessful() { IAuthorizationStrategy basicAuthStrategy = MockAuthStrategy(); IServiceCommunicator serviceCommunicator = MockServiceCommunicator(); IStamprApiClient stamprApiClient = new StamprApiClient.StamprApiClient("http://no", _username, _password, serviceCommunicator, basicAuthStrategy); Assert.Throws <ServiceCommunicationException>(() => stamprApiClient.GetConfig(1)); }
public void TestPostMailingUnsuccessful() { IAuthorizationStrategy basicAuthStrategy = MockAuthStrategy(); IServiceCommunicator serviceCommunicator = MockServiceCommunicator(); IStamprApiClient stamprApiClient = new StamprApiClient.StamprApiClient("http://no", _username, _password, serviceCommunicator, basicAuthStrategy); Assert.Throws <ServiceCommunicationException>(() => stamprApiClient.CreateMailing(1, "Add", "RetAdd", Format.none)); }
public void TestSearchBatchUnsuccessful() { IAuthorizationStrategy basicAuthStrategy = MockAuthStrategy(); IServiceCommunicator serviceCommunicator = MockServiceCommunicator(); IStamprApiClient stamprApiClient = new StamprApiClient.StamprApiClient("http://no", _username, _password, serviceCommunicator, basicAuthStrategy); Assert.Throws <ServiceCommunicationException>(() => stamprApiClient.GetBatches(Status.processing)); }
public void TestSearchBatchMailingsInvalidSearch() { IAuthorizationStrategy basicAuthStrategy = MockAuthStrategy(); IServiceCommunicator serviceCommunicator = MockServiceCommunicator(); IStamprApiClient stamprApiClient = new StamprApiClient.StamprApiClient(_url, _username, _password, serviceCommunicator, basicAuthStrategy); Assert.Throws <ArgumentException>(() => stamprApiClient.GetBatchMailings(1930, new SearchModel <StamprApiClient.Api.Models.Mailing.Status>())); }
public void TestPostBatchUnsuccessful() { IAuthorizationStrategy basicAuthStrategy = MockAuthStrategy(); IServiceCommunicator serviceCommunicator = MockServiceCommunicator(); IStamprApiClient stamprApiClient = new StamprApiClient.StamprApiClient("http://no", _username, _password, serviceCommunicator, basicAuthStrategy); Assert.Throws <ServiceCommunicationException>(() => stamprApiClient.CreateBatch(1, "", Status.hold)); }
public void TestDeleteBatch() { IAuthorizationStrategy basicAuthStrategy = MockAuthStrategy(); IServiceCommunicator serviceCommunicator = MockServiceCommunicator(); IStamprApiClient stamprApiClient = new StamprApiClient.StamprApiClient(_url, _username, _password, serviceCommunicator, basicAuthStrategy); bool result = stamprApiClient.DeleteBatch(1904); Assert.True(result); }
public static async Task <IMessage> WaitForSingleReplyAsync(this IServiceCommunicator communicator, IMessage message, CancellationToken?token = null, TimeSpan?timeout = null) { var options = ReplyOptions.WaitForSingleReply(message); options.CancelToken = token; if (timeout != null) { options.Timeout = timeout.Value; } return((await communicator.WaitForRepliesAsync(options)).FirstOrDefault()); }
public void TestGetMailingSuccessful() { IAuthorizationStrategy basicAuthStrategy = MockAuthStrategy(); IServiceCommunicator serviceCommunicator = MockServiceCommunicator(); IStamprApiClient stamprApiClient = new StamprApiClient.StamprApiClient(_url, _username, _password, serviceCommunicator, basicAuthStrategy); MailingModel model = stamprApiClient.GetMailings(1348).First(); Assert.AreEqual(model.Format, Format.none); Assert.AreEqual(model.Address, "Add"); Assert.AreEqual(model.ReturnAddress, "RetAdd"); Assert.AreEqual(model.Mailing_Id, 1348); Assert.AreEqual(model.User_Id, 1); }
public void TestSearchBatchMailingsSuccessful() { IAuthorizationStrategy basicAuthStrategy = MockAuthStrategy(); IServiceCommunicator serviceCommunicator = MockServiceCommunicator(); IStamprApiClient stamprApiClient = new StamprApiClient.StamprApiClient(_url, _username, _password, serviceCommunicator, basicAuthStrategy); var mailings = stamprApiClient.GetBatchMailings(1930, StamprApiClient.Api.Models.Mailing.Status.queued, DateTime.Parse("2013-05-24T18:01:35.707Z"), DateTime.Parse("2013-05-25T18:01:35.707Z"), 12).First(); Assert.AreEqual(mailings.Format, StamprApiClient.Api.Models.Mailing.Format.none); Assert.AreEqual(mailings.Address, "Add"); Assert.AreEqual(mailings.ReturnAddress, "RetAdd"); Assert.AreEqual(mailings.Mailing_Id, 1348); Assert.AreEqual(mailings.User_Id, 1); }
public void TestSearchBatchSuccessful() { IAuthorizationStrategy basicAuthStrategy = MockAuthStrategy(); IServiceCommunicator serviceCommunicator = MockServiceCommunicator(); IStamprApiClient stamprApiClient = new StamprApiClient.StamprApiClient(_url, _username, _password, serviceCommunicator, basicAuthStrategy); BatchModel model = stamprApiClient.GetBatches(Status.processing).First(); Assert.AreEqual(model.Config_Id, 4679); Assert.AreEqual(model.Status, Status.processing); Assert.AreEqual(model.Template, "Hello"); Assert.AreEqual(model.Batch_Id, 1904); Assert.AreEqual(model.User_Id, 1); Assert.AreEqual(model.Version, "1.0"); }
public void TestPostConfig() { IAuthorizationStrategy basicAuthStrategy = MockAuthStrategy(); IServiceCommunicator serviceCommunicator = MockServiceCommunicator(); IStamprApiClient stamprApiClient = new StamprApiClient.StamprApiClient(_url, _username, _password, serviceCommunicator, basicAuthStrategy); ConfigModel model = stamprApiClient.CreateConfig(); Assert.AreEqual(model.Output, Output.single); Assert.AreEqual(model.Style, Style.color); Assert.AreEqual(model.Turnaround, Turnaround.threeday); Assert.AreEqual(model.Size, Size.standard); Assert.AreEqual(model.ReturnEnvelope, false); Assert.Greater(model.Config_Id, 0); Assert.Greater(model.User_Id, 0); }
internal StamprApiClient(string baseUrl, string userName, string password, IServiceCommunicator serviceCommunicator, IAuthorizationStrategy authorizationStrategy) { _baseUri = new Uri(VirtualPathUtility.AppendTrailingSlash(baseUrl), UriKind.Absolute); if (!_allowedSchemas.Contains(_baseUri.Scheme)) { throw new ArgumentException(string.Format(Resources.StringResource.NOT_VALID_URI, baseUrl)); } _userName = userName; _password = password; _authorizationStrategy = authorizationStrategy; _serviceCommunicator = serviceCommunicator; _modelConvertor = new ModelConvertor(); _mailingModelConvertor = new MailingModelConvertor(); }
public void TestGetConfigAllSuccessful() { IAuthorizationStrategy basicAuthStrategy = MockAuthStrategy(); IServiceCommunicator serviceCommunicator = MockServiceCommunicator(); IStamprApiClient stamprApiClient = new StamprApiClient.StamprApiClient(_url, _username, _password, serviceCommunicator, basicAuthStrategy); ConfigModel model = stamprApiClient.GetAllConfigs().First(); Assert.AreEqual(model.Output, Output.single); Assert.AreEqual(model.Style, Style.color); Assert.AreEqual(model.Turnaround, Turnaround.threeday); Assert.AreEqual(model.Size, Size.standard); Assert.AreEqual(model.ReturnEnvelope, false); Assert.AreEqual(model.Config_Id, 4679); Assert.AreEqual(model.User_Id, 1); Assert.AreEqual(model.Version, "1.0"); }
public void TestPostBatch() { IAuthorizationStrategy basicAuthStrategy = MockAuthStrategy(); IServiceCommunicator serviceCommunicator = MockServiceCommunicator(); IStamprApiClient stamprApiClient = new StamprApiClient.StamprApiClient(_url, _username, _password, serviceCommunicator, basicAuthStrategy); BatchModel postModel = new BatchModel() { Config_Id = 4769, Status = Status.processing, Template = "Hello" }; BatchModel model = stamprApiClient.CreateBatch(postModel); Assert.AreEqual(model.Config_Id, postModel.Config_Id); Assert.AreEqual(model.Status, postModel.Status); Assert.AreEqual(model.Template, postModel.Template); Assert.Greater(model.Batch_Id, 0); Assert.Greater(model.User_Id, 0); }
private void OnValidateLicenseFromUrl() { BackgroundWorker bgWorker = new BackgroundWorker(); bgWorker.DoWork += (s, e) => { ChannelFactory <IServiceCommunicator> channelFactory = null; try { NetTcpBinding ServiceBinding = new NetTcpBinding(); ServiceBinding.Security.Mode = SecurityMode.None; channelFactory = new ChannelFactory <IServiceCommunicator>(ServiceBinding, new EndpointAddress(ServicePath)); IServiceCommunicator Service = channelFactory.CreateChannel(); String UniqueHW = Service.GetUniqueHWID(); using (WebClient client = new WebClient()) { LicenseKey = client.DownloadString("http://joncarsondev.appspot.com/plc2sql?pk=" + PurchaseKey + "&hid=" + LicenseHelper.Unique_HW_ID()); Service.SetLicense(PurchaseKey, LicenseKey); if (LicenseHelper.IsLicenseValid(LicenseKey, PurchaseKey, UniqueHW)) { IsDemo = false; } else { IsDemo = true; } } channelFactory.Close(); } catch (Exception ex) { if (channelFactory != null) { channelFactory.Abort(); } } }; bgWorker.RunWorkerAsync(); }
public void TestPostMailing() { IAuthorizationStrategy basicAuthStrategy = MockAuthStrategy(); IServiceCommunicator serviceCommunicator = MockServiceCommunicator(); IStamprApiClient stamprApiClient = new StamprApiClient.StamprApiClient(_url, _username, _password, serviceCommunicator, basicAuthStrategy); MailingModel postModel = new MailingModel() { Batch_Id = 4769, Format = Format.none, Address = "Add", ReturnAddress = "RetAdd" }; MailingModel model = stamprApiClient.CreateMailing(postModel); Assert.AreEqual(model.Batch_Id, postModel.Batch_Id); Assert.AreEqual(model.Format, postModel.Format); Assert.AreEqual(model.Address, postModel.Address); Assert.AreEqual(model.ReturnAddress, postModel.ReturnAddress); Assert.Greater(model.Mailing_Id, 0); Assert.Greater(model.User_Id, 0); }
private void CheckLogs(object sender, DoWorkEventArgs e) { ChannelFactory <IServiceCommunicator> channelFactory = null; try { NetTcpBinding ServiceBinding = new NetTcpBinding(); ServiceBinding.Security.Mode = SecurityMode.None; ServiceBinding.MaxBufferSize = 2147483647; ServiceBinding.MaxReceivedMessageSize = 2147483647; channelFactory = new ChannelFactory <IServiceCommunicator>(ServiceBinding, new EndpointAddress(ServicePath)); IServiceCommunicator Service = channelFactory.CreateChannel(); DateTime LatestDate; if (ServiceLogs.Count == 0) { LatestDate = DateTime.MinValue; } else { LatestDate = ServiceLogs.Max(p => p.Occurred); } e.Result = Service.GetLatestLogs(LatestDate); channelFactory.Close(); } catch (Exception ex) { if (channelFactory != null) { channelFactory.Abort(); } } }
protected ApolloClientBase(IServiceCommunicator communicator, params ApolloPlugin[] apolloPlugins) { Communicator = communicator ?? throw new ArgumentNullException(nameof(communicator)); LoadPlugins(apolloPlugins); }
public ApolloServer(IServiceCommunicator communicator, IApolloServerRepository storage) : base(communicator) { LoadCorePlugin(storage); }
internal void SetCommunicator(IServiceCommunicator communicator) { Communicator = communicator ?? throw new ArgumentNullException(nameof(communicator)); OnInitialized(); }
public ApolloClient(IServiceCommunicator communicator, PluginCollection apolloPluginsBase) : base(communicator, apolloPluginsBase.ToArray()) { LoadCorePlugin(); }
public ApolloClient(IServiceCommunicator communicator, params ApolloPlugin[] apolloPlugins) : base(communicator, apolloPlugins) { LoadCorePlugin(); }
public ApolloClient(IServiceCommunicator communicator) : base(communicator) { LoadCorePlugin(); }
protected ApolloClientBase(IServiceCommunicator communicator) { Communicator = communicator ?? throw new ArgumentNullException(nameof(communicator)); }
public ApolloServer(IServiceCommunicator communicator, IApolloServerRepository storage, PluginCollection ApolloPluginsBase) : base(communicator, ApolloPluginsBase.ToArray()) { LoadCorePlugin(storage); }
public static T GetState <T>(this IServiceCommunicator communicator, string key) { return(communicator.State.TryGetValue(key, out var value) ? (T)value : default(T)); }
public ApolloServer(IServiceCommunicator communicator, IApolloServerRepository storage, params ApolloPlugin[] apolloPlugins) : base(communicator, apolloPlugins) { LoadCorePlugin(storage); }