public Commerce() { _billingProcessor = new BillingProcessor(); _customer = new Customer(); _notifier = new Notifier(); _logger = new Logger(); }
public Commerce() { _BillingProcessor = new BillingProcessor(); _Customer = new Customer(); _Notifier = new Notifier(); _Logger = new Logger(); }
/// <summary> /// Клиент пробует подключиться /// </summary> void communicator_OnBind(object source, BindEventArgs e) { SmppBindResp pdu = new SmppBindResp(); pdu.SequenceNumber = e.BindPdu.SequenceNumber; if (!communicator.IsBinded) { //Биндинг соединения AccountBase account = null; try { account = billingprov.GetAccount(e.BindPdu.SystemId, e.BindPdu.Password); billing = new BillingProcessor(account); pdu.CommandStatus = (uint)SmppCommandStatus.ESME_ROK; e.IsBindSucessfull = true; LoggerService.Logger.TraceEvent(TraceEventType.Information, LoggingCatoegory.Protocol.IntValue(), string.Format("Client {0} binded", e.BindPdu.SystemId)); PerformanceCountersService.GetCounter(CONNECTION_COUNTER_NAME).Increment(); } catch (Exception ex) { LoggerService.Logger.TraceEvent(TraceEventType.Error, LoggingCatoegory.Protocol.IntValue(), string.Format("Bind failed in fact of account for user {0} cannot be get. Error {1}", e.BindPdu.SystemId, ex.ToString())); pdu.CommandStatus = (uint)SmppCommandStatus.ESME_RBINDFAIL; e.IsBindSucessfull = false; } } else { pdu.CommandStatus = (uint)SmppCommandStatus.ESME_RALYBND; e.IsBindSucessfull = false; } communicator.SendPdu(pdu); }
public void ProcessOrder(OrderInfo orderInfo) { BillingProcessor billingProcessor = new BillingProcessor(); CustomerProcessor customerProcessor = new CustomerProcessor(); Notifier notifier = new Notifier(); billingProcessor.ProcessPayment(orderInfo.CustomerName, orderInfo.CreditCard, orderInfo.CustomerEmail); customerProcessor.UpdateCustomerOrder(orderInfo.CustomerName, orderInfo.Product); notifier.SendReceipt(orderInfo); }
/// <summary> /// Комманда отсоединения /// </summary> void communicator_OnUnbind(object source, UnbindEventArgs e) { //Отсоединяемся if (communicator.IsBinded && billing != null) { LoggerService.Logger.TraceEvent(TraceEventType.Information, LoggingCatoegory.Protocol.IntValue(), string.Format("Client {0} unbinded", billing.Account.Login)); billing.Account.Dispose(); billing = null; PerformanceCountersService.GetCounter(CONNECTION_COUNTER_NAME).Decrement(); } SmppUnbindResp pdu = new SmppUnbindResp(); pdu.SequenceNumber = e.UnbindPdu.SequenceNumber; pdu.CommandStatus = (uint)SmppCommandStatus.ESME_ROK; }
public void SetConnInAppBilling() { try { switch (Handler) { case null: Handler = new BillingProcessor(ActivityContext, InAppBillingGoogle.ProductId, this); Handler.Initialize(); break; } } catch (Exception e) { Methods.DisplayReportResultTrack(e); } }
public InitInAppBillingPayment(Activity activity) { try { ActivityContext = activity; if (!BillingProcessor.IsIabServiceAvailable(activity)) { Console.WriteLine("In-app billing service is unavailable, please upgrade Android Market/Play to version >= 3.9.16"); return; } SetConnInAppBilling(); } catch (Exception e) { Methods.DisplayReportResultTrack(e); } }
public void Test_RegisterWithResolveExplicitValues() { Container container = new Container(); BillingProcessor billingProcessor = new BillingProcessor(PaymentType.CreditCard); container.Register <IBillingProcessor>(billingProcessor); container.Register <ICustomer, InternetCustomer>(); container.Register <INotifier, EmailNotifer>(); OnlineOrder onlineOrder = new OnlineOrder() { CustomerId = 12212, EmailAddress = "*****@*****.**", Price = 400, Product = "NewProduct" }; ECommerce commerce = container.Resolve <ECommerce>(); commerce.Process(onlineOrder); Assert.IsNotNull(commerce); }
public bool NotifyFailed(Guid smsId, string clientId, string distibutionId = null, Dictionary <string, string> additionalParams = null) { long intClientId; bool result = false; if (long.TryParse(clientId, out intClientId)) { ClientModel client = ClientRepo.GetClientConcrete(intClientId); if (client != null && client.Id.HasValue) { if (client.DebtingType == DebtingType.ByDelivered) { if (!additionalParams.ContainsKey(ADEService.EXTERNAL)) { long?intDistibutionId = null; if (!string.IsNullOrEmpty(distibutionId)) { long dId; if (long.TryParse(distibutionId, out dId)) { intDistibutionId = dId; } } result = BillingProcessor.ResetSMSSend(intClientId, distributionId: intDistibutionId); } else { result = BillingProcessor.ResetSMSSend(intClientId, extDistributionId: distibutionId); } } else { result = true; } } } return(result); }
static void Main(string[] args) { /* This example demonstrates using a proxy as a protection. * Below you'll see the original usage of sample billing processor * which allows negative payments, plus does not care about the billing method. */ IBillingProcessor processor; processor = new BillingProcessor(); processor.AcceptPayment(-500M); processor.AcceptPayment(-5.0M); /* * This is the usage of proxy as a protection layer on top of the existing class * proxy both checks the payment method and the amount and if all checks pass, it delegates * the call to the original billing proxy object created inside. */ processor = new BillingProxy(PaymentMethod.MasterCard); try { processor.AcceptPayment(1000M); processor.AcceptPayment(-5M); } catch (Exception e) { WriteLine(e.Message); } /* * Example below demonstrates the use of proxy pattern as a property proxy. */ var creature = new Creature() { Name = "Obi-Wan Kenobi" }; creature.Agility = 100; // Below line will not yield a console output. creature.Agility = 100; WriteLine(creature); /* * Below example demonstrates a value proxy over integer type. */ WriteLine(5.Percent()); WriteLine(100f * 5.Percent()); WriteLine(5.Percent() + 10.Percent()); /* * This composite proxy pattern implementation demonstrates how to use * both patterns to achieve a pseudo memory efficient way of accessing * many objects and changing their properties. */ /* * Imagine this scenario where you have millions of creatures and want to change * their X coordinates in each game tick. Since Creature object has many fields * and they have different byte sizes in the memory the instructor would theoretically * (without compiler and cpu optimizations) jump unnecessary amount of memory blocks to perform it. */ /*var inefficientCreatures = new GameObject[100]; * foreach (var creature in inefficientCreatures) * { * creature.X++; * }*/ /* * With the help of proxy and composite patterns we build a more memory efficient data * structure to perform such operation. */ var i = 1; var gameObjects = new GameObjects(1000); foreach (var gameObject in gameObjects) { gameObject.X++; WriteLine($"Game object {i}: {gameObject}"); ++i; } /* * Below example shows a dynamic proxy which is generated runtime (with the added performance costs) * to create a log proxy over any type. */ var ba = new BankAccount(100); ba.Withdraw(20); ba.Deposit(50); WriteLine(ba); var loggedAccount = LogProxy <BankAccount> .As <IBankAccount>(100); loggedAccount.Withdraw(50); loggedAccount.Deposit(15); // Exercise demo var p = new Person() { Age = 21 }; var rp = new ResponsiblePerson(p); WriteLine(rp.Drive()); WriteLine(rp.Drink()); WriteLine(rp.DrinkAndDrive()); }
public List <SMSSeriesId> SendSms(string sessionKey, List <string> addresses, string message, string distibutionId = null, string messageId = null, bool transliterate = false, DateTime?deliveryTime = null, TimeSpan?validalityPeriod = null) { List <SMSSeriesId> ids = new List <SMSSeriesId>(); ServiceSession session = _sessionManager.GetSession(sessionKey); if (session != null) { Dictionary <string, string> custom = new Dictionary <string, string>(); custom.Add(USER_ID, session.UserId); custom.Add(EXTERNAL, true.ToString()); bool isSent = false; long clientId = long.Parse(session.ClientId); if (BillingProcessor.SMSBeginSend(clientId, extDistributionId: distibutionId)) { try { try { ids = _gateService.SendSms( session.GateSessionKey, addresses, message, session.ClientId, distibutionId, messageId, transliterate, deliveryTime, validalityPeriod, custom); } catch { session.GateSessionKey = _gateService.Login(Settings.Default.GateUserName, Settings.Default.GatePassword, session.SenderName); ids = _gateService.SendSms( session.GateSessionKey, addresses, message, session.ClientId, distibutionId, messageId, transliterate, deliveryTime, validalityPeriod, custom); } isSent = true; } catch (Exception ex) { Trace.TraceError("Ошибка отправки на шлюз {0}", ex); isSent = false; } } else { throw new InvalidOperationException("Блокировка средств на вашем счету завершилась неудачей, отправка невозможна, проверьте ваш баланс"); } if (isSent && session.DebtingType == DebtingType.BySent) { BillingProcessor.CommintSMSSend(clientId, extDistributionId: distibutionId); } else { BillingProcessor.ResetSMSSend(clientId, extDistributionId: distibutionId); } return(ids); } else { throw new Exception(Resources.Error_SessionIncorrect); } }