Commit de7e08dbd35c34afa8d65a475388e78c9691ea67

Authored by Utkarsh Singh
1 parent 24f2da39

Committing updated files with SQL Connection exception handling

400-SOURCECODE/AIAHTML5.API/Controllers/AuthenticateController.cs
... ... @@ -35,217 +35,280 @@ namespace AIAHTML5.API.Controllers
35 35  
36 36 dynamic authenticationRepsonse;
37 37  
38   - //01. check user is authenticated or not by login credential macth
39   - //bool isUserAuthenticated = AIAHTML5.API.Models.Users.IsUserAuthenticated(credentials);
40   -
41   - //Above code commented to reduce db hitting for same result set
42   - // get user details based on credentials provided
43   - dynamic userInfo = AIAHTML5.API.Models.Users.getUserDetails(credentials);
44   -
45   - if (userInfo != null && Convert.ToString(userInfo) != AIAConstants.SQL_CONNECTION_ERROR)
  38 + try
46 39 {
47   - //check is user authenticated
48   - bool isUserAuthenticated = AIAHTML5.API.Models.Users.IsUserAuthenticated(credentials, userInfo);
49 40  
50   - // check if user is blocked
51   - DateTime blockTime;
52   - bool isUserBlocked = AIAHTML5.API.Models.Users.isUserBlocked(userInfo.Id, out blockTime);
  41 + //01. check user is authenticated or not by login credential macth
  42 + //bool isUserAuthenticated = AIAHTML5.API.Models.Users.IsUserAuthenticated(credentials);
  43 +
  44 + //Above code commented to reduce db hitting for same result set
  45 + // get user details based on credentials provided
  46 + User userInfo = AIAHTML5.API.Models.Users.getUserDetails(credentials);
53 47  
54   - if (isUserAuthenticated && !isUserBlocked)
  48 + if (userInfo.Id > 0)
55 49 {
56   - //01. Get User details
57   - //userInfo = AIAHTML5.API.Models.Users.getUserDetails(credentials);
  50 + //check is user authenticated
  51 + bool isUserAuthenticated = AIAHTML5.API.Models.Users.IsUserAuthenticated(credentials, userInfo);
58 52  
59   - //02. assigning isCorrectPassword to true 'required for internal processing'
60   - userInfo.IsCorrectPassword = true;
  53 + // check if user is blocked
  54 + DateTime blockTime;
  55 + bool isUserBlocked = AIAHTML5.API.Models.Users.isUserBlocked(userInfo.Id, out blockTime);
61 56  
62   - //04.delete past wrong login attempts of user
63   - int wrongAttemptDeteledCount = AIAHTML5.API.Models.Users.deletePastWrongAttempts(userInfo.Id);
64   - if (wrongAttemptDeteledCount < 0)
  57 + if (isUserAuthenticated && !isUserBlocked)
65 58 {
66   - logger.Fatal("Unable to delete past wrong login attempts for userId= " + userInfo.Id);
67   - }
  59 + //01. Get User details
  60 + //userInfo = AIAHTML5.API.Models.Users.getUserDetails(credentials);
68 61  
69   - //05. Now get the module list- for ADMIN (superadmin/ general admin) by default all module loads
70   - if (userInfo.UserType == AIAHTML5.API.Models.User.SUPER_ADMIN || userInfo.UserType == AIAHTML5.API.Models.User.GENERAL_ADMIN)
71   - {
72   - userInfo.Modules = AIAHTML5.API.Models.Users.getAllModulesList();
73   -
74   - //Insert user login detail
75   - AIAHTML5.API.Models.Users.insertLoginDetails(userInfo.Id);
76   - }
77   - else
78   - {
79   - //05.1 For normal user need to get the license details, get the license id for authenticated user
80   - int licenseId, editionId;
81   - AIAHTML5.API.Models.Users.getLicenseIdForThisUser(userInfo.Id, out licenseId, out editionId);
  62 + //02. assigning isCorrectPassword to true 'required for internal processing'
  63 + userInfo.IsCorrectPassword = true;
82 64  
83   - userInfo.LicenseId = licenseId;
84   - userInfo.EditionId = editionId;
  65 + //04.delete past wrong login attempts of user
  66 + int wrongAttemptDeteledCount = AIAHTML5.API.Models.Users.deletePastWrongAttempts(userInfo.Id);
  67 + if (wrongAttemptDeteledCount < 0)
  68 + {
  69 + logger.Fatal("Unable to delete past wrong login attempts for userId= " + userInfo.Id);
  70 + }
85 71  
86   - //05.2 Check user is active or not
  72 + //05. Now get the module list- for ADMIN (superadmin/ general admin) by default all module loads
  73 + if (userInfo.UserType == AIAHTML5.API.Models.User.SUPER_ADMIN || userInfo.UserType == AIAHTML5.API.Models.User.GENERAL_ADMIN)
  74 + {
  75 + userInfo.Modules = AIAHTML5.API.Models.Users.getAllModulesList();
87 76  
  77 + //Insert user login detail
  78 + AIAHTML5.API.Models.Users.insertLoginDetails(userInfo.Id);
  79 + }
  80 + else
  81 + {
  82 + //05.1 For normal user need to get the license details, get the license id for authenticated user
  83 + int licenseId, editionId;
  84 + AIAHTML5.API.Models.Users.getLicenseIdForThisUser(userInfo.Id, out licenseId, out editionId);
88 85  
89   - //05.3 get license details
90   - userInfo.LicenseInfo = AIAHTML5.API.Models.Users.getLicenseDetails(userInfo.LicenseId);
  86 + userInfo.LicenseId = licenseId;
  87 + userInfo.EditionId = editionId;
91 88  
92   - //05.4 get licenseSubscription details
93   - userInfo.LicenseSubscriptions = AIAHTML5.API.Models.Users.getLicenseSubscriptionDetails(userInfo.LicenseId);
  89 + //05.2 Check user is active or not
94 90  
95   - //05.5 check the License expiration irespective of either user is active or not because on AIA
96   - //we shows the License expiration message for inactive users too
97   - string expirationDate = null;
98 91  
99   - bool isLicenseExpired = AIAHTML5.API.Models.Users.checkIfLicenseExpired(userInfo.LicenseSubscriptions, out expirationDate);
  92 + //05.3 get license details
  93 + userInfo.LicenseInfo = AIAHTML5.API.Models.Users.getLicenseDetails(userInfo.LicenseId);
100 94  
101   - // send message to the UI for license expiration
102   - //05.6 Check for subscription Expiration [Promoted for case if license inactive along with subscription expired]
103   - if (isLicenseExpired)
104   - {
105   - userInfo.IsSubscriptionExpired = isLicenseExpired;
106   - userInfo.SubscriptionExpirationDate = expirationDate;
107   - }
108   - else
109   - {
110   - //05.6.1
111   - if (userInfo.LicenseInfo.IsActive)
  95 + if (userInfo.LicenseInfo.Id > 0)
112 96 {
113   - if (!userInfo.LicenseInfo.IsTermAccepted)
  97 + //05.4 get licenseSubscription details
  98 + userInfo.LicenseSubscriptions = AIAHTML5.API.Models.Users.getLicenseSubscriptionDetails(userInfo.LicenseId);
  99 +
  100 + //05.5 check the License expiration irespective of either user is active or not because on AIA
  101 + //we shows the License expiration message for inactive users too
  102 + string expirationDate = null;
  103 + bool isLicenseExpired = false;
  104 +
  105 + if (userInfo.LicenseSubscriptions.Id > 0)
114 106 {
115   - ArrayList termsList = AIAHTML5.API.Models.Users.getTermsOfServiceText();
116   - foreach (Hashtable item in termsList)
117   - {
118   - userInfo.TermsOfServiceTitle = item["title"].ToString();
119   - userInfo.TermsOfServiceText = item["content"].ToString();
120   - }
  107 + isLicenseExpired = AIAHTML5.API.Models.Users.checkIfLicenseExpired(userInfo.LicenseSubscriptions, out expirationDate);
  108 + }
  109 +
  110 + // send message to the UI for license expiration
  111 + //05.6 Check for subscription Expiration [Promoted for case if license inactive along with subscription expired]
  112 + if (isLicenseExpired)
  113 + {
  114 + userInfo.IsSubscriptionExpired = isLicenseExpired;
  115 + userInfo.SubscriptionExpirationDate = expirationDate;
121 116 }
122 117 else
123 118 {
124   - userInfo.Modules = AIAHTML5.API.Models.Users.getModuleListByLicenseId(userInfo.LicenseId);
  119 + //05.6.1
  120 + if (userInfo.LicenseInfo.IsActive)
  121 + {
  122 + if (!userInfo.LicenseInfo.IsTermAccepted)
  123 + {
  124 + ArrayList termsList = AIAHTML5.API.Models.Users.getTermsOfServiceText();
  125 + foreach (Hashtable item in termsList)
  126 + {
  127 + userInfo.TermsOfServiceTitle = item["title"].ToString();
  128 + userInfo.TermsOfServiceText = item["content"].ToString();
  129 + }
  130 + }
  131 + else
  132 + {
  133 + userInfo.Modules = AIAHTML5.API.Models.Users.getModuleListByLicenseId(userInfo.LicenseId);
125 134  
126   - //Insert user login detail
127   - AIAHTML5.API.Models.Users.insertLoginDetails(userInfo.Id);
128   - }
129   - }
130   - else
131   - {
132   - //05.6.1.1
133   - // return message of license inactive
134   - // property value assigned. Separate return statement not required
  135 + //Insert user login detail
  136 + AIAHTML5.API.Models.Users.insertLoginDetails(userInfo.Id);
  137 + }
  138 + }
  139 + else
  140 + {
  141 + //05.6.1.1
  142 + // return message of license inactive
  143 + // property value assigned. Separate return statement not required
135 144  
  145 + }
  146 + }
136 147 }
137   -
138 148 }
139   - }
140 149  
141   - authenticationRepsonse = JsonConvert.SerializeObject(userInfo);
142   - }
143   - else
144   - {
145   - //compare block time of user with current time if user is blocked
146   - DateTime blockDuration = blockTime.AddDays(1);
147   - var difference = DateTime.Compare(DateTime.Now, blockDuration);
  150 + authenticationRepsonse = JsonConvert.SerializeObject(userInfo);
  151 + }
  152 + else
  153 + {
  154 + //compare block time of user with current time if user is blocked
  155 + DateTime blockDuration = blockTime.AddDays(1);
  156 + var difference = DateTime.Compare(DateTime.Now, blockDuration);
148 157  
149   - //check if credentials are valid credentials
150   - bool isCorrectLoginId, isCorrectPassword;
151   - AIAHTML5.API.Models.Users.isCredentialCorrect(credentials, out isCorrectLoginId, out isCorrectPassword);
  158 + //check if credentials are valid credentials
  159 + bool isCorrectLoginId, isCorrectPassword;
  160 + AIAHTML5.API.Models.Users.isCredentialCorrect(credentials, userInfo, out isCorrectLoginId, out isCorrectPassword);
152 161  
153   - if (isUserBlocked)
154   - {
155   - if (difference >= 0)
  162 + if (isUserBlocked)
156 163 {
157   - if (isCorrectPassword)
  164 + if (difference >= 0)
158 165 {
159   - userInfo.IsBlocked = false;
160   - userInfo.IsCorrectPassword = true;
161   -
162   - int wrongAttemptDeteledCount = AIAHTML5.API.Models.Users.deletePastWrongAttempts(userInfo.Id);
163   - if (wrongAttemptDeteledCount < 0)
  166 + if (isCorrectPassword)
164 167 {
165   - logger.Fatal("Unable to delete past wrong login attempts for userId= " + userInfo.Id);
166   - }
  168 + userInfo.IsBlocked = false;
  169 + userInfo.IsCorrectPassword = true;
167 170  
168   - //05. Now get the module list- for ADMIN (superadmin/ general admin) by default all module loads
  171 + int wrongAttemptDeteledCount = AIAHTML5.API.Models.Users.deletePastWrongAttempts(userInfo.Id);
  172 + if (wrongAttemptDeteledCount < 0)
  173 + {
  174 + logger.Fatal("Unable to delete past wrong login attempts for userId= " + userInfo.Id);
  175 + }
169 176  
170   - if (userInfo.UserType == AIAHTML5.API.Models.User.SUPER_ADMIN || userInfo.UserType == AIAHTML5.API.Models.User.GENERAL_ADMIN)
171   - {
172   - userInfo.Modules = AIAHTML5.API.Models.Users.getAllModulesList();
  177 + //05. Now get the module list- for ADMIN (superadmin/ general admin) by default all module loads
173 178  
174   - //Insert user login detail
175   - AIAHTML5.API.Models.Users.insertLoginDetails(userInfo.Id);
176   - }
177   - else
178   - {
179   - //05.1 For normal user need to get the license details, get the license id for aUTHENTICATED USER
180   - int licenseId, editionId;
181   - AIAHTML5.API.Models.Users.getLicenseIdForThisUser(userInfo.Id, out licenseId, out editionId);
  179 + if (userInfo.UserType == AIAHTML5.API.Models.User.SUPER_ADMIN || userInfo.UserType == AIAHTML5.API.Models.User.GENERAL_ADMIN)
  180 + {
  181 + userInfo.Modules = AIAHTML5.API.Models.Users.getAllModulesList();
182 182  
183   - userInfo.LicenseId = licenseId;
184   - userInfo.EditionId = editionId;
  183 + //Insert user login detail
  184 + AIAHTML5.API.Models.Users.insertLoginDetails(userInfo.Id);
  185 + }
  186 + else
  187 + {
  188 + //05.1 For normal user need to get the license details, get the license id for aUTHENTICATED USER
  189 + int licenseId, editionId;
  190 + AIAHTML5.API.Models.Users.getLicenseIdForThisUser(userInfo.Id, out licenseId, out editionId);
185 191  
186   - //05.2 Check user is active or not
  192 + userInfo.LicenseId = licenseId;
  193 + userInfo.EditionId = editionId;
187 194  
  195 + //05.2 Check user is active or not
188 196  
189   - //05.3 get license/ licenseSubscription details
190   - userInfo.LicenseInfo = AIAHTML5.API.Models.Users.getLicenseDetails(userInfo.LicenseId);
191 197  
192   - //05.4
193   - userInfo.LicenseSubscriptions = AIAHTML5.API.Models.Users.getLicenseSubscriptionDetails(userInfo.LicenseId);
  198 + //05.3 get license/ licenseSubscription details
  199 + userInfo.LicenseInfo = AIAHTML5.API.Models.Users.getLicenseDetails(userInfo.LicenseId);
194 200  
195   - //05.5 check the License expiration irespective of either user is active or not because on AIA
196   - //we shows the License expiration message for inactive users too
197   - string expirationDate = null;
  201 + if (userInfo.LicenseInfo.Id > 0)
  202 + {
  203 + //05.4
  204 + userInfo.LicenseSubscriptions = AIAHTML5.API.Models.Users.getLicenseSubscriptionDetails(userInfo.LicenseId);
198 205  
199   - bool isLicenseExpired = AIAHTML5.API.Models.Users.checkIfLicenseExpired(userInfo.LicenseSubscriptions, out expirationDate);
  206 + //05.5 check the License expiration irespective of either user is active or not because on AIA
  207 + //we shows the License expiration message for inactive users too
  208 + string expirationDate = null;
  209 + bool isLicenseExpired = false;
200 210  
201   - // send message to the UI for license expiration
202   - //05.6 Check for subscription Expiration [Promoted for case if license inactive along with subscription expired]
203   - if (isLicenseExpired)
204   - {
205   - userInfo.IsSubscriptionExpired = isLicenseExpired;
206   - userInfo.SubscriptionExpirationDate = expirationDate;
207   - }
208   - else
209   - {
210   - //05.6.1
211   - if (userInfo.LicenseInfo.IsActive)
212   - {
213   - if (!userInfo.LicenseInfo.IsTermAccepted)
  211 + if (userInfo.LicenseSubscriptions.Id > 0)
214 212 {
215   - ArrayList termsList = AIAHTML5.API.Models.Users.getTermsOfServiceText();
216   - foreach (Hashtable item in termsList)
217   - {
218   - userInfo.TermsOfServiceTitle = item["title"].ToString();
219   - userInfo.TermsOfServiceText = item["content"].ToString();
220   - }
  213 + isLicenseExpired = AIAHTML5.API.Models.Users.checkIfLicenseExpired(userInfo.LicenseSubscriptions, out expirationDate);
  214 + }
  215 + // send message to the UI for license expiration
  216 + //05.6 Check for subscription Expiration [Promoted for case if license inactive along with subscription expired]
  217 + if (isLicenseExpired)
  218 + {
  219 + userInfo.IsSubscriptionExpired = isLicenseExpired;
  220 + userInfo.SubscriptionExpirationDate = expirationDate;
221 221 }
222 222 else
223 223 {
224   - userInfo.Modules = AIAHTML5.API.Models.Users.getModuleListByLicenseId(userInfo.LicenseId);
  224 + //05.6.1
  225 + if (userInfo.LicenseInfo.IsActive)
  226 + {
  227 + if (!userInfo.LicenseInfo.IsTermAccepted)
  228 + {
  229 + ArrayList termsList = AIAHTML5.API.Models.Users.getTermsOfServiceText();
  230 + foreach (Hashtable item in termsList)
  231 + {
  232 + userInfo.TermsOfServiceTitle = item["title"].ToString();
  233 + userInfo.TermsOfServiceText = item["content"].ToString();
  234 + }
  235 + }
  236 + else
  237 + {
  238 + userInfo.Modules = AIAHTML5.API.Models.Users.getModuleListByLicenseId(userInfo.LicenseId);
  239 +
  240 + //Insert user login detail
  241 + AIAHTML5.API.Models.Users.insertLoginDetails(userInfo.Id);
  242 + }
  243 + }
  244 + else
  245 + {
  246 + //05.6.1.1
  247 + // return message of license inactive
  248 + // property value assigned. Separate return statement not required
225 249  
226   - //Insert user login detail
227   - AIAHTML5.API.Models.Users.insertLoginDetails(userInfo.Id);
  250 + }
228 251 }
229 252 }
230   - else
231   - {
232   - //05.6.1.1
233   - // return message of license inactive
234   - // property value assigned. Separate return statement not required
  253 + }
  254 + }
  255 + else
  256 + {
  257 + int wrongAttemptDeteledCount = AIAHTML5.API.Models.Users.deletePastWrongAttempts(userInfo.Id);
  258 + if (wrongAttemptDeteledCount < 0)
  259 + {
  260 + logger.Fatal("Unable to delete past wrong login attempts for userId= " + userInfo.Id);
  261 + }
235 262  
236   - }
  263 + // send message back to th UI that password is incorrect
  264 + userInfo.IsCorrectPassword = false;
237 265  
  266 + //get wrong attempt count of user
  267 + userInfo.IncorrectLoginAttemptCount = AIAHTML5.API.Models.Users.checkNoOfWrongAttempts(userInfo.Id) + 1;
  268 + userInfo.LoginFailureCauseId = ErrorHelper.E_PASSWORD_NOT_MATCH;
  269 +
  270 + //01. insert wrong attempt in dtabase
  271 + int updateCount = AIAHTML5.API.Models.Users.saveWrongAttemptofUser(userInfo.Id);
  272 +
  273 + if (updateCount < 0)
  274 + {
  275 + //Put the log in log file
  276 + logger.Fatal("Unable to Update past wrong login attempts for userId= " + userInfo.Id);
238 277 }
  278 + else
  279 + {
  280 + if (userInfo.IncorrectLoginAttemptCount > 4)
  281 + {
  282 + userInfo.IsBlocked = true;
  283 + userInfo.LoginFailureCauseId = ErrorHelper.E_USER_ID_BLOCKED_24_HRS;
  284 + }
  285 + }
  286 +
239 287 }
  288 +
240 289 }
241 290 else
242 291 {
243   - int wrongAttemptDeteledCount = AIAHTML5.API.Models.Users.deletePastWrongAttempts(userInfo.Id);
244   - if (wrongAttemptDeteledCount < 0)
245   - {
246   - logger.Fatal("Unable to delete past wrong login attempts for userId= " + userInfo.Id);
247   - }
  292 + userInfo.IsBlocked = true;
  293 + }
  294 + }
  295 +
  296 + else
  297 + {
248 298  
  299 + //bool isCorrectLoginId, isCorrectPassword;
  300 + //AIAHTML5.API.Models.Users.isCredentialCorrect(credentials, out isCorrectLoginId, out isCorrectPassword);
  301 +
  302 + //below code commented as way of retrieving data changed 'very first line in this method'
  303 + //if (!isCorrectLoginId)
  304 + //{
  305 + // // send message back to th UI that login id is incorrect
  306 + // authenticationRepsonse = AIAConstants.USER_NOT_FOUND;
  307 + //}
  308 + //else
  309 + //{
  310 + if (!isCorrectPassword)
  311 + {
249 312 // send message back to th UI that password is incorrect
250 313 userInfo.IsCorrectPassword = false;
251 314  
... ... @@ -269,88 +332,39 @@ namespace AIAHTML5.API.Controllers
269 332 userInfo.LoginFailureCauseId = ErrorHelper.E_USER_ID_BLOCKED_24_HRS;
270 333 }
271 334 }
272   -
273 335 }
274   -
275 336 }
276   - else
277   - {
278   - userInfo.IsBlocked = true;
279   - }
280   - }
281   -
282   - else
283   - {
284   -
285   - //bool isCorrectLoginId, isCorrectPassword;
286   - //AIAHTML5.API.Models.Users.isCredentialCorrect(credentials, out isCorrectLoginId, out isCorrectPassword);
287   -
288   - //below code commented as way of retrieving data changed 'very first line in this method'
289   - //if (!isCorrectLoginId)
  337 + // unreachable code detected as license is null
  338 + //if (userInfo.License != null && !string.IsNullOrEmpty(userInfo.License.AccountNumber))
290 339 //{
291   - // // send message back to th UI that login id is incorrect
292   - // authenticationRepsonse = AIAConstants.USER_NOT_FOUND;
  340 + // int result = AIAHTML5.API.Models.Users.insertUserLoginLog(userInfo.License.AccountNumber, userInfo.LoginFailureCauseId, null, userInfo.EditionId.ToString(), null);
  341 + // if (result < 0)
  342 + // logger.Fatal("Unable to insert wrong attempt detail in UserLoginLog table for accountNumber= " + userInfo.License.AccountNumber);
293 343 //}
294   - //else
295   - //{
296   - if (!isCorrectPassword)
297   - {
298   - // send message back to th UI that password is incorrect
299   - userInfo.IsCorrectPassword = false;
300   -
301   - //get wrong attempt count of user
302   - userInfo.IncorrectLoginAttemptCount = AIAHTML5.API.Models.Users.checkNoOfWrongAttempts(userInfo.Id) + 1;
303   - userInfo.LoginFailureCauseId = ErrorHelper.E_PASSWORD_NOT_MATCH;
304 344  
305   - //01. insert wrong attempt in dtabase
306   - int updateCount = AIAHTML5.API.Models.Users.saveWrongAttemptofUser(userInfo.Id);
307   -
308   - if (updateCount < 0)
309   - {
310   - //Put the log in log file
311   - logger.Fatal("Unable to Update past wrong login attempts for userId= " + userInfo.Id);
312   - }
313   - else
314   - {
315   - if (userInfo.IncorrectLoginAttemptCount > 4)
316   - {
317   - userInfo.IsBlocked = true;
318   - userInfo.LoginFailureCauseId = ErrorHelper.E_USER_ID_BLOCKED_24_HRS;
319   - }
320   - }
321   - }
  345 + authenticationRepsonse = JsonConvert.SerializeObject(userInfo);
  346 + //}
322 347 }
323   - // unreachable code detected as license is null
324   - //if (userInfo.License != null && !string.IsNullOrEmpty(userInfo.License.AccountNumber))
325   - //{
326   - // int result = AIAHTML5.API.Models.Users.insertUserLoginLog(userInfo.License.AccountNumber, userInfo.LoginFailureCauseId, null, userInfo.EditionId.ToString(), null);
327   - // if (result < 0)
328   - // logger.Fatal("Unable to insert wrong attempt detail in UserLoginLog table for accountNumber= " + userInfo.License.AccountNumber);
329   - //}
330   -
331   - authenticationRepsonse = JsonConvert.SerializeObject(userInfo);
332   - //}
  348 + }
  349 + else
  350 + {
  351 + authenticationRepsonse = AIAConstants.USER_NOT_FOUND;
333 352 }
334 353 }
335   - else if (Convert.ToString(userInfo) != AIAConstants.SQL_CONNECTION_ERROR)
336   - {
337   - authenticationRepsonse = AIAConstants.USER_NOT_FOUND;
338   - }
339   - else
  354 + catch (Exception e)
