public static ContainerEload Load(string tID) { if (ContainerEloadCache.ContainsKey(tID)) { return(ContainerEloadCache[tID]); } else { ContainerEload ce = new ContainerEload(); ce.ID = tID; ce.Select(); if (ce != null) { ContainerEloadCache.Add(tID, ce); } return(ce); } }
public static void ReloadAll(string source) { List <MyFavourite> list = MyFavourite.Cache.FavouriteList_Active; JavaScriptSerializer jsonSerializer = new JavaScriptSerializer(); if (list.Count > 0 && source == "cache") { foreach (MyFavourite mf in list) { switch (mf.OBJECTTYPE) { case "ContainerEload": ContainerEload ce = ContainerEload.Cache.Load(mf.OBJECTID); if (ce != null) { mf.OverRideObjContent(jsonSerializer.Serialize(ce)); } break; case "ContainerMain": case "ContainerDetail": ContainerMain cm = ContainerMain.Cache.Load(mf.OBJECTID); if (cm != null) { mf.OverRideObjContent(jsonSerializer.Serialize(cm)); } break; case "ContainerPlan": ContainerPlan cp = ContainerPlan.Cache.Load(mf.OBJECTID); if (cp != null) { mf.OverRideObjContent(jsonSerializer.Serialize(cp)); } break; case "Truck": OTruck truck = OTruck.Cache.Load(mf.OBJECTID); if (truck != null) { mf.OverRideObjContent(jsonSerializer.Serialize(truck)); } break; case "VesselPlan": OVesselPlan vp = OVesselPlan.Cache.Load(mf.OBJECTID); if (vp != null) { mf.OverRideObjContent(jsonSerializer.Serialize(vp)); } break; default: break; } } } else if (list.Count > 0 && source == "database") { foreach (MyFavourite mf in list) { switch (mf.OBJECTTYPE) { case "ContainerEload": ContainerEload ce = new ContainerEload(); ce.ID = mf.OBJECTID; ce.Select(); if (ce != null) { mf.OverRideObjContent(jsonSerializer.Serialize(ce)); } break; case "ContainerMain": case "ContainerDetail": ContainerMain cm = new ContainerMain(); cm.ID = mf.OBJECTID; cm.Select(); if (cm != null) { mf.OverRideObjContent(jsonSerializer.Serialize(cm)); } break; case "ContainerPlan": ContainerPlan cp = new ContainerPlan(); cp.ID = mf.OBJECTID; cp.Select(); if (cp != null) { mf.OverRideObjContent(jsonSerializer.Serialize(cp)); } break; case "Truck": OTruck truck = new OTruck(); truck.ID = mf.OBJECTID; truck.Select(); if (truck != null) { mf.OverRideObjContent(jsonSerializer.Serialize(truck)); } break; case "VesselPlan": OVesselPlan vp = new OVesselPlan(); vp.ID = mf.OBJECTID; vp.Select(); if (vp != null) { mf.OverRideObjContent(jsonSerializer.Serialize(vp)); } break; default: break; } } } // 持久化 list = list.FindAll(f => f.UpdateFlag); foreach (MyFavourite mf in list) { mf.Update(); } }