| | |
| | | using HStation.Vmo; |
| | | using NPOI.HSSF.Record; |
| | | |
| | | namespace HStation.WinFrmUI |
| | | namespace HStation.WinFrmUI |
| | | { |
| | | public partial class SetXhsProjectMapLocationWizardPage : DevExpress.XtraEditors.XtraUserControl, Yw.WinFrmUI.IWizardPage<ImportXhsProjectViewModel> |
| | | public partial class SetXhsProjectMapLocationWizardPage : DevExpress.XtraEditors.XtraUserControl, Yw.WinFrmUI.IWizardPageAsync<ImportXhsProjectViewModel> |
| | | { |
| | | public SetXhsProjectMapLocationWizardPage() |
| | | { |
| | | InitializeComponent(); |
| | | this.layoutControl1.SetupLayoutControl(); |
| | | this.mapSetSimpleMarkerContainer1.LoadCompletedEvent += MapSetSimpleMarkerContainer1_LoadCompletedEvent; |
| | | this.mapSetSimpleMarkerContainer1.SetMarkerEvent += MapSetSimpleMarkerContainer1_SetMarkerEvent; |
| | | } |
| | | |
| | | private ImportXhsProjectViewModel _vm = null; |
| | | /// <summary> |
| | | /// 页面状态发生改变事件 |
| | | /// </summary> |
| | | public event Action PageStateChangedEvent; |
| | | |
| | | private ImportXhsProjectViewModel _vm = null;//操作对象 |
| | | private bool _isInitialize = false;//是否初始化 |
| | | |
| | | /// <summary> |
| | | /// 初始化 |
| | | /// </summary> |
| | | public async void InitialPage(ImportXhsProjectViewModel t) |
| | | public async void InitialPage(ImportXhsProjectViewModel vm) |
| | | { |
| | | _vm = t; |
| | | this.mapSetSimpleMarkerContainer1.LoadCompletedEvent += MapSetSimpleMarkerContainer1_LoadCompletedEvent; |
| | | this.mapSetSimpleMarkerContainer1.SetMarkerEvent += MapSetSimpleMarkerContainer1_SetMarkerEvent; |
| | | if (_isInitialize) |
| | | { |
| | | return; |
| | | } |
| | | _vm = vm; |
| | | _isInitialize = true; |
| | | this.txtAddress.EditValue = vm.Project.Address; |
| | | await this.mapSetSimpleMarkerContainer1.InitialContainer(); |
| | | PageStateChangedEvent.Invoke(); |
| | | } |
| | | |
| | | /// <summary> |
| | | /// 是否初始化 |
| | | /// </summary> |
| | | public bool IsInitialize |
| | | { |
| | | get { return _isInitialize; } |
| | | } |
| | | |
| | | private bool _isInitialize = false; |
| | | |
| | | public event Action PageStateChangedEvent; |
| | | |
| | | /// <summary> |
| | | /// 是否允许上一步 |
| | | /// </summary> |
| | | public bool AllowPrev |
| | | { |
| | | get { return true; } |
| | | get |
| | | { |
| | | return true; |
| | | } |
| | | } |
| | | |
| | | /// <summary> |
| | |
| | | /// </summary> |
| | | public bool AllowNext |
| | | { |
| | | get { return true; } |
| | | set { } |
| | | get |
| | | { |
| | | return true; |
| | | } |
| | | } |
| | | |
| | | /// <summary> |
| | |
| | | /// </summary> |
| | | public bool AllowCancel |
| | | { |
| | | get { return true; } |
| | | get |
| | | { |
| | | return true; |
| | | } |
| | | } |
| | | |
| | | /// <summary> |
| | |
| | | /// </summary> |
| | | public bool AllowComplete |
| | | { |
| | | get { return false; } |
| | | set { } |
| | | get |
| | | { |
| | | return false; |
| | | } |
| | | } |
| | | |
| | | /// <summary> |
| | | /// 能否上一步 |
| | | /// </summary> |
| | | public bool CanPrev() |
| | | public Task<bool> CanPrev() |
| | | { |
| | | return true; |
| | | return Task.Run(() => true); |
| | | } |
| | | |
| | | /// <summary> |
| | | /// 能否下一步 |
| | | /// </summary> |
| | | public bool CanNext() |
| | | public Task<bool> CanNext() |
| | | { |
| | | return true; |
| | | return Task.Run(() => |
| | | { |
| | | if (string.IsNullOrEmpty(_vm.Project.Address)) |
| | | { |
| | | _vm.Project.Address = this.txtAddress.Text.Trim(); |
| | | } |
| | | return true; |
| | | }); |
| | | } |
| | | |
| | | /// <summary> |
| | | /// 能否取消 |
| | | /// </summary> |
| | | public bool CanCancel() |
| | | public Task<bool> CanCancel() |
| | | { |
| | | return true; |
| | | return Task.Run(() => true); |
| | | } |
| | | |
| | | /// <summary> |
| | | /// 能否完成 |
| | | /// </summary> |
| | | public bool CanComplete() |
| | | public Task<bool> CanComplete() |
| | | { |
| | | Task<bool> task = Task.Run(async () => await InsertProject()); |
| | | var bol = task.GetAwaiter(); |
| | | return true; |
| | | } |
| | | |
| | | private async Task<bool> InsertProject() |
| | | { |
| | | var bllXhsProjectExtensions = new BLL.XhsProjectExtensions(); |
| | | var project = new XhsProjectExtensionsVmo(); |
| | | project.NO = _vm.NO; |
| | | project.Name = _vm.Name; |
| | | project.Address = _vm.Address; |
| | | project.Customer = _vm.Customer; |
| | | project.Flags = _vm.Flags; |
| | | project.TagName = _vm.TagName; |
| | | project.Description = _vm.Description; |
| | | project.SiteList = new List<XhsProjectSiteVmo>() { |
| | | new XhsProjectSiteVmo(){ |
| | | Name=_vm.Name, |
| | | Description=_vm.Description |
| | | } |
| | | }; |
| | | var projectId = await bllXhsProjectExtensions.Insert(project); |
| | | if (projectId > 1) |
| | | { |
| | | _vm.ProjectID = projectId; |
| | | if (_vm.Location != null) |
| | | { |
| | | var mapInfo = new Yw.Vmo.MapInfoVmo(); |
| | | mapInfo.ObjectType = HStation.Xhs.DataType.XhsProject; |
| | | mapInfo.ObjectID = projectId; |
| | | mapInfo.ObjectName = project.Name; |
| | | mapInfo.Purpose = Yw.Map.Purpose.Location; |
| | | mapInfo.Kind = Yw.Map.Kind.Gaodei; |
| | | mapInfo.Shape = Yw.Map.Shape.Marker; |
| | | mapInfo.Position = _vm.Location.ToJson(); |
| | | var mapInfoId = await new Yw.BLL.MapInfo().Insert(mapInfo); |
| | | if (mapInfoId < 1) |
| | | { |
| | | return false; |
| | | } |
| | | else |
| | | { |
| | | return true; |
| | | } |
| | | } |
| | | } |
| | | return true; |
| | | return Task.Run(() => false); |
| | | } |
| | | |
| | | //地图加载完成 |
| | | private async void MapSetSimpleMarkerContainer1_LoadCompletedEvent() |
| | | { |
| | | if (_vm == null) |
| | | if (!_isInitialize) |
| | | { |
| | | return; |
| | | } |
| | | if (_vm.Location != null) |
| | | if (_vm.MapInfo != null) |
| | | { |
| | | await this.mapSetSimpleMarkerContainer1.LoadMarker(_vm.Location); |
| | | var marker = Yw.Model.Map.Marker.ToModel(_vm.MapInfo.Position); |
| | | if (marker != null) |
| | | { |
| | | await this.mapSetSimpleMarkerContainer1.LoadMarker(marker); |
| | | if (string.IsNullOrEmpty(this.txtAddress.Text.Trim())) |
| | | { |
| | | this.txtAddress.EditValue = marker.Address; |
| | | } |
| | | } |
| | | |
| | | } |
| | | await this.mapSetSimpleMarkerContainer1.SearchAddress(); |
| | | } |
| | | |
| | | //设置位置 |
| | | private void MapSetSimpleMarkerContainer1_SetMarkerEvent(Yw.Model.Map.Marker obj) |
| | | { |
| | | if (_vm != null) |
| | | if (!_isInitialize) |
| | | { |
| | | _vm.Location = obj; |
| | | return; |
| | | } |
| | | if (_vm.MapInfo == null) |
| | | { |
| | | _vm.MapInfo = new Yw.Vmo.MapInfoVmo(); |
| | | _vm.MapInfo.ObjectType = HStation.Xhs.DataType.XhsProject; |
| | | _vm.MapInfo.ObjectID = _vm.Project.ID; |
| | | _vm.MapInfo.ObjectName = _vm.Project.Name; |
| | | _vm.MapInfo.Purpose = Yw.Map.Purpose.Location; |
| | | _vm.MapInfo.Kind = Yw.Map.Kind.Gaodei; |
| | | _vm.MapInfo.Shape = Yw.Map.Shape.Marker; |
| | | } |
| | | _vm.MapInfo.Position = obj.ToJson(); |
| | | this.txtAddress.EditValue = obj.Address; |
| | | } |
| | | |
| | | } |
| | | } |