internal override void ProcessMappingsToRowValues(RowValues rowValues, bool excludeReadonlyData)
 {
     foreach (var pair in Values)
     {
         rowValues[pair.Key] = pair.Value;
     }
 }
 /// <summary>
 /// Read object data from a single row.                
 /// </summary>
 /// <example>
 /// SingleLineBulkEntity: reads entity fields.
 /// BulkError: reads error fields.
 /// BulkEntityIdentifier: reads identifier fields (Id, status etc.).
 /// </example>
 /// <param name="values"></param>
 internal virtual void ReadFromRowValues(RowValues values)
 {
     throw new NotSupportedException();
 }
 private void ReadFromRowValues(RowValues values)
 {
     values.ConvertToEntity(this, Mappings);
 }
        internal static QualityScoreData ReadFromRowValuesOrNull(RowValues values)
        {
            var qualityScoreData = new QualityScoreData();

            qualityScoreData.ReadFromRowValues(values);

            return qualityScoreData.HasAnyValues ? qualityScoreData : null;
        }
        internal override void ProcessMappingsFromRowValues(RowValues values)
        {
            SiteLink = new SiteLink();

            Identifier.ReadFromRowValues(values);

            values.ConvertToEntity(this, Mappings);
        }
        internal override void ProcessMappingsFromRowValues(RowValues values)
        {
            AdGroup = new AdGroup { AdDistribution = 0 };

            values.ConvertToEntity(this, Mappings);

            QualityScoreData = QualityScoreData.ReadFromRowValuesOrNull(values);

            PerformanceData = PerformanceData.ReadFromRowValuesOrNull(values);
        }
        internal override void ProcessMappingsToRowValues(RowValues values, bool excludeReadonlyData)
        {
            this.ConvertToValues(values, Mappings);

            if (!excludeReadonlyData)
            {
                PerformanceData.WriteToRowValuesIfNotNull(PerformanceData, values);
            }
        }
        internal override void ProcessMappingsFromRowValues(RowValues values)
        {
            ProductConditionCollection = new ProductConditionCollection
            {
                Conditions = new List<ProductCondition>()
            };

            Identifier.ReadFromRowValues(values);

            values.ConvertToEntity(this, Mappings);            
        }
        private static void BudgetToCsv(BulkCampaign c, RowValues values)
        {
            var budgetType = c.Campaign.BudgetType;

            if (budgetType == null)
            {
                return;
            }

            values[StringTable.Budget] =
                budgetType == BudgetLimitType.DailyBudgetAccelerated || budgetType == BudgetLimitType.DailyBudgetStandard ?
                    c.Campaign.DailyBudget.ToBulkString() :
                    c.Campaign.MonthlyBudget.ToBulkString();
        }
        private static void CsvToBudget(RowValues values, BulkCampaign c)
        {
            string budgetTypeRowValue;

            BudgetLimitType? budgetType;

            if (!values.TryGetValue(StringTable.BudgetType, out budgetTypeRowValue) || (budgetType = budgetTypeRowValue.ParseOptional<BudgetLimitType>()) == null)
            {
                return;
            }

            string budgetRowValue;
            
            if (!values.TryGetValue(StringTable.Budget, out budgetRowValue))
            {
                return;
            }

            var budgetValue = budgetRowValue.ParseOptional<double>();

            c.Campaign.BudgetType = budgetType;

            if (budgetType == BudgetLimitType.DailyBudgetAccelerated || budgetType == BudgetLimitType.DailyBudgetStandard)
            {
                c.Campaign.DailyBudget = budgetValue;
            }
            else
            {
                c.Campaign.MonthlyBudget = budgetValue;
            }
        }
        internal override void ProcessMappingsFromRowValues(RowValues values)
        {
            Campaign = new Campaign();

            values.ConvertToEntity(this, Mappings);

            QualityScoreData = QualityScoreData.ReadFromRowValuesOrNull(values);

            PerformanceData = PerformanceData.ReadFromRowValuesOrNull(values);            
        }
 internal static void WriteToRowValuesIfNotNull(PerformanceData performanceData, RowValues values)
 {
     if (performanceData != null)
     {
         performanceData.WriteToRowValues(values);
     }
 }
示例#13
0
 /// <summary>
 /// Writes object data to a single row.
 /// </summary>
 /// <example>
 /// SingleLineBulkEntity: writes entity fields.
 /// BulkEntityIdentifier: writes identifier fields (Id, status etc.)
 /// </example>
 /// <param name="values"></param>
 internal virtual void WriteToRowValues(RowValues values)
 {
     throw new NotSupportedException();
 }
示例#14
0
 internal override void ProcessMappingsToRowValues(RowValues values, bool excludeReadonlyData)
 {
     this.ConvertToValues(values, Mappings);
 }
        private static void RowValuesToConditions(RowValues values, BulkCampaignProductScope c)
        {
            var product = (ProductScope)c.CampaignCriterion.Criterion;

            product.Conditions = new List<ProductCondition>();

            ProductConditionHelper.AddConditionsFromRowValues(values, product.Conditions);
        }
