示例#1
0
 protected void GetLogModelDebug(string ip, string url, string httpMethod, string client, string username, string data, string deviceName)
 {
     Task.Run(() =>
     {
         try
         {
             var tempData = _base64Escape.Replace(data, "[Base64 string]") + ",";
             foreach (var item in _exraEscape)
             {
                 tempData = item.Replace(tempData, "");
             }
             data = tempData.TrimEnd(',');
             LogModelDebug model = new LogModelDebug()
             {
                 Time       = DateTime.Now.AddHours(AdditinalHour),
                 Data       = data,
                 IP         = ip,
                 Client     = client,
                 URL        = url,
                 Username   = username,
                 Method     = httpMethod,
                 DeviceName = deviceName
             };
             dataDebugItems.Add(model);
         }
         catch { }
     });
 }
示例#2
0
 internal async override Task WriteDebug()
 {
     try
     {
         List <string> items = new List <string>();
         while (!dataDebugItems.IsCompleted && dataDebugItems.Count > 0 && items.Count < dataDebugItems.BoundedCapacity)
         {
             LogModelDebug item = dataDebugItems.Take();
             items.Add($"StringTime: {item.StringTime} |=> IP: {item.IP} |=> Username: {item.Username} |=> Client: {item.Client} |=> DeviceName: {item.DeviceName} |=> Method: {item.Method} |=> URL: {item.URL} |=> Data: {item.Data}");
         }
         WritetoDisk(items, "Debug");
     }
     finally
     {
         await Task.Delay(30);
     }
 }
示例#3
0
 internal async override Task WriteDebug()
 {
     try
     {
         List <LogModelDebug> items = new List <LogModelDebug>();
         while (!dataDebugItems.IsCompleted && dataDebugItems.Count > 0 && items.Count < dataDebugItems.BoundedCapacity)
         {
             items.Add(dataDebugItems.Take());
         }
         if (items.Any())
         {
             DateTime logTime = DateTime.Now.AddHours(AdditinalHour);
             string   path    = Path.Combine(logPath, logName) + " " + logTime.ToString("yyyy-MM-dd") + " Debug.xml";
             if (File.Exists(path))
             {
                 LogModelDebug item          = items[0];
                 XDocument     xDocument     = XDocument.Load(path, LoadOptions.PreserveWhitespace);
                 XElement      root          = xDocument.Element(logName);
                 XElement      currentparent =
                     new XElement("Request",
                                  new XElement("IP", item.IP),
                                  new XElement("Username", item.Username),
                                  new XElement("Client", item.Client),
                                  new XElement("DeviceName", item.DeviceName),
                                  new XElement("URL", $"{item.Method}:{item.URL}"),
                                  new XElement("Data", item.Data)
                                  );
                 currentparent.SetAttributeValue("Time", item.StringTime);
                 root.AddFirst(currentparent);
                 xDocument.Save(path);
                 WriteItemList(path, items.Skip(1));
             }
             else
             {
                 WriteItemList(path, items);
             }
         }
     }
     finally
     {
         await Task.Delay(30);
     }
 }
示例#4
0
 internal override async Task WriteDebug()
 {
     try
     {
         Table.Rows.Clear();
         while (!dataDebugItems.IsCompleted && dataDebugItems.Count > 0 && Table.Rows.Count < dataDebugItems.BoundedCapacity)
         {
             LogModelDebug item = dataDebugItems.Take();
             Table.Rows.Add(0, item.Time, item.IP, item.Username, item.Client, item.URL, item.Method, item.DeviceName, item.Data);
         }
         using (SqlBulkCopy bulkCopy = new SqlBulkCopy(logConnection))
         {
             bulkCopy.DestinationTableName = "dbo." + logName + "_Debug";
             await bulkCopy.WriteToServerAsync(Table);
         }
     }
     finally
     {
         await Task.Delay(30);
     }
 }