1: using System;
2: using System.Collections.Generic;
3: using System.Configuration;
4: using System.Data;
5: using System.Linq;
6: using System.Text.RegularExpressions;
7: using System.Web;
8:
9: namespace Ia.Ngn.Cl.Model.Business
10: {
11: ////////////////////////////////////////////////////////////////////////////
12:
13: /// <summary publish="true">
14: /// Default general support class of Next Generation Network'a (NGN's) business model.
15: /// </summary>
16: ///
17: /// <remarks>
18: /// Copyright © 2006-2019 Jasem Y. Al-Shamlan (info@ia.com.kw), Internet Applications - Kuwait. All Rights Reserved.
19: ///
20: /// 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
21: /// the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
22: ///
23: /// This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
24: /// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
25: ///
26: /// You should have received a copy of the GNU General Public License along with this library. If not, see http://www.gnu.org/licenses.
27: ///
28: /// Copyright notice: This notice may not be removed or altered from any source distribution.
29: /// </remarks>
30: public partial class Default
31: {
32: private const int fixedLengthOfOntId = 16;
33:
34: ////////////////////////////////////////////////////////////////////////////
35:
36: /// <summary>
37: ///
38: /// </summary>
39: public static int FixedLengthOfOntId { get { return fixedLengthOfOntId; } }
40:
41: ////////////////////////////////////////////////////////////////////////////
42:
43: /// <summary>
44: ///
45: /// </summary>
46: public const int PortUndefinedOrInvalidOrUnknown = -1;
47:
48: ////////////////////////////////////////////////////////////////////////////
49:
50: /// <summary>
51: ///
52: /// </summary>
53: public enum ProjectState { Running = 1, PartiallyRunning, Idle, Down, Unknown };
54:
55: ////////////////////////////////////////////////////////////////////////////
56:
57: /// <summary>
58: ///
59: /// </summary>
60: public enum Process { Create = 1, Read, Update, Delete };
61:
62: ////////////////////////////////////////////////////////////////////////////
63:
64: /// <summary>
65: ///
66: /// </summary>
67: public enum Protocol { DefaultAsInNdd = 1, Sip, H248 };
68:
69: ////////////////////////////////////////////////////////////////////////////
70:
71: /// <summary>
72: ///
73: /// </summary>
74: public static List<string> H248ToSipUpdateOltSymbolList
75: {
76: get
77: {
78: return new List<string> { /*"SDQ", "SAA", "ADS",*/ "LAB" };
79: }
80: }
81:
82: ////////////////////////////////////////////////////////////////////////////
83:
84: /// <summary>
85: ///
86: /// </summary>
87: public static Ia.Ngn.Cl.Model.Business.Default.Process Translate(string processNameString)
88: {
89: Ia.Ngn.Cl.Model.Business.Default.Process process;
90:
91: switch (processNameString)
92: {
93: case "Create": process = Ia.Ngn.Cl.Model.Business.Default.Process.Create; break;
94: case "Read": process = Ia.Ngn.Cl.Model.Business.Default.Process.Read; break;
95: case "Update": process = Ia.Ngn.Cl.Model.Business.Default.Process.Update; break;
96: case "Delete": process = Ia.Ngn.Cl.Model.Business.Default.Process.Delete; break;
97: default: process = Ia.Ngn.Cl.Model.Business.Default.Process.Read; break;
98: }
99:
100: return process;
101: }
102:
103: ////////////////////////////////////////////////////////////////////////////
104:
105: /// <summary>
106: /// Flag to indicate of the system should be running
107: /// </summary>
108: public static bool AllowSystemToRun
109: {
110: get
111: {
112: bool b;
113: DateTime dateTime;
114:
115: dateTime = DateTime.UtcNow.AddHours(3);
116:
117: // below: I decided to keep the system always running pending a possible contract
118: b = true; // dateTime.Year == 2019 && dateTime.Month <= 10;
119:
120: return b;
121: }
122: }
123:
124: ////////////////////////////////////////////////////////////////////////////
125:
126: /// <summary>
127: ///
128: /// </summary>
129: public static string OntId(string ponId, int ontNumber)
130: {
131: string id;
132:
133: id = ponId + ontNumber.ToString().PadLeft(2, '0');
134:
135: if (id.Length != fixedLengthOfOntId)
136: {
137: throw new ArgumentOutOfRangeException(@"OntId(): Id length is not " + fixedLengthOfOntId);
138: }
139:
140: return id;
141: }
142:
143: ////////////////////////////////////////////////////////////////////////////
144:
145: /// <summary>
146: ///
147: /// </summary>
148: public static string ExtractAccessNameWithValidSymbolAndLegalFormatForPonAndOntFromValue(string value)
149: {
150: bool isValid;
151: int oltId, ponNumber, ontNumber;
152: string accessName;
153: Dictionary<int, string> typeDictionary;
154:
155: typeDictionary = new Dictionary<int, string>(1);
156: typeDictionary.Add(1, value);
157:
158: isValid = ExtractAccessNameWithValidSymbolAndLegalFormatForPonAndOntFromDictionaryValueList(typeDictionary, out oltId, out ponNumber, out ontNumber);
159:
160: if (isValid) accessName = (from o in Ia.Ngn.Cl.Model.Data.NetworkDesignDocument.OntList where o.Pon.PonGroup.Olt.Id == oltId && o.Pon.Number == ponNumber && o.Number == ontNumber select o.Access.Name).SingleOrDefault();
161: else accessName = string.Empty;
162:
163: return accessName;
164: }
165:
166: ////////////////////////////////////////////////////////////////////////////
167:
168: /// <summary>
169: ///
170: /// </summary>
171: public static Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Ont NddOntFromHuaweiEmsAccessNameFormat(string mduName)
172: {
173: string accessName, s;
174: Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Ont ont;
175:
176: s = Ia.Ngn.Cl.Model.Business.Huawei.Ems.HuaweiAccessNameFormatFromInaccurateHuaweiFileAndEmsNameFormat(mduName);
177:
178: accessName = Ia.Ngn.Cl.Model.Business.Default.ExtractAccessNameWithValidSymbolAndLegalFormatForPonAndOntFromValue(s);
179:
180: ont = Ia.Ngn.Cl.Model.Data.NetworkDesignDocument.OntByAccessName(accessName);
181:
182: return ont;
183: }
184:
185: ////////////////////////////////////////////////////////////////////////////
186:
187: /// <summary>
188: ///
189: /// </summary>
190: public static string ExtractPonNameWithValidSymbolAndLegalFormatForPonAndOntFromValue(string value)
191: {
192: bool isValid;
193: int oltId, ponNumber, ontNumber;
194: string ponName;
195: Dictionary<int, string> typeDictionary;
196:
197: // below: we will replace ' ' and '/' with '.' to avoid errors
198: value = value.Replace(" ", ".");
199: value = value.Replace("/", ".");
200:
201: typeDictionary = new Dictionary<int, string>(1);
202: typeDictionary.Add(1, value + ".1"); // to mimic a WWW.D.1 format
203:
204: isValid = ExtractAccessNameWithValidSymbolAndLegalFormatForPonAndOntFromDictionaryValueList(typeDictionary, out oltId, out ponNumber, out ontNumber);
205:
206: if (isValid) ponName = (from p in Ia.Ngn.Cl.Model.Data.NetworkDesignDocument.PonList where p.PonGroup.Olt.Id == oltId && p.Number == ponNumber select p.Name).SingleOrDefault();
207: else ponName = string.Empty;
208:
209: return ponName;
210: }
211:
212: ////////////////////////////////////////////////////////////////////////////
213:
214: /// <summary>
215: ///
216: /// </summary>
217: public static string StandardizeAccessNameInLegalFormatFromValue(string value)
218: {
219: string accessName;
220: Dictionary<int, string> typeDictionary;
221:
222: typeDictionary = new Dictionary<int, string>(1);
223: typeDictionary.Add(1, value);
224:
225: accessName = ExtractAccessNameInLegalFormatFromDictionaryValueList(typeDictionary);
226:
227: return accessName;
228: }
229:
230: ////////////////////////////////////////////////////////////////////////////
231:
232: /// <summary>
233: ///
234: /// </summary>
235: public static bool ExtractOntNameWithValidSymbolAndLegalFormatForPonAndOntFromValue(string value, out int oltId, out int ponNumber, out int ontNumber)
236: {
237: Dictionary<int, string> typeDictionary;
238:
239: typeDictionary = new Dictionary<int, string>(1);
240: typeDictionary.Add(1, value);
241:
242: return ExtractAccessNameWithValidSymbolAndLegalFormatForPonAndOntFromDictionaryValueList(typeDictionary, out oltId, out ponNumber, out ontNumber);
243: }
244:
245: ////////////////////////////////////////////////////////////////////////////
246:
247: /// <summary>
248: ///
249: /// </summary>
250: public static bool ExtractAccessNameWithValidSymbolAndLegalFormatForPonAndOntFromDictionaryValueList(Dictionary<int, string> typeDictionary, out int oltId, out int ponNumber, out int ontNumber)
251: {
252: bool b, isValidAccessNameWithValidSymbolAndLegalFormatForPonAndOnt;
253: int p, o;
254: string p1, p2, p3, p4, p5, p45, p55, symbol;
255: Match match;
256:
257: b = isValidAccessNameWithValidSymbolAndLegalFormatForPonAndOnt = false;
258: oltId = ponNumber = ontNumber = 0;
259:
260: p1 = (typeDictionary.ContainsKey(1)) ? typeDictionary[1] : "";
261: p2 = (typeDictionary.ContainsKey(2)) ? typeDictionary[2] : "";
262: p3 = (typeDictionary.ContainsKey(3)) ? typeDictionary[3] : "";
263: p4 = (typeDictionary.ContainsKey(4)) ? typeDictionary[4] : "";
264: p5 = (typeDictionary.ContainsKey(5)) ? typeDictionary[5] : "";
265: p45 = (typeDictionary.ContainsKey(45)) ? typeDictionary[45] : "";
266: p55 = (typeDictionary.ContainsKey(55)) ? typeDictionary[55] : "";
267:
268: b = ExtractAccessNameWithLegalFormatForPonAndOntMatchFromString(p2, out match);
269:
270: if (!b)
271: {
272: b = ExtractAccessNameWithLegalFormatForPonAndOntMatchFromString(p1, out match);
273:
274: if (!b)
275: {
276: b = ExtractAccessNameWithLegalFormatForPonAndOntMatchFromString(p55, out match);
277:
278: if (!b)
279: {
280: b = ExtractAccessNameWithLegalFormatForPonAndOntMatchFromTwoStrings(p1, p2, out match);
281:
282: if (!b)
283: {
284: b = ExtractAccessNameWithLegalFormatForPonAndOntMatchFromTwoStrings(p1, p45, out match);
285:
286: if (!b)
287: {
288: b = ExtractAccessNameWithLegalFormatForPonAndOntMatchFromTwoStrings(p2, p45, out match);
289:
290: if (!b)
291: {
292: b = ExtractAccessNameWithLegalFormatForPonAndOntMatchFromTwoStrings(p1, p4, out match);
293:
294: if (!b)
295: {
296: b = ExtractAccessNameWithLegalFormatForPonAndOntMatchFromString(p4, out match);
297:
298: if (!b)
299: {
300: b = ExtractAccessNameWithLegalFormatForPonAndOntMatchFromString(p5, out match);
301:
302: if (!b)
303: {
304: b = ExtractAccessNameWithLegalFormatForPonAndOntMatchFromString(p3, out match);
305:
306: if (!b)
307: {
308: b = ExtractAccessNameWithLegalFormatForPonAndOntMatchFromTwoStrings(p1, p3, out match);
309: }
310: }
311: }
312: }
313: }
314: }
315: }
316: }
317: }
318: }
319:
320: if (b)
321: {
322: if (match.Success)
323: {
324: symbol = match.Groups[1].Captures[0].Value;
325: ponNumber = p = int.Parse(match.Groups[2].Captures[0].Value);
326: ontNumber = o = int.Parse(match.Groups[3].Captures[0].Value);
327:
328: oltId = (from _o in Ia.Ngn.Cl.Model.Data.NetworkDesignDocument.OntList where _o.Pon.PonGroup.Symbol == symbol && _o.Pon.Number == p && _o.Number == o select _o.Pon.PonGroup.Olt.Id).SingleOrDefault();
329:
330: if (oltId != 0)
331: {
332: isValidAccessNameWithValidSymbolAndLegalFormatForPonAndOnt = true;
333: }
334: else
335: {
336: oltId = ponNumber = ontNumber = 0;
337: isValidAccessNameWithValidSymbolAndLegalFormatForPonAndOnt = false;
338: }
339: }
340: else
341: {
342: oltId = ponNumber = ontNumber = 0;
343: isValidAccessNameWithValidSymbolAndLegalFormatForPonAndOnt = false;
344: }
345: }
346: else isValidAccessNameWithValidSymbolAndLegalFormatForPonAndOnt = false;
347:
348: return isValidAccessNameWithValidSymbolAndLegalFormatForPonAndOnt;
349: }
350:
351: ////////////////////////////////////////////////////////////////////////////
352:
353: /// <summary>
354: ///
355: /// </summary>
356: public static string ExtractAccessNameInLegalFormatFromDictionaryValueList(Dictionary<int, string> typeDictionary)
357: {
358: bool b;
359: int ponNumber, ontNumber;
360: string p1, p2, p3, p4, p5, p45, symbol, accessName;
361: Match match;
362:
363: p1 = (typeDictionary.ContainsKey(1)) ? typeDictionary[1] : "";
364: p2 = (typeDictionary.ContainsKey(2)) ? typeDictionary[2] : "";
365: p3 = (typeDictionary.ContainsKey(3)) ? typeDictionary[3] : "";
366: p4 = (typeDictionary.ContainsKey(4)) ? typeDictionary[4] : "";
367: p5 = (typeDictionary.ContainsKey(5)) ? typeDictionary[5] : "";
368: p45 = (typeDictionary.ContainsKey(45)) ? typeDictionary[45] : "";
369:
370: b = ExtractAccessNameWithLegalFormatForPonAndOntMatchFromString(p2, out match);
371:
372: if (!b)
373: {
374: b = ExtractAccessNameWithLegalFormatForPonAndOntMatchFromString(p1, out match);
375:
376: if (!b)
377: {
378: b = ExtractAccessNameWithLegalFormatForPonAndOntMatchFromTwoStrings(p1, p2, out match);
379:
380: if (!b)
381: {
382: b = ExtractAccessNameWithLegalFormatForPonAndOntMatchFromTwoStrings(p1, p45, out match);
383:
384: if (!b)
385: {
386: b = ExtractAccessNameWithLegalFormatForPonAndOntMatchFromTwoStrings(p2, p45, out match);
387:
388: if (!b)
389: {
390: b = ExtractAccessNameWithLegalFormatForPonAndOntMatchFromTwoStrings(p1, p4, out match);
391:
392: if (!b)
393: {
394: b = ExtractAccessNameWithLegalFormatForPonAndOntMatchFromString(p4, out match);
395:
396: if (!b)
397: {
398: b = ExtractAccessNameWithLegalFormatForPonAndOntMatchFromString(p5, out match);
399:
400: if (!b)
401: {
402: b = ExtractAccessNameWithLegalFormatForPonAndOntMatchFromString(p3, out match);
403:
404: if (!b)
405: {
406: b = ExtractAccessNameWithLegalFormatForPonAndOntMatchFromTwoStrings(p1, p3, out match);
407: }
408: }
409: }
410: }
411: }
412: }
413: }
414: }
415: }
416:
417: if (b)
418: {
419: if (match.Success)
420: {
421: symbol = match.Groups[1].Captures[0].Value;
422:
423: ponNumber = int.Parse(match.Groups[2].Captures[0].Value);
424: ontNumber = int.Parse(match.Groups[3].Captures[0].Value);
425:
426: accessName = symbol.ToUpper() + "." + ponNumber + "." + ontNumber;
427: }
428: else
429: {
430: accessName = string.Empty;
431: }
432: }
433: else
434: {
435: accessName = string.Empty;
436: }
437:
438: return accessName;
439: }
440:
441: ////////////////////////////////////////////////////////////////////////////
442:
443: /// <summary>
444: ///
445: /// </summary>
446: private static bool ExtractAccessNameWithLegalFormatForPonAndOntMatchFromString(string s, out Match match)
447: {
448: // below: this checks if string conferms
449: bool b;
450: string pattern = @"([a-zA-Z]{3})\.(\d{1,4})\.(\d{1,3})";
451:
452: match = null;
453:
454: if (!string.IsNullOrEmpty(s))
455: {
456: s = s.ToUpper();
457:
458: if (!Regex.IsMatch(s, pattern))
459: {
460: s = s.Replace("-", ".");
461: s = s.Replace("/", ".");
462: s = s.Replace(" ", ".");
463:
464: if (!Regex.IsMatch(s, pattern))
465: {
466: s = s.Replace(". ", ".");
467:
468: if (!Regex.IsMatch(s, pattern))
469: {
470: s = s.Replace(" .", ".");
471:
472: if (!Regex.IsMatch(s, pattern))
473: {
474: s = s.Replace(".00", ".");
475: s = s.Replace(".0", ".");
476:
477: if (!Regex.IsMatch(s, pattern))
478: {
479: s = s.Replace("...", ".");
480: s = s.Replace("..", ".");
481:
482: if (!Regex.IsMatch(s, pattern))
483: {
484: s = Regex.Replace(s, @"\.$", @"");
485:
486: if (!Regex.IsMatch(s, pattern))
487: {
488: s = Regex.Replace(s, @"([a-zA-Z]{3})(\d{1,4})\.(\d{1,3})", @"$1.$2.$3");
489:
490: if (!Regex.IsMatch(s, pattern))
491: {
492: s = Regex.Replace(s, @"([a-zA-Z]{3})\.(\d{3})(\d{3})", @"$1.$2.$3");
493:
494: if (!Regex.IsMatch(s, pattern))
495: {
496: s = Regex.Replace(s, @"([a-zA-Z]{3})\.(\d{4})(\d{3})", @"$1.$2.$3");
497:
498: if (!Regex.IsMatch(s, pattern))
499: {
500: s = Regex.Replace(s, @"([a-zA-Z]{3})(\d{3})(\d{3})", @"$1.$2.$3");
501:
502: if (!Regex.IsMatch(s, pattern))
503: {
504: s = Regex.Replace(s, @"([a-zA-Z]{3})(\d{4})(\d{3})", @"$1.$2.$3");
505:
506: if (!Regex.IsMatch(s, pattern))
507: {
508: s = Regex.Replace(s, @"([a-zA-Z]{3})\.(\d{1,4}) (\d{1,3})", @"$1.$2.$3");
509:
510: if (!Regex.IsMatch(s, pattern))
511: {
512: s = Regex.Replace(s, @"([a-zA-Z]{3}) (\d{1,4}) (\d{1,3})", @"$1.$2.$3");
513: }
514: }
515: }
516: }
517: }
518: }
519: }
520: }
521: }
522: }
523: }
524: }
525: }
526:
527: match = Regex.Match(s, pattern);
528:
529: if (match.Success) b = true;
530: else b = false;
531: }
532: else b = false;
533:
534: return b;
535: }
536:
537: ////////////////////////////////////////////////////////////////////////////
538:
539: /// <summary>
540: ///
541: /// </summary>
542: private static bool ExtractAccessNameWithLegalFormatForPonAndOntMatchFromTwoStrings(string s1, string s2, out Match match)
543: {
544: // below: this checks if string conferms
545: bool b;
546: match = null;
547:
548: s1 = s1.Replace("-", ".");
549: s1 = s1.Replace("/", ".");
550: s1 = s1.Replace(" /", "/");
551: s1 = s1.ToUpper();
552: s1 = s1.Replace("ZHA", "ZAH");
553: s1 = s1.Replace("JAB", "JBA");
554:
555: s1 = Regex.Replace(s1, @"([a-zA-Z]{3})(\d{1,4})", @"$1.$2");
556:
557: if (Regex.IsMatch(s1, @"[a-zA-Z]{3}\.\d{1,4}") && Regex.IsMatch(s2, @"\d{1,3}"))
558: {
559: b = ExtractAccessNameWithLegalFormatForPonAndOntMatchFromString(s1 + @"." + s2, out match);
560: }
561: else b = false;
562:
563: return b;
564: }
565:
566: ////////////////////////////////////////////////////////////////////////////
567:
568: /// <summary>
569: /// ASP.NET State Management
570: /// below: remove later to default.cs or state.cs
571: /// <remarks>https://msdn.microsoft.com/en-us/library/z1hkazw7(v=vs.100).aspx</remarks>
572: /// </summary>
573: public static bool Application(string name, int lifeInMinutes, object o)
574: {
575: bool valueStored;
576: DateTime expiration;
577:
578: if (name != string.Empty)
579: {
580: expiration = DateTime.UtcNow.AddMinutes(3 * 60 + lifeInMinutes);
581:
582: HttpContext.Current.Application[name + "|" + lifeInMinutes.ToString()] = o;
583:
584: valueStored = true;
585: }
586: else valueStored = false;
587:
588: return valueStored;
589: }
590:
591: ////////////////////////////////////////////////////////////////////////////
592:
593: /// <summary>
594: ///
595: /// </summary>
596: public static object Application(string name)
597: {
598: string expirationString;
599: DateTime expiration;
600: object o;
601:
602: o = null;
603:
604: // below: loop through keys to find the one that starts with name
605: foreach (string s in HttpContext.Current.Application.AllKeys)
606: {
607: if (s.Contains(name + "|"))
608: {
609: expirationString = Ia.Cl.Model.Default.Match(s, @"\|(.+)");
610:
611: expiration = DateTime.Parse(expirationString);
612:
613: if (expiration < DateTime.UtcNow.AddHours(3))
614: {
615: // below: did not expire
616:
617: o = HttpContext.Current.Application[s];
618: }
619: else o = null;
620: }
621: }
622:
623: return o;
624: }
625:
626: ////////////////////////////////////////////////////////////////////////////
627:
628: /// <summary>
629: /// RecordState holds the current state of the record according to user and system interactions with it. It could be used as an
630: /// indicator to define the current state of the record and how it should be handle in state monitoring execution cycles.
631: /// </summary>
632: public enum RecordState
633: {
634: Undefined = 0, Synchronized = 10, Synchronize = 20, Modified = 30, Updated = 40, Etc = 50
635: };
636:
637: ////////////////////////////////////////////////////////////////////////////
638:
639: /// <summary>
640: ///
641: /// </summary>
642: public Default() { }
643:
644: ////////////////////////////////////////////////////////////////////////////
645:
646: /// <summary>
647: ///
648: /// </summary>
649: public static string CorrectCustomerAddress(string addressString)
650: {
651: addressString = addressString.Trim();
652:
653: //line = Ia.Cl.Model.Language.ConvertSingleLatinDigitsToArabicWordEquivalents(line);
654: //line = Ia.Cl.Model.Language.RemoveNonArabicAndNonArabicExtendedLettersAndDigits(line);
655: //line = Ia.Cl.Model.Language.CorrectArabicNameNounStringFormat(line);
656: // to do line = Ia.Cl.Model.Language.RemoveTitlesFromNames(line);
657: // to do line = Ia.Cl.Model.Language.CorrectArabicNameNounFormat(line);
658: // to do line = Ia.Cl.Model.Language.CorrectArabicNonNameNounStringFormat(line);
659: //line = Ia.Cl.Model.Language.RemoveWrongSpaceBetweenArabicDefinitArticleAndItsWord(line);
660: //line = Regex.Replace(line, @"\s+", @" ");
661:
662: addressString = Regex.Replace(addressString, @"[0]{2,}", "0"); // "000" to "0"
663:
664: addressString = addressString.Replace("جادة جاده", "جادة ");
665: addressString = addressString.Replace("جادة جادة", "جادة ");
666: addressString = addressString.Replace("شارع الاول", "شارع 1");
667: addressString = addressString.Replace("شارع الثانى", "شارع 2");
668: addressString = addressString.Replace("شارع الثالث", "شارع 3");
669: addressString = addressString.Replace("شارع الرابع", "شارع 4");
670: addressString = addressString.Replace("شارع الخامس", "شارع 5");
671: addressString = addressString.Replace("شارع السادس", "شارع 6");
672: addressString = addressString.Replace("شارع السابع", "شارع 7");
673: addressString = addressString.Replace("شارع الثامن", "شارع 8");
674: addressString = addressString.Replace("شارع التاسع", "شارع 9");
675:
676: addressString = addressString.Trim();
677:
678: return addressString;
679: }
680:
681: ////////////////////////////////////////////////////////////////////////////
682:
683: /// <summary>
684: ///
685: /// </summary>
686: public static string CorrectCustomerAddressMissingProvinceArea(string service, string addressString)
687: {
688: // correct some missing information in address lines based on service number
689:
690: if (service.StartsWith("2453") || service.StartsWith("2454")) addressString = "الجهراء سعد العبدالله" + addressString;
691: else if (service.StartsWith("2466")) addressString = "الفروانية القيروان" + addressString;
692: else if (service.StartsWith("2435") || service.StartsWith("2436")) addressString = "الفروانية عبدالله المبارك" + addressString;
693: else if (service.StartsWith("2363")) addressString = "الأحمدي فهد الأحمد" + addressString;
694: else if (service.StartsWith("2368")) addressString = "الأحمدي لآلئ الخيران" + addressString;
695:
696: return addressString;
697: }
698:
699: ////////////////////////////////////////////////////////////////////////////
700:
701: /// <summary>
702: ///
703: /// </summary>
704: public static string CorrectCustomerName(string line)
705: {
706: line = line.Trim();
707: //line = Ia.Cl.Model.Language.ConvertSingleLatinDigitsToArabicWordEquivalents(line);
708: line = Ia.Cl.Model.Language.RemoveNonNativeAndNonNativeExtendedLettersAndDigitsAccordingToLanguage("ar", line);
709: line = Ia.Cl.Model.Language.CorrectArabicNameNounStringFormat(line);
710: // to do line = Ia.Cl.Model.Language.RemoveTitlesFromNames(line);
711: // to do line = Ia.Cl.Model.Language.CorrectArabicNameNounFormat(line);
712: // to do line = Ia.Cl.Model.Language.CorrectArabicNonNameNounStringFormat(line);
713: line = Ia.Cl.Model.Language.RemoveWrongSpaceBetweenNativeDefinitArticleAndItsWord("ar", line);
714: line = Regex.Replace(line, @"\s+", @" ");
715: line = line.Trim();
716:
717: return line;
718: }
719:
720: ////////////////////////////////////////////////////////////////////////////
721:
722: /// <summary>
723: ///
724: /// </summary>
725: public static DataTable ReturnDataTableOfServiceAdministrativeStateOfANumberInOldNgnDatabase(long dn)
726: {
727: string sql;
728: DataTable dt;
729: Ia.Cl.Model.Db.SqlServer ngn;
730:
731: 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 + ")";
732: dt = null;
733:
734: try
735: {
736: ngn = new Ia.Cl.Model.Db.SqlServer(ConfigurationManager.ConnectionStrings["DefaultConnectionToNgn"].ConnectionString);
737:
738: dt = ngn.Select(sql);
739: }
740: catch (Exception)
741: {
742: }
743:
744: return dt;
745: }
746:
747: ////////////////////////////////////////////////////////////////////////////
748:
749: /// <summary>
750: ///
751: /// </summary>
752: public static void UpdateServiceAdministrativeStateOfANumberInOldNgnDatabase(long dn, string state)
753: {
754: string sql;
755: Ia.Cl.Model.Db.SqlServer ngn;
756:
757: sql = @"UPDATE ia_service_administrative SET state = " + state + " WHERE dn = " + dn;
758:
759: try
760: {
761: ngn = new Ia.Cl.Model.Db.SqlServer(ConfigurationManager.ConnectionStrings["DefaultConnectionToNgn"].ConnectionString);
762:
763: ngn.Sql(sql);
764: }
765: catch (Exception)
766: {
767: }
768: }
769:
770: ////////////////////////////////////////////////////////////////////////////
771: ////////////////////////////////////////////////////////////////////////////
772:
773: /// <summary>
774: ///
775: /// </summary>
776: public static int ChangeOldSevenDigitNumbersToEightDigitFormat(int o)
777: {
778: // below: take an old 7 digit number and covert it to the new 8 digit number according to plan
779:
780: int n;
781:
782: // below: check if it is already an 8 digit number
783: if (o >= 10000000) n = o;
784:
785: // 2 (NGN):
786: else if (
787: (o >= 2000000 && o <= 2999999) ||
788: (o >= 3000000 && o <= 3999999) ||
789: (o >= 4100000 && o <= 4399999) ||
790: (o >= 4500000 && o <= 4999999) ||
791: (o >= 5000000 && o <= 5009999) ||
792: (o >= 5030000 && o <= 5049999) ||
793: (o >= 5200000 && o <= 5499999) ||
794: (o >= 5510000 && o <= 5539999) ||
795: (o >= 5600000 && o <= 5699999) ||
796: (o >= 5710000 && o <= 5779999)) { n = 20000000 + o; }
797:
798: //6 (Wataniya):
799: else if (
800: (o >= 5010000 && o <= 5029999) ||
801: (o >= 5050000 && o <= 5099999) ||
802: (o >= 5100000 && o <= 5199999) ||
803: (o >= 5500000 && o <= 5509999) ||
804: (o >= 5540000 && o <= 5599999) ||
805: (o >= 5700000 && o <= 5709999) ||
806: (o >= 5780000 && o <= 5799999) ||
807: (o >= 5800000 && o <= 5999999) ||
808: (o >= 6000000 && o <= 6999999) ||
809: (o >= 7000000 && o <= 7019999) ||
810: (o >= 7030000 && o <= 7099999) ||
811: (o >= 7700000 && o <= 7769999) ||
812: (o >= 7780000 && o <= 7799999)) { n = 60000000 + o; }
813:
814: //1 (NGN):
815: else if (o >= 800000 && o <= 899999) { n = 1000000 + o; }
816:
817: //9 (Zain):
818: else if (
819: (o >= 7020000 && o <= 7029999) ||
820: (o >= 7100000 && o <= 7699999) ||
821: (o >= 7800000 && o <= 7999999) ||
822: (o >= 9000000 && o <= 9999999) ||
823: (o >= 4400000 && o <= 4499999) ||
824: (o >= 4000000 && o <= 4099999)) { n = 90000000 + o; }
825:
826: else n = o;
827:
828: return n;
829:
830: /*
831: New numbering list
832:
833: Add digit,Old Numbers Ranges,Operator
834: ,From,To,
835: 2,2-000000,2-999999,MOC
836: 2,3-000000,3-999999,MOC
837: 9,40-00000,40-99999,Zain
838: 2,41-00000,43-99999,MOC
839: 9,44-00000,44-99999,Zain
840: 2,45-00000,49-99999,MOC
841: 2,500-0000,500-9999,MOC
842: 6,501-0000,502-9999,Wataniya
843: 2,503-0000,504-9999,MOC
844: 6,505-0000,509-9999,Wataniya
845: 6,51-00000,51-99999,Wataniya
846: 2,52-00000,54-99999,MOC
847: 6,550-0000,550-9999,Wataniya
848: 2,551-0000,553-9999,MOC
849: 6,554-0000,559-9999,Wataniya
850: 2,56-00000,56-99999,MOC
851: 6,570-0000,570-9999,Wataniya
852: 2,571-0000,577-9999,MOC
853: 6,578-0000,579-9999,Wataniya
854: 6,58-00000,59-99999,Wataniya
855: 6,6-000000,6-999999,Wataniya
856: 6,700-0000,701-9999,Wataniya
857: 9,702-0000,702-9999,Zain
858: 6,703-0000,709-9999,Wataniya
859: 9,71-00000,76-99999,Zain
860: 6,770-0000,776-9999,Wataniya
861: 6,778-0000,779-9999,Wataniya
862: 9,78-00000,79-99999,Zain
863: 1,800-000,899-999,MOC
864: 9,9-000000,9-999999,Zain
865:
866:
867: Example: the number 2123456 will become 2 2123456.
868:
869: Notice: Unchanged numbers:
870: •,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.
871: •,The country code for Kuwait 965 stays the same (for international incoming calls).
872: •,The 3 digits numbers do not change (numbers from 100 to 179). For example, for the Inquiry Directory, dial 101.
873: •,The emergency number in Kuwait 777 does not change.
874: */
875: }
876:
877: ////////////////////////////////////////////////////////////////////////////
878: ////////////////////////////////////////////////////////////////////////////
879:
880: /// <summary>
881: ///
882: /// </summary>
883: 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)
884: {
885: int number, serial, status, serviceId;
886: string service, serviceSerial;
887: Ia.Ngn.Cl.Model.Business.ServiceSerialRequestService serviceSerialRequestService;
888: List<string> serviceSerialsToRemoveList;
889: List<Ia.Ngn.Cl.Model.ServiceRequest> serviceRequestList;
890: List<Ia.Ngn.Cl.Model.ServiceRequestHistory> serviceRequestHistoryList;
891: List<Ia.Ngn.Cl.Model.Business.ServiceSerialRequestService> serviceRequestServiceList;
892: Dictionary<string, int> serviceToLastSerialDictionary;
893: Dictionary<string, Ia.Ngn.Cl.Model.Business.ServiceSerialRequestService> serviceRequestServiceNumberSerialComplementaryServiceDictionary, serviceRequestNumberSerialComplementaryServiceDictionary, serviceRequestHistoryNumberSerialComplementaryServiceDictionary, matchedServiceRequestAndServiceRequestHistoryNumberSerialComplementaryServiceDictionary, matchedServiceRequestAndServiceRequestServiceNumberSerialComplementaryServiceDictionary;
894:
895: mismatchBetweenSrAndSrsList = new List<string>();
896: mismatchBetweenSrAndSrhList = new List<string>();
897: serviceSerialsToRemoveList = new List<string>();
898: inSrhNotInSrList = new List<string>();
899: inSrNotInSrhList = new List<string>();
900:
901: number = 0; // 24555994;// 25210209;// 24550208;
902:
903: if (number == 0)
904: {
905: serviceRequestList = Ia.Ngn.Cl.Model.Data.ServiceRequest.List();
906: serviceRequestHistoryList = Ia.Ngn.Cl.Model.Data.ServiceRequestHistory.List();
907: serviceRequestServiceList = Ia.Ngn.Cl.Model.Data.ServiceRequestService.ServiceSerialRequestServiceList();
908: }
909: else
910: {
911: serviceRequestList = Ia.Ngn.Cl.Model.Data.ServiceRequest.List(number);
912: serviceRequestHistoryList = Ia.Ngn.Cl.Model.Data.ServiceRequestHistory.List(number);
913: serviceRequestServiceList = Ia.Ngn.Cl.Model.Data.ServiceRequestService.ServiceSerialRequestServiceList(number.ToString());
914: }
915:
916: serviceIdIssue = string.Empty;
917:
918: serviceRequestNumberSerialComplementaryServiceDictionary = new Dictionary<string, Ia.Ngn.Cl.Model.Business.ServiceSerialRequestService>(serviceRequestList.Count);
919:
920: serviceToLastSerialDictionary = new Dictionary<string, int>(serviceRequestList.Count + serviceRequestHistoryList.Count);
921:
922: // build service request service from service requests
923: //var list = serviceRequestList.OrderBy(p => p.RequestDateTime.Date).ThenBy(p => p.ServiceId == 38); // <service id="38" arabicName="مجموعة الخدمات" />
924: var list = serviceRequestList.OrderBy(p => p.RequestDateTime.Date).ThenBy(p => p.ServiceId == 38).ThenBy(p => p.Id); // <service id="38" arabicName="مجموعة الخدمات" />
925: //var list = serviceRequestHistoryList.OrderBy(p => p.ServiceDateTime).ThenBy(p => p.ServiceId == 38); // <service id="38" arabicName="مجموعة الخدمات" />
926: foreach (var serviceRequest in list)
927: {
928: if (serviceRequest.ServiceCategoryId == 3)
929: {
930: // <category id="3" arabicName="هاتف" />
931:
932: if (serviceRequest.Status == 2003 || serviceRequest.Status == 2005)
933: {
934: // <status id="2003" arabicName="قيد التنفيذ" />
935: // <status id="2005" arabicName="تم التنفيذ" />
936:
937: service = serviceRequest.Number.ToString();
938: serial = serviceRequest.Serial;
939: serviceId = serviceRequest.ServiceId;
940: status = -1;
941: serviceSerial = service + ":" + serial;
942:
943: if (!serviceRequestNumberSerialComplementaryServiceDictionary.ContainsKey(serviceSerial) || serviceRequestNumberSerialComplementaryServiceDictionary.ContainsKey(serviceSerial) && serviceRequestNumberSerialComplementaryServiceDictionary[serviceSerial].Provisioned == false)
944: {
945: if (serviceId == 1 || serviceId == 129 || serviceId == 54)
946: {
947: // <service id="1" arabicName="خط هاتف" />
948: // <service id="129" arabicName="خط هاتف مع نداء آلي"/>
949: // <service id="54" arabicName="اعادة تركيب" />
950:
951: serviceSerialRequestService = new Ia.Ngn.Cl.Model.Business.ServiceSerialRequestService();
952:
953: serviceSerialRequestService.Id = serviceSerial;
954: serviceSerialRequestService.Service = service;
955: serviceSerialRequestService.Serial = serial;
956: serviceSerialRequestService.Provisioned = true;
957:
958: serviceRequestNumberSerialComplementaryServiceDictionary[serviceSerial] = serviceSerialRequestService;
959:
960: Ia.Ngn.Cl.Model.Business.ServiceRequestService.TelephonyService2(ref serviceRequestNumberSerialComplementaryServiceDictionary, serviceSerial, status, serviceId, ref serviceIdIssue);
961:
962: if (serviceToLastSerialDictionary.ContainsKey(service))
963: {
964: if (serviceToLastSerialDictionary[service] < serial) serviceToLastSerialDictionary[service] = serial;
965: }
966: else serviceToLastSerialDictionary[service] = serial;
967: }
968: else
969: {
970: // incomplete service request list for serial
971: }
972: }
973: else
974: {
975: if (serviceRequestNumberSerialComplementaryServiceDictionary[serviceSerial].Provisioned && serviceRequestNumberSerialComplementaryServiceDictionary[serviceSerial].Serial == serial)
976: {
977: if (serviceId == 41)
978: {
979: // <service id="41" arabicName="تغيير رقم" />
980: }
981: else
982: {
983: Ia.Ngn.Cl.Model.Business.ServiceRequestService.TelephonyService2(ref serviceRequestNumberSerialComplementaryServiceDictionary, serviceSerial, status, serviceId, ref serviceIdIssue);
984: }
985: }
986: }
987: }
988: else
989: {
990: }
991: }
992: }
993:
994:
995: serviceRequestHistoryNumberSerialComplementaryServiceDictionary = new Dictionary<string, Ia.Ngn.Cl.Model.Business.ServiceSerialRequestService>(serviceRequestHistoryList.Count);
996:
997: // build service request service from service request histories.
998: var list2 = serviceRequestHistoryList.OrderBy(p => p.ServiceDateTime.Date).ThenBy(p => p.ServiceId == 38); // <service id="38" arabicName="مجموعة الخدمات" />
999: foreach (var serviceRequestHistory in list2)
1000: {
1001: if (serviceRequestHistory.ServiceCategoryId == 3)
1002: {
1003: // <category id="3" arabicName="هاتف" />
1004: service = serviceRequestHistory.Number.ToString();
1005: serial = serviceRequestHistory.Serial;
1006: serviceId = serviceRequestHistory.ServiceId;
1007: status = serviceRequestHistory.Status;
1008:
1009: serviceSerial = service + ":" + serial;
1010:
1011: if (serviceToLastSerialDictionary.ContainsKey(service))
1012: {
1013: if (serviceToLastSerialDictionary[service] < serial) serviceToLastSerialDictionary[service] = serial;
1014: }
1015: else serviceToLastSerialDictionary[service] = serial;
1016:
1017: if (!serviceRequestHistoryNumberSerialComplementaryServiceDictionary.ContainsKey(serviceSerial) || serviceRequestHistoryNumberSerialComplementaryServiceDictionary.ContainsKey(serviceSerial) && serviceRequestHistoryNumberSerialComplementaryServiceDictionary[serviceSerial].Provisioned == false)
1018: {
1019: if (serviceId == 1 || serviceId == 129 || serviceId == 54)
1020: {
1021: // <service id="1" arabicName="خط هاتف" />
1022: // <service id="129" arabicName="خط هاتف مع نداء آلي"/>
1023: // <service id="54" arabicName="اعادة تركيب" />
1024:
1025: serviceSerialRequestService = new Ia.Ngn.Cl.Model.Business.ServiceSerialRequestService();
1026:
1027: serviceSerialRequestService.Id = serviceSerial;
1028: serviceSerialRequestService.Service = service;
1029: serviceSerialRequestService.Serial = serial;
1030: serviceSerialRequestService.Provisioned = true;
1031:
1032: serviceRequestHistoryNumberSerialComplementaryServiceDictionary[serviceSerial] = serviceSerialRequestService;
1033: }
1034: else
1035: {
1036: // incomplete service request list for serial
1037: }
1038: }
1039: else
1040: {
1041: if (serviceRequestHistoryNumberSerialComplementaryServiceDictionary[serviceSerial].Provisioned && serviceRequestHistoryNumberSerialComplementaryServiceDictionary[serviceSerial].Serial == serial)
1042: {
1043: if (serviceId == 41)
1044: {
1045: // <service id="41" arabicName="تغيير رقم" />
1046: }
1047: else
1048: {
1049: Ia.Ngn.Cl.Model.Business.ServiceRequestService.TelephonyService2(ref serviceRequestHistoryNumberSerialComplementaryServiceDictionary, serviceSerial, status, serviceId, ref serviceIdIssue);
1050: }
1051: }
1052: }
1053: }
1054: }
1055:
1056:
1057: // collect all numbers serials that are not the last in their serial series:
1058: foreach (KeyValuePair<string, Ia.Ngn.Cl.Model.Business.ServiceSerialRequestService> kvp in serviceRequestNumberSerialComplementaryServiceDictionary)
1059: {
1060: if (serviceToLastSerialDictionary.ContainsKey(kvp.Value.Service))
1061: {
1062: if (serviceToLastSerialDictionary[kvp.Value.Service] > kvp.Value.Serial) serviceSerialsToRemoveList.Add(kvp.Key);
1063: }
1064: else
1065: {
1066: serviceIdIssue += "Error: serviceToLastSerialDictionary does not contain kvp.Value.Service: " + kvp.Value.Service + "\r\n";
1067: }
1068: }
1069:
1070: foreach (KeyValuePair<string, Ia.Ngn.Cl.Model.Business.ServiceSerialRequestService> kvp in serviceRequestHistoryNumberSerialComplementaryServiceDictionary)
1071: {
1072: if (serviceToLastSerialDictionary.ContainsKey(kvp.Value.Service))
1073: {
1074: if (serviceToLastSerialDictionary[kvp.Value.Service] > kvp.Value.Serial) serviceSerialsToRemoveList.Add(kvp.Key);
1075: }
1076: else
1077: {
1078: serviceIdIssue += "Error: serviceToLastSerialDictionary does not contain kvp.Value.Service: " + kvp.Value.Service + "\r\n";
1079: }
1080: }
1081:
1082:
1083: // remove previous service-serials
1084: foreach (string s in serviceSerialsToRemoveList)
1085: {
1086: serviceRequestNumberSerialComplementaryServiceDictionary.Remove(s);
1087: serviceRequestHistoryNumberSerialComplementaryServiceDictionary.Remove(s);
1088: }
1089:
1090:
1091: serviceRequestServiceNumberSerialComplementaryServiceDictionary = new Dictionary<string, Ia.Ngn.Cl.Model.Business.ServiceSerialRequestService>(serviceRequestServiceList.Count);
1092:
1093: foreach (var srs in serviceRequestServiceList)
1094: {
1095: serviceSerial = srs.Service + ":" + srs.Serial;
1096:
1097: if (!serviceRequestServiceNumberSerialComplementaryServiceDictionary.ContainsKey(serviceSerial))
1098: {
1099: serviceRequestServiceNumberSerialComplementaryServiceDictionary[serviceSerial] = srs;
1100: }
1101: }
1102:
1103:
1104: mismatchBetweenSrAndSrsList = new List<string>(1000);
1105: mismatchBetweenSrAndSrhList = new List<string>(1000);
1106: inSrNotInSrhList = new List<string>(serviceRequestNumberSerialComplementaryServiceDictionary.Count);
1107: inSrhNotInSrList = new List<string>(serviceRequestHistoryNumberSerialComplementaryServiceDictionary.Count);
1108:
1109: matchedServiceRequestAndServiceRequestHistoryNumberSerialComplementaryServiceDictionary = new Dictionary<string, ServiceSerialRequestService>(serviceRequestNumberSerialComplementaryServiceDictionary.Count + serviceRequestHistoryNumberSerialComplementaryServiceDictionary.Count);
1110: matchedServiceRequestAndServiceRequestServiceNumberSerialComplementaryServiceDictionary = new Dictionary<string, ServiceSerialRequestService>(serviceRequestNumberSerialComplementaryServiceDictionary.Count + serviceRequestServiceNumberSerialComplementaryServiceDictionary.Count);
1111:
1112: foreach (KeyValuePair<string, Ia.Ngn.Cl.Model.Business.ServiceSerialRequestService> kvp in serviceRequestNumberSerialComplementaryServiceDictionary)
1113: {
1114: if (serviceRequestServiceNumberSerialComplementaryServiceDictionary.ContainsKey(kvp.Key))
1115: {
1116: if (kvp.Value != serviceRequestServiceNumberSerialComplementaryServiceDictionary[kvp.Key])
1117: {
1118: if (!mismatchBetweenSrAndSrsList.Contains(kvp.Key))
1119: {
1120: mismatchBetweenSrAndSrsList.Add(kvp.Key);
1121: }
1122: else
1123: {
1124:
1125: }
1126: }
1127: else
1128: {
1129: matchedServiceRequestAndServiceRequestServiceNumberSerialComplementaryServiceDictionary[kvp.Key] = kvp.Value;
1130: }
1131: }
1132: //else inSrhNotInSrsList.Add(kvp.Key);
1133:
1134: if (serviceRequestHistoryNumberSerialComplementaryServiceDictionary.ContainsKey(kvp.Key))
1135: {
1136: if (kvp.Value != serviceRequestHistoryNumberSerialComplementaryServiceDictionary[kvp.Key])
1137: {
1138: mismatchBetweenSrAndSrhList.Add(kvp.Key);
1139: }
1140: else
1141: {
1142: matchedServiceRequestAndServiceRequestHistoryNumberSerialComplementaryServiceDictionary[kvp.Key] = kvp.Value;
1143: }
1144: }
1145: else inSrNotInSrhList.Add(kvp.Key);
1146: }
1147:
1148: foreach (KeyValuePair<string, Ia.Ngn.Cl.Model.Business.ServiceSerialRequestService> kvp in serviceRequestHistoryNumberSerialComplementaryServiceDictionary)
1149: {
1150: if (serviceRequestNumberSerialComplementaryServiceDictionary.ContainsKey(kvp.Key))
1151: {
1152: if (kvp.Value != serviceRequestNumberSerialComplementaryServiceDictionary[kvp.Key])
1153: {
1154: if (!mismatchBetweenSrAndSrhList.Contains(kvp.Key))
1155: {
1156: mismatchBetweenSrAndSrhList.Add(kvp.Key);
1157: }
1158: else
1159: {
1160:
1161: }
1162: }
1163: else
1164: {
1165: matchedServiceRequestAndServiceRequestHistoryNumberSerialComplementaryServiceDictionary[kvp.Key] = kvp.Value;
1166: }
1167: }
1168: else inSrhNotInSrList.Add(kvp.Key);
1169: }
1170:
1171:
1172: serviceRequestServiceListCount = serviceRequestServiceList.Count;
1173: serviceRequestNumberSerialComplementaryServiceDictionaryCount = serviceRequestNumberSerialComplementaryServiceDictionary.Count;
1174: serviceRequestHistoryNumberSerialComplementaryServiceDictionaryCount = serviceRequestHistoryNumberSerialComplementaryServiceDictionary.Count;
1175: matchedServiceRequestAndServiceRequestHistoryNumberSerialComplementaryServiceDictionaryCount = matchedServiceRequestAndServiceRequestHistoryNumberSerialComplementaryServiceDictionary.Count;
1176: matchedServiceRequestAndServiceRequestServiceNumberSerialComplementaryServiceDictionaryCount = matchedServiceRequestAndServiceRequestServiceNumberSerialComplementaryServiceDictionary.Count;
1177: }
1178:
1179: ////////////////////////////////////////////////////////////////////////////
1180: ////////////////////////////////////////////////////////////////////////////
1181: }
1182:
1183: ////////////////////////////////////////////////////////////////////////////
1184: ////////////////////////////////////////////////////////////////////////////
1185:
1186:
1187:
1188:
1189:
1190:
1191:
1192:
1193: ////////////////////////////////////////////////////////////////////////////
1194:
1195: /// <summary>
1196: /// Number Format Covnerter for Nokia and Huaweri Number Formats for the Optical Fiber Network - Kuwait
1197: /// </summary>
1198: ///
1199: /// <remarks>
1200: /// Copyright © 2001-2017 Jasem Y. Al-Shamlan (info@ia.com.kw), Internet Applications - Kuwait. All Rights Reserved.
1201: ///
1202: /// 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
1203: /// the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
1204: ///
1205: /// This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
1206: /// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
1207: ///
1208: /// You should have received a copy of the GNU General Public License along with this library. If not, see http://www.gnu.org/licenses.
1209: ///
1210: /// Copyright notice: This notice may not be removed or altered from any source distribution.
1211: /// </remarks>
1212: public class NumberFormatConverter
1213: {
1214: /// <summary/>
1215: public NumberFormatConverter()
1216: {
1217: /*
1218: <Dn>+96522239100</Dn>
1219: <PrividUser>priv_96522239100</PrividUser>
1220: <PartyId>+96522239501</PartyId>
1221: <PrimaryPUID>+96522239501</PrimaryPUID>
1222: <aid>+96522239501</aid>
1223: <PublicUID>+96522239100@ims.moc1.kw</PublicUID>
1224: <PrivateId>priv_96522239100</PrivateId>
1225: <Puid>sip:+96522239100</Puid>
1226: <PridUser>priv_96522239100</PridUser>
1227: *
1228: * impu = "tel:+" + Ia.Ngn.Cl.Model.Data.Service.CountryCode + number;
1229: sip:+96523900012@ims.moc.kw
1230:
1231: */
1232: }
1233:
1234: /// <summary/>
1235: public static string Dn(string service)
1236: {
1237: return "+" + Ia.Ngn.Cl.Model.Business.Service.CountryCode + service;
1238: }
1239:
1240: public static string SipUserName(string service)
1241: {
1242: return Dn(service);
1243: }
1244:
1245: /// <summary/>
1246: public static string ServiceWithCountryCode(string service)
1247: {
1248: return Ia.Ngn.Cl.Model.Business.Service.CountryCode + service;
1249: }
1250:
1251: /// <summary>
1252: /// This will check if service is a regex match to a service number with a country code
1253: /// </summary>
1254: public static bool IsMatchToServiceWithCountryCode(string service)
1255: {
1256: return Regex.IsMatch(service, @"^" + Ia.Ngn.Cl.Model.Business.Service.CountryCode + @"\d{8}$");
1257: }
1258:
1259: /// <summary/>
1260: public static string PrividUser(string service)
1261: {
1262: return "priv_" + Ia.Ngn.Cl.Model.Business.Service.CountryCode + service;
1263: }
1264:
1265: /// <summary/>
1266: public static string PartyId(string service)
1267: {
1268: return "+" + Ia.Ngn.Cl.Model.Business.Service.CountryCode + Service(service);
1269: }
1270:
1271: /// <summary/>
1272: public static string PrimaryPuid(string service)
1273: {
1274: return "+" + Ia.Ngn.Cl.Model.Business.Service.CountryCode + service;
1275: }
1276:
1277: /// <summary/>
1278: public static string Aid(string service)
1279: {
1280: return "+" + Ia.Ngn.Cl.Model.Business.Service.CountryCode + service;
1281: }
1282:
1283: /// <summary/>
1284: public static string PublicUid(string service)
1285: {
1286: return "+" + Ia.Ngn.Cl.Model.Business.Service.CountryCode + service + "@ims.moc1.kw";
1287: }
1288:
1289: /// <summary/>
1290: public static string PrivateId(string service)
1291: {
1292: return "priv_" + Ia.Ngn.Cl.Model.Business.Service.CountryCode + service;
1293: }
1294:
1295: /// <summary/>
1296: public static string Puid(string service)
1297: {
1298: return "sip:+" + Ia.Ngn.Cl.Model.Business.Service.CountryCode + service;
1299: }
1300:
1301: /// <summary/>
1302: public static string PridUser(string service)
1303: {
1304: return "priv_" + Ia.Ngn.Cl.Model.Business.Service.CountryCode + service;
1305: }
1306:
1307: /// <summary>
1308: /// This will check if service is a regex match to PridUser number
1309: /// </summary>
1310: public static bool IsMatchToPridUser(string service)
1311: {
1312: return Regex.IsMatch(service, @"^priv_" + Ia.Ngn.Cl.Model.Business.Service.CountryCode + @"\d{8}$");
1313: }
1314:
1315: /// <summary/>
1316: public static string Impu(int number)
1317: {
1318: return "tel:+" + Ia.Ngn.Cl.Model.Business.Service.CountryCode + number;
1319: }
1320:
1321: /// <summary/>
1322: public static string Impi(string service)
1323: {
1324: return "+" + Ia.Ngn.Cl.Model.Business.Service.CountryCode + Service(service) + "@ims.moc.kw";
1325: }
1326:
1327: /// <summary/>
1328: public static string SipName(string service)
1329: {
1330: return Impi(service);
1331: }
1332:
1333: /// <summary>
1334: /// This will check if service is a regex match to Impi number
1335: /// </summary>
1336: public static bool IsMatchToImpi(string service)
1337: {
1338: return Regex.IsMatch(service, @"^\+" + Ia.Ngn.Cl.Model.Business.Service.CountryCode + @"\d{8}@ims.moc.kw$");
1339: }
1340:
1341: /// <summary/>
1342: public static string Impu(string service)
1343: {
1344: return "tel:+" + Ia.Ngn.Cl.Model.Business.Service.CountryCode + Service(service);
1345: }
1346:
1347: /// <summary/>
1348: public static string ImpuSipDomain(int number)
1349: {
1350: return "sip:+" + Ia.Ngn.Cl.Model.Business.Service.CountryCode + number + "@ims.moc.kw";
1351: }
1352:
1353: /// <summary/>
1354: public static string ImpuAid(string service)
1355: {
1356: return "+" + Ia.Ngn.Cl.Model.Business.Service.CountryCode + Service(service);
1357: }
1358:
1359: /// <summary>
1360: /// This will check if service is a regex match to ImpuAid number
1361: /// </summary>
1362: public static bool IsMatchToImpuAid(string service)
1363: {
1364: return Regex.IsMatch(service, @"^\+" + Ia.Ngn.Cl.Model.Business.Service.CountryCode + @"\d{8}$");
1365: }
1366:
1367: /// <summary/>
1368: public static string E164ProtocolUserNumber(string service)
1369: {
1370: string s, u, v;
1371:
1372: if (!string.IsNullOrEmpty(service))
1373: {
1374: u = Ia.Ngn.Cl.Model.Business.Service.CountryCode + Service(service);
1375:
1376: if (u.Length > 0)
1377: {
1378: // convert number to E164 protocol user number format
1379: v = string.Empty;
1380:
1381: for (int i = u.Length - 1; i >= 0; i--) v += u[i] + ".";
1382:
1383: s = v + "e164.arpa";
1384: }
1385: else s = string.Empty;
1386: }
1387: else s = string.Empty;
1388:
1389: return s;
1390: }
1391:
1392: /// <summary/>
1393: public static string SubId(string service)
1394: {
1395: return Impi(service);
1396: }
1397:
1398: /// <summary/>
1399: public static string ImpuSipDomain(string service)
1400: {
1401: return "sip:+" + Ia.Ngn.Cl.Model.Business.Service.CountryCode + Service(service) + "@ims.moc.kw";
1402: }
1403:
1404: /// <summary/>
1405: public static int Number(string service)
1406: {
1407: int i, number;
1408:
1409: service = Service(service);
1410:
1411: number = int.TryParse(service, out i) ? i : 0;
1412:
1413: return number;
1414: }
1415:
1416: /// <summary/>
1417: public static string Service(string someNumberFormat)
1418: {
1419: string s;
1420:
1421: if (someNumberFormat.Contains("tel:")) s = someNumberFormat.Replace("tel:+" + Ia.Ngn.Cl.Model.Business.Service.CountryCode, "");
1422: else if (someNumberFormat.Contains("sip:"))
1423: {
1424: s = someNumberFormat.Replace("sip:+" + Ia.Ngn.Cl.Model.Business.Service.CountryCode, "");
1425: s = s.Replace("@ims.moc.kw", "");
1426: }
1427: else if (someNumberFormat.Contains("priv_" + Ia.Ngn.Cl.Model.Business.Service.CountryCode)) s = someNumberFormat.Replace("priv_" + Ia.Ngn.Cl.Model.Business.Service.CountryCode, "");
1428: else if (someNumberFormat.Contains("+" + Ia.Ngn.Cl.Model.Business.Service.CountryCode)) s = someNumberFormat.Replace("+" + Ia.Ngn.Cl.Model.Business.Service.CountryCode, "");
1429: 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, "");
1430: else if (Regex.IsMatch(someNumberFormat, @"\d{8}")) s = someNumberFormat; // order important
1431: else s = Ia.Cl.Model.Default.Match(someNumberFormat, @".+(\d{8})");
1432:
1433: return s;
1434: }
1435:
1436: ////////////////////////////////////////////////////////////////////////////
1437: ////////////////////////////////////////////////////////////////////////////
1438: }
1439:
1440: ////////////////////////////////////////////////////////////////////////////
1441: ////////////////////////////////////////////////////////////////////////////
1442: }