/// <summary>
 /// Records API operation count for a user.
 /// </summary>
 /// <param name="user">The AdWords user who made the call.</param>
 /// <param name="service">The AdWords API service that was called.</param>
 /// <param name="methodName">The name of the method that was called.</param>
 /// <param name="operationCount">The number of API operations for the
 /// current call.</param>
 private static void RecordApiOperationCount(AdWordsUser user, AdsClient service,
     string methodName, int operationCount) {
   if (user != null) {
     ApiCallEntry entry = new ApiCallEntry();
     entry.Service = service;
     entry.Method = methodName;
     entry.OperationCount = operationCount;
     user.AddCallDetails(entry);
   }
 }
Example #2
0
 /// <summary>
 /// Records API operation count for a user.
 /// </summary>
 /// <param name="user">The AdWords user who made the call.</param>
 /// <param name="service">The AdWords API service that was called.</param>
 /// <param name="methodName">The name of the method that was called.</param>
 /// <param name="operationCount">The number of API operations for the
 /// current call.</param>
 private static void RecordApiOperationCount(AdWordsUser user, AdsClient service,
                                             string methodName, int operationCount)
 {
     if (user != null)
     {
         ApiCallEntry entry = new ApiCallEntry();
         entry.Service        = service;
         entry.Method         = methodName;
         entry.OperationCount = operationCount;
         user.AddCallDetails(entry);
     }
 }
Example #3
0
        /// <summary>
        /// Performs any operations after receiving the SOAP response.
        /// </summary>
        /// <param name="reply">The message to be transformed into types
        /// and handed back to the client application.</param>
        /// <param name="correlationState">Correlation state data returned by BeforeSendRequest</param>
        public void AfterReceiveReply(ref Message reply, object correlationState)
        {
            if (reply.Headers.Count > 0)
            {
                XmlReader reader = reply.Headers.GetReaderAtHeader(0);
                ResponseHeader = ResponseHeader.ReadFrom(reader, RequestHeader.Namespace);

                ApiCallEntry entry = new ApiCallEntry()
                {
                    OperationCount = (int)ResponseHeader.operations,
                    Method         = ResponseHeader.methodName,
                    Service        = ResponseHeader.serviceName
                };

                this.User.AddCallDetails(entry);
            }
            AdsFeatureUsageRegistry.Instance.Clear();
        }
Example #4
0
        /// <summary>
        /// Performs any operations after receiving the SOAP response.
        /// </summary>
        /// <param name="reply">The message to be transformed into types
        /// and handed back to the client application.</param>
        /// <param name="correlationState">Correlation state data returned by BeforeSendRequest</param>
        public void AfterReceiveReply(ref Message reply, object correlationState)
        {
            if (reply.Headers.Count > 0)
            {
                // DataContract is strict with namespacing. Change the namespace to be the same
                // as the DataContract attribute.
                XmlReader reader     = reply.Headers.GetReaderAtHeader(0);
                String    ns         = reader.NamespaceURI;
                String    headerText = reader.ReadOuterXml();
                headerText = headerText.Replace(ns, ResponseHeader.PLACEHOLDER_NAMESPACE);
                XmlObjectSerializer ser = new DataContractSerializer(typeof(ResponseHeader));

                ApiCallEntry entry = new ApiCallEntry();
                using (MemoryStream stream = new MemoryStream(Encoding.UTF8.GetBytes(headerText))) {
                    ResponseHeader       = (ResponseHeader)ser.ReadObject(stream);
                    entry.OperationCount = (int)ResponseHeader.operations;
                    entry.Method         = ResponseHeader.methodName;
                    entry.Service        = ResponseHeader.serviceName;
                }

                this.User.AddCallDetails(entry);
            }
            AdsFeatureUsageRegistry.Instance.Clear();
        }
 public void AddCallDetails(ApiCallEntry apiCall)
 {
     apiCalls.Add(apiCall);
 }
 public void AddCallDetails(ApiCallEntry apiCall) {
   apiCalls.Add(apiCall);
 }