private string UpdateComputerInfo(string eInfo, string mConnInfo, GetDevice decCompInfo) { decCompInfo.Code = AccountConstants.CODE_NOT_ACTIVE_BY_UPDATE; decCompInfo.Hk = mConnInfo; _repository.UpdateComputerInfo(eInfo, decCompInfo.SerializeAndEncrypt()); return(BuildResponse(SharedConstants.Client.STATUS_SCREEN_MESSAGE, AccountConstants.LstCodes[decCompInfo.Code])); }
private static string IsValidDeviceInfo(GetDevice device) { var now = DateTime.Now; if (device.Code != AccountConstants.CODE_VALID) { return(BuildResponse(SharedConstants.Client.STATUS_SCREEN_MESSAGE, AccountConstants.LstCodes[device.Code])); } if (now < device.St.AddDays(-2)) { device.Iv = false; device.Code = AccountConstants.CODE_NOT_ACTIVE_ST; return(BuildResponse(SharedConstants.Client.STATUS_SCREEN_MESSAGE, AccountConstants.LstCodes[AccountConstants.CODE_NOT_ACTIVE_ST])); } if (now > device.Et.AddDays(10)) { device.Iv = false; device.Code = AccountConstants.CODE_NOT_ACTIVE_ET; return(BuildResponse(SharedConstants.Client.STATUS_SCREEN_MESSAGE, AccountConstants.LstCodes[AccountConstants.CODE_NOT_ACTIVE_ET])); } if (device.Iv == false) { device.Iv = false; device.Code = AccountConstants.CODE_NOT_ACTIVE; return(BuildResponse(SharedConstants.Client.STATUS_SCREEN_MESSAGE, AccountConstants.LstCodes[AccountConstants.CODE_NOT_ACTIVE])); } return(BuildResponse(SharedConstants.Client.STATUS_SCREEN_LOGIN, AccountConstants.LstCodes[AccountConstants.CODE_VALID])); }
private async void DeviceWatcher_Added(DeviceWatcher sender, DeviceInformation deviceInfo) { //Logger.Log($"Device Added with Id: {deviceInfo.Id}, Name: {deviceInfo.Name}, Kind: {deviceInfo.Kind}"); //Could also check System.Devices.Aep.DeviceAddress:4a:d9:74:a3:29:4b if (deviceInfo.Id.Contains(_addressToPair)) { Logger.Log($"Got matching DeviceInfo for : {deviceInfo.Id}, Name: {deviceInfo.Name}, Kind: {deviceInfo.Kind}"); Stop(); //Keep for future pairing _lastDeviceInfo = deviceInfo; if (GetDevice != null) { var args = new GetDeviceEventArgs(); if (deviceInfo.Pairing.IsPaired) { args.IsPaired = true; } args.Properties = new Dictionary <string, object>(); foreach (var de in deviceInfo.Properties) { args.Properties.Add(de.Key, de.Value); } GetDevice.Invoke(this, args); } } }
private bool IsUpdatedComputerInfo(string mConnInfo, string computerInfo, out GetDevice decCompInfo) { var connInfo = mConnInfo; decCompInfo = new JavaScriptSerializer().Deserialize <GetDevice>(Cypher.Decrypt(computerInfo)); return(connInfo == decCompInfo.Hk); }
private void UpdateInfoServer(string mConnInfo, GetDevice decServInfo, InfoServer infoServer) { decServInfo.Hk = mConnInfo; infoServer.Code = Cypher.Encrypt(new JavaScriptSerializer().Serialize(decServInfo)); _repository.SaveChanges(); //if (infoServer.InfoCallCenterId.HasValue == false) // return; }
private bool IsUpdatedInfoServer(string mConnInfo, InfoServer infoServer, out GetDevice decCompInfo) { var connInfo = mConnInfo; decCompInfo = new JavaScriptSerializer().Deserialize <GetDevice>(Cypher.Decrypt(infoServer.Code)); if (connInfo == decCompInfo.Hk) { return(true); } return(false); }
private void CreateInfoServer(string eInfo, string mConnInfo) { var model = new GetDevice { Hk = mConnInfo, //HostId Hn = Cypher.Decrypt(eInfo), //HostName St = DateTime.MinValue, Et = DateTime.MinValue, Iv = false, //Is valid license Code = AccountConstants.CODE_NEW }; _repository.AddInfoServer(Cypher.Encrypt(eInfo), Cypher.Encrypt(new JavaScriptSerializer().Serialize(model))); }
private string CreateComputerInfo(string eInfo, string sConnInfo) { var model = new GetDevice { Hk = Cypher.Decrypt(sConnInfo), //HostId Hn = Cypher.Decrypt(Cypher.Decrypt(eInfo)), //HostName St = DateTime.MinValue, Et = DateTime.MinValue, Iv = false, //Is valid license Code = AccountConstants.CODE_NEW }; _repository.AddComputerInfo(eInfo, Cypher.Encrypt(new JavaScriptSerializer().Serialize(model))); return(BuildResponse(SharedConstants.Client.STATUS_SCREEN_MESSAGE, AccountConstants.LstCodes[model.Code])); }
public void TestGetDevice() { var message = new GetDevice(); var bytes = message.ToByteArray(); var expectedBytes = new List <byte>(); expectedBytes.AddRange(Constants.HEADER); expectedBytes.AddRange(Constants.PRODUCT_ID); expectedBytes.AddRange(Constants.SERIAL_NUMBER); expectedBytes.AddRange(new byte[] { 0x00, 0x00, 0x40, 0x01, 0x00, 0x00, 0x0f, 0xf7 }); Debug.WriteLine(bytes.ToDebugString()); Debug.WriteLine(expectedBytes.ToArray().ToDebugString()); Assert.IsTrue(bytes.SequenceEqual(expectedBytes)); }
public async Task handler_should_return_device_with_correct_data() { var command = new GetDevice { Id = "device1", }; var userName = "******"; var httpContext = new DefaultHttpContext(); var user = new System.Security.Claims.ClaimsPrincipal(); user.AddIdentity(new System.Security.Claims.ClaimsIdentity(new List <Claim> { new Claim(ClaimTypes.Name, userName) })); httpContext.User = user; _httpContextAccessor.HttpContext.Returns(httpContext); var account = new Account() { Id = Guid.NewGuid() }; _accountRepository.GetByUserName(userName).Returns(account); var device = new Device { Id = command.Id }; var accountDevice = new AccountDevice { AccountId = account.Id, DeviceId = device.Id }; _accountDeviceRepository.Get((account.Id, device.Id)).Returns(accountDevice); _deviceRepository.Get(command.Id).Returns(device); var deviceDto = await _handler.Handle(command, new System.Threading.CancellationToken()); deviceDto.Id.ShouldBe(device.Id); }