Exemplo n.º 1
0
        /// <summary>
        /// 判断是否要发送当前商业数据的前一条记录
        /// </summary>
        /// <param name="aircraft"></param>
        /// <param name="currentAircraftBusiness"></param>
        /// <returns></returns>
        public static AircraftBusiness GetAircraftBusiness(Aircraft aircraft, AircraftBusiness currentAircraftBusiness, FleetEntities dbContext)
        {
            if (aircraft == null || aircraft.AircraftBusinesses.Count <= 1)
            {
                return null;
            }
            else
            {
                //当前商业数据的前一条记录
                var ab = dbContext.AircraftBusinesses.Where(
                        o => o.AircraftBusinessID != currentAircraftBusiness.AircraftBusinessID && o.AircraftID == aircraft.AircraftID).OrderByDescending(
                            o => o.StartDate).FirstOrDefault();

                if (ab != null && currentAircraftBusiness.StartDate != null)
                {
                    return ab;
                }
                else
                {
                    return null;
                }
            }
        }
Exemplo n.º 2
0
        /// <summary>
        /// 创建新的商业数据历史
        /// </summary>
        /// <param name="aircraft">飞机</param>
        /// <param name="service"></param>
        private static void CreateAircraftBusiness(PlanHistory planDetail, Aircraft aircraft, IFleetService service)
        {
            var aircraftBusiness = new AircraftBusiness
                {
                    AircraftBusinessID = Guid.NewGuid(),
                    Aircraft = aircraft,
                    AircraftType = aircraft.AircraftType,
                    ImportCategory = aircraft.ImportCategory,
                    SeatingCapacity = aircraft.SeatingCapacity,
                    CarryingCapacity = aircraft.CarryingCapacity,
                    Status = (int)OpStatus.Draft,
                };

            if (planDetail is ChangePlan) (planDetail as ChangePlan).AircraftBusiness = aircraftBusiness;
            service.EntityContainer.GetEntitySet<AircraftBusiness>().Add(aircraftBusiness);
            // 更改商业数据历史状态
            aircraftBusiness.Status = (int)OpStatus.Draft;
        }
Exemplo n.º 3
0
 private void UpdatepreviousAircraftBusiness(AircraftBusiness obj)
 {
     LogicHistoryHandle.SetPreviousrAircraftBusiness(obj.Aircraft, obj,this._FE);
 }
Exemplo n.º 4
0
 /// <summary>
 /// 设置前一条的商业数据的结束时间为当前商业数据的开始时间减去一天
 /// </summary>
 /// <param name="aircraft"></param>
 /// <param name="currentAircraftBusiness"></param>
 public static void SetPreviousrAircraftBusiness(Aircraft aircraft, AircraftBusiness currentAircraftBusiness, FleetEntities dbContext)
 {
     if (currentAircraftBusiness != null && currentAircraftBusiness.StartDate != null)
     {
         //获取前一条商业数据
         var formerAircraftBusiness = GetAircraftBusiness(aircraft, currentAircraftBusiness, dbContext);
         if (formerAircraftBusiness == null) return;
         //设置前一条商业数据的结束时间为当前商业数据的开始时间减去一天
         formerAircraftBusiness.EndDate = currentAircraftBusiness.StartDate.Value.AddDays(-1);
     }
 }