|
|
@@ -92,7 +92,24 @@ namespace BulkPrinting
|
|
92
|
92
|
|
|
93
|
93
|
return true;
|
|
94
|
94
|
}
|
|
95
|
|
- catch (WebException) {
|
|
|
95
|
+ catch (WebException ex)
|
|
|
96
|
+ {
|
|
|
97
|
+ if (ex != null && ex.Response != null)
|
|
|
98
|
+ {
|
|
|
99
|
+ var response = ex.Response;
|
|
|
100
|
+ var stream = response.GetResponseStream();
|
|
|
101
|
+ var reader = new StreamReader(stream);
|
|
|
102
|
+ var message = reader.ReadToEnd();
|
|
|
103
|
+ MaxException MaxError = JsonConvert.DeserializeObject<MaxException>(message);
|
|
|
104
|
+ if (MaxError.Code != null)
|
|
|
105
|
+ {
|
|
|
106
|
+ MessageBox.Show("Error " + MaxError.Code.ToString() + ": " + MaxError.Error, "Login Failed", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
|
|
107
|
+ }
|
|
|
108
|
+ else
|
|
|
109
|
+ {
|
|
|
110
|
+ MessageBox.Show("Login Failed. Please try again.", "Login Failed", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
|
|
111
|
+ }
|
|
|
112
|
+ }
|
|
96
|
113
|
return false;
|
|
97
|
114
|
}
|
|
98
|
115
|
}
|
|
|
@@ -135,45 +152,23 @@ namespace BulkPrinting
|
|
135
|
152
|
Result = JsonConvert.DeserializeObject<R>(responseString);
|
|
136
|
153
|
return true;
|
|
137
|
154
|
}
|
|
138
|
|
- catch (WebException)
|
|
|
155
|
+ catch (WebException ex)
|
|
139
|
156
|
{
|
|
|
157
|
+ if (ex != null && ex.Response != null)
|
|
|
158
|
+ {
|
|
|
159
|
+ var response = ex.Response;
|
|
|
160
|
+ var stream = response.GetResponseStream();
|
|
|
161
|
+ var reader = new StreamReader(stream);
|
|
|
162
|
+ var message = reader.ReadToEnd();
|
|
|
163
|
+ MaxException MaxError = JsonConvert.DeserializeObject<MaxException>(message);
|
|
|
164
|
+ if (MaxError.Code != null)
|
|
|
165
|
+ {
|
|
|
166
|
+ MessageBox.Show("Error " + MaxError.Code.ToString() + ": " + MaxError.Error, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
|
|
167
|
+ }
|
|
|
168
|
+ }
|
|
140
|
169
|
return false;
|
|
141
|
170
|
}
|
|
142
|
171
|
}
|
|
143
|
|
- /*
|
|
144
|
|
- private static bool RegSave(string Key, string Value)
|
|
145
|
|
- {
|
|
146
|
|
- bool Result;
|
|
147
|
|
- try
|
|
148
|
|
- {
|
|
149
|
|
- RegistryKey MaxRegistry = Registry.CurrentUser.OpenSubKey("Software\\M@X\\BulkPrint");
|
|
150
|
|
- Registry.SetValue(MaxRegistry.Name, Key, Value);
|
|
151
|
|
- Registry.CurrentUser.Close();
|
|
152
|
|
- Result = true;
|
|
153
|
|
- }
|
|
154
|
|
- catch (Exception)
|
|
155
|
|
- {
|
|
156
|
|
- Result = false;
|
|
157
|
|
- }
|
|
158
|
|
- return Result;
|
|
159
|
|
- }
|
|
160
|
|
-
|
|
161
|
|
- public static string RegFetch(string Key)
|
|
162
|
|
- {
|
|
163
|
|
- string Result;
|
|
164
|
|
- try
|
|
165
|
|
- {
|
|
166
|
|
- RegistryKey MaxRegistry = Registry.CurrentUser.OpenSubKey("Software\\M@X\\BulkPrint");
|
|
167
|
|
- Result = Registry.GetValue(MaxRegistry.Name, Key, "").ToString();
|
|
168
|
|
- Registry.CurrentUser.Close();
|
|
169
|
|
- }
|
|
170
|
|
- catch (Exception)
|
|
171
|
|
- {
|
|
172
|
|
- Result = "";
|
|
173
|
|
- }
|
|
174
|
|
- return Result;
|
|
175
|
|
- }
|
|
176
|
|
- */
|
|
177
|
172
|
|
|
178
|
173
|
private static bool SaveSetting(string Key, string Value)
|
|
179
|
174
|
{
|