示例#1
0
 /// <summary>
 /// 判断是否要发送当前所有权历史的前一条记录
 /// </summary>
 /// <param name="aircraft"></param>
 /// <param name="currentOwnershipHistory"></param>
 /// <returns></returns>
 public static OwnershipHistory GetOwnershipHistory(Aircraft aircraft, OwnershipHistory currentOwnershipHistory, FleetEntities dbContext)
 {
     if (aircraft == null || aircraft.OwnershipHistorys.Count <= 1)
     {
         return null;
     }
     else
     {
         //当前飞机所有权人历史的前一条记录
         var oh = dbContext.OwnershipHistories.Where(
                 o => o.OwnershipHistoryID != currentOwnershipHistory.OwnershipHistoryID && o.AircraftID == aircraft.AircraftID).OrderByDescending(
                     o => o.StartDate).FirstOrDefault();
         if (oh != null && currentOwnershipHistory.StartDate != null)
         {
             return oh;
         }
         else
         {
             return null;
         }
     }
 }
示例#2
0
 /// <summary>
 /// 移除所有权历史记录
 /// </summary>
 /// <param name="ownership"></param>
 /// <param name="service"></param>
 internal void RemoveOwnership(OwnershipHistory ownership, IFleetService service)
 {
     var ownweships =
         service.EntityContainer.GetEntitySet<OwnershipHistory>()
                .Where(os => os.Aircraft == ownership.Aircraft)
                .OrderBy(os => os.StartDate)
                .ToList();
     var count = ownweships.Count;
     // 所有权历史至少要保留一条
     if (count > 1)
     {
         service.EntityContainer.GetEntitySet<OwnershipHistory>().Remove(ownership);
         // 修改之前记录的结束日期
         ownweships[count - 2].EndDate = null;
     }
 }
示例#3
0
 /// <summary>
 /// 创建新的所有权历史记录
 /// </summary>
 /// <param name="aircraft"></param>
 /// <param name="service"></param>
 /// <returns></returns>
 internal OwnershipHistory CreateNewOwnership(Aircraft aircraft, IFleetService service)
 {
     var ownership = new OwnershipHistory
         {
             OwnershipHistoryID = Guid.NewGuid(),
             Aircraft = aircraft,
             Owner = service.CurrentAirlines,
             StartDate = DateTime.Now,
             Status = (int)OpStatus.Draft,
         };
     service.EntityContainer.GetEntitySet<OwnershipHistory>().Add(ownership);
     return ownership;
 }
示例#4
0
 /// <summary>
 /// 设置前一条的所有权历史的结束时间为当前所有权历史的开始时间减去一天
 /// </summary>
 /// <param name="aircraft"></param>
 /// <param name="currentOwnershipHistory"></param>
 public static void SetPreviousOwershipHistory(Aircraft aircraft, OwnershipHistory currentOwnershipHistory, FleetEntities dbContext)
 {
     if (currentOwnershipHistory != null && currentOwnershipHistory.StartDate != null)
     {
         //获取前一条所有权历史
         var formerOwershipHistory = GetOwnershipHistory(aircraft, currentOwnershipHistory, dbContext);
         if (formerOwershipHistory == null) return;
         //设置前一条所有权历史的结束时间为当前所有权历史的开始时间减去一天
         formerOwershipHistory.EndDate = currentOwnershipHistory.StartDate.Value.AddDays(-1);
     }
 }
示例#5
0
 private void UpdatepreviousOwnershipHistory(OwnershipHistory obj)
 {
     LogicHistoryHandle.SetPreviousOwershipHistory(obj.Aircraft, obj,this._FE);
 }