Пример #1
0
        private GoalProperty <string> CreateCustomEventGoalProperty(string propertyName, string value, byte?comparisonOperatorByte)
        {
            GoalProperty <string> eventCategoryProperty = null;
            var valueColumnName    = String.Format("Event{0}", propertyName);
            var operatorColumnName = String.Format("{0}ComparisonOperator", propertyName);

            if (value != null)
            {
                if (comparisonOperatorByte == null)
                {
                    throw new Exception(String.Format("{0} value cannot be null when {1} value is not null.", operatorColumnName, valueColumnName));
                }

                if (!GoalUtils.IsValidComparisonOperator((byte)comparisonOperatorByte))
                {
                    throw new Exception(String.Format("{0} value {1} is outside of range.", operatorColumnName, comparisonOperatorByte));
                }

                var comparisonOperator = (GoalComparisonOperator)comparisonOperatorByte;

                if (!GoalUtils.IsValidStringOperator(comparisonOperator))
                {
                    throw new Exception(String.Format("Comparison operator value {0} is not supported by {1} goal type.", comparisonOperator.ToString(), GoalType));
                }

                eventCategoryProperty = new GoalProperty <string>
                {
                    ComparisonOperator = comparisonOperator,
                    PropertyValue      = value.Trim()
                };
            }
            return(eventCategoryProperty);
        }
Пример #2
0
        public TagToGoalRecordDestinationUrl(IReadOnlyDictionary <string, int> columnMetadata, IList <object> row)
            : base(columnMetadata, row)
        {
            GoalType = GoalType.DestinationUrl;

            if (_destinationUrlOrdinal == -1)
            {
                _destinationUrlOrdinal = MapFileUtils.GetColumnOrdinal(columnMetadata, "DestinationURL");
            }

            if (_comparisonOperatorOrdinal == -1)
            {
                _comparisonOperatorOrdinal = MapFileUtils.GetColumnOrdinal(columnMetadata, "DestinationURLOperator");
            }

            var destinationUrl         = (string)row[_destinationUrlOrdinal];
            var comparisonOperatorByte = (byte)row[_comparisonOperatorOrdinal];

            if (!GoalUtils.IsValidComparisonOperator(comparisonOperatorByte))
            {
                throw new Exception(String.Format("DestinationUrl comparison operator value {0} is outside of range.", comparisonOperatorByte));
            }

            var comparisonOperator = (GoalComparisonOperator)comparisonOperatorByte;

            if (!GoalUtils.IsValidStringOperator(comparisonOperator))
            {
                throw new Exception(String.Format("Comparison operator value {0} is not supported by {1} goal type.", comparisonOperator.ToString(), GoalType));
            }

            DestinationUrlProperty = new GoalProperty <string>
            {
                ComparisonOperator = comparisonOperator,
                PropertyValue      = destinationUrl.Trim()
            };
        }