protected virtual object GetServiceParameterValue(TransactionTrackingQueryParameter key)
        {
            object value = null;

            CollectionUtils.ForEachBreak(_serviceParameters, delegate(KeyValuePair <TransactionTrackingQueryParameter, object> pair)
            {
                if (pair.Key == key)
                {
                    value = pair.Value;
                    return(false);
                }
                return(true);
            });
            return(value);
        }
        public override IList <TypedParameter> GetDataServiceParameters(string serviceName, out DataServicePublishFlags publishFlags)
        {
            IList <TransactionTrackingQueryParameter> possibleParameters = new TransactionTrackingQueryParameter[] { TransactionTrackingQueryParameter.TransactionId };

            return(GetDataServiceParameters(serviceName, possibleParameters, out publishFlags));
        }
        protected virtual void GetServiceParameters()
        {
            Dictionary <TransactionTrackingQueryParameter, object> serviceParameters =
                new Dictionary <TransactionTrackingQueryParameter, object>();

            IList <TransactionTrackingQueryParameter> possibleParameters = EnumUtils.GetAllEnumValues <TransactionTrackingQueryParameter>();
            bool     transactionIdSpecified = false;
            DateTime fromDate = DateTime.MinValue, toDate = DateTime.MaxValue;

            for (int i = 0; i < possibleParameters.Count; ++i)
            {
                TransactionTrackingQueryParameter parameter = possibleParameters[i];
                object parameterValue = null;
                if (TryGetParameter(_dataRequest, possibleParameters[i].ToString(), i,
                                    ref parameterValue))
                {
                    switch (parameter)
                    {
                    case TransactionTrackingQueryParameter.fromDate:
                    case TransactionTrackingQueryParameter.toDate:
                    {
                        DateTime date;
                        if (!DateTime.TryParse(parameterValue.ToString(), out date))
                        {
                            throw new ArgumentException(string.Format("Failed to convert the \"{0}\" parameter value \"{1}\" to a valid date.",
                                                                      parameter.ToString(), parameterValue.ToString()));
                        }
                        parameterValue = date;
                        if (parameter == TransactionTrackingQueryParameter.fromDate)
                        {
                            fromDate = date;
                        }
                        else
                        {
                            toDate = date;
                        }
                    }
                    break;

                    case TransactionTrackingQueryParameter.Status:
                    {
                        CommonTransactionStatusCode status;
                        try
                        {
                            status = (CommonTransactionStatusCode)Enum.Parse(typeof(CommonTransactionStatusCode), parameterValue.ToString(), true);
                        }
                        catch (Exception)
                        {
                            throw new ArgumentException(string.Format("Failed to convert the \"{0}\" parameter value \"{1}\" to a valid status code.",
                                                                      parameter.ToString(), parameterValue.ToString()));
                        }
                        parameterValue = status;
                    }
                    break;

                    case TransactionTrackingQueryParameter.Type:
                    {
                        NodeMethod type;
                        try
                        {
                            type = (NodeMethod)Enum.Parse(typeof(NodeMethod), parameterValue.ToString(), true);
                        }
                        catch (Exception)
                        {
                            throw new ArgumentException(string.Format("Failed to convert the \"{0}\" parameter value \"{1}\" to a valid transaction type.",
                                                                      parameter.ToString(), parameterValue.ToString()));
                        }
                        parameterValue = type;
                    }
                    break;

                    case TransactionTrackingQueryParameter.TransactionId:
                        transactionIdSpecified = true;
                        goto case TransactionTrackingQueryParameter.Dataflow;

                    case TransactionTrackingQueryParameter.Dataflow:
                    case TransactionTrackingQueryParameter.Organization:
                    case TransactionTrackingQueryParameter.Recipients:
                    case TransactionTrackingQueryParameter.Userid:
                    {
                        string value = parameterValue.ToString().Trim();
                        parameterValue = string.IsNullOrEmpty(value) ? null : value;
                    }
                    break;

                    default:
                        parameterValue = null;      // Unrecognized
                        break;
                    }
                    if (parameterValue != null)
                    {
                        if (serviceParameters.ContainsKey(parameter))
                        {
                            throw new ArgumentException(string.Format("More than one instance of the parameter \"{0}\" was specified: \"{1}\" and \"{2}\".  Please remove the duplicated query parameters.",
                                                                      parameter.ToString(), serviceParameters[parameter].ToString(), parameterValue.ToString()));
                        }
                        serviceParameters[parameter] = parameterValue;
                    }
                }
            }
            if (serviceParameters.Count > 0)
            {
                if (transactionIdSpecified && (serviceParameters.Count > 1))
                {
                    throw new ArgumentException(string.Format("The \"{0}\" parameter must be the only query parameter specified.  Please remove the other query parameters.",
                                                              TransactionTrackingQueryParameter.TransactionId.ToString()));
                }
                if (fromDate >= toDate)
                {
                    throw new ArgumentException(string.Format("\"{0}\" must be before \"{1}\"", TransactionTrackingQueryParameter.fromDate.ToString(),
                                                              TransactionTrackingQueryParameter.toDate.ToString()));
                }
                StringBuilder sb = new StringBuilder("The following query parameters were passed to the service: ");
                _serviceParameters = new List <KeyValuePair <TransactionTrackingQueryParameter, object> >(serviceParameters.Count);
                bool first = true;
                foreach (KeyValuePair <TransactionTrackingQueryParameter, object> pair in serviceParameters)
                {
                    if (!first)
                    {
                        sb.Append(", ");
                    }
                    else
                    {
                        first = false;
                    }
                    sb.AppendFormat("{0} ({1})", pair.Key.ToString(), pair.Value.ToString());
                    _serviceParameters.Add(pair);
                }
                AppendAuditLogEvent(sb.ToString());
            }
            else
            {
                AppendAuditLogEvent("No query parameters were passed to the service.");
            }
        }