1
+ using System ;
2
+ using System . Windows . Forms ;
3
+ using Exceptionless . Dependency ;
4
+ using Exceptionless . Models ;
5
+ using Exceptionless . Storage ;
6
+ using Exceptionless . Utility ;
7
+
8
+ namespace Exceptionless . Dialogs {
9
+ public sealed partial class CrashReportForm : Form {
10
+ public ExceptionlessClient Client { get ; internal set ; }
11
+ public Event Event { get ; internal set ; }
12
+
13
+ public CrashReportForm ( ExceptionlessClient client , Event ev ) {
14
+ InitializeComponent ( ) ;
15
+
16
+ Client = client ;
17
+ Event = ev ;
18
+ Text = String . Concat ( AssemblyHelper . GetAssemblyTitle ( ) , " Error" ) ;
19
+ InformationHeaderLabel . Text = String . Concat ( AssemblyHelper . GetAssemblyTitle ( ) , " has encountered a problem and needs to close. We are sorry for the inconvenience." ) ;
20
+
21
+ var userInfo = ev . GetUserIdentity ( client . Configuration . Resolver . GetJsonSerializer ( ) ) ;
22
+ if ( userInfo != null && ! String . IsNullOrEmpty ( userInfo . Identity ) ) {
23
+ EmailAddressTextBox . Text = userInfo . Identity ;
24
+ } else {
25
+ var storage = client . Configuration . Resolver . Resolve < PersistedDictionary > ( ) ;
26
+ string emailAddress ;
27
+ if ( storage != null && storage . TryGetValue ( "EmailAddress" , out emailAddress ) )
28
+ EmailAddressTextBox . Text = emailAddress ;
29
+ }
30
+
31
+ var userDescription = Event . GetUserDescription ( client . Configuration . Resolver . GetJsonSerializer ( ) ) ;
32
+ if ( userDescription != null )
33
+ DescriptionTextBox . Text = userDescription . Description ;
34
+ }
35
+
36
+ private void ExitButton_Click ( object sender , EventArgs e ) {
37
+ Close ( ) ;
38
+ }
39
+
40
+ private void OnSubmitReportButtonClick ( object sender , EventArgs e ) {
41
+ Cursor = Cursors . WaitCursor ;
42
+ SendReportButton . Enabled = false ;
43
+ ExitButton . Enabled = false ;
44
+
45
+ if ( ! String . IsNullOrWhiteSpace ( EmailAddressTextBox . Text ) ) {
46
+ var storage = Client . Configuration . Resolver . Resolve < PersistedDictionary > ( ) ;
47
+ if ( storage != null )
48
+ storage [ "EmailAddress" ] = EmailAddressTextBox . Text ;
49
+ }
50
+
51
+ Event . SetUserDescription ( EmailAddressTextBox . Text , DescriptionTextBox . Text ) ;
52
+
53
+ Cursor = Cursors . Default ;
54
+ SendReportButton . Enabled = true ;
55
+ ExitButton . Enabled = true ;
56
+
57
+ DialogResult = DialogResult . OK ;
58
+ Close ( ) ;
59
+ }
60
+ }
61
+ }
0 commit comments