340 355 {
  356 +
  357 + logger.Fatal("Exception occured for loginId =" + credentials["username"].ToString() + " and password= " + credentials["password"].ToString() + "Exception= " + e.Message + ", STACKTRACE: " + e.StackTrace);
  358 +
  359 + ArrayList supportMailList = UserUtility.GetSupportMailList();
  360 + string mailSubject = "SQL Exception intimation mail";
  361 + string mailBody = "MESSAGE: " + e.Message + ", STACKTRACE: " + e.StackTrace;
  362 + UserUtility.SendEmail(credentials, supportMailList, "", mailSubject, mailBody);
  363 +
341 364 authenticationRepsonse = AIAConstants.SQL_CONNECTION_ERROR;
342 365 }
343 366  
344   - //if (Convert.ToString(authenticationRepsonse) != AIAConstants.USER_NOT_FOUND && Convert.ToString(authenticationRepsonse) != AIAConstants.ERROR_IN_FECTHING_DETAILS && Convert.ToString(authenticationRepsonse)!= AIAConstants.SQL_CONNECTION_ERROR)
345   - //{
346   - // //string userDetails = Newtonsoft.Json.JsonConvert.SerializeObject(authenticationRepsonse);
347   - // return new HttpResponseMessage { StatusCode = HttpStatusCode.OK, Content = new StringContent(authenticationRepsonse) };
348   - //}
349   - //else
350   - //{
351 367 return new HttpResponseMessage { StatusCode = HttpStatusCode.OK, Content = new StringContent(authenticationRepsonse) };
352   -
353   - //}
354 368 }
355 369  
356 370  
... ...
400-SOURCECODE/AIAHTML5.API/Models/DBModel.cs
... ... @@ -89,12 +89,12 @@ namespace AIAHTML5.API.Models
89 89 return arrUserModules;
90 90 }
91 91  
92   - internal static dynamic GetUserDetailsByLoginId(string loginId)
  92 + internal static User GetUserDetailsByLoginId(string loginId)
93 93 {
94 94 ILog logger = log4net.LogManager.GetLogger((System.Reflection.MethodBase.GetCurrentMethod().DeclaringType));
95 95 logger.Debug(" Inside GetUserDetailsByLoginId for LoginId = " + loginId);
96 96  
97   - dynamic objUser = null;
  97 + User objUser = null;
98 98 DBModel objModel = new DBModel();
99 99  
100 100 try
... ... @@ -117,6 +117,7 @@ namespace AIAHTML5.API.Models
117 117 da.SelectCommand = cmd;
118 118 DataTable dt = new DataTable();
119 119 da.Fill(dt);
  120 +
120 121  
121 122 if (dt.Rows.Count > 0)
122 123 {
... ... @@ -124,6 +125,7 @@ namespace AIAHTML5.API.Models
124 125 {
125 126 int tempVal;
126 127 DateTime date;
  128 + objUser = new User();
127 129  
128 130 objUser.Id = Convert.ToInt32(dr["Id"]);
129 131 objUser.FirstName = dr["FirstName"].ToString();
... ... @@ -145,7 +147,7 @@ namespace AIAHTML5.API.Models
145 147 }
146 148 else
147 149 {
148   - objUser = null;
  150 + objUser = new User();
149 151 }
150 152 }
151 153 catch (SqlException ex)
... ... @@ -299,7 +301,7 @@ namespace AIAHTML5.API.Models
299 301 ILog logger = log4net.LogManager.GetLogger((System.Reflection.MethodBase.GetCurrentMethod().DeclaringType));
300 302 logger.Debug(" Inside GetUserDetailsByEmailId for emailId = " + emailId);
301 303  
302   - User objUser = new User();
  304 + User objUser = null;
303 305 DBModel objModel = new DBModel();
304 306  
305 307 try
... ... @@ -334,6 +336,7 @@ namespace AIAHTML5.API.Models
334 336 {
335 337 int tempVal;
336 338 DateTime date;
  339 + objUser = new User();
337 340  
338 341 objUser.Id = Convert.ToInt32(dr["Id"]);
339 342 objUser.FirstName = dr["FirstName"].ToString();
... ... @@ -356,7 +359,7 @@ namespace AIAHTML5.API.Models
356 359 }
357 360 else
358 361 {
359   - objUser = null;
  362 + objUser = new User ();
360 363 }
361 364 }
362 365 catch (SqlException ex)
... ... @@ -454,7 +457,7 @@ namespace AIAHTML5.API.Models
454 457 }
455 458 else
456 459 {
457   - lsd = null;
  460 + lsd = new LicenseSubscriptionDetails ();
458 461 }
459 462  
460 463 }
... ... @@ -528,7 +531,7 @@ namespace AIAHTML5.API.Models
528 531 }
529 532 else
530 533 {
531   - license = null;
  534 + license = new License ();
532 535 }
533 536 }
534 537 catch (Exception ex)
... ... @@ -883,7 +886,7 @@ namespace AIAHTML5.API.Models
883 886 }
884 887 else
885 888 {
886   - blockedUser = null;
  889 + blockedUser = new BlockedUser ();
887 890 }
888 891 }
889 892 catch (SqlException ex)
... ... @@ -935,7 +938,7 @@ namespace AIAHTML5.API.Models
935 938 }
936 939 else
937 940 {
938   - blockedUser = null;
  941 + blockedUser = new BlockedUser();
939 942 }
940 943 }
941 944 catch (SqlException ex)
... ...
400-SOURCECODE/AIAHTML5.API/Models/Users.cs
... ... @@ -97,7 +97,7 @@ namespace AIAHTML5.API.Models
97 97  
98 98 //dynamic userDetails;
99 99  
100   - if (objUser != null)
  100 + if (objUser.Id > 0)
101 101 {
102 102 logger.Debug("userDetails.loginId= " + objUser.LoginId);
103 103 //return userDetails = JsonConvert.SerializeObject(objUser);
... ... @@ -203,11 +203,11 @@ namespace AIAHTML5.API.Models
203 203 return isAuthenticatedUser;
204 204 }
205 205  
206   - internal static dynamic getUserDetails(Newtonsoft.Json.Linq.JObject credentials)
  206 + internal static User getUserDetails(Newtonsoft.Json.Linq.JObject credentials)
207 207 {
208 208 ILog logger = log4net.LogManager.GetLogger((System.Reflection.MethodBase.GetCurrentMethod().DeclaringType));
209 209 logger.Debug("inside getUserDetails for loginId =" + credentials["username"].ToString() + " and password= " + credentials["password"].ToString());
210   - dynamic userDetails = null;
  210 + User userDetails = null;
211 211  
212 212 try
213 213 {
... ... @@ -217,13 +217,13 @@ namespace AIAHTML5.API.Models
217 217 {
218 218  
219 219 logger.Fatal("Exception in getUserDetails for loginId =" + credentials["username"].ToString() + " and password= " + credentials["password"].ToString() + "Exception= " + e.Message + ", STACKTRACE: " + e.StackTrace);
  220 + throw;
  221 + //ArrayList supportMailList = UserUtility.GetSupportMailList();
  222 + //string mailSubject = "SQL Exception intimation mail";
  223 + //string mailBody = "MESSAGE: " + e.Message + ", STACKTRACE: " + e.StackTrace;
  224 + //UserUtility.SendEmail(credentials, supportMailList, "", mailSubject, mailBody);
220 225  
221   - ArrayList supportMailList = UserUtility.GetSupportMailList();
222   - string mailSubject = "SQL Exception intimation mail";
223   - string mailBody = "MESSAGE: " + e.Message + ", STACKTRACE: " + e.StackTrace;
224   - UserUtility.SendEmail(credentials, supportMailList, "", mailSubject, mailBody);
225   -
226   - userDetails = AIAConstants.SQL_CONNECTION_ERROR;
  226 + //userDetails = AIAConstants.SQL_CONNECTION_ERROR;
227 227 }
228 228  
229 229 return userDetails;
... ... @@ -260,13 +260,7 @@ namespace AIAHTML5.API.Models
260 260 catch (Exception e)
261 261 {
262 262 logger.Fatal("Exception in getLicenseIdForThisUser for UserId =" + userId + "Exception= " + e.Message + ", STACKTRACE: " + e.StackTrace);
263   -
264   - //ArrayList supportMailList = UserUtility.GetSupportMailList();
265   - //string mailSubject = "SQL Exception intimation mail";
266   - //string mailBody = "MESSAGE: " + e.Message + ", STACKTRACE: " + e.StackTrace;
267   - //UserUtility.SendEmail(credentials, supportMailList, "", mailSubject, mailBody);
268   -
269   - //userDetails = AIAConstants.SQL_CONNECTION_ERROR;
  263 + throw;
270 264 }
271 265 }
272 266  
... ... @@ -285,13 +279,7 @@ namespace AIAHTML5.API.Models
285 279 catch (Exception e)
286 280 {
287 281 logger.Fatal("Exception in insertLoginDetails for UserId =" + userId + "Exception= " + e.Message + ", STACKTRACE: " + e.StackTrace);
288   -
289   - //ArrayList supportMailList = UserUtility.GetSupportMailList();
290   - //string mailSubject = "SQL Exception intimation mail";
291   - //string mailBody = "MESSAGE: " + e.Message + ", STACKTRACE: " + e.StackTrace;
292   - //UserUtility.SendEmail(credentials, supportMailList, "", mailSubject, mailBody);
293   -
294   - //userDetails = AIAConstants.SQL_CONNECTION_ERROR;
  282 + throw;
295 283 }
296 284  
297 285 return result;
... ... @@ -310,7 +298,7 @@ namespace AIAHTML5.API.Models
310 298 expirationDate = string.Empty;
311 299 bool isLicenseExpired = false;
312 300  
313   - if (subscriptionDetail != null)
  301 + if (subscriptionDetail.Id > 0)
314 302 {
315 303 DateTime? subscriptionValidThrough = subscriptionDetail.SubscriptionValidThrough;
316 304 if (subscriptionValidThrough != null && subscriptionValidThrough.Value.Date >= DateTime.Now.Date)
... ... @@ -342,13 +330,7 @@ namespace AIAHTML5.API.Models
342 330 catch (Exception e)
343 331 {
344 332 logger.Fatal("Exception in getModuleListByLicenseId for LicenseId =" + licenseId + "Exception= " + e.Message + ", STACKTRACE: " + e.StackTrace);
345   -
346   - //ArrayList supportMailList = UserUtility.GetSupportMailList();
347   - //string mailSubject = "SQL Exception intimation mail";
348   - //string mailBody = "MESSAGE: " + e.Message + ", STACKTRACE: " + e.StackTrace;
349   - //UserUtility.SendEmail(credentials, supportMailList, "", mailSubject, mailBody);
350   -
351   - //userDetails = AIAConstants.SQL_CONNECTION_ERROR;
  333 + throw;
352 334 }
353 335  
354 336 return licensedModulesList;
... ... @@ -370,13 +352,7 @@ namespace AIAHTML5.API.Models
370 352 catch (Exception e)
371 353 {
372 354 logger.Fatal("Exception in deletePastWrongAttempts for UserId =" + userId + "Exception= " + e.Message + ", STACKTRACE: " + e.StackTrace);
373   -
374   - //ArrayList supportMailList = UserUtility.GetSupportMailList();
375   - //string mailSubject = "SQL Exception intimation mail";
376   - //string mailBody = "MESSAGE: " + e.Message + ", STACKTRACE: " + e.StackTrace;
377   - //UserUtility.SendEmail(credentials, supportMailList, "", mailSubject, mailBody);
378   -
379   - //userDetails = AIAConstants.SQL_CONNECTION_ERROR;
  355 + throw;
380 356 }
381 357 return result;
382 358 }
... ... @@ -397,13 +373,7 @@ namespace AIAHTML5.API.Models
397 373 catch (Exception e)
398 374 {
399 375 logger.Fatal("Exception in checkNoOfWrongAttempts for UserId =" + userId + "Exception= " + e.Message + ", STACKTRACE: " + e.StackTrace);
400   -
401   - //ArrayList supportMailList = UserUtility.GetSupportMailList();
402   - //string mailSubject = "SQL Exception intimation mail";
403   - //string mailBody = "MESSAGE: " + e.Message + ", STACKTRACE: " + e.StackTrace;
404   - //UserUtility.SendEmail(credentials, supportMailList, "", mailSubject, mailBody);
405   -
406   - //userDetails = AIAConstants.SQL_CONNECTION_ERROR;
  376 + throw;
407 377 }
408 378 return result;
409 379 }
... ... @@ -432,13 +402,7 @@ namespace AIAHTML5.API.Models
432 402 catch (Exception e)
433 403 {
434 404 logger.Fatal("Exception in saveWrongAttemptofUser for UserId =" + userId + "Exception= " + e.Message + ", STACKTRACE: " + e.StackTrace);
435   -
436   - //ArrayList supportMailList = UserUtility.GetSupportMailList();
437   - //string mailSubject = "SQL Exception intimation mail";
438   - //string mailBody = "MESSAGE: " + e.Message + ", STACKTRACE: " + e.StackTrace;
439   - //UserUtility.SendEmail(credentials, supportMailList, "", mailSubject, mailBody);
440   -
441   - //userDetails = AIAConstants.SQL_CONNECTION_ERROR;
  405 + throw;
442 406 }
443 407  
444 408 return result;
... ... @@ -464,13 +428,7 @@ namespace AIAHTML5.API.Models
464 428 catch (Exception e)
465 429 {
466 430 logger.Fatal("Exception in isLicenseActive for LicenseId =" + licenseId + "Exception= " + e.Message + ", STACKTRACE: " + e.StackTrace);
467   -
468   - //ArrayList supportMailList = UserUtility.GetSupportMailList();
469   - //string mailSubject = "SQL Exception intimation mail";
470   - //string mailBody = "MESSAGE: " + e.Message + ", STACKTRACE: " + e.StackTrace;
471   - //UserUtility.SendEmail(credentials, supportMailList, "", mailSubject, mailBody);
472   -
473   - //userDetails = AIAConstants.SQL_CONNECTION_ERROR;
  431 + throw;
474 432 }
475 433 return result;
476 434 }
... ... @@ -490,13 +448,7 @@ namespace AIAHTML5.API.Models
490 448 catch (Exception e)
491 449 {
492 450 logger.Fatal("Exception in getLicenseDetails for LicenseId =" + licenseId + "Exception= " + e.Message + ", STACKTRACE: " + e.StackTrace);
493   -
494   - //ArrayList supportMailList = UserUtility.GetSupportMailList();
495   - //string mailSubject = "SQL Exception intimation mail";
496   - //string mailBody = "MESSAGE: " + e.Message + ", STACKTRACE: " + e.StackTrace;
497   - //UserUtility.SendEmail(credentials, supportMailList, "", mailSubject, mailBody);
498   -
499   - //userDetails = AIAConstants.SQL_CONNECTION_ERROR;
  451 + throw;
500 452 }
501 453 return userLicense;
502 454 }
... ... @@ -515,25 +467,17 @@ namespace AIAHTML5.API.Models
515 467 catch (Exception e)
516 468 {
517 469 logger.Fatal("Exception in getLicenseSubscriptionDetails for LicenseId =" + licenseId + "Exception= " + e.Message + ", STACKTRACE: " + e.StackTrace);
518   -
519   - //ArrayList supportMailList = UserUtility.GetSupportMailList();
520   - //string mailSubject = "SQL Exception intimation mail";
521   - //string mailBody = "MESSAGE: " + e.Message + ", STACKTRACE: " + e.StackTrace;
522   - //UserUtility.SendEmail(credentials, supportMailList, "", mailSubject, mailBody);
523   -
524   - //userDetails = AIAConstants.SQL_CONNECTION_ERROR;
  470 + throw;
525 471 }
526 472 return userSubscriptionDetail;
527 473 }
528 474  
529   - internal static void isCredentialCorrect(Newtonsoft.Json.Linq.JObject credentials, out bool isCorrectLoginId, out bool isCorrectPassword)
  475 + internal static void isCredentialCorrect(Newtonsoft.Json.Linq.JObject credentials, User userInfo, out bool isCorrectLoginId, out bool isCorrectPassword)
530 476 {
531 477 isCorrectLoginId = false;
532   - isCorrectPassword = false;
  478 + isCorrectPassword = false;
533 479  
534   - User userInfo = Users.getUserDetails(credentials);
535   -
536   - if (userInfo != null)
  480 + if (userInfo.Id> 0)
537 481 {
538 482 if (string.Equals(credentials["username"].ToString().ToUpper(), userInfo.LoginId.ToUpper()))
539 483 isCorrectLoginId = true;
... ... @@ -560,13 +504,7 @@ namespace AIAHTML5.API.Models
560 504 catch (Exception e)
561 505 {
562 506 logger.Fatal("Exception in insertUserLoginLog for accountNumber =" + accountNumber + "Exception= " + e.Message + ", STACKTRACE: " + e.StackTrace);
563   -
564   - //ArrayList supportMailList = UserUtility.GetSupportMailList();
565   - //string mailSubject = "SQL Exception intimation mail";
566   - //string mailBody = "MESSAGE: " + e.Message + ", STACKTRACE: " + e.StackTrace;
567   - //UserUtility.SendEmail(credentials, supportMailList, "", mailSubject, mailBody);
568   -
569   - //userDetails = AIAConstants.SQL_CONNECTION_ERROR;
  507 + throw;
570 508 }
571 509 return result;
572 510 }
... ... @@ -587,13 +525,7 @@ namespace AIAHTML5.API.Models
587 525 catch (Exception e)
588 526 {
589 527 logger.Fatal("Exception in getTermsOfServiceText, Exception= " + e.Message + ", STACKTRACE: " + e.StackTrace);
590   -
591   - //ArrayList supportMailList = UserUtility.GetSupportMailList();
592   - //string mailSubject = "SQL Exception intimation mail";
593   - //string mailBody = "MESSAGE: " + e.Message + ", STACKTRACE: " + e.StackTrace;
594   - //UserUtility.SendEmail(credentials, supportMailList, "", mailSubject, mailBody);
595   -
596   - //userDetails = AIAConstants.SQL_CONNECTION_ERROR;
  528 + throw;
597 529 }
598 530 return arrTermsOfService;
599 531 }
... ... @@ -612,13 +544,7 @@ namespace AIAHTML5.API.Models
612 544 catch (Exception e)
613 545 {
614 546 logger.Fatal("Exception in getAllModulesList, Exception= " + e.Message + ", STACKTRACE: " + e.StackTrace);
615   -
616   - //ArrayList supportMailList = UserUtility.GetSupportMailList();
617   - //string mailSubject = "SQL Exception intimation mail";
618   - //string mailBody = "MESSAGE: " + e.Message + ", STACKTRACE: " + e.StackTrace;
619   - //UserUtility.SendEmail(credentials, supportMailList, "", mailSubject, mailBody);
620   -
621   - //userDetails = AIAConstants.SQL_CONNECTION_ERROR;
  547 + throw;
622 548 }
623 549 return modulesList;
624 550 }
... ... @@ -637,7 +563,7 @@ namespace AIAHTML5.API.Models
637 563 DBModel objModel = new DBModel();
638 564 BlockedUser blockedUser = objModel.GetBlockedUserByUserId(userId);
639 565  
640   - if (blockedUser != null)
  566 + if (blockedUser.Id> 0)
641 567 {
642 568 blockTime = blockedUser.LoginTime;
643 569 result = true;
... ... @@ -649,13 +575,7 @@ namespace AIAHTML5.API.Models
649 575 catch (Exception e)
650 576 {
651 577 logger.Fatal("Exception in isUserBlocked for UserId =" + userId + "Exception= " + e.Message + ", STACKTRACE: " + e.StackTrace);
652   -
653   - //ArrayList supportMailList = UserUtility.GetSupportMailList();
654   - //string mailSubject = "SQL Exception intimation mail";
655   - //string mailBody = "MESSAGE: " + e.Message + ", STACKTRACE: " + e.StackTrace;
656   - //UserUtility.SendEmail(credentials, supportMailList, "", mailSubject, mailBody);
657   -
658   - //userDetails = AIAConstants.SQL_CONNECTION_ERROR;
  578 + throw;
659 579 }
660 580  
661 581 return result;
... ...
400-SOURCECODE/AIAHTML5.API/Utility/EmailUtility.cs
1   -๏ปฟusing System;
2   -using System.Collections.Generic;
3   -using System.Linq;
4   -using System.Web;
5   -using System.Configuration;
6   -using System.Collections;
7   -using System.Xml;
8   -using System.Text;
9   -using System.IO;
  1 +๏ปฟusing System;
  2 +using System.Collections.Generic;
  3 +using System.Linq;
  4 +using System.Web;
  5 +using System.Configuration;
  6 +using System.Collections;
  7 +using System.Xml;
  8 +using System.Text;
  9 +using System.IO;
10 10 using System.Net.Mail;
11   -using log4net;
12   -
13   -namespace AIAHTML5.API.Utility
14   -{
15   -
16   - public class EmailUtility
17   - {
18   - public string sFromAddress { get; set; }
19   - public List<string> sToAddresses { get; set; }
20   - public List<string> sBccAddresses { get; set; }
21   - public string sHostName { get; set; }
22   - public string sSubject { get; set; }
23   - public int iPort { get; set; }
24   - public bool bEnableSsl { get; set; }
25   - public string sUserName { get; set; }
26   - public string sPassword { get; set; }
27   - public bool bIsBodyHtml { get; set; }
28   - public List<Attachment> sAttachments { get; set; }
29   - public string sBodyText { get; set; }
30   - public AlternateView sAlternateView { get; set; }
31   -
32   - public void SendMail(MailMessage mm)
33   - {
34   - SmtpClient smtp = new SmtpClient();
35   - smtp.Host = ConfigurationManager.AppSettings["SMTPAddress"];
36   - smtp.EnableSsl = Convert.ToBoolean(ConfigurationManager.AppSettings["EnableSSL"]);
37   - System.Net.NetworkCredential NetworkCred = new System.Net.NetworkCredential(mm.From.ToString(), ConfigurationManager.AppSettings["SenderPassword"]);
38   - smtp.Credentials = NetworkCred;
39   - smtp.Port = Convert.ToInt32(ConfigurationManager.AppSettings["SMTPPort"]);
40   -
41   - smtp.Send(mm);
42   - }
43   -
44   - public void SendSmtpEmail()
  11 +using log4net;
  12 +
  13 +namespace AIAHTML5.API.Utility
  14 +{
  15 +
  16 + public class EmailUtility
  17 + {
  18 + public string sFromAddress { get; set; }
  19 + public List<string> sToAddresses { get; set; }
  20 + public List<string> sBccAddresses { get; set; }
  21 + public string sHostName { get; set; }
  22 + public string sSubject { get; set; }
  23 + public int iPort { get; set; }
  24 + public bool bEnableSsl { get; set; }
  25 + public string sUserName { get; set; }
  26 + public string sPassword { get; set; }
  27 + public bool bIsBodyHtml { get; set; }
  28 + public List<Attachment> sAttachments { get; set; }
  29 + public string sBodyText { get; set; }
  30 + public AlternateView sAlternateView { get; set; }
  31 +
  32 + public void SendMail(MailMessage mm)
  33 + {
  34 + SmtpClient smtp = new SmtpClient();
  35 + smtp.Host = ConfigurationManager.AppSettings["SMTPAddress"];
  36 + smtp.EnableSsl = Convert.ToBoolean(ConfigurationManager.AppSettings["EnableSSL"]);
  37 + System.Net.NetworkCredential NetworkCred = new System.Net.NetworkCredential(mm.From.ToString(), ConfigurationManager.AppSettings["SenderPassword"]);
  38 + smtp.Credentials = NetworkCred;
  39 + smtp.Port = Convert.ToInt32(ConfigurationManager.AppSettings["SMTPPort"]);
  40 +
  41 + smtp.Send(mm);
  42 + }
  43 +
  44 + public void SendSmtpEmail()
45 45 {
46 46 ILog logger = log4net.LogManager.GetLogger((System.Reflection.MethodBase.GetCurrentMethod().DeclaringType));
47   - logger.Debug("inside SendSmtpEmail");
48   -
49   - try
50   - {
51   - MailMessage sMail = new MailMessage();
52   - SmtpClient SmtpServer = new SmtpClient(sHostName);
53   - string recipientEmailAddress = string.Empty;
54   -
55   -
56   - if (sToAddresses != null)
57   - {
58   - foreach (var sItem in sToAddresses)
59   - {
  47 + logger.Debug("inside SendSmtpEmail");
  48 +
  49 + try
  50 + {
  51 + MailMessage sMail = new MailMessage();
  52 + SmtpClient SmtpServer = new SmtpClient(sHostName);
  53 + string recipientEmailAddress = string.Empty;
  54 +
  55 +
  56 + if (sToAddresses != null)
  57 + {
  58 + foreach (var sItem in sToAddresses)
  59 + {
60 60 sMail.To.Add(sItem);
61   - logger.Debug("sToAddresses= " + sItem);
62   - }
63   - }
64   -
65   - if (sBccAddresses != null)
66   - {
67   - foreach (var sItem in sBccAddresses)
68   - {
  61 + logger.Debug("sToAddresses= " + sItem);
  62 + }
  63 + }
  64 +
  65 + if (sBccAddresses != null)
  66 + {
  67 + foreach (var sItem in sBccAddresses)
  68 + {
69 69 sMail.Bcc.Add(sItem);
70   - logger.Debug("sBccAddresses= " + sItem);
71   -
72   - }
73   - }
74   -
75   - sMail.IsBodyHtml = bIsBodyHtml;
76   -
77   - if (sAlternateView != null)
78   - {
  70 + logger.Debug("sBccAddresses= " + sItem);
  71 +
  72 + }
  73 + }
  74 +
  75 + sMail.IsBodyHtml = bIsBodyHtml;
  76 +
  77 + if (sAlternateView != null)
  78 + {
79 79 sMail.AlternateViews.Add(sAlternateView);
80   - logger.Debug("sAlternateView= " + sAlternateView);
81   -
82   - }
83   - else
84   - {
  80 + logger.Debug("sAlternateView= " + sAlternateView);
  81 +
  82 + }
  83 + else
  84 + {
85 85 sMail.Body = sBodyText;
86   - logger.Debug("sMail.Body= " + sBodyText);
87   -
88   - }
89   -
  86 + logger.Debug("sMail.Body= " + sBodyText);
  87 +
  88 + }
  89 +
90 90 sMail.Subject = sSubject;
91   - logger.Debug("sMail.Subject= " + sSubject);
92   -
93   - if (sAttachments != null)
94   - {
95   - foreach (var sItem in sAttachments)
96   - {
  91 + logger.Debug("sMail.Subject= " + sSubject);
  92 +
  93 + if (sAttachments != null)
  94 + {
  95 + foreach (var sItem in sAttachments)
  96 + {
97 97 sMail.Attachments.Add(sItem);
98   - logger.Debug("sAttachments= " + sAttachments);
99   -
100   -
101   - }
  98 + logger.Debug("sAttachments= " + sAttachments);
  99 +
  100 +
  101 + }
102 102 }
103   - logger.Debug("sUserName= " + sUserName + ", sPassword= " + sPassword);
104   -
105   - SmtpServer.Port = iPort;
106   - SmtpServer.Credentials = new System.Net.NetworkCredential(sUserName, sPassword);
107   - SmtpServer.EnableSsl = bEnableSsl;
108   -
109   - using (MailMessage mm = new MailMessage(sFromAddress, sMail.To.ToString()))
110   - {
111   - mm.Subject = sSubject;
112   - mm.IsBodyHtml = bIsBodyHtml;
113   -
114   - if (sAlternateView != null)
115   - {
116   - mm.AlternateViews.Add(sAlternateView);
117   - }
118   - else
119   - {
120   - mm.Body = sBodyText;
121   - }
122   -
123   - mm.IsBodyHtml = true;
  103 + logger.Debug("sUserName= " + sUserName + ", sPassword= " + sPassword);
  104 +
  105 + SmtpServer.Port = iPort;
  106 + SmtpServer.Credentials = new System.Net.NetworkCredential(sUserName, sPassword);
  107 + SmtpServer.EnableSsl = bEnableSsl;
  108 +
  109 + using (MailMessage mm = new MailMessage(sFromAddress, sMail.To.ToString()))
  110 + {
  111 + mm.Subject = sSubject;
  112 + mm.IsBodyHtml = bIsBodyHtml;
  113 +
  114 + if (sAlternateView != null)
  115 + {
  116 + mm.AlternateViews.Add(sAlternateView);
  117 + }
  118 + else
  119 + {
  120 + mm.Body = sBodyText;
  121 + }
  122 +
  123 + mm.IsBodyHtml = true;
124 124 SendMail(mm);
125   - logger.Debug("after sending email");
126   - }
127   -
128   - }
129   - catch (Exception ex)
  125 + logger.Debug("after sending email");
  126 + }
  127 +
  128 + }
  129 + catch (Exception ex)
130 130 {
131   - logger.Fatal("exception in SendSmtpEmail.msg= " + ex.Message + ", stacktarce= " + ex.StackTrace);
132   - throw ex;
133   - }
134   - }
135   - }
  131 + logger.Fatal("exception in SendSmtpEmail.msg= " + ex.Message + ", stacktarce= " + ex.StackTrace);
  132 + throw ex;
  133 + }
  134 + }
  135 + }
136 136 }
137 137 \ No newline at end of file
... ...