2025-09-04 18:28:02 +08:00

74 lines
2.4 KiB
C#
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

using Bricscad.ApplicationServices;
using Prism.Events;
using SWS.CAD.CADFunc.Editor;
using SWS.CAD.Event;
using SWS.CAD.ViewModels.myViewModelBase;
using SWS.CAD.Views;
using SWS.Commons;
using SWS.Model;
using SWS.Service;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using Telerik.Windows.Controls;
using Unity;
namespace SWS.CAD.ViewModels
{
public class ProjectViewModel : DialogBase
{
private List<ec_project> projects;
public List<ec_project> Projects
{
get { return this.projects; }
set
{
this.projects = value;
RaisePropertyChanged(nameof(Projects));
}
}
private ec_project _select;
public ec_project select
{
get { return _select; }
set { _select = value; RaisePropertyChanged(nameof(select)); }
}
ProjectService _Service;
ConfigService _configService;
IEventAggregator _eventAggregator;
public ProjectViewModel(IEventAggregator eventAggregator, ProjectService httpService, ConfigService configService) : base()
{
title = "项目选择";
_eventAggregator = eventAggregator;
_Service = httpService;
_configService = configService;
//_configService.Read(out address, out port, out directory);
}
public async override void onWindow_loaded(object para)
{
Projects = (await _Service.GetProjects(1, 200)).Rows;
base.onWindow_loaded(para);
}
public override async void ExecuteOKCommandAsync(object para)
{
if (select == null)
{
Application.ShowAlertDialog("请选择一个项目。");
return;
}
_configService.Save(nameof(ConfigIni.ProjectID), select.ProjectId);
GlobalObject.curProject = select;
IsBusy = true;
var userName = _configService.Read(nameof(ConfigIni.UserName));
var o = await _Service.InitProjInfo(GlobalObject.curProject.ProjectId, userName);
IsBusy = false;
_eventAggregator.GetEvent<loginEvent>().Publish(o);
EditorHelper.WriteInfo("进入项目!");
CloseWindowAction?.Invoke();//因为不能用 ExecuteCloseCommand 没办法把window作为参数带进去
}
}
}