public void Create(CreateEquipmentArchiveInput input)
        {
            var archive = _equipmentArchiveRepository.FirstOrDefault(e => e.SerialNo == input.SerialNo);

            if (archive != null)
            {
                throw new UserFriendlyException("设备序号已经存在!");
            }
            archive = new EquipmentArchive
            {
                AssignedPersonId = input.AssignedPersonId,
                CustomerId       = input.CustomerId,
                InstallType      = input.InstallType,
                Office           = input.Office,
                OfficeMobile     = input.OfficeMobile,
                OfficePerson     = input.OfficePerson,
                OfficePosition   = input.OfficePosition,
                OfficeTel        = input.OfficeTel,
                ProductId        = input.ProductId,
                SerialNo         = input.SerialNo,
                ServiceTime      = input.ServiceTime,
                Warrenty         = input.Warrenty
            };
            _equipmentArchiveRepository.Insert(archive);
        }
Example #2
0
        public void Archive(int id)
        {
            var bill = _workOrderRepository.Get(id);

            if (string.IsNullOrEmpty(bill.SerialNo))
            {
                throw new UserFriendlyException("设备序列号不能为空");
            }
            var archive = _equipmentArchiveAppService.GetArchiveBySerialNo(bill.SerialNo);

            if (archive != null)
            {
                var editInput = new EditEquipmentArchiveInput()
                {
                    AssignedPersonId = bill.ServiceType.Equals(ServiceType.Install) ? bill.AssignedPersonId : archive.AssignedPersonId,
                    CustomerId       = bill.CustomerId,
                    InstallType      = bill.ServiceType.Equals(ServiceType.Install) ? bill.InstallType : archive.InstallType,
                    Id             = archive.Id,
                    Office         = bill.Office,
                    OfficeMobile   = bill.OfficeMobile,
                    OfficePerson   = bill.OfficePerson,
                    OfficePosition = bill.OfficePosition,
                    OfficeTel      = bill.OfficeTel,
                    ProductId      = bill.ProductId,
                    SerialNo       = bill.SerialNo,
                    ServiceTime    = bill.ServiceType.Equals(ServiceType.Install) ? bill.ServiceTime : archive.ServiceTime,
                    Warrenty       = bill.ServiceType.Equals(ServiceType.Install) ? bill.Warrenty : archive.Warrenty
                };
                _equipmentArchiveAppService.Edit(editInput);
            }
            else
            {
                var createInput = new CreateEquipmentArchiveInput()
                {
                    AssignedPersonId = bill.ServiceType.Equals(ServiceType.Install) ? bill.AssignedPersonId : new Nullable <long>(),
                    CustomerId       = bill.CustomerId,
                    InstallType      = bill.ServiceType.Equals(ServiceType.Install) ? bill.InstallType : "",
                    Office           = bill.Office,
                    OfficeMobile     = bill.OfficeMobile,
                    OfficePerson     = bill.OfficePerson,
                    OfficePosition   = bill.OfficePosition,
                    OfficeTel        = bill.OfficeTel,
                    ProductId        = bill.ProductId,
                    SerialNo         = bill.SerialNo,
                    ServiceTime      = bill.ServiceType.Equals(ServiceType.Install) ? bill.ServiceTime : new Nullable <DateTime>(),
                    Warrenty         = bill.ServiceType.Equals(ServiceType.Install) ? bill.Warrenty : new Nullable <DateTime>()
                };
                _equipmentArchiveAppService.Create(createInput);
            }

            //记录归档活动
            var user            = AsyncHelper.RunSync(() => UserManager.GetUserByIdAsync(UserManager.AbpSession.UserId.Value));
            var archiveActivity = new Activity()
            {
                Bill = bill, Operater = user, Log = string.Format("归档")
            };

            _workOrderManager.AddActivity(archiveActivity);
        }