Пример #1
0
        private void SetLocationProperty(Action <LocationTarget2> setAction)
        {
            if (Location == null)
            {
                Location = new LocationTarget2();
            }

            setAction(Location);
        }
Пример #2
0
        internal override void ReadRelatedDataFromStream(IBulkStreamReader reader)
        {
            var hasMoreRows = true;

            while (hasMoreRows)
            {
                BulkTargetBid bidRow;

                TIdentifier identifierRow;

                if (reader.TryRead(x => x.Identifier.EntityId == EntityId, out bidRow))
                {
                    _bids.Add(bidRow);
                }
                else if (reader.TryRead(x => x.EntityId == EntityId && x.IsDeleteRow, out identifierRow))
                {
                    _deleteAllRows.Add(identifierRow);
                }
                else
                {
                    hasMoreRows = false;
                }

                // Delta download sends delete-all rows first, which don't have targetId. Have to look at all rows and set first non-null Id.
                if (Target.Id == null && bidRow != null && bidRow.TargetId != null)
                {
                    Target.Id = bidRow.TargetId;
                }
            }

            Status = _bids.Count > 0 ? BingAds.Bulk.Entities.Status.Active : BingAds.Bulk.Entities.Status.Deleted;

            var bidGroups = _bids.GroupBy(r => r.GetType()).ToDictionary(x => x.Key, x => x.ToList());

            var location = new LocationTarget2();

            LocationTarget.Location         = location;
            NegativeLocationTarget.Location = location;
            RadiusTarget.Location           = location;

            PopulateChildTargetBids(LocationTarget, bidGroups);
            PopulateChildTargetBids(AgeTarget, bidGroups);
            PopulateChildTargetBids(GenderTarget, bidGroups);
            PopulateChildTargetBids(DayTimeTarget, bidGroups);
            PopulateChildTargetBids(DeviceOsTarget, bidGroups);
            PopulateChildTargetBids(NegativeLocationTarget, bidGroups);
            PopulateChildTargetBids(RadiusTarget, bidGroups);

            var deleteAllGroups = _deleteAllRows.GroupBy(r => r.TargetBidType).ToDictionary(x => x.Key, x => x.ToList());

            PopulateChildTargetIdentities(LocationTarget, deleteAllGroups);
            PopulateChildTargetIdentities(AgeTarget, deleteAllGroups);
            PopulateChildTargetIdentities(GenderTarget, deleteAllGroups);
            PopulateChildTargetIdentities(DayTimeTarget, deleteAllGroups);
            PopulateChildTargetIdentities(DeviceOsTarget, deleteAllGroups);
            PopulateChildTargetIdentities(NegativeLocationTarget, deleteAllGroups);
            PopulateChildTargetIdentities(RadiusTarget, deleteAllGroups);

            if (new object[] { location.CityTarget, location.MetroAreaTarget, location.StateTarget, location.CountryTarget, location.PostalCodeTarget, location.RadiusTarget }.Any(x => x != null))
            {
                Target.Location = location;
            }

            Target.Age      = AgeTarget.AgeTarget;
            Target.Gender   = GenderTarget.GenderTarget;
            Target.DayTime  = DayTimeTarget.DayTimeTarget;
            Target.DeviceOS = DeviceOsTarget.DeviceOsTarget;
        }
Пример #3
0
 /// <summary>
 /// Outputs the LocationTarget2.
 /// </summary>
 protected void OutputLocationTarget2(LocationTarget2 locationTarget)
 {
     if (locationTarget != null)
     {
         OutputStatusMessage(string.Format("IntentOption: {0}", locationTarget.IntentOption));
         if (locationTarget.CityTarget != null)
         {
             foreach (var bid in locationTarget.CityTarget.Bids)
             {
                 OutputCityTargetBid(bid);
             }
         }
         if (locationTarget.CountryTarget != null)
         {
             foreach (var bid in locationTarget.CountryTarget.Bids)
             {
                 OutputCountryTargetBid(bid);
             }
         }
         if (locationTarget.MetroAreaTarget != null)
         {
             foreach (var bid in locationTarget.MetroAreaTarget.Bids)
             {
                 OutputMetroAreaTargetBid(bid);
             }
         }
         if (locationTarget.PostalCodeTarget != null)
         {
             foreach (var bid in locationTarget.PostalCodeTarget.Bids)
             {
                 OutputPostalCodeTargetBid(bid);
             }
         }
         if (locationTarget.RadiusTarget != null)
         {
             foreach (var bid in locationTarget.RadiusTarget.Bids)
             {
                 OutputRadiusTargetBid2(bid);
             }
         }
         if (locationTarget.StateTarget != null)
         {
             foreach (var bid in locationTarget.StateTarget.Bids)
             {
                 OutputStateTargetBid(bid);
             }
         }
     }
 }