日期:2014-05-17 浏览次数:20443 次
private void SynchronizeDailyMaintenanceModel() { this.EquipItemTable = this.EquipItemAdapter.GetData(); this.EquipItemVlTable = this.EquipItemVlAdapter.GetData(); this.InspectTable = this.InspectAdapter.GetData(); this.InspectItemVlTable = this.InspectItemVlAdapter.GetData(); DateTime maxLogTime; if (this.MmsEntityModel.DataSynchronizationLogEntities.Count() > 0) { maxLogTime = this.MmsEntityModel.DataSynchronizationLogEntities.Select(p => p.Time).Max(); } else { maxLogTime = Convert.ToDateTime("01/01/0001"); } var inspectQuery = from inspect in this.InspectTable where inspect.STANDARD_TIME > maxLogTime select inspect; foreach (MmsDataBase.NMS_INSPECTRow inspectRow in inspectQuery) { var inspectItemVlQuery = from inspectItemVl in this.InspectItemVlTable where inspectItemVl.INSPECT_ID == inspectRow.ID select inspectItemVl; foreach (MmsDataBase.NMS_INSPECT_ITEM_VLRow inspectItemVlRow in inspectItemVlQuery) { var equipItemVlQuery = from equipItemVl in this.EquipItemVlTable where equipItemVl.ID == inspectItemVlRow.ITEM_VL_ID select equipItemVl; foreach (MmsDataBase.NMS_EQUIP_ITEM_VLRow equipItemVlRow in equipItemVlQuery) { var equipItemQuery = from equipItem in this.EquipItemTable where equipItem.ID == equipItemVlRow.ITEM_ID select equipItem; foreach (MmsDataBase.NMS_EQUIP_ITEMRow equipItemRow in equipItemQuery) { var equipQuery = from equip in this.MmsEntityModel.EquipmentEntities where equip.ID == equipItemRow.EQUIP_ID select equip; if (equipQuery.Count() > 0) { DailyMaintenance maintenance = new DailyMaintenance(); maintenance.ID = inspectRow.ID; maintenance.Description = equipItemRow.NAME; maintenance.Time = inspectRow.STANDARD_TIME; maintenance.Cost = 0; Equipment parentEquip = equipQuery.First(); parentEquip.Maintenance.Add(maintenance); this.MmsEntityModel.MaintenanceEntities.AddObject(maintenance); } } } } } }
private void SynchronizeMaintenanceModel() { this.SynchronizeDailyMaintenanceModel(); this.MmsEntityModel.SaveChanges();