public bool ReadPin(DIO_BUS bus, PIN pin) { byte pin_num = Convert.ToByte(pin); bool value = ReadPin(bus, pin_num); return(value); }
/// <summary> /// Set the state of the pin /// </summary> /// <param name="bus"></param> /// <param name="pin"></param> /// <param name="value"></param> /// <returns></returns> public FTDI.FT_STATUS SetPin(DIO_BUS bus, PIN pin, bool value) { byte pin_num = Convert.ToByte(pin); FTDI.FT_STATUS status = SetPin(bus, pin_num, value); return(status); }
public async Task <IHttpActionResult> PutPIN(Guid id, PIN pIN) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } if (id != pIN.PINID) { return(BadRequest()); } db.Entry(pIN).State = EntityState.Modified; try { await db.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!PINExists(id)) { return(NotFound()); } else { throw; } } return(StatusCode(HttpStatusCode.NoContent)); }
public JObject ToJSON() => JSONObject.Create( AuthToken.HasValue ? new JProperty("authToken", AuthToken.ToString()) : null, QRCodeIdentification != null ? new JProperty("QRCodeIdentification", QRCodeIdentification.ToString()) : null, PlugAndChargeIdentification.HasValue ? new JProperty("plugAndChargeIdentification", PlugAndChargeIdentification.ToString()) : null, RemoteIdentification.HasValue ? new JProperty("remoteIdentification", RemoteIdentification.ToString()) : null, PIN.HasValue ? new JProperty("PIN", PIN.ToString()) : null, PublicKey != null ? new JProperty("publicKey", PublicKey.ToString()) : null );
public async Task <IHttpActionResult> PostPIN(PIN pIN) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } db.PINs.Add(pIN); try { await db.SaveChangesAsync(); } catch (DbUpdateException) { if (PINExists(pIN.PINID)) { return(Conflict()); } else { throw; } } return(CreatedAtRoute("DefaultApi", new { id = pIN.PINID }, pIN)); }
public void Withdraw_100() { // // Arrange Customer customer = Customer.Create( PIN.Create("08724050601"), Name.Create("Ivan Paulovich")); Account account = Account.Create( customer, Amount.Create(1000.0)); customer.Register(account); Account sut = customer.GetAccounts().First(); Transaction transaction = Debit.Create( customer.Id, Amount.Create(100.0)); // // Act sut.Withdraw(transaction); // // Assert var transactions = sut.GetTransactions(); var deposited = transactions.Where(e => e.Id == transaction.Id).First(); Assert.Equal(deposited.GetAmount().Value, 100.0); Assert.Equal(sut.GetCurrentBalance().Value, 900); }
public void Withdraw_100() { // // Arrange Account account = Account.Create( Guid.NewGuid(), Amount.Create(1000.0)); Customer customer = Customer.Create( PIN.Create("08724050601"), Name.Create("Ivan Paulovich")); customer.Register(account); Account sut = customer.GetAccounts().First(); Transaction transaction = Debit.Create( customer.Id, Amount.Create(100.0)); // // Act sut.Withdraw(transaction); // // Assert var domainEvents = sut.GetEvents(); var deposited = domainEvents.Where(e => e is WithdrewDomainEvent).First() as WithdrewDomainEvent; Assert.Equal(deposited.Amount.Value, 100.0); Assert.Equal(sut.GetCurrentBalance().Value, 900); }
public void Close_Account() { // // Arrange Account account = Account.Create( Guid.NewGuid(), Amount.Create(1000.0)); Customer customer = Customer.Create( PIN.Create("08724050601"), Name.Create("Ivan Paulovich")); customer.Register(account); Account sut = customer.GetAccounts().First(); Transaction transaction = Debit.Create( customer.Id, Amount.Create(1000.0)); sut.Withdraw(transaction); // // Act sut.Close(); // // Assert var domainEvents = sut.GetEvents(); var closed = domainEvents.Where(e => e is ClosedDomainEvent).Count(); Assert.NotEqual(closed, 0); }
public WalletPinConfirmationViewModel(INavigationService navigationService) : base("Confirm Pin", navigationService) { NoError = true; ConfirmPin = new Command(async() => { if (!string.IsNullOrEmpty(First) && !string.IsNullOrEmpty(Second) && !string.IsNullOrEmpty(Third) && !string.IsNullOrEmpty(Fourth)) { string toConfirm = $"{First}{Second}{Third}{Fourth}"; if (PIN.Equals(toConfirm)) { NoMatch = false; Preferences.Set(AppConstant.PIN, toConfirm); await NavigationService.NavigateToAsync <AllowFingerprintViewModel>(); } else { NoMatch = true; await Task.Delay(3000); NoMatch = false; } } }); }
public List <AttemptViewModel> FindResults(int id) { PIN pin = _context.PIN.Where(x => x.Id == id).Include(e => e.Attempts).FirstOrDefault(); var model = new List <AttemptViewModel>(); foreach (var attempt in pin.Attempts) { var attemptUser = _context.Attempt.Where(x => x.Id == attempt.Id).Include(e => e.User).FirstOrDefault(); attempt.User = attemptUser.User; List <Result> results = _context.Result.Where(x => x.AttemptID == attempt.Id).ToList(); int correct = 0; int total = 0; foreach (var result in results) { if (result.Response) { correct++; } total++; } model.Add(new AttemptViewModel { attempt = attempt, total = total, correct = correct }); } return(model); }
/// <summary> /// Return a JSON representation of this object. /// </summary> /// <param name="CustomQRCodeIdentificationSerializer">A delegate to serialize custom QR code identification JSON objects.</param> public JObject ToJSON(CustomJObjectSerializerDelegate <QRCodeIdentification> CustomQRCodeIdentificationSerializer = null) { var JSON = JSONObject.Create( new JProperty("EvcoID", EVCOId.ToString()), PIN.IsNotNullOrEmpty() ? Function == PINCrypto.None ? new JProperty("PIN", PIN) : new JProperty("HashedPIN", JSONObject.Create( new JProperty("Value", PIN), new JProperty("Function", Function.AsString()), new JProperty("Salt", Salt) )) : null ); return(CustomQRCodeIdentificationSerializer != null ? CustomQRCodeIdentificationSerializer(this, JSON) : JSON); }
public int CompareTo(Citizen other) { #if DEBUG return((FirstName, LastName).CompareTo((other.FirstName, other.LastName))); #else return(PIN.CompareTo(other.PIN)); #endif }
//backspace button private void Button_Click_3(object sender, RoutedEventArgs e) { if (tb.Text.Length >= 1) { tb.Text = tb.Text.Substring(0, tb.Text.Length - 1); PIN = PIN.Substring(0, PIN.Length - 1); } }
public PinDefinition GetPin(PIN type) { if (PINLOOKUP.ContainsKey(type)) { return(PINLOOKUP[type]); } return(null); }
public void DisablePIN(string code) { PIN pin = _context.PIN.FirstOrDefault(x => x.Code == code); pin.Active = false; _context.PIN.Update(pin); _context.SaveChanges(); }
/// <summary> /// Returns true if OutputCredentialsInfo instances are equal /// </summary> /// <param name="other">Instance of OutputCredentialsInfo to be compared</param> /// <returns>Boolean</returns> public bool Equals(OutputCredentialsInfo other) { if (ReferenceEquals(null, other)) { return(false); } if (ReferenceEquals(this, other)) { return(true); } return (( Description == other.Description || Description != null && Description.Equals(other.Description) ) && ( Key == other.Key || Key != null && Key.Equals(other.Key) ) && ( Cert == other.Cert || Cert != null && Cert.Equals(other.Cert) ) && ( AuthMode == other.AuthMode || AuthMode != null && AuthMode.Equals(other.AuthMode) ) && ( SCAL == other.SCAL || SCAL != null && SCAL.Equals(other.SCAL) ) && ( PIN == other.PIN || PIN != null && PIN.Equals(other.PIN) ) && ( OTP == other.OTP || OTP != null && OTP.Equals(other.OTP) ) && ( Multisign == other.Multisign || Multisign != null && Multisign.Equals(other.Multisign) ) && ( Lang == other.Lang || Lang != null && Lang.Equals(other.Lang) )); }
public RegisteredDomainEvent(Guid aggregateRootId, int version, DateTime createdDate, Header header, Name name, PIN pin, Guid accountId, Amount initialAmount) : base(aggregateRootId, version, createdDate, header) { this.Name = name; this.PIN = pin; this.AccountId = accountId; this.InitialAmount = initialAmount; }
/// <summary> /// Get the hashcode of this object. /// </summary> public override Int32 GetHashCode() { unchecked { return(EVCOId.GetHashCode() * 7 ^ PIN.GetHashCode() * 5 ^ Function.GetHashCode() * 3 ^ Salt.GetHashCode()); } }
public void Empty_PIN() { // // Arrange string empty = string.Empty; // // Act and Assert Assert.Throws <PINShouldNotBeEmptyException>( () => PIN.Create(empty)); }
public async Task <IHttpActionResult> GetPIN(Guid id) { PIN pIN = await db.PINs.FindAsync(id); if (pIN == null) { return(NotFound()); } return(Ok(pIN)); }
/// <summary> /// Compares two QR code identifications with (hashed) pins for equality. /// </summary> /// <param name="QRCodeIdentification">An QR code identification with (hashed) pin to compare with.</param> /// <returns>True if both match; False otherwise.</returns> public Boolean Equals(QRCodeIdentification QRCodeIdentification) { if ((Object)QRCodeIdentification == null) { return(false); } return(EVCOId.Equals(QRCodeIdentification.EVCOId) && PIN.Equals(QRCodeIdentification.PIN) && Function.Equals(QRCodeIdentification.Function) && Salt.Equals(QRCodeIdentification.Salt)); }
public RegisteredDomainEvent( Guid aggregateRootId, int version, Name customerName, PIN customerPIN, Guid accountId) { AggregateRootId = aggregateRootId; Version = version; CustomerName = customerName; CustomerPIN = customerPIN; AccountId = accountId; }
public void Valid_PIN() { // // Arrange string valid = "08724050601"; // // Act PIN pin = PIN.Create(valid); // Assert Assert.Equal(valid, pin.Text); }
public void Valid_PIN_Should_Be_Created() { // // Arrange string valid = "08724050601"; // // Act PIN pin = new PIN(valid); // Assert Assert.Equal(valid, pin.Text); }
public static RegisteredDomainEvent Create(AggregateRoot aggregateRoot, Name name, PIN pin, Guid accountId, Amount initialAmount) { if (aggregateRoot == null) { throw new ArgumentNullException(nameof(aggregateRoot)); } RegisteredDomainEvent domainEvent = new RegisteredDomainEvent( aggregateRoot.Id, aggregateRoot.Version, DateTime.UtcNow, null, name, pin, accountId, initialAmount); return(domainEvent); }
public override void PIN(PIN Options) { Console.WriteLine ("Pin file {0} account {1}", Options.Configuration, Options.Account); OmniBroker.Config Config = new OmniBroker.Config (Options.Configuration.Value); Connect Connect = Config.GetConnect (Options.Handle.Text); Seed LatestSeed = Connect.Secrets.First (); if (LatestSeed == null) throw new Exception ("Cryptographic seed not initialized"); string PIN = Cryptography.MakePin (Options.Account.Value, LatestSeed.MasterSeed.KeyData, 8); Console.WriteLine ("PIN value for account {0} is {1}", Options.Account, PIN); Console.WriteLine (" Will expire on [TBS]"); }
public async Task <IHttpActionResult> DeletePIN(Guid id) { PIN pIN = await db.PINs.FindAsync(id); if (pIN == null) { return(NotFound()); } db.PINs.Remove(pIN); await db.SaveChangesAsync(); return(Ok(pIN)); }
public GeneratePINViewModel GeneratePIN(int quizId, string userId) { Random rnd = new Random(); string code = rnd.Next(100000, 999999).ToString(); PIN pin = new PIN { Active = true, Code = code, QuizID = quizId, UserId = userId }; this.CreatePIN(pin); return(new GeneratePINViewModel { PIN = code, }); }
/// <summary> /// Returns true if InputCredentialsAuthorize instances are equal /// </summary> /// <param name="other">Instance of InputCredentialsAuthorize to be compared</param> /// <returns>Boolean</returns> public bool Equals(InputCredentialsAuthorize other) { if (ReferenceEquals(null, other)) { return(false); } if (ReferenceEquals(this, other)) { return(true); } return (( CredentialID == other.CredentialID || CredentialID != null && CredentialID.Equals(other.CredentialID) ) && ( NumSignatures == other.NumSignatures || NumSignatures != null && NumSignatures.Equals(other.NumSignatures) ) && ( Hash == other.Hash || Hash != null && Hash.Equals(other.Hash) ) && ( PIN == other.PIN || PIN != null && PIN.Equals(other.PIN) ) && ( OTP == other.OTP || OTP != null && OTP.Equals(other.OTP) ) && ( Description == other.Description || Description != null && Description.Equals(other.Description) ) && ( ClientData == other.ClientData || ClientData != null && ClientData.Equals(other.ClientData) )); }
public Customer(PIN pin, Name name) : this() { if (pin == null) { throw new ArgumentNullException(nameof(pin)); } if (name == null) { throw new ArgumentNullException(nameof(name)); } PIN = pin; Name = name; }
protected void When(RegisteredDomainEvent domainEvent) { if (domainEvent == null) { throw new ArgumentNullException(nameof(domainEvent)); } Id = domainEvent.AggregateRootId; name = domainEvent.Name; pin = domainEvent.PIN; Account account = Account.Load(domainEvent.AccountId, domainEvent.InitialAmount); accounts = new List <Account>(); accounts.Add(account); }
/// <summary> /// Set the state of the pin /// </summary> /// <param name="bus"></param> /// <param name="pin"></param> /// <param name="value"></param> /// <returns></returns> public FTDI.FT_STATUS SetPin(DIO_BUS bus, PIN pin, bool value) { byte pin_num = Convert.ToByte(pin); FTDI.FT_STATUS status = SetPin(bus, pin_num, value); return status; }
private void CONTROL(PIN chanel, int status) { try { if (serial_port.IsOpen) { switch (chanel) { case PIN.MOTO2: if (status == ON) serial_port.Write("role 0005\r\n"); else serial_port.Write("role 0006\r\n"); break; case PIN.FAN2: if (status == ON) serial_port.Write("role 0007\r\n"); else serial_port.Write("role 0008\r\n"); break; case PIN.VAN: if (status == ON) { serial_port.Write("role 0001\r\n"); fireStatus = true; } else { serial_port.Write("role 0002\r\n"); fireStatus = false; } break; case PIN.FIRE: if (status == ON) serial_port.Write("role 0003\r\n"); else serial_port.Write("role 0004\r\n"); break; case PIN.MOTO1_PWM: string x = generate_command(status); serial_port.Write("pwm1 " + generate_command(status) + "\r\n"); break; case PIN.FAN1_PWM: serial_port.Write("pwm2 " + generate_command(status) + "\r\n"); break; case PIN.BEEP: if (status == ON) serial_port.Write("role 0009\r\n"); else serial_port.Write("role 0000\r\n"); break; default: break; } } } catch (Exception) {/* MessageBox.Show("Chưa kết nối"); */} }
/// <summary> /// Reads the state of the pin /// </summary> /// <param name="bus"></param> /// <param name="pin"></param> /// <returns></returns> public bool ReadPin(DIO_BUS bus, PIN pin) { byte pin_num = Convert.ToByte(pin); bool value = ReadPin(bus, pin_num); return value; }
public virtual void PIN( PIN Options ) { char UsageFlag = '-'; { PIN Dummy = new PIN (); Console.Write ("{0}pin ", UsageFlag); Console.Write ("[{0}] ", Dummy.Configuration.Usage (null, "config", UsageFlag)); Console.Write ("[{0}] ", Dummy.Account.Usage (null, "account", UsageFlag)); Console.Write ("[{0}] ", Dummy.Handle.Usage ("id", "value", UsageFlag)); Console.WriteLine (); Console.WriteLine (" Provide a pin code for the specified account"); } Console.WriteLine (" {0}\t{1} = [{2}]", "ExistingFile", "Configuration", Options.Configuration); Console.WriteLine (" {0}\t{1} = [{2}]", "String", "Account", Options.Account); Console.WriteLine (" {0}\t{1} = [{2}]", "String", "Handle", Options.Handle); Console.WriteLine ("Not Yet Implemented"); }
private static void Usage() { Console.WriteLine ("Omnibroker Connection Service"); Console.WriteLine (""); { Server Dummy = new Server (); Console.Write ("{0}server ", UsageFlag); Console.Write ("[{0}] ", Dummy.Configuration.Usage (null, "config", UsageFlag)); Console.Write ("[{0}] ", Dummy.Log.Usage ("log", "value", UsageFlag)); Console.Write ("[{0}] ", Dummy.Detach.Usage ("detach", "value", UsageFlag)); Console.Write ("[{0}] ", Dummy.Handle.Usage ("id", "value", UsageFlag)); Console.WriteLine (); Console.WriteLine (" Launch omnibroker connection service"); } { PIN Dummy = new PIN (); Console.Write ("{0}pin ", UsageFlag); Console.Write ("[{0}] ", Dummy.Configuration.Usage (null, "config", UsageFlag)); Console.Write ("[{0}] ", Dummy.Account.Usage (null, "account", UsageFlag)); Console.Write ("[{0}] ", Dummy.Handle.Usage ("id", "value", UsageFlag)); Console.WriteLine (); Console.WriteLine (" Provide a pin code for the specified account"); } { Initialize Dummy = new Initialize (); Console.Write ("{0}init ", UsageFlag); Console.Write ("[{0}] ", Dummy.Configuration.Usage (null, "config", UsageFlag)); Console.Write ("[{0}] ", Dummy.Handle.Usage ("id", "value", UsageFlag)); Console.Write ("[{0}] ", Dummy.Refresh.Usage ("refresh", "value", UsageFlag)); Console.WriteLine (); Console.WriteLine (" Create and register new master secrets"); } { Rollover Dummy = new Rollover (); Console.Write ("{0}roll ", UsageFlag); Console.WriteLine (); Console.WriteLine (" Roll over the master secrets"); } }
private static void Handle_PIN( OBPConnect Dispatch, string[] args, int index) { PIN Options = new PIN (); Registry Registry = new Registry (); Options.Configuration.Register ("config", Registry, (int) TagType_PIN.Configuration); Options.Account.Register ("account", Registry, (int) TagType_PIN.Account); Options.Handle.Register ("id", Registry, (int) TagType_PIN.Handle); // looking for parameter Param.Name} if (index < args.Length && !IsFlag (args [index][0] )) { // Have got the parameter, call the parameter value method Options.Configuration.Parameter (args [index]); index++; } // looking for parameter Param.Name} if (index < args.Length && !IsFlag (args [index][0] )) { // Have got the parameter, call the parameter value method Options.Account.Parameter (args [index]); index++; } #pragma warning disable 162 for (int i = index; i< args.Length; i++) { if (!IsFlag (args [i][0] )) { throw new Exception ("Unexpected parameter: " + args[i]);} string Rest = args [i].Substring (1); TagType_PIN TagType = (TagType_PIN) Registry.Find (Rest); // here have the cases for what to do with it. switch (TagType) { case TagType_PIN.Handle : { int OptionParams = Options.Handle.Tag (Rest); if (OptionParams>0 && ((i+1) < args.Length)) { if (!IsFlag (args [i+1][0] )) { i++; Options.Handle.Parameter (args[i]); } } break; } default : throw new Exception ("Internal error"); } } #pragma warning restore 162 Dispatch.PIN (Options); }