1: using System;
2: using System.Collections.Generic;
3: using System.Data;
4: using System.Globalization;
5: using System.Linq;
6:
7: namespace Ia.Ngn.Cl.Model.Business
8: {
9: ////////////////////////////////////////////////////////////////////////////
10:
11: /// <summary publish="true">
12: /// Service Request Type support class of Next Generation Network'a (NGN's) business model.
13: /// </summary>
14: ///
15: /// <remarks>
16: /// Copyright © 2006-2019 Jasem Y. Al-Shamlan (info@ia.com.kw), Integrated Applications - Kuwait. All Rights Reserved.
17: ///
18: /// 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
19: /// the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
20: ///
21: /// This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
22: /// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
23: ///
24: /// You should have received a copy of the GNU General Public License along with this library. If not, see http://www.gnu.org/licenses.
25: ///
26: /// Copyright notice: This notice may not be removed or altered from any source distribution.
27: /// </remarks>
28: public partial class ServiceRequestType
29: {
30: /// <summary/>
31: public ServiceRequestType() { }
32:
33: ////////////////////////////////////////////////////////////////////////////
34:
35: /// <summary>
36: ///
37: /// </summary>
38: public static string OracleSqlCommandForGivenDateTime(DateTime dateTime)
39: {
40: string sql;
41:
42: sql = @"select SRV_REQ_FIPER_TECH.SRV_REQ_ID, SRV_REQ_FIPER_TECH.TECH_TYPE_ID, SRV_REQ_FIPER_TECH.VAL from SRV_REQ_FIPER left outer join SRV_REQ_FIPER_TECH on SRV_REQ_FIPER_TECH.SRV_REQ_ID = SRV_REQ_FIPER.SRV_REQ_ID where REQ_DATE >= '" + dateTime.ToString("dd/MM/yyyy", CultureInfo.InvariantCulture) + @"' and REQ_DATE < '" + dateTime.AddDays(1).ToString("dd/MM/yyyy", CultureInfo.InvariantCulture) + @"' and SRV_REQ_FIPER_TECH.SRV_REQ_ID is not null and SRV_REQ_FIPER_TECH.TECH_TYPE_ID is not null and SRV_REQ_FIPER_TECH.VAL is not null order by SRV_REQ_FIPER.SRV_REQ_ID asc";
43:
44: return sql;
45: }
46:
47: ////////////////////////////////////////////////////////////////////////////
48:
49: /// <summary>
50: ///
51: /// </summary>
52: public static string OracleSqlCommandForServiceRequestIdRange(Tuple<int, int> startEndRange)
53: {
54: return OracleSqlCommandForServiceRequestIdRange(startEndRange.Item1, startEndRange.Item2);
55: }
56:
57: ////////////////////////////////////////////////////////////////////////////
58:
59: /// <summary>
60: ///
61: /// </summary>
62: public static string OracleSqlCommandForServiceRequestIdRange(int start, int end)
63: {
64: string sql;
65:
66: sql = @"select SRV_REQ_FIPER_TECH.SRV_REQ_ID, SRV_REQ_FIPER_TECH.TECH_TYPE_ID, SRV_REQ_FIPER_TECH.VAL from SRV_REQ_FIPER left outer join SRV_REQ_FIPER_TECH on SRV_REQ_FIPER_TECH.SRV_REQ_ID = SRV_REQ_FIPER.SRV_REQ_ID where SRV_REQ_FIPER_TECH.SRV_REQ_ID >= " + start + " and SRV_REQ_FIPER_TECH.SRV_REQ_ID <= " + end + " and SRV_REQ_FIPER_TECH.SRV_REQ_ID is not null and SRV_REQ_FIPER_TECH.TECH_TYPE_ID is not null and SRV_REQ_FIPER_TECH.VAL is not null order by SRV_REQ_FIPER.SRV_REQ_ID asc";
67:
68: return sql;
69: }
70:
71: ////////////////////////////////////////////////////////////////////////////
72:
73: /// <summary>
74: ///
75: /// </summary>
76: public static string OracleSqlCommandForServiceRequestByService(string service)
77: {
78: string sql;
79:
80: if (!string.IsNullOrEmpty(service))
81: {
82: sql = @"select SRV_REQ_FIPER_TECH.SRV_REQ_ID, SRV_REQ_FIPER_TECH.TECH_TYPE_ID, SRV_REQ_FIPER_TECH.VAL from SRV_REQ_FIPER
83: left outer join SRV_REQ_FIPER_TECH on SRV_REQ_FIPER_TECH.SRV_REQ_ID = SRV_REQ_FIPER.SRV_REQ_ID
84: where SRV_REQ_FIPER.SRV_NO = " + service + @" and SRV_REQ_FIPER_TECH.SRV_REQ_ID is not null and SRV_REQ_FIPER_TECH.TECH_TYPE_ID is not null and SRV_REQ_FIPER_TECH.VAL is not null
85: order by SRV_REQ_FIPER.SRV_REQ_ID asc";
86: }
87: else sql = string.Empty;
88:
89: return sql;
90: }
91:
92: ////////////////////////////////////////////////////////////////////////////
93:
94: /// <summary>
95: ///
96: /// </summary>
97: public static List<int> ChangedNumberList()
98: {
99: List<int> numberList;
100: List<string> stringNumberList;
101:
102: numberList = new List<int>();
103:
104: using (var db = new Ia.Ngn.Cl.Model.Ngn())
105: {
106: stringNumberList = (from srt in db.ServiceRequestTypes where srt.TypeId == 11 select srt.Value).ToList();
107: }
108:
109: if (stringNumberList.Count > 0)
110: {
111: foreach (string u in stringNumberList)
112: {
113: if (int.TryParse(u, out int i)) numberList.Add(i);
114: }
115: }
116: else
117: {
118: }
119:
120: return numberList;
121: }
122:
123: ////////////////////////////////////////////////////////////////////////////
124:
125: /// <summary>
126: ///
127: /// </summary>
128: public static List<int> ChangedNumberList(List<Ia.Ngn.Cl.Model.ServiceRequestType> serviceRequestTypeList)
129: {
130: int i;
131: List<int> numberList;
132: List<string> stringNumberList;
133:
134: numberList = new List<int>();
135: stringNumberList = (from srt in serviceRequestTypeList where srt.TypeId == 11 select srt.Value).ToList();
136:
137: if (stringNumberList.Count > 0)
138: {
139: foreach (string u in stringNumberList)
140: {
141: if (int.TryParse(u, out i)) numberList.Add(i);
142: }
143: }
144: else
145: {
146: }
147:
148: return numberList;
149: }
150:
151: ////////////////////////////////////////////////////////////////////////////
152:
153: /// <summary>
154: ///
155: /// </summary>
156: public static Ia.Ngn.Cl.Model.Access ExtractAccess(int serviceRequestId, List<Ia.Ngn.Cl.Model.ServiceRequestType> serviceRequestTypeList)
157: {
158: Ia.Ngn.Cl.Model.Access access;
159: List<Ia.Ngn.Cl.Model.ServiceRequestType> subtypeSrtList;
160:
161: subtypeSrtList = (from srt in serviceRequestTypeList
162: where srt.ServiceRequest.Id == serviceRequestId
163: select srt).ToList();
164:
165: access = ExtractAccess(subtypeSrtList);
166:
167: return access;
168: }
169:
170: ////////////////////////////////////////////////////////////////////////////
171:
172: /// <summary>
173: ///
174: /// </summary>
175: private static Ia.Ngn.Cl.Model.Access ExtractAccess(List<Ia.Ngn.Cl.Model.ServiceRequestType> serviceRequestTypeList)
176: {
177: int oltId, ponNumber, ontNumber;
178: Dictionary<int, string> typeDictionary;
179: Ia.Ngn.Cl.Model.Access access;
180:
181: typeDictionary = TypeDictionary(serviceRequestTypeList);
182:
183: Ia.Ngn.Cl.Model.Business.Default.ExtractAccessNameWithValidSymbolAndLegalFormatForPonAndOntFromDictionaryValueList(typeDictionary, out oltId, out ponNumber, out ontNumber);
184:
185: access = Ia.Ngn.Cl.Model.Data.Access.Read(oltId, ponNumber, ontNumber);
186:
187: return access;
188: }
189:
190: ////////////////////////////////////////////////////////////////////////////
191:
192: /// <summary>
193: ///
194: /// </summary>
195: public static Ia.Ngn.Cl.Model.Access ExtractAccess(Ia.Ngn.Cl.Model.Ngn db, string value)
196: {
197: int oltId, ponNumber, ontNumber;
198: Dictionary<int, string> typeDictionary;
199: Ia.Ngn.Cl.Model.Access access;
200:
201: typeDictionary = new Dictionary<int, string>(1);
202: typeDictionary.Add(1, value);
203:
204: Ia.Ngn.Cl.Model.Business.Default.ExtractAccessNameWithValidSymbolAndLegalFormatForPonAndOntFromDictionaryValueList(typeDictionary, out oltId, out ponNumber, out ontNumber);
205:
206: access = Ia.Ngn.Cl.Model.Data.Access.Read(db, oltId, ponNumber, ontNumber);
207:
208: return access;
209: }
210:
211: ////////////////////////////////////////////////////////////////////////////
212:
213: /// <summary>
214: ///
215: /// </summary>
216: public static Dictionary<int, string> TypeDictionary(List<Ia.Ngn.Cl.Model.ServiceRequestType> serviceRequestTypeList)
217: {
218: Dictionary<int, string> typeDictionary;
219:
220: typeDictionary = new Dictionary<int, string>(63); // <serviceRequestType> <typeList> <type> has about 63 types max
221:
222: foreach (Ia.Ngn.Cl.Model.ServiceRequestType serviceRequestType in serviceRequestTypeList)
223: {
224: typeDictionary.Add(serviceRequestType.TypeId, serviceRequestType.Value);
225: }
226:
227: return typeDictionary;
228: }
229:
230: ////////////////////////////////////////////////////////////////////////////
231: ////////////////////////////////////////////////////////////////////////////
232: }
233:
234: ////////////////////////////////////////////////////////////////////////////
235: ////////////////////////////////////////////////////////////////////////////
236: }