namespace PBS.WinFrmUI.Hydro
{
///
///
///
public class QuickModelingHelper
{
///
/// 创建
///
/// 通用视图Model
/// 信息反馈
/// 进度反馈
///
public static async Task Create(QuickModelingViewModel vm, Action feedBackMsg, Action feedBackProgress)
{
var msg = string.Empty;
if (vm == null)
{
return false;
}
//#region 第一步 复制水力信息
//feedBackMsg?.Invoke("正在创建水力信息副本...", Color.Black);
//var hydroInfoId = await BLLFactory.Instance.Copy(vm.HydroInfo.ID);
//if (hydroInfoId < 1)
//{
// feedBackMsg?.Invoke("水力信息副本创建失败!!!", Color.Red);
// return false;
//}
//feedBackMsg?.Invoke("水力信息副本创建成功。。。", Color.Green);
//feedBackProgress?.Invoke(100, 30);
//vm.HydroInfo = await BLLFactory.Instance.GetByID(hydroInfoId);
//#endregion
//#region 第二步 创建方案
//feedBackMsg?.Invoke("正在创建水力方案...", Color.Black);
//var schemeId = await BLLFactory.Instance.Insert(vm.Scheme);
//if (schemeId < 1)
//{
// feedBackMsg?.Invoke("水力方案创建失败!!!", Color.Red);
// return true;
//}
//feedBackMsg?.Invoke("水力方案创建成功。。。", Color.Green);
//feedBackProgress?.Invoke(100, 40);
//vm.Scheme = await BLLFactory.Instance.GetByID(schemeId);
//#endregion
//#region 第三步 建立水力关联
//feedBackMsg?.Invoke("正在建立水力关联...", Color.Black);
//var relation = new Yw.Vmo.HydroModelRelationVmo();
//relation.ObjectType = HStation.Xhs.DataType.XhsScheme;
//relation.ObjectID = vm.Scheme.ID;
//relation.ModelID = vm.HydroInfo.ID;
//relation.Purpose = Yw.Hydro.Purpose.Simulation;
//relation.Content = null;
//relation.SortCode = 1;
//relation.Description = "自动生成";
//relation.ID = await BLLFactory.Instance.Insert(relation);
//if (relation.ID < 1)
//{
// feedBackMsg?.Invoke("水力关联失败!!!", Color.Red);
// return true;
//}
//feedBackMsg?.Invoke("水力关联成功。。。", Color.Green);
//feedBackProgress?.Invoke(100, 50);
//#endregion
//#region 第四步 更新水力信息
//feedBackMsg?.Invoke("正在更新水力信息...", Color.Black);
//if (vm.allChangeRecordList != null && vm.allChangeRecordList.Count > 0)
//{
// var allParterChangeList = new List();
// foreach (var changeRecord in vm.allChangeRecordList)
// {
// var parter = changeRecord.ViewModel.Vmo;
// if (!allParterChangeList.Exists(x => x.Code == parter.Code))
// {
// allParterChangeList.Add(changeRecord.ViewModel.Vmo);
// }
// }
// var bol = await BLLFactory.Instance.Update(vm.HydroInfo, null, allParterChangeList, null);
// if (!bol)
// {
// feedBackMsg?.Invoke("水力信息更新失败!!!", Color.Red);
// }
//}
//feedBackMsg?.Invoke("水力信息更新成功。。。", Color.Green);
//feedBackProgress?.Invoke(100, 100);
return true;
}
}
}