public KnowledgeArticleFactory(IDataAdapterDependencies dependencies)
        {
            dependencies.ThrowOnNull("dependencies");

            _dependencies = dependencies;

            var request = _dependencies.GetRequestContext();

            _httpContext = request == null ? null : request.HttpContext;
        }
Example #2
0
        /// <summary>Try to apply the special case.</summary>
        /// <param name="configuration">The configuration.</param>
        /// <param name="dependencies">The dependencies.</param>
        /// <param name="customParameters">The custom parameters.</param>
        /// <param name="fetch">The fetch.</param>
        /// <returns>True if applied, false otherwise.</returns>
        public bool TryApply(IViewConfiguration configuration, IDataAdapterDependencies dependencies, IDictionary <string, string> customParameters, Fetch fetch)
        {
            if (!this.IsApplicable(configuration))
            {
                return(false);
            }

            var contextLanguageInfo = dependencies.GetRequestContext()?.HttpContext?.GetContextLanguageInfo();

            if (contextLanguageInfo == null || !contextLanguageInfo.IsCrmMultiLanguageEnabled)
            {
                return(false);
            }

            var serviceContext       = dependencies.GetServiceContext();
            var provisionedLanguages = ContextLanguageInfo.GetProvisionedLanugages(serviceContext as IOrganizationService);

            if (!provisionedLanguages.Any())
            {
                return(false);
            }

            var languageCondition = new Condition
            {
                Attribute = "adx_systemlanguage",
                Operator  = ConditionOperator.In,
                Values    = provisionedLanguages.Cast <object>().ToArray()
            };

            var filter = new Filter {
                Conditions = new[] { languageCondition }
            };

            if (fetch.Entity.Filters == null)
            {
                fetch.Entity.Filters = new List <Filter> {
                    filter
                };
            }
            else
            {
                fetch.Entity.Filters.Add(filter);
            }

            return(true);
        }
Example #3
0
 /// <summary> Initializes a new instance of the <see cref="ContentMapDataAdapter"/> class. </summary>
 /// <param name="dependencies"> The dependencies. </param>
 protected ContentMapDataAdapter(IDataAdapterDependencies dependencies)
     : this(dependencies.GetRequestContext(), dependencies)
 {
 }