private static Task <Translation> GetFieldTranslationFromCache(Guid connectionId, IOrganizationServiceExtented service) { var sdkMessageRequestRepository = new SdkMessageRequestRepository(service); var translationRepository = new TranslationRepository(service); return(GetTranslationFromCacheOrCreate(connectionId, _cacheField, _fileNameFieldTranslation, () => GetFieldTranslation(sdkMessageRequestRepository, translationRepository))); }
private static async Task <Translation> GetFieldTranslationFromCache(Guid connectionId, IOrganizationServiceExtented service) { if (_cacheField.ContainsKey(connectionId)) { return(_cacheField[connectionId]); } var fileName = string.Format("FieldTranslation.{0}.xml", connectionId.ToString()); var trans = FileOperations.GetTranslationLocalCache(fileName); if (trans != null) { if (!_cacheField.ContainsKey(connectionId)) { _cacheField.TryAdd(connectionId, trans); } return(trans); } var repository = new SdkMessageRequestRepository(service); var request = await repository.FindByRequestNameAsync(SdkMessageRequest.Instances.ExportFieldTranslationRequest, new ColumnSet(false)); if (request == null) { return(null); } var rep = new TranslationRepository(service); var result = rep.GetFieldTranslations(); if (result != null) { if (!_cacheField.ContainsKey(connectionId)) { _cacheField.TryAdd(connectionId, result); } FileOperations.SaveTranslationLocalCache(fileName, result); } return(result); }
private static Translation GetDefaultTranslationFromCache(Guid connectionId, IOrganizationServiceExtented service) { if (_cacheDefault.ContainsKey(connectionId)) { return(_cacheDefault[connectionId]); } var fileName = string.Format("DefaultTranslation.{0}.xml", connectionId.ToString()); var trans = FileOperations.GetTranslationLocalCache(fileName); if (trans != null) { if (!_cacheDefault.ContainsKey(connectionId)) { _cacheDefault.TryAdd(connectionId, trans); } return(trans); } var rep = new TranslationRepository(service); var result = rep.GetTranslations(); if (result != null) { FileOperations.SaveTranslationLocalCache(fileName, result); if (!_cacheDefault.ContainsKey(connectionId)) { _cacheDefault.TryAdd(connectionId, result); } } return(result); }
private static async Task <Translation> GetDefaultTranslationFromCache(Guid connectionId, IOrganizationServiceExtented service) { var repository = new TranslationRepository(service); return(await GetTranslationFromCacheOrCreate(connectionId, _cacheDefault, _fileNameDefaultTranslation, repository.GetTranslationsAsync)); }
private static async Task <Translation> GetFieldTranslation(SdkMessageRequestRepository sdkMessageRequestRepository, TranslationRepository translationRepository) { var request = await sdkMessageRequestRepository.FindByRequestNameAsync(SdkMessageRequest.Instances.ExportFieldTranslationRequest, ColumnSetInstances.None); if (request == null) { return(null); } var result = await translationRepository.GetFieldTranslationsAsync(); return(result); }