コード例 #1
0
ファイル: OperationHistorySync.cs プロジェクト: unicloud/AFRP
 /// <summary>
 /// 同步上一年度计划
 /// </summary>
 /// <param name="dbContext"></param>
 /// <param name="currentPlanHisotry"></param>
 /// <param name="StartDate"></param>
 /// <param name="currentOpenAnnual"></param>
 private static void SynOperationLastYearPlan(FleetEntities dbContext, PlanHistory currentPlanHisotry, DateTime StartDate, Annual currentOpenAnnual)
 {
     //找到上个年度的有效计划,补上当前计划运营历史或者商业数据
     //上个年度有效的打开的年度
     var lastOpenAnnual = dbContext.Annuals.FirstOrDefault(p => p.Year == currentOpenAnnual.Year - 1);
     //需要同步的计划历史
     var needSyncPlanHisotry = from t in dbContext.Plans
                               from a in dbContext.PlanHistories
                               from r in dbContext.PlanAircrafts
                               where
                                   t.IsValid == true && t.AnnualID == lastOpenAnnual.AnnualID &&
                                   t.PlanID == a.PlanID
                                   && r.PlanAircraftID == a.PlanAircraftID &&
                                   r.PlanAircraftID == currentPlanHisotry.PlanAircraftID
                               select a;
     var searchPlanHistory = needSyncPlanHisotry.FirstOrDefault();
     if (searchPlanHistory != null)
     {
         //如果运营日期在上一执行年度,则需要反向同步
         if (lastOpenAnnual != null && StartDate.Year <= lastOpenAnnual.Year)
         {
             if (currentPlanHisotry != null && (currentPlanHisotry.GetType() == typeof(OperationPlan) && searchPlanHistory.GetType() == typeof(OperationPlan) && (searchPlanHistory as OperationPlan).OperationHistory == null))
             {
                 var operationPlan = searchPlanHistory as OperationPlan;
                 if (operationPlan != null)
                     operationPlan.OperationHistoryID = (currentPlanHisotry as OperationPlan).OperationHistoryID;
             }
             if (currentPlanHisotry.GetType() == typeof(ChangePlan) && searchPlanHistory.GetType() == typeof(ChangePlan) && (searchPlanHistory as ChangePlan).AircraftBusiness == null)
             {
                 var changePlan = searchPlanHistory as ChangePlan;
                 if (changePlan != null)
                     changePlan.AircraftBusinessID = (currentPlanHisotry as ChangePlan).AircraftBusinessID;
             }
         }
         else //如果不需要反向同步的需要,要将可能由于运营时间得改动,有做过反向同步的给取消掉
         {
             if (currentPlanHisotry.GetType() == typeof(OperationPlan) && searchPlanHistory.GetType() == typeof(OperationPlan) && (searchPlanHistory as OperationPlan).OperationHistory != null)
             {
                 var operationPlan = searchPlanHistory as OperationPlan;
                 if (operationPlan != null)
                     operationPlan.OperationHistoryID = null;
             }
             if (currentPlanHisotry.GetType() == typeof(ChangePlan) && searchPlanHistory.GetType() == typeof(ChangePlan) && (searchPlanHistory as ChangePlan).AircraftBusiness != null)
             {
                 var changePlan = searchPlanHistory as ChangePlan;
                 if (changePlan != null)
                     changePlan.AircraftBusinessID = null;
             }
         }
     }
 }
コード例 #2
0
ファイル: OperationHistorySync.cs プロジェクト: unicloud/AFRP
        /// <summary>
        ///同步下一年度计划 
        /// </summary>
        /// <param name="dbContext"></param>
        /// <param name="currentPlanHisotry"></param>
        /// <param name="currentOpenAnnual"></param>
        private static void SynOperationNextYearPlan(FleetEntities dbContext, PlanHistory currentPlanHisotry, Annual currentOpenAnnual)
        {
            //找到大于当前年度的计划,补上当前计划运营历史或者商业数据
            //大于当前有效计划的集合
            var exceedAnnual = dbContext.Annuals.Where(p => p.Year > currentOpenAnnual.Year);
            //需要同步的计划历史
            var searchNextPlanHistories = from t in dbContext.Plans
                                          from a in dbContext.PlanHistories
                                          from r in dbContext.PlanAircrafts
                                          from f in exceedAnnual
                                          where
                                              t.AnnualID == f.AnnualID &&
                                              t.PlanID == a.PlanID
                                              && r.PlanAircraftID == a.PlanAircraftID &&
                                              r.PlanAircraftID == currentPlanHisotry.PlanAircraftID
                                          select a;

            searchNextPlanHistories.ToList().ForEach
                (
                    f =>
                    {
                        if (currentPlanHisotry.GetType() == typeof(OperationPlan) && f.GetType() == typeof(OperationPlan) && (f as OperationPlan).OperationHistory == null)
                        {
                            var operationPlan = f as OperationPlan;
                            if (operationPlan != null)
                            {
                                var plan = currentPlanHisotry as OperationPlan;
                                if (plan != null)
                                    operationPlan.OperationHistoryID = plan.OperationHistoryID;
                            }
                        }
                        if (currentPlanHisotry.GetType() != typeof(ChangePlan) ||
                            f.GetType() != typeof(ChangePlan) || (f as ChangePlan).AircraftBusiness != null)
                            return;
                        var changePlan = f as ChangePlan;
                        if (changePlan != null)
                        {
                            var plan = currentPlanHisotry as ChangePlan;
                            if (plan != null)
                                changePlan.AircraftBusinessID = plan.AircraftBusinessID;
                        }
                    }
                );
        }
コード例 #3
0
ファイル: DecodePlan.cs プロジェクト: unicloud/AFRP
 /// <summary>
 /// 更新年度
 /// </summary>
 /// <param name="annual">计划的当前年度</param>
 private void UpdateAnnual(Annual annual)
 {
     if (annual != null)
     {
         //设置当前年度为打开的年度,其他年度为不能打开的年度
         if (annual != null && annual.IsOpen != false)
         {
             annual.IsOpen = true;
             //更新其他年度的年度为不可打开
             if (this._FE.Annuals.Any(p => p.IsOpen == true && p.AnnualID != annual.AnnualID))
             {
                 //找到存在该条件的计划,设置可打开的属性为false
                 this._FE.Annuals.Where(p => p.IsOpen == true && p.AnnualID != annual.AnnualID).ToList().ForEach
                     (
                       ann =>
                       {
                           ann.IsOpen = false;
                           this.Update<Annual>(_FE, ann);
                       }
                     );
             }
             this.Update<Annual>(_FE, annual);
         }
     }
 }