/// <summary> /// 30-33.ปริมาณการใช้น้ำประปา /// /// </summary> public CubicMeterRequest CubicMeterPlumbing(bool isChecked, WaterCharacter character) { this.character = character; var waterActivityMWA = WaterActivity(Plumbing?.WaterActivityMWA); var waterActivityPWA = WaterActivity(Plumbing?.WaterActivityPWA); var waterActivityOther = WaterActivity(Plumbing?.WaterActivityOther); var cubicMeterMWA = CubicMeter(Plumbing?.MWA, "M") * (waterActivityMWA / 100); var cubicMeterPWA = CubicMeter(Plumbing?.PWA, "P") * (waterActivityPWA / 100); var cubicMeterOther = CubicMeter(Plumbing?.Other, "O") * (waterActivityOther / 100); var cubicMeter = cubicMeterMWA + cubicMeterPWA + cubicMeterOther; if (cubicMeter < 1 && cubicMeter != 0) { cubicMeter = 1; } return(new CubicMeterRequest { CanCompute = isChecked ? CanCumputePlumbing : StatusCompute.NA, CubicMeterMWA = isChecked ? cubicMeterMWA : 0, CubicMeterPWA = isChecked ? cubicMeterPWA : 0, CubicMeterOther = isChecked ? cubicMeterOther : 0, CubicMeter = isChecked ? cubicMeter : 0, }); }
public double CalcBuying(WaterCharacter character) { return(Buying != null ? Buying.Package .Where(it => double.TryParse(it?.Size, out double size)) .Sum(it => double.Parse(it.Size) * BuyingActivity(it, character) / (!string.IsNullOrEmpty(it.Name) && it.Name.Contains("ขวด") ? 1000000 : 1000)) * 12 : 0); }
private double BuyingActivity(Package package, WaterCharacter character) { switch (character) { case WaterCharacter.IsAgriculture: return(package?.Agriculture ?? 0); case WaterCharacter.IsCommercial: return(package?.Service ?? 0); case WaterCharacter.IsFactorial: return(package?.Factory ?? 0); case WaterCharacter.IsHouseHold: return(package?.Drink ?? 0); default: return(0); } }
private double WaterActivity(WaterActivity waterAct, WaterCharacter character) { switch (character) { case WaterCharacter.IsAgriculture: return(waterAct?.Agriculture ?? 0); case WaterCharacter.IsCommercial: return(waterAct?.Service ?? 0); case WaterCharacter.IsFactorial: return(waterAct?.Product ?? 0); case WaterCharacter.IsHouseHold: return(waterAct?.Drink ?? 0); default: return(0); } }
private double CalcPumps(List <Pump> pumps, bool isGround, WaterCharacter character) { var cubicMeter = pumps.Where(it => it != null).Sum(it => { if (it?.PumpAuto == false) { var pumpsPerYear = it.NumberOfPumpsPerYear ?? 0; if (pumpsPerYear < 0) { this.Adjusted = true; pumpsPerYear = Math.Abs(pumpsPerYear); } ; if (pumpsPerYear > 10) { pumpsPerYear = 10; } return((it.HoursPerPump ?? 0) * pumpsPerYear * CalcPumpRate(it, isGround)); } else { this.CanCumpute = StatusCompute.False; return(0); } }); if (pumps?.Any(it => it?.PumpAuto == true) == true) { switch (character) { case WaterCharacter.IsHouseHold: return(cubicMeter + 131.4); case WaterCharacter.IsAgriculture: return(cubicMeter + 3840); case WaterCharacter.IsFactorial: return(cubicMeter + 2496); case WaterCharacter.IsCommercial: return(cubicMeter + 468); default: return(cubicMeter); } } else { return(cubicMeter); } }
public CubicMeterSurfaceRequest CubicMeterSurface(WaterCharacter character) { this.character = character; var river = CalcRiver(); var irrigation = CalcIrrigation(); var rain = CalcRain(); var status = new StatusComputeManage(); var canComputeLst = new List <StatusCompute> { river.CanCompute, irrigation.CanCompute }; return(new CubicMeterSurfaceRequest { CanCompute = status.CheckStatusCompute(canComputeLst), CubicMeterRiver = river.CubicMeter, CubicMeterIrrigation = irrigation.CubicMeter, CubicMeterRain = rain, CubicMeter = river.CubicMeter + irrigation.CubicMeter + rain, Adjusted = river.Adjusted || irrigation.Adjusted }); }
public CubicMeterSurfaceRequest CalcPool(IEnumerable <WaterConsumptionUsingPump> resources, WaterCharacter character) { this.character = character; var canCumpute = StatusCompute.True; var adjusted = false; var cubicMeterPool = resources.Where(it => it != null).Sum(it => { try { if (it.HasCubicMeterPerMonth == true) { return((it.CubicMeterPerMonth ?? 0) * 12.0 * WaterActivity(it.WaterActivities) / 100); } else if (it.HasPump == true) { var PumpRequest = CalcPumps(it.Pumps, false); if (PumpRequest.Adjusted == true) { adjusted = true; } return(PumpRequest.CubicMeter * WaterActivity(it.WaterActivities) / 100); } else { canCumpute = StatusCompute.False; return(0); } } catch (System.Exception) { } return(0); }); return(new CubicMeterSurfaceRequest { CanCompute = canCumpute, CubicMeterPool = cubicMeterPool, Adjusted = adjusted }); }
public CubicMeterRequest CalcPublic(IEnumerable <WaterConsumptionUsingPump> resources, WaterCharacter character) { this.CanCumpute = StatusCompute.True; this.Adjusted = false; var cubicMeter = resources.Where(it => it != null).Sum(it => { try { if (it.HasCubicMeterPerMonth == true) { return((it.CubicMeterPerMonth ?? 0) * 12 * WaterActivity(it.WaterActivities, character) / 100); } else if (it.HasPump == true) { return(CalcPumps(it.Pumps, true, character) * WaterActivity(it.WaterActivities, character) / 100); } else { this.CanCumpute = StatusCompute.False; return(0); } } catch (System.Exception) { } return(0); }); return(new CubicMeterRequest { CanCompute = this.CanCumpute, CubicMeter = cubicMeter, Adjusted = this.Adjusted }); }
public CubicMeterRequest CalcPrivate(IEnumerable <GroundWaterWell> resources, WaterCharacter character) { this.CanCumpute = StatusCompute.True; this.Adjusted = false; var cubicMeter = resources.Where(it => it != null).Sum(it => { try { if (it.UsageType.GroundWaterQuantity == GroundWaterQuantity.CubicMeterPerMonth) { return((it.UsageType.UsageCubicMeters ?? 0) * 12 * WaterActivity(it.WaterActivities, character) / 100); } else if (it.UsageType.GroundWaterQuantity == GroundWaterQuantity.WaterBill) { return((it.UsageType.WaterBill ?? 0) / WaterPrice(it.Location) * 12 * WaterActivity(it.WaterActivities, character) / 100); } else if (it.UsageType.GroundWaterQuantity == GroundWaterQuantity.Unknown && (it.HasPump == true)) { return(CalcPumps(it.Pumps, true, character) * WaterActivity(it.WaterActivities, character) / 100); } else { this.CanCumpute = StatusCompute.False; return(0); } } catch (System.Exception) { } return(0); }); return(new CubicMeterRequest { CanCompute = this.CanCumpute, CubicMeter = cubicMeter, Adjusted = this.Adjusted }); }