Ejemplo n.º 1
0
        public void ProcessRequest(HttpContext context)
        {
            context.Response.ContentType = "text/xml";
            int id = ValueTypeParser.Parse(context.Request.QueryString["id"], -1);
            string result = null;
            if (id > -1 && string.Compare(context.Request.QueryString["t"], "request", true) == 0)
            {
                result = new TripsErrorManager().GetRequestXml(id);
            }
            else if (id > -1 && string.Compare(context.Request.QueryString["t"], "response", true) == 0)
            {
                result = new TripsErrorManager().GetResponseXml(id);
            }

            if (string.IsNullOrWhiteSpace(result) == false)
            {
                try
                {
                    XElement.Parse(result);
                }
                catch (Exception)
                {
                    context.Response.ContentType = "text/plain";
                }

                context.Response.Write(result);
                context.Response.Flush();
                context.Response.End();
            }
        }
Ejemplo n.º 2
0
        public string GetExceptions()
        {
            try
            {
                NameValueCollection form = HttpContext.Current.Request.Form;
                int pageIndex = ValueTypeParser.Parse(form["page"], 1);
                int pageSize = ValueTypeParser.Parse(form["rp"], 10);
                //string qtype = form["qtype"];
                string query = form["query"];
                //string sortname = form["sortname"];
                //string sortorder = form["sortorder"];
                //string action = form["action"].Trim();

                int totalRowCount;
                int? exceptionId = null;
                string machineName = null;
                string source = null;
                string targetSite = null;
                string exceptionType = null;
                string appDomainName = null;
                string message = null;
                string sessionid = null;
                DateTime? timestampFrom = null;
                DateTime? timestampTo = null;
                string searchText = null;

                if (!string.IsNullOrEmpty(query))
                {
                    NameValueCollection col = ConvertToCollection(query);
                    Array.ForEach(col.AllKeys, o =>
                                                   {
                                                       switch (o.ToLower())
                                                       {
                                                           case "id":
                                                               if (!string.IsNullOrEmpty(col[o]))
                                                               {
                                                                   try
                                                                   {
                                                                       exceptionId = !string.IsNullOrEmpty(col[o])
                                                                                         ? (int?)int.Parse(col[o])
                                                                                         : null;
                                                                   }
                                                                   catch (Exception)
                                                                   {
                                                                       exceptionId = null;
                                                                   }
                                                               }
                                                               break;
                                                           case "machinename":
                                                               if (!string.IsNullOrEmpty(col[o]))
                                                                   machineName = col[o];
                                                               break;
                                                           case "source":
                                                               if (!string.IsNullOrEmpty(col[o]))
                                                                   source = col[o];
                                                               break;
                                                           case "targetsite":
                                                               if (!string.IsNullOrEmpty(col[o]))
                                                                   targetSite = col[o];
                                                               break;
                                                           case "exceptiontype":
                                                               if (!string.IsNullOrEmpty(col[o]))
                                                                   exceptionType = col[o];
                                                               break;
                                                           case "appdomainname":
                                                               if (!string.IsNullOrEmpty(col[o]))
                                                                   appDomainName = col[o];
                                                               break;
                                                           case "message":
                                                               message = col[o];
                                                               break;
                                                           case "timestampf":
                                                               {
                                                                   timestampFrom = ValueTypeParser.Parse(col[o], null, null);
                                                               }
                                                               break;
                                                           case "timestampt":
                                                               {
                                                                   timestampTo = ValueTypeParser.Parse(col[o], null, null);
                                                                   if (timestampTo != null)
                                                                       timestampTo = timestampTo.Value.AddDays(1);
                                                               }
                                                               break;
                                                           case "sessionid":
                                                               {
                                                                   sessionid = col[o];
                                                               }
                                                               break;
                                                           case "searchtext":
                                                               if (!string.IsNullOrEmpty(col[o]))
                                                                   searchText = col[o];
                                                               break;
                                                       }
                                                   });

                    if (timestampFrom == null || timestampTo == null)
                    {
                        timestampFrom = timestampTo = null;
                    }
                    else
                    {
                        int iCnt = DateTime.Compare(timestampFrom.Value, timestampTo.Value);
                        if (iCnt > 0)
                        {
                            DateTime dt = timestampTo.Value;
                            timestampTo = timestampFrom.Value;
                            timestampFrom = dt;
                        }
                    }
                }

                machineName = string.IsNullOrEmpty(machineName) ? null : machineName;
                source = string.IsNullOrEmpty(source) ? null : source;
                targetSite = string.IsNullOrEmpty(targetSite) ? null : targetSite;
                exceptionType = string.IsNullOrEmpty(exceptionType) ? null : exceptionType;
                appDomainName = string.IsNullOrEmpty(appDomainName) ? null : appDomainName;
                message = string.IsNullOrEmpty(message) ? null : message;
                searchText = string.IsNullOrEmpty(searchText) ? null : searchText;
                sessionid = string.IsNullOrEmpty(sessionid) ? null : sessionid;
                var manager = new TripsErrorManager();
                return manager.GetExceptions(exceptionId, machineName, source, targetSite,
                                             exceptionType, appDomainName, message, timestampFrom, timestampTo, pageIndex,
                                             pageSize, searchText, sessionid, out totalRowCount);
            }
            catch (Exception exception)
            {
                return exception.ToString();
            }
        }