private static void UpdateUserDefineCache() { using (SqlConnection conn = new SqlConnection(PLMConstantString.PLM_APP_ConnectionString)) { conn.Open(); string lastChange = PdmCacheEntityLookupItem.GetLastChangeCheckSum(conn, UserDefineEntityTableName); if (lastChange != string.Empty && lastChange != LastScanUserDefinePdmEntityBlClrDto.LastScanCheckSum) { // CLROutput.InsertException(conn, " lastChange before userdefine " + LastScanUserDefinePdmEntityBlClrDto.LastScanCheckSum); Dictionary <int, List <LookupItemDto> > dictUserDefineLookupItem = PLMSEntityClrBL.GetUserDefineEntityDisplayInfoList(UserDefineEntityList, conn); foreach (int entityId in dictUserDefineLookupItem.Keys) { Dictionary <object, string> result = PdmCacheEntityLookupItem.ConvertLookItemToDictionaryItem(dictUserDefineLookupItem[entityId]); // if( DictEntityLookupCache.Remove(entityId); DictEntityLookupCache.Add(entityId, result); } LastScanUserDefinePdmEntityBlClrDto.LastScanCheckSum = lastChange; // CLROutput.InsertException(conn, " lastChange userdefine after" + LastScanUserDefinePdmEntityBlClrDto.LastScanCheckSum); } } }
// private static System.Threading.Timer _timer; // private static readonly Thread JobThread = new Thread(new ThreadStart(CallthreadTask)); static PLMSCacheSystemTest() { PLMSCacheSystemTest.StartBaseCache(); SystemDefineEntityList = DictPdmEntityBlCache.Where(o => o.Value.EntityType.HasValue && o.Value.EntityType.Value == (int)EmEntityType.SystemDefineTable).Select(o => o.Value).ToList(); UserDefineEntityList = DictPdmEntityBlCache.Where(o => (o.Value.EntityType.HasValue) && o.Value.EntityType.Value == (int)EmEntityType.UserDefineTable).Select(o => o.Value).ToList(); PdmCacheEntityLookupItem.SetupAllLookItemCache(); SetupTimer(); }
private static void UpdateSystemDefineCache(PdmEntityBlClrDto entity) { int entityId = entity.EntityId; CLROutput.OutputDebug("UpdateSystemDefineCache start... ConnectInfo:" + entity.ConnectInfo); // CLROutput.OutputDebug("UpdateSystemDefineCache start..."); if (!string.IsNullOrEmpty(entity.ConnectInfo)) { //try //{ using (SqlConnection conn = new SqlConnection(entity.ConnectInfo)) { conn.Open(); string lastChange = PdmCacheEntityLookupItem.GetLastChangeCheckSum(conn, entity.SysTableName); // CLROutput.InsertException(conn, "entity.LastScanCheckSum: " + entity.LastScanCheckSum + "lastChange :" + lastChange); CLROutput.OutputDebug("entity.LastScanCheckSum: " + entity.LastScanCheckSum + "lastChange :" + lastChange); if (lastChange != entity.LastScanCheckSum) { if (DictEntityLookupCache.ContainsKey(entityId)) { CLROutput.OutputDebug(" lastChange sysdefine before DictEntityLookupCache " + "__" + entity.EntityCode + "__" + entity.LastScanCheckSum, conn); List <LookupItemDto> newLookupitem = PdmCacheEntityLookupItem.GetOneSystemDefinTableLookupItems(conn, PLMSEntityClrBL.GetSysDefineQueryIDAndDisplay(entity)); Dictionary <object, string> result = PdmCacheEntityLookupItem.ConvertLookItemToDictionaryItem(newLookupitem); DictEntityLookupCache.Remove(entityId); DictEntityLookupCache.Add(entityId, result); entity.LastScanCheckSum = lastChange; // CLROutput.InsertException(conn, " lastChange sysdefine after" + "__" + entity.EntityCode + "__" + entity.LastScanCheckSum); } } } //} //catch (Exception ex) //{ // //using (SqlConnection conn = new SqlConnection(PLMConstantString.PLM_APP_ConnectionString)) // //{ // // conn.Open(); // // CLROutput.InsertException(conn, " exception " + entity.EntityId + "__" + entity.EntityCode + ex.ToString()); // //} //} } }
static PdmCacheManager() { PdmCacheManager.StartBaseCache(); SystemDefineEntityList = DictPdmEntityBlEntity.Where(o => o.Value.EntityType.HasValue && o.Value.EntityType.Value == (int)EmEntityType.SystemDefineTable).Select(o => o.Value).ToList(); UserDefineEntityList = DictPdmEntityBlEntity.Where(o => (o.Value.EntityType.HasValue) && o.Value.EntityType.Value == (int)EmEntityType.UserDefineTable).Select(o => o.Value).ToList(); PdmCacheEntityLookupItem.SetupAllLookItemCache(); SetupEntityScanTimer(); }
internal static void GetUserDefineDictLookItem(SqlConnection conn, Dictionary <int, List <LookupItemDto> > dictEntityDisplayInfoList, List <PdmEntityBlClrDto> listPdmEntityDto) { List <PdmEntityBlClrDto> userDefineEntityList = listPdmEntityDto.Where(o => o.EntityType == (int)EmEntityType.UserDefineTable).ToList(); //Important, need to setyp last sca ltime string lastScaltime = PdmCacheEntityLookupItem.GetLastChangeCheckSum(conn, PdmCacheManager.UserDefineEntityTableName); PdmCacheManager.LastScanUserDefinePdmEntityBlClrDto.LastScanCheckSum = lastScaltime; if (userDefineEntityList.Count > 0) { Dictionary <int, List <LookupItemDto> > dictEnumList = GetUserDefineEntityDisplayInfoList(userDefineEntityList, conn); foreach (var dictitem in dictEnumList) { dictEntityDisplayInfoList.Add(dictitem.Key, dictitem.Value); } } }
public static Dictionary <int, Dictionary <object, string> > GetDictEntityDictDisplayString(List <int> entityIDs) { return(PdmCacheEntityLookupItem.GetDictEntityDictDisplayInforFromCache(entityIDs)); }