72 lines
2.2 KiB
C#
72 lines
2.2 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using System.ComponentModel;
|
|
using System.ComponentModel.DataAnnotations;
|
|
using System.Linq;
|
|
using System.Reflection;
|
|
using WalkingTec.Mvvm.Core;
|
|
using HHWMS.Web.Models;
|
|
|
|
namespace HHWMS.Web
|
|
{
|
|
public class LocationMonitor2DVM : BaseVM
|
|
{
|
|
public string Area { get; set; }
|
|
public string Row { get; set; }
|
|
|
|
public class LocationGridItem
|
|
{
|
|
public string Code { get; set; }
|
|
public short Row { get; set; }
|
|
public short Line { get; set; }
|
|
public short Layer { get; set; }
|
|
public LocationStatusEnum Status { get; set; }
|
|
public string ContainerCode { get; set; }
|
|
}
|
|
|
|
public IEnumerable<int> GetAreas()
|
|
{
|
|
return DC.Set<Location>()
|
|
.Select(x => x.ZoneId)
|
|
.Distinct()
|
|
.OrderBy(x => x)
|
|
.ToList();
|
|
}
|
|
|
|
public IEnumerable<short> GetRows(int area)
|
|
{
|
|
return DC.Set<Location>()
|
|
.Where(x => x.ZoneId == area)
|
|
.Select(x => x.Row)
|
|
.Distinct()
|
|
.OrderBy(x => x)
|
|
.ToList();
|
|
}
|
|
|
|
public IEnumerable<dynamic> GetLocationsByAreaAndRow(int area, short row)
|
|
{
|
|
var result = DC.Set<Location>()
|
|
.Where(x => x.ZoneId == area && x.Row == row)
|
|
.OrderBy(x => x.Line)
|
|
.Select(x => new
|
|
{
|
|
Code = x.Code,
|
|
Row = x.Row,
|
|
Line = x.Line,
|
|
Layer = x.Layer,
|
|
x.Status,
|
|
Status1 = x.Status.GetEnumDisplayName(),
|
|
ContainerCode = x.ContainerCode
|
|
}).ToList();
|
|
return result;
|
|
}
|
|
|
|
private string GetEnumDisplayName(Enum enumValue)
|
|
{
|
|
var fieldInfo = enumValue.GetType().GetField(enumValue.ToString());
|
|
var displayAttribute = fieldInfo.GetCustomAttributes(typeof(DisplayAttribute), false).FirstOrDefault() as DisplayAttribute;
|
|
|
|
return displayAttribute?.Name ?? enumValue.ToString();
|
|
}
|
|
}
|
|
} |