1: using System;
2: using System.Web;
3: using System.Xml;
4: using System.Xml.Linq;
5: using System.IO;
6: using System.Configuration;
7: using System.Text;
8: using System.Text.RegularExpressions;
9: using System.Data;
10: using System.Data.SqlClient;
11: using System.Web.UI;
12: using System.Web.UI.WebControls;
13: using System.Collections;
14: using System.Collections.Generic;
15: using System.Linq;
16:
17: namespace Ia.Ngn.Ofn.Wa.Model.Data
18: {
19: ////////////////////////////////////////////////////////////////////////////
20:
21: /// <summary publish="true">
22: /// Service Request support class for Next Generation Network (NGN) web application (Intranet) model.
23: /// </summary>
24: ///
25: /// <remarks>
26: /// Copyright © 2006-2017 Jasem Y. Al-Shamlan (info@ia.com.kw), Integrated Applications - Kuwait. All Rights Reserved.
27: ///
28: /// This library is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by
29: /// the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
30: ///
31: /// This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
32: /// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
33: ///
34: /// You should have received a copy of the GNU General Public License along with this library. If not, see http://www.gnu.org/licenses.
35: ///
36: /// Copyright notice: This notice may not be removed or altered from any source distribution.
37: /// </remarks>
38: public class ServiceRequest
39: {
40: ////////////////////////////////////////////////////////////////////////////
41:
42: /// <summary>
43: ///
44: /// </summary>
45: public ServiceRequest()
46: {
47: }
48:
49: ////////////////////////////////////////////////////////////////////////////
50:
51: /// <summary>
52: ///
53: /// </summary>
54: public static List<Ia.Ngn.Cl.Model.ServiceRequest> LastN(int numberOfServiceRequests)
55: {
56: // below:
57: List<Ia.Ngn.Cl.Model.ServiceRequest> serviceRequestList;
58:
59: serviceRequestList = null;
60:
61: try
62: {
63: using (var db = new Ia.Ngn.Cl.Model.Ngn())
64: {
65: serviceRequestList = (from sr in db.ServiceRequests orderby sr.RequestDateTime descending select sr).Take(numberOfServiceRequests).ToList();
66: }
67: }
68: catch (Exception)
69: {
70: //resultLabel.Text = "Error during retrieval of data for \"" + ip + "\": " + ex.Message + ". ";
71: //resultLabel.CssClass = "error";
72: }
73:
74: return serviceRequestList;
75: }
76:
77: ////////////////////////////////////////////////////////////////////////////
78:
79: /// <summary>
80: ///
81: /// </summary>
82: public static List<Ia.Ngn.Cl.Model.ServiceRequest> ForRequestDate(DateTime requestDate)
83: {
84: // below:
85: DateTime nextDate;
86: List<Ia.Ngn.Cl.Model.ServiceRequest> serviceRequestList;
87:
88: serviceRequestList = null;
89:
90: // below: 00:00 time values
91: requestDate = requestDate.Date;
92:
93: nextDate = requestDate.AddDays(1);
94:
95: try
96: {
97: using (var db = new Ia.Ngn.Cl.Model.Ngn())
98: {
99: serviceRequestList = (from sr in db.ServiceRequests where sr.RequestDateTime >= requestDate && sr.RequestDateTime < nextDate orderby sr.RequestDateTime descending select sr).ToList();
100: }
101: }
102: catch (Exception)
103: {
104: //resultLabel.Text = "Error during retrieval of data for \"" + ip + "\": " + ex.Message + ". ";
105: //resultLabel.CssClass = "error";
106: }
107:
108: return serviceRequestList;
109: }
110:
111: ////////////////////////////////////////////////////////////////////////////
112: ////////////////////////////////////////////////////////////////////////////
113: }
114:
115: ////////////////////////////////////////////////////////////////////////////
116: ////////////////////////////////////////////////////////////////////////////
117: }