1: using System.Collections.Generic;
2: using System.Data;
3: using System.Linq;
4: using System.Text.RegularExpressions;
5:
6: namespace Ia.Ngn.Cl.Model.Business
7: {
8: ////////////////////////////////////////////////////////////////////////////
9:
10: /// <summary publish="true">
11: /// Service support class of Next Generation Network'a (NGN's) business model.
12: /// </summary>
13: ///
14: /// <remarks>
15: /// Copyright © 2006-2020 Jasem Y. Al-Shamlan (info@ia.com.kw), Integrated Applications - Kuwait. All Rights Reserved.
16: ///
17: /// 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
18: /// the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
19: ///
20: /// This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
21: /// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
22: ///
23: /// You should have received a copy of the GNU General Public License along with this library. If not, see http://www.gnu.org/licenses.
24: ///
25: /// Copyright notice: This notice may not be removed or altered from any source distribution.
26: /// </remarks>
27: public partial class Service
28: {
29: private static int sequentialQueueOriginalCount;
30: private static Queue<string> sequentialQueue = new Queue<string>();
31:
32: //public static readonly int TemporaryProcedureToIndicateWhereTheLastReadNumberFromOracleDatabaseBecauseListIsTooLongToRepeatHahaha = 25667698;
33:
34: /// <summary/>
35: public static readonly List<string> AllowedToBeMigratedOltSymbolList = new List<string>() { "EGL", "SAB", "COB", "FNT", "BYN", "MSF", "MBA", "MHL", "MAH", "SSB", "MGF", "ADN", "QSR" };
36:
37: /// <summary/>
38: public enum SupplementaryService
39: {
40: CallerId = 1, InternationalCalling, InternationalCallingUserControlled, CallForwarding, CallWaiting, ConferenceCall, WakeupCall, AbbriviatedCalling, ServiceSuspension
41: };
42:
43: ////////////////////////////////////////////////////////////////////////////
44:
45: /// <summary>
46: ///
47: /// </summary>
48: public static int CountryCode { get { return 965; } }
49:
50: ////////////////////////////////////////////////////////////////////////////
51:
52: /// <summary>
53: ///
54: /// </summary>
55: public class ServiceSupplementaryService
56: {
57: public int Service { get; set; }
58: public string Pin { get; set; }
59: public bool SubscriberHasPin { get; set; }
60: public bool InternationalCallingUserControlledActivated { get; set; }
61: public bool ServiceAdministrativelySuspendedByBillingDepartment { get; set; }
62: public bool ServiceAdministrativelySuspendedForOtherReasons { get; set; }
63: public bool IsPbx { get; set; }
64:
65: public List<Ia.Ngn.Cl.Model.Business.Service.SupplementaryService> SupplementaryServiceList { get; set; }
66:
67: public ServiceSupplementaryService()
68: {
69: this.Service = 0;
70: this.Pin = string.Empty;
71: this.SubscriberHasPin = false;
72: this.InternationalCallingUserControlledActivated = false;
73: this.ServiceAdministrativelySuspendedByBillingDepartment = false;
74: this.ServiceAdministrativelySuspendedForOtherReasons = false;
75: this.IsPbx = false;
76:
77: this.SupplementaryServiceList = new List<Ia.Ngn.Cl.Model.Business.Service.SupplementaryService>();
78: }
79: }
80:
81: ////////////////////////////////////////////////////////////////////////////
82:
83: /// <summary>
84: ///
85: /// </summary>
86: public class ServiceType
87: {
88: /// <summary/>
89: public int Id { get; set; }
90: /// <summary/>
91: public string Name { get; set; }
92: /// <summary/>
93: public string NameArabicName { get; set; }
94: /// <summary/>
95: public string Color { get; set; }
96:
97: /// <summary/>
98: public ServiceType(int id, string name, string nameArabicName, string color)
99: {
100: this.Id = id;
101: this.Name = name;
102: this.NameArabicName = nameArabicName;
103: this.Color = color;
104: }
105:
106: /// <summary/>
107: public string ColoredNameArabicName
108: {
109: get
110: {
111: return @"<span class=""" + this.Color + @""">" + this.NameArabicName + @"</span>";
112: }
113: }
114:
115: /// <summary/>
116: public static int GponService
117: {
118: get
119: {
120: return (from s in Ia.Ngn.Cl.Model.Data.Service.ServiceTypeList where s.Name == "Ngn" select s.Id).Single();
121: }
122: }
123:
124: /// <summary/>
125: public static int PstnService
126: {
127: get
128: {
129: return (from s in Ia.Ngn.Cl.Model.Data.Service.ServiceTypeList where s.Name == "Pstn" select s.Id).Single();
130: }
131: }
132:
133: ////////////////////////////////////////////////////////////////////////////
134: ////////////////////////////////////////////////////////////////////////////
135: }
136:
137: ////////////////////////////////////////////////////////////////////////////
138:
139: /// <summary>
140: ///
141: /// </summary>
142: public Service() { }
143:
144: ////////////////////////////////////////////////////////////////////////////
145:
146: /// <summary>
147: ///
148: /// </summary>
149: public static string ServiceName(string service, int serviceType)
150: {
151: string name;
152:
153: name = service;
154:
155: if (name == "0") name = string.Empty;
156:
157: return name;
158: }
159:
160: ////////////////////////////////////////////////////////////////////////////
161:
162: /// <summary>
163: ///
164: /// </summary>
165: public static string ServiceIdToService(string serviceId)
166: {
167: string service;
168:
169: service = serviceId.Substring(0, serviceId.IndexOf(":"));
170:
171: return service;
172: }
173:
174: ////////////////////////////////////////////////////////////////////////////
175:
176: /// <summary>
177: ///
178: /// </summary>
179: public static string ServiceToServiceId(string service, int serviceType)
180: {
181: string serviceId;
182:
183: serviceId = service + ":" + serviceType + ":" + Ia.Ngn.Cl.Model.Business.Service.CountryCode;
184:
185: return serviceId;
186: }
187:
188: ////////////////////////////////////////////////////////////////////////////
189:
190: /// <summary>
191: ///
192: /// </summary>
193: public static int ServiceIdToServiceType(string serviceId)
194: {
195: int serviceType;
196:
197: serviceType = int.Parse(serviceId.Substring(serviceId.IndexOf(":") + 1, 1));
198:
199: return serviceType;
200: }
201:
202: ////////////////////////////////////////////////////////////////////////////
203:
204: /// <summary>
205: ///
206: /// </summary>
207: public static List<string> ServiceListToServiceIdListForAllServiceTypes(List<string> serviceList)
208: {
209: List<string> serviceIdList;
210:
211: serviceIdList = new List<string>();
212:
213: foreach (var service in serviceList)
214: {
215: // I will add serviceIds for both GPON and PSTN version of the number
216: var serviceId = Ia.Ngn.Cl.Model.Business.Service2.ServiceId(service, Ia.Ngn.Cl.Model.Business.Service.ServiceType.GponService);
217: serviceIdList.Add(serviceId);
218:
219: serviceId = Ia.Ngn.Cl.Model.Business.Service2.ServiceId(service, Ia.Ngn.Cl.Model.Business.Service.ServiceType.PstnService);
220: serviceIdList.Add(serviceId);
221: }
222:
223: return serviceIdList.Distinct().ToList();
224: }
225:
226: ////////////////////////////////////////////////////////////////////////////
227:
228: /// <summary>
229: ///
230: /// </summary>
231: public static bool ServiceHasEightDigits(string service)
232: {
233: bool isValid;
234:
235: if (!string.IsNullOrEmpty(service))
236: {
237: isValid = Regex.IsMatch(service, @"^\d{8}$");
238: }
239: else isValid = false;
240:
241: return isValid;
242: }
243:
244: ////////////////////////////////////////////////////////////////////////////
245:
246: /// <summary>
247: ///
248: /// </summary>
249: public class KuwaitNgnArea
250: {
251: /// <summary/>
252: public KuwaitNgnArea() { }
253:
254: /// <summary/>
255: public KuwaitNgnArea(string name, string arabicName)
256: {
257: this.Name = name;
258: this.ArabicName = arabicName;
259: }
260:
261: /// <summary/>
262: public int Id { get; set; }
263:
264: /// <summary/>
265: public string Name { get; set; }
266:
267: /// <summary/>
268: public string ArabicName { get; set; }
269:
270: /// <summary/>
271: public string NameArabicName
272: {
273: get
274: {
275: return Name + " (" + ArabicName + ")";
276: }
277: }
278:
279: /// <summary/>
280: public string Symbol { get; set; }
281:
282: /// <summary/>
283: public string ServiceRequestAddressProvinceAreaName { get; set; }
284:
285: /// <summary/>
286: public virtual List<Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Site> SiteList { get; set; }
287: }
288:
289: ////////////////////////////////////////////////////////////////////////////
290:
291: /// <summary>
292: ///
293: /// </summary>
294: public static List<int> SelectListOfNumbersWithinAllowedDomainList(List<int> inNumberList)
295: {
296: string numberString;
297: List<int> numberList;
298:
299: numberList = new List<int>();
300:
301: if (inNumberList.Count > 0)
302: {
303: numberList = new List<int>(inNumberList.Count);
304:
305: foreach (int i in inNumberList)
306: {
307: numberString = i.ToString();
308:
309: if (NumberIsWithinAllowedDomainList(numberString)) numberList.Add(i);
310: }
311: }
312:
313: return numberList;
314: }
315:
316: ////////////////////////////////////////////////////////////////////////////
317:
318: /// <summary>
319: ///
320: /// </summary>
321: public static bool OltIsWithinAllowedToBeProvisionedOltList(Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Olt olt)
322: {
323: return Ia.Ngn.Cl.Model.Data.Service.AllowedToBeProvisionedOltList.Any(u => u == olt);
324: }
325:
326: ////////////////////////////////////////////////////////////////////////////
327:
328: /// <summary>
329: ///
330: /// </summary>
331: public static bool OltIsWithinAllowedToBeMigratedOltList(Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Olt olt)
332: {
333: return Ia.Ngn.Cl.Model.Data.Service.AllowedToBeMigratedOltList.Any(u => u == olt);
334: }
335:
336: ////////////////////////////////////////////////////////////////////////////
337:
338: /// <summary>
339: ///
340: /// </summary>
341: public static bool OltIdIsWithinAllowedToBeMigratedOltList(int oltId)
342: {
343: return Ia.Ngn.Cl.Model.Data.Service.AllowedToBeMigratedOltIdList.Contains(oltId);
344: }
345:
346: ////////////////////////////////////////////////////////////////////////////
347:
348: /// <summary>
349: ///
350: /// </summary>
351: public static bool OltIsWithinAllowedToBeProvisionedOrMigratedOltList(Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Olt olt)
352: {
353: return Ia.Ngn.Cl.Model.Data.Service.AllowedToBeProvisionedOltList.Any(u => u == olt) || Ia.Ngn.Cl.Model.Data.Service.AllowedToBeMigratedOltList.Any(u => u == olt);
354: }
355:
356: ////////////////////////////////////////////////////////////////////////////
357:
358: /// <summary>
359: ///
360: /// </summary>
361: public static bool AreaSymbolIsWithinAnAllowedOltToBeProvisionedDomainList(string areaSymbol)
362: {
363: bool b;
364:
365: if (!string.IsNullOrEmpty(areaSymbol))
366: {
367: b = Ia.Ngn.Cl.Model.Data.Service.AllowedToBeProvisionedOltList.Any(v => v.Odf.Router.Site.AreaSymbolList.Any(u => areaSymbol == u));
368: }
369: else
370: {
371: b = false;
372: }
373:
374: return b;
375: }
376:
377: ////////////////////////////////////////////////////////////////////////////
378:
379: /// <summary>
380: ///
381: /// </summary>
382: public static bool NumberIsWithinAnAllowedOltToBeProvisionedDomainList(string service)
383: {
384: bool b;
385:
386: if (!string.IsNullOrEmpty(service))
387: {
388: b = Ia.Ngn.Cl.Model.Data.Service.AllowedToBeProvisionedOltList.Any(v => v.Odf.Router.DomainList.Any(u => service.StartsWith(u.ToString())));
389: }
390: else
391: {
392: b = false;
393: }
394:
395: return b;
396: }
397:
398: ////////////////////////////////////////////////////////////////////////////
399:
400: /// <summary>
401: ///
402: /// </summary>
403: public static bool NumberIsWithinAllowedDomainList(long number)
404: {
405: string numberString;
406:
407: numberString = number.ToString();
408:
409: return NumberIsWithinAllowedDomainList(numberString);
410: }
411:
412: ////////////////////////////////////////////////////////////////////////////
413:
414: /// <summary>
415: ///
416: /// </summary>
417: public static bool NumberIsWithinAllowedRouterDomainList(Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Ont ont, string service)
418: {
419: bool b;
420:
421: if (ont != null)
422: {
423: b = ont.Pon.PonGroup.Olt.Odf.Router.DomainList.Any(u => service.StartsWith(u.ToString()));
424: }
425: else b = false;
426:
427: return b;
428: }
429:
430: ////////////////////////////////////////////////////////////////////////////
431:
432: /// <summary>
433: ///
434: /// </summary>
435: public static bool NumberIsWithinAllowedDomainList(string number)
436: {
437: bool isWithinAllowed;
438:
439: if (!string.IsNullOrEmpty(number))
440: {
441: if (Ia.Ngn.Cl.Model.Data.Service.DomainList.Any(u => number.StartsWith(u.ToString()))) isWithinAllowed = true;
442: else isWithinAllowed = false;
443: }
444: else isWithinAllowed = false;
445:
446: return isWithinAllowed;
447: }
448:
449: ////////////////////////////////////////////////////////////////////////////
450:
451: /// <summary>
452: ///
453: /// </summary>
454: public static bool NumberIsWithinAllowedNokiaSwitchDomainList(long number)
455: {
456: string numberString;
457:
458: numberString = number.ToString();
459:
460: return NumberIsWithinAllowedNokiaSwitchDomainList(numberString);
461: }
462:
463: ////////////////////////////////////////////////////////////////////////////
464:
465: /// <summary>
466: ///
467: /// </summary>
468: public static bool NumberIsWithinAllowedNokiaSwitchDomainList(string number)
469: {
470: bool isWithinAllowedDomains;
471:
472: if (NumberIsWithinAllowedDomainList(number))
473: {
474: if (Ia.Ngn.Cl.Model.Data.Service.NokiaSwitchDomainList.Any(u => number.StartsWith(u.ToString()))) isWithinAllowedDomains = true;
475: else isWithinAllowedDomains = false;
476: }
477: else isWithinAllowedDomains = false;
478:
479: return isWithinAllowedDomains;
480: }
481:
482: ////////////////////////////////////////////////////////////////////////////
483:
484: /// <summary>
485: ///
486: /// </summary>
487: public static bool NumberIsWithinAllowedHuaweiSwitchDomainList(long number)
488: {
489: string numberString;
490:
491: numberString = number.ToString();
492:
493: return NumberIsWithinAllowedHuaweiSwitchDomainList(numberString);
494: }
495:
496: ////////////////////////////////////////////////////////////////////////////
497:
498: /// <summary>
499: ///
500: /// </summary>
501: public static bool NumberIsWithinAllowedHuaweiSwitchDomainList(string number)
502: {
503: bool isWithinAllowedDomains;
504:
505: if (NumberIsWithinAllowedDomainList(number))
506: {
507: if (Ia.Ngn.Cl.Model.Data.Service.HuaweiSwitchDomainList.Any(u => number.StartsWith(u.ToString()))) isWithinAllowedDomains = true;
508: else isWithinAllowedDomains = false;
509: }
510: else isWithinAllowedDomains = false;
511:
512: return isWithinAllowedDomains;
513: }
514:
515: ////////////////////////////////////////////////////////////////////////////
516:
517: /// <summary>
518: ///
519: /// </summary>
520: public static Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Vendor SwitchVendor(string service)
521: {
522: Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Vendor vendor;
523:
524: if (NumberIsWithinAllowedNokiaSwitchDomainList(service))
525: {
526: vendor = Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Vendor.Nokia;
527: }
528: else if (NumberIsWithinAllowedHuaweiSwitchDomainList(service))
529: {
530: vendor = Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Vendor.Huawei;
531: }
532: else vendor = Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Vendor.Undefined;
533:
534: return vendor;
535: }
536:
537: ////////////////////////////////////////////////////////////////////////////
538:
539: /// <summary>
540: ///
541: /// </summary>
542: public static Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Vendor AccessVendor(string accessName)
543: {
544: Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Vendor vendor;
545:
546: vendor = (from v in Ia.Ngn.Cl.Model.Data.NetworkDesignDocument.OntList where v.Access.Name == accessName select v.Pon.PonGroup.Olt.Odf.Vendor).SingleOrDefault();
547:
548: if (vendor == null) vendor = Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Vendor.Undefined;
549:
550: return vendor;
551: }
552:
553: ////////////////////////////////////////////////////////////////////////////
554:
555: /// <summary>
556: ///
557: /// </summary>
558: public static int ConvertEmsVoipPstnUsersPnToServiceRequestServicePosition(int pn)
559: {
560: /*
561: * - All Nokia ONTs (SFUs and MDUs) start at port position 1
562: * - Huawei ONTs (SFUs) start at port position 1, while Huawei MDUs start at port position 0
563: * - All positions in the Customer Department database will start at position 1 (e.g. port 3 in a Huawei MDU is 4 in the Customer Department database)
564: */
565:
566: // +1 because it has a Huawei MDU. See above.
567:
568: return pn + 1;
569: }
570:
571: ////////////////////////////////////////////////////////////////////////////
572:
573: /// <summary>
574: ///
575: /// </summary>
576: public static int ConvertServiceRequestServicePositionToEmsVoipPstnUsersPn(int servicePosition)
577: {
578: /*
579: * - All Nokia ONTs (SFUs and MDUs) start at port position 1
580: * - Huawei ONTs (SFUs) start at port position 1, while Huawei MDUs start at port position 0
581: * - All positions in the Customer Department database will start at position 1 (e.g. port 3 in a Huawei MDU is 4 in the Customer Department database)
582: */
583:
584: // -1 because it has a Huawei MDU. See above.
585:
586: return servicePosition - 1;
587: }
588:
589: ////////////////////////////////////////////////////////////////////////////
590:
591: /// <summary>
592: ///
593: /// </summary>
594: public static int ConvertFlatTermIdPositionToEmsVoipPstnUsersPn(int flatTermId)
595: {
596: /*
597: * - All Nokia ONTs (SFUs and MDUs) start at port position 1
598: * - Huawei ONTs (SFUs) start at port position 1, while Huawei MDUs start at port position 0
599: * - All positions in the Customer Department database will start at position 1 (e.g. port 3 in a Huawei MDU is 4 in the Customer Department database)
600: */
601:
602: // -1 because it has a Huawei MDU. See above.
603:
604: return flatTermId - 1;
605: }
606:
607: ////////////////////////////////////////////////////////////////////////////
608:
609: /// <summary>
610: ///
611: /// </summary>
612: public static string SequentialServiceNotInServiceRequestServiceManager(out int sequentialQueueCount, out string progressCounterString)
613: {
614: string service;
615:
616: if (sequentialQueue.Count == 0)
617: {
618: var list = Ia.Ngn.Cl.Model.Data.Service.ServiceNotInServiceRequestServiceList();
619: sequentialQueue = new Queue<string>(list);
620:
621: sequentialQueueOriginalCount = sequentialQueue.Count;
622: }
623:
624: if (sequentialQueue.Count > 0) service = sequentialQueue.Dequeue();
625: else service = string.Empty;
626:
627: progressCounterString = "(" + sequentialQueue.Count + "/" + sequentialQueueOriginalCount + ")";
628:
629: sequentialQueueCount = sequentialQueue.Count;
630:
631: return service;
632: }
633:
634: ////////////////////////////////////////////////////////////////////////////
635: ////////////////////////////////////////////////////////////////////////////
636: }
637:
638: ////////////////////////////////////////////////////////////////////////////
639:
640: /// <summary>
641: ///
642: /// </summary>
643: public static class ServiceExtension
644: {
645: ////////////////////////////////////////////////////////////////////////////
646:
647: /// <summary>
648: ///
649: /// <see cref="http://stackoverflow.com/questions/8910588/how-to-override-contains"/>
650: /// </summary>
651: public static bool Contains(this List<Ia.Ngn.Cl.Model.Business.ServiceRequest.NumberSerial> sourceList, int number, int serial)
652: {
653: return ((from n in sourceList where n.Number == number && n.Serial == serial select n) != null);
654: }
655:
656: ////////////////////////////////////////////////////////////////////////////
657:
658: /// <summary>
659: ///
660: /// </summary>
661: public static List<long> IdList(this List<Ia.Ngn.Cl.Model.Business.ServiceRequest.NumberSerial> sourceList)
662: {
663: return ((from n in sourceList select (long)((long)n.Number * 100 + n.Serial)).ToList());
664: }
665:
666: ////////////////////////////////////////////////////////////////////////////
667: ////////////////////////////////////////////////////////////////////////////
668: }
669:
670: ////////////////////////////////////////////////////////////////////////////
671: ////////////////////////////////////////////////////////////////////////////
672: }