Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public void SendErrorToFile ( Exception ex, string nick )
- {
- if ( !Directory.Exists ( Program.LogsPath ) )
- Directory.CreateDirectory ( Program.LogsPath );
- DateTime d = DateTime.Now;
- string r = d.ToString ( "yyyyMMddHHmmssfft" );
- string clientmsg = string.Format (
- "Something has terribly gone wrong. Please report this to {0}! Your new Fingerprint is {1}",
- Owner,
- r );
- string servermsg = string.Format (
- "Something has terribly gone wrong. Gathering UserInfo:\nNick: {0}\nFingerPrint: {1}\nTime Of incident: {2}\nException: {3}",
- nick,
- r,
- d.ToString ( "dddd MMMM dd, yyyy :: HH:mm:ss" ),
- ex );
- SendMessage ( nick, clientmsg );
- OpenWriteLog ( string.Format ( Program.LogsPath + "\\{0}.blog", r ), servermsg );
- }
- // vs
- public static string GenerateErrorTicketId( string[] data )
- {
- var sb = new StringBuilder( );
- DateTime dt = DateTime.Now;
- string timestamp = DateTimeToUnixTimestamp( dt ).ToString( CultureInfo.InvariantCulture );
- string error = string.Format( "error_{0}.lock", timestamp );
- string refId = string.Format( "159{0:yyMMddHHmmss}", dt );
- var w = new StreamWriter( error ) {AutoFlush = true};
- sb.AppendLine( "=== Begin Error Ticket ===" );
- sb.AppendFormat( "TimeStamp: {0}\r\n", timestamp );
- sb.AppendFormat( "Snapshot: {0:dddd dd MMMM, yyyy - HH:mm:ss K}\r\n", dt );
- sb.AppendFormat( "Reference: {0}\r\n", refId );
- sb.AppendLine( "Data {{" );
- foreach ( string dat in data )
- {
- sb.AppendFormat( "\t{0}\r\n", dat );
- }
- sb.AppendLine( "}}" );
- sb.AppendLine( "=== End Error Ticket ===" );
- w.WriteLine( sb.ToString( ) );
- w.Close( );
- LzmaAlone.ParseFile( new[] {"e", error, string.Format( "Ticket_{0}.bzt", timestamp )} );
- File.Delete( error );
- // Implement db lookup
- return refId;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement