public override void Write(string token, ErrorInfo error)
 {
     if(string.IsNullOrWhiteSpace(token))
     {
         throw new ArgumentNullException("token");
     }
     if(error == null)
     {
         throw new ArgumentNullException("error");
     }
     try
     {
         var webClient = CreateWebClient();
         webClient.UploadStringCompleted += (s, e) =>
                                                {
                                                    if (e.Error != null)
                                                    {
                                                        this.Exception = e.Error;
                                                    }
                                                    OnCompleted(new WritterEventArgs(error));
                                                };
         string postData = CreatePostData(token, error);
         webClient.UploadStringAsync(RequestUri, "POST", postData, null);
     }
     catch (Exception exception)
     {
         Exception = exception;
         OnCompleted(new WritterEventArgs(error));
     }
 }
 public void LogException(ErrorInfo errorInfo)
 {
     if (errorInfo == null)
     {
         throw new ArgumentNullException("errorInfo");
     }
     Error error = ToError(errorInfo);
     LogInternal(error, null);
 }
 public string LogException(ErrorInfo errorInfo)
 {
     if (errorInfo == null)
     {
         throw new ArgumentNullException("errorInfo");
     }
     Error error = ToError(errorInfo);
     var errorId = LogInternal(error, null);
     return errorId;
 }
 public bool ValidateErrorInfo(ErrorInfo model)
 {
     bool valid = !string.IsNullOrWhiteSpace(model.ApplicationName);
     if(string.IsNullOrWhiteSpace(model.Host))
     {
         valid = false;
     }
     if (string.IsNullOrWhiteSpace(model.Message))
     {
         valid = false;
     }
     if (string.IsNullOrWhiteSpace(model.Detail))
     {
         valid = false;
     }
     return valid;
 }
        public static Error ToError(ErrorInfo errorInfo)
        {
            var error = new Error
            {
                ApplicationName = errorInfo.ApplicationName,
                HostName = errorInfo.Host,
                Type = errorInfo.ErrorType,
                Source = errorInfo.Source,
                Message = errorInfo.Message,
                Detail = errorInfo.BuildMessage(),
                Time = errorInfo.Date,
                User = errorInfo.User,
                StatusCode = errorInfo.StatusCode
            };

            CopyToCollections(errorInfo, error.Cookies, "Cookies");
            CopyToCollections(errorInfo, error.Form, "Form");
            CopyToCollections(errorInfo, error.QueryString, "QueryString");
            CopyToCollections(errorInfo, error.ServerVariables, "ServerVariables");

            return error;
        }
 public override void Write(string token, ErrorInfo errorInfo)
 {
     if(string.IsNullOrWhiteSpace(token))
     {
         throw new ArgumentNullException("token");
     }
     if (errorInfo == null)
     {
         throw new ArgumentNullException("errorInfo");
     }
     try
     {
         WriteInternal(CreatePostData(token, errorInfo));
     }
     catch (Exception exception)
     {
         Exception = exception;
     }
     finally
     {
         OnCompleted(new WritterEventArgs(errorInfo));
     }
 }
 protected abstract string CreatePostData(string token, ErrorInfo info);
 private static void CopyToCollections(ErrorInfo errorInfo, NameValueCollection collection, string collectionName)
 {
     var detail = errorInfo.ErrorDetails.SingleOrDefault(x => x.Name == collectionName);
     if(detail != null)
     {
         foreach (var pair in detail.Items)
         {
             collection.Add(pair.Key, pair.Value);
         }
     }
 }
 protected override string CreatePostData(string token, ErrorInfo info)
 {
     string xml = Utility.SerializeXml(info);
     string error = Convert.ToBase64String(Encoding.UTF8.GetBytes(xml));
     return FormData(new { token, error }, HttpUtility.UrlEncode);
 }
 public bool ValidateErrorInfo(ErrorInfo model)
 {
     // TODO: For now we dont validate these details
     return true;
 }
 public abstract void Write(string token, ErrorInfo errorInfo);