public void AddAlloySample(NicelideTitanumSampleModel model) { using (ObjectContext context = new ObjectContext(_connectionString)) { var alloys = context.CreateObjectSet <NickelideTitaniumAlloy>(); if (!alloys.Select(x => x.Name).Contains(model.NickelideTitaniumAlloyName)) { var alloy = new NickelideTitaniumAlloy { Name = model.NickelideTitaniumAlloyName, Description = null }; alloys.AddObject(alloy); context.SaveChanges(); } var alloyArray = context.CreateObjectSet <NickelideTitaniumAlloy>().ToList(); var sample = new NicelideTitanumSample { HammerSpeed = model.HammerSpeed.Value, SampleNumber = model.SampleNumber.Value, HammerThickness = model.HammerThickness.Value, SampleThickness = model.SampleThickness.Value, SpallSpeed = model.SpallSpeed.Value, SpallStrength = model.SpallStrength.Value, NickelideTitaniumAlloyId = alloyArray.First(x => x.Name == model.NickelideTitaniumAlloyName) .NickelideTitaniumAlloyId }; var samples = context.CreateObjectSet <NicelideTitanumSample>(); samples.AddObject(sample); context.SaveChanges(); } }
private IList <AlloySampleQualityRateModel> SetAlloySamplePropertyList(NicelideTitanumQualityBaseValue baseValues, NicelideTitanumSample sample, NicelideTitanumCoefficientWeighting coeficientValues) { var propertyList = new List <AlloySampleQualityRateModel>(); var model = new AlloySampleQualityRateModel { SampleProperty = "Товщина зразку H, мм", BaseValue = baseValues.SampleThickness, SampleValue = sample.SampleThickness, RelativeValue = Math.Round((decimal)sample.SampleThickness / baseValues.SampleThickness, 2), CoefficientWeighting = coeficientValues.SampleThickness, Angle = Round(360 * coeficientValues.SampleThickness, 0) }; propertyList.Add(model); model = new AlloySampleQualityRateModel { SampleProperty = "Товщина ударника h, мм", BaseValue = baseValues.HammerThickness, SampleValue = sample.HammerThickness, RelativeValue = Math.Round((decimal)sample.HammerThickness / baseValues.HammerThickness, 2), CoefficientWeighting = coeficientValues.HammerThickness, Angle = Round(360 * coeficientValues.HammerThickness, 0) }; propertyList.Add(model); model = new AlloySampleQualityRateModel { SampleProperty = "Швидкість ударника V, м/c", BaseValue = baseValues.HammerSpeed, SampleValue = sample.HammerSpeed, RelativeValue = Math.Round((decimal)sample.HammerSpeed / baseValues.HammerSpeed, 2), CoefficientWeighting = coeficientValues.HammerSpeed, Angle = Round(360 * coeficientValues.HammerSpeed, 0) }; propertyList.Add(model); model = new AlloySampleQualityRateModel { SampleProperty = "Швидкість відколу W, м/с", BaseValue = baseValues.SpallSpeed, SampleValue = sample.SpallSpeed, RelativeValue = Math.Round((decimal)sample.SpallSpeed / baseValues.SpallSpeed, 2), CoefficientWeighting = coeficientValues.SpallSpeed, Angle = Round(360 * coeficientValues.SpallSpeed, 0) }; propertyList.Add(model); model = new AlloySampleQualityRateModel { SampleProperty = "Міцність відколу σ, ГПа", BaseValue = baseValues.SpallStrength, SampleValue = sample.SpallStrength, RelativeValue = Math.Round((decimal)sample.SpallStrength / baseValues.SpallStrength, 2), CoefficientWeighting = coeficientValues.SpallStrength, Angle = Round(360 * coeficientValues.SpallStrength, 0) }; propertyList.Add(model); return(propertyList); }
private decimal GetCoeficientK(NicelideTitanumCoefficientWeighting coeficientValues, NicelideTitanumSample sample, NicelideTitanumQualityBaseValue baseValues) { return((decimal)Round(Sqrt( (double)(coeficientValues.SampleThickness * Round(sample.SampleThickness / baseValues.SampleThickness, 2) * Round(sample.SampleThickness / baseValues.SampleThickness, 2) + coeficientValues.HammerThickness * Round(sample.HammerThickness / baseValues.HammerThickness, 2) * Round(sample.HammerThickness / baseValues.HammerThickness, 2) + coeficientValues.HammerSpeed * Round((decimal)sample.HammerSpeed / baseValues.HammerSpeed, 2) * Round((decimal)sample.HammerSpeed / baseValues.HammerSpeed, 2) + coeficientValues.SpallSpeed * Round((decimal)sample.SpallSpeed / baseValues.SpallSpeed, 2) * Round((decimal)sample.SpallSpeed / baseValues.SpallSpeed, 2) + coeficientValues.SpallStrength * Round(sample.SpallStrength / baseValues.SpallStrength, 2) * Round(sample.SpallStrength / baseValues.SpallStrength, 2) )), 2)); }