using System.IO;
|
using Yw;
|
|
namespace PBS.WinFrmUI
|
{
|
public class packageCurveViewModel
|
{
|
public long PcakageID { get; set; }
|
|
public string PackageName { get; set; }
|
|
public List<PumpInfo> PumpInfos { get; set; }
|
|
public static async void SaveCurveFile(long facilityId, long packageId)
|
{
|
if (packageId < 0)
|
return;
|
var model = new packageCurveViewModel();
|
model.PcakageID = packageId;
|
model.PumpInfos = new List<PumpInfo>();
|
var pumpList = await new HStation.BLL.AssetsPackagePumpMapping().GetByPackageID(packageId);
|
foreach (var item in pumpList)
|
{
|
var allList = await BLLFactory<HStation.BLL.PhartDiagramRelation>.Instance
|
.GetByObjectTypeAndObjectID(HStation.Assets.DataType.PumpMain, item.PumpMainID);
|
var maxImportance = allList.OrderByDescending(x => x.Importance).FirstOrDefault();
|
var vmo = await BLLFactory<Yw.BLL.PhartDiagramExtensions>.Instance.GetByID(maxImportance.DiagramID);
|
model.PumpInfos.Add(new PumpInfo
|
{
|
PumpID = item.ID,
|
PumpName = item.PumpOtherName,
|
phartDiagramExGraphListVmo = vmo
|
});
|
}
|
var json = Yw.JsonHelper.Object2Json(model);
|
string rootDirectory = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "Package_Curve");
|
if (!Directory.Exists(rootDirectory))
|
{
|
Directory.CreateDirectory(rootDirectory);
|
}
|
string filePath = Path.Combine(rootDirectory, $"{facilityId}.json");
|
if (!Directory.Exists(filePath))
|
{
|
File.Delete(filePath);
|
}
|
File.WriteAllText(filePath, json);
|
}
|
|
public static void DeleteCurveFile(long facilityId)
|
{
|
string rootDirectory = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "Package_Curve");
|
|
string filePath = Path.Combine(rootDirectory, $"{facilityId}.json");
|
if (!Directory.Exists(filePath))
|
{
|
File.Delete(filePath);
|
}
|
}
|
|
public static packageCurveViewModel GetFacilityCurve(long facilityId)
|
{
|
string rootDirectory = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "Package_Curve");
|
|
string filePath = Path.Combine(rootDirectory, $"{facilityId}.json");
|
if (!Directory.Exists(filePath))
|
{
|
var json = File.ReadAllText(filePath);
|
return JsonHelper.Json2Object<packageCurveViewModel>(json);
|
}
|
return null;
|
}
|
}
|
|
public class PumpInfo
|
{
|
public long PumpID { get; set; }
|
|
public string PumpName { get; set; }
|
|
public Yw.Vmo.PhartDiagramExGraphListVmo phartDiagramExGraphListVmo { get; set; }
|
}
|
}
|