1: using Microsoft.EntityFrameworkCore;
2: using System;
3: using System.Collections.Generic;
4: using System.Configuration;
5: using System.Data;
6: using System.Linq;
7: using System.Text.RegularExpressions;
8: using System.Web;
9:
10: namespace Ia.Ngn.Cl.Model.Business
11: {
12: ////////////////////////////////////////////////////////////////////////////
13:
14: /// <summary publish="true">
15: /// Default general support class of Optical Fiber Network (OFN) business model.
16: /// </summary>
17: ///
18: /// <remarks>
19: /// Copyright © 2006-2021 Jasem Y. Al-Shamlan (info@ia.com.kw), Integrated Applications - Kuwait. All Rights Reserved.
20: ///
21: /// 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
22: /// the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
23: ///
24: /// This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
25: /// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
26: ///
27: /// You should have received a copy of the GNU General Public License along with this library. If not, see http://www.gnu.org/licenses.
28: ///
29: /// Copyright notice: This notice may not be removed or altered from any source distribution.
30: /// </remarks>
31: public class Default
32: {
33: private static bool allowApplicationsToRun = true;
34: private const int fixedLengthOfOntId = 16;
35: private static int visitorCounter;
36:
37: private static readonly object objectLock = new object();
38:
39: ////////////////////////////////////////////////////////////////////////////
40:
41: /// <summary>
42: ///
43: /// </summary>
44: public static int FixedLengthOfOntId { get { return fixedLengthOfOntId; } }
45:
46: ////////////////////////////////////////////////////////////////////////////
47:
48: /// <summary>
49: ///
50: /// </summary>
51: public const int PortUndefinedOrInvalidOrUnknown = -1;
52:
53: ////////////////////////////////////////////////////////////////////////////
54:
55: /// <summary>
56: ///
57: /// </summary>
58: public enum ProjectState { Running = 1, PartiallyRunning, Idle, Down, Unknown };
59:
60: ////////////////////////////////////////////////////////////////////////////
61:
62: /// <summary>
63: ///
64: /// </summary>
65: public enum Procedure { InitializeOrIterate, IterateOnly };
66:
67: ////////////////////////////////////////////////////////////////////////////
68:
69: /// <summary>
70: ///
71: /// </summary>
72: public enum Protocol { DefaultAsInNdd = 1, Sip, H248 };
73:
74: ////////////////////////////////////////////////////////////////////////////
75:
76: /// <summary>
77: ///
78: /// </summary>
79: public enum SwitchRoute
80: {
81: NokiaIms = 1, HuaweiIms = 2, SiemensEwsdCopper = 3, EricssonAxeCopper = 4, Unknown = -1
82: };
83:
84: ////////////////////////////////////////////////////////////////////////////
85:
86: /// <summary>
87: ///
88: /// </summary>
89: public enum SchedulerInterval { Year, Month, Week, Day, Hour, Minute, Second }
90:
91: ////////////////////////////////////////////////////////////////////////////
92:
93: /// <summary>
94: ///
95: /// </summary>
96: public enum ValidityOfData { Minute, Hour, SixHours, TwelveHours, Day, Week, Month, Year };
97:
98: ////////////////////////////////////////////////////////////////////////////
99:
100: /// <summary>
101: ///
102: /// </summary>
103: public static List<string> H248ToSipUpdateOltSymbolList
104: {
105: get
106: {
107: return new List<string> { }; // "SAA" }; // "SDQ", "SAA", "ADS" ,"LAB"
108: }
109: }
110:
111: ////////////////////////////////////////////////////////////////////////////
112:
113: /// <summary>
114: ///
115: /// </summary>
116: public static List<string> EntityTableNameList
117: {
118: get
119: {
120: List<string> list;
121:
122: using (var db = new Ia.Ngn.Cl.Model.Ngn())
123: {
124: list = db.Model.GetEntityTypes().Select(t => t.GetTableName()).Distinct().ToList();
125: }
126:
127: return list;
128: }
129: }
130:
131: ////////////////////////////////////////////////////////////////////////////
132:
133: /// <summary>
134: ///
135: /// </summary>
136: public static Dictionary<string, string> ApplicationAssemblyNameToApplicationName
137: {
138: get
139: {
140: // see and update Ia.Ngn.Cl.Model.Business.Msmq.Application
141:
142: var d = new Dictionary<string, string> {
143: { "ia.ngn.ams.wfa", "Optical Fiber Network's Operations Support System Nokia AMS Manager Application" },
144: { "ia.ngn.axe.ca", "Optical Fiber Network's Operations Support System Ericsson AXE Manager Application" },
145: { "ia.ngn.citrixguistarter.ca", "Optical Fiber Network's Operations Support System Citrix GUI Starter Application" },
146: { "ia.ngn.email.wfa", "Optical Fiber Network's Operations Support System Mailbox Manager Application" },
147: { "ia.ngn.nce.wfa", "Optical Fiber Network's Operations Support System Huawei NCE Manager Application" },
148: { "ia.ngn.netm.ca", "Optical Fiber Network's Operations Support System Siemens NetManager Citrix Netm Shell Prompt Trigger Application" },
149: { "ia.ngn.netmanager.ca", "Optical Fiber Network's Operations Support System Siemens NetManager Manager Application" },
150: { "ia.ngn.ofn.wa", "Optical Fiber Network's Operations Support System Management Intranet Application" },
151: { "ia.ngn.provision.wfa", "Optical Fiber Network's Operations Support System Provision Manager Application" },
152: { "ia.ngn.scheduler.ca", "Optical Fiber Network's Operations Support System Scheduler Application" },
153: { "ia.ngn.sdc.wfa", "Optical Fiber Network's Operations Support System Nokia Statistics and Data Collector (SDC) Northbound Interface Manager Application" },
154: { "ia.ngn.secretary.ca", "Optical Fiber Network's Operations Support System Secretary Application" },
155: { "ia.ngn.service.wfa", "Optical Fiber Network's Operations Support System Service Manager Application" },
156: { "ia.ngn.servicerequest.wfa", "Optical Fiber Network's Operations Support System Server Request Order Manager Application" },
157: { "ia.ngn.softx.ca", "Optical Fiber Network's Operations Support System Huawei SoftX3000 Manager Application" },
158: { "ia.ngn.sps.ca", "Optical Fiber Network's Operations Support System Huawei SPS Signaling Service Processing System Manager Application" },
159: { "ia.ngn.telegram.ca", "Optical Fiber Network's Operations Support System Telegram Bot API Manager Application" },
160: { "ia.mdaa.ca", "Ministry Database Analysis Application" },
161: };
162:
163: return d;
164: }
165: }
166:
167:
168: ////////////////////////////////////////////////////////////////////////////
169:
170: /// <summary>
171: ///
172: /// </summary>
173: public static int VisitorCounter
174: {
175: get
176: {
177: lock (objectLock)
178: {
179: if (visitorCounter == 0) visitorCounter = 100;
180:
181: return visitorCounter++;
182: }
183: }
184: }
185:
186: /*
187: ////////////////////////////////////////////////////////////////////////////
188:
189: /// <summary>
190: ///
191: /// </summary>
192: public static Ia.Ngn.Cl.Model.Business.Default.Process Translate(string processNameString)
193: {
194: Ia.Ngn.Cl.Model.Business.Default.Process process;
195:
196: switch (processNameString)
197: {
198: case "Create": process = Ia.Ngn.Cl.Model.Business.Default.Process.Create; break;
199: case "Read": process = Ia.Ngn.Cl.Model.Business.Default.Process.Read; break;
200: case "Update": process = Ia.Ngn.Cl.Model.Business.Default.Process.Update; break;
201: case "Delete": process = Ia.Ngn.Cl.Model.Business.Default.Process.Delete; break;
202: default: process = Ia.Ngn.Cl.Model.Business.Default.Process.Read; break;
203: }
204:
205: return process;
206: }
207: */
208:
209: ////////////////////////////////////////////////////////////////////////////
210:
211: /// <summary>
212: /// Flag to indicate if the applications should be running
213: /// </summary>
214: public static bool AllowApplicationsToRun
215: {
216: get
217: {
218: return allowApplicationsToRun;
219: }
220:
221: set
222: {
223: allowApplicationsToRun = value;
224: }
225:
226: /*
227: {
228: get
229: {
230: bool b;
231: DateTime dateTime;
232:
233: dateTime = DateTime.UtcNow.AddHours(3);
234:
235: // below: I decided to keep the system always running pending a possible contract
236: b = true; // dateTime.Year == 2019 && dateTime.Month <= 10;
237:
238: return b;
239: }
240: }
241: */
242: }
243:
244: ////////////////////////////////////////////////////////////////////////////
245:
246: /// <summary>
247: ///
248: /// </summary>
249: public static string OntId(string ponId, int ontNumber)
250: {
251: string id;
252:
253: id = ponId + ontNumber.ToString().PadLeft(2, '0');
254:
255: if (id.Length != fixedLengthOfOntId)
256: {
257: throw new ArgumentOutOfRangeException(@"OntId(): Id length is not " + fixedLengthOfOntId);
258: }
259:
260: return id;
261: }
262:
263: ////////////////////////////////////////////////////////////////////////////
264:
265: /// <summary>
266: ///
267: /// </summary>
268: public static bool DataIsValid(Ia.Ngn.Cl.Model.Business.Default.ValidityOfData validityOfData, DateTime now, DateTime timestamp)
269: {
270: bool valid;
271:
272: if (validityOfData == Ia.Ngn.Cl.Model.Business.Default.ValidityOfData.Year && now.Year == timestamp.Year) valid = true;
273: else if (now.Year == timestamp.Year)
274: {
275: if (validityOfData == Ia.Ngn.Cl.Model.Business.Default.ValidityOfData.Month && now.Month == timestamp.Month) valid = true;
276: else if (validityOfData == Ia.Ngn.Cl.Model.Business.Default.ValidityOfData.Week && now.DayOfYear >= timestamp.DayOfYear && now.DayOfYear < timestamp.DayOfYear + 7) valid = true;
277: else if (now.DayOfYear == timestamp.DayOfYear)
278: {
279: if (validityOfData == Ia.Ngn.Cl.Model.Business.Default.ValidityOfData.Day) valid = true;
280: else if (validityOfData == Ia.Ngn.Cl.Model.Business.Default.ValidityOfData.TwelveHours && now.Hour >= timestamp.Hour && now.Hour < timestamp.Hour + 12) valid = true;
281: else if (validityOfData == Ia.Ngn.Cl.Model.Business.Default.ValidityOfData.Hour && now.Hour == timestamp.Hour) valid = true;
282: else if (validityOfData == Ia.Ngn.Cl.Model.Business.Default.ValidityOfData.Minute && now.Hour == timestamp.Hour && now.Minute == timestamp.Minute) valid = true;
283: else valid = false;
284: }
285: else valid = false;
286: }
287: else valid = false;
288:
289: return valid;
290: }
291:
292: ////////////////////////////////////////////////////////////////////////////
293:
294: /// <summary>
295: ///
296: /// </summary>
297: public static Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Ont NddOntUsingExtractedAccessNameWithValidSymbolAndLegalFormatForPonAndOntFromValue(string accessNameRow)
298: {
299: Dictionary<int, string> typeDictionary;
300:
301: typeDictionary = new Dictionary<int, string>(1);
302: typeDictionary.Add(1, accessNameRow.ToUpper());
303:
304: var nddOnt = NddOntUsingExtractedAccessNameWithValidSymbolAndLegalFormatForPonAndOntFromDictionaryValueList(typeDictionary);
305:
306: return nddOnt;
307: }
308:
309: ////////////////////////////////////////////////////////////////////////////
310:
311: /// <summary>
312: ///
313: /// </summary>
314: public static Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Ont NddOntFromHuaweiEmsAccessNameFormat(string mduName)
315: {
316: var s = Ia.Ngn.Cl.Model.Business.Huawei.Ems.HuaweiAccessNameFormatFromInaccurateHuaweiFileAndEmsNameFormat(mduName);
317:
318: var nddOnt = Ia.Ngn.Cl.Model.Business.Default.NddOntUsingExtractedAccessNameWithValidSymbolAndLegalFormatForPonAndOntFromValue(s);
319:
320: return nddOnt;
321: }
322:
323: ////////////////////////////////////////////////////////////////////////////
324:
325: /// <summary>
326: ///
327: /// </summary>
328: public static Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Msan MsanFromHuaweiEmsDev(string dev)
329: {
330: var msan = (from m in Ia.Ngn.Cl.Model.Data.Huawei.Default.MsanDevList
331: where m.Dev == dev
332: select m.Msan).SingleOrDefault();
333:
334: return msan;
335: }
336:
337: ////////////////////////////////////////////////////////////////////////////
338:
339: /// <summary>
340: ///
341: /// </summary>
342: public static string ExtractPonNameWithValidSymbolAndLegalFormatForPonAndOntFromValue(string value)
343: {
344: string ponName;
345: Dictionary<int, string> typeDictionary;
346:
347: // below: we will replace ' ' and '/' with '.' to avoid errors
348: value = value.Replace(" ", ".");
349: value = value.Replace("/", ".");
350:
351: typeDictionary = new Dictionary<int, string>(1);
352: typeDictionary.Add(1, value + ".1"); // to mimic a WWW.D.1 format
353:
354: var nddOnt = NddOntUsingExtractedAccessNameWithValidSymbolAndLegalFormatForPonAndOntFromDictionaryValueList(typeDictionary);
355:
356: if (nddOnt != null) ponName = nddOnt.Pon.Name;
357: else ponName = string.Empty;
358:
359: return ponName;
360: }
361:
362: ////////////////////////////////////////////////////////////////////////////
363:
364: /// <summary>
365: ///
366: /// </summary>
367: public static string StandardizeAccessNameInLegalFormatFromValue(string value)
368: {
369: string accessName;
370: Dictionary<int, string> typeDictionary;
371:
372: typeDictionary = new Dictionary<int, string>(1);
373: typeDictionary.Add(1, value);
374:
375: accessName = ExtractAccessNameInLegalFormatFromDictionaryValueList(typeDictionary);
376:
377: return accessName;
378: }
379:
380: ////////////////////////////////////////////////////////////////////////////
381:
382: /// <summary>
383: ///
384: /// </summary>
385: public static Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Ont NddOntUsingExtractedAccessNameWithValidSymbolAndLegalFormatForPonAndOntFromDictionaryValueList(Dictionary<int, string> typeDictionary)
386: {
387: bool b;
388: string p1, p2, p3, p4, p5, p45, p55;
389: Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Ont nddOnt;
390:
391: p1 = (typeDictionary.ContainsKey(1)) ? typeDictionary[1] : "";
392: p2 = (typeDictionary.ContainsKey(2)) ? typeDictionary[2] : "";
393: p3 = (typeDictionary.ContainsKey(3)) ? typeDictionary[3] : "";
394: p4 = (typeDictionary.ContainsKey(4)) ? typeDictionary[4] : "";
395: p5 = (typeDictionary.ContainsKey(5)) ? typeDictionary[5] : "";
396: p45 = (typeDictionary.ContainsKey(45)) ? typeDictionary[45] : "";
397: p55 = (typeDictionary.ContainsKey(55)) ? typeDictionary[55] : "";
398:
399: b = ExtractAccessNameWithLegalFormatForPonAndOntMatchFromString(p2, out Match match);
400:
401: if (!b)
402: {
403: b = ExtractAccessNameWithLegalFormatForPonAndOntMatchFromString(p1, out match);
404:
405: if (!b)
406: {
407: b = ExtractAccessNameWithLegalFormatForPonAndOntMatchFromString(p55, out match);
408:
409: if (!b)
410: {
411: b = ExtractAccessNameWithLegalFormatForPonAndOntMatchFromTwoStrings(p1, p2, out match);
412:
413: if (!b)
414: {
415: b = ExtractAccessNameWithLegalFormatForPonAndOntMatchFromTwoStrings(p1, p45, out match);
416:
417: if (!b)
418: {
419: b = ExtractAccessNameWithLegalFormatForPonAndOntMatchFromTwoStrings(p2, p45, out match);
420:
421: if (!b)
422: {
423: b = ExtractAccessNameWithLegalFormatForPonAndOntMatchFromTwoStrings(p1, p4, out match);
424:
425: if (!b)
426: {
427: b = ExtractAccessNameWithLegalFormatForPonAndOntMatchFromString(p4, out match);
428:
429: if (!b)
430: {
431: b = ExtractAccessNameWithLegalFormatForPonAndOntMatchFromString(p5, out match);
432:
433: if (!b)
434: {
435: b = ExtractAccessNameWithLegalFormatForPonAndOntMatchFromString(p3, out match);
436:
437: if (!b)
438: {
439: b = ExtractAccessNameWithLegalFormatForPonAndOntMatchFromTwoStrings(p1, p3, out match);
440: }
441: }
442: }
443: }
444: }
445: }
446: }
447: }
448: }
449: }
450:
451: if (b)
452: {
453: if (match.Success)
454: {
455: var symbol = match.Groups[1].Captures[0].Value;
456: var ponNumber = int.Parse(match.Groups[2].Captures[0].Value);
457: var ontNumber = int.Parse(match.Groups[3].Captures[0].Value);
458:
459: nddOnt = Ia.Ngn.Cl.Model.Data.NetworkDesignDocument.OntByAccessName(symbol + "." + ponNumber + "." + ontNumber);
460: }
461: else
462: {
463: nddOnt = null;
464: }
465: }
466: else nddOnt = null;
467:
468: return nddOnt;
469: }
470:
471: ////////////////////////////////////////////////////////////////////////////
472:
473: /// <summary>
474: ///
475: /// </summary>
476: public static string ExtractAccessNameInLegalFormatFromDictionaryValueList(Dictionary<int, string> typeDictionary)
477: {
478: bool b;
479: int ponNumber, ontNumber;
480: string p1, p2, p3, p4, p5, p45, symbol, accessName;
481: Match match;
482:
483: p1 = (typeDictionary.ContainsKey(1)) ? typeDictionary[1] : "";
484: p2 = (typeDictionary.ContainsKey(2)) ? typeDictionary[2] : "";
485: p3 = (typeDictionary.ContainsKey(3)) ? typeDictionary[3] : "";
486: p4 = (typeDictionary.ContainsKey(4)) ? typeDictionary[4] : "";
487: p5 = (typeDictionary.ContainsKey(5)) ? typeDictionary[5] : "";
488: p45 = (typeDictionary.ContainsKey(45)) ? typeDictionary[45] : "";
489:
490: b = ExtractAccessNameWithLegalFormatForPonAndOntMatchFromString(p2, out match);
491:
492: if (!b)
493: {
494: b = ExtractAccessNameWithLegalFormatForPonAndOntMatchFromString(p1, out match);
495:
496: if (!b)
497: {
498: b = ExtractAccessNameWithLegalFormatForPonAndOntMatchFromTwoStrings(p1, p2, out match);
499:
500: if (!b)
501: {
502: b = ExtractAccessNameWithLegalFormatForPonAndOntMatchFromTwoStrings(p1, p45, out match);
503:
504: if (!b)
505: {
506: b = ExtractAccessNameWithLegalFormatForPonAndOntMatchFromTwoStrings(p2, p45, out match);
507:
508: if (!b)
509: {
510: b = ExtractAccessNameWithLegalFormatForPonAndOntMatchFromTwoStrings(p1, p4, out match);
511:
512: if (!b)
513: {
514: b = ExtractAccessNameWithLegalFormatForPonAndOntMatchFromString(p4, out match);
515:
516: if (!b)
517: {
518: b = ExtractAccessNameWithLegalFormatForPonAndOntMatchFromString(p5, out match);
519:
520: if (!b)
521: {
522: b = ExtractAccessNameWithLegalFormatForPonAndOntMatchFromString(p3, out match);
523:
524: if (!b)
525: {
526: b = ExtractAccessNameWithLegalFormatForPonAndOntMatchFromTwoStrings(p1, p3, out match);
527: }
528: }
529: }
530: }
531: }
532: }
533: }
534: }
535: }
536:
537: if (b)
538: {
539: if (match.Success)
540: {
541: symbol = match.Groups[1].Captures[0].Value;
542:
543: ponNumber = int.Parse(match.Groups[2].Captures[0].Value);
544: ontNumber = int.Parse(match.Groups[3].Captures[0].Value);
545:
546: accessName = symbol.ToUpper() + "." + ponNumber + "." + ontNumber;
547: }
548: else
549: {
550: accessName = string.Empty;
551: }
552: }
553: else
554: {
555: accessName = string.Empty;
556: }
557:
558: return accessName;
559: }
560:
561: ////////////////////////////////////////////////////////////////////////////
562:
563: /// <summary>
564: ///
565: /// </summary>
566: private static bool ExtractAccessNameWithLegalFormatForPonAndOntMatchFromString(string s, out Match match)
567: {
568: // below: this checks if string conferms
569: bool b;
570: const string pattern = @"([a-zA-Z]{3})\.(\d{1,4})\.(\d{1,3})";
571: Regex regex;
572:
573: match = null;
574: regex = new Regex(pattern);
575:
576: if (!string.IsNullOrEmpty(s))
577: {
578: s = s.ToUpper();
579:
580: if (!regex.IsMatch(s))
581: {
582: s = s.Replace("-", ".");
583: s = s.Replace("/", ".");
584: s = s.Replace(" ", ".");
585: s = s.Replace(",", ".");
586:
587: if (!regex.IsMatch(s))
588: {
589: s = s.Replace(". ", ".");
590:
591: if (!regex.IsMatch(s))
592: {
593: s = s.Replace(" .", ".");
594:
595: if (!regex.IsMatch(s))
596: {
597: s = s.Replace(".00", ".");
598: s = s.Replace(".0", ".");
599:
600: if (!regex.IsMatch(s))
601: {
602: s = s.Replace("...", ".");
603: s = s.Replace("..", ".");
604:
605: if (!regex.IsMatch(s))
606: {
607: s = Regex.Replace(s, @"\.$", @"");
608:
609: if (!regex.IsMatch(s))
610: {
611: s = Regex.Replace(s, @"([a-zA-Z]{3})(\d{1,4})\.(\d{1,3})", @"$1.$2.$3");
612:
613: if (!regex.IsMatch(s))
614: {
615: s = Regex.Replace(s, @"([a-zA-Z]{3})\.(\d{3})(\d{3})", @"$1.$2.$3");
616:
617: if (!regex.IsMatch(s))
618: {
619: s = Regex.Replace(s, @"([a-zA-Z]{3})\.(\d{4})(\d{3})", @"$1.$2.$3");
620:
621: if (!regex.IsMatch(s))
622: {
623: s = Regex.Replace(s, @"([a-zA-Z]{3})(\d{3})(\d{3})", @"$1.$2.$3");
624:
625: if (!regex.IsMatch(s))
626: {
627: s = Regex.Replace(s, @"([a-zA-Z]{3})(\d{4})(\d{3})", @"$1.$2.$3");
628:
629: if (!regex.IsMatch(s))
630: {
631: s = Regex.Replace(s, @"([a-zA-Z]{3})\.(\d{1,4}) (\d{1,3})", @"$1.$2.$3");
632:
633: if (!regex.IsMatch(s))
634: {
635: s = Regex.Replace(s, @"([a-zA-Z]{3}) (\d{1,4}) (\d{1,3})", @"$1.$2.$3");
636: }
637: }
638: }
639: }
640: }
641: }
642: }
643: }
644: }
645: }
646: }
647: }
648: }
649:
650: match = Regex.Match(s, pattern);
651:
652: if (match.Success) b = true;
653: else b = false;
654: }
655: else b = false;
656:
657: return b;
658: }
659:
660: ////////////////////////////////////////////////////////////////////////////
661:
662: /// <summary>
663: ///
664: /// </summary>
665: private static bool ExtractAccessNameWithLegalFormatForPonAndOntMatchFromTwoStrings(string s1, string s2, out Match match)
666: {
667: // below: this checks if string conferms
668: bool b;
669: match = null;
670:
671: s1 = s1.Replace("-", ".");
672: s1 = s1.Replace("/", ".");
673: s1 = s1.Replace(" /", "/");
674: s1 = s1.ToUpper();
675: s1 = s1.Replace("ZHA", "ZAH");
676: s1 = s1.Replace("JAB", "JBA");
677:
678: s1 = Regex.Replace(s1, @"([a-zA-Z]{3})(\d{1,4})", @"$1.$2");
679:
680: if (Regex.IsMatch(s1, @"[a-zA-Z]{3}\.\d{1,4}") && Regex.IsMatch(s2, @"\d{1,3}"))
681: {
682: b = ExtractAccessNameWithLegalFormatForPonAndOntMatchFromString(s1 + @"." + s2, out match);
683: }
684: else b = false;
685:
686: return b;
687: }
688:
689: ////////////////////////////////////////////////////////////////////////////
690:
691: /// <summary>
692: /// ASP.NET State Management
693: /// below: remove later to default.cs or state.cs
694: /// <remarks>https://msdn.microsoft.com/en-us/library/z1hkazw7(v=vs.100).aspx</remarks>
695: /// </summary>
696: public static bool Application(string name, int lifeInMinutes, object o)
697: {
698: bool valueStored;
699: DateTime expiration;
700:
701: if (name != string.Empty)
702: {
703: expiration = DateTime.UtcNow.AddMinutes(3 * 60 + lifeInMinutes);
704:
705: HttpContext.Current.Application[name + "|" + lifeInMinutes.ToString()] = o;
706:
707: valueStored = true;
708: }
709: else valueStored = false;
710:
711: return valueStored;
712: }
713:
714: ////////////////////////////////////////////////////////////////////////////
715:
716: /// <summary>
717: ///
718: /// </summary>
719: public static object Application(string name)
720: {
721: string expirationString;
722: DateTime expiration;
723: object o;
724:
725: o = null;
726:
727: // below: loop through keys to find the one that starts with name
728: foreach (string s in HttpContext.Current.Application.AllKeys)
729: {
730: if (s.Contains(name + "|"))
731: {
732: expirationString = Ia.Cl.Model.Default.Match(s, @"\|(.+)");
733:
734: expiration = DateTime.Parse(expirationString);
735:
736: if (expiration < DateTime.UtcNow.AddHours(3))
737: {
738: // below: did not expire
739:
740: o = HttpContext.Current.Application[s];
741: }
742: else o = null;
743: }
744: }
745:
746: return o;
747: }
748:
749: ////////////////////////////////////////////////////////////////////////////
750:
751: /// <summary>
752: /// RecordState holds the current state of the record according to user and system interactions with it. It could be used as an
753: /// indicator to define the current state of the record and how it should be handle in state monitoring execution cycles.
754: /// </summary>
755: public enum RecordState
756: {
757: Undefined = 0, Synchronized = 10, Synchronize = 20, Modified = 30, Updated = 40, Etc = 50
758: };
759:
760: ////////////////////////////////////////////////////////////////////////////
761:
762: /// <summary>
763: ///
764: /// </summary>
765: public Default() { }
766:
767: ////////////////////////////////////////////////////////////////////////////
768:
769: /// <summary>
770: ///
771: /// </summary>
772: public static string CorrectCustomerAddress(string addressString)
773: {
774: addressString = addressString.Trim();
775:
776: //line = Ia.Cl.Model.Language.ConvertSingleLatinDigitsToArabicWordEquivalents(line);
777: //line = Ia.Cl.Model.Language.RemoveNonArabicAndNonArabicExtendedLettersAndDigits(line);
778: //line = Ia.Cl.Model.Language.CorrectArabicNameNounStringFormat(line);
779: // to do line = Ia.Cl.Model.Language.RemoveTitlesFromNames(line);
780: // to do line = Ia.Cl.Model.Language.CorrectArabicNameNounFormat(line);
781: // to do line = Ia.Cl.Model.Language.CorrectArabicNonNameNounStringFormat(line);
782: //line = Ia.Cl.Model.Language.RemoveWrongSpaceBetweenArabicDefinitArticleAndItsWord(line);
783: //line = Regex.Replace(line, @"\s+", @" ");
784:
785: // order is important
786:
787: // BYN
788: addressString = addressString.Replace(" جادة الفتره 1-20/2009 المرحله الثانيه", "");
789: addressString = addressString.Replace(" جادة جادة الفتره 23/11-20/12/2009 1-20/12/2009", "");
790: addressString = addressString.Replace(" جادة الفتره 23/11-20/12/2009", "");
791: addressString = addressString.Replace(" جادة الفتره 23/11-20/12/2009", "");
792: addressString = addressString.Replace(" جادة الفتره /23/11-20/12/2009", "");
793: addressString = addressString.Replace(" شارع المرحله الثانيه /قاعه التحرير", " شارع قاعة التحرير");
794: addressString = addressString.Replace(" جادة الفتره 1-20/12/2009", "");
795: addressString = addressString.Replace(" جادة الفتره/1-20/12/2009", "");
796: addressString = addressString.Replace(" جادة الفتره -1-20/12/2009", "");
797: addressString = addressString.Replace(" جادة الفتره/1-20/12/2009", "");
798: addressString = addressString.Replace(" جادة الفترة1-20-12-2009", "");
799: addressString = addressString.Replace(" جادة الفترهة 1-20/12/2009", "");
800: addressString = addressString.Replace(" جادة 1-20/12/2009", "");
801: addressString = addressString.Replace(" جادة الفتره1-20-12-2009", "");
802: addressString = addressString.Replace(" جادة الفتره 1-200/12/2009", "");
803: addressString = addressString.Replace(" جادة الفتره-1-20/12/2009", "");
804: addressString = addressString.Replace(" جادة الفتره 1-20/2009", "");
805: addressString = addressString.Replace("قطعة قصر بيان", "قطعة 2");
806: addressString = addressString.Replace("حولى مشرف,, منزل قصر بيان", "حولى بيان,قطعة 2, منزل قصر بيان");
807: addressString = addressString.Replace("حولى بيان,, منزل قصر بيان", "حولى بيان,قطعة 2, منزل قصر بيان");
808: addressString = addressString.Replace("منزل قصربيان", "منزل قصر بيان");
809: // end BYN
810:
811: //
812: //
813:
814: addressString = addressString.Replace("جادة جاده", "جادة ");
815: addressString = addressString.Replace("جادة جادة", "جادة ");
816: addressString = addressString.Replace("شارع الأول", "شارع 1");
817: addressString = addressString.Replace("شارع الاول", "شارع 1");
818: addressString = addressString.Replace("شارع الثانى", "شارع 2");
819: addressString = addressString.Replace("شارع الثاني", "شارع 2");
820: addressString = addressString.Replace("شارع الثالث", "شارع 3");
821: addressString = addressString.Replace("شارع الرابع", "شارع 4");
822: addressString = addressString.Replace("شارع الخامس", "شارع 5");
823: addressString = addressString.Replace("شارع السادس", "شارع 6");
824: addressString = addressString.Replace("شارع السابع", "شارع 7");
825: addressString = addressString.Replace("شارع الثامن", "شارع 8");
826: addressString = addressString.Replace("شارع التاسع", "شارع 9");
827:
828: addressString = addressString.Replace("شارع طريق ", "شارع ");
829: addressString = addressString.Replace(" جاده ", " جادة ");
830: addressString = addressString.Replace("_", " ");
831: addressString = addressString.Replace("***", "0");
832: addressString = addressString.Replace("**", "0");
833: addressString = addressString.Replace("*", "0");
834:
835: // SLA
836: addressString = addressString.Replace("شارع علي الجسار", "شارع 22");
837: addressString = addressString.Replace(@"شارع 26 / علي نقي النقي", "شارع 26");
838: addressString = addressString.Replace(@"شارع علي النقي", "شارع 26");
839: // end SLA
840:
841: addressString = addressString.Trim();
842:
843: return addressString;
844: }
845:
846: ////////////////////////////////////////////////////////////////////////////
847:
848: /// <summary>
849: ///
850: /// </summary>
851: public static string CorrectCustomerAddressMissingProvinceArea(string service, string addressString)
852: {
853: // correct some missing information in address lines based on service number
854:
855: if (service.StartsWith("2453") || service.StartsWith("2454")) addressString = "الجهراء سعد العبدالله" + addressString;
856: //else if (service.StartsWith("2466")) addressString = "الفروانية القيروان" + addressString; delete later
857: //else if (service.StartsWith("2435") || service.StartsWith("2436")) addressString = "الفروانية عبدالله المبارك" + addressString; delete later
858: //else if (service.StartsWith("2363")) addressString = "الأحمدي فهد الأحمد" + addressString; delete later
859: else if (service.StartsWith("2368")) addressString = "الأحمدي لآلئ الخيران" + addressString;
860:
861: return addressString;
862: }
863:
864: ////////////////////////////////////////////////////////////////////////////
865:
866: /// <summary>
867: ///
868: /// </summary>
869: public static string CorrectCustomerName(string line)
870: {
871: line = line.Trim();
872: //line = Ia.Cl.Model.Language.ConvertSingleLatinDigitsToArabicWordEquivalents(line);
873: line = Ia.Cl.Model.Language.RemoveNonNativeAndNonNativeExtendedLettersAndDigitsAccordingToLanguage("ar", line);
874: line = Ia.Cl.Model.Language.CorrectArabicNameNounStringFormat(line);
875: // to do line = Ia.Cl.Model.Language.RemoveTitlesFromNames(line);
876: // to do line = Ia.Cl.Model.Language.CorrectArabicNameNounFormat(line);
877: // to do line = Ia.Cl.Model.Language.CorrectArabicNonNameNounStringFormat(line);
878: line = Ia.Cl.Model.Language.RemoveWrongSpaceBetweenNativeDefinitArticleAndItsWord("ar", line);
879: line = Regex.Replace(line, @"\s+", @" ");
880: line = line.Trim();
881:
882: return line;
883: }
884:
885: ////////////////////////////////////////////////////////////////////////////
886:
887: /// <summary>
888: ///
889: /// </summary>
890: public static DataTable ReturnDataTableOfServiceAdministrativeStateOfANumberInOldNgnDatabase(long dn)
891: {
892: string sql;
893: DataTable dt;
894: Ia.Cl.Model.Db.SqlServer ngn;
895:
896: sql = @"SELECT sa.state, srs.active FROM ia_service_administrative AS sa LEFT OUTER JOIN ia_service_request_service AS srs ON srs.dn = sa.dn WHERE (sa.dn = " + dn + ")";
897: dt = null;
898:
899: try
900: {
901: ngn = new Ia.Cl.Model.Db.SqlServer(ConfigurationManager.ConnectionStrings["DefaultConnectionToNgn"].ConnectionString);
902:
903: dt = ngn.Select(sql);
904: }
905: catch (Exception)
906: {
907: }
908:
909: return dt;
910: }
911:
912: ////////////////////////////////////////////////////////////////////////////
913:
914: /// <summary>
915: ///
916: /// </summary>
917: public static void UpdateServiceAdministrativeStateOfANumberInOldNgnDatabase(long dn, string state)
918: {
919: string sql;
920: Ia.Cl.Model.Db.SqlServer ngn;
921:
922: sql = @"UPDATE ia_service_administrative SET state = " + state + " WHERE dn = " + dn;
923:
924: try
925: {
926: ngn = new Ia.Cl.Model.Db.SqlServer(ConfigurationManager.ConnectionStrings["DefaultConnectionToNgn"].ConnectionString);
927:
928: ngn.Sql(sql);
929: }
930: catch (Exception)
931: {
932: }
933: }
934:
935: ////////////////////////////////////////////////////////////////////////////
936: ////////////////////////////////////////////////////////////////////////////
937:
938: /// <summary>
939: ///
940: /// </summary>
941: public static bool IsKuwaitLandlineService(string service)
942: {
943: bool isValid;
944:
945: if (!string.IsNullOrEmpty(service))
946: {
947: if (int.TryParse(service, out int number))
948: {
949: isValid = IsKuwaitLandlineNumber(number);
950: }
951: else isValid = false;
952: }
953: else isValid = false;
954:
955: return isValid;
956: }
957:
958: ////////////////////////////////////////////////////////////////////////////
959:
960: /// <summary>
961: ///
962: /// </summary>
963: public static bool IsKuwaitLandlineNumber(int number)
964: {
965: bool b;
966:
967: b =
968: (number >= 22000000 && number <= 22999999) ||
969: (number >= 23000000 && number <= 23999999) ||
970: (number >= 24100000 && number <= 24399999) ||
971: (number >= 24500000 && number <= 24999999) ||
972: (number >= 25000000 && number <= 25009999) ||
973: (number >= 25030000 && number <= 25049999) ||
974: (number >= 25200000 && number <= 25499999) ||
975: (number >= 25510000 && number <= 25539999) ||
976: (number >= 25600000 && number <= 25699999) ||
977: (number >= 25710000 && number <= 25779999);
978:
979: return b;
980: }
981:
982: ////////////////////////////////////////////////////////////////////////////
983:
984: /// <summary>
985: ///
986: /// </summary>
987: public static int ChangeOldSevenDigitNumbersToEightDigitFormat(int o)
988: {
989: // below: take an old 7 digit number and covert it to the new 8 digit number according to plan
990:
991: int n;
992:
993: // below: check if it is already an 8 digit number
994: if (o >= 10000000) n = o;
995:
996: // 2 (NGN):
997: else if (
998: (o >= 2000000 && o <= 2999999) ||
999: (o >= 3000000 && o <= 3999999) ||
(o >= 4100000 && o <= 4399999) ||
(o >= 4500000 && o <= 4999999) ||
(o >= 5000000 && o <= 5009999) ||
(o >= 5030000 && o <= 5049999) ||
(o >= 5200000 && o <= 5499999) ||
(o >= 5510000 && o <= 5539999) ||
(o >= 5600000 && o <= 5699999) ||
(o >= 5710000 && o <= 5779999)) { n = 20000000 + o; }
//6 (Wataniya):
else if (
(o >= 5010000 && o <= 5029999) ||
(o >= 5050000 && o <= 5099999) ||
(o >= 5100000 && o <= 5199999) ||
(o >= 5500000 && o <= 5509999) ||
(o >= 5540000 && o <= 5599999) ||
(o >= 5700000 && o <= 5709999) ||
(o >= 5780000 && o <= 5799999) ||
(o >= 5800000 && o <= 5999999) ||
(o >= 6000000 && o <= 6999999) ||
(o >= 7000000 && o <= 7019999) ||
(o >= 7030000 && o <= 7099999) ||
(o >= 7700000 && o <= 7769999) ||
(o >= 7780000 && o <= 7799999)) { n = 60000000 + o; }
//1 (NGN):
else if (o >= 800000 && o <= 899999) { n = 1000000 + o; }
//9 (Zain):
else if (
(o >= 7020000 && o <= 7029999) ||
(o >= 7100000 && o <= 7699999) ||
(o >= 7800000 && o <= 7999999) ||
(o >= 9000000 && o <= 9999999) ||
(o >= 4400000 && o <= 4499999) ||
(o >= 4000000 && o <= 4099999)) { n = 90000000 + o; }
else n = o;
return n;
/*
New numbering list
Add digit,Old Numbers Ranges,Operator
,From,To,
2,2-000000,2-999999,MOC
2,3-000000,3-999999,MOC
9,40-00000,40-99999,Zain
2,41-00000,43-99999,MOC
9,44-00000,44-99999,Zain
2,45-00000,49-99999,MOC
2,500-0000,500-9999,MOC
6,501-0000,502-9999,Wataniya
2,503-0000,504-9999,MOC
6,505-0000,509-9999,Wataniya
6,51-00000,51-99999,Wataniya
2,52-00000,54-99999,MOC
6,550-0000,550-9999,Wataniya
2,551-0000,553-9999,MOC
6,554-0000,559-9999,Wataniya
2,56-00000,56-99999,MOC
6,570-0000,570-9999,Wataniya
2,571-0000,577-9999,MOC
6,578-0000,579-9999,Wataniya
6,58-00000,59-99999,Wataniya
6,6-000000,6-999999,Wataniya
6,700-0000,701-9999,Wataniya
9,702-0000,702-9999,Zain
6,703-0000,709-9999,Wataniya
9,71-00000,76-99999,Zain
6,770-0000,776-9999,Wataniya
6,778-0000,779-9999,Wataniya
9,78-00000,79-99999,Zain
1,800-000,899-999,MOC
9,9-000000,9-999999,Zain
Example: the number 2123456 will become 22123456.
Notice: Unchanged numbers:
•,The international numbers outside Kuwait do not change and need the prefix 00 followed by the country code. For example, for the United Kingdom, dial 00 44 1234567890.
•,The country code for Kuwait 965 stays the same (for international incoming calls).
•,The 3 digits numbers do not change (numbers from 100 to 179). For example, for the Inquiry Directory, dial 101.
•,The emergency number in Kuwait 112 does not change.
*/
}
////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////
/// <summary>
///
/// </summary>
public static void DifferencesBetweenServiceRequestAndServiceRequestHistoryAndServiceRequestServiceData(out List<string> mismatchBetweenSrAndSrsList, out List<string> mismatchBetweenSrAndSrhList, out List<string> inSrhNotInSrList, out List<string> inSrNotInSrhList, out string serviceIdIssue, out int serviceRequestServiceListCount, out int serviceRequestNumberSerialComplementaryServiceDictionaryCount, out int serviceRequestHistoryNumberSerialComplementaryServiceDictionaryCount, out int matchedServiceRequestAndServiceRequestHistoryNumberSerialComplementaryServiceDictionaryCount, out int matchedServiceRequestAndServiceRequestServiceNumberSerialComplementaryServiceDictionaryCount)
{
int number, serial, status, serviceId;
string service, serviceSerial;
Ia.Ngn.Cl.Model.Business.ServiceSerialRequestService serviceSerialRequestService;
List<string> serviceSerialsToRemoveList;
List<Ia.Ngn.Cl.Model.ServiceRequest> serviceRequestList;
List<Ia.Ngn.Cl.Model.ServiceRequestHistory> serviceRequestHistoryList;
List<Ia.Ngn.Cl.Model.Business.ServiceSerialRequestService> serviceRequestServiceList;
Dictionary<string, int> serviceToLastSerialDictionary;
Dictionary<string, Ia.Ngn.Cl.Model.Business.ServiceSerialRequestService> serviceRequestServiceNumberSerialComplementaryServiceDictionary, serviceRequestNumberSerialComplementaryServiceDictionary, serviceRequestHistoryNumberSerialComplementaryServiceDictionary, matchedServiceRequestAndServiceRequestHistoryNumberSerialComplementaryServiceDictionary, matchedServiceRequestAndServiceRequestServiceNumberSerialComplementaryServiceDictionary;
mismatchBetweenSrAndSrsList = new List<string>();
mismatchBetweenSrAndSrhList = new List<string>();
serviceSerialsToRemoveList = new List<string>();
inSrhNotInSrList = new List<string>();
inSrNotInSrhList = new List<string>();
number = 0; // 24555994;// 25210209;// 24550208;
if (number == 0)
{
serviceRequestList = Ia.Ngn.Cl.Model.Data.ServiceRequest.List();
serviceRequestHistoryList = Ia.Ngn.Cl.Model.Data.ServiceRequestHistory.List();
serviceRequestServiceList = Ia.Ngn.Cl.Model.Data.ServiceRequestService.ServiceSerialRequestServiceList();
}
else
{
serviceRequestList = Ia.Ngn.Cl.Model.Data.ServiceRequest.List(number);
serviceRequestHistoryList = Ia.Ngn.Cl.Model.Data.ServiceRequestHistory.List(number);
serviceRequestServiceList = Ia.Ngn.Cl.Model.Data.ServiceRequestService.ServiceSerialRequestServiceList(number.ToString());
}
serviceIdIssue = string.Empty;
serviceRequestNumberSerialComplementaryServiceDictionary = new Dictionary<string, Ia.Ngn.Cl.Model.Business.ServiceSerialRequestService>(serviceRequestList.Count);
serviceToLastSerialDictionary = new Dictionary<string, int>(serviceRequestList.Count + serviceRequestHistoryList.Count);
// build service request service from service requests
//var list = serviceRequestList.OrderBy(p => p.RequestDateTime.Date).ThenBy(p => p.ServiceId == 38); // <service id="38" arabicName="مجموعة الخدمات" />
var list = serviceRequestList.OrderBy(p => p.RequestDateTime.Date).ThenBy(p => p.ServiceId == 38).ThenBy(p => p.Id); // <service id="38" arabicName="مجموعة الخدمات" />
//var list = serviceRequestHistoryList.OrderBy(p => p.ServiceDateTime).ThenBy(p => p.ServiceId == 38); // <service id="38" arabicName="مجموعة الخدمات" />
foreach (var serviceRequest in list)
{
if (serviceRequest.ServiceCategoryId == 3)
{
// <category id="3" arabicName="هاتف" />
if (serviceRequest.Status == 2003 || serviceRequest.Status == 2005)
{
// <status id="2003" arabicName="قيد التنفيذ" />
// <status id="2005" arabicName="تم التنفيذ" />
service = serviceRequest.Number.ToString();
serial = serviceRequest.Serial;
serviceId = serviceRequest.ServiceId;
status = -1;
serviceSerial = service + ":" + serial;
if (!serviceRequestNumberSerialComplementaryServiceDictionary.ContainsKey(serviceSerial) || serviceRequestNumberSerialComplementaryServiceDictionary.ContainsKey(serviceSerial) && serviceRequestNumberSerialComplementaryServiceDictionary[serviceSerial].Provisioned == false)
{
if (serviceId == 1 || serviceId == 129 || serviceId == 54)
{
// <service id="1" arabicName="خط هاتف" />
// <service id="129" arabicName="خط هاتف مع نداء آلي"/>
// <service id="54" arabicName="اعادة تركيب" />
serviceSerialRequestService = new Ia.Ngn.Cl.Model.Business.ServiceSerialRequestService();
serviceSerialRequestService.Id = serviceSerial;
serviceSerialRequestService.Service = service;
serviceSerialRequestService.Serial = serial;
serviceSerialRequestService.Provisioned = true;
serviceRequestNumberSerialComplementaryServiceDictionary[serviceSerial] = serviceSerialRequestService;
Ia.Ngn.Cl.Model.Business.ServiceRequestService.TelephonyServiceHistory(ref serviceRequestNumberSerialComplementaryServiceDictionary, serviceSerial, status, serviceId, ref serviceIdIssue);
if (serviceToLastSerialDictionary.ContainsKey(service))
{
if (serviceToLastSerialDictionary[service] < serial) serviceToLastSerialDictionary[service] = serial;
}
else serviceToLastSerialDictionary[service] = serial;
}
else
{
// incomplete service request list for serial
}
}
else
{
if (serviceRequestNumberSerialComplementaryServiceDictionary[serviceSerial].Provisioned && serviceRequestNumberSerialComplementaryServiceDictionary[serviceSerial].Serial == serial)
{
if (serviceId == 41)
{
// <service id="41" arabicName="تغيير رقم" />
}
else
{
Ia.Ngn.Cl.Model.Business.ServiceRequestService.TelephonyServiceHistory(ref serviceRequestNumberSerialComplementaryServiceDictionary, serviceSerial, status, serviceId, ref serviceIdIssue);
}
}
}
}
else
{
}
}
}
serviceRequestHistoryNumberSerialComplementaryServiceDictionary = new Dictionary<string, Ia.Ngn.Cl.Model.Business.ServiceSerialRequestService>(serviceRequestHistoryList.Count);
// build service request service from service request histories.
var list2 = serviceRequestHistoryList.OrderBy(p => p.ServiceDateTime.Date).ThenBy(p => p.ServiceId == 38); // <service id="38" arabicName="مجموعة الخدمات" />
foreach (var serviceRequestHistory in list2)
{
if (serviceRequestHistory.ServiceCategoryId == 3)
{
// <category id="3" arabicName="هاتف" />
service = serviceRequestHistory.Number.ToString();
serial = serviceRequestHistory.Serial;
serviceId = serviceRequestHistory.ServiceId;
status = serviceRequestHistory.Status;
serviceSerial = service + ":" + serial;
if (serviceToLastSerialDictionary.ContainsKey(service))
{
if (serviceToLastSerialDictionary[service] < serial) serviceToLastSerialDictionary[service] = serial;
}
else serviceToLastSerialDictionary[service] = serial;
if (!serviceRequestHistoryNumberSerialComplementaryServiceDictionary.ContainsKey(serviceSerial) || serviceRequestHistoryNumberSerialComplementaryServiceDictionary.ContainsKey(serviceSerial) && serviceRequestHistoryNumberSerialComplementaryServiceDictionary[serviceSerial].Provisioned == false)
{
if (serviceId == 1 || serviceId == 129 || serviceId == 54)
{
// <service id="1" arabicName="خط هاتف" />
// <service id="129" arabicName="خط هاتف مع نداء آلي"/>
// <service id="54" arabicName="اعادة تركيب" />
serviceSerialRequestService = new Ia.Ngn.Cl.Model.Business.ServiceSerialRequestService();
serviceSerialRequestService.Id = serviceSerial;
serviceSerialRequestService.Service = service;
serviceSerialRequestService.Serial = serial;
serviceSerialRequestService.Provisioned = true;
serviceRequestHistoryNumberSerialComplementaryServiceDictionary[serviceSerial] = serviceSerialRequestService;
}
else
{
// incomplete service request list for serial
}
}
else
{
if (serviceRequestHistoryNumberSerialComplementaryServiceDictionary[serviceSerial].Provisioned && serviceRequestHistoryNumberSerialComplementaryServiceDictionary[serviceSerial].Serial == serial)
{
if (serviceId == 41)
{
// <service id="41" arabicName="تغيير رقم" />
}
else
{
Ia.Ngn.Cl.Model.Business.ServiceRequestService.TelephonyServiceHistory(ref serviceRequestHistoryNumberSerialComplementaryServiceDictionary, serviceSerial, status, serviceId, ref serviceIdIssue);
}
}
}
}
}
// collect all numbers serials that are not the last in their serial series:
foreach (KeyValuePair<string, Ia.Ngn.Cl.Model.Business.ServiceSerialRequestService> kvp in serviceRequestNumberSerialComplementaryServiceDictionary)
{
if (serviceToLastSerialDictionary.ContainsKey(kvp.Value.Service))
{
if (serviceToLastSerialDictionary[kvp.Value.Service] > kvp.Value.Serial) serviceSerialsToRemoveList.Add(kvp.Key);
}
else
{
serviceIdIssue += "Error: serviceToLastSerialDictionary does not contain kvp.Value.Service: " + kvp.Value.Service + "\r\n";
}
}
foreach (KeyValuePair<string, Ia.Ngn.Cl.Model.Business.ServiceSerialRequestService> kvp in serviceRequestHistoryNumberSerialComplementaryServiceDictionary)
{
if (serviceToLastSerialDictionary.ContainsKey(kvp.Value.Service))
{
if (serviceToLastSerialDictionary[kvp.Value.Service] > kvp.Value.Serial) serviceSerialsToRemoveList.Add(kvp.Key);
}
else
{
serviceIdIssue += "Error: serviceToLastSerialDictionary does not contain kvp.Value.Service: " + kvp.Value.Service + "\r\n";
}
}
// remove previous service-serials
foreach (string s in serviceSerialsToRemoveList)
{
serviceRequestNumberSerialComplementaryServiceDictionary.Remove(s);
serviceRequestHistoryNumberSerialComplementaryServiceDictionary.Remove(s);
}
serviceRequestServiceNumberSerialComplementaryServiceDictionary = new Dictionary<string, Ia.Ngn.Cl.Model.Business.ServiceSerialRequestService>(serviceRequestServiceList.Count);
foreach (var srs in serviceRequestServiceList)
{
serviceSerial = srs.Service + ":" + srs.Serial;
if (!serviceRequestServiceNumberSerialComplementaryServiceDictionary.ContainsKey(serviceSerial))
{
serviceRequestServiceNumberSerialComplementaryServiceDictionary[serviceSerial] = srs;
}
}
mismatchBetweenSrAndSrsList = new List<string>(1000);
mismatchBetweenSrAndSrhList = new List<string>(1000);
inSrNotInSrhList = new List<string>(serviceRequestNumberSerialComplementaryServiceDictionary.Count);
inSrhNotInSrList = new List<string>(serviceRequestHistoryNumberSerialComplementaryServiceDictionary.Count);
matchedServiceRequestAndServiceRequestHistoryNumberSerialComplementaryServiceDictionary = new Dictionary<string, ServiceSerialRequestService>(serviceRequestNumberSerialComplementaryServiceDictionary.Count + serviceRequestHistoryNumberSerialComplementaryServiceDictionary.Count);
matchedServiceRequestAndServiceRequestServiceNumberSerialComplementaryServiceDictionary = new Dictionary<string, ServiceSerialRequestService>(serviceRequestNumberSerialComplementaryServiceDictionary.Count + serviceRequestServiceNumberSerialComplementaryServiceDictionary.Count);
foreach (KeyValuePair<string, Ia.Ngn.Cl.Model.Business.ServiceSerialRequestService> kvp in serviceRequestNumberSerialComplementaryServiceDictionary)
{
if (serviceRequestServiceNumberSerialComplementaryServiceDictionary.ContainsKey(kvp.Key))
{
if (kvp.Value != serviceRequestServiceNumberSerialComplementaryServiceDictionary[kvp.Key])
{
if (!mismatchBetweenSrAndSrsList.Contains(kvp.Key))
{
mismatchBetweenSrAndSrsList.Add(kvp.Key);
}
else
{
}
}
else
{
matchedServiceRequestAndServiceRequestServiceNumberSerialComplementaryServiceDictionary[kvp.Key] = kvp.Value;
}
}
//else inSrhNotInSrsList.Add(kvp.Key);
if (serviceRequestHistoryNumberSerialComplementaryServiceDictionary.ContainsKey(kvp.Key))
{
if (kvp.Value != serviceRequestHistoryNumberSerialComplementaryServiceDictionary[kvp.Key])
{
mismatchBetweenSrAndSrhList.Add(kvp.Key);
}
else
{
matchedServiceRequestAndServiceRequestHistoryNumberSerialComplementaryServiceDictionary[kvp.Key] = kvp.Value;
}
}
else inSrNotInSrhList.Add(kvp.Key);
}
foreach (KeyValuePair<string, Ia.Ngn.Cl.Model.Business.ServiceSerialRequestService> kvp in serviceRequestHistoryNumberSerialComplementaryServiceDictionary)
{
if (serviceRequestNumberSerialComplementaryServiceDictionary.ContainsKey(kvp.Key))
{
if (kvp.Value != serviceRequestNumberSerialComplementaryServiceDictionary[kvp.Key])
{
if (!mismatchBetweenSrAndSrhList.Contains(kvp.Key))
{
mismatchBetweenSrAndSrhList.Add(kvp.Key);
}
else
{
}
}
else
{
matchedServiceRequestAndServiceRequestHistoryNumberSerialComplementaryServiceDictionary[kvp.Key] = kvp.Value;
}
}
else inSrhNotInSrList.Add(kvp.Key);
}
serviceRequestServiceListCount = serviceRequestServiceList.Count;
serviceRequestNumberSerialComplementaryServiceDictionaryCount = serviceRequestNumberSerialComplementaryServiceDictionary.Count;
serviceRequestHistoryNumberSerialComplementaryServiceDictionaryCount = serviceRequestHistoryNumberSerialComplementaryServiceDictionary.Count;
matchedServiceRequestAndServiceRequestHistoryNumberSerialComplementaryServiceDictionaryCount = matchedServiceRequestAndServiceRequestHistoryNumberSerialComplementaryServiceDictionary.Count;
matchedServiceRequestAndServiceRequestServiceNumberSerialComplementaryServiceDictionaryCount = matchedServiceRequestAndServiceRequestServiceNumberSerialComplementaryServiceDictionary.Count;
}
////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////
}
////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////
/// <summary>
/// Number Format Covnerter for Nokia and Huaweri Number Formats for the Optical Fiber Network's Operations Support System - Kuwait
/// </summary>
///
/// <remarks>
/// Copyright © 2001-2021 Jasem Y. Al-Shamlan (info@ia.com.kw), Integrated Applications - Kuwait. All Rights Reserved.
///
/// 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
/// the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
///
/// This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
/// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
///
/// You should have received a copy of the GNU General Public License along with this library. If not, see http://www.gnu.org/licenses.
///
/// Copyright notice: This notice may not be removed or altered from any source distribution.
/// </remarks>
public class NumberFormatConverter
{
/// <summary/>
public NumberFormatConverter()
{
/*
<Dn>+96522239100</Dn>
<PrividUser>priv_96522239100</PrividUser>
<PartyId>+96522239501</PartyId>
<PrimaryPUID>+96522239501</PrimaryPUID>
<aid>+96522239501</aid>
<PublicUID>+96522239100@ims.moc1.kw</PublicUID>
<PrivateId>priv_96522239100</PrivateId>
<Puid>sip:+96522239100</Puid>
<PridUser>priv_96522239100</PridUser>
*
* impu = "tel:+" + Ia.Ngn.Cl.Model.Data.Service.CountryCode + number;
sip:+96523900012@ims.moc.kw
*/
}
/// <summary/>
public static string Dn(string service)
{
return "+" + Ia.Ngn.Cl.Model.Business.Service.CountryCode + service;
}
public static string SipUserName(string service)
{
return Dn(service);
}
/// <summary/>
public static string ServiceWithCountryCode(string service)
{
return Ia.Ngn.Cl.Model.Business.Service.CountryCode + Service(service);
}
/// <summary>
///
/// </summary>
public static bool IsMatchToServiceWithCountryCode(string service)
{
return Regex.IsMatch(service, @"^" + Ia.Ngn.Cl.Model.Business.Service.CountryCode + @"\d{8}$");
}
/// <summary/>
public static string PrividUser(string service)
{
return "priv_" + Ia.Ngn.Cl.Model.Business.Service.CountryCode + service;
}
/// <summary/>
public static string PartyId(string service)
{
return "+" + Ia.Ngn.Cl.Model.Business.Service.CountryCode + Service(service);
}
/// <summary/>
public static string PrimaryPuid(string service)
{
return "+" + Ia.Ngn.Cl.Model.Business.Service.CountryCode + service;
}
/// <summary/>
public static string Aid(string service)
{
return "+" + Ia.Ngn.Cl.Model.Business.Service.CountryCode + service;
}
/// <summary/>
public static string PublicUid(string service)
{
return "+" + Ia.Ngn.Cl.Model.Business.Service.CountryCode + service + "@ims.moc1.kw";
}
/// <summary/>
public static string PrivateId(string service)
{
return "priv_" + Ia.Ngn.Cl.Model.Business.Service.CountryCode + service;
}
/// <summary/>
public static string Puid(string service)
{
return "sip:+" + Ia.Ngn.Cl.Model.Business.Service.CountryCode + service;
}
/// <summary/>
public static string PridUser(string service)
{
return "priv_" + Ia.Ngn.Cl.Model.Business.Service.CountryCode + service;
}
/// <summary>
/// This will check if service is a regex match to PridUser number
/// </summary>
public static bool IsMatchToPridUser(string service)
{
return Regex.IsMatch(service, @"^priv_" + Ia.Ngn.Cl.Model.Business.Service.CountryCode + @"\d{8}$");
}
/// <summary/>
public static string Impu(int number)
{
return "tel:+" + Ia.Ngn.Cl.Model.Business.Service.CountryCode + number;
}
/// <summary/>
public static string Impi(string service)
{
return "+" + Ia.Ngn.Cl.Model.Business.Service.CountryCode + Service(service) + "@ims.moc.kw";
}
/// <summary/>
public static string SipName(string service)
{
return Impi(service);
}
/// <summary>
/// This will check if service is a regex match to Impi number
/// </summary>
public static bool IsMatchToImpi(string service)
{
return Regex.IsMatch(service, @"^\+" + Ia.Ngn.Cl.Model.Business.Service.CountryCode + @"\d{8}@ims.moc.kw$");
}
/// <summary/>
public static string Impu(string service)
{
return "tel:+" + Ia.Ngn.Cl.Model.Business.Service.CountryCode + Service(service);
}
/// <summary/>
public static string ImpuSipDomain(int number)
{
return "sip:+" + Ia.Ngn.Cl.Model.Business.Service.CountryCode + number + "@ims.moc.kw";
}
/// <summary/>
public static bool IsMatchToImpuSipDomain(string service)
{
return Regex.IsMatch(service, @"^sip:\+" + Ia.Ngn.Cl.Model.Business.Service.CountryCode + @"\d{8}@ims.moc.kw$");
}
/// <summary/>
public static string ImpuAid(string service)
{
return "+" + Ia.Ngn.Cl.Model.Business.Service.CountryCode + Service(service);
}
/// <summary>
///
/// </summary>
public static bool IsMatchToImpuAid(string service)
{
return Regex.IsMatch(service, @"^\+" + Ia.Ngn.Cl.Model.Business.Service.CountryCode + @"\d{8}$");
}
/// <summary/>
public static string E164ProtocolUserNumber(string service)
{
string s, u, v;
if (!string.IsNullOrEmpty(service))
{
u = Ia.Ngn.Cl.Model.Business.Service.CountryCode + Service(service);
if (u.Length > 0)
{
// convert number to E164 protocol user number format
v = string.Empty;
for (int i = u.Length - 1; i >= 0; i--) v += u[i] + ".";
s = v + "e164.arpa";
}
else s = string.Empty;
}
else s = string.Empty;
return s;
}
/// <summary/>
public static string SubId(string service)
{
return Impi(service);
}
/// <summary/>
public static string ImpuSipDomain(string service)
{
return "sip:+" + Ia.Ngn.Cl.Model.Business.Service.CountryCode + Service(service) + "@ims.moc.kw";
}
/// <summary/>
public static string Pui(string service)
{
return ImpuSipDomain(service);
}
/// <summary/>
public static string Pri(string service)
{
return Impi(service);
}
/// <summary/>
public static int Number(string service)
{
int number;
service = Service(service);
number = int.TryParse(service, out int i) ? i : 0;
return number;
}
/// <summary/>
public static string Service(string someNumberFormat)
{
string s;
if (!string.IsNullOrEmpty(someNumberFormat))
{
if (someNumberFormat.StartsWith("tel:")) s = someNumberFormat.Replace("tel:+" + Ia.Ngn.Cl.Model.Business.Service.CountryCode, "");
else if (someNumberFormat.StartsWith("sip:"))
{
s = someNumberFormat.Replace("sip:+" + Ia.Ngn.Cl.Model.Business.Service.CountryCode, "");
s = s.Replace("@ims.moc.kw", "");
}
else if (someNumberFormat.StartsWith("priv_" + Ia.Ngn.Cl.Model.Business.Service.CountryCode)) s = someNumberFormat.Replace("priv_" + Ia.Ngn.Cl.Model.Business.Service.CountryCode, "");
else if (someNumberFormat.StartsWith("+" + Ia.Ngn.Cl.Model.Business.Service.CountryCode)) s = someNumberFormat.Replace("+" + Ia.Ngn.Cl.Model.Business.Service.CountryCode, "");
else if (Regex.IsMatch(someNumberFormat, @"^" + Ia.Ngn.Cl.Model.Business.Service.CountryCode + @"\d{8}")) s = Regex.Replace(someNumberFormat, @"^" + Ia.Ngn.Cl.Model.Business.Service.CountryCode, "");
else if (Regex.IsMatch(someNumberFormat, @"\d{8}")) s = someNumberFormat; // order important
else s = Ia.Cl.Model.Default.Match(someNumberFormat, @".+(\d{8})");
}
else s = string.Empty;
return s;
}
////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////
}
////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////
}