示例#16
0
 /// <summary>
 /// Read object data from a single row.
 /// </summary>
 /// <example>
 /// SingleLineBulkEntity: reads entity fields.
 /// BulkError: reads error fields.
 /// BulkEntityIdentifier: reads identifier fields (Id, status etc.).
 /// </example>
 /// <param name="values"></param>
 internal virtual void ReadFromRowValues(RowValues values)
 {
     throw new NotSupportedException();
 }
        private static void ConditionsToRowValues(BulkCampaignProductScope c, RowValues values)
        {
            if (c.CampaignCriterion.Criterion == null)
            {
                return;
            }

            var product = (ProductScope)c.CampaignCriterion.Criterion;

            if (product.Conditions == null)
            {
                return;
            }

            ProductConditionHelper.AddRowValuesFromConditions(product.Conditions, values);
        }
        internal override void ProcessMappingsToRowValues(RowValues values, bool excludeReadonlyData)
        {
            ValidatePropertyNotNull(ProductConditionCollection, "ProductConditionCollection");

            ValidatePropertyNotNull(ProductConditionCollection.Conditions, "ProductConditionCollection.Conditions");

            Identifier.WriteToRowValues(values, excludeReadonlyData);                       

            this.ConvertToValues(values, Mappings);
        }
        internal override void ProcessMappingsToRowValues(RowValues values, bool excludeReadonlyData)
        {
            ValidatePropertyNotNull(CampaignCriterion, typeof(CampaignCriterion).Name);

            this.ConvertToValues(values, Mappings);
        }
        internal override void ProcessMappingsFromRowValues(RowValues values)
        {
            values.ConvertToEntity(this, Mappings);

            PerformanceData = PerformanceData.ReadFromRowValuesOrNull(values);
        }
        internal override void ProcessMappingsFromRowValues(RowValues values)
        {
            CampaignCriterion = new CampaignCriterion
            {
                Criterion = new ProductScope
                {
                    Type = typeof(ProductScope).Name,
                },
                Type = typeof(CampaignCriterion).Name,
            };

            values.ConvertToEntity(this, Mappings);
        }
示例#22
0
        internal override void ProcessMappingsToRowValues(RowValues values, bool excludeReadonlyData)
        {
            ValidatePropertyNotNull(AdGroup, "AdGroup");

            this.ConvertToValues(values, Mappings);

            if (!excludeReadonlyData)
            {
                QualityScoreData.WriteToRowValuesIfNotNull(QualityScoreData, values);

                PerformanceData.WriteToRowValuesIfNotNull(PerformanceData, values);
            }
        }
        internal override void ProcessMappingsToRowValues(RowValues values)
        {
            base.ProcessMappingsToRowValues(values);

            this.ConvertToValues(values, Mappings);
        }
        internal override void ProcessMappingsToRowValues(RowValues values, bool excludeReadonlyData)
        {
            ValidatePropertyNotNull(SiteLink, "SiteLink");
            
            Identifier.WriteToRowValues(values, excludeReadonlyData);

            this.ConvertToValues(values, Mappings);
        }
        public BulkObject CreateBulkObject(RowValues values)
        {
            string type;

            if (!values.TryGetValue(StringTable.Type, out type))
            {
                throw new InvalidOperationException(ErrorMessages.TypeColumnNotFound);
            }

            if (type.EndsWith("Error"))
            {
                return new BulkError();
            }

            Func<BulkObject> additionalObjectFunc;

            if (AdditionalObjectMap.TryGetValue(type, out additionalObjectFunc))
            {
                return additionalObjectFunc();
            }

            EntityInfo info;

            if (!IndividualEntityMap.TryGetValue(type, out info))
            {
                return new UnknownBulkEntity();
            }            

            if (values[StringTable.Status] == "Deleted" &&
                !string.IsNullOrEmpty(info.DeleteAllColumnName) &&
                string.IsNullOrEmpty(values[info.DeleteAllColumnName]))
            {
                return info.CreateIdentifierFunc();
            }

            return info.CreateFunc();
        }
 internal static void WriteToRowValuesIfNotNull(QualityScoreData qualityScoreData, RowValues values)
 {
     if (qualityScoreData != null)
     {
         qualityScoreData.WriteToRowValues(values);
     }
 }
示例#27
0
        public RowValues ReadNextRow()
        {
            if (_mappings == null)
            {
                _mappings = Headers.Select((i, h) => new { key = i, value = h }).ToDictionary(x => x.key, x => x.value);
            }

            if (!ReadNextRecord())
            {
                return null;
            }

            if (Columns == null)
            {
                return null;
            }

            var rowValues = new RowValues(Columns, _mappings);

            return rowValues;
        }
 private void WriteToRowValues(RowValues values)
 {
     this.ConvertToValues(values, Mappings);
 }
 private static void RowValuesToConditions(RowValues values, BulkProductConditionCollection c)
 {
     ProductConditionHelper.AddConditionsFromRowValues(values, c.ProductConditionCollection.Conditions);             
 }
示例#30
0
 /// <summary>
 /// Writes object data to a single row.        
 /// </summary>
 /// <example>
 /// SingleLineBulkEntity: writes entity fields.
 /// BulkEntityIdentifier: writes identifier fields (Id, status etc.)
 /// </example>
 /// <param name="values"></param>
 /// <param name="excludeReadonlyData"></param>
 internal virtual void WriteToRowValues(RowValues values, bool excludeReadonlyData)
 {
     throw new NotSupportedException();
 }
 private static void ConditionsToRowValues(BulkProductConditionCollection c, RowValues values)
 {
     ProductConditionHelper.AddRowValuesFromConditions(c.ProductConditionCollection.Conditions, values);
 }
示例#32
0
 internal override void ProcessMappingsFromRowValues(RowValues values)
 {
     values.ConvertToEntity(this, Mappings);
 }
示例#33
0
 internal override void ReadFromRowValues(RowValues values)
 {
     values.ConvertToEntity(this, Mappings);
 }