//This method is for getting the list of destinations
        public async Task <List <Destination> > GetDestinations()
        {
            List <Destination> Destinations = new List <Destination>();

            try
            {
                var sitecoreItems = await _sitecoreHelper.GetItemByPath(
                    Constants.ConstantPath.RepositoryPath,
                    Sitecore.MobileSDK.API.Request.Parameters.PayloadType.Full,
                    new List <Sitecore.MobileSDK.API.Request.Parameters.ScopeType> {
                    Sitecore.MobileSDK.API.Request.Parameters.ScopeType.Children
                });

                if (sitecoreItems != null)
                {
                    foreach (var item in sitecoreItems)
                    {
                        var Dstn = new Destination
                        {
                            SitecoreID = item.Id,
                            Name       = item.GetValueFromField(Constants.Templates.Destination.Fields.DestinationName),
                            Thumbnail  = item.GetImageUrlFromMediaField(Constants.Templates.Destination.Fields.Thumbnail, Constants.Settings.ResetBaseUrl)
                        };
                        Destinations.Add(Dstn);
                    }
                }
            }
            catch (Exception ex)
            {
                Log.Error("Error in GetDestinations(),  Error: {0}", ex.Message);
                throw ex;
            }
            return(Destinations);
        }
Exemplo n.º 2
0
        //In this method we are tracking the user and collecting the data in Universal tracker DB. After collection data is processed
        //using processing service and push to xDB
        public async Task <TrackerSettings> GetTrackerSettings()
        {
            string trackerSettingsFullPath = string.Empty;
            string query = string.Empty;

            query = Constants.Settings.TrackerItemPath;

            TrackerSettings ts = new TrackerSettings();

            var trackerSettingsItemPath = await _sitecoreHelper.GetItemByPath(query, Sitecore.MobileSDK.API.Request.Parameters.PayloadType.Full,
                                                                              new List <Sitecore.MobileSDK.API.Request.Parameters.ScopeType> {
                Sitecore.MobileSDK.API.Request.Parameters.ScopeType.Self
            });

            if (trackerSettingsItemPath != null)
            {
                ts.ServiceURL = trackerSettingsItemPath[0].GetValueFromField(Templates.TrackerSettings.Fields.ServiceURL);
                ts.ChannelID  = trackerSettingsItemPath[0].GetValueFromField(Templates.TrackerSettings.Fields.Channel);
                ts.Event      = trackerSettingsItemPath[0].GetValueFromField(Templates.TrackerSettings.Fields.Event);
                ts.Goals      = trackerSettingsItemPath[0].GetValueFromField(Templates.TrackerSettings.Fields.Goal);
                if (trackerSettingsItemPath[0].GetValueFromField(Templates.TrackerSettings.Fields.IsTrackingActive).Equals("1"))
                {
                    ts.IsTrackingActive = true;
                }
                else
                {
                    ts.IsTrackingActive = false;
                }
            }
            return(ts);
        }