Updated code for device creation (create appconfig) + misc
This commit is contained in:
parent
b81972f723
commit
4d755549af
@ -194,7 +194,11 @@ namespace ManagerService.Controllers
|
|||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
List<AppConfigurationLink> appConfigurationLinks = _myInfoMateDbContext.AppConfigurationLinks.Include(acl => acl.Configuration).Where(acl => acl.ApplicationInstanceId == applicationInstanceId).ToList();
|
List<AppConfigurationLink> appConfigurationLinks = _myInfoMateDbContext.AppConfigurationLinks
|
||||||
|
.Include(acl => acl.Configuration)
|
||||||
|
.Include(acl => acl.Device)
|
||||||
|
.Where(acl => acl.ApplicationInstanceId == applicationInstanceId)
|
||||||
|
.ToList();
|
||||||
return new OkObjectResult(appConfigurationLinks.Select(acl => acl.ToDTO()).OrderBy(acl => acl.order).ToList());
|
return new OkObjectResult(appConfigurationLinks.Select(acl => acl.ToDTO()).OrderBy(acl => acl.order).ToList());
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
|
|||||||
@ -133,7 +133,7 @@ namespace ManagerService.Controllers
|
|||||||
|
|
||||||
device.InstanceId = newDevice.instanceId;
|
device.InstanceId = newDevice.instanceId;
|
||||||
device.Name = newDevice.name;
|
device.Name = newDevice.name;
|
||||||
device.ConfigurationId = newDevice.configurationId;
|
device.ConfigurationId = newDevice.configurationId; // OLD WAY -> AppConfigurationLink
|
||||||
device.IpAddressETH = newDevice.ipAddressETH;
|
device.IpAddressETH = newDevice.ipAddressETH;
|
||||||
device.IpAddressWLAN = newDevice.ipAddressWLAN;
|
device.IpAddressWLAN = newDevice.ipAddressWLAN;
|
||||||
device.Connected = newDevice.connected;
|
device.Connected = newDevice.connected;
|
||||||
@ -142,6 +142,8 @@ namespace ManagerService.Controllers
|
|||||||
device.BatteryLevel = newDevice.batteryLevel;
|
device.BatteryLevel = newDevice.batteryLevel;
|
||||||
device.LastBatteryLevel = newDevice.lastBatteryLevel;
|
device.LastBatteryLevel = newDevice.lastBatteryLevel;
|
||||||
|
|
||||||
|
ApplicationInstance applicationInstance = _myInfoMateDbContext.ApplicationInstances.FirstOrDefault(ai => ai.InstanceId == newDevice.instanceId && ai.AppType == AppType.Tablet);
|
||||||
|
|
||||||
//OldDevice deviceCreated = _deviceService.IsExistIdentifier(newDevice.identifier) ? _deviceService.Update(device.Id, device) : _deviceService.Create(device);
|
//OldDevice deviceCreated = _deviceService.IsExistIdentifier(newDevice.identifier) ? _deviceService.Update(device.Id, device) : _deviceService.Create(device);
|
||||||
if (deviceDB != null)
|
if (deviceDB != null)
|
||||||
{
|
{
|
||||||
@ -151,6 +153,19 @@ namespace ManagerService.Controllers
|
|||||||
}
|
}
|
||||||
_myInfoMateDbContext.SaveChanges();
|
_myInfoMateDbContext.SaveChanges();
|
||||||
|
|
||||||
|
if (deviceDB == null)
|
||||||
|
{
|
||||||
|
// Create AppConfigurationLink
|
||||||
|
AppConfigurationLink link = new AppConfigurationLink();
|
||||||
|
link.ConfigurationId = newDevice.configurationId;
|
||||||
|
link.ApplicationInstanceId = applicationInstance.Id;
|
||||||
|
link.DeviceId = device.Id;
|
||||||
|
link.Id = idService.GenerateHexId();
|
||||||
|
_myInfoMateDbContext.AppConfigurationLinks.Add(link);
|
||||||
|
}
|
||||||
|
|
||||||
|
_myInfoMateDbContext.SaveChanges();
|
||||||
|
|
||||||
return new OkObjectResult(device.ToDTO());
|
return new OkObjectResult(device.ToDTO());
|
||||||
}
|
}
|
||||||
catch (ArgumentNullException ex)
|
catch (ArgumentNullException ex)
|
||||||
|
|||||||
@ -30,6 +30,8 @@ namespace ManagerService.DTOs
|
|||||||
|
|
||||||
public string deviceId { get; set; } // Specific Kiosk
|
public string deviceId { get; set; } // Specific Kiosk
|
||||||
|
|
||||||
|
public DeviceDTO device { get; set; } // Specific Kiosk
|
||||||
|
|
||||||
public LayoutMainPageType layoutMainPage { get; set; } // Specific Kiosk
|
public LayoutMainPageType layoutMainPage { get; set; } // Specific Kiosk
|
||||||
|
|
||||||
public string LoaderImageUrl { get; set; } // Specific Kiosk
|
public string LoaderImageUrl { get; set; } // Specific Kiosk
|
||||||
|
|||||||
@ -77,6 +77,7 @@ namespace ManagerService.Data
|
|||||||
screenPercentageSectionsMainPage = ScreenPercentageSectionsMainPage,
|
screenPercentageSectionsMainPage = ScreenPercentageSectionsMainPage,
|
||||||
isSectionImageBackground = IsSectionImageBackground,
|
isSectionImageBackground = IsSectionImageBackground,
|
||||||
deviceId = DeviceId,
|
deviceId = DeviceId,
|
||||||
|
device = Device?.ToDTO()
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -92,6 +93,7 @@ namespace ManagerService.Data
|
|||||||
RoundedValue = appConfigurationLinkDTO.roundedValue;
|
RoundedValue = appConfigurationLinkDTO.roundedValue;
|
||||||
ScreenPercentageSectionsMainPage = appConfigurationLinkDTO.screenPercentageSectionsMainPage;
|
ScreenPercentageSectionsMainPage = appConfigurationLinkDTO.screenPercentageSectionsMainPage;
|
||||||
IsSectionImageBackground = appConfigurationLinkDTO.isSectionImageBackground;
|
IsSectionImageBackground = appConfigurationLinkDTO.isSectionImageBackground;
|
||||||
|
DeviceId = appConfigurationLinkDTO.deviceId;
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -188,7 +188,7 @@ namespace ManagerService
|
|||||||
app.UseCors(
|
app.UseCors(
|
||||||
#if DEBUG
|
#if DEBUG
|
||||||
options => options
|
options => options
|
||||||
.SetIsOriginAllowed(origin => string.IsNullOrEmpty(origin) || origin == "http://localhost:62150")
|
.SetIsOriginAllowed(origin => string.IsNullOrEmpty(origin) || origin == "http://localhost:55628")
|
||||||
.AllowAnyMethod()
|
.AllowAnyMethod()
|
||||||
.AllowAnyHeader()
|
.AllowAnyHeader()
|
||||||
.AllowCredentials()
|
.AllowCredentials()
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user