duheng
2024-06-25 43e88ef24c6b3a7988c495d1740e68e33ce52f84
WinFrmUI/HStation.WinFrmUI.Xhs.Project/01-project/00-ViewModel/ProjectViewModel.cs
@@ -1,10 +1,16 @@
using HStation.Dto;
using HStation.BLL;
using HStation.Dto;
using HStation.Xhs;
using Yw.Dto;
namespace HStation.WinFrmUI.Xhs.Project
{
    public class ProjectViewModel : XhsProjectDto
    {
        public ProjectViewModel()
        {
        }
        public ProjectViewModel(XhsProjectDto rhs)
        {
            this.ID = rhs.ID;
@@ -13,6 +19,7 @@
            this.PrjNumber = rhs.PrjNumber;
            this.Flags = rhs.Flags;
            this.TagName = rhs.TagName;
            this.Address = rhs.Address;
            this.UseStatus = rhs.UseStatus;
            this.SortCode = rhs.SortCode;
            this.Description = rhs.Description;
@@ -21,7 +28,7 @@
            this.CreateUserID = rhs.CreateUserID;
            this.Version = rhs.Version;
            this.MapPosition = rhs.MapPosition;
            this.CreateDisplayName = CreateUserID.ToString();
            this.CreateUserDisplayName = rhs.CreateUserDisplayName;
        }
        public void Reset(ProjectViewModel rhs)
@@ -38,16 +45,19 @@
            this.CreateUserID = rhs.CreateUserID;
            this.Version = rhs.Version;
            this.MapPosition = rhs.MapPosition;
            this.CreateDisplayName = CreateUserID.ToString();
            this.CreateUserDisplayName = rhs.CreateUserDisplayName;
        }
        public void Reset(UpdateXhsProjectInput rhs)
        {
            this.ID = rhs.ID;
            this.GID = rhs.GID;
            this.Name = rhs.Name;
            this.Paras = rhs.Paras;
            this.Flags = rhs.Flags;
            this.PrjNumber = rhs.PrjNumber;
            this.TagName = rhs.TagName;
            this.Address = rhs.Address;
            this.SortCode = rhs.SortCode;
            this.Description = rhs.Description;
            this.CreateTime = rhs.CreateTime;
@@ -55,12 +65,59 @@
            this.CreateUserID = rhs.CreateUserID;
            this.Version = rhs.Version;
            this.MapPosition = rhs.MapPosition;
            this.CreateDisplayName = CreateUserID.ToString();
            this.CreateUserDisplayName = rhs.CreateUserDisplayName;
        }
        public async Task<ProjectViewModel> SetUploadStatusAsync(ProjectViewModel model)
        {
            var modelbll = new BLL.XhsProjectItemModel();
            var result = await modelbll.GetByPrjID(model.ID);
            var select = result.Where(x => x.UseStatus == 1).FirstOrDefault();
            if (select != null)
            {
                if (select.UploadStatus == HStation.Xhs.eUploadStatus.Disable)
                {
                    model.eUploadStatus = "未上传";
                }
                else if (select.UploadStatus == HStation.Xhs.eUploadStatus.Enable)
                {
                    model.eUploadStatus = "已上传";
                }
                else
                {
                    model.eUploadStatus = "上传中";
                }
            }
            return model;
        }
        public async Task<ProjectViewModel> SetUploadStatusAsync(XhsProjectDto model)
        {
            var prjviewmodel = new ProjectViewModel(model);
            var modelbll = new BLL.XhsProjectItemModel();
            var result = await modelbll.GetByPrjID(model.ID);
            var select = result.Find(x => x.UseStatus == 1);
            if (select != null)
            {
                if (select.UploadStatus == HStation.Xhs.eUploadStatus.Disable)
                {
                    prjviewmodel.eUploadStatus = "未上传";
                }
                else if (select.UploadStatus == HStation.Xhs.eUploadStatus.Enable)
                {
                    prjviewmodel.eUploadStatus = "已上传";
                }
                else
                {
                    prjviewmodel.eUploadStatus = "上传中";
                }
            }
            return prjviewmodel;
        }
        /// <summary>
        /// 创建人显示名字
        /// 上传状态
        /// </summary>
        public string CreateDisplayName { get; set; }
        public string eUploadStatus { get; set; }
    }
}