コード例 #1
0
        public static LocationContext ResolveLocationContext(DataProxyBase dataProxy, BaseView viewSettings, IDictionary<string, string> parameters)
        {
            int? locationId = null;
            string locationSiteUrl = null;

            // First look for location context in request parameters
            if (parameters != null && parameters.ContainsKey("LocationContext") && !string.IsNullOrEmpty(parameters["LocationContext"]))
                locationId = int.Parse(parameters["LocationContext"]);
            else
            {
                if (viewSettings != null)
                {
                    // Next look at module instance setting
                    var locationContextSetting = viewSettings.GetSettingValue("LocationContext", null);

                    if (!string.IsNullOrEmpty(locationContextSetting))
                        locationId = int.Parse(locationContextSetting);
                }
            }

            // Get full context using locationId or request URL
            //if (viewSettings != null && parameters != null)
            //{
            //	locationId = dataProxy.LocationContext.Id;
            //	locationSiteUrl = dataProxy.LocationContext.SiteUrl;
            //}
            //else
            //{
                var request = new ResolveOrgUnitContextRequest() { ItemUrl = ServiceContext.RequestReferrerUrl, OrgUnitId = locationId };
                var response = dataProxy.ProcessRequest<ResolveOrgUnitContextResponse>(request);

                locationId = response.OrgUnitId;
                locationSiteUrl = response.OrgUnitSiteUrl;
            //}

            return new LocationContext(locationId, locationSiteUrl);
        }
コード例 #2
0
 public static DescendantOption ResolveLocationDescendantOption(BaseView viewSettings, IDictionary<string, string> parameters)
 {
     if (parameters.ContainsKey("LocationDescendants") && !string.IsNullOrEmpty(parameters["LocationDescendants"]))
         return (bool.Parse(parameters["LocationDescendants"])) ? DescendantOption.IncludeDescendants : DescendantOption.NoDescendants;
     else
     {
         var locationDescendantsSetting = viewSettings.GetSettingValue("LocationDescendants", "true");
         return (bool.Parse(locationDescendantsSetting)) ? DescendantOption.IncludeDescendants : DescendantOption.NoDescendants;
     }
 }