internal override void WriteToStream(IBulkObjectWriter rowWriter, bool excludeReadonlyData) { // If the sub-target (for example BulkAgeTarget) is being written as part of BulkTarget, // AgeTarget may be null, which means no Age bids should be written. // Otherwise, if BulkAgeTarget is written individually, AgeTarget must be set. // Also, if target is being deleted, don't require SubTarget API properties to be set if (!IsBeingWrittenAsPartOfParentTarget && Status != V10.Bulk.Entities.Status.Deleted) { ValidatePropertiesNotNull(); } // In any case, for non-empty targets Bids list need to be validated. API doesn't allow passing null or empty list of bids, so shouldn't SDK ValidateBidsNotNullOrEmpty(); var identifier = CreateBid().Identifier; identifier.Status = V10.Bulk.Entities.Status.Deleted; identifier.TargetId = TargetId; identifier.EntityId = EntityId; identifier.EntityName = EntityName; identifier.ParentEntityName = ParentEntityName; identifier.WriteToStream(rowWriter, excludeReadonlyData); if (Status == V10.Bulk.Entities.Status.Deleted) { return; } foreach (var subTarget in ConvertApiToBulkBids()) { subTarget.WriteToStream(rowWriter, excludeReadonlyData); } }
internal override void WriteToStream(IBulkObjectWriter rowWriter, bool excludeReadonlyData) { ValidatePropertyNotNull(SiteLinksAdExtension, "SiteLinksAdExtension"); if (SiteLinksAdExtension.Status != AdExtensionStatus.Deleted) { ValidateListNotNullOrEmpty(SiteLinksAdExtension.SiteLinks, "SiteLinksAdExtension.SiteLinks"); } if (SiteLinksAdExtension.Id == null) { throw new InvalidOperationException(ErrorMessages.SiteLinkAdExtensionIdMustBeSet); } rowWriter.WriteObjectRow(new SiteLinkAdExtensionIdentifier { Status = AdExtensionStatus.Deleted, AccountId = AccountId, AdExtensionId = SiteLinksAdExtension.Id }, excludeReadonlyData); if (SiteLinksAdExtension.Status == AdExtensionStatus.Deleted) { return; } foreach (var bulkSiteLink in ConvertRawToBulkSiteLinks()) { bulkSiteLink.WriteToStream(rowWriter, excludeReadonlyData); } }
private void WriteErrors(IBulkObjectWriter writer) { if (HasErrors) { foreach (var bulkError in Errors) { writer.WriteObjectRow(bulkError); } } }
/// <summary> /// Writes entity data to bulk file /// </summary> /// <param name="rowWriter">Writer object, allowing to write consecutive bulk rows</param> /// <param name="excludeReadonlyData"></param> internal override void WriteToStream(IBulkObjectWriter rowWriter, bool excludeReadonlyData) { rowWriter.WriteObjectRow(this, excludeReadonlyData); if (!excludeReadonlyData) { WriteAdditionalData(rowWriter); WriteErrors(rowWriter); } }
/// <summary> /// Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources. /// </summary> /// <param name="disposing">Disposes of the object writer if set to true.</param> /// <remarks>You should use this method before you upload the file written with <see cref="BulkFileWriter"/>.</remarks> protected virtual void Dispose(bool disposing) { if (disposing) { if (_bulkObjectWriter != null) { _bulkObjectWriter.Dispose(); _bulkObjectWriter = null; } } }
internal override void WriteToStream(IBulkObjectWriter rowWriter, bool excludeReadonlyData) { if (Status != Microsoft.BingAds.V10.Bulk.Entities.Status.Deleted) { ValidatePropertyNotNull(Target, "Target"); } if (Target != null) { if (Target.Location == null && Target.Age == null && Target.Gender == null && Target.DayTime == null && Target.DeviceOS == null && Target.Location == null) { throw new InvalidOperationException(ErrorMessages.AtLeastOneSubTargetMustNotBeNull); } } if (Target != null) { LocationTarget.Location = Target.Location; AgeTarget.AgeTarget = Target.Age; GenderTarget.GenderTarget = Target.Gender; DayTimeTarget.DayTimeTarget = Target.DayTime; DeviceOsTarget.DeviceOsTarget = Target.DeviceOS; NegativeLocationTarget.Location = Target.Location; RadiusTarget.Location = Target.Location; } SetDefaultIdentifier(LocationTarget); SetDefaultIdentifier(AgeTarget); SetDefaultIdentifier(GenderTarget); SetDefaultIdentifier(DayTimeTarget); SetDefaultIdentifier(DeviceOsTarget); SetDefaultIdentifier(NegativeLocationTarget); SetDefaultIdentifier(RadiusTarget); LocationTarget.IsBeingWrittenAsPartOfParentTarget = true; AgeTarget.IsBeingWrittenAsPartOfParentTarget = true; GenderTarget.IsBeingWrittenAsPartOfParentTarget = true; DayTimeTarget.IsBeingWrittenAsPartOfParentTarget = true; DeviceOsTarget.IsBeingWrittenAsPartOfParentTarget = true; NegativeLocationTarget.IsBeingWrittenAsPartOfParentTarget = true; RadiusTarget.IsBeingWrittenAsPartOfParentTarget = true; foreach (var childEntity in SubTargets) { childEntity.WriteToStream(rowWriter, excludeReadonlyData); } }
internal override void WriteAdditionalData(IBulkObjectWriter writer) { if (BidSuggestions != null) { if (BidSuggestions.BestPosition != null) { writer.WriteObjectRow(BidSuggestions.BestPosition); } if (BidSuggestions.MainLine != null) { writer.WriteObjectRow(BidSuggestions.MainLine); } if (BidSuggestions.FirstPage != null) { writer.WriteObjectRow(BidSuggestions.FirstPage); } } }
internal override void WriteToStream(IBulkObjectWriter rowWriter) { ValidatePropertyNotNull(ProductAdExtension, "ProductAdExtension"); ValidatePropertyNotNull(ProductAdExtension.ProductSelection, "ProductAdExtension.ProductSelection"); rowWriter.WriteObjectRow(new BulkProductAdExtensionIdentifier { Status = AdExtensionStatus.Deleted, AccountId = AccountId, AdExtensionId = ProductAdExtension.Id, Name = ProductAdExtension.Name, Version = ProductAdExtension.Version }); foreach (var bulkSiteLink in ConvertRawToBulkProductConditionCollections()) { bulkSiteLink.WriteToStream(rowWriter); } }
internal override void WriteToStream(IBulkObjectWriter streamWriter, bool excludeReadonlyData) { ValidatePropertiesNotNull(); var deleteRow = CreateIdentifier(); deleteRow.Status = BingAds.Bulk.Entities.Status.Deleted; streamWriter.WriteObjectRow(deleteRow, excludeReadonlyData); if (Status == BingAds.Bulk.Entities.Status.Deleted) { return; } foreach (var site in ConvertApiToBulkNegativeSites()) { site.WriteToStream(streamWriter, excludeReadonlyData); } }
/// <summary> /// Writes object data to consecutive rows. /// </summary> /// <example> /// SingleLineBulkEntity: writes entity. /// MultilineBulkEntity: writes child entities. /// BulkEntityIdentifier: writes identifier information (Id, status etc.) /// </example> /// <param name="rowWriter"></param> /// <param name="excludeReadonlyData"></param> internal virtual void WriteToStream(IBulkObjectWriter rowWriter, bool excludeReadonlyData) { throw new NotSupportedException(); }
/// <summary> /// For unit tests /// </summary> internal BulkFileWriter(IBulkObjectWriter bulkObjectWriter) { _bulkObjectWriter = bulkObjectWriter; _bulkObjectWriter.WriteFileMetadata(); }
/// <summary> /// Writes entity data to bulk file /// </summary> /// <param name="rowWriter">Writer object, allowing to write consecutive bulk rows</param> internal override void WriteToStream(IBulkObjectWriter rowWriter) { rowWriter.WriteObjectRow(this); }
/// <summary> /// Writes object data to consecutive rows. /// </summary> /// <example> /// SingleLineBulkEntity: writes entity. /// MultilineBulkEntity: writes child entities. /// BulkEntityIdentifier: writes identifier information (Id, status etc.) /// </example> /// <param name="rowWriter"></param> internal virtual void WriteToStream(IBulkObjectWriter rowWriter) { throw new NotSupportedException(); }
internal override void WriteToStream(IBulkObjectWriter rowWriter, bool excludeReadonlyData) { rowWriter.WriteObjectRow(this, excludeReadonlyData); }
internal virtual void WriteAdditionalData(IBulkObjectWriter writer) { }
internal override void WriteToStream(IBulkObjectWriter rowWriter, bool excludeReadonlyData) { ValidatePropertyNotNull(ProductAdExtension, "ProductAdExtension"); ValidatePropertyNotNull(ProductAdExtension.ProductSelection, "ProductAdExtension.ProductSelection"); rowWriter.WriteObjectRow(new BulkProductAdExtensionIdentifier { Status = AdExtensionStatus.Deleted, AccountId = AccountId, AdExtensionId = ProductAdExtension.Id, Name = ProductAdExtension.Name, Version = ProductAdExtension.Version }, excludeReadonlyData); foreach (var bulkSiteLink in ConvertRawToBulkProductConditionCollections()) { bulkSiteLink.WriteToStream(rowWriter, excludeReadonlyData); } }