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> 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);
        }
Esempio n. 3
0
        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);
        }