public static void SubmitLeadData(BrightWhistleLead lead, int? locationContextId, DataProxyBase dataProxy)
 {
     if (lead.IsValid())
     {
         try
         {
             var request = new SubmitLeadDataRequest { LeadData = lead, OrgUnitContextId = locationContextId };
             dataProxy.ProcessRequest<SubmitLeadDataResponse>(request);
         }
         catch (BusinessException ex)
         {
             ServiceContext.Logger.Error("Lead Management Submission Error", ex);
         }
     }
 }
        public static List<KeyValuePair<object, object>> GetLocationContextOptions(DataProxyBase dataProxy)
        {
            var request = new ListOrgUnitAssociationsRequest() { SecondaryIsSite = true, IsEnabled = true, PageSize = -1, SortField = "SecondaryPath", SortDirection = "Ascending" };
            var response = dataProxy.ProcessRequest<ListOrgUnitAssociationsResponse>(request);

            var locations = new List<KeyValuePair<object, object>>();

            locations.Add(new KeyValuePair<object, object>(0, "- Automatic -"));

            foreach (var association in response.OrgUnitAssociations)
            {
                locations.Add(new KeyValuePair<object, object>(association.SecondaryId.Value, association.SecondaryPath));
            }

            return locations;
        }
        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);
        }
 public static BrightWhistleSettings ReadSettings(DataProxyBase dataProxy)
 {
     var response = dataProxy.ProcessRequest<ReadBrightWhistleSettingsResponse>(new ReadBrightWhistleSettingsRequest());
     return response.Settings;
 }
 public DigitalAssetManager(DataProxyBase dataProxy)
 {
     _dataProxy = dataProxy;
     _settings = dataProxy.ProcessRequest<ReadCmsIntegrationSettingsResponse>(new ReadCmsIntegrationSettingsRequest()).Settings;
     _cmsType = ResolveAssetManagerType();
 }
        private string ResolveProviderIdFromDirectUrl(DataProxyBase dataProxy, string directUrl)
        {
            var request = new ReadProviderIdByDirectUrlRequest { DirectUrl = directUrl };
            var providerId = dataProxy.ProcessRequest<ReadProviderIdByDirectUrlResponse>(request).ProviderId;

            return CommonUtils.JsonSerialize(providerId);
        }
        private string ResolveEventIdFromDirectUrl(DataProxyBase dataProxy, string directUrl)
        {
            var request = new GetEventIdRequest { DirectUrl = directUrl };
            var eventId = dataProxy.ProcessRequest<GetEventIdResponse>(request).Id;

            return CommonUtils.JsonSerialize(eventId);
        }