/// <summary> /// Constructor. /// </summary> /// <param name="pinCode"></param> public RaspberyPin(PinCode pinCode) { this.Code = pinCode; this.Group = GetGPIOGroup(pinCode); if (pinCode.ToString().Contains("GPIO")) { this.Type = PinType.GPIO; this.Direction = PinDirection.Out; this.Value = PinValue.Low; } else if (pinCode.ToString().Contains("GND")) { this.Type = PinType.GND; this.Direction = PinDirection.Out; this.Value = PinValue.Low; } else if (pinCode.ToString().Contains("3V")) { this.Type = PinType.POWER; this.Direction = PinDirection.Out; this.Value = PinValue.High; } else if (pinCode.ToString().Contains("5V")) { this.Type = PinType.POWER; this.Direction = PinDirection.Out; this.Value = PinValue.High; } }
static void Main(string[] args) { var pin1 = new PinCode(new char[] { '1', '2', '3', '4' }); var pin2 = PinCode.NewPinCode(); var pin3 = PinCode.NewPinCode(); Console.WriteLine(pin1); Console.WriteLine(pin2); Console.WriteLine(pin3); // Bad practice. We should dispose this object at the end. var rng = new RNGCryptoServiceProvider(); var data = new byte[4]; rng.GetBytes(data); var seed = BitConverter.ToInt32(data, 0); var rnd = new Random(seed); var guid1 = new Guid(); var guid2 = Guid.NewGuid(); Console.WriteLine(guid1.ToString()); Console.WriteLine(guid2.ToString()); }
public static string AddCustomer(string C_Name, long C_Contact, string C_email, DateTime C_Dob, int C_PinCode, string C_State, string C_City, string C_Pwd) { Customer CustAdd = new Customer(); CustAdd.name = C_Name; CustAdd.c_contact = C_Contact; CustAdd.c_email = C_email; CustAdd.Dob = C_Dob; CustAdd.pincode = C_PinCode; PinCode pin = new PinCode(); pin.city = C_City; pin.state = C_State; pin.pin = C_PinCode; CustAdd.PinCode1 = pin; CustAdd.password = C_Pwd; string AddCust_res = HRSData.AddCustomer(CustAdd); string alert; if (AddCust_res.CompareTo("no_C_Id") == 0) { alert = "Customer Not Added"; } else { alert = AddCust_res.ToString(); } return(alert); }
/// <summary> /// Gets raspberry device pin value. /// </summary> /// <param name="pinCode">Raspberry pin code</param> /// <returns></returns> public PinValue GetPinValue(PinCode pinCode) { if (!this.IsInitialized) { throw new Exception("Raspberry device not initialized"); } try { string pinAddress = pinCode.ToString().Split('_').Last().Replace("0", ""); double value = 0; if (Environment.OSVersion.Platform == PlatformID.Unix) { value = double.Parse(("cat /sys/class/gpio/gpio" + pinAddress + "/value").Bash()); if (value > 0) { this._devicePins.Where(p => p.Code == pinCode).SingleOrDefault().Value = PinValue.High; } else { this._devicePins.Where(p => p.Code == pinCode).SingleOrDefault().Value = PinValue.Low; } } } catch (Exception ex) { throw ex; } return(this._devicePins.Where(p => p.Code == pinCode).SingleOrDefault().Value); }
public async Task <IActionResult> Edit(int id, [Bind("Id,Pin,Name,Enabled,ActionGroupId")] PinCode pinCode) { if (id != pinCode.Id) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(pinCode); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!PinCodeExists(pinCode.Id)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } ViewData["ActionGroupId"] = new SelectList(_context.ActionGroups, "Id", "Id", pinCode.ActionGroupId); return(View(pinCode)); }
public bool IsPinCodeValid(PinCode pinCode) { int?firstValue = null; for (int i = 0; i < pinCode.ToString().Length; i++) { int pinCodeUnit = pinCode.AsParts()[i]; if (firstValue == null) { firstValue = pinCodeUnit; continue; } if (firstValue == pinCodeUnit) { _logger.Warn("Two consecutive values found, pincode is not valid"); return(false); } int prevPinCodeValue = int.Parse(firstValue.ToString()); int pinCodeValue = int.Parse(pinCodeUnit.ToString()); if (prevPinCodeValue == pinCodeValue - 1 && i != pinCode.ToString().Length - 1) { _logger.Warn("Two consecutive sequential values found"); int nextValue = pinCode.AsParts()[i + 1]; if (pinCodeValue == nextValue - 1) { _logger.Warn("Three consecutive sequential values found"); return(false); } } } return(true); }
private void State_KeyDown(object sender, KeyEventArgs e) { if (e.Key == Key.Enter) { PinCode.Focus(); } }
private void OnRemoveNumberClicked(object sender, System.EventArgs e) { if (PinCode.Length > 0) { PinCode = PinCode.Substring(0, PinCode.Length - 1); UpdateRemoveNumberBtnVisibility(); } }
/// <summary> /// Gets GPIO group based on pin code. /// </summary> /// <param name="pinCode"></param> /// <returns></returns> public static PinGroup GetGPIOGroup(PinCode pinCode) { if (pinCode.ToString().Contains("GPIO")) { switch (pinCode) { case PinCode.PIN3_GPIO_02: case PinCode.PIN5_GPIO_03: return(PinGroup.I2C); case PinCode.PIN8_GPIO_14: case PinCode.PIN10_GPIO_15: return(PinGroup.UART); case PinCode.PIN19_GPIO_10: case PinCode.PIN21_GPIO_09: case PinCode.PIN23_GPIO_11: case PinCode.PIN24_GPIO_08: case PinCode.PIN26_GPIO_27: case PinCode.PIN35_GPIO_19: case PinCode.PIN38_GPIO_20: case PinCode.PIN40_GPIO_21: return(PinGroup.SPI); default: return(PinGroup.GPIO); } } else if (pinCode.ToString().Contains("GND")) { return(PinGroup.GND); } else if (pinCode.ToString().Contains("3V")) { return(PinGroup.V3); } else if (pinCode.ToString().Contains("5V")) { return(PinGroup.V5); } else if (pinCode.ToString().Contains("ID")) { return(PinGroup.I2C); } else { return(PinGroup.GPIO); } }
/// <summary> /// Gets pin name based on pin code. /// </summary> /// <param name="pinCode"></param> /// <returns></returns> public static string GetGPIOLabel(PinCode pinCode) { string result = ""; string[] parts = pinCode.ToString().Split('_'); parts[0] = ""; for (int i = 0; i < parts.Length; i++) { result += parts[i]; } return(result); }
public async Task <IActionResult> Create([Bind("Id,Pin,Name,Enabled,ActionGroupId")] PinCode pinCode) { if (ModelState.IsValid) { _context.Add(pinCode); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } ViewData["ActionGroupId"] = new SelectList(_context.ActionGroups, "Id", "Name", pinCode.ActionGroupId); return(View(pinCode)); }
private void buttonBackOffice_Click(object sender, RoutedEventArgs e) { PinCode Pin = new PinCode(); BackOffice BO = new BackOffice(); BO.mainWindow = this; Pin.MW = this; this.Opacity = 0.4; Pin.ShowDialog(); if (Pin.IsValidUser) { this.Hide(); BO.ShowDialog(); } }
public override int GetHashCode() { int hashcode = 157; unchecked { if (__isset.authToken) { hashcode = (hashcode * 397) + AuthToken.GetHashCode(); } if (__isset.certificate) { hashcode = (hashcode * 397) + Certificate.GetHashCode(); } if (__isset.verifier) { hashcode = (hashcode * 397) + Verifier.GetHashCode(); } if (__isset.pinCode) { hashcode = (hashcode * 397) + PinCode.GetHashCode(); } if (__isset.type) { hashcode = (hashcode * 397) + Type.GetHashCode(); } if (__isset.lastPrimaryBindTime) { hashcode = (hashcode * 397) + LastPrimaryBindTime.GetHashCode(); } if (__isset.displayMessage) { hashcode = (hashcode * 397) + DisplayMessage.GetHashCode(); } if (__isset.sessionForSMSConfirm) { hashcode = (hashcode * 397) + SessionForSMSConfirm.GetHashCode(); } } return(hashcode); }
public static string UpdateHotel(string ManagerId, string HotelId, string HotelName, string HotelDsrrp, int pincode, string Country, string City, int No_Of_Ac_Rooms, int No_Of_Non_Ac_Rooms, int price_ac_adult, int price_ac_child, int price_nonac_adult, int price_nonac_child) { Hotel update = new Hotel(); update.hotel_description = HotelDsrrp; update.id = HotelId; update.name = HotelName; update.manager_id = ManagerId; update.pincode = pincode; PinCode pin = new PinCode(); pin.pin = pincode; pin.state = Country; pin.city = City; update.PinCode1 = pin; update.no_of_ac_rooms = No_Of_Ac_Rooms; update.no_of_non_ac_rooms = No_Of_Non_Ac_Rooms; return(HRSData.UpdateHoteldata(update, price_ac_adult, price_ac_child, price_nonac_adult, price_nonac_child)); }
public static string UpdateCustomer(string C_ID, string C_Name, long C_Contact, string C_email, DateTime C_Dob, int C_PinCode, string C_Country, string C_City, string C_Pwd) { Customer CustAdd = new Customer(); CustAdd.id = C_ID; CustAdd.name = C_Name; CustAdd.c_contact = C_Contact; CustAdd.c_email = C_email; CustAdd.Dob = C_Dob; CustAdd.pincode = C_PinCode; PinCode pin = new PinCode(); pin.city = C_City; pin.state = C_Country; pin.pin = C_PinCode; CustAdd.PinCode1 = pin; CustAdd.password = C_Pwd; string AddCust_res = HRSData.UpdateCustomer(CustAdd); return(AddCust_res); }
/// <summary> /// Sets raspbery device pin direction. /// </summary> /// <param name="pinCode">Raspberry pin code</param> /// <param name="pinDirection">Raspberry pin direction</param> public void SetPinDirection(PinCode pinCode, PinDirection pinDirection) { if (!this.IsInitialized) { throw new Exception("Raspberry device not initialized"); } if (!RaspberyPin.IsGPIOPin(pinCode)) { throw new Exception("Can not set pin direction to non GPIO pin"); } try { string pinAddress = pinCode.ToString().Split('_').Last().Replace("0", ""); string direction = ""; switch (pinDirection) { case PinDirection.In: direction = "in"; break; case PinDirection.Out: direction = "out"; break; } if (Environment.OSVersion.Platform == PlatformID.Unix) { ("echo " + direction + " > /sys/class/gpio/gpio" + pinAddress + "/direction").Bash(); } this._devicePins.Where(p => p.Code == pinCode).SingleOrDefault().Direction = pinDirection; } catch (Exception ex) { throw ex; } }
/// <summary> /// Sets raspberry device pin value. /// </summary> /// <param name="pinCode">Raspberry pin</param> /// <param name="pinValue">Raspberry pin value</param> public void SetPinValue(PinCode pinCode, PinValue pinValue) { if (!this.IsInitialized) { throw new Exception("Raspberry device not initialized"); } if (!RaspberyPin.IsGPIOPin(pinCode)) { throw new Exception("Can not set pin value to non GPIO pin"); } try { string pinAddress = pinCode.ToString().Split('_').Last().Replace("0", ""); string value = ""; switch (pinValue) { case PinValue.High: value = "1"; break; case PinValue.Low: value = "0"; break; } if (Environment.OSVersion.Platform == PlatformID.Unix) { ("echo " + value + " > /sys/class/gpio/gpio" + pinAddress + "/value").Bash(); } this._devicePins.Where(p => p.Code == pinCode).SingleOrDefault().Value = pinValue; } catch (Exception ex) { throw ex; } }
public override string ToString() { var sb = new StringBuilder("LoginResult("); bool __first = true; if (AuthToken != null && __isset.authToken) { if (!__first) { sb.Append(", "); } __first = false; sb.Append("AuthToken: "); AuthToken.ToString(sb); } if (Certificate != null && __isset.certificate) { if (!__first) { sb.Append(", "); } __first = false; sb.Append("Certificate: "); Certificate.ToString(sb); } if (Verifier != null && __isset.verifier) { if (!__first) { sb.Append(", "); } __first = false; sb.Append("Verifier: "); Verifier.ToString(sb); } if (PinCode != null && __isset.pinCode) { if (!__first) { sb.Append(", "); } __first = false; sb.Append("PinCode: "); PinCode.ToString(sb); } if (__isset.type) { if (!__first) { sb.Append(", "); } __first = false; sb.Append("Type: "); Type.ToString(sb); } if (__isset.lastPrimaryBindTime) { if (!__first) { sb.Append(", "); } __first = false; sb.Append("LastPrimaryBindTime: "); LastPrimaryBindTime.ToString(sb); } if (DisplayMessage != null && __isset.displayMessage) { if (!__first) { sb.Append(", "); } __first = false; sb.Append("DisplayMessage: "); DisplayMessage.ToString(sb); } if (SessionForSMSConfirm != null && __isset.sessionForSMSConfirm) { if (!__first) { sb.Append(", "); } __first = false; sb.Append("SessionForSMSConfirm: "); SessionForSMSConfirm.ToString(sb); } sb.Append(")"); return(sb.ToString()); }
public static Customer GetCustomer(string C_custID) { Customer C_getdetails = new Customer(); C_getdetails.id = C_custID; SqlConnection con = new SqlConnection(ConfigurationManager.ConnectionStrings["CS"].ConnectionString); con.Open(); SqlCommand cmd = new SqlCommand("GetCustomerDetails", con); cmd.CommandType = CommandType.StoredProcedure; cmd.Parameters.Add(new SqlParameter("@Customer_id", C_custID)); SqlParameter out_CustomerName = new SqlParameter(); out_CustomerName.ParameterName = "@name"; out_CustomerName.SqlDbType = SqlDbType.VarChar; out_CustomerName.Direction = ParameterDirection.Output; out_CustomerName.Size = 50; cmd.Parameters.Add(out_CustomerName); SqlParameter out_CustomerContact = new SqlParameter(); out_CustomerContact.ParameterName = "@c_contact"; out_CustomerContact.SqlDbType = SqlDbType.BigInt; out_CustomerContact.Direction = ParameterDirection.Output; cmd.Parameters.Add(out_CustomerContact); SqlParameter out_CustomerEmail = new SqlParameter(); out_CustomerEmail.ParameterName = "@c_email"; out_CustomerEmail.SqlDbType = SqlDbType.VarChar; out_CustomerEmail.Direction = ParameterDirection.Output; out_CustomerEmail.Size = 30; cmd.Parameters.Add(out_CustomerEmail); SqlParameter out_CustomerDob = new SqlParameter(); out_CustomerDob.ParameterName = "@dob"; out_CustomerDob.SqlDbType = SqlDbType.Date; out_CustomerDob.Direction = ParameterDirection.Output; cmd.Parameters.Add(out_CustomerDob); SqlParameter out_CustomerPin = new SqlParameter(); out_CustomerPin.ParameterName = "@pincode"; out_CustomerPin.SqlDbType = SqlDbType.Int; out_CustomerPin.Direction = ParameterDirection.Output; cmd.Parameters.Add(out_CustomerPin); SqlParameter out_CustomerCity = new SqlParameter(); out_CustomerCity.ParameterName = "@city"; out_CustomerCity.SqlDbType = SqlDbType.VarChar; out_CustomerCity.Direction = ParameterDirection.Output; out_CustomerCity.Size = 20; cmd.Parameters.Add(out_CustomerCity); SqlParameter out_CustomerCountry = new SqlParameter(); out_CustomerCountry.ParameterName = "@state"; out_CustomerCountry.SqlDbType = SqlDbType.VarChar; out_CustomerCountry.Direction = ParameterDirection.Output; out_CustomerCountry.Size = 10; cmd.Parameters.Add(out_CustomerCountry); SqlParameter out_CustomerPassword = new SqlParameter(); out_CustomerPassword.ParameterName = "@password"; out_CustomerPassword.SqlDbType = SqlDbType.VarChar; out_CustomerPassword.Direction = ParameterDirection.Output; out_CustomerPassword.Size = 25; cmd.Parameters.Add(out_CustomerPassword); int result = cmd.ExecuteNonQuery(); if (result == -1) { C_getdetails.id = C_custID; C_getdetails.c_contact = long.Parse(cmd.Parameters["@c_contact"].Value.ToString()); C_getdetails.name = cmd.Parameters["@name"].Value.ToString(); C_getdetails.c_email = cmd.Parameters["@c_email"].Value.ToString(); C_getdetails.Dob = Convert.ToDateTime(cmd.Parameters["@dob"].Value.ToString()); C_getdetails.pincode = int.Parse(cmd.Parameters["@pincode"].Value.ToString()); C_getdetails.password = cmd.Parameters["@password"].Value.ToString(); PinCode pin = new PinCode(); pin.city = cmd.Parameters["@city"].Value.ToString(); pin.state = cmd.Parameters["@state"].Value.ToString(); pin.pin = int.Parse(cmd.Parameters["@pincode"].Value.ToString()); C_getdetails.PinCode1 = pin; } else { C_getdetails.id = "C_Idnot"; } con.Close(); return(C_getdetails); }
public static Hotel RetriveHotels(string ret_id) { Hotel R_id = new Hotel(); R_id.id = ret_id; SqlConnection con = new SqlConnection(ConfigurationManager.ConnectionStrings["CS"].ConnectionString); con.Open(); SqlCommand cmd = new SqlCommand("GetHotelDetails", con); cmd.CommandType = CommandType.StoredProcedure; cmd.Parameters.Add(new SqlParameter("@hotel_id", R_id.id)); SqlParameter out_name = new SqlParameter(); out_name.ParameterName = "@name"; out_name.SqlDbType = SqlDbType.VarChar; out_name.Direction = ParameterDirection.Output; out_name.Size = 50; cmd.Parameters.Add(out_name); SqlParameter out_hotel_description = new SqlParameter(); out_hotel_description.ParameterName = "@hotel_description"; out_hotel_description.SqlDbType = SqlDbType.VarChar; out_hotel_description.Direction = ParameterDirection.Output; out_hotel_description.Size = 1000; cmd.Parameters.Add(out_hotel_description); SqlParameter out_pincode = new SqlParameter(); out_pincode.ParameterName = "@pincode"; out_pincode.SqlDbType = SqlDbType.Int; out_pincode.Direction = ParameterDirection.Output; cmd.Parameters.Add(out_pincode); SqlParameter out_country = new SqlParameter(); out_country.ParameterName = "@state"; out_country.SqlDbType = SqlDbType.VarChar; out_country.Size = 20; out_country.Direction = ParameterDirection.Output; cmd.Parameters.Add(out_country); SqlParameter out_city = new SqlParameter(); out_city.ParameterName = "@city"; out_city.SqlDbType = SqlDbType.VarChar; out_city.Size = 20; out_city.Direction = ParameterDirection.Output; cmd.Parameters.Add(out_city); SqlParameter out_manager_id = new SqlParameter(); out_manager_id.ParameterName = "@manager_id"; out_manager_id.SqlDbType = SqlDbType.VarChar; out_manager_id.Direction = ParameterDirection.Output; out_manager_id.Size = 10; cmd.Parameters.Add(out_manager_id); SqlParameter out_ac_room = new SqlParameter(); out_ac_room.ParameterName = "@ac_room"; out_ac_room.SqlDbType = SqlDbType.Int; out_ac_room.Direction = ParameterDirection.Output; cmd.Parameters.Add(out_ac_room); SqlParameter out_non_ac_rooms = new SqlParameter(); out_non_ac_rooms.ParameterName = "@non_ac_room"; out_non_ac_rooms.SqlDbType = SqlDbType.Int; out_non_ac_rooms.Direction = ParameterDirection.Output; cmd.Parameters.Add(out_non_ac_rooms); SqlDataReader reader = cmd.ExecuteReader(); reader.Read(); // int result = // cmd.ExecuteReader(); // if (result == 1) { R_id.id = R_id.ToString(); R_id.name = (cmd.Parameters["@name"].Value.ToString()); R_id.hotel_description = (cmd.Parameters["@hotel_description"].Value.ToString()); R_id.pincode = Convert.ToInt32(cmd.Parameters["@pincode"].Value.ToString()); PinCode pin = new PinCode(); pin.pin = Convert.ToInt32(cmd.Parameters["@pincode"].Value.ToString()); pin.state = (cmd.Parameters["@state"].Value.ToString()); pin.city = (cmd.Parameters["@city"].Value.ToString()); R_id.PinCode1 = pin; R_id.manager_id = (cmd.Parameters["@manager_id"].Value.ToString()); R_id.no_of_ac_rooms = Convert.ToInt32(cmd.Parameters["@ac_room"].Value.ToString()); R_id.no_of_non_ac_rooms = Convert.ToInt32(cmd.Parameters["@non_ac_room"].Value.ToString()); } // else { // R_id.id = "Unable to Retrive Details"; } con.Close(); return(R_id); }
protected override void OnAppearing() { base.OnAppearing(); PinCode.Focus(); }
/// <summary> /// Checks if pin is GPIO pin. /// </summary> /// <param name="pinCode"></param> /// <returns></returns> public static bool IsGPIOPin(PinCode pinCode) { return(pinCode.ToString().ToUpper().Contains("GPIO")); }
protected override void OnAppearingAnimationBegin() { base.OnAppearingAnimationBegin(); Device.BeginInvokeOnMainThread(() => PinCode.Focus()); }
private void OnTapped(object sender, EventArgs e) { PinCode.Focus(); }