static void Main(string[] args) { ServicePointManager.DefaultConnectionLimit = 65535; var options = ProgramOptions.GetOptionsFromCommandLine(args); url = options.url; cashBoxId = options.cashboxid.ToString(); System.ServiceModel.Channels.Binding binding = null; if (url.StartsWith("http://")) { var b = new BasicHttpBinding(BasicHttpSecurityMode.None); b.MaxReceivedMessageSize = 16 * 1024 * 1024; binding = b; } else if (url.StartsWith("https://")) { var b = new BasicHttpBinding(BasicHttpSecurityMode.Transport); b.MaxReceivedMessageSize = 16 * 1024 * 1024; binding = b; } else if (url.StartsWith("net.pipe://")) { var b = new NetNamedPipeBinding(NetNamedPipeSecurityMode.None); b.MaxReceivedMessageSize = 16 * 1024 * 1024; binding = b; } else if (url.StartsWith("net.tcp://")) { var b = new NetTcpBinding(SecurityMode.None); b.MaxReceivedMessageSize = 16 * 1024 * 1024; binding = b; } var endpoint = new EndpointAddress(url); var factory = new ChannelFactory <IPOS>(binding, endpoint); proxy = factory.CreateChannel(); // use echo for communication test var message = proxy.Echo("message"); if (message != "message") { throw new Exception("echo failed"); } while (true) { Menu(); } }
public static void Run(string url, Guid cashboxId, HttpCommunicationType communicationType, string accessToken, string receiptExampleDirectory) { _cashBoxId = cashboxId; var retryOptions = new RetryPolicyOptions { ClientTimeout = TimeSpan.FromSeconds(90), DelayBetweenRetries = TimeSpan.FromSeconds(5), Retries = 3 }; _pos = HttpPosFactory.CreatePosAsync(new HttpPosClientOptions { Url = new Uri(url), CommunicationType = communicationType, CashboxId = cashboxId, AccessToken = accessToken, RetryPolicyOptions = retryOptions, UseUnversionedLegacyUrls = true }).Result; _examples = LoadExamples(receiptExampleDirectory, cashboxId); ExecuteEcho("Test"); while (true) { Menu(); } }
public static async Task RunAsync(string url, Guid cashboxId, HttpCommunicationType communicationType, string accessToken, string receiptExampleDirectory) { _cashBoxId = cashboxId; var retryOptions = new RetryPolicyOptions { ClientTimeout = TimeSpan.FromSeconds(90), DelayBetweenRetries = TimeSpan.FromSeconds(5), Retries = 3 }; _pos = await HttpPosFactory.CreatePosAsync(new HttpPosClientOptions { Url = new Uri(url), CommunicationType = communicationType, CashboxId = cashboxId, AccessToken = accessToken, RetryPolicyOptions = retryOptions }); _examples = LoadExamples(receiptExampleDirectory, cashboxId); await ExecuteEchoAsync("Test"); while (true) { await MenuAsync(); } }
/// <param name="cashboxId">The cashboxid for the Middleware.</param> /// <param name="url">The url that is used for sending requests to the Middleware(Default: grpc://localhost:10103).</param> /// <returns></returns> public static async Task Main(string cashboxId, string url = "grpc://localhost:10103") { try { if (Guid.TryParse(cashboxId, out var parsedCashBoxId)) { _cashBoxId = parsedCashBoxId; LoadExamples(); pos = GetPosClientForUrl(url); await EchoAsync(); while (true) { await MenuAsync(); } } else { ConsoleHelper.WriteError("Please provide a valid CashBoxId"); } } catch (Exception ex) { ConsoleHelper.WriteError(ex.ToString()); } finally { Console.ReadLine(); } }
/// <summary> /// Updates the POS. /// </summary> /// <param name="pos">The POS.</param> /// <returns>boolean value</returns> public async Task <bool> UpdatePOS(IPOS posUpdate) { bool posExists = pos.Entities.Where(x => x.POSNumber == posUpdate.POSNumber && x.SerialNumber.Trim().ToLower() == posUpdate.SerialNumber.Trim().ToLower() && x.PurchaseLPO == posUpdate.PurchaseLPO && x.Id != posUpdate.Id).Any(); if (posExists) { return(false); } var posEntity = await pos.GetByIdAsync(posUpdate.Id); posEntity.Id = posUpdate.Id; posEntity.POSNumber = posUpdate.POSNumber; posEntity.SerialNumber = posUpdate.SerialNumber; posEntity.ModelNumber = posUpdate.ModelNumber; posEntity.PurchaseLPO = posUpdate.PurchaseLPO; posEntity.WarrantyExpiry = posUpdate.WarrantyExpiry; posEntity.SupplierId = posUpdate.SupplierId; posEntity.Manufacturer = posUpdate.Manufacturer; posEntity.ManufacturingYear = posUpdate.ManufacturingYear; posEntity.Remarks = posUpdate.Remarks; posEntity.CreatedDate = posUpdate.CreatedDate; posEntity.EditedDate = posUpdate.EditedDate; posEntity.IsActive = posUpdate.IsActive; pos.Update(posEntity); var updatedPos = UnitOfWork.Commit(); return(true); }
public static void Run(string url, Guid cashboxId, string receiptExampleDirectory) { _cashBoxId = cashboxId; _pos = SoapPosFactory.CreatePosAsync(new ClientOptions { Url = new Uri(url) }).Result; _examples = LoadExamples(receiptExampleDirectory, cashboxId); ExecuteEcho("Test"); while (true) { Menu(); } }
/// <summary> /// Adds the POS. /// </summary> /// <param name="pos">The POS.</param> /// <returns>boolean value</returns> public bool CreatePOS(IPOS posRegistration) { posRegistration.AssignedTo = "Not Assigned"; var paramExists = pos.Entities.Where(x => x.POSNumber.Trim().ToLower() == posRegistration.POSNumber.Trim().ToLower() && x.SerialNumber == posRegistration.SerialNumber && x.PurchaseLPO == posRegistration.PurchaseLPO).Any(); if (paramExists) { return(false); } var addedPos = pos.Add(posRegistration); UnitOfWork.Commit(); return(true); }
public HttpResponseMessage CreatePOS([ModelBinder(typeof(IocCustomCreationConverter))] IPOS pos) { try { var status = posRegistrationService.CreatePOS(pos); if (!status) { return(CreateHttpResponse <IPOS>(HttpStatusCode.Accepted, HttpCustomStatus.Success, null, GetLocalisedString("msgPOSDuplicate"))); } return(CreateHttpResponse <IPOS>(HttpStatusCode.Created, HttpCustomStatus.Success, null, GetLocalisedString("msgPOSCreated"))); } catch (Exception ex) { logger.Error(ex.Message); return(CreateHttpResponse <IPOS>(HttpStatusCode.InternalServerError, HttpCustomStatus.Failure, null, GetLocalisedString("msgWebServiceError"))); } }
/// <summary> /// Updates the POS. /// </summary> /// <param name="pos">The POS.</param> /// <returns>boolean value</returns> public async Task <bool> UpdatePOS(IPOS pos) { return(await posRegistrationDataService.UpdatePOS(pos)); }
/// <summary> /// Adds the POS. /// </summary> /// <param name="pos">The POS.</param> /// <returns>boolean value</returns> public bool CreatePOS(IPOS pos) { return(posRegistrationDataService.CreatePOS(pos)); }
static void Main(string[] args) { ServicePointManager.DefaultConnectionLimit = 65535; Console.Write("fiskaltrust-service-url:"); url = Console.ReadLine(); Console.Write("cashboxid:"); cashBoxId = Console.ReadLine(); Guid _tempCashBoxID; if (!Guid.TryParse(cashBoxId, out _tempCashBoxID)) { throw new ArgumentException("cashboxid is not a guid!"); } System.ServiceModel.Channels.Binding binding = null; if (url.StartsWith("http://")) { var b = new BasicHttpBinding(BasicHttpSecurityMode.None); b.MaxReceivedMessageSize = 16 * 1024 * 1024; binding = b; } else if (url.StartsWith("https://")) { var b = new BasicHttpBinding(BasicHttpSecurityMode.Transport); b.MaxReceivedMessageSize = 16 * 1024 * 1024; binding = b; } else if (url.StartsWith("net.pipe://")) { var b = new NetNamedPipeBinding(NetNamedPipeSecurityMode.None); b.MaxReceivedMessageSize = 16 * 1024 * 1024; binding = b; } else if (url.StartsWith("net.tcp://")) { var b = new NetTcpBinding(SecurityMode.None); b.MaxReceivedMessageSize = 16 * 1024 * 1024; binding = b; } var endpoint = new EndpointAddress(url); var factory = new ChannelFactory <IPOS>(binding, endpoint); proxy = factory.CreateChannel(); // use echo for communication test var message = proxy.Echo("message"); if (message != "message") { throw new Exception("echo failed"); } while (true) { Menu(); } }
public AsyncJournalPOSHelper(IPOS innerPOS) { _innerPOS = innerPOS; }