Advertisement
Blizzardo1

hmm

Nov 30th, 2015
230
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 2.25 KB | None | 0 0
  1.         public void SendErrorToFile ( Exception ex, string nick )
  2.         {
  3.             if ( !Directory.Exists ( Program.LogsPath ) )
  4.                 Directory.CreateDirectory ( Program.LogsPath );
  5.             DateTime d = DateTime.Now;
  6.             string r = d.ToString ( "yyyyMMddHHmmssfft" );
  7.  
  8.             string clientmsg = string.Format (
  9.                 "Something has terribly gone wrong. Please report this to {0}! Your new Fingerprint is {1}",
  10.                 Owner,
  11.                 r );
  12.  
  13.             string servermsg = string.Format (
  14.                 "Something has terribly gone wrong. Gathering UserInfo:\nNick: {0}\nFingerPrint: {1}\nTime Of incident: {2}\nException: {3}",
  15.                 nick,
  16.                 r,
  17.                 d.ToString ( "dddd MMMM dd, yyyy :: HH:mm:ss" ),
  18.                 ex );
  19.  
  20.             SendMessage ( nick, clientmsg );
  21.             OpenWriteLog ( string.Format ( Program.LogsPath + "\\{0}.blog", r ), servermsg );
  22.         }
  23. // vs
  24.  
  25.         public static string GenerateErrorTicketId( string[] data )
  26.         {
  27.             var sb = new StringBuilder( );
  28.             DateTime dt = DateTime.Now;
  29.             string timestamp = DateTimeToUnixTimestamp( dt ).ToString( CultureInfo.InvariantCulture );
  30.             string error = string.Format( "error_{0}.lock", timestamp );
  31.             string refId = string.Format( "159{0:yyMMddHHmmss}", dt );
  32.             var w = new StreamWriter( error ) {AutoFlush = true};
  33.             sb.AppendLine( "=== Begin Error Ticket ===" );
  34.             sb.AppendFormat( "TimeStamp: {0}\r\n", timestamp );
  35.             sb.AppendFormat( "Snapshot: {0:dddd dd MMMM, yyyy - HH:mm:ss K}\r\n", dt );
  36.             sb.AppendFormat( "Reference: {0}\r\n", refId );
  37.             sb.AppendLine( "Data {{" );
  38.             foreach ( string dat in data )
  39.             {
  40.                 sb.AppendFormat( "\t{0}\r\n", dat );
  41.             }
  42.             sb.AppendLine( "}}" );
  43.             sb.AppendLine( "=== End Error Ticket ===" );
  44.             w.WriteLine( sb.ToString( ) );
  45.             w.Close( );
  46.             LzmaAlone.ParseFile( new[] {"e", error, string.Format( "Ticket_{0}.bzt", timestamp )} );
  47.  
  48.             File.Delete( error );
  49.  
  50.             // Implement db lookup
  51.             return refId;
  52.         }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement