Commit 0b600801a95c4bc77405a8f1f616b0e0815288fc
Merge branch 'SQLException1' of http://52.6.196.163/ADAM/AIAHTML5 into Develop-IPAD-MAC
Showing
1 changed file
with
380 additions
and
383 deletions
400-SOURCECODE/AIAHTML5.API/Models/DBModel.cs
1 | -using System; | |
1 | +using System; | |
2 | 2 | using System.Collections.Generic; |
3 | 3 | using System.Linq; |
4 | 4 | using System.Web; |
... | ... | @@ -16,35 +16,26 @@ namespace AIAHTML5.API.Models |
16 | 16 | { |
17 | 17 | static string dbConnectionString = System.Configuration.ConfigurationManager.AppSettings["AIADatabaseV5Context"]; |
18 | 18 | |
19 | - static SqlConnection conn; | |
20 | - static SqlCommand cmd; | |
21 | 19 | |
22 | 20 | private static readonly ILog logger = LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType); |
23 | 21 | |
24 | 22 | |
25 | 23 | public DBModel() { } |
26 | 24 | |
27 | - public static void OpenConnection() | |
28 | - { | |
29 | - SqlConnection conn = new SqlConnection(dbConnectionString); | |
30 | - | |
31 | - if (conn.State == ConnectionState.Closed) | |
32 | - conn.Open(); | |
33 | - } | |
34 | 25 | |
35 | 26 | protected static DataSet GetDataFromStoredProcedure(string commandText) |
36 | 27 | { |
37 | 28 | |
38 | 29 | logger.Debug(" Inside GetSQLData for command text = " + commandText); |
39 | 30 | DataSet ds = null; |
40 | - SqlConnection conn = new SqlConnection(dbConnectionString); | |
41 | - cmd = new SqlCommand(commandText, conn); | |
42 | - cmd.CommandType = CommandType.StoredProcedure; | |
43 | - SqlDataAdapter da = new SqlDataAdapter(); | |
44 | - da.SelectCommand = cmd; | |
45 | - ds = new DataSet(); | |
46 | - da.Fill(ds); | |
47 | - | |
31 | + SqlConnection conn = new SqlConnection(dbConnectionString); | |
32 | + SqlCommand cmd = new SqlCommand(commandText, conn); | |
33 | + cmd.CommandType = CommandType.StoredProcedure; | |
34 | + SqlDataAdapter da = new SqlDataAdapter(); | |
35 | + da.SelectCommand = cmd; | |
36 | + ds = new DataSet(); | |
37 | + da.Fill(ds); | |
38 | + | |
48 | 39 | return ds; |
49 | 40 | } |
50 | 41 | |
... | ... | @@ -54,26 +45,26 @@ namespace AIAHTML5.API.Models |
54 | 45 | |
55 | 46 | ArrayList arrUserModules = new ArrayList(); |
56 | 47 | |
57 | - Hashtable userModuleHash = new Hashtable(); | |
48 | + Hashtable userModuleHash = new Hashtable(); | |
58 | 49 | |
59 | - string sp = DBConstants.GET_ALL_MODULES; | |
50 | + string sp = DBConstants.GET_ALL_MODULES; | |
60 | 51 | |
61 | - DataSet ds = DBModel.GetDataFromStoredProcedure(sp); | |
52 | + DataSet ds = DBModel.GetDataFromStoredProcedure(sp); | |
62 | 53 | |
63 | - if (ds!= null && ds.Tables.Count > 0) | |
64 | - { | |
65 | - DataTable dt = ds.Tables[0]; | |
54 | + if (ds != null && ds.Tables.Count > 0) | |
55 | + { | |
56 | + DataTable dt = ds.Tables[0]; | |
66 | 57 | |
67 | - foreach (DataRow drModule in dt.Rows) | |
68 | - { | |
69 | - userModuleHash = new Hashtable(); | |
70 | - userModuleHash.Add(AIAConstants.KEY_ID, drModule["Id"]); | |
71 | - userModuleHash.Add(AIAConstants.KEY_NAME, drModule["Name"]); | |
72 | - userModuleHash.Add(AIAConstants.KEY_SLUG, drModule["Slug"]); | |
73 | - arrUserModules.Add(userModuleHash); | |
74 | - } | |
58 | + foreach (DataRow drModule in dt.Rows) | |
59 | + { | |
60 | + userModuleHash = new Hashtable(); | |
61 | + userModuleHash.Add(AIAConstants.KEY_ID, drModule["Id"]); | |
62 | + userModuleHash.Add(AIAConstants.KEY_NAME, drModule["Name"]); | |
63 | + userModuleHash.Add(AIAConstants.KEY_SLUG, drModule["Slug"]); | |
64 | + arrUserModules.Add(userModuleHash); | |
75 | 65 | } |
76 | - | |
66 | + } | |
67 | + | |
77 | 68 | return arrUserModules; |
78 | 69 | } |
79 | 70 | |
... | ... | @@ -84,55 +75,55 @@ namespace AIAHTML5.API.Models |
84 | 75 | User objUser = null; |
85 | 76 | DBModel objModel = new DBModel(); |
86 | 77 | |
87 | - | |
88 | - conn = new SqlConnection(dbConnectionString); | |
89 | - cmd = new SqlCommand(); | |
90 | - SqlDataAdapter da = new SqlDataAdapter(); | |
91 | - SqlParameter param; | |
92 | - DataSet ds = new DataSet(); | |
93 | 78 | |
94 | - cmd.Connection = conn; | |
95 | - cmd.CommandText = DBConstants.GET_USER_DELAILS_BY_LOGIN_ID; | |
96 | - cmd.CommandType = CommandType.StoredProcedure; | |
79 | + SqlConnection conn = new SqlConnection(dbConnectionString); | |
80 | + SqlCommand cmd = new SqlCommand(); | |
81 | + SqlDataAdapter da = new SqlDataAdapter(); | |
82 | + SqlParameter param; | |
83 | + DataSet ds = new DataSet(); | |
97 | 84 | |
98 | - param = new SqlParameter("@sLoginId", loginId); | |
99 | - param.Direction = ParameterDirection.Input; | |
100 | - param.DbType = DbType.String; | |
101 | - cmd.Parameters.Add(param); | |
102 | - | |
103 | - da.SelectCommand = cmd; | |
104 | - DataTable dt = new DataTable(); | |
105 | - da.Fill(dt); | |
106 | - | |
107 | - | |
108 | - if (dt!= null && dt.Rows.Count > 0) | |
109 | - { | |
110 | - foreach (DataRow dr in dt.Rows) | |
111 | - { | |
112 | - int tempVal; | |
113 | - DateTime date; | |
114 | - objUser = new User(); | |
85 | + cmd.Connection = conn; | |
86 | + cmd.CommandText = DBConstants.GET_USER_DELAILS_BY_LOGIN_ID; | |
87 | + cmd.CommandType = CommandType.StoredProcedure; | |
115 | 88 | |
116 | - objUser.Id = Convert.ToInt32(dr["Id"]); | |
117 | - objUser.FirstName = dr["FirstName"].ToString(); | |
118 | - objUser.LastName = dr["LastName"].ToString(); | |
119 | - objUser.EmailId = dr["EmailId"].ToString(); | |
120 | - objUser.LoginId = dr["LoginId"].ToString(); | |
121 | - objUser.Password = dr["Password"].ToString(); | |
122 | - objUser.SecurityQuestionId =Int32.TryParse(dr["SecurityQuestionId"].ToString(), out tempVal) ? tempVal : (int?)null; | |
123 | - objUser.SecurityAnswer = dr["SecurityAnswer"].ToString(); ; | |
124 | - objUser.CreatorId = Int32.TryParse(dr["CreatorId"].ToString(), out tempVal) ? tempVal : (int?)null; | |
125 | - objUser.CreationDate = Convert.ToDateTime(dr["CreationDate"]); | |
126 | - objUser.DeactivationDate = DateTime.TryParse(dr["DeactivationDate"].ToString(), out date) ? date : (DateTime?)null; | |
127 | - objUser.ModifierId = Int32.TryParse(dr["ModifierId"].ToString(), out tempVal) ? tempVal : (int?)null; | |
128 | - objUser.ModifiedDate = DateTime.TryParse(dr["ModifiedDate"].ToString(), out date) ? date : (DateTime?)null; | |
129 | - objUser.UserTypeId = Convert.ToInt32(dr["UserTypeId"]); | |
130 | - objUser.UserType = objModel.GetUserTypeStringById(Convert.ToInt32(dr["UserTypeId"])); | |
131 | - objUser.IsActive = Convert.ToBoolean(dr["IsActive"]); | |
132 | - } | |
89 | + param = new SqlParameter("@sLoginId", loginId); | |
90 | + param.Direction = ParameterDirection.Input; | |
91 | + param.DbType = DbType.String; | |
92 | + cmd.Parameters.Add(param); | |
93 | + | |
94 | + da.SelectCommand = cmd; | |
95 | + DataTable dt = new DataTable(); | |
96 | + da.Fill(dt); | |
97 | + | |
98 | + | |
99 | + if (dt != null && dt.Rows.Count > 0) | |
100 | + { | |
101 | + foreach (DataRow dr in dt.Rows) | |
102 | + { | |
103 | + int tempVal; | |
104 | + DateTime date; | |
105 | + objUser = new User(); | |
106 | + | |
107 | + objUser.Id = Convert.ToInt32(dr["Id"]); | |
108 | + objUser.FirstName = dr["FirstName"].ToString(); | |
109 | + objUser.LastName = dr["LastName"].ToString(); | |
110 | + objUser.EmailId = dr["EmailId"].ToString(); | |
111 | + objUser.LoginId = dr["LoginId"].ToString(); | |
112 | + objUser.Password = dr["Password"].ToString(); | |
113 | + objUser.SecurityQuestionId = Int32.TryParse(dr["SecurityQuestionId"].ToString(), out tempVal) ? tempVal : (int?)null; | |
114 | + objUser.SecurityAnswer = dr["SecurityAnswer"].ToString(); ; | |
115 | + objUser.CreatorId = Int32.TryParse(dr["CreatorId"].ToString(), out tempVal) ? tempVal : (int?)null; | |
116 | + objUser.CreationDate = Convert.ToDateTime(dr["CreationDate"]); | |
117 | + objUser.DeactivationDate = DateTime.TryParse(dr["DeactivationDate"].ToString(), out date) ? date : (DateTime?)null; | |
118 | + objUser.ModifierId = Int32.TryParse(dr["ModifierId"].ToString(), out tempVal) ? tempVal : (int?)null; | |
119 | + objUser.ModifiedDate = DateTime.TryParse(dr["ModifiedDate"].ToString(), out date) ? date : (DateTime?)null; | |
120 | + objUser.UserTypeId = Convert.ToInt32(dr["UserTypeId"]); | |
121 | + objUser.UserType = objModel.GetUserTypeStringById(Convert.ToInt32(dr["UserTypeId"])); | |
122 | + objUser.IsActive = Convert.ToBoolean(dr["IsActive"]); | |
133 | 123 | } |
134 | - | |
135 | - | |
124 | + } | |
125 | + | |
126 | + | |
136 | 127 | return objUser; |
137 | 128 | } |
138 | 129 | |
... | ... | @@ -142,33 +133,33 @@ namespace AIAHTML5.API.Models |
142 | 133 | |
143 | 134 | Hashtable hash = new Hashtable(); |
144 | 135 | |
145 | - conn = new SqlConnection(dbConnectionString); | |
146 | - cmd = new SqlCommand(); | |
147 | - SqlDataAdapter adapter; | |
148 | - SqlParameter param; | |
149 | - DataSet ds = new DataSet(); | |
136 | + SqlConnection conn = new SqlConnection(dbConnectionString); | |
137 | + SqlCommand cmd = new SqlCommand(); | |
138 | + SqlDataAdapter adapter; | |
139 | + SqlParameter param; | |
140 | + DataSet ds = new DataSet(); | |
150 | 141 | |
151 | - cmd.Connection = conn; | |
152 | - cmd.CommandText = DBConstants.GET_LICENSE_DETAILS_BY_USER_ID; | |
153 | - cmd.CommandType = CommandType.StoredProcedure; | |
142 | + cmd.Connection = conn; | |
143 | + cmd.CommandText = DBConstants.GET_LICENSE_DETAILS_BY_USER_ID; | |
144 | + cmd.CommandType = CommandType.StoredProcedure; | |
154 | 145 | |
155 | - param = new SqlParameter("@iUserId", userId); | |
156 | - param.Direction = ParameterDirection.Input; | |
157 | - param.DbType = DbType.Int32; | |
158 | - cmd.Parameters.Add(param); | |
146 | + param = new SqlParameter("@iUserId", userId); | |
147 | + param.Direction = ParameterDirection.Input; | |
148 | + param.DbType = DbType.Int32; | |
149 | + cmd.Parameters.Add(param); | |
159 | 150 | |
160 | - adapter = new SqlDataAdapter(cmd); | |
161 | - adapter.Fill(ds); | |
151 | + adapter = new SqlDataAdapter(cmd); | |
152 | + adapter.Fill(ds); | |
162 | 153 | |
163 | - if (ds!= null && ds.Tables.Count > 0) | |
154 | + if (ds != null && ds.Tables.Count > 0) | |
155 | + { | |
156 | + if (ds.Tables[0].Rows.Count > 0) | |
164 | 157 | { |
165 | - if (ds.Tables[0].Rows.Count > 0) | |
166 | - { | |
167 | - hash.Add(AIAConstants.LICENSE_KEY_ID, ds.Tables[0].Rows[0][0]); | |
168 | - hash.Add(AIAConstants.EDITION_KEY_ID, ds.Tables[0].Rows[0][1]); | |
169 | - } | |
158 | + hash.Add(AIAConstants.LICENSE_KEY_ID, ds.Tables[0].Rows[0][0]); | |
159 | + hash.Add(AIAConstants.EDITION_KEY_ID, ds.Tables[0].Rows[0][1]); | |
170 | 160 | } |
171 | - | |
161 | + } | |
162 | + | |
172 | 163 | return hash; |
173 | 164 | } |
174 | 165 | |
... | ... | @@ -178,45 +169,45 @@ namespace AIAHTML5.API.Models |
178 | 169 | |
179 | 170 | ArrayList userModulelist = new ArrayList(); |
180 | 171 | |
181 | - Hashtable modulesHash; | |
182 | - DataSet ds = new DataSet(); | |
172 | + Hashtable modulesHash; | |
173 | + DataSet ds = new DataSet(); | |
183 | 174 | |
184 | - conn = new SqlConnection(dbConnectionString); | |
185 | - cmd = new SqlCommand(); | |
186 | - SqlDataAdapter adapter; | |
187 | - SqlParameter param; | |
175 | + SqlConnection conn = new SqlConnection(dbConnectionString); | |
176 | + SqlCommand cmd = new SqlCommand(); | |
177 | + SqlDataAdapter adapter; | |
178 | + SqlParameter param; | |
188 | 179 | |
189 | - cmd.Connection = conn; | |
190 | - cmd.CommandText = DBConstants.GET_USER_MODULES_BY_LICENSE_ID; | |
191 | - cmd.CommandType = CommandType.StoredProcedure; | |
180 | + cmd.Connection = conn; | |
181 | + cmd.CommandText = DBConstants.GET_USER_MODULES_BY_LICENSE_ID; | |
182 | + cmd.CommandType = CommandType.StoredProcedure; | |
192 | 183 | |
193 | - param = new SqlParameter("@iLicenseId", licenseId); | |
194 | - param.Direction = ParameterDirection.Input; | |
195 | - param.DbType = DbType.Int32; | |
196 | - cmd.Parameters.Add(param); | |
184 | + param = new SqlParameter("@iLicenseId", licenseId); | |
185 | + param.Direction = ParameterDirection.Input; | |
186 | + param.DbType = DbType.Int32; | |
187 | + cmd.Parameters.Add(param); | |
197 | 188 | |
198 | - adapter = new SqlDataAdapter(cmd); | |
199 | - adapter.Fill(ds); | |
200 | - | |
189 | + adapter = new SqlDataAdapter(cmd); | |
190 | + adapter.Fill(ds); | |
201 | 191 | |
202 | - if (ds!=null && ds.Tables.Count > 0) | |
203 | - { | |
204 | - DataTable dt = ds.Tables[0]; | |
205 | 192 | |
206 | - if (dt.Rows.Count > 0) | |
193 | + if (ds != null && ds.Tables.Count > 0) | |
194 | + { | |
195 | + DataTable dt = ds.Tables[0]; | |
196 | + | |
197 | + if (dt.Rows.Count > 0) | |
198 | + { | |
199 | + foreach (DataRow dr in dt.Rows) | |
207 | 200 | { |
208 | - foreach (DataRow dr in dt.Rows) | |
209 | - { | |
210 | - modulesHash = new Hashtable(); | |
211 | - modulesHash.Add(AIAConstants.KEY_ID, dr["Id"]); | |
212 | - modulesHash.Add(AIAConstants.KEY_NAME, dr["Title"]); | |
213 | - modulesHash.Add(AIAConstants.KEY_SLUG, dr["Slug"]); | |
214 | - userModulelist.Add(modulesHash); | |
215 | - } | |
201 | + modulesHash = new Hashtable(); | |
202 | + modulesHash.Add(AIAConstants.KEY_ID, dr["Id"]); | |
203 | + modulesHash.Add(AIAConstants.KEY_NAME, dr["Title"]); | |
204 | + modulesHash.Add(AIAConstants.KEY_SLUG, dr["Slug"]); | |
205 | + userModulelist.Add(modulesHash); | |
216 | 206 | } |
217 | 207 | } |
218 | - | |
219 | - | |
208 | + } | |
209 | + | |
210 | + | |
220 | 211 | return userModulelist; |
221 | 212 | } |
222 | 213 | |
... | ... | @@ -264,57 +255,57 @@ namespace AIAHTML5.API.Models |
264 | 255 | User objUser = null; |
265 | 256 | DBModel objModel = new DBModel(); |
266 | 257 | |
267 | - conn = new SqlConnection(dbConnectionString); | |
268 | - cmd = new SqlCommand(); | |
269 | - SqlDataAdapter adapter; | |
270 | - SqlParameter param; | |
271 | - DataSet ds = new DataSet(); | |
258 | + SqlConnection conn = new SqlConnection(dbConnectionString); | |
259 | + SqlCommand cmd = new SqlCommand(); | |
260 | + SqlDataAdapter adapter; | |
261 | + SqlParameter param; | |
262 | + DataSet ds = new DataSet(); | |
272 | 263 | |
273 | - cmd.Connection = conn; | |
274 | - cmd.CommandText = DBConstants.GET_USER_DETAILS_BY_EMAILID; | |
275 | - cmd.CommandType = CommandType.StoredProcedure; | |
264 | + cmd.Connection = conn; | |
265 | + cmd.CommandText = DBConstants.GET_USER_DETAILS_BY_EMAILID; | |
266 | + cmd.CommandType = CommandType.StoredProcedure; | |
276 | 267 | |
277 | - param = new SqlParameter("@sEmailId", emailId); | |
278 | - param.Direction = ParameterDirection.Input; | |
279 | - param.DbType = DbType.String; | |
280 | - cmd.Parameters.Add(param); | |
268 | + param = new SqlParameter("@sEmailId", emailId); | |
269 | + param.Direction = ParameterDirection.Input; | |
270 | + param.DbType = DbType.String; | |
271 | + cmd.Parameters.Add(param); | |
281 | 272 | |
282 | - adapter = new SqlDataAdapter(cmd); | |
283 | - adapter.Fill(ds); | |
273 | + adapter = new SqlDataAdapter(cmd); | |
274 | + adapter.Fill(ds); | |
284 | 275 | |
285 | 276 | |
286 | - if (ds!= null && ds.Tables.Count > 0) | |
287 | - { | |
288 | - DataTable dt = ds.Tables[0]; | |
277 | + if (ds != null && ds.Tables.Count > 0) | |
278 | + { | |
279 | + DataTable dt = ds.Tables[0]; | |
289 | 280 | |
290 | - if (dt.Rows.Count > 0) | |
281 | + if (dt.Rows.Count > 0) | |
282 | + { | |
283 | + foreach (DataRow dr in dt.Rows) | |
291 | 284 | { |
292 | - foreach (DataRow dr in dt.Rows) | |
293 | - { | |
294 | - int tempVal; | |
295 | - DateTime date; | |
296 | - objUser = new User(); | |
297 | - | |
298 | - objUser.Id = Convert.ToInt32(dr["Id"]); | |
299 | - objUser.FirstName = dr["FirstName"].ToString(); | |
300 | - objUser.LastName = dr["LastName"].ToString(); | |
301 | - objUser.EmailId = dr["EmailId"].ToString(); | |
302 | - objUser.LoginId = dr["LoginId"].ToString(); | |
303 | - objUser.Password = dr["Password"].ToString(); | |
304 | - objUser.SecurityQuestionId = Int32.TryParse(dr["SecurityQuestionId"].ToString(), out tempVal) ? tempVal : (int?)null; | |
305 | - objUser.SecurityAnswer = dr["SecurityAnswer"].ToString(); ; | |
306 | - objUser.CreatorId = Int32.TryParse(dr["CreatorId"].ToString(), out tempVal) ? tempVal : (int?)null; | |
307 | - objUser.CreationDate = Convert.ToDateTime(dr["CreationDate"]); | |
308 | - objUser.DeactivationDate = DateTime.TryParse(dr["DeactivationDate"].ToString(), out date) ? date : (DateTime?)null; | |
309 | - objUser.ModifierId = Int32.TryParse(dr["ModifierId"].ToString(), out tempVal) ? tempVal : (int?)null; | |
310 | - objUser.ModifiedDate = DateTime.TryParse(dr["ModifiedDate"].ToString(), out date) ? date : (DateTime?)null; | |
311 | - objUser.UserTypeId = Convert.ToInt32(dr["UserTypeId"]); | |
312 | - objUser.UserType = objModel.GetUserTypeStringById(Convert.ToInt32(dr["UserTypeId"])); | |
313 | - objUser.IsActive = Convert.ToBoolean(dr["IsActive"]); | |
314 | - } | |
285 | + int tempVal; | |
286 | + DateTime date; | |
287 | + objUser = new User(); | |
288 | + | |
289 | + objUser.Id = Convert.ToInt32(dr["Id"]); | |
290 | + objUser.FirstName = dr["FirstName"].ToString(); | |
291 | + objUser.LastName = dr["LastName"].ToString(); | |
292 | + objUser.EmailId = dr["EmailId"].ToString(); | |
293 | + objUser.LoginId = dr["LoginId"].ToString(); | |
294 | + objUser.Password = dr["Password"].ToString(); | |
295 | + objUser.SecurityQuestionId = Int32.TryParse(dr["SecurityQuestionId"].ToString(), out tempVal) ? tempVal : (int?)null; | |
296 | + objUser.SecurityAnswer = dr["SecurityAnswer"].ToString(); ; | |
297 | + objUser.CreatorId = Int32.TryParse(dr["CreatorId"].ToString(), out tempVal) ? tempVal : (int?)null; | |
298 | + objUser.CreationDate = Convert.ToDateTime(dr["CreationDate"]); | |
299 | + objUser.DeactivationDate = DateTime.TryParse(dr["DeactivationDate"].ToString(), out date) ? date : (DateTime?)null; | |
300 | + objUser.ModifierId = Int32.TryParse(dr["ModifierId"].ToString(), out tempVal) ? tempVal : (int?)null; | |
301 | + objUser.ModifiedDate = DateTime.TryParse(dr["ModifiedDate"].ToString(), out date) ? date : (DateTime?)null; | |
302 | + objUser.UserTypeId = Convert.ToInt32(dr["UserTypeId"]); | |
303 | + objUser.UserType = objModel.GetUserTypeStringById(Convert.ToInt32(dr["UserTypeId"])); | |
304 | + objUser.IsActive = Convert.ToBoolean(dr["IsActive"]); | |
315 | 305 | } |
316 | 306 | } |
317 | - | |
307 | + } | |
308 | + | |
318 | 309 | return objUser; |
319 | 310 | } |
320 | 311 | |
... | ... | @@ -324,10 +315,11 @@ namespace AIAHTML5.API.Models |
324 | 315 | |
325 | 316 | int result = 0; |
326 | 317 | |
318 | + SqlConnection conn = null; | |
327 | 319 | try |
328 | 320 | { |
329 | 321 | conn = new SqlConnection(dbConnectionString); |
330 | - cmd = new SqlCommand(); | |
322 | + SqlCommand cmd = new SqlCommand(); | |
331 | 323 | conn.Open(); |
332 | 324 | cmd.Connection = conn; |
333 | 325 | cmd.CommandText = DBConstants.UPDATE_USER_PASSWORD; |
... | ... | @@ -336,7 +328,7 @@ namespace AIAHTML5.API.Models |
336 | 328 | cmd.Parameters.AddWithValue("@sEmailId", emailId); |
337 | 329 | cmd.Parameters.AddWithValue("@sNewPassword", userInfo["newPassword"].ToString()); |
338 | 330 | result = cmd.ExecuteNonQuery(); |
339 | - | |
331 | + | |
340 | 332 | } |
341 | 333 | catch (SqlException ex) |
342 | 334 | { |
... | ... | @@ -356,53 +348,53 @@ namespace AIAHTML5.API.Models |
356 | 348 | logger.Debug(" Inside GetLicenseSubscriptionDetailsByLicenseId for LicenseId = " + licenseId); |
357 | 349 | |
358 | 350 | LicenseSubscriptionDetails licenseSubscriptionDetails = null; |
359 | - | |
360 | - conn = new SqlConnection(dbConnectionString); | |
361 | - cmd = new SqlCommand(); | |
362 | - SqlDataAdapter adapter; | |
363 | - SqlParameter param; | |
364 | - DataSet ds = new DataSet(); | |
365 | 351 | |
366 | - cmd.Connection = conn; | |
367 | - cmd.CommandText = DBConstants.GET_SUBSCRIPTION_DETAILS_BY_LICENSE_ID; | |
368 | - cmd.CommandType = CommandType.StoredProcedure; | |
352 | + SqlConnection conn = new SqlConnection(dbConnectionString); | |
353 | + SqlCommand cmd = new SqlCommand(); | |
354 | + SqlDataAdapter adapter; | |
355 | + SqlParameter param; | |
356 | + DataSet ds = new DataSet(); | |
369 | 357 | |
370 | - param = new SqlParameter("@iLicenseId", licenseId); | |
371 | - param.Direction = ParameterDirection.Input; | |
372 | - param.DbType = DbType.Int32; | |
373 | - cmd.Parameters.Add(param); | |
358 | + cmd.Connection = conn; | |
359 | + cmd.CommandText = DBConstants.GET_SUBSCRIPTION_DETAILS_BY_LICENSE_ID; | |
360 | + cmd.CommandType = CommandType.StoredProcedure; | |
374 | 361 | |
375 | - adapter = new SqlDataAdapter(cmd); | |
376 | - adapter.Fill(ds); | |
362 | + param = new SqlParameter("@iLicenseId", licenseId); | |
363 | + param.Direction = ParameterDirection.Input; | |
364 | + param.DbType = DbType.Int32; | |
365 | + cmd.Parameters.Add(param); | |
377 | 366 | |
378 | - if (ds!= null && ds.Tables.Count > 0) | |
379 | - { | |
380 | - licenseSubscriptionDetails = new LicenseSubscriptionDetails(); | |
381 | - DataTable dt = ds.Tables[0]; | |
367 | + adapter = new SqlDataAdapter(cmd); | |
368 | + adapter.Fill(ds); | |
369 | + | |
370 | + if (ds != null && ds.Tables.Count > 0) | |
371 | + { | |
372 | + licenseSubscriptionDetails = new LicenseSubscriptionDetails(); | |
373 | + DataTable dt = ds.Tables[0]; | |
382 | 374 | |
383 | - if (dt.Rows.Count > 0) | |
375 | + if (dt.Rows.Count > 0) | |
376 | + { | |
377 | + foreach (DataRow dr in dt.Rows) | |
384 | 378 | { |
385 | - foreach (DataRow dr in dt.Rows) | |
386 | - { | |
387 | - int tempVal; | |
388 | - DateTime date; | |
389 | - licenseSubscriptionDetails.Id = Convert.ToInt32(dr["Id"]); | |
390 | - licenseSubscriptionDetails.LicenseId = Convert.ToInt32(dr["LicenseId"]); | |
391 | - licenseSubscriptionDetails.SubscriptionPlanId = Int32.TryParse(dr["SubscriptionPlanId"].ToString(), out tempVal) ? tempVal : (int?)null; | |
392 | - licenseSubscriptionDetails.SubscriptionValidFrom = DateTime.TryParse(dr["SubscriptionValidFrom"].ToString(), out date) ? date : (DateTime?)null; | |
393 | - licenseSubscriptionDetails.SubscriptionValidThrough = DateTime.TryParse(dr["SubscriptionValidThrough"].ToString(), out date) ? date : (DateTime?)null; | |
394 | - licenseSubscriptionDetails.RenewalDate = DateTime.TryParse(dr["RenewalDate"].ToString(), out date) ? date : (DateTime?)null; | |
395 | - licenseSubscriptionDetails.PaymentMode = dr["PaymentMode"].ToString(); | |
396 | - licenseSubscriptionDetails.TotalAmount = Convert.ToDouble(dr["TotalAmount"]); | |
397 | - licenseSubscriptionDetails.AmountPaid = Convert.ToDouble(dr["AmountPaid"]); | |
398 | - licenseSubscriptionDetails.AmountPending = Convert.ToDouble(dr["AmountPending"]); | |
399 | - licenseSubscriptionDetails.NoOfImages = Convert.ToInt32(dr["NoofImages"]); | |
400 | - } | |
379 | + int tempVal; | |
380 | + DateTime date; | |
381 | + licenseSubscriptionDetails.Id = Convert.ToInt32(dr["Id"]); | |
382 | + licenseSubscriptionDetails.LicenseId = Convert.ToInt32(dr["LicenseId"]); | |
383 | + licenseSubscriptionDetails.SubscriptionPlanId = Int32.TryParse(dr["SubscriptionPlanId"].ToString(), out tempVal) ? tempVal : (int?)null; | |
384 | + licenseSubscriptionDetails.SubscriptionValidFrom = DateTime.TryParse(dr["SubscriptionValidFrom"].ToString(), out date) ? date : (DateTime?)null; | |
385 | + licenseSubscriptionDetails.SubscriptionValidThrough = DateTime.TryParse(dr["SubscriptionValidThrough"].ToString(), out date) ? date : (DateTime?)null; | |
386 | + licenseSubscriptionDetails.RenewalDate = DateTime.TryParse(dr["RenewalDate"].ToString(), out date) ? date : (DateTime?)null; | |
387 | + licenseSubscriptionDetails.PaymentMode = dr["PaymentMode"].ToString(); | |
388 | + licenseSubscriptionDetails.TotalAmount = Convert.ToDouble(dr["TotalAmount"]); | |
389 | + licenseSubscriptionDetails.AmountPaid = Convert.ToDouble(dr["AmountPaid"]); | |
390 | + licenseSubscriptionDetails.AmountPending = Convert.ToDouble(dr["AmountPending"]); | |
391 | + licenseSubscriptionDetails.NoOfImages = Convert.ToInt32(dr["NoofImages"]); | |
401 | 392 | } |
402 | 393 | } |
403 | - | |
404 | - | |
405 | - | |
394 | + } | |
395 | + | |
396 | + | |
397 | + | |
406 | 398 | return licenseSubscriptionDetails; |
407 | 399 | } |
408 | 400 | |
... | ... | @@ -411,65 +403,65 @@ namespace AIAHTML5.API.Models |
411 | 403 | logger.Debug(" inside GetLicenseDetailsByLicenseId for LicenseId = " + licenseId); |
412 | 404 | |
413 | 405 | License license = null; |
414 | - | |
415 | - conn = new SqlConnection(dbConnectionString); | |
416 | - cmd = new SqlCommand(); | |
417 | - SqlDataAdapter adapter; | |
418 | - SqlParameter param; | |
419 | - DataSet ds = new DataSet(); | |
420 | 406 | |
421 | - cmd.Connection = conn; | |
422 | - cmd.CommandText = DBConstants.GET_LICENSE_DETAILS_BY_ID; | |
423 | - cmd.CommandType = CommandType.StoredProcedure; | |
407 | + SqlConnection conn = new SqlConnection(dbConnectionString); | |
408 | + SqlCommand cmd = new SqlCommand(); | |
409 | + SqlDataAdapter adapter; | |
410 | + SqlParameter param; | |
411 | + DataSet ds = new DataSet(); | |
424 | 412 | |
425 | - param = new SqlParameter("@Id", licenseId); | |
426 | - param.Direction = ParameterDirection.Input; | |
427 | - param.DbType = DbType.Int32; | |
428 | - cmd.Parameters.Add(param); | |
413 | + cmd.Connection = conn; | |
414 | + cmd.CommandText = DBConstants.GET_LICENSE_DETAILS_BY_ID; | |
415 | + cmd.CommandType = CommandType.StoredProcedure; | |
429 | 416 | |
430 | - adapter = new SqlDataAdapter(cmd); | |
431 | - adapter.Fill(ds); | |
417 | + param = new SqlParameter("@Id", licenseId); | |
418 | + param.Direction = ParameterDirection.Input; | |
419 | + param.DbType = DbType.Int32; | |
420 | + cmd.Parameters.Add(param); | |
432 | 421 | |
433 | - if (ds!= null && ds.Tables.Count > 0) | |
422 | + adapter = new SqlDataAdapter(cmd); | |
423 | + adapter.Fill(ds); | |
424 | + | |
425 | + if (ds != null && ds.Tables.Count > 0) | |
426 | + { | |
427 | + | |
428 | + DataTable dt = ds.Tables[0]; | |
429 | + if (dt.Rows.Count > 0) | |
434 | 430 | { |
435 | - | |
436 | - DataTable dt = ds.Tables[0]; | |
437 | - if (dt.Rows.Count > 0) | |
438 | - { | |
439 | - license = new License(); | |
431 | + license = new License(); | |
440 | 432 | |
441 | - foreach (DataRow dr in dt.Rows) | |
442 | - { | |
443 | - DateTime date; | |
444 | - license.Id = Convert.ToInt32(dr["Id"]); | |
445 | - license.AccountNumber = dr["AccountNumber"].ToString(); | |
446 | - license.LicenseeFirstName = dr["LicenseeFirstName"].ToString(); | |
447 | - license.LicenseeLastName = dr["LicenseeLastName"].ToString(); | |
448 | - license.LicenseTypeId = Convert.ToInt32(dr["LicenseTypeId"]); | |
449 | - license.InstitutionName = dr["InstitutionName"].ToString(); | |
450 | - license.Address1 = dr["Address1"].ToString(); | |
451 | - license.Address2 = dr["Address2"].ToString(); | |
452 | - license.CountryId = Convert.ToInt32(dr["CountryId"]); | |
453 | - license.StateId = Convert.ToInt32(dr["StateId"]); | |
454 | - license.City = dr["City"].ToString(); | |
455 | - license.Zip = dr["Zip"].ToString(); | |
456 | - license.Phone = dr["Phone"].ToString(); | |
457 | - license.EmailId = dr["EmailId"].ToString(); | |
458 | - license.TotalLogins = Convert.ToInt32(dr["TotalLogins"]); | |
459 | - license.AccountTypeId = Convert.ToInt32(dr["AccountTypeId"]); | |
460 | - license.IsActive = Convert.ToBoolean(dr["IsActive"]); | |
461 | - license.IsDistrictSiteLicense = Convert.ToBoolean(dr["IsDistrictSiteLicense"]); | |
462 | - license.CreationDate = Convert.ToDateTime(dr["CreationDate"]); | |
463 | - license.ModifiedDate = DateTime.TryParse(dr["ModifiedDate"].ToString(), out date) ? date : (DateTime?)null; | |
464 | - license.NoOfRenewals = Convert.ToInt32(dr["NoOfRenewals"]); | |
465 | - license.IsTermAccepted = Convert.ToBoolean(dr["IsTermsAccepted"]); | |
466 | - license.ProductId = dr["ProductId"].ToString(); | |
467 | - } | |
433 | + foreach (DataRow dr in dt.Rows) | |
434 | + { | |
435 | + DateTime date; | |
436 | + license.Id = Convert.ToInt32(dr["Id"]); | |
437 | + license.AccountNumber = dr["AccountNumber"].ToString(); | |
438 | + license.LicenseeFirstName = dr["LicenseeFirstName"].ToString(); | |
439 | + license.LicenseeLastName = dr["LicenseeLastName"].ToString(); | |
440 | + license.LicenseTypeId = Convert.ToInt32(dr["LicenseTypeId"]); | |
441 | + license.InstitutionName = dr["InstitutionName"].ToString(); | |
442 | + license.Address1 = dr["Address1"].ToString(); | |
443 | + license.Address2 = dr["Address2"].ToString(); | |
444 | + license.CountryId = Convert.ToInt32(dr["CountryId"]); | |
445 | + license.StateId = Convert.ToInt32(dr["StateId"]); | |
446 | + license.City = dr["City"].ToString(); | |
447 | + license.Zip = dr["Zip"].ToString(); | |
448 | + license.Phone = dr["Phone"].ToString(); | |
449 | + license.EmailId = dr["EmailId"].ToString(); | |
450 | + license.TotalLogins = Convert.ToInt32(dr["TotalLogins"]); | |
451 | + license.AccountTypeId = Convert.ToInt32(dr["AccountTypeId"]); | |
452 | + license.IsActive = Convert.ToBoolean(dr["IsActive"]); | |
453 | + license.IsDistrictSiteLicense = Convert.ToBoolean(dr["IsDistrictSiteLicense"]); | |
454 | + license.CreationDate = Convert.ToDateTime(dr["CreationDate"]); | |
455 | + license.ModifiedDate = DateTime.TryParse(dr["ModifiedDate"].ToString(), out date) ? date : (DateTime?)null; | |
456 | + license.NoOfRenewals = Convert.ToInt32(dr["NoOfRenewals"]); | |
457 | + license.IsTermAccepted = Convert.ToBoolean(dr["IsTermsAccepted"]); | |
458 | + license.ProductId = dr["ProductId"].ToString(); | |
468 | 459 | } |
469 | 460 | } |
470 | - | |
471 | - | |
472 | - | |
461 | + } | |
462 | + | |
463 | + | |
464 | + | |
473 | 465 | return license; |
474 | 466 | } |
475 | 467 | |
... | ... | @@ -478,18 +470,18 @@ namespace AIAHTML5.API.Models |
478 | 470 | logger.Debug(" inside UpdateLicenseTermStatus for AccountNumber = " + accountNumber); |
479 | 471 | |
480 | 472 | int result = 0; |
481 | - | |
473 | + SqlConnection conn = null; | |
482 | 474 | try |
483 | - { | |
475 | + { | |
484 | 476 | conn = new SqlConnection(dbConnectionString); |
485 | - cmd = new SqlCommand(); | |
477 | + SqlCommand cmd = new SqlCommand(); | |
486 | 478 | conn.Open(); |
487 | 479 | cmd.Connection = conn; |
488 | 480 | cmd.CommandText = DBConstants.UPDATE_LICENSE_TERM_STATUS; |
489 | 481 | cmd.CommandType = CommandType.StoredProcedure; |
490 | 482 | cmd.Parameters.AddWithValue("@sAccountNumber", accountNumber); |
491 | 483 | result = cmd.ExecuteNonQuery(); |
492 | - | |
484 | + | |
493 | 485 | } |
494 | 486 | catch (SqlException ex) |
495 | 487 | { |
... | ... | @@ -509,28 +501,28 @@ namespace AIAHTML5.API.Models |
509 | 501 | |
510 | 502 | ArrayList arrTermsAndConditions = new ArrayList(); |
511 | 503 | |
512 | - | |
513 | - Hashtable contentHash = null; | |
514 | - string str = string.Empty; | |
515 | - string spName = DBConstants.GET_TERMS_AND_CONDITIONS; | |
516 | - DataSet ds = DBModel.GetDataFromStoredProcedure(spName); | |
517 | 504 | |
518 | - if (ds!= null && ds.Tables.Count > 0) | |
505 | + Hashtable contentHash = null; | |
506 | + string str = string.Empty; | |
507 | + string spName = DBConstants.GET_TERMS_AND_CONDITIONS; | |
508 | + DataSet ds = DBModel.GetDataFromStoredProcedure(spName); | |
509 | + | |
510 | + if (ds != null && ds.Tables.Count > 0) | |
511 | + { | |
512 | + DataTable dt = ds.Tables[0]; | |
513 | + if (dt.Rows.Count > 0) | |
519 | 514 | { |
520 | - DataTable dt = ds.Tables[0]; | |
521 | - if (dt.Rows.Count > 0) | |
515 | + foreach (DataRow dr in dt.Rows) | |
522 | 516 | { |
523 | - foreach (DataRow dr in dt.Rows) | |
524 | - { | |
525 | - contentHash = new Hashtable(); | |
526 | - contentHash.Add(AIAConstants.KEY_TITLE, dr["Title"]); | |
527 | - contentHash.Add(AIAConstants.KEY_CONTENT, dr["Content"]); | |
528 | - arrTermsAndConditions.Add(contentHash); | |
529 | - } | |
517 | + contentHash = new Hashtable(); | |
518 | + contentHash.Add(AIAConstants.KEY_TITLE, dr["Title"]); | |
519 | + contentHash.Add(AIAConstants.KEY_CONTENT, dr["Content"]); | |
520 | + arrTermsAndConditions.Add(contentHash); | |
530 | 521 | } |
531 | 522 | } |
532 | - | |
533 | - | |
523 | + } | |
524 | + | |
525 | + | |
534 | 526 | return arrTermsAndConditions; |
535 | 527 | } |
536 | 528 | |
... | ... | @@ -539,10 +531,11 @@ namespace AIAHTML5.API.Models |
539 | 531 | logger.Debug(" inside InsertLoginDetails for UserId= " + userId); |
540 | 532 | |
541 | 533 | int result = 0; |
534 | + SqlConnection conn = null; | |
542 | 535 | try |
543 | 536 | { |
544 | 537 | conn = new SqlConnection(dbConnectionString); |
545 | - cmd = new SqlCommand(); | |
538 | + SqlCommand cmd = new SqlCommand(); | |
546 | 539 | conn.Open(); |
547 | 540 | cmd.Connection = conn; |
548 | 541 | cmd.CommandText = DBConstants.INSERT_LOGIN_DETAIL; |
... | ... | @@ -568,10 +561,11 @@ namespace AIAHTML5.API.Models |
568 | 561 | logger.Debug(" inside InsertIncorrectLoginAttempts for UserId= " + userId); |
569 | 562 | |
570 | 563 | int result = 0; |
564 | + SqlConnection conn = null; | |
571 | 565 | try |
572 | 566 | { |
573 | 567 | conn = new SqlConnection(dbConnectionString); |
574 | - cmd = new SqlCommand(); | |
568 | + SqlCommand cmd = new SqlCommand(); | |
575 | 569 | conn.Open(); |
576 | 570 | cmd.Connection = conn; |
577 | 571 | cmd.CommandText = DBConstants.INSERT_INCORRECT_LOGIN_ATTEMPTS; |
... | ... | @@ -596,35 +590,35 @@ namespace AIAHTML5.API.Models |
596 | 590 | logger.Debug(" inside GetIncorrectLoginAttempts for UserId = " + userId); |
597 | 591 | |
598 | 592 | int count = 0; |
599 | - | |
600 | - conn = new SqlConnection(dbConnectionString); | |
601 | - cmd = new SqlCommand(); | |
602 | - cmd.Connection = conn; | |
603 | - cmd.CommandText = DBConstants.GET_INCORRECT_LOGIN_ATTEMPTS; | |
604 | - cmd.CommandType = CommandType.StoredProcedure; | |
605 | - cmd.Parameters.AddWithValue("@iUserId", userId); | |
606 | - SqlDataAdapter da = new SqlDataAdapter(); | |
607 | - da.SelectCommand = cmd; | |
608 | - DataSet ds = new DataSet(); | |
609 | - da.Fill(ds); | |
610 | 593 | |
611 | - if (ds!= null && ds.Tables.Count > 0) | |
612 | - { | |
613 | - DataTable dt = ds.Tables[0]; | |
594 | + SqlConnection conn = new SqlConnection(dbConnectionString); | |
595 | + SqlCommand cmd = new SqlCommand(); | |
596 | + cmd.Connection = conn; | |
597 | + cmd.CommandText = DBConstants.GET_INCORRECT_LOGIN_ATTEMPTS; | |
598 | + cmd.CommandType = CommandType.StoredProcedure; | |
599 | + cmd.Parameters.AddWithValue("@iUserId", userId); | |
600 | + SqlDataAdapter da = new SqlDataAdapter(); | |
601 | + da.SelectCommand = cmd; | |
602 | + DataSet ds = new DataSet(); | |
603 | + da.Fill(ds); | |
604 | + | |
605 | + if (ds != null && ds.Tables.Count > 0) | |
606 | + { | |
607 | + DataTable dt = ds.Tables[0]; | |
614 | 608 | |
615 | - if (dt.Rows.Count > 0) | |
609 | + if (dt.Rows.Count > 0) | |
610 | + { | |
611 | + foreach (DataRow dr in dt.Rows) | |
616 | 612 | { |
617 | - foreach (DataRow dr in dt.Rows) | |
613 | + foreach (DataColumn dc in dt.Columns) | |
618 | 614 | { |
619 | - foreach (DataColumn dc in dt.Columns) | |
620 | - { | |
621 | - count = Convert.ToInt32(dr[dc]); | |
622 | - } | |
615 | + count = Convert.ToInt32(dr[dc]); | |
623 | 616 | } |
624 | 617 | } |
625 | 618 | } |
626 | - | |
627 | - | |
619 | + } | |
620 | + | |
621 | + | |
628 | 622 | return count; |
629 | 623 | } |
630 | 624 | |
... | ... | @@ -633,10 +627,11 @@ namespace AIAHTML5.API.Models |
633 | 627 | logger.Debug(" inside UpdateIncorrectLoginAttempts for UserId= " + userId); |
634 | 628 | |
635 | 629 | int result = 0; |
630 | + SqlConnection conn = null; | |
636 | 631 | try |
637 | 632 | { |
638 | 633 | conn = new SqlConnection(dbConnectionString); |
639 | - cmd = new SqlCommand(); | |
634 | + SqlCommand cmd = new SqlCommand(); | |
640 | 635 | conn.Open(); |
641 | 636 | cmd.Connection = conn; |
642 | 637 | cmd.CommandText = DBConstants.UPDATE_INCORRECT_LOGIN_ATTEMPTS; |
... | ... | @@ -661,10 +656,11 @@ namespace AIAHTML5.API.Models |
661 | 656 | logger.Debug(" inside DeleteIncorrectLoginAttempts for UserId= " + userId); |
662 | 657 | |
663 | 658 | int result = 0; |
659 | + SqlConnection conn = null; | |
664 | 660 | try |
665 | 661 | { |
666 | 662 | conn = new SqlConnection(dbConnectionString); |
667 | - cmd = new SqlCommand(); | |
663 | + SqlCommand cmd = new SqlCommand(); | |
668 | 664 | conn.Open(); |
669 | 665 | cmd.Connection = conn; |
670 | 666 | cmd.CommandText = DBConstants.DELETE_INCORRECT_LOGIN_ATTEMPTS; |
... | ... | @@ -690,28 +686,28 @@ namespace AIAHTML5.API.Models |
690 | 686 | |
691 | 687 | ArrayList failureCauseList = new ArrayList(); |
692 | 688 | |
693 | - Hashtable fcHash = null; | |
689 | + Hashtable fcHash = null; | |
694 | 690 | |
695 | - string sp = DBConstants.GET_ALL_LOGIN_FAILURE_CAUSES; | |
691 | + string sp = DBConstants.GET_ALL_LOGIN_FAILURE_CAUSES; | |
696 | 692 | |
697 | - DataSet ds = DBModel.GetDataFromStoredProcedure(sp); | |
693 | + DataSet ds = DBModel.GetDataFromStoredProcedure(sp); | |
698 | 694 | |
699 | - if (ds.Tables.Count > 0) | |
700 | - { | |
701 | - DataTable dt = ds.Tables[0]; | |
695 | + if (ds.Tables.Count > 0) | |
696 | + { | |
697 | + DataTable dt = ds.Tables[0]; | |
702 | 698 | |
703 | - if (dt.Rows.Count > 0) | |
699 | + if (dt.Rows.Count > 0) | |
700 | + { | |
701 | + foreach (DataRow drFailureCause in dt.Rows) | |
704 | 702 | { |
705 | - foreach (DataRow drFailureCause in dt.Rows) | |
706 | - { | |
707 | - fcHash = new Hashtable(); | |
708 | - fcHash.Add(AIAConstants.KEY_ID, drFailureCause["Id"]); | |
709 | - fcHash.Add(AIAConstants.KEY_DESCRIPTION, drFailureCause["Description"]); | |
710 | - failureCauseList.Add(fcHash); | |
711 | - } | |
703 | + fcHash = new Hashtable(); | |
704 | + fcHash.Add(AIAConstants.KEY_ID, drFailureCause["Id"]); | |
705 | + fcHash.Add(AIAConstants.KEY_DESCRIPTION, drFailureCause["Description"]); | |
706 | + failureCauseList.Add(fcHash); | |
712 | 707 | } |
713 | 708 | } |
714 | - | |
709 | + } | |
710 | + | |
715 | 711 | return failureCauseList; |
716 | 712 | } |
717 | 713 | |
... | ... | @@ -720,10 +716,11 @@ namespace AIAHTML5.API.Models |
720 | 716 | logger.Debug(" inside InsertUserLoginLog for AccountNumber= " + accountNumber); |
721 | 717 | |
722 | 718 | int result = 0; |
719 | + SqlConnection conn = null; | |
723 | 720 | try |
724 | 721 | { |
725 | 722 | conn = new SqlConnection(dbConnectionString); |
726 | - cmd = new SqlCommand(); | |
723 | + SqlCommand cmd = new SqlCommand(); | |
727 | 724 | conn.Open(); |
728 | 725 | cmd.Connection = conn; |
729 | 726 | cmd.CommandText = DBConstants.INSERT_LOGIN_ERROR_LOG; |
... | ... | @@ -754,35 +751,35 @@ namespace AIAHTML5.API.Models |
754 | 751 | |
755 | 752 | BlockedUser blockedUser = null; |
756 | 753 | DataTable dt = null; |
757 | - | |
758 | - conn = new SqlConnection(dbConnectionString); | |
759 | - cmd = new SqlCommand(); | |
760 | - cmd.Connection = conn; | |
761 | - cmd.CommandText = DBConstants.GET_BLOCKED_USER_BY_USER_ID; | |
762 | - cmd.CommandType = CommandType.StoredProcedure; | |
763 | - cmd.Parameters.AddWithValue("@userId", userId); | |
764 | - SqlDataAdapter da = new SqlDataAdapter(); | |
765 | - da.SelectCommand = cmd; | |
766 | - dt = new DataTable(); | |
767 | - da.Fill(dt); | |
768 | 754 | |
769 | - if (dt!= null && dt.Rows.Count > 0) | |
755 | + SqlConnection conn = new SqlConnection(dbConnectionString); | |
756 | + SqlCommand cmd = new SqlCommand(); | |
757 | + cmd.Connection = conn; | |
758 | + cmd.CommandText = DBConstants.GET_BLOCKED_USER_BY_USER_ID; | |
759 | + cmd.CommandType = CommandType.StoredProcedure; | |
760 | + cmd.Parameters.AddWithValue("@userId", userId); | |
761 | + SqlDataAdapter da = new SqlDataAdapter(); | |
762 | + da.SelectCommand = cmd; | |
763 | + dt = new DataTable(); | |
764 | + da.Fill(dt); | |
765 | + | |
766 | + if (dt != null && dt.Rows.Count > 0) | |
767 | + { | |
768 | + blockedUser = new BlockedUser(); | |
769 | + foreach (DataRow dr in dt.Rows) | |
770 | 770 | { |
771 | - blockedUser = new BlockedUser(); | |
772 | - foreach (DataRow dr in dt.Rows) | |
773 | - { | |
774 | - blockedUser.Id = Convert.ToInt32(dr["Id"]); | |
775 | - blockedUser.FirstName = dr["FirstName"].ToString(); | |
776 | - blockedUser.LastName = dr["LastName"].ToString(); | |
777 | - blockedUser.EmailId = dr["EmailId"].ToString(); | |
778 | - blockedUser.LoginId = dr["LoginId"].ToString(); | |
779 | - blockedUser.Password = dr["Password"].ToString(); | |
780 | - blockedUser.AccountNumber = dr["AccountNumber"].ToString(); | |
781 | - blockedUser.LoginTime = Convert.ToDateTime(dr["LoginTime"]); | |
782 | - } | |
771 | + blockedUser.Id = Convert.ToInt32(dr["Id"]); | |
772 | + blockedUser.FirstName = dr["FirstName"].ToString(); | |
773 | + blockedUser.LastName = dr["LastName"].ToString(); | |
774 | + blockedUser.EmailId = dr["EmailId"].ToString(); | |
775 | + blockedUser.LoginId = dr["LoginId"].ToString(); | |
776 | + blockedUser.Password = dr["Password"].ToString(); | |
777 | + blockedUser.AccountNumber = dr["AccountNumber"].ToString(); | |
778 | + blockedUser.LoginTime = Convert.ToDateTime(dr["LoginTime"]); | |
783 | 779 | } |
784 | - | |
785 | - | |
780 | + } | |
781 | + | |
782 | + | |
786 | 783 | return blockedUser; |
787 | 784 | } |
788 | 785 | |
... | ... | @@ -793,39 +790,39 @@ namespace AIAHTML5.API.Models |
793 | 790 | ArrayList blockedUsersList = new ArrayList(); |
794 | 791 | BlockedUser blockedUser = null; |
795 | 792 | DataTable dt = null; |
796 | - | |
797 | - conn = new SqlConnection(dbConnectionString); | |
798 | - cmd = new SqlCommand(); | |
799 | - cmd.Connection = conn; | |
800 | - cmd.CommandText = DBConstants.GET_BLOCKED_USERS_BY_USER_TYPE; | |
801 | - cmd.CommandType = CommandType.StoredProcedure; | |
802 | - cmd.Parameters.AddWithValue("@iUserTypeId", userTypeId); | |
803 | - SqlDataAdapter da = new SqlDataAdapter(); | |
804 | - da.SelectCommand = cmd; | |
805 | - dt = new DataTable(); | |
806 | - da.Fill(dt); | |
807 | 793 | |
808 | - if (dt.Rows.Count > 0) | |
794 | + SqlConnection conn = new SqlConnection(dbConnectionString); | |
795 | + SqlCommand cmd = new SqlCommand(); | |
796 | + cmd.Connection = conn; | |
797 | + cmd.CommandText = DBConstants.GET_BLOCKED_USERS_BY_USER_TYPE; | |
798 | + cmd.CommandType = CommandType.StoredProcedure; | |
799 | + cmd.Parameters.AddWithValue("@iUserTypeId", userTypeId); | |
800 | + SqlDataAdapter da = new SqlDataAdapter(); | |
801 | + da.SelectCommand = cmd; | |
802 | + dt = new DataTable(); | |
803 | + da.Fill(dt); | |
804 | + | |
805 | + if (dt.Rows.Count > 0) | |
806 | + { | |
807 | + foreach (DataRow dr in dt.Rows) | |
809 | 808 | { |
810 | - foreach (DataRow dr in dt.Rows) | |
811 | - { | |
812 | - blockedUser = new BlockedUser(); | |
813 | - | |
814 | - blockedUser.Id = Convert.ToInt32(dr["Id"]); | |
815 | - blockedUser.FirstName = dr["FirstName"].ToString(); | |
816 | - blockedUser.LastName = dr["LastName"].ToString(); | |
817 | - blockedUser.EmailId = dr["EmailId"].ToString(); | |
818 | - blockedUser.LoginId = dr["LoginId"].ToString(); | |
819 | - blockedUser.Password = dr["Password"].ToString(); | |
820 | - blockedUser.AccountNumber = dr["AccountNumber"].ToString(); | |
821 | - blockedUser.LoginTime = Convert.ToDateTime(dr["LoginTime"]); | |
822 | - | |
823 | - blockedUsersList.Add(blockedUser); | |
824 | - } | |
809 | + blockedUser = new BlockedUser(); | |
810 | + | |
811 | + blockedUser.Id = Convert.ToInt32(dr["Id"]); | |
812 | + blockedUser.FirstName = dr["FirstName"].ToString(); | |
813 | + blockedUser.LastName = dr["LastName"].ToString(); | |
814 | + blockedUser.EmailId = dr["EmailId"].ToString(); | |
815 | + blockedUser.LoginId = dr["LoginId"].ToString(); | |
816 | + blockedUser.Password = dr["Password"].ToString(); | |
817 | + blockedUser.AccountNumber = dr["AccountNumber"].ToString(); | |
818 | + blockedUser.LoginTime = Convert.ToDateTime(dr["LoginTime"]); | |
819 | + | |
820 | + blockedUsersList.Add(blockedUser); | |
825 | 821 | } |
826 | - | |
827 | - | |
828 | - | |
822 | + } | |
823 | + | |
824 | + | |
825 | + | |
829 | 826 | return blockedUsersList; |
830 | 827 | } |
831 | 828 | |
... | ... | @@ -862,7 +859,7 @@ namespace AIAHTML5.API.Models |
862 | 859 | throw; |
863 | 860 | } |
864 | 861 | |
865 | - return result; | |
862 | + return result; | |
866 | 863 | } |
867 | 864 | } |
868 | 865 | } |
869 | 866 | \ No newline at end of file | ... | ... |