Сообщение зацените код. прилетел инцедент от 12.02.2024 7:54
Изменено 12.02.2024 7:55 undo75
зацените код. прилетел инцедент
по таймауту у них падает.
опуская подробности чисто функция. комент убил наповал:
опуская подробности чисто функция. комент убил наповал:
protected override async Task<AgricultureJournalUnit[]> HandleAsync(
GetSubOperations query,
CancellationToken token = default)
{
using (var dbConnectionString = ConnectionFactory.CreateDbConnection(MainDb.Replica1))
using (var context = ConnectionFactory.CreateWebDbContext(dbConnectionString))
{
var entities = context.SubOperations
.AsNoTracking()
.Include(x => x.Operation)
.Include(x => x.User)
.Include(x => x.Account)
.Include($"{nameof(Db.Model.WebDb.Public.SubOperation.Seeds)}.{nameof(Db.Model.WebDb.Public.Seed)}.{nameof(Db.Model.WebDb.Public.Variety)}")
.Include($"{nameof(Db.Model.WebDb.Public.SubOperation.Seeds)}.{nameof(Db.Model.WebDb.Public.SubOperationSoilProtector.Stock)}")
.Include($"{nameof(Db.Model.WebDb.Public.SubOperation.SoilProtectors)}.{nameof(Db.Model.WebDb.Public.SubOperationSoilProtector.Stock)}")
.Include($"{nameof(Db.Model.WebDb.Public.SubOperation.SoilProtectors)}.{nameof(Db.Model.WebDb.Public.SubOperationSoilProtector.SoilProtector)}")
.Include($"{nameof(Db.Model.WebDb.Public.SubOperation.Fertilizers)}.{nameof(Db.Model.WebDb.Public.SubOperationFertilizer.Stock)}")
.Include($"{nameof(Db.Model.WebDb.Public.SubOperation.Fertilizers)}.{nameof(Db.Model.WebDb.Public.SubOperationFertilizer.Fertilizer)}")
.Include($"{nameof(Db.Model.WebDb.Public.Machine)}.{nameof(Db.Model.WebDb.Public.Model)}.{nameof(Db.Model.WebDb.Manufacturer)}")
.Include($"{nameof(Db.Model.WebDb.Public.AgroInstrument)}.{nameof(Db.Model.WebDb.Public.Model)}.{nameof(Db.Model.WebDb.Manufacturer)}");
entities = entities.Where(x => x.Operation.CropField.Field.Layer.ClientId == query.CurrentClientId);
if (query.Ids.Any())
{
entities = entities.Where(x => query.Ids.Contains(x.Id));
}
if (query.Years.Any())
{
entities = entities.Where(x => query.Years.Contains(x.Operation.CropField.Year));
}
if (query.OperationModifiedIdFrom.HasValue)
{
entities = entities.Where(x => x.Operation.ModifiedId >= query.OperationModifiedIdFrom && x.Operation.ModifiedId <= query.OperationModifiedIdTo);
}
else if (query.OperationIds.Any())
{
entities = entities.Where(x => query.OperationIds.Contains(x.OperationId));
}
if (!query.IncludeDeleted)
{
entities = entities.Where(x => !x.IsDeleted && !x.Operation.IsDeleted);
}
if (query.TreatmentId.HasValue)
{
entities = entities.Where(x => x.Operation.TreatmentTypeId == query.TreatmentId.Value);
}
if (query.AgroUnitType.HasValue)
{
entities = entities.Where(x => x.PlanType == (int)query.AgroUnitType.Value);
}
if (query.PlanType.HasValue)
{
entities = entities.Where(x => x.Operation.PlantType == (int)query.PlanType.Value);
}
if (query.DateFrom.HasValue)
{
entities = entities.Where(x => x.DateStart >= query.DateFrom.Value);
}
if (query.DateTo.HasValue)
{
entities = entities.Where(x => x.DateEnd <= query.DateTo.Value);
}
// почему тут огромный селект? потому что Seed.SoilProtectionsJson не селектится, но будем считать, что это для перформанса выборки семечек:)
return (await entities.Select(x => new
{
x.Id,
x.OperationId,
x.DateStart,
x.DateEnd,
x.Square,
x.PlanType,
x.MachineId,
x.MachineModelId,
x.AgroInstrumentId,
x.AmountInstrument,
x.UserId,
x.Fuel,
x.FuelTotal,
x.FuelNormal,
x.Comment,
x.IsNightShift,
x.DistanceTraveled,
x.Created,
x.Quota,
x.HandSquare,
x.AppgoverUserId,
x.ResponsibleId,
x.CreatorId,
x.Route,
x.SquareWorkOnField,
x.EngineWorkTime,
x.Series,
x.QualityControl,
x.SpeedometerReadingsStart,
x.SpeedometerReadingsEnd,
x.RidersWithLoad,
x.RidersWithoutLoad,
x.TransportedTons,
x.TotalMileage,
x.IsExportedTo1C,
x.IsChronometrage,
x.IsAssist,
x.IsApproved,
x.AssistPercent,
x.LastRecalculate,
x.AccountId,
x.WaybillNumber,
x.WaybillNumberAddedManually,
x.DataFillingMethod,
x.IsDeleted,
x.Fertilizers,
x.SoilProtectors,
x.Machine,
x.AgroInstrument,
x.Operation.CropField.Field.LayerId,
User = x.UserId != null
? new
{
x.User.Id,
x.User.Name,
x.User.Surname,
x.User.MiddleName,
x.User.Birthday,
x.User.DrivingLicenseNumber,
x.User.PersonnelNumber,
}
: null,
x.Account,
Seeds = x.Seeds.Select(s => new
{
s.Id,
s.SeedId,
s.Amount,
s.AmountTotalHand,
Stock = s.Stock,
Seed = new
{
s.SeedId,
s.Seed.Reproduction,
s.Seed.VarietyId,
Variety = new
{
s.Seed.Variety.Id,
s.Seed.Variety.Name,
s.Seed.Variety.CropId,
s.Seed.Reproduction,
}
}
})
}).ToArrayAsync(token))
.Where(x => (!query.LayerIds.Any() || query.LayerIds.Contains(x.LayerId) || query.LayerIds.Contains(query.SystemLayerId))
&& (!query.AvailableLayerIds.Any() || query.AvailableLayerIds.Contains(x.LayerId)))
.Select(x =>
{
var result = new AgricultureJournalUnit
{
Id = x.Id,
IdJournal = x.OperationId,
DateStart = x.DateStart,
DateEnd = x.DateEnd,
Square = _rounderSquare.Round(x.Square),
PlanType = (AgroUnitType)x.PlanType,
IdMachine = x.MachineId,
IdModelTS = x.MachineModelId,
IdInstrument = x.AgroInstrumentId,
AmountInstrument = x.AmountInstrument,
IdUser = x.UserId,
Fuel = x.Fuel,
FuelTotal = x.FuelTotal,
NormaFuel = x.FuelNormal,
Comment = x.Comment,
IsNigthShift = x.IsNightShift,
DistanceTraveled = x.DistanceTraveled,
Created = x.Created,
Quota = x.Quota,
SquareHand = _rounderSquare.Round(x.HandSquare ?? 0),
SupervisorId = x.AppgoverUserId,
ResponsibleId = x.ResponsibleId,
CreatorId = x.CreatorId,
RouteId = x.Route,
SquareWorkOnField = _rounderSquare.Round(x.SquareWorkOnField ?? 0),
EngineWorkHour = x.EngineWorkTime,
Series = x.Series,
QualityControl = x.QualityControl,
SpeedometerReadingsStart = x.SpeedometerReadingsStart,
SpeedometerReadingsEnd = x.SpeedometerReadingsEnd,
RidersWithLoad = x.RidersWithLoad,
RidersWithoutLoad = x.RidersWithoutLoad,
TransportedTons = x.TransportedTons,
TotalMileage = x.TotalMileage,
WasExported1c = x.IsExportedTo1C,
IsChronometrage = x.IsChronometrage,
BrigadeWaySupportingWork = x.IsAssist,
Approved = x.IsApproved,
PercentForBrigadeWay = x.AssistPercent,
LastDateRecalculateArea = x.LastRecalculate,
ExpenseAccountId = x.AccountId,
WaybillNumber = x.WaybillNumber,
WaybillNumberAddedManually = x.WaybillNumberAddedManually,
DataFillingMethod = (DataFillingMethod)x.DataFillingMethod,
IsDeleted = x.IsDeleted,
ExpenseAccountValue = x.Account?.Value,
Seeds = x.Seeds.Select(s => new AgroUnitSeed
{
Id = s.Id,
IdSeed = s.SeedId,
Amount = s.Amount,
AmountTotalHand = s.AmountTotalHand,
SaveTotalHand = s.AmountTotalHand != null,
StockName = s.Stock?.Name,
StockId = s.Stock?.Id,
IdUnit = x.Id,
Seed = new Seed
{
Id = s.SeedId,
Reproduction = s.Seed.Reproduction,
IdVariety = s.Seed.VarietyId,
Variety = new Variety
{
Id = s.Seed.Variety.Id,
Name = s.Seed.Variety.Name,
IdCrop = s.Seed.Variety.CropId,
Reproduction = s.Seed.Reproduction,
}
}
}).ToList(),
Fertilizers = x.Fertilizers.Select(s => new AgroUnitFertilizer
{
Id = s.Id,
IdFertilizer = s.FertilizerId,
Amount = s.Amount,
AmountTotalHand = s.AmountTotalHand,
SaveTotalHand = s.AmountTotalHand != null,
StockName = s.Stock?.Name,
StockId = s.StockId,
IdUnit = x.Id,
Fertilizer = new Fertilizer
{
Id = s.FertilizerId,
Name = s.Fertilizer.Name,
Type = s.Fertilizer.Type,
UnitType = (UnitSoilType)s.Fertilizer.UnitType,
}
}).ToList(),
SoilProtections = x.SoilProtectors.Select(s => new AgroUnitSoilProtection
{
Id = s.Id,
IdSoilProtection = s.SoilProtectorId,
Amount = s.Amount,
AmountTotalHand = s.AmountTotalHand,
SaveTotalHand = s.AmountTotalHand != null,
StockName = s.Stock?.Name,
StockId = s.StockId,
IdUnit = x.Id,
SoilProtection = new Model.SoilProtection
{
Id = s.SoilProtectorId,
Name = s.SoilProtector.Name,
Type = s.SoilProtector.Type,
UnitType = (UnitSoilType)s.SoilProtector.UnitType,
}
}).ToList(),
};
if (result.IdMachine.HasValue && x.Machine != null)
{
result.Machine = new Machine
{
Id = x.Machine.Id,
Type = (MachineType?)x.Machine.Model.MachineSubType?.Type ?? MachineType.Noname,
IdManufacturer = x.Machine.Model.Manufacturer.Id,
IdClient = x.Machine.ClientId,
Nomer = x.Machine.Number,
Manufacturer = new Model.Manufacturer
{
Id = x.Machine.Model.Manufacturer.Id,
ExternalId = x.Machine.Manufacturer.ExternalId,
IdClient = x.Machine.Manufacturer.ClientId,
Name = x.Machine.Manufacturer.Name,
},
IdModel = x.MachineModelId,
Model = new ModelTS
{
Id = x.Machine.Model.Id,
ExternalId = x.Machine.Model.ExternalId,
Name = x.Machine.Model.Name,
Type = (ModelType)(x.Machine.Model.TypeTechnics ?? 0),
MachineSubTypeId = x.Machine.Model.MachineSubTypeId,
Photo = x.Machine.Model.PhotoId,
FuelTypeId = x.Machine.Model.FuelTypeId,
},
TerminalType = (TerminalType)x.Machine.TerminalTypeId,
TerminalNumber = x.Machine.TerminalNumber,
MonitoringId = x.Machine.MonitoringId,
MonitoringHistoryStatus = (MonitoringHistoryStatuses)x.Machine.MonitoringHistoryStatus,
};
}
if (result.IdUser.HasValue && x.User != null)
{
result.Executor = new User
{
Id = x.User.Id,
Name = x.User.Name,
SurName = x.User.Surname,
MiddleName = x.User.MiddleName,
Birthday = x.User.Birthday,
DrivingLicenseNumber = x.User.DrivingLicenseNumber,
PersonnelNumber = x.User.PersonnelNumber,
};
}
if (result.IdInstrument.HasValue && x.AgroInstrument != null)
{
result.Instrument = new AgroInstrument
{
Id = x.AgroInstrument.Id,
Type = (MachineType?)x.AgroInstrument.Model.MachineSubType?.Type ?? MachineType.Noname,
IdManufacturer = x.AgroInstrument.Model.Manufacturer.Id,
IdClient = x.AgroInstrument.ClientId,
AggregateWidth = (double)x.AgroInstrument.Width,
LeverX = (double)x.AgroInstrument.LeverPointX,
LeverY = (double)x.AgroInstrument.LeverPointY,
LinkX = (double)x.AgroInstrument.LinkPointX,
LinkY = (double)x.AgroInstrument.LinkPointY,
Manufacturer = new Model.Manufacturer
{
Id = x.AgroInstrument.Model.Manufacturer.Id,
ExternalId = x.AgroInstrument.Manufacturer.ExternalId,
IdClient = x.AgroInstrument.Manufacturer.ClientId,
Name = x.AgroInstrument.Manufacturer.Name,
},
IdModel = x.AgroInstrument.ModelId,
Model = new ModelTS
{
Id = x.AgroInstrument.Model.Id,
ExternalId = x.AgroInstrument.Model.ExternalId,
Name = x.AgroInstrument.Model.Name,
Type = (ModelType)(x.AgroInstrument.Model.TypeTechnics ?? 0),
MachineSubTypeId = x.AgroInstrument.Model.MachineSubTypeId,
Photo = x.AgroInstrument.Model.PhotoId,
},
TerminalType = (TerminalType)x.AgroInstrument.TypeTerminal,
TerminalNumber = x.AgroInstrument.TerminalNumber,
MonitoringId = x.AgroInstrument.MonitoringId,
};
}
return result;
})
.ToArray();
}
}
зацените код. прилетел инцедент
по таймауту у них падает.
опуская подробности чисто функция. комент убил наповал:
а действитель — херли тут по таймауту падать-то?
кто это пропустил я хз...
опуская подробности чисто функция. комент убил наповал:
а действитель — херли тут по таймауту падать-то?
кто это пропустил я хз...
protected override async Task<AgricultureJournalUnit[]> HandleAsync(
GetSubOperations query,
CancellationToken token = default)
{
using (var dbConnectionString = ConnectionFactory.CreateDbConnection(MainDb.Replica1))
using (var context = ConnectionFactory.CreateWebDbContext(dbConnectionString))
{
var entities = context.SubOperations
.AsNoTracking()
.Include(x => x.Operation)
.Include(x => x.User)
.Include(x => x.Account)
.Include($"{nameof(Db.Model.WebDb.Public.SubOperation.Seeds)}.{nameof(Db.Model.WebDb.Public.Seed)}.{nameof(Db.Model.WebDb.Public.Variety)}")
.Include($"{nameof(Db.Model.WebDb.Public.SubOperation.Seeds)}.{nameof(Db.Model.WebDb.Public.SubOperationSoilProtector.Stock)}")
.Include($"{nameof(Db.Model.WebDb.Public.SubOperation.SoilProtectors)}.{nameof(Db.Model.WebDb.Public.SubOperationSoilProtector.Stock)}")
.Include($"{nameof(Db.Model.WebDb.Public.SubOperation.SoilProtectors)}.{nameof(Db.Model.WebDb.Public.SubOperationSoilProtector.SoilProtector)}")
.Include($"{nameof(Db.Model.WebDb.Public.SubOperation.Fertilizers)}.{nameof(Db.Model.WebDb.Public.SubOperationFertilizer.Stock)}")
.Include($"{nameof(Db.Model.WebDb.Public.SubOperation.Fertilizers)}.{nameof(Db.Model.WebDb.Public.SubOperationFertilizer.Fertilizer)}")
.Include($"{nameof(Db.Model.WebDb.Public.Machine)}.{nameof(Db.Model.WebDb.Public.Model)}.{nameof(Db.Model.WebDb.Manufacturer)}")
.Include($"{nameof(Db.Model.WebDb.Public.AgroInstrument)}.{nameof(Db.Model.WebDb.Public.Model)}.{nameof(Db.Model.WebDb.Manufacturer)}");
entities = entities.Where(x => x.Operation.CropField.Field.Layer.ClientId == query.CurrentClientId);
if (query.Ids.Any())
{
entities = entities.Where(x => query.Ids.Contains(x.Id));
}
if (query.Years.Any())
{
entities = entities.Where(x => query.Years.Contains(x.Operation.CropField.Year));
}
if (query.OperationModifiedIdFrom.HasValue)
{
entities = entities.Where(x => x.Operation.ModifiedId >= query.OperationModifiedIdFrom && x.Operation.ModifiedId <= query.OperationModifiedIdTo);
}
else if (query.OperationIds.Any())
{
entities = entities.Where(x => query.OperationIds.Contains(x.OperationId));
}
if (!query.IncludeDeleted)
{
entities = entities.Where(x => !x.IsDeleted && !x.Operation.IsDeleted);
}
if (query.TreatmentId.HasValue)
{
entities = entities.Where(x => x.Operation.TreatmentTypeId == query.TreatmentId.Value);
}
if (query.AgroUnitType.HasValue)
{
entities = entities.Where(x => x.PlanType == (int)query.AgroUnitType.Value);
}
if (query.PlanType.HasValue)
{
entities = entities.Where(x => x.Operation.PlantType == (int)query.PlanType.Value);
}
if (query.DateFrom.HasValue)
{
entities = entities.Where(x => x.DateStart >= query.DateFrom.Value);
}
if (query.DateTo.HasValue)
{
entities = entities.Where(x => x.DateEnd <= query.DateTo.Value);
}
// почему тут огромный селект? потому что Seed.SoilProtectionsJson не селектится, но будем считать, что это для перформанса выборки семечек:)
return (await entities.Select(x => new
{
x.Id,
x.OperationId,
x.DateStart,
x.DateEnd,
x.Square,
x.PlanType,
x.MachineId,
x.MachineModelId,
x.AgroInstrumentId,
x.AmountInstrument,
x.UserId,
x.Fuel,
x.FuelTotal,
x.FuelNormal,
x.Comment,
x.IsNightShift,
x.DistanceTraveled,
x.Created,
x.Quota,
x.HandSquare,
x.AppgoverUserId,
x.ResponsibleId,
x.CreatorId,
x.Route,
x.SquareWorkOnField,
x.EngineWorkTime,
x.Series,
x.QualityControl,
x.SpeedometerReadingsStart,
x.SpeedometerReadingsEnd,
x.RidersWithLoad,
x.RidersWithoutLoad,
x.TransportedTons,
x.TotalMileage,
x.IsExportedTo1C,
x.IsChronometrage,
x.IsAssist,
x.IsApproved,
x.AssistPercent,
x.LastRecalculate,
x.AccountId,
x.WaybillNumber,
x.WaybillNumberAddedManually,
x.DataFillingMethod,
x.IsDeleted,
x.Fertilizers,
x.SoilProtectors,
x.Machine,
x.AgroInstrument,
x.Operation.CropField.Field.LayerId,
User = x.UserId != null
? new
{
x.User.Id,
x.User.Name,
x.User.Surname,
x.User.MiddleName,
x.User.Birthday,
x.User.DrivingLicenseNumber,
x.User.PersonnelNumber,
}
: null,
x.Account,
Seeds = x.Seeds.Select(s => new
{
s.Id,
s.SeedId,
s.Amount,
s.AmountTotalHand,
Stock = s.Stock,
Seed = new
{
s.SeedId,
s.Seed.Reproduction,
s.Seed.VarietyId,
Variety = new
{
s.Seed.Variety.Id,
s.Seed.Variety.Name,
s.Seed.Variety.CropId,
s.Seed.Reproduction,
}
}
})
}).ToArrayAsync(token))
.Where(x => (!query.LayerIds.Any() || query.LayerIds.Contains(x.LayerId) || query.LayerIds.Contains(query.SystemLayerId))
&& (!query.AvailableLayerIds.Any() || query.AvailableLayerIds.Contains(x.LayerId)))
.Select(x =>
{
var result = new AgricultureJournalUnit
{
Id = x.Id,
IdJournal = x.OperationId,
DateStart = x.DateStart,
DateEnd = x.DateEnd,
Square = _rounderSquare.Round(x.Square),
PlanType = (AgroUnitType)x.PlanType,
IdMachine = x.MachineId,
IdModelTS = x.MachineModelId,
IdInstrument = x.AgroInstrumentId,
AmountInstrument = x.AmountInstrument,
IdUser = x.UserId,
Fuel = x.Fuel,
FuelTotal = x.FuelTotal,
NormaFuel = x.FuelNormal,
Comment = x.Comment,
IsNigthShift = x.IsNightShift,
DistanceTraveled = x.DistanceTraveled,
Created = x.Created,
Quota = x.Quota,
SquareHand = _rounderSquare.Round(x.HandSquare ?? 0),
SupervisorId = x.AppgoverUserId,
ResponsibleId = x.ResponsibleId,
CreatorId = x.CreatorId,
RouteId = x.Route,
SquareWorkOnField = _rounderSquare.Round(x.SquareWorkOnField ?? 0),
EngineWorkHour = x.EngineWorkTime,
Series = x.Series,
QualityControl = x.QualityControl,
SpeedometerReadingsStart = x.SpeedometerReadingsStart,
SpeedometerReadingsEnd = x.SpeedometerReadingsEnd,
RidersWithLoad = x.RidersWithLoad,
RidersWithoutLoad = x.RidersWithoutLoad,
TransportedTons = x.TransportedTons,
TotalMileage = x.TotalMileage,
WasExported1c = x.IsExportedTo1C,
IsChronometrage = x.IsChronometrage,
BrigadeWaySupportingWork = x.IsAssist,
Approved = x.IsApproved,
PercentForBrigadeWay = x.AssistPercent,
LastDateRecalculateArea = x.LastRecalculate,
ExpenseAccountId = x.AccountId,
WaybillNumber = x.WaybillNumber,
WaybillNumberAddedManually = x.WaybillNumberAddedManually,
DataFillingMethod = (DataFillingMethod)x.DataFillingMethod,
IsDeleted = x.IsDeleted,
ExpenseAccountValue = x.Account?.Value,
Seeds = x.Seeds.Select(s => new AgroUnitSeed
{
Id = s.Id,
IdSeed = s.SeedId,
Amount = s.Amount,
AmountTotalHand = s.AmountTotalHand,
SaveTotalHand = s.AmountTotalHand != null,
StockName = s.Stock?.Name,
StockId = s.Stock?.Id,
IdUnit = x.Id,
Seed = new Seed
{
Id = s.SeedId,
Reproduction = s.Seed.Reproduction,
IdVariety = s.Seed.VarietyId,
Variety = new Variety
{
Id = s.Seed.Variety.Id,
Name = s.Seed.Variety.Name,
IdCrop = s.Seed.Variety.CropId,
Reproduction = s.Seed.Reproduction,
}
}
}).ToList(),
Fertilizers = x.Fertilizers.Select(s => new AgroUnitFertilizer
{
Id = s.Id,
IdFertilizer = s.FertilizerId,
Amount = s.Amount,
AmountTotalHand = s.AmountTotalHand,
SaveTotalHand = s.AmountTotalHand != null,
StockName = s.Stock?.Name,
StockId = s.StockId,
IdUnit = x.Id,
Fertilizer = new Fertilizer
{
Id = s.FertilizerId,
Name = s.Fertilizer.Name,
Type = s.Fertilizer.Type,
UnitType = (UnitSoilType)s.Fertilizer.UnitType,
}
}).ToList(),
SoilProtections = x.SoilProtectors.Select(s => new AgroUnitSoilProtection
{
Id = s.Id,
IdSoilProtection = s.SoilProtectorId,
Amount = s.Amount,
AmountTotalHand = s.AmountTotalHand,
SaveTotalHand = s.AmountTotalHand != null,
StockName = s.Stock?.Name,
StockId = s.StockId,
IdUnit = x.Id,
SoilProtection = new Model.SoilProtection
{
Id = s.SoilProtectorId,
Name = s.SoilProtector.Name,
Type = s.SoilProtector.Type,
UnitType = (UnitSoilType)s.SoilProtector.UnitType,
}
}).ToList(),
};
if (result.IdMachine.HasValue && x.Machine != null)
{
result.Machine = new Machine
{
Id = x.Machine.Id,
Type = (MachineType?)x.Machine.Model.MachineSubType?.Type ?? MachineType.Noname,
IdManufacturer = x.Machine.Model.Manufacturer.Id,
IdClient = x.Machine.ClientId,
Nomer = x.Machine.Number,
Manufacturer = new Model.Manufacturer
{
Id = x.Machine.Model.Manufacturer.Id,
ExternalId = x.Machine.Manufacturer.ExternalId,
IdClient = x.Machine.Manufacturer.ClientId,
Name = x.Machine.Manufacturer.Name,
},
IdModel = x.MachineModelId,
Model = new ModelTS
{
Id = x.Machine.Model.Id,
ExternalId = x.Machine.Model.ExternalId,
Name = x.Machine.Model.Name,
Type = (ModelType)(x.Machine.Model.TypeTechnics ?? 0),
MachineSubTypeId = x.Machine.Model.MachineSubTypeId,
Photo = x.Machine.Model.PhotoId,
FuelTypeId = x.Machine.Model.FuelTypeId,
},
TerminalType = (TerminalType)x.Machine.TerminalTypeId,
TerminalNumber = x.Machine.TerminalNumber,
MonitoringId = x.Machine.MonitoringId,
MonitoringHistoryStatus = (MonitoringHistoryStatuses)x.Machine.MonitoringHistoryStatus,
};
}
if (result.IdUser.HasValue && x.User != null)
{
result.Executor = new User
{
Id = x.User.Id,
Name = x.User.Name,
SurName = x.User.Surname,
MiddleName = x.User.MiddleName,
Birthday = x.User.Birthday,
DrivingLicenseNumber = x.User.DrivingLicenseNumber,
PersonnelNumber = x.User.PersonnelNumber,
};
}
if (result.IdInstrument.HasValue && x.AgroInstrument != null)
{
result.Instrument = new AgroInstrument
{
Id = x.AgroInstrument.Id,
Type = (MachineType?)x.AgroInstrument.Model.MachineSubType?.Type ?? MachineType.Noname,
IdManufacturer = x.AgroInstrument.Model.Manufacturer.Id,
IdClient = x.AgroInstrument.ClientId,
AggregateWidth = (double)x.AgroInstrument.Width,
LeverX = (double)x.AgroInstrument.LeverPointX,
LeverY = (double)x.AgroInstrument.LeverPointY,
LinkX = (double)x.AgroInstrument.LinkPointX,
LinkY = (double)x.AgroInstrument.LinkPointY,
Manufacturer = new Model.Manufacturer
{
Id = x.AgroInstrument.Model.Manufacturer.Id,
ExternalId = x.AgroInstrument.Manufacturer.ExternalId,
IdClient = x.AgroInstrument.Manufacturer.ClientId,
Name = x.AgroInstrument.Manufacturer.Name,
},
IdModel = x.AgroInstrument.ModelId,
Model = new ModelTS
{
Id = x.AgroInstrument.Model.Id,
ExternalId = x.AgroInstrument.Model.ExternalId,
Name = x.AgroInstrument.Model.Name,
Type = (ModelType)(x.AgroInstrument.Model.TypeTechnics ?? 0),
MachineSubTypeId = x.AgroInstrument.Model.MachineSubTypeId,
Photo = x.AgroInstrument.Model.PhotoId,
},
TerminalType = (TerminalType)x.AgroInstrument.TypeTerminal,
TerminalNumber = x.AgroInstrument.TerminalNumber,
MonitoringId = x.AgroInstrument.MonitoringId,
};
}
return result;
})
.ToArray();
}
}