private async Task <bool> InitaliseRooms() { Rooms.Clear(); IMobileServiceTableQuery <RoomItem> roomQuery; roomQuery = RoomTable.RoomSyncTable.Where(p => p.HomeId == SelectedHomeId); await RoomTable.Read(roomQuery); foreach (RoomItem RoomItem in RoomTable.RoomItems) { Room room = RoomConverter.CreateFrom(RoomItem); IMobileServiceTableQuery <DeviceItem> deviceQuery; deviceQuery = DeviceTable.deviceTable.Where(p => p.RoomId == room.Id); await DeviceTable.Read(deviceQuery); foreach (DeviceItem DeviceItem in DeviceTable.deviceItems) { Device device = DeviceConverter.CreateFrom(DeviceItem); try { device = await Lights.GetLightState(device); } catch (Exception e) { device.HasAccess = false; } } Rooms.Add(room); } return(true); }
void ReleaseDesignerOutlets() { if (DeviceTable != null) { DeviceTable.Dispose(); DeviceTable = null; } if (DeviceTableHeaderView != null) { DeviceTableHeaderView.Dispose(); DeviceTableHeaderView = null; } if (DeviceTableView != null) { DeviceTableView.Dispose(); DeviceTableView = null; } if (tableContent != null) { tableContent.Dispose(); tableContent = null; } }
private async void HasAccess_ts_Toggled(object sender, RoutedEventArgs e) { ToggleSwitch clickedItem = (ToggleSwitch)e.OriginalSource; try { var item = clickedItem.DataContext; if (item.GetType() == typeof(Home)) { await HomeTable.Update(HomeConverter.CreateFrom((Home)item)); } else if (item.GetType() == typeof(Room)) { await RoomTable.Update(RoomConverter.CreateFrom((Room)item)); } else if (item.GetType() == typeof(Device)) { await DeviceTable.Update(DeviceConverter.CreateFrom((Device)item)); } await Shared.Services.Storage.SyncAsync(); } catch (Exception) { } }
public async Task <bool> GetDevices(string roomid) { Devices.Clear(); IMobileServiceTableQuery <DeviceItem> deviceQuery; deviceQuery = DeviceTable.deviceTable.Where(p => p.RoomId == roomid); await DeviceTable.Read(deviceQuery); foreach (DeviceItem DeviceItem in DeviceTable.deviceItems) { Device device = DeviceConverter.CreateFrom(DeviceItem); Devices.Add(device); } return(true); }
public static async void AddUser(string userID, string homeId) { IMobileServiceTableQuery <HomeItem> homeQuery; homeQuery = HomeTable.HomeSyncTable.Where(p => p.HomeId == homeId); await HomeTable.Read(homeQuery); foreach (HomeItem HomeItem in HomeTable.HomeItems) { HomeItem.UserId = userID; HomeItem.UserName = "******"; HomeItem.Id = null; await HomeTable.Create(HomeItem); IMobileServiceTableQuery <RoomItem> roomQuery; roomQuery = RoomTable.RoomSyncTable.Where(p => p.HomeId == homeId); await RoomTable.Read(roomQuery); foreach (RoomItem RoomItem in RoomTable.RoomItems) { RoomItem.UserId = userID; string roomId = RoomItem.Id; RoomItem.Id = null; RoomItem.HomeId = HomeTable.HomeItem.Id; await RoomTable.Create(RoomItem); IMobileServiceTableQuery <DeviceItem> deviceQuery; deviceQuery = DeviceTable.deviceTable.Where(p => p.RoomId == roomId); await DeviceTable.Read(deviceQuery); foreach (DeviceItem DeviceItem in DeviceTable.deviceItems) { DeviceItem.UserId = userID; DeviceItem.Id = null; DeviceItem.RoomId = RoomTable.RoomItem.Id; await DeviceTable.Create(DeviceItem); } } } }
private async void GetFavouriteDevices() { FavouriteDevices.Clear(); IMobileServiceTableQuery <DeviceItem> deviceQuery; deviceQuery = DeviceTable.deviceTable.Where(p => p.HomeId == SelectedHome.Id && p.Deleted == false); if (await DeviceTable.Read(deviceQuery)) { foreach (DeviceItem DeviceItem in DeviceTable.deviceItems) { Device device = DeviceConverter.CreateFrom(DeviceItem); try { device = await Lights.GetLightState(device); } catch (Exception e) { device.HasAccess = false; } FavouriteDevices.Add(device); } } }
public static async Task <bool> CreateSampleDevice(string deviceName, string deviceId) { Device Device = new Device { CreatedAt = DateTime.Now, UpdatedAt = DateTime.Now, OwnerId = "sid:79cb2d8a9896fd48bac1f3969a9965cc", UserId = "sid:79cb2d8a9896fd48bac1f3969a9965cc", HomeId = HomeTable.HomeItem.Id, RoomId = RoomTable.RoomItem.Id, HasAccess = true, Name = deviceName, Room = RoomTable.RoomItem.Name, DeviceId = deviceId, Status = false, Level = "40%", Deleted = false }; DeviceItem item = DeviceConverter.CreateFrom(Device); await DeviceTable.Create(item); return(true); }
/// <summary> /// /// </summary> /// <returns></returns> public static async Task <bool> PurgeLocalStoreAsync() { Debug.WriteLine("LocalStore.PurgeLocalStoreAsync - Purging Local Store from device"); if (await HomeTable.PurgeTableAsync() && await RoomTable.PurgeTableAsync() && await DeviceTable.PurgeTableAsync()) { Debug.WriteLine("LocalStore.PurgeLocalStoreAsync - Local Store Purged from device"); return(true); } else { return(false); } }
/// <summary> /// /// </summary> /// <returns></returns> public static async Task <bool> PullLocalStoreAsync() { Debug.WriteLine("LocalStore.PullLocalStoreAsync - Pulling Local Store from server"); if (await HomeTable.PullTableAsync() && await RoomTable.PullTableAsync() && await DeviceTable.PullTableAsync()) { Debug.WriteLine("LocalStore.PullLocalStoreAsync - Local Store pulled sucessfully"); return(true); } else { return(false); } }
/// <summary> /// Starts this instance. /// </summary> public static void Start() { // Setup hardware abstraction interface IHardwareAbstraction hardwareAbstraction = new Mosa.EmulatedKernel.HardwareAbstraction(); // Set device driver system to the emulator port and memory methods Mosa.DeviceSystem.HAL.SetHardwareAbstraction(hardwareAbstraction); // Start the emulated devices Mosa.EmulatedDevices.Setup.Initialize(); // Initialize the driver system Mosa.DeviceSystem.Setup.Initialize(); // Registry device drivers Mosa.DeviceSystem.Setup.DeviceDriverRegistry.RegisterBuiltInDeviceDrivers(); Mosa.DeviceSystem.Setup.DeviceDriverRegistry.RegisterDeviceDrivers(typeof(Mosa.DeviceDrivers.ISA.CMOS).Module.Assembly); // Set the interrupt handler Mosa.DeviceSystem.HAL.SetInterruptHandler(Mosa.DeviceSystem.Setup.ResourceManager.InterruptManager.ProcessInterrupt); // Start the driver system Mosa.DeviceSystem.Setup.Start(); // Create pci controller manager PCIControllerManager pciControllerManager = new PCIControllerManager(Mosa.DeviceSystem.Setup.DeviceManager); // Create pci controller devices pciControllerManager.CreatePartitionDevices(); // Create synthetic graphic pixel device Mosa.EmulatedDevices.Synthetic.PixelGraphicDevice pixelGraphicDevice = new Mosa.EmulatedDevices.Synthetic.PixelGraphicDevice(Mosa.EmulatedDevices.Setup.PrimaryDisplayForm); // Added the synthetic graphic device to the device drivers Mosa.DeviceSystem.Setup.DeviceManager.Add(pixelGraphicDevice); // Create synthetic ram disk device Mosa.EmulatedDevices.Synthetic.RamDiskDevice ramDiskDevice = new Mosa.EmulatedDevices.Synthetic.RamDiskDevice(1024 * 1024 * 10 / 512); // Add emulated ram disk device to the device drivers Mosa.DeviceSystem.Setup.DeviceManager.Add(ramDiskDevice); // Create disk controller manager DiskControllerManager diskControllerManager = new DiskControllerManager(Mosa.DeviceSystem.Setup.DeviceManager); // Create disk devices from disk controller devices diskControllerManager.CreateDiskDevices(); // Get the text VGA device LinkedList <IDevice> devices = Mosa.DeviceSystem.Setup.DeviceManager.GetDevices(new FindDevice.WithName("VGAText")); // Create a screen interface to the text VGA device ITextScreen screen = new TextScreen((ITextDevice)devices.First.value); // Create synthetic keyboard device Mosa.EmulatedDevices.Synthetic.Keyboard keyboard = new Mosa.EmulatedDevices.Synthetic.Keyboard(Mosa.EmulatedDevices.Setup.PrimaryDisplayForm); // Add the synthetic keyboard device to the device drivers Mosa.DeviceSystem.Setup.DeviceManager.Add(keyboard); // Create master boot block record MasterBootBlock mbr = new MasterBootBlock(ramDiskDevice); mbr.DiskSignature = 0x12345678; mbr.Partitions[0].Bootable = true; mbr.Partitions[0].StartLBA = 17; mbr.Partitions[0].TotalBlocks = ramDiskDevice.TotalBlocks - 17; mbr.Partitions[0].PartitionType = PartitionType.FAT12; mbr.Write(); // Create partition device PartitionDevice partitionDevice = new PartitionDevice(ramDiskDevice, mbr.Partitions[0], false); // Set FAT settings FatSettings fatSettings = new FatSettings(); fatSettings.FATType = FatType.FAT12; fatSettings.FloppyMedia = false; fatSettings.VolumeLabel = "MOSADISK"; fatSettings.SerialID = new byte[4] { 0x01, 0x02, 0x03, 0x04 }; // Create FAT file system FatFileSystem fat12 = new FatFileSystem(partitionDevice); fat12.Format(fatSettings); // Create partition manager PartitionManager partitionManager = new PartitionManager(Mosa.DeviceSystem.Setup.DeviceManager); // Create partition devices partitionManager.CreatePartitionDevices(); // Get a list of all devices devices = Mosa.DeviceSystem.Setup.DeviceManager.GetAllDevices(); // Print them screen.WriteLine("Devices: "); foreach (IDevice device in devices) { screen.Write(device.Name); screen.Write(" ["); switch (device.Status) { case DeviceStatus.Online: screen.Write("Online"); break; case DeviceStatus.Available: screen.Write("Available"); break; case DeviceStatus.Initializing: screen.Write("Initializing"); break; case DeviceStatus.NotFound: screen.Write("Not Found"); break; case DeviceStatus.Error: screen.Write("Error"); break; } screen.Write("]"); if (device.Parent != null) { screen.Write(" - Parent: "); screen.Write(device.Parent.Name); } screen.WriteLine(); if (device is IPartitionDevice) { FileSystem.FAT.FatFileSystem fat = new Mosa.FileSystem.FAT.FatFileSystem(device as IPartitionDevice); screen.Write(" File System: "); if (fat.IsValid) { switch (fat.FATType) { case FatType.FAT12: screen.WriteLine("FAT12"); break; case FatType.FAT16: screen.WriteLine("FAT16"); break; case FatType.FAT32: screen.WriteLine("FAT32"); break; default: screen.WriteLine("Unknown"); break; } screen.WriteLine(" Volume Name: " + fat.VolumeLabel); } else { screen.WriteLine("Unknown"); } } if (device is PCIDevice) { PCIDevice pciDevice = (device as PCIDevice); screen.Write(" Vendor:0x"); screen.Write(pciDevice.VendorID.ToString("X")); screen.Write(" ["); screen.Write(DeviceTable.Lookup(pciDevice.VendorID)); screen.WriteLine("]"); screen.Write(" Device:0x"); screen.Write(pciDevice.DeviceID.ToString("X")); screen.Write(" Rev:0x"); screen.Write(pciDevice.RevisionID.ToString("X")); screen.Write(" ["); screen.Write(DeviceTable.Lookup(pciDevice.VendorID, pciDevice.DeviceID)); screen.WriteLine("]"); screen.Write(" Class:0x"); screen.Write(pciDevice.ClassCode.ToString("X")); screen.Write(" ["); screen.Write(ClassCodeTable.Lookup(pciDevice.ClassCode)); screen.WriteLine("]"); screen.Write(" SubClass:0x"); screen.Write(pciDevice.SubClassCode.ToString("X")); screen.Write(" ["); screen.Write(SubClassCodeTable.Lookup(pciDevice.ClassCode, pciDevice.SubClassCode, pciDevice.ProgIF)); screen.WriteLine("]"); // screen.Write(" "); // screen.WriteLine(DeviceTable.Lookup(pciDevice.VendorID, pciDevice.DeviceID, pciDevice.SubDeviceID, pciDevice.SubVendorID)); foreach (BaseAddress address in pciDevice.BaseAddresses) { if (address == null) { continue; } if (address.Address == 0) { continue; } screen.Write(" "); if (address.Region == AddressType.IO) { screen.Write("I/O Port at 0x"); } else { screen.Write("Memory at 0x"); } screen.Write(address.Address.ToString("X")); screen.Write(" [size="); if ((address.Size & 0xFFFFF) == 0) { screen.Write((address.Size >> 20).ToString()); screen.Write("M"); } else if ((address.Size & 0x3FF) == 0) { screen.Write((address.Size >> 10).ToString()); screen.Write("K"); } else { screen.Write(address.Size.ToString()); } screen.Write("]"); if (address.Prefetchable) { screen.Write("(prefetchable)"); } screen.WriteLine(); } if (pciDevice.IRQ != 0) { screen.Write(" "); screen.Write("IRQ at "); screen.Write(pciDevice.IRQ.ToString()); screen.WriteLine(); } } } //while (keyboard.GetKeyPressed() == null) ; Mosa.HelloWorld.Boot.Main(); //EmulatorDemo.StartDemo(); return; }
public async Task<IActionResult> getStore(String storeCode, String deviceId) { if (deviceId != null) { bool deviceaidi = _context.DeviceTable.Any(x => x.DeviceId == deviceId); if (!deviceaidi) { DeviceTable dtnew = new DeviceTable(); var check = _context.DeviceTable.LastOrDefault(); if (check == null) { dtnew.InitialId = "AAA"; } else { string ddv = check.InitialId; ddv = getGet(ddv); dtnew.InitialId = ddv; } dtnew.FirstLogin = DateTime.Now.ToString(); dtnew.TypeDevice = "POS"; dtnew.DeviceId = deviceId; _context.DeviceTable.Add(dtnew); _context.SaveChanges(); } else { DeviceTable tab = _context.DeviceTable.Where(x => x.DeviceId == deviceId).First(); tab.LastLogin = DateTime.Now.ToString(); _context.Update(tab); _context.SaveChanges(); } } StoreData storeData = new StoreData(); if (_context.Store.Any(c => c.Code == storeCode)) { // if (employee == null) // { // return NotFound(); // } try { Store store = _context.Store.Where(c => c.Code == storeCode).First(); try { storeData.deviceCode = _context.DeviceTable.Where(x => x.DeviceId == deviceId).First().InitialId; } catch { storeData.deviceCode = ""; } try { storeData.store = masterStore(store.Id); } catch { } try { storeData.warehouse = masterWarehose(_context.Store.Where(c => c.Id == store.Id).First().Code); } catch { } try { storeData.banks = masterBanks(store.Id); } catch { } try { storeData.employees = masterEmployee(store.Id); } catch (Exception) { } try { storeData.currency = masterCurrency("IDR"); } catch (Exception) { } try { storeData.budgetStore = this.budgetStore(storeCode); } catch { } } catch (Exception ex) { return Ok(ex.ToString()); } } return Ok(storeData); }
public async Task<IActionResult> CheckLogin([FromBody] Authentification authentification) { var employeecode = await _context.Employee.Where(c => c.EmployeeCode == authentification.userId).Select(c => c.Id).FirstOrDefaultAsync(); // var login = await _context.UserLogin.FirstOrDefaultAsync(x => x.UserId == Int32.Parse(username)); var login = await _context.UserLogin.FirstOrDefaultAsync(x => x.UserId == employeecode); if (login == null || login.Status == false) { return StatusCode(404, new { status = "404", error = true, message = "Username Not found" }); } if (!VerifyPasswordHash(authentification.password, login.PasswordHash, login.PasswordSalt)) { return StatusCode(404, new { status = "404", error = true, message = "Incorrect password" }); } //var userexist = _repo.Login(authentification.userId, authentification.password); //if(userexist == null) //{ // return StatusCode(404, new // { // status = "404", // error = true, // message = "Not found" // }); //} bool deviceaidi = _context.DeviceTable.Any(x => x.DeviceId == authentification.deviceId); if (!deviceaidi) { DeviceTable dtnew = new DeviceTable(); var check = _context.DeviceTable.LastOrDefault(); if (check == null) { dtnew.InitialId = "AAA"; } else { string ddv = check.InitialId; ddv = getGet(ddv); dtnew.InitialId = ddv; } dtnew.FirstLogin = DateTime.Now.ToString(); dtnew.TypeDevice = "MPOS"; dtnew.DeviceId = authentification.deviceId; _context.DeviceTable.Add(dtnew); _context.SaveChanges(); } else { DeviceTable tab = _context.DeviceTable.Where(x => x.DeviceId == authentification.deviceId).First(); tab.LastLogin = DateTime.Now.ToString(); _context.Update(tab); _context.SaveChanges(); } String employeeId = authentification.storeId; StoreData storeData = new StoreData(); // if (employee == null) // { // return NotFound(); // } try { Employee employee = _context.Employee.Where(c => c.EmployeeCode == authentification.userId).First(); storeData.deviceCode = _context.DeviceTable.Where(x => x.DeviceId == authentification.deviceId).First().InitialId; try { storeData.store = masterStore(employee.StoreId); } catch { } try { storeData.warehouse = masterWarehose(_context.Store.Where(c => c.Id == employee.StoreId).First().Code); } catch { } try { storeData.banks = masterBanks(employee.StoreId); } catch { } try { storeData.employees = masterEmployeepost(employee.StoreId); } catch (Exception) { } try { storeData.currency = masterCurrency("IDR"); } catch (Exception) { } try { storeData.budgetStore = this.budgetStore(_context.Store.Where(c => c.Id == employee.StoreId).First().Code); } catch { } try { UserLogin userheckk = _context.UserLogin.Where(x => x.UserId == employeecode).First(); userheckk.LastLogin = DateTime.Now; _context.Update(userheckk); _context.SaveChanges(); } catch { } } catch (Exception ex) { return Ok(ex.ToString()); } return Ok(storeData); //return StatusCode(200, new //{ // status = "200", // error = false, // message = "Login Success", // body = storeData //}); }