Пример #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 LocationContext ResolveLocationContext(ConvertServiceRequest request)
        {
            if (request.Parameters.ContainsKey("LocationId") && !string.IsNullOrEmpty(request.Parameters["LocationId"]))
            {
                var locationId = int.Parse(request.Parameters["LocationId"]);

                if (locationId > 0)
                {
                    var contextRequest = new ResolveOrgUnitContextRequest() { ItemUrl = ServiceContext.RequestReferrerUrl, OrgUnitId = locationId };
                    var contextResponse = ProcessRequest<ResolveOrgUnitContextResponse>(contextRequest);

                    return new LocationContext(contextResponse.OrgUnitId, contextResponse.OrgUnitSiteUrl);
                }
            }

            return new LocationContext(null, null);
        }
 /// <summary>
 /// Determines whether the specified <see cref="ResolveOrgUnitContextRequest" /> is equal to this instance.
 /// </summary>
 /// <param name="other">The other.</param>
 /// <returns></returns>
 public bool Equals(ResolveOrgUnitContextRequest other)
 {
     return base.Equals(other) && ItemId == other.ItemId && string.Equals(ItemUrl, other.ItemUrl) && OrgUnitId == other.OrgUnitId;
 }