1: using Ia.Ngn.Cl.Migrations;
2: using System;
3: using System.Collections;
4: using System.Collections.Generic;
5: using System.Data;
6: using System.IO;
7: using System.Linq;
8: using System.Reflection;
9: using System.Text;
10: using System.Text.RegularExpressions;
11: using System.Web;
12: using System.Xml.Linq;
13:
14: namespace Ia.Ngn.Cl.Model.Data
15: {
16: ////////////////////////////////////////////////////////////////////////////
17:
18: /// <summary publish="true">
19: /// Network Design Document support class for Next Generation Network (NGN) data model.
20: /// </summary>
21: ///
22: /// <remarks>
23: /// Copyright © 2006-2020 Jasem Y. Al-Shamlan (info@ia.com.kw), Integrated Applications - Kuwait. All Rights Reserved.
24: ///
25: /// 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
26: /// the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
27: ///
28: /// This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
29: /// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
30: ///
31: /// You should have received a copy of the GNU General Public License along with this library. If not, see http://www.gnu.org/licenses.
32: ///
33: /// Copyright notice: This notice may not be removed or altered from any source distribution.
34: /// </remarks>
35: public static partial class NetworkDesignDocument
36: {
37: private static XDocument xDocument;
38: private static Dictionary<string, int> ontIdToOntPonPonGroupOltIdDictionary;
39: private static Dictionary<string, string> ontAccessIdToOntIdDictionary, ontIdToOntAccessNameDictionary, ontAccessNameToOntAccessIdDictionary, ontAccessNameToOntIdDictionary, ontAccessIdToOntAccessNameDictionary, ontAccessIdToOntAccessNameWithinAllowedToBeMigratedOltDictionary, ontIpToOntAccessNameDictionary, ontIpToOntAccessIdDictionary, ontAccessNameToOntIpDictionary, ontAccessNameToOntMgcIpDictionary, ontAccessNameToOntPositionDictionary, ontIdDictionary, ontIpDictionary, ponNameToPonIdDictionary;
40: private static Dictionary<string, Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Ont> ontAccessIdToOntDictionary, ontIdToOntDictionary, ontIpToOntDictionary, ontAccessNameToOntDictionary;
41: private static Dictionary<string, Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Pon> ponIdToPonDictionary, ponNameToPonDictionary;
42: private static Dictionary<int, Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Site> routerDomainToSiteDictionary, pstnDomainToSiteDictionary;
43: private static Dictionary<int, Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.PstnExchangeType> pstnFiveDigitDomainToPstnExchangeTypeDictionary;
44: private static Dictionary<Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Pstn, List<int>> pstnToFiveDigitDomainListDictionary;
45: private static List<Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Network> networkList;
46: private static List<Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Vendor> vendorList;
47: private static List<Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Site> siteList;
48: private static List<Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Pstn> pstnList;
49: private static List<Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Router> routerList;
50: private static List<Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Oam> oamList;
51: private static List<Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Odf> odfList;
52: private static List<Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Olt> oltList;
53: private static List<Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.PonGroup> ponGroupList;
54: private static List<Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Pon> ponList;
55: private static List<Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Ont> ontList;
56:
57: private static readonly object objectLock = new object();
58:
59: /// <summary/>
60: public enum BellcoreState { Undefined = 0, IsNr = 1, OosAu, OosMa, OosAuma };
61:
62: ////////////////////////////////////////////////////////////////////////////
63:
64: /// <summary>
65: ///
66: /// </summary>
67: //public NetworkDesignDocument() { }
68:
69: ////////////////////////////////////////////////////////////////////////////
70:
71: /// <summary>
72: ///
73: /// </summary>
74: public static List<Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Ont> OntList
75: {
76: get
77: {
78: lock (objectLock)
79: {
80: if (ontList == null || ontList.Count == 0) ontList = Ia.Ngn.Cl.Model.Data.NetworkDesignDocument._OntList;
81:
82: return ontList;
83: }
84: }
85: }
86:
87: ////////////////////////////////////////////////////////////////////////////
88:
89: /// <summary>
90: ///
91: /// </summary>
92: private static List<Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Ont> _OntList
93: {
94: get
95: {
96: bool nokiaRouter, huaweiRouter, nokiaOdf, huaweiOdf;
97: long networkNumberIpLong, ipLong, diff, l;
98: string oltSymbol;
99:
100: #if DEBUG
101: Dictionary<string, string> ontDictionary, proposedOntDictionary, ipDictionary;
102: #endif
103: Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Ont ont;
104: Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Access access;
105: Ia.Ngn.Cl.Model.Business.Ims.ImsBasicService imsBasicService;
106:
107: ontList = new List<Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Ont>(Ia.Ngn.Cl.Model.Data.NetworkDesignDocument.PonList.Count * 32);
108: #if DEBUG
109: ontDictionary = new Dictionary<string, string>(Ia.Ngn.Cl.Model.Data.NetworkDesignDocument.PonList.Count * 32);
110: proposedOntDictionary = new Dictionary<string, string>(Ia.Ngn.Cl.Model.Data.NetworkDesignDocument.PonList.Count * 32);
111: ipDictionary = new Dictionary<string, string>(Ia.Ngn.Cl.Model.Data.NetworkDesignDocument.PonList.Count * 32);
112: #endif
113:
114: var nokiaAccessNameWithPbxList = Ia.Ngn.Cl.Model.Data.Ims.NokiaAccessNameWithPbxList;
115:
116: foreach (var ponGroup in Ia.Ngn.Cl.Model.Data.NetworkDesignDocument.PonGroupList)
117: {
118: nokiaRouter = (ponGroup.Olt.Odf.Router.Vendor == Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Vendor.Nokia) ? true : false; // false for Huawei
119: huaweiRouter = !nokiaRouter;
120:
121: nokiaOdf = (ponGroup.Olt.Odf.Vendor == Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Vendor.Nokia) ? true : false; // false for Huawei
122: huaweiOdf = !nokiaOdf;
123:
124: oltSymbol = ponGroup.Olt.Symbol;
125:
126: networkNumberIpLong = Ia.Cl.Model.Default.IpToDec(ponGroup.NetworkNumber);
127:
128: // standard imsBasicService
129: if (nokiaRouter)
130: {
131: if (nokiaOdf) imsBasicService = Ia.Ngn.Cl.Model.Business.Ims.NokiaImsBasicServiceItem(ponGroup);
132: else imsBasicService = Ia.Ngn.Cl.Model.Business.Ims.SpecialHuaweiIpHandlingForNokiaImsBasicServiceItem(ponGroup);
133: }
134: else imsBasicService = Ia.Ngn.Cl.Model.Business.Ims.HuaweiImsBasicServiceItem(ponGroup);
135:
136: foreach (var pon in ponGroup.PonList)
137: {
138: #if DEBUG
139: if (pon.Name == "ABW.144")
140: {
141:
142: }
143: #endif
144:
145: for (int ontNumber = 1; ontNumber <= ponGroup.Olt.NumberOfOntsInPon; ontNumber++)
146: {
147: ont = new Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Ont();
148: access = new Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Access();
149:
150: ont.Pon = pon;
151:
152: ont.Rack = ponGroup.Olt.Rack;
153: ont.Sub = ponGroup.Olt.Sub;
154: ont.CardSlot = pon.CardSlot; // CardSlot might change for MDUs below
155: ont.Port = pon.Port;
156:
157: ont.Number = ontNumber;
158:
159: ont.InternalNumber = (pon.Index * ponGroup.Olt.NumberOfOntsInPon) % 32 + ont.Number;
160:
161: ont.Position = ponGroup.Olt.AmsName + "-" + ont.CardSlot + "-" + ont.Port + "-" + ont.InternalNumber;
162:
163: access.Id = access.AccessId(ponGroup.Olt.Id, pon.Number, ont.Number);
164: access.Pon = pon.Number;
165: access.ProposedPon = pon.ProposedNumber;
166: access.Ont = ont.Number;
167:
168: access.Symbol = ponGroup.Symbol;
169: access.Name = ponGroup.Symbol + "." + pon.Number + "." + ont.Number;
170: access.ProposedName = ponGroup.Symbol + "." + pon.ProposedNumber + "." + ont.Number;
171:
172: #if DEBUG
173: if (access.Name == "SSB.44.27")
174: {
175:
176: }
177: #endif
178:
179: ont.Access = access;
180:
181: ipLong = networkNumberIpLong + pon.PonGroupPonIndex * ponGroup.Olt.NumberOfOntsInPon + ont.Number; // or ont.InternalNumber
182: diff = ipLong - networkNumberIpLong;
183:
184: if (nokiaOdf)
185: {
186: // below: skip *.*.*.0 only for Nokia ONTs
187: l = (diff - 1) / 255;
188:
189: ipLong += l;
190: }
191: else //if(huaweiOdf)
192: {
193: if (nokiaRouter)
194: {
195: }
196: else //if (huaweiRouter)
197: {
198: // Huawei router and ODF. Here we will skip *.*.*.0 and *.*.*.1. Go figure!
199: ipLong += 1;
200: }
201: }
202:
203: ont.Ip = Ia.Cl.Model.Default.DecToIp((int)ipLong);
204:
205: // ont.Id is used in functions below
206: ont.Id = Ia.Ngn.Cl.Model.Business.Nokia.Ont.OntId(pon.Id, ont.InternalNumber);
207:
208: // special imsBasicService
209: if (nokiaRouter)
210: {
211: if (huaweiOdf)
212: {
213: if (nokiaAccessNameWithPbxList.Contains(ont.Access.Name))
214: {
215: ont.ImsBasicService = Ia.Ngn.Cl.Model.Business.Ims.NokiaImsBasicServiceItemForAccessWithPbx(ont);
216: }
217: else ont.ImsBasicService = Ia.Ngn.Cl.Model.Business.Ims.SpecialHuaweiIpHandlingForNokiaImsBasicServiceItem(ont) ?? imsBasicService;
218: }
219: else
220: {
221: if (nokiaAccessNameWithPbxList.Contains(ont.Access.Name))
222: {
223: ont.ImsBasicService = Ia.Ngn.Cl.Model.Business.Ims.NokiaImsBasicServiceItemForAccessWithPbx(ont);
224: }
225: else ont.ImsBasicService = imsBasicService;
226: }
227: }
228: else ont.ImsBasicService = imsBasicService;
229:
230:
231: #if DEBUG
232: // this will throw an exception if there is a duplicate ont.Access.Name
233: if (ontDictionary.ContainsKey(ont.Access.Name))
234: {
235: throw new ArgumentOutOfRangeException(@"ontDictionary.ContainsKey(ont.Access.Name)");
236: }
237: else ontDictionary[ont.Access.Name] = ont.Id;
238:
239: // this will throw an exception if there is a duplicate ont.Access.ProposedName
240: if (proposedOntDictionary.ContainsKey(ont.Access.ProposedName))
241: {
242: throw new ArgumentOutOfRangeException(@"proposedOntDictionary.ContainsKey(ont.Access.ProposedName)");
243: }
244: else proposedOntDictionary[ont.Access.ProposedName] = ont.Id;
245:
246: /*
247: // this will throw an exception if an IP has *.*.*.0
248: // over 400 Huawei ONTs with *.*.*.0 IPs
249: if (Regex.IsMatch(ont.Ip, @"\d{1,3}\.\d{1,3}\.\d{1,3}\.0"))
250: {
251: list.Add(ont.Access.Name);
252: }
253: */
254:
255: // this will throw an exception if there is a duplicate ont.Ip
256: if (ipDictionary.ContainsKey(ont.Ip))
257: {
258: throw new ArgumentOutOfRangeException(@"ipDictionary.ContainsKey(ont.Ip)");
259: }
260: else ipDictionary[ont.Ip] = ont.Id;
261: #endif
262: ontList.Add(ont);
263: }
264: }
265: }
266:
267: // as a precaution, this will throw an exception if there are not n number of records
268: if (ontList.Count != Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.PrecautionaryHardCodedNumberOfOntRecords)
269: {
270: throw new ArgumentOutOfRangeException(@"(ontList.Count != " + Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.PrecautionaryHardCodedNumberOfOntRecords);
271: }
272:
273: return ontList;
274: }
275: }
276:
277: ////////////////////////////////////////////////////////////////////////////
278:
279: /// <summary>
280: /// A Hashtable "faster" version of OntList for frequent use
281: /// </summary>
282: public static Hashtable OntAccessIdToAccessVendorHashtable
283: {
284: get
285: {
286: Hashtable ht;
287:
288: ht = new Hashtable(Ia.Ngn.Cl.Model.Data.NetworkDesignDocument.OntList.Count);
289:
290: foreach (Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Ont ont in Ia.Ngn.Cl.Model.Data.NetworkDesignDocument.OntList)
291: {
292: ht[ont.Access.Id] = ont.Pon.PonGroup.Olt.Odf.Vendor;
293: }
294:
295: return ht;
296: }
297: }
298:
299: ////////////////////////////////////////////////////////////////////////////
300:
301: /// <summary>
302: ///
303: /// </summary>
304: public static List<string> OntAccessIdList
305: {
306: get
307: {
308: List<string> list;
309:
310: list = (from o in Ia.Ngn.Cl.Model.Data.NetworkDesignDocument.OntList orderby o.Access.Id select o.Access.Id).ToList();
311:
312: return list;
313: }
314: }
315:
316: ////////////////////////////////////////////////////////////////////////////
317:
318: /// <summary>
319: ///
320: /// </summary>
321: public static Dictionary<string, int> OntAccessIdDictionary
322: {
323: get
324: {
325: Dictionary<string, int> dictionary;
326:
327: dictionary = (from o in Ia.Ngn.Cl.Model.Data.NetworkDesignDocument.OntList
328: select o.Access.Id).ToDictionary(n => n, n => 1);
329:
330: return dictionary;
331: }
332: }
333:
334: ////////////////////////////////////////////////////////////////////////////
335:
336: /// <summary>
337: ///
338: /// </summary>
339: public static Dictionary<string, string> OntAccessIdToOntIdDictionary
340: {
341: get
342: {
343: if (ontAccessIdToOntIdDictionary == null || ontAccessIdToOntIdDictionary.Count == 0)
344: {
345: ontAccessIdToOntIdDictionary = (from o in Ia.Ngn.Cl.Model.Data.NetworkDesignDocument.OntList
346: select new { AccessId = o.Access.Id, OntId = o.Id }).ToDictionary(n => n.AccessId, n => n.OntId);
347: }
348:
349: return ontAccessIdToOntIdDictionary;
350: }
351: }
352:
353: ////////////////////////////////////////////////////////////////////////////
354:
355: /// <summary>
356: ///
357: /// </summary>
358: public static Dictionary<string, Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Ont> OntAccessIdToOntDictionary
359: {
360: get
361: {
362: if (ontAccessIdToOntDictionary == null || ontAccessIdToOntDictionary.Count == 0)
363: {
364: ontAccessIdToOntDictionary = (from o in Ia.Ngn.Cl.Model.Data.NetworkDesignDocument.OntList
365: select new { AccessId = o.Access.Id, Ont = o }).ToDictionary(n => n.AccessId, n => n.Ont);
366: }
367:
368: return ontAccessIdToOntDictionary;
369: }
370: }
371:
372: ////////////////////////////////////////////////////////////////////////////
373:
374: /// <summary>
375: ///
376: /// </summary>
377: public static Dictionary<string, Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Ont> OntIpToOntDictionary
378: {
379: get
380: {
381: if (ontIpToOntDictionary == null || ontIpToOntDictionary.Count == 0)
382: {
383: ontIpToOntDictionary = (from o in Ia.Ngn.Cl.Model.Data.NetworkDesignDocument.OntList
384: select new { Ip = o.Ip, Ont = o }).ToDictionary(n => n.Ip, n => n.Ont);
385: }
386:
387: return ontIpToOntDictionary;
388: }
389: }
390:
391: ////////////////////////////////////////////////////////////////////////////
392:
393: /// <summary>
394: ///
395: /// </summary>
396: public static Dictionary<string, Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Ont> OntAccessIdToOntForOltIdListDictionary(List<int> oltIdList)
397: {
398: var list = (from o in Ia.Ngn.Cl.Model.Data.NetworkDesignDocument.OntList
399: where oltIdList.Contains(o.Pon.PonGroup.Olt.Id)
400: select new { AccessId = o.Access.Id, Ont = o }).ToDictionary(n => n.AccessId, n => n.Ont);
401:
402: return list;
403: }
404:
405: ////////////////////////////////////////////////////////////////////////////
406:
407: /// <summary>
408: ///
409: /// </summary>
410: public static Dictionary<string, Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Ont> OntIpToOntForOltIdListDictionary(List<int> oltIdList)
411: {
412: var list = (from o in Ia.Ngn.Cl.Model.Data.NetworkDesignDocument.OntList
413: where oltIdList.Contains(o.Pon.PonGroup.Olt.Id)
414: select new { OntIp = o.Ip, Ont = o }).ToDictionary(n => n.OntIp, n => n.Ont);
415:
416: return list;
417: }
418:
419: ////////////////////////////////////////////////////////////////////////////
420:
421: /// <summary>
422: ///
423: /// </summary>
424: public static Dictionary<string, Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Ont> OntAccessIdToOntForOltSymbolListDictionary(List<string> oltSymbolList)
425: {
426: var list = (from o in Ia.Ngn.Cl.Model.Data.NetworkDesignDocument.OntList
427: where oltSymbolList.Contains(o.Pon.PonGroup.Olt.Symbol)
428: select new { AccessId = o.Access.Id, Ont = o }).ToDictionary(n => n.AccessId, n => n.Ont);
429:
430: return list;
431: }
432:
433: ////////////////////////////////////////////////////////////////////////////
434:
435: /// <summary>
436: ///
437: /// </summary>
438: public static Dictionary<int, Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Site> RouterDomainToSiteDictionary
439: {
440: get
441: {
442: if (routerDomainToSiteDictionary == null || routerDomainToSiteDictionary.Count == 0)
443: {
444: routerDomainToSiteDictionary = new Dictionary<int, Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Site>();
445:
446: var routerList = Ia.Ngn.Cl.Model.Data.NetworkDesignDocument.RouterList;
447:
448: foreach (int domain in routerList.SelectMany(u => u.DomainList))
449: {
450: routerDomainToSiteDictionary[domain] = (from r in routerList where r.DomainList.Contains(domain) select r.Site).FirstOrDefault(); //.SingleOrDefault(); see NDD XML with domain 2390, has two sites
451: }
452: }
453:
454: return routerDomainToSiteDictionary;
455: }
456: }
457:
458: ////////////////////////////////////////////////////////////////////////////
459:
460: /// <summary>
461: ///
462: /// </summary>
463: public static Dictionary<int, Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Site> PstnDomainToSiteDictionary
464: {
465: get
466: {
467: if (pstnDomainToSiteDictionary == null || pstnDomainToSiteDictionary.Count == 0)
468: {
469: pstnDomainToSiteDictionary = new Dictionary<int, Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Site>();
470:
471: var pstnList = Ia.Ngn.Cl.Model.Data.NetworkDesignDocument.PstnList;
472:
473: foreach (int domain in pstnList.SelectMany(u => u.DomainList))
474: {
475: pstnDomainToSiteDictionary[domain] = (from p in pstnList where p.DomainList.Contains(domain) select p.Site).SingleOrDefault();
476: }
477: }
478:
479: return routerDomainToSiteDictionary;
480: }
481: }
482:
483: ////////////////////////////////////////////////////////////////////////////
484:
485: /// <summary>
486: ///
487: /// </summary>
488: public static Dictionary<Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Pstn, List<int>> PstnToFiveDigitDomainListDictionary()
489: {
490: if (pstnToFiveDigitDomainListDictionary == null || pstnToFiveDigitDomainListDictionary.Count == 0)
491: {
492: pstnToFiveDigitDomainListDictionary = new Dictionary<Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Pstn, List<int>>();
493:
494: var pstnList = Ia.Ngn.Cl.Model.Data.NetworkDesignDocument.PstnList;
495:
496: foreach (var pstn in pstnList)
497: {
498: var list = new List<int>();
499:
500: foreach (int domain in pstn.DomainList)
501: {
502: // already five digit domain
503: if (domain > 9999) list.Add(domain);
504: else
505: {
506: // four digit domain, we will need to create five digit domains related to it
507: for (int i = 0; i <= 9; i++)
508: {
509: list.Add(domain * 10 + i);
510: }
511: }
512:
513: pstnToFiveDigitDomainListDictionary[pstn] = list;
514: }
515: }
516: }
517:
518: return pstnToFiveDigitDomainListDictionary;
519: }
520:
521: ////////////////////////////////////////////////////////////////////////////
522:
523: /// <summary>
524: ///
525: /// </summary>
526: public static Dictionary<int, Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.PstnExchangeType> PstnFiveDigitDomainToVendorDictionary()
527: {
528: if (pstnFiveDigitDomainToPstnExchangeTypeDictionary == null || pstnFiveDigitDomainToPstnExchangeTypeDictionary.Count == 0)
529: {
530: pstnFiveDigitDomainToPstnExchangeTypeDictionary = new Dictionary<int, Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.PstnExchangeType>();
531:
532: var pstnList = Ia.Ngn.Cl.Model.Data.NetworkDesignDocument.PstnList;
533:
534: foreach (var pstn in pstnList)
535: {
536: foreach (int domain in pstn.DomainList)
537: {
538: // already five digit domain
539: if (domain > 9999) pstnFiveDigitDomainToPstnExchangeTypeDictionary[domain] = pstn.PstnExchangeType;
540: else
541: {
542: // four digit domain, we will need to create five digit domains related to it
543: for (int i = 0; i <= 9; i++)
544: {
545: pstnFiveDigitDomainToPstnExchangeTypeDictionary[domain * 10 + i] = pstn.PstnExchangeType;
546: }
547: }
548: }
549: }
550: }
551:
552: return pstnFiveDigitDomainToPstnExchangeTypeDictionary;
553: }
554:
555: ////////////////////////////////////////////////////////////////////////////
556:
557: /// <summary>
558: ///
559: /// </summary>
560: public static Dictionary<int, Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Vendor> DomainToRouterVendorDictionary
561: {
562: get
563: {
564: var dictionary = new Dictionary<int, Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Vendor>();
565:
566: var routerList = Ia.Ngn.Cl.Model.Data.NetworkDesignDocument.RouterList;
567:
568: foreach (int domain in routerList.SelectMany(u => u.DomainList))
569: {
570: dictionary[domain] = (from r in routerList
571: where r.DomainList.Contains(domain)
572: select r.Vendor).FirstOrDefault(); //.SingleOrDefault(); see NDD XML with domain 2390, has two sites
573: }
574:
575: return dictionary;
576: }
577: }
578:
579: ////////////////////////////////////////////////////////////////////////////
580:
581: /// <summary>
582: ///
583: /// </summary>
584: public static Dictionary<string, Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Ont> OntIdToOntDictionary
585: {
586: get
587: {
588: if (ontIdToOntDictionary == null || ontIdToOntDictionary.Count == 0)
589: {
590: ontIdToOntDictionary = (from o in Ia.Ngn.Cl.Model.Data.NetworkDesignDocument.OntList
591: select new { OntId = o.Id, Ont = o }).ToDictionary(n => n.OntId, n => n.Ont);
592: }
593:
594: return ontIdToOntDictionary;
595: }
596: }
597:
598: ////////////////////////////////////////////////////////////////////////////
599:
600: /// <summary>
601: ///
602: /// </summary>
603: public static Dictionary<string, string> OntIdToOntAccessNameDictionary
604: {
605: get
606: {
607: if (ontIdToOntAccessNameDictionary == null || ontIdToOntAccessNameDictionary.Count == 0)
608: {
609: ontIdToOntAccessNameDictionary = (from o in Ia.Ngn.Cl.Model.Data.NetworkDesignDocument.OntList
610: select new { OntId = o.Id, OntAccessName = o.Access.Name }).ToDictionary(n => n.OntId, n => n.OntAccessName);
611: }
612:
613: return ontIdToOntAccessNameDictionary;
614: }
615: }
616:
617: ////////////////////////////////////////////////////////////////////////////
618:
619: /// <summary>
620: ///
621: /// </summary>
622: public static Dictionary<string, string> OntAccessNameToOntIdDictionary
623: {
624: get
625: {
626: if (ontAccessNameToOntIdDictionary == null || ontAccessNameToOntIdDictionary.Count == 0)
627: {
628: ontAccessNameToOntIdDictionary = (from o in Ia.Ngn.Cl.Model.Data.NetworkDesignDocument.OntList
629: select new { OntAccessName = o.Access.Name, OntId = o.Id, }).ToDictionary(n => n.OntAccessName, n => n.OntId);
630: }
631:
632: return ontAccessNameToOntIdDictionary;
633: }
634: }
635:
636: ////////////////////////////////////////////////////////////////////////////
637:
638: /// <summary>
639: ///
640: /// </summary>
641: public static Dictionary<string, string> OntAccessNameToOntAccessIdDictionary
642: {
643: get
644: {
645: if (ontAccessNameToOntAccessIdDictionary == null || ontAccessNameToOntAccessIdDictionary.Count == 0)
646: {
647: ontAccessNameToOntAccessIdDictionary = (from o in Ia.Ngn.Cl.Model.Data.NetworkDesignDocument.OntList
648: select new { OntAccessName = o.Access.Name, OntAccessId = o.Access.Id, }).ToDictionary(n => n.OntAccessName, n => n.OntAccessId);
649: }
650:
651: return ontAccessNameToOntAccessIdDictionary;
652: }
653: }
654:
655: ////////////////////////////////////////////////////////////////////////////
656:
657: /// <summary>
658: ///
659: /// </summary>
660: public static Dictionary<string, Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Ont> OntAccessNameToOntDictionary
661: {
662: get
663: {
664: if (ontAccessNameToOntDictionary == null || ontAccessNameToOntDictionary.Count == 0)
665: {
666: ontAccessNameToOntDictionary = (from o in Ia.Ngn.Cl.Model.Data.NetworkDesignDocument.OntList
667: select new { OntAccessName = o.Access.Name, Ont = o, }).ToDictionary(n => n.OntAccessName, n => n.Ont);
668: }
669:
670: return ontAccessNameToOntDictionary;
671: }
672: }
673:
674: ////////////////////////////////////////////////////////////////////////////
675:
676: /// <summary>
677: ///
678: /// </summary>
679: public static Dictionary<string, string> OntAccessIdToOntAccessNameDictionary
680: {
681: get
682: {
683: if (ontAccessIdToOntAccessNameDictionary == null || ontAccessIdToOntAccessNameDictionary.Count == 0)
684: {
685: ontAccessIdToOntAccessNameDictionary = (from o in Ia.Ngn.Cl.Model.Data.NetworkDesignDocument.OntList
686: select new { OntAccessId = o.Access.Id, OntAccessName = o.Access.Name }).ToDictionary(n => n.OntAccessId, n => n.OntAccessName);
687: }
688:
689: return ontAccessIdToOntAccessNameDictionary;
690: }
691: }
692:
693: ////////////////////////////////////////////////////////////////////////////
694:
695: /// <summary>
696: ///
697: /// </summary>
698: public static Dictionary<string, string> OntAccessIdToOntAccessNameWithinAllowedToBeMigratedOltDictionary
699: {
700: get
701: {
702: if (ontAccessIdToOntAccessNameWithinAllowedToBeMigratedOltDictionary == null || ontAccessIdToOntAccessNameWithinAllowedToBeMigratedOltDictionary.Count == 0)
703: {
704: var allowedToBeMigratedOltIdList = Ia.Ngn.Cl.Model.Data.Service.AllowedToBeMigratedOltIdList;
705:
706: ontAccessIdToOntAccessNameWithinAllowedToBeMigratedOltDictionary = (from o in Ia.Ngn.Cl.Model.Data.NetworkDesignDocument.OntList
707: where allowedToBeMigratedOltIdList.Contains(o.Pon.PonGroup.Olt.Id)
708: select new { OntAccessId = o.Access.Id, OntAccessName = o.Access.Name }).ToDictionary(n => n.OntAccessId, n => n.OntAccessName);
709: }
710:
711: return ontAccessIdToOntAccessNameWithinAllowedToBeMigratedOltDictionary;
712: }
713: }
714:
715: ////////////////////////////////////////////////////////////////////////////
716:
717: /// <summary>
718: ///
719: /// </summary>
720: public static Dictionary<string, string> OntAccessIdToOntAccessNameForOltSymbolListDictionary(List<string> oltSymbolList)
721: {
722: var list = (from o in Ia.Ngn.Cl.Model.Data.NetworkDesignDocument.OntList
723: where oltSymbolList.Contains(o.Pon.PonGroup.Olt.Symbol)
724: select new { OntAccessId = o.Access.Id, OntAccessName = o.Access.Name }).ToDictionary(n => n.OntAccessId, n => n.OntAccessName);
725:
726: return list;
727: }
728:
729: ////////////////////////////////////////////////////////////////////////////
730:
731: /// <summary>
732: ///
733: /// </summary>
734: public static Dictionary<string, string> OntIpToOntAccessNameDictionary
735: {
736: get
737: {
738: if (ontIpToOntAccessNameDictionary == null || ontIpToOntAccessNameDictionary.Count == 0)
739: {
740: ontIpToOntAccessNameDictionary = (from o in Ia.Ngn.Cl.Model.Data.NetworkDesignDocument.OntList
741: select new { OntIp = o.Ip, OntAccessName = o.Access.Name }).ToDictionary(n => n.OntIp, n => n.OntAccessName);
742: }
743:
744: return ontIpToOntAccessNameDictionary;
745: }
746: }
747:
748: ////////////////////////////////////////////////////////////////////////////
749:
750: /// <summary>
751: ///
752: /// </summary>
753: public static Dictionary<string, string> OntIpToOntAccessIdDictionary
754: {
755: get
756: {
757: if (ontIpToOntAccessIdDictionary == null || ontIpToOntAccessIdDictionary.Count == 0)
758: {
759: ontIpToOntAccessIdDictionary = (from o in Ia.Ngn.Cl.Model.Data.NetworkDesignDocument.OntList
760: select new { OntIp = o.Ip, OntAccessId = o.Access.Id }).ToDictionary(n => n.OntIp, n => n.OntAccessId);
761: }
762:
763: return ontIpToOntAccessIdDictionary;
764: }
765: }
766:
767: ////////////////////////////////////////////////////////////////////////////
768:
769: /// <summary>
770: ///
771: /// </summary>
772: public static Dictionary<string, string> OntAccessNameToOntIpDictionary
773: {
774: get
775: {
776: if (ontAccessNameToOntIpDictionary == null || ontAccessNameToOntIpDictionary.Count == 0)
777: {
778: ontAccessNameToOntIpDictionary = (from o in Ia.Ngn.Cl.Model.Data.NetworkDesignDocument.OntList
779: select new { OntAccessName = o.Access.Name, OntIp = o.Ip }).ToDictionary(n => n.OntAccessName, n => n.OntIp);
780: }
781:
782: return ontAccessNameToOntIpDictionary;
783: }
784: }
785:
786: ////////////////////////////////////////////////////////////////////////////
787:
788: /// <summary>
789: ///
790: /// </summary>
791: public static Dictionary<string, string> OntAccessNameToOntIpInHuaweiSwitchNokiaGponDictionary()
792: {
793: var dic = (from o in Ia.Ngn.Cl.Model.Data.NetworkDesignDocument.OntList
794: where o.Pon.PonGroup.Olt.Odf.Router.Vendor == Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Vendor.Huawei
795: && o.Pon.PonGroup.Olt.Odf.Vendor == Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Vendor.Nokia
796: select new { OntAccessName = o.Access.Name, OntIp = o.Ip }
797: ).ToDictionary(n => n.OntAccessName, n => n.OntIp);
798:
799: return dic;
800: }
801:
802: ////////////////////////////////////////////////////////////////////////////
803:
804: /// <summary>
805: ///
806: /// </summary>
807: public static Dictionary<string, string> OntAccessNameToOntMgcIpDictionary
808: {
809: get
810: {
811: if (ontAccessNameToOntMgcIpDictionary == null || ontAccessNameToOntMgcIpDictionary.Count == 0)
812: {
813: ontAccessNameToOntMgcIpDictionary = (from o in Ia.Ngn.Cl.Model.Data.NetworkDesignDocument.OntList
814: select new { OntAccessName = o.Access.Name, OntMgcIp = o.MgcIp }).ToDictionary(n => n.OntAccessName, n => n.OntMgcIp);
815: }
816:
817: return ontAccessNameToOntMgcIpDictionary;
818: }
819: }
820:
821: ////////////////////////////////////////////////////////////////////////////
822:
823: /// <summary>
824: ///
825: /// </summary>
826: public static Dictionary<string, string> OntAccessNameToOntPositionDictionary
827: {
828: get
829: {
830: if (ontAccessNameToOntPositionDictionary == null || ontAccessNameToOntPositionDictionary.Count == 0)
831: {
832: ontAccessNameToOntPositionDictionary = (from o in Ia.Ngn.Cl.Model.Data.NetworkDesignDocument.OntList
833: select new { OntAccessName = o.Access.Name, OntPosition = o.Position }).ToDictionary(n => n.OntAccessName, n => n.OntPosition);
834: }
835:
836: return ontAccessNameToOntPositionDictionary;
837: }
838: }
839:
840: ////////////////////////////////////////////////////////////////////////////
841:
842: /// <summary>
843: ///
844: /// </summary>
845: public static Dictionary<string, int> OntIdToOntPonPonGroupOltIdDictionary
846: {
847: get
848: {
849: if (ontIdToOntPonPonGroupOltIdDictionary == null || ontIdToOntPonPonGroupOltIdDictionary.Count == 0)
850: {
851: ontIdToOntPonPonGroupOltIdDictionary = (from o in Ia.Ngn.Cl.Model.Data.NetworkDesignDocument.OntList
852: select new { OntId = o.Id, OntPonPonGroupOltId = o.Pon.PonGroup.Olt.Id }).ToDictionary(n => n.OntId, n => n.OntPonPonGroupOltId);
853: }
854:
855: return ontIdToOntPonPonGroupOltIdDictionary;
856: }
857: }
858:
859: ////////////////////////////////////////////////////////////////////////////
860:
861: /// <summary>
862: ///
863: /// </summary>
864: public static Dictionary<string, string> OntIdDictionary
865: {
866: get
867: {
868: if (ontIdDictionary == null || ontIdDictionary.Count == 0)
869: {
870: ontIdDictionary = (from o in Ia.Ngn.Cl.Model.Data.NetworkDesignDocument.OntList select o.Id).ToDictionary(n => n, n => n);
871: }
872:
873: return ontIdDictionary;
874: }
875: }
876:
877: ////////////////////////////////////////////////////////////////////////////
878:
879: /// <summary>
880: ///
881: /// </summary>
882: public static Dictionary<string, string> OntIpDictionary
883: {
884: get
885: {
886: if (ontIpDictionary == null || ontIpDictionary.Count == 0)
887: {
888: ontIpDictionary = (from o in Ia.Ngn.Cl.Model.Data.NetworkDesignDocument.OntList select o.Ip).ToDictionary(n => n, n => n);
889: }
890:
891: return ontIpDictionary;
892: }
893: }
894:
895: ////////////////////////////////////////////////////////////////////////////
896:
897: /// <summary>
898: ///
899: /// </summary>
900: public static Dictionary<string, string> NokiaOntIpToPrimarySwitchImsFsdbDictionary
901: {
902: get
903: {
904: Dictionary<string, string> dictionary;
905:
906: dictionary = (from o in Ia.Ngn.Cl.Model.Data.NetworkDesignDocument.OntList
907: where o.Pon.PonGroup.Olt.Odf.Vendor == Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Vendor.Nokia
908: select o).Distinct().ToDictionary(n => n.Ip, n => n.PrimarySwitch + "(" + n.ImsFsdb + ")");
909:
910: return dictionary;
911: }
912: }
913:
914: ////////////////////////////////////////////////////////////////////////////
915:
916: /// <summary>
917: ///
918: /// </summary>
919: public static Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Ont OntByOltIdCardPortOntNumber(int oltId, int cardSlot, int port, int ontInternalNumber)
920: {
921: Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Ont item;
922:
923: item = (from o in Ia.Ngn.Cl.Model.Data.NetworkDesignDocument.OntList
924: where o.Pon.PonGroup.Olt.Id == oltId && o.CardSlot == cardSlot && o.Port == port && o.InternalNumber == ontInternalNumber
925: select o).SingleOrDefault();
926:
927: return item;
928: }
929:
930: ////////////////////////////////////////////////////////////////////////////
931:
932: /// <summary>
933: ///
934: /// </summary>
935: public static Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Ont OntByOltIdPonIdOntNumber(int oltId, string ponId, int ontInternalNumber)
936: {
937: Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Ont item;
938:
939: item = (from o in Ia.Ngn.Cl.Model.Data.NetworkDesignDocument.OntList
940: where o.Pon.PonGroup.Olt.Id == oltId && o.Pon.Id == ponId && o.InternalNumber == ontInternalNumber
941: select o).SingleOrDefault();
942:
943: return item;
944: }
945:
946: ////////////////////////////////////////////////////////////////////////////
947:
948: /// <summary>
949: ///
950: /// </summary>
951: public static bool AccessNameIsWithinAllowedOntList(string inputAccessName, out string accessName)
952: {
953: // below: this checks that this accessName is within the standard possible values in network
954: bool isWithinAllowedOnts;
955: string s;
956:
957: accessName = Ia.Ngn.Cl.Model.Business.Default.ExtractAccessNameWithValidSymbolAndLegalFormatForPonAndOntFromValue(inputAccessName);
958:
959: if (!string.IsNullOrEmpty(accessName))
960: {
961: s = accessName;
962:
963: isWithinAllowedOnts = (from o in Ia.Ngn.Cl.Model.Data.NetworkDesignDocument.OntList where o.Access.Name == s select o).SingleOrDefault() != null;
964: }
965: else isWithinAllowedOnts = false;
966:
967: return isWithinAllowedOnts;
968: }
969:
970: ////////////////////////////////////////////////////////////////////////////
971:
972: /// <summary>
973: ///
974: /// </summary>
975: public static Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Ont ReadOnt(string ontId)
976: {
977: return (from o in Ia.Ngn.Cl.Model.Data.NetworkDesignDocument.OntList where o.Id == ontId select o).SingleOrDefault();
978: }
979:
980: ////////////////////////////////////////////////////////////////////////////
981:
982: /// <summary>
983: ///
984: /// </summary>
985: public static Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Ont OntByAccessName(string accessName)
986: {
987: return (from o in Ia.Ngn.Cl.Model.Data.NetworkDesignDocument.OntList where o.Access.Name == accessName select o).SingleOrDefault();
988: }
989:
990: ////////////////////////////////////////////////////////////////////////////
991:
992: /// <summary>
993: ///
994: /// </summary>
995: public static Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Vendor AccessVendorByOntId(string ontId)
996: {
997: return (from o in Ia.Ngn.Cl.Model.Data.NetworkDesignDocument.OntList where o.Id == ontId select o.Pon.PonGroup.Olt.Odf.Vendor).SingleOrDefault();
998: }
999:
1000: ////////////////////////////////////////////////////////////////////////////
1001:
1002: /// <summary>
1003: ///
1004: /// </summary>
1005: public static Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Vendor AccessVendorByAccessName(string accessName)
1006: {
1007: return (from o in Ia.Ngn.Cl.Model.Data.NetworkDesignDocument.OntList where o.Access.Name == accessName select o.Pon.PonGroup.Olt.Odf.Vendor).SingleOrDefault();
1008: }
1009:
1010: ////////////////////////////////////////////////////////////////////////////
1011:
1012: /// <summary>
1013: ///
1014: /// </summary>
1015: public static Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Vendor SwitchVendorByAccessName(string accessName)
1016: {
1017: return (from o in Ia.Ngn.Cl.Model.Data.NetworkDesignDocument.OntList where o.Access.Name == accessName select o.Pon.PonGroup.Olt.Odf.Router.Vendor).SingleOrDefault();
1018: }
1019:
1020: ////////////////////////////////////////////////////////////////////////////
1021:
1022: /// <summary>
1023: ///
1024: /// </summary>
1025: public static Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Router RouterFromService(string service)
1026: {
1027: Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Router router;
1028:
1029: if (!string.IsNullOrEmpty(service))
1030: {
1031: if (int.TryParse(service, out int i))
1032: {
1033: router = (from r in Ia.Ngn.Cl.Model.Data.NetworkDesignDocument.RouterList
1034: where r.DomainList.Any(u => service.StartsWith(u.ToString()))
1035: select r).FirstOrDefault(); //.SingleOrDefault(); // 2390 is defined in two different huawei routers
1036: }
1037: else router = null;
1038: }
1039: else router = null;
1040:
1041: return router;
1042: }
1043:
1044: ////////////////////////////////////////////////////////////////////////////
1045:
1046: /// <summary>
1047: ///
1048: /// </summary>
1049: public static bool PonNameIsWithinAllowedOntList(string ontAreaPon)
1050: {
1051: // below: this checks that this accessName is within the standard possible values in network
1052:
1053: bool isWithinAllowedOnts;
1054:
1055: if (ontAreaPon == null || ontAreaPon.Length == 0) isWithinAllowedOnts = false;
1056: else
1057: {
1058: isWithinAllowedOnts = (from o in Ia.Ngn.Cl.Model.Data.NetworkDesignDocument.OntList where o.Access.Name.Contains(ontAreaPon + ".") select o).FirstOrDefault() != null;
1059: }
1060:
1061: return isWithinAllowedOnts;
1062: }
1063:
1064: ////////////////////////////////////////////////////////////////////////////
1065:
1066: /// <summary>
1067: ///
1068: /// </summary>
1069: public static string OntIdFromPosition(string position)
1070: {
1071: string id;
1072:
1073: id = (from o in Ia.Ngn.Cl.Model.Data.NetworkDesignDocument.OntList where o.Position == position select o.Id).FirstOrDefault();
1074:
1075: return id;
1076: }
1077:
1078: ////////////////////////////////////////////////////////////////////////////
1079:
1080: /// <summary>
1081: ///
1082: /// </summary>
1083: public static void ExportOntListToText()
1084: {
1085: string filePath;
1086: StringBuilder sb;
1087:
1088: sb = new StringBuilder();
1089:
1090: foreach (var o in Ia.Ngn.Cl.Model.Data.NetworkDesignDocument.OntList) sb.AppendLine(o.Access.Name + " " + o.Position + " " + o.Id);
1091:
1092: filePath = Environment.GetFolderPath(Environment.SpecialFolder.Desktop) + "\\ont-list.txt";
1093: File.WriteAllText(filePath, sb.ToString());
1094: }
1095:
1096: ////////////////////////////////////////////////////////////////////////////
1097: ////////////////////////////////////////////////////////////////////////////
1098:
1099:
1100:
1101:
1102:
1103:
1104:
1105: ////////////////////////////////////////////////////////////////////////////
1106: ////////////////////////////////////////////////////////////////////////////
1107:
1108: /// <summary>
1109: ///
1110: /// </summary>
1111: public static List<Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Pon> PonList
1112: {
1113: get
1114: {
1115: lock (objectLock)
1116: {
1117: if (ponList == null || ponList.Count == 0) ponList = Ia.Ngn.Cl.Model.Data.NetworkDesignDocument._PonList;
1118:
1119: return ponList;
1120: }
1121: }
1122: }
1123:
1124: ////////////////////////////////////////////////////////////////////////////
1125:
1126: /// <summary>
1127: ///
1128: /// </summary>
1129: private static List<Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Pon> _PonList
1130: {
1131: get
1132: {
1133: bool nokiaRouter, huaweiRouter, nokiaOdf, huaweiOdf;
1134: int ponNumber, proposedPonNumber, slot, oltPonIndex, oltPonCount, oltProposedPonCount;
1135: string odfName;
1136: #if DEBUG
1137: Dictionary<string, string> ponIdDictionary;
1138: #endif
1139: Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Pon pon;
1140:
1141: ponList = new List<Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Pon>(Ia.Ngn.Cl.Model.Data.NetworkDesignDocument.PonGroupList.Count * 32); // 32 is the max number of PONs in an PonGroup (16 max per LT)
1142: #if DEBUG
1143: ponIdDictionary = new Dictionary<string, string>(Ia.Ngn.Cl.Model.Data.NetworkDesignDocument.PonGroupList.Count * 32);
1144: #endif
1145: foreach (var olt in Ia.Ngn.Cl.Model.Data.NetworkDesignDocument.OltList)
1146: {
1147: oltPonIndex = 0;
1148:
1149: nokiaRouter = (olt.Odf.Router.Vendor == Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Vendor.Nokia) ? true : false; // false for Huawei
1150: huaweiRouter = !nokiaRouter;
1151:
1152: nokiaOdf = (olt.Odf.Vendor == Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Vendor.Nokia) ? true : false; // false for Huawei
1153: huaweiOdf = !nokiaOdf;
1154:
1155: odfName = olt.Odf.Name;
1156:
1157: oltPonCount = oltProposedPonCount = 0;
1158:
1159: foreach (var ponGroup in olt.PonGroupList)
1160: {
1161: oltPonCount += ponGroup.UsedPonInPonGroupList.Count;
1162:
1163: if (ponGroup.HasNewProposedPonList) oltProposedPonCount += ponGroup.UsedProposedPonInPonGroupList.Count;
1164: }
1165:
1166: if (((oltPonCount == oltProposedPonCount) || oltProposedPonCount == 0) && oltPonCount % 32 == 0)
1167: {
1168: foreach (var ponGroup in olt.PonGroupList)
1169: {
1170: if (!ponGroup.HasNewProposedPonList || ponGroup.UsedPonInPonGroupList.Count == ponGroup.UsedProposedPonInPonGroupList.Count)
1171: {
1172: // below: Note that I will use the INDEX of the PON number in the UsedPonList to construct the PON Id, this will make it possible
1173: // to match this index with that from the Ip, position list, because that list does not recognize PONs.
1174: for (int ponGroupPonIndex = 0; ponGroupPonIndex < ponGroup.UsedPonInPonGroupList.Count; ponGroupPonIndex++)
1175: {
1176: if ((int)ponGroup.UsedPonInPonGroupList[ponGroupPonIndex] != 0 && (!ponGroup.HasNewProposedPonList || (int)ponGroup.UsedProposedPonInPonGroupList[ponGroupPonIndex] != 0))
1177: {
1178: pon = new Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Pon();
1179:
1180: ponNumber = (int)ponGroup.UsedPonInPonGroupList[ponGroupPonIndex];
1181:
1182: if (ponGroup.HasNewProposedPonList) proposedPonNumber = (int)ponGroup.UsedProposedPonInPonGroupList[ponGroupPonIndex];
1183: else proposedPonNumber = ponNumber;
1184:
1185: pon.Id = pon.PonId(ponGroup.Olt.Id, oltPonIndex);
1186:
1187: pon.Index = oltPonIndex;
1188: pon.PonGroupPonIndex = ponGroupPonIndex;
1189:
1190: pon.PonGroup = (from l in PonGroupList where l.Id == ponGroup.Id select l).SingleOrDefault();
1191:
1192: pon.Rack = pon.PonGroup.Olt.Rack;
1193: pon.Sub = pon.PonGroup.Olt.Sub;
1194:
1195: if (nokiaOdf)
1196: {
1197: pon.CardSlot = oltPonIndex / olt.NumberOfLts + 1;
1198: pon.Port = oltPonIndex % olt.NumberOfLts + 1;
1199: }
1200: else //if(huaweiOdf)
1201: {
1202: // Huawei skips slots 9 and 10 and goes directly from 8 to 11
1203:
1204: slot = oltPonIndex / (olt.NumberOfPonsPerLt * olt.NumberOfLts / 16) + 1;
1205:
1206: if (slot > 8) slot += 2;
1207:
1208: if (ponGroup.Olt.NumberOfFirstSlot == 0) slot--;
1209:
1210: pon.CardSlot = slot;
1211:
1212: pon.Port = (16 * oltPonIndex % olt.NumberOfPons) / (32 / olt.NumberOfOntsInPon) / 16;
1213:
1214: }
1215:
1216: pon.Number = ponNumber;
1217: pon.ProposedNumber = proposedPonNumber;
1218: pon.Position = pon.PonGroup.Olt.AmsName + "-" + pon.CardSlot + "-" + pon.Port;
1219: pon.Name = pon.PonGroup.Symbol + "." + pon.Number;
1220:
1221: #if DEBUG
1222: if (pon.Name == "SBA.618")
1223: {
1224:
1225: }
1226: #endif
1227:
1228: #if DEBUG
1229: // this will throw an exception if there is a duplicate pon.Id
1230: if (ponIdDictionary.ContainsKey(pon.Id))
1231: {
1232: throw new ArgumentOutOfRangeException(@"ponDictionary.ContainsKey(pon.Id)");
1233: }
1234: else ponIdDictionary[pon.Id] = pon.Name;
1235: #endif
1236:
1237: ponList.Add(pon);
1238: }
1239: #if DEBUG
1240: else if ((int)ponGroup.UsedPonInPonGroupList[ponGroupPonIndex] != 0 && (ponGroup.HasNewProposedPonList && (int)ponGroup.UsedProposedPonInPonGroupList[ponGroupPonIndex] == 0))
1241: {
1242: throw new ArgumentOutOfRangeException(@"Fault condition met: (int)ponGroup.UsedPonInPonGroupList[ponGroupPonIndex] != 0 && (!ponGroup.UsesProposedList || (int)ponGroup.UsedProposedPonInPonGroupList[ponGroupPonIndex] == 0)");
1243: }
1244: else if ((int)ponGroup.UsedPonInPonGroupList[ponGroupPonIndex] == 0 && (ponGroup.HasNewProposedPonList && (int)ponGroup.UsedProposedPonInPonGroupList[ponGroupPonIndex] != 0))
1245: {
1246: throw new ArgumentOutOfRangeException(@"Fault condition met: (int)ponGroup.UsedPonInPonGroupList[ponGroupPonIndex] == 0 && (!ponGroup.UsesProposedList || (int)ponGroup.UsedProposedPonInPonGroupList[ponGroupPonIndex] != 0)");
1247: }
1248: else
1249: {
1250: }
1251: #endif
1252: oltPonIndex++;
1253: }
1254: }
1255: else throw new ArgumentOutOfRangeException(@"Condition not met: (!ponGroup.UsesProposedList || ponGroup.UsedPonInPonGroupList.Count == ponGroup.UsedProposedPonInPonGroupList.Count)");
1256: }
1257: }
1258: else throw new ArgumentOutOfRangeException(@"Condition not met: ((oltPonCount == oltProposedPonCount) || oltProposedPonCount == 0) && oltPonCount % 32 == 0");
1259: }
1260:
1261: return ponList;
1262: }
1263: }
1264:
1265: ////////////////////////////////////////////////////////////////////////////
1266:
1267: /// <summary>
1268: ///
1269: /// </summary>
1270: public static Dictionary<string, string> PonNameToPonIdDictionary
1271: {
1272: get
1273: {
1274: if (ponNameToPonIdDictionary == null || ponNameToPonIdDictionary.Count == 0)
1275: {
1276: ponNameToPonIdDictionary = (from p in Ia.Ngn.Cl.Model.Data.NetworkDesignDocument.PonList select new { p.Name, p.Id }).ToDictionary(n => n.Name, n => n.Id);
1277: }
1278:
1279: return ponNameToPonIdDictionary;
1280: }
1281: }
1282:
1283: ////////////////////////////////////////////////////////////////////////////
1284:
1285: /// <summary>
1286: ///
1287: /// </summary>
1288: public static Dictionary<string, Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Pon> PonIdToPonDictionary
1289: {
1290: get
1291: {
1292: if (ponIdToPonDictionary == null || ponIdToPonDictionary.Count == 0)
1293: {
1294: ponIdToPonDictionary = (from p in Ia.Ngn.Cl.Model.Data.NetworkDesignDocument.PonList select new { p.Id, Pon = p }).ToDictionary(n => n.Id, n => n.Pon);
1295: }
1296:
1297: return ponIdToPonDictionary;
1298: }
1299: }
1300:
1301: ////////////////////////////////////////////////////////////////////////////
1302:
1303: /// <summary>
1304: ///
1305: /// </summary>
1306: public static Dictionary<string, Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Pon> PonNameToPonDictionary
1307: {
1308: get
1309: {
1310: if (ponNameToPonDictionary == null || ponNameToPonDictionary.Count == 0)
1311: {
1312: ponNameToPonDictionary = (from p in Ia.Ngn.Cl.Model.Data.NetworkDesignDocument.PonList select new { p.Name, Pon = p }).ToDictionary(n => n.Name, n => n.Pon);
1313: }
1314:
1315: return ponNameToPonDictionary;
1316: }
1317: }
1318:
1319: ////////////////////////////////////////////////////////////////////////////
1320:
1321: /// <summary>
1322: ///
1323: /// </summary>
1324: public static Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Pon PonByOltEmsNameAndSnAndPnAndOptionallyOntId(string emsName, int sn, int pn, int ontId)
1325: {
1326: Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Pon pon;
1327:
1328: var olt = Ia.Ngn.Cl.Model.Data.NetworkDesignDocument.OltByEmsName(emsName);
1329:
1330: if (olt.EmsName == "OLT-QRN-ABW-01") // ABW is all screwed up with multiple PON grouped. I will use ontId and read PON from OntList
1331: {
1332: pon = (from o in Ia.Ngn.Cl.Model.Data.NetworkDesignDocument.OntList where o.Pon.PonGroup.Olt.Id == olt.Id && o.CardSlot == sn && o.Port == pn && o.InternalNumber == ontId select o.Pon).SingleOrDefault();
1333: }
1334: else
1335: {
1336: pon = (from p in Ia.Ngn.Cl.Model.Data.NetworkDesignDocument.PonList where p.PonGroup.Olt.Id == olt.Id && p.CardSlot == sn && p.Port == pn select p).SingleOrDefault();
1337: }
1338:
1339: return pon;
1340: }
1341:
1342: ////////////////////////////////////////////////////////////////////////////
1343: ////////////////////////////////////////////////////////////////////////////
1344:
1345: /// <summary>
1346: ///
1347: /// </summary>
1348: public static List<Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.PonGroup> PonGroupList
1349: {
1350: get
1351: {
1352: lock (objectLock)
1353: {
1354: if (ponGroupList == null || ponGroupList.Count == 0) ponGroupList = Ia.Ngn.Cl.Model.Data.NetworkDesignDocument._PonGroupList;
1355:
1356: return ponGroupList;
1357: }
1358: }
1359: }
1360:
1361: ////////////////////////////////////////////////////////////////////////////
1362:
1363: /// <summary>
1364: ///
1365: /// </summary>
1366: private static List<Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.PonGroup> _PonGroupList
1367: {
1368: get
1369: {
1370: int networkId, siteId, routerId, odfId, oltId, id;
1371: const string pattern = @"\d{1,3}\.\d{1,3}\.\d{1,3}\.0";
1372: Regex regex;
1373: Hashtable idHashtable, networkNumberHashtable;
1374: #if DEBUG
1375: Hashtable gatewayIpHashtable;
1376: #endif
1377: Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.PonGroup ponGroup;
1378:
1379: regex = new Regex(pattern);
1380: ponGroupList = new List<Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.PonGroup>(16); // 16 is max number of ponGroup in ONT
1381: idHashtable = new Hashtable();
1382: networkNumberHashtable = new Hashtable();
1383: #if DEBUG
1384: gatewayIpHashtable = new Hashtable();
1385: #endif
1386:
1387: foreach (XElement x in XDocument.Element("networkDesignDocument").Elements("network").Elements("site").Elements("router").Elements("odf").Elements("olt").Elements("ponGroup"))
1388: {
1389: ponGroup = new Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.PonGroup
1390: {
1391: Olt = new Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Olt()
1392: };
1393: ponGroup.Olt.Odf = new Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Odf();
1394: ponGroup.Olt.Odf.Router = new Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Router();
1395: ponGroup.Olt.Odf.Router.Site = new Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Site();
1396:
1397: networkId = int.Parse(x.Parent.Parent.Parent.Parent.Parent.Attribute("id").Value);
1398: siteId = int.Parse(x.Parent.Parent.Parent.Parent.Attribute("id").Value);
1399: routerId = int.Parse(x.Parent.Parent.Parent.Attribute("id").Value);
1400: odfId = int.Parse(x.Parent.Parent.Attribute("id").Value);
1401: oltId = int.Parse(x.Parent.Attribute("id").Value);
1402: id = int.Parse(x.Attribute("id").Value);
1403:
1404: siteId = ponGroup.Olt.Odf.Router.Site.SiteId(networkId, siteId);
1405: routerId = ponGroup.Olt.Odf.Router.RouterId(siteId, routerId);
1406: odfId = ponGroup.Olt.Odf.OdfId(routerId, odfId);
1407: oltId = ponGroup.Olt.OltId(odfId, oltId);
1408: ponGroup.Id = ponGroup.PonGroupId(oltId, id);
1409:
1410: ponGroup.Number = id;
1411:
1412: ponGroup.Olt = (from o in OltList where o.Id == oltId select o).SingleOrDefault();
1413:
1414: if (x.Attribute("symbol") != null) ponGroup.Symbol = x.Attribute("symbol").Value;
1415: else ponGroup.Symbol = ponGroup.Olt.Symbol;
1416:
1417: ponGroup.NetworkNumber = x.Attribute("networkNumber").Value;
1418: // Network number must be unique and must end with *.*.*.0
1419: if (networkNumberHashtable.ContainsKey(ponGroup.NetworkNumber)) throw new ArgumentException(@"Lt.NetworkNumber is not unique for LT under OLT name=" + ponGroup.Olt.Name + ". ");
1420: else if (!regex.IsMatch(ponGroup.NetworkNumber)) throw new ArgumentException(@"Lt.NetworkNumber is not if format *.*.*.0 OLT name=" + ponGroup.Olt.Name + ". ");
1421: else networkNumberHashtable[ponGroup.NetworkNumber] = 1;
1422:
1423:
1424: ponGroup.PonListString = x.Attribute("list").Value;
1425: // below: pass ponList and change "*" to "0"
1426: ponGroup.UsedPonInPonGroupList = Ia.Cl.Model.Default.ConvertHyphenAndCommaSeperatedNumberStringToNumberList(ponGroup.PonListString.Replace("*", "0"));
1427:
1428: if (x.Attribute("proposedList") != null && x.Attribute("proposedList").Value.Length > 0)
1429: {
1430: ponGroup.ProposedPonListString = x.Attribute("proposedList").Value;
1431:
1432: // below: pass ponList and change "*" to "0"
1433: ponGroup.UsedProposedPonInPonGroupList = Ia.Cl.Model.Default.ConvertHyphenAndCommaSeperatedNumberStringToNumberList(ponGroup.ProposedPonListString.Replace("*", "0"));
1434: }
1435: else
1436: {
1437: ponGroup.ProposedPonListString = string.Empty;
1438: ponGroup.UsedProposedPonInPonGroupList = new List<int>();
1439: }
1440:
1441: if (x.Attribute("gatewayIp") != null) ponGroup.GatewayIp = x.Attribute("gatewayIp").Value;
1442: else if (x.Parent.Attribute("gatewayIp") != null) ponGroup.GatewayIp = x.Parent.Attribute("gatewayIp").Value;
1443: else if (x.Parent.Parent.Attribute("gatewayIp") != null) ponGroup.GatewayIp = x.Parent.Parent.Attribute("gatewayIp").Value;
1444: else throw new ArgumentException(@"ponGroup.GatewayIp could not be produced from XML document. ");
1445:
1446: if (x.Attribute("mgcIp") != null) ponGroup.MgcIp = x.Attribute("mgcIp").Value;
1447: else if (x.Parent.Attribute("mgcIp") != null) ponGroup.MgcIp = x.Parent.Attribute("mgcIp").Value;
1448: else if (x.Parent.Parent.Attribute("mgcIp") != null) ponGroup.MgcIp = x.Parent.Parent.Attribute("mgcIp").Value;
1449: else if (ponGroup.Olt.Name != "SAA-1" && (ponGroup.Olt.Name != "SDQ-1")) throw new ArgumentException(@"ponGroup.MgcIp could not be produced from XML document. ");
1450: // note that MgcIp need some special handling on the PON.ONT level
1451:
1452: #if DEBUG
1453: // GatewayIp number must be unique
1454: /*if (gatewayIpHashtable.ContainsKey(ponGroup.GatewayIp)) throw new ArgumentException(@"Lt.GatewayIp is not unique for LT under OLT name=" + ponGroup.Olt.Name + ". ");
1455: else*/
1456: gatewayIpHashtable[ponGroup.GatewayIp] = 1;
1457:
1458: // Id
1459: if (idHashtable.ContainsKey(ponGroup.Id)) throw new ArgumentException(@"ponGroup.Id is not unique for LT under OLT name=" + ponGroup.Olt.Name + ". ");
1460: else idHashtable[ponGroup.Id] = 1;
1461: #endif
1462: ponGroupList.Add(ponGroup);
1463: }
1464:
1465: return ponGroupList;
1466: }
1467: }
1468:
1469: ////////////////////////////////////////////////////////////////////////////
1470:
1471: /// <summary>
1472: ///
1473: /// </summary>
1474: public static List<Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Olt> OltList
1475: {
1476: get
1477: {
1478: lock (objectLock)
1479: {
1480: if (oltList == null || oltList.Count == 0) oltList = Ia.Ngn.Cl.Model.Data.NetworkDesignDocument._OltList;
1481:
1482: return oltList;
1483: }
1484: }
1485: }
1486:
1487: ////////////////////////////////////////////////////////////////////////////
1488:
1489: /// <summary>
1490: ///
1491: /// </summary>
1492: private static List<Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Olt> _OltList
1493: {
1494: get
1495: {
1496: int networkId, siteId, routerId, odfId, id;
1497: string fieldTypeString;
1498: Hashtable networkNumberHashtable;
1499: Ia.Ngn.Cl.Model.Data.NetworkDesignDocument.BellcoreState state;
1500: Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Olt olt;
1501:
1502: oltList = new List<Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Olt>(100);
1503: networkNumberHashtable = new Hashtable();
1504:
1505: foreach (XElement x in XDocument.Element("networkDesignDocument").Elements("network").Elements("site").Elements("router").Elements("odf").Elements("olt"))
1506: {
1507: olt = new Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Olt();
1508: olt.Odf = new Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Odf();
1509: olt.Odf.Router = new Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Router();
1510: olt.Odf.Router.Site = new Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Site();
1511:
1512: networkId = int.Parse(x.Parent.Parent.Parent.Parent.Attribute("id").Value);
1513: siteId = int.Parse(x.Parent.Parent.Parent.Attribute("id").Value);
1514: routerId = int.Parse(x.Parent.Parent.Attribute("id").Value);
1515: odfId = int.Parse(x.Parent.Attribute("id").Value);
1516: id = int.Parse(x.Attribute("id").Value);
1517:
1518: siteId = olt.Odf.Router.Site.SiteId(networkId, siteId);
1519: routerId = olt.Odf.Router.RouterId(siteId, routerId);
1520: odfId = olt.Odf.OdfId(routerId, odfId);
1521: olt.Id = olt.OltId(odfId, id);
1522:
1523: olt.Odf = (from o in OdfList where o.Id == odfId select o).SingleOrDefault();
1524:
1525: olt.Name = x.Attribute("name").Value;
1526: olt.AmsName = x.Attribute("amsName").Value;
1527:
1528: if (x.Attribute("did") != null) olt.Did = int.Parse(x.Attribute("did").Value);
1529:
1530: olt.Type = x.Attribute("type").Value;
1531:
1532: if (x.Attribute("state") != null)
1533: {
1534: switch (x.Attribute("state").Value)
1535: {
1536: case "is-nr": state = Ia.Ngn.Cl.Model.Data.NetworkDesignDocument.BellcoreState.IsNr; break;
1537: case "oos-au": state = Ia.Ngn.Cl.Model.Data.NetworkDesignDocument.BellcoreState.OosAu; break;
1538: case "oos-ma": state = Ia.Ngn.Cl.Model.Data.NetworkDesignDocument.BellcoreState.OosMa; break;
1539: case "oos-auma": state = Ia.Ngn.Cl.Model.Data.NetworkDesignDocument.BellcoreState.OosAuma; break;
1540: default: state = Ia.Ngn.Cl.Model.Data.NetworkDesignDocument.BellcoreState.Undefined; break;
1541: }
1542: }
1543: else state = Ia.Ngn.Cl.Model.Data.NetworkDesignDocument.BellcoreState.Undefined;
1544:
1545: olt.StateId = (int)state;
1546:
1547: olt.IsSip = x.Attribute("isSip").Value == "true";
1548:
1549: if (olt.Odf.Vendor == Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Vendor.Nokia)
1550: {
1551: olt.Rack = 1;
1552: olt.Sub = 1;
1553: }
1554: else //if (olt.Odf.Vendor == Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Vendor.Huawei)
1555: {
1556: olt.Rack = 0;
1557: olt.Sub = 0;
1558: }
1559:
1560: if (x.Attribute("gatewayIp") != null) olt.GatewayIp = x.Attribute("gatewayIp").Value;
1561: else if (x.Parent.Attribute("gatewayIp") != null) olt.GatewayIp = x.Parent.Attribute("gatewayIp").Value;
1562: else olt.GatewayIp = string.Empty;
1563:
1564: if (x.Attribute("mgcIp") != null) olt.MgcIp = x.Attribute("mgcIp").Value;
1565: else if (x.Parent.Attribute("mgcIp") != null) olt.MgcIp = x.Parent.Attribute("mgcIp").Value;
1566: else olt.MgcIp = string.Empty;
1567:
1568: fieldTypeString = x.Attribute("fieldType").Value;
1569:
1570: if (!string.IsNullOrEmpty(fieldTypeString))
1571: {
1572: if (fieldTypeString == "green") olt.FieldType = Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.FieldType.Green;
1573: else if (fieldTypeString == "brown") olt.FieldType = Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.FieldType.Brown;
1574: else throw new ArgumentException(@"OLT field type unrecognized. ");
1575: }
1576: else throw new ArgumentException(@"OLT field type invalid. ");
1577:
1578: olt.Symbol = x.Attribute("symbol").Value;
1579:
1580: // below: the number of possible PONs differs between Nokia OLT types and Huawei
1581: if (olt.Odf.Vendor == Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Vendor.Nokia)
1582: {
1583: olt.NumberOfPonsPerLt = 16;
1584: olt.NumberOfOntsInPon = 32;
1585: olt.NumberOfFirstSlot = 1;
1586:
1587: if (olt.Type == "7342")
1588: {
1589: olt.NumberOfLts = 2;
1590: }
1591: else if (olt.Type == "7360")
1592: {
1593: olt.NumberOfLts = 16;
1594: }
1595: else
1596: {
1597: throw new ArgumentException(@"Nokia olt.Type unrecognized. ");
1598: }
1599: }
1600: else if (olt.Odf.Vendor == Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Vendor.Huawei)
1601: {
1602: olt.NumberOfLts = 2;
1603:
1604: if (olt.Type == "MA5600T")
1605: {
1606: olt.NumberOfPonsPerLt = 128;
1607: olt.NumberOfOntsInPon = 32;
1608: olt.NumberOfFirstSlot = 1;
1609: }
1610: else if (olt.Type == "MA5600T-temp")
1611: {
1612: olt.NumberOfPonsPerLt = 128 * 8;
1613: olt.NumberOfOntsInPon = 4;
1614: olt.NumberOfFirstSlot = 1;
1615: }
1616: else if (olt.Type == "MA5603T")
1617: {
1618: olt.NumberOfPonsPerLt = 128;
1619: olt.NumberOfOntsInPon = 32;
1620: olt.NumberOfFirstSlot = 0;
1621: }
1622: else
1623: {
1624: throw new ArgumentException(@"Huawei olt.Type unrecognized. ");
1625: }
1626: }
1627: else
1628: {
1629: throw new ArgumentException(@"olt.Odf.Vendor unrecognized. ");
1630: }
1631:
1632: olt.NumberOfPons = olt.NumberOfLts * olt.NumberOfPonsPerLt;
1633: #if DEBUG
1634: if ((olt.NumberOfPons * olt.NumberOfOntsInPon % 1024) != 0) throw new ArgumentException(@"(olt.NumberOfPons * olt.NumberOfOntsInPon % 1024) != 0");
1635: if (olt.NumberOfFirstSlot != 0 && olt.NumberOfFirstSlot != 1) throw new ArgumentException(@"olt.NumberOfFirstSlot == 0 || olt.NumberOfFirstSlot == 1");
1636: #endif
1637: oltList.Add(olt);
1638: }
1639:
1640: return oltList;
1641: }
1642: }
1643:
1644: ////////////////////////////////////////////////////////////////////////////
1645: ////////////////////////////////////////////////////////////////////////////
1646:
1647: /// <summary>
1648: ///
1649: /// </summary>
1650: public static List<Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Olt> NokiaOltList
1651: {
1652: get
1653: {
1654: return VendorOltList(Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Vendor.Nokia, 0);
1655: }
1656: }
1657:
1658: ////////////////////////////////////////////////////////////////////////////
1659:
1660: /// <summary>
1661: ///
1662: /// </summary>
1663: public static List<Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Olt> HuaweiOltList
1664: {
1665: get
1666: {
1667: return VendorOltList(Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Vendor.Huawei, 0);
1668: }
1669: }
1670:
1671: /*
1672: ////////////////////////////////////////////////////////////////////////////
1673:
1674: /// <summary>
1675: ///
1676: /// </summary>
1677: public static List<Ia.Ngn.Cl.Model.Data.NewNetworkDesignDocument.Olt> NokiaOltList(int siteId)
1678: {
1679: return VendorOltList("No", siteId);
1680: }
1681:
1682: ////////////////////////////////////////////////////////////////////////////
1683:
1684: /// <summary>
1685: ///
1686: /// </summary>
1687: public static List<Ia.Ngn.Cl.Model.Data.NewNetworkDesignDocument.Olt> HuaweiOltList(int siteId)
1688: {
1689: return VendorOltList("Hu", siteId);
1690: }
1691: */
1692:
1693: ////////////////////////////////////////////////////////////////////////////
1694:
1695: /// <summary>
1696: ///
1697: /// </summary>
1698: public static List<Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Olt> VendorOltList(Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Vendor vendor, int siteId)
1699: {
1700: List<Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Olt> list;
1701:
1702: list = (from o in Ia.Ngn.Cl.Model.Data.NetworkDesignDocument.OltList
1703: where o.Odf.Vendor == vendor && (o.Odf.Router.Site.Id == siteId || siteId == 0)
1704: select o).ToList();
1705:
1706: return list;
1707: }
1708:
1709: /*
1710: ////////////////////////////////////////////////////////////////////////////
1711:
1712: /// <summary>
1713: ///
1714: /// </summary>
1715: public static List<Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Olt> HuaweiOltTempList
1716: {
1717: get
1718: {
1719: List<Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Olt> list;
1720:
1721: list = (from o in Ia.Ngn.Cl.Model.Data.NetworkDesignDocument.OltList
1722: where o.Odf.Vendor == Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Vendor.Huawei && Ia.Ngn.Cl.Model.Data.Huawei.Ont.OltDidToEmsName.ContainsValue(o.AmsName) && o.Symbol == "SAA" || o.Symbol == "SDQ" || o.Symbol == "ADN" || o.Symbol == "QSR" || o.Symbol == "ABW" || o.Symbol == "JBA" || o.Symbol == "ADS"
1723: select o).ToList();
1724:
1725: return list;
1726: }
1727: }
1728: */
1729:
1730: ////////////////////////////////////////////////////////////////////////////
1731:
1732: /// <summary>
1733: ///
1734: /// </summary>
1735: public static List<int> NokiaOltIdList()
1736: {
1737: return OltIdByVendorAndSiteIdList("No", 0);
1738: }
1739:
1740: ////////////////////////////////////////////////////////////////////////////
1741:
1742: /// <summary>
1743: ///
1744: /// </summary>
1745: public static List<int> NokiaOltIdList(int siteId)
1746: {
1747: return OltIdByVendorAndSiteIdList("No", siteId);
1748: }
1749:
1750: ////////////////////////////////////////////////////////////////////////////
1751:
1752: /// <summary>
1753: ///
1754: /// </summary>
1755: public static List<int> HuaweiOltIdList()
1756: {
1757: return OltIdByVendorAndSiteIdList("Hu", 0);
1758: }
1759:
1760: /*
1761: ////////////////////////////////////////////////////////////////////////////
1762:
1763: /// <summary>
1764: ///
1765: /// </summary>
1766: public static List<int> HuaweiOltIdTempList()
1767: {
1768: List<int> list;
1769:
1770: list = (from o in HuaweiOltTempList select o.Id).ToList();
1771:
1772: return list;
1773: }
1774: */
1775:
1776: ////////////////////////////////////////////////////////////////////////////
1777:
1778: /// <summary>
1779: ///
1780: /// </summary>
1781: public static List<int> HuaweiOltIdList(int siteId)
1782: {
1783: return OltIdByVendorAndSiteIdList("Hu", siteId);
1784: }
1785:
1786: ////////////////////////////////////////////////////////////////////////////
1787:
1788: /// <summary>
1789: ///
1790: /// </summary>
1791: public static List<int> OltIdByVendorAndSiteIdList(string vendorShortName, int siteId)
1792: {
1793: List<int> list;
1794:
1795: list = new List<int>();
1796:
1797: foreach (var olt in Ia.Ngn.Cl.Model.Data.NetworkDesignDocument.OltList)
1798: {
1799: // siteId 0 will return all sites
1800:
1801: if (olt.Odf.Vendor.ShortName == vendorShortName && (olt.Odf.Router.Site.Id == siteId || siteId == 0))
1802: {
1803: list.Add(olt.Id);
1804: }
1805: }
1806:
1807: return list;
1808: }
1809:
1810: ////////////////////////////////////////////////////////////////////////////
1811:
1812: /// <summary>
1813: ///
1814: /// </summary>
1815: public static List<int> OltIdList
1816: {
1817: get
1818: {
1819: List<int> list;
1820:
1821: list = (from o in Ia.Ngn.Cl.Model.Data.NetworkDesignDocument.OltList select o.Id).ToList();
1822:
1823: return list;
1824: }
1825: }
1826:
1827: ////////////////////////////////////////////////////////////////////////////
1828:
1829: /// <summary>
1830: ///
1831: /// </summary>
1832: public static List<int> HuaweiSwitchNokiaGponOltIdList
1833: {
1834: get
1835: {
1836: List<int> list;
1837:
1838: list = (from o in Ia.Ngn.Cl.Model.Data.NetworkDesignDocument.OltList
1839: where o.Odf.Router.Vendor == Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Vendor.Huawei
1840: && o.Odf.Vendor == Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Vendor.Nokia
1841: select o.Id).ToList();
1842:
1843: return list;
1844: }
1845: }
1846:
1847: ////////////////////////////////////////////////////////////////////////////
1848:
1849: /// <summary>
1850: ///
1851: /// </summary>
1852: public static Hashtable OltAmsNameToIdList
1853: {
1854: get
1855: {
1856: Hashtable ht;
1857:
1858: ht = new Hashtable(Ia.Ngn.Cl.Model.Data.NetworkDesignDocument.OltList.Count);
1859:
1860: foreach (Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Olt olt in Ia.Ngn.Cl.Model.Data.NetworkDesignDocument.OltList)
1861: {
1862: ht[olt.AmsName] = olt.Id;
1863: }
1864:
1865: return ht;
1866: }
1867: }
1868:
1869: ////////////////////////////////////////////////////////////////////////////
1870:
1871: /// <summary>
1872: ///
1873: /// </summary>
1874: public static Hashtable FirstPonNameInOltToOltIdList
1875: {
1876: get
1877: {
1878: Hashtable ht;
1879:
1880: ht = new Hashtable(Ia.Ngn.Cl.Model.Data.NetworkDesignDocument.OltList.Count);
1881:
1882: foreach (Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Olt olt in Ia.Ngn.Cl.Model.Data.NetworkDesignDocument.OltList)
1883: {
1884: foreach (Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.PonGroup ponGroup in olt.PonGroupList)
1885: {
1886: ht[ponGroup.PonList.First().Name] = olt.Id;
1887: }
1888: }
1889:
1890: return ht;
1891: }
1892: }
1893:
1894: ////////////////////////////////////////////////////////////////////////////
1895:
1896: /// <summary>
1897: ///
1898: /// </summary>
1899: public static Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Olt OltByEmsName(string emsName)
1900: {
1901: Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Olt olt;
1902:
1903: olt = (from o in Ia.Ngn.Cl.Model.Data.NetworkDesignDocument.OltList where o.EmsName == emsName select o).SingleOrDefault();
1904:
1905: return olt;
1906: }
1907:
1908: ////////////////////////////////////////////////////////////////////////////
1909:
1910: /// <summary>
1911: ///
1912: /// </summary>
1913: public static Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Olt OltByDid(int did)
1914: {
1915: Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Olt olt;
1916:
1917: olt = (from o in Ia.Ngn.Cl.Model.Data.NetworkDesignDocument.OltList where o.Did == did select o).SingleOrDefault();
1918:
1919: return olt;
1920: }
1921:
1922: /*
1923: ////////////////////////////////////////////////////////////////////////////
1924:
1925: /// <summary>
1926: ///
1927: /// </summary>
1928: public static Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Olt OltByDid(int did)
1929: {
1930: string emsName;
1931: Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Olt item;
1932:
1933: if (Ia.Ngn.Cl.Model.Data.Huawei.Ont.OltDidToEmsName.ContainsKey(did))
1934: {
1935: emsName = Ia.Ngn.Cl.Model.Data.Huawei.Ont.OltDidToEmsName[did];
1936:
1937: item = (from o in Ia.Ngn.Cl.Model.Data.NetworkDesignDocument.OltList where o.EmsName == emsName select o).SingleOrDefault();
1938: }
1939: else item = null;
1940:
1941: return item;
1942: }
1943: */
1944:
1945: /*
1946: ////////////////////////////////////////////////////////////////////////////
1947:
1948: /// <summary>
1949: ///
1950: /// </summary>
1951: public static int DidByOlt(Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Olt olt)
1952: {
1953: int did;
1954: string emsName;
1955:
1956: emsName = olt.EmsName;
1957:
1958: if (Ia.Ngn.Cl.Model.Data.Huawei.Ont.OltDidToEmsName.ContainsValue(emsName))
1959: {
1960: did = (from odem in Ia.Ngn.Cl.Model.Data.Huawei.Ont.OltDidToEmsName where odem.Value == emsName select odem.Key).SingleOrDefault();
1961: }
1962: else did = 0;
1963:
1964: return did;
1965: }
1966: */
1967:
1968: ////////////////////////////////////////////////////////////////////////////
1969: ////////////////////////////////////////////////////////////////////////////
1970:
1971: /// <summary>
1972: ///
1973: /// </summary>
1974: public static List<int> SipOltIdList
1975: {
1976: get
1977: {
1978: return (from o in Ia.Ngn.Cl.Model.Data.NetworkDesignDocument.OltList
1979: where o.IsSip == true
1980: select o.Id).ToList();
1981: }
1982: }
1983:
1984: ////////////////////////////////////////////////////////////////////////////
1985: ////////////////////////////////////////////////////////////////////////////
1986:
1987: /// <summary>
1988: ///
1989: /// </summary>
1990: public static List<int> GreenFieldOltIdList
1991: {
1992: get
1993: {
1994: return (from o in Ia.Ngn.Cl.Model.Data.NetworkDesignDocument.OltList
1995: where o.FieldType == Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.FieldType.Green
1996: select o.Id).ToList();
1997: }
1998: }
1999:
2000: ////////////////////////////////////////////////////////////////////////////
2001:
2002: /// <summary>
2003: ///
2004: /// </summary>
2005: public static List<Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Olt> GreenFieldOltList
2006: {
2007: get
2008: {
2009: return (from o in Ia.Ngn.Cl.Model.Data.NetworkDesignDocument.OltList
2010: where o.FieldType == Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.FieldType.Green
2011: select o).ToList();
2012: }
2013: }
2014:
2015: ////////////////////////////////////////////////////////////////////////////
2016:
2017: /// <summary>
2018: ///
2019: /// </summary>
2020: public static List<int> GreenFieldSipOltIdList
2021: {
2022: get
2023: {
2024: return (from o in Ia.Ngn.Cl.Model.Data.NetworkDesignDocument.OltList
2025: where o.IsSip == true && o.FieldType == Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.FieldType.Green
2026: select o.Id).ToList();
2027: }
2028: }
2029:
2030: ////////////////////////////////////////////////////////////////////////////
2031:
2032: /// <summary>
2033: ///
2034: /// </summary>
2035: public static List<Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Olt> GreenFieldSipOltList
2036: {
2037: get
2038: {
2039: return (from o in Ia.Ngn.Cl.Model.Data.NetworkDesignDocument.OltList
2040: where o.IsSip == true && o.FieldType == Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.FieldType.Green
2041: select o).ToList();
2042: }
2043: }
2044:
2045: ////////////////////////////////////////////////////////////////////////////
2046:
2047: /// <summary>
2048: ///
2049: /// </summary>
2050: public static List<Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Ont> GreenFieldOntList
2051: {
2052: get
2053: {
2054: return (from o in Ia.Ngn.Cl.Model.Data.NetworkDesignDocument.OntList
2055: where o.Pon.PonGroup.Olt.FieldType == Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.FieldType.Green
2056: select o).ToList();
2057: }
2058: }
2059:
2060: ////////////////////////////////////////////////////////////////////////////
2061: ////////////////////////////////////////////////////////////////////////////
2062:
2063: /// <summary>
2064: ///
2065: /// </summary>
2066: public static List<int> BrownFieldOltIdList
2067: {
2068: get
2069: {
2070: return (from o in Ia.Ngn.Cl.Model.Data.NetworkDesignDocument.OltList
2071: where o.FieldType == Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.FieldType.Brown
2072: select o.Id).ToList();
2073: }
2074: }
2075:
2076: ////////////////////////////////////////////////////////////////////////////
2077:
2078: /// <summary>
2079: ///
2080: /// </summary>
2081: public static List<Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Olt> BrownFieldOltList
2082: {
2083: get
2084: {
2085: return (from o in Ia.Ngn.Cl.Model.Data.NetworkDesignDocument.OltList
2086: where o.FieldType == Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.FieldType.Brown
2087: select o).ToList();
2088: }
2089: }
2090:
2091: ////////////////////////////////////////////////////////////////////////////
2092:
2093: /// <summary>
2094: ///
2095: /// </summary>
2096: public static List<int> BrownFieldSipOltIdList
2097: {
2098: get
2099: {
2100: return (from o in Ia.Ngn.Cl.Model.Data.NetworkDesignDocument.OltList
2101: where o.IsSip == true && o.FieldType == Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.FieldType.Brown
2102: select o.Id).ToList();
2103: }
2104: }
2105:
2106: ////////////////////////////////////////////////////////////////////////////
2107:
2108: /// <summary>
2109: ///
2110: /// </summary>
2111: public static List<Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Olt> BrownFieldSipOltList
2112: {
2113: get
2114: {
2115: return (from o in Ia.Ngn.Cl.Model.Data.NetworkDesignDocument.OltList
2116: where o.IsSip == true && o.FieldType == Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.FieldType.Brown
2117: select o).ToList();
2118: }
2119: }
2120:
2121: ////////////////////////////////////////////////////////////////////////////
2122:
2123: /// <summary>
2124: ///
2125: /// </summary>
2126: public static List<Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Ont> BrownFieldOntList
2127: {
2128: get
2129: {
2130: return (from o in Ia.Ngn.Cl.Model.Data.NetworkDesignDocument.OntList
2131: where o.Pon.PonGroup.Olt.FieldType == Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.FieldType.Brown
2132: select o).ToList();
2133: }
2134: }
2135:
2136: ////////////////////////////////////////////////////////////////////////////
2137: ////////////////////////////////////////////////////////////////////////////
2138:
2139: /// <summary>
2140: ///
2141: /// </summary>
2142: public static List<string> IsNrNokiaOltAmsNameList
2143: {
2144: get
2145: {
2146: List<string> list;
2147:
2148: list = (from o in Ia.Ngn.Cl.Model.Data.NetworkDesignDocument.OltList
2149: where o.Odf.Vendor == Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Vendor.Nokia
2150: && o.StateId == (int)Ia.Ngn.Cl.Model.Data.NetworkDesignDocument.BellcoreState.IsNr
2151: select o.AmsName).ToList();
2152:
2153: return list;
2154: }
2155: }
2156:
2157: ////////////////////////////////////////////////////////////////////////////
2158:
2159: /// <summary>
2160: ///
2161: /// </summary>
2162: public static List<string> IsNrHuaweiOltAmsNameList
2163: {
2164: get
2165: {
2166: List<string> list;
2167:
2168: list = (from o in Ia.Ngn.Cl.Model.Data.NetworkDesignDocument.OltList
2169: where o.Odf.Vendor == Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Vendor.Huawei
2170: && o.StateId == (int)Ia.Ngn.Cl.Model.Data.NetworkDesignDocument.BellcoreState.IsNr
2171: select o.AmsName).ToList();
2172:
2173: return list;
2174: }
2175: }
2176:
2177: ////////////////////////////////////////////////////////////////////////////
2178:
2179: /// <summary>
2180: ///
2181: /// </summary>
2182: public static List<Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Odf> OdfList
2183: {
2184: get
2185: {
2186: lock (objectLock)
2187: {
2188: if (odfList == null || odfList.Count == 0) odfList = Ia.Ngn.Cl.Model.Data.NetworkDesignDocument._OdfList;
2189:
2190: return odfList;
2191: }
2192: }
2193: }
2194:
2195: ////////////////////////////////////////////////////////////////////////////
2196:
2197: /// <summary>
2198: ///
2199: /// </summary>
2200: private static List<Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Odf> _OdfList
2201: {
2202: get
2203: {
2204: int networkId, siteId, routerId, id;
2205: string vendorShortName;
2206: Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Odf odf;
2207:
2208: odfList = new List<Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Odf>();
2209:
2210: foreach (XElement x in XDocument.Element("networkDesignDocument").Element("network").Elements("site").Elements("router").Elements("odf"))
2211: {
2212: odf = new Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Odf();
2213: odf.Router = new Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Router();
2214: odf.Router.Site = new Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Site();
2215:
2216: networkId = int.Parse(x.Parent.Parent.Parent.Attribute("id").Value);
2217: siteId = int.Parse(x.Parent.Parent.Attribute("id").Value);
2218: routerId = int.Parse(x.Parent.Attribute("id").Value);
2219: id = int.Parse(x.Attribute("id").Value);
2220:
2221: siteId = odf.Router.Site.SiteId(networkId, siteId);
2222: routerId = odf.Router.RouterId(siteId, routerId);
2223: odf.Id = odf.OdfId(routerId, id);
2224:
2225: odf.Name = x.Attribute("name").Value;
2226:
2227: odf.GatewayIp = (x.Attribute("gatewayIp") != null) ? x.Attribute("gatewayIp").Value : string.Empty;
2228: odf.MgcIp = (x.Attribute("mgcIp") != null) ? x.Attribute("mgcIp").Value : string.Empty;
2229:
2230: vendorShortName = x.Attribute("vendorShortName").Value;
2231: odf.Vendor = (from v in Ia.Ngn.Cl.Model.Data.NetworkDesignDocument.VendorList where v.ShortName == vendorShortName select v).SingleOrDefault();
2232:
2233: odf.Router = (from r in RouterList where r.Id == routerId select r).SingleOrDefault();
2234:
2235: odfList.Add(odf);
2236: }
2237:
2238: return odfList.ToList();
2239: }
2240: }
2241:
2242: ////////////////////////////////////////////////////////////////////////////
2243:
2244: /// <summary>
2245: ///
2246: /// </summary>
2247: public static List<Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Oam> OamList
2248: {
2249: get
2250: {
2251: lock (objectLock)
2252: {
2253: if (oamList == null || oamList.Count == 0) oamList = Ia.Ngn.Cl.Model.Data.NetworkDesignDocument._OamList;
2254:
2255: return oamList;
2256: }
2257: }
2258: }
2259:
2260: ////////////////////////////////////////////////////////////////////////////
2261:
2262: /// <summary>
2263: ///
2264: /// </summary>
2265: private static List<Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Oam> _OamList
2266: {
2267: get
2268: {
2269: int networkId, siteId, routerId, id;
2270: Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Oam oam;
2271:
2272: oamList = new List<Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Oam>();
2273:
2274: foreach (XElement x in XDocument.Element("networkDesignDocument").Element("network").Elements("site").Elements("router").Elements("oam"))
2275: {
2276: oam = new Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Oam();
2277: oam.Router = new Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Router();
2278: oam.Router.Site = new Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Site();
2279:
2280: networkId = int.Parse(x.Parent.Parent.Parent.Attribute("id").Value);
2281: siteId = int.Parse(x.Parent.Parent.Attribute("id").Value);
2282: routerId = int.Parse(x.Parent.Attribute("id").Value);
2283: id = int.Parse(x.Attribute("id").Value);
2284:
2285: siteId = oam.Router.Site.SiteId(networkId, siteId);
2286: routerId = oam.Router.RouterId(siteId, routerId);
2287: oam.Id = oam.OamId(routerId, id);
2288:
2289: oam.Network = x.Attribute("network").Value;
2290: oam.Gateway = x.Attribute("gateway").Value;
2291: oam.Vlan = int.Parse(x.Attribute("vlan").Value);
2292: oam.Vpls = int.Parse(x.Attribute("vpls").Value);
2293: oam.FtpIp = x.Attribute("ftpIp").Value;
2294: oam.ConfigFile = x.Attribute("configFile").Value;
2295:
2296: oam.Router = (from r in RouterList where r.Id == routerId select r).SingleOrDefault();
2297:
2298: oamList.Add(oam);
2299: }
2300:
2301: return oamList;
2302: }
2303: }
2304:
2305: ////////////////////////////////////////////////////////////////////////////
2306:
2307: /// <summary>
2308: /// Return router (switch) vendor from service number
2309: /// </summary>
2310: public static Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Vendor SwitchVendorFromService(string service)
2311: {
2312: Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Vendor switchVendor;
2313:
2314: if (int.TryParse(service, out int i))
2315: {
2316: switchVendor = (from r in Ia.Ngn.Cl.Model.Data.NetworkDesignDocument.RouterList where r.DomainList.Any(u => service.StartsWith(u.ToString())) select r.Vendor).FirstOrDefault(); //.SingleOrDefault();
2317:
2318: if (switchVendor == null) switchVendor = Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Vendor.Undefined;
2319: }
2320: else switchVendor = Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Vendor.Undefined;
2321:
2322: return switchVendor;
2323: }
2324:
2325: ////////////////////////////////////////////////////////////////////////////
2326:
2327: /// <summary>
2328: /// Return PSTN from service number
2329: /// </summary>
2330: public static Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Pstn PstnFromService(int number)
2331: {
2332: return PstnFromService(number.ToString());
2333: }
2334:
2335: ////////////////////////////////////////////////////////////////////////////
2336:
2337: /// <summary>
2338: /// Return PSTN from service number
2339: /// </summary>
2340: public static Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Pstn PstnFromService(string service)
2341: {
2342: Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Pstn pstn;
2343:
2344: if (int.TryParse(service, out int i))
2345: {
2346: pstn = (from p in Ia.Ngn.Cl.Model.Data.NetworkDesignDocument.PstnList
2347: where p.DomainList.Any(u => service.StartsWith(u.ToString()))
2348: select p).SingleOrDefault();
2349: }
2350: else pstn = null;
2351:
2352: return pstn;
2353: }
2354:
2355: ////////////////////////////////////////////////////////////////////////////
2356:
2357: /// <summary>
2358: ///
2359: /// </summary>
2360: public static List<Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Pstn> PstnList
2361: {
2362: get
2363: {
2364: lock (objectLock)
2365: {
2366: if (pstnList == null || pstnList.Count == 0) pstnList = Ia.Ngn.Cl.Model.Data.NetworkDesignDocument._PstnList;
2367:
2368: return pstnList;
2369: }
2370: }
2371: }
2372:
2373: ////////////////////////////////////////////////////////////////////////////
2374:
2375: /// <summary>
2376: ///
2377: /// </summary>
2378: private static List<Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Pstn> _PstnList
2379: {
2380: get
2381: {
2382: int networkId, siteId, id;
2383: string pstnExchangeTypeString, usesLnpServerString;
2384: #if DEBUG
2385: //Dictionary<int, int> domainDictionary;
2386: #endif
2387: Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Pstn pstn;
2388:
2389: #if DEBUG
2390: //domainDictionary = new Dictionary<int, int>(100);
2391: #endif
2392: pstnList = new List<Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Pstn>();
2393:
2394: foreach (XElement x in XDocument.Element("networkDesignDocument").Element("network").Elements("site").Elements("pstn"))
2395: {
2396: pstn = new Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Pstn();
2397: pstn.Site = new Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Site();
2398:
2399: networkId = int.Parse(x.Parent.Parent.Attribute("id").Value);
2400: siteId = int.Parse(x.Parent.Attribute("id").Value);
2401: id = int.Parse(x.Attribute("id").Value);
2402:
2403: siteId = pstn.Site.SiteId(networkId, siteId);
2404: pstn.Id = pstn.PstnId(siteId, id);
2405: pstn.Name = x.Attribute("name").Value;
2406:
2407: //if (x.Attribute("ip") != null) pstn.Ip = x.Attribute("ip").Value;
2408: //else pstn.Ip = string.Empty;
2409:
2410: pstn.DomainListString = x.Attribute("domainList").Value;
2411:
2412: pstn.DomainList = Ia.Cl.Model.Default.CommaSeperatedNumberStringToNumberList(pstn.DomainListString);
2413:
2414: #if DEBUG
2415: /*
2416: foreach (int i in pstn.DomainList)
2417: {
2418: // this will throw an exception if there are similar domains in pstns
2419: if (domainDictionary.ContainsKey(i))
2420: {
2421: throw new ArgumentOutOfRangeException(@"domainDictionary.ContainsKey(" + i + ")");
2422: }
2423: else domainDictionary[i] = 1;
2424: }
2425: */
2426: #endif
2427:
2428: pstnExchangeTypeString = x.Attribute("type").Value;
2429:
2430: if (pstnExchangeTypeString == "EWSD") pstn.PstnExchangeType = Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.PstnExchangeType.SiemensEwsd;
2431: else if (pstnExchangeTypeString == "AXE") pstn.PstnExchangeType = Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.PstnExchangeType.EricssonAxe;
2432: #if DEBUG
2433: else throw new ArgumentOutOfRangeException(@"Unknown PSTN exchange type: " + pstnExchangeTypeString);
2434: #endif
2435:
2436: usesLnpServerString = x.Attribute("usesLnpServer").Value;
2437: pstn.UsesLnpServer = usesLnpServerString == "true";
2438:
2439: pstn.Site = (from s in SiteList where s.Id == siteId select s).SingleOrDefault();
2440:
2441: pstnList.Add(pstn);
2442: }
2443:
2444: return pstnList;
2445: }
2446: }
2447:
2448: ////////////////////////////////////////////////////////////////////////////
2449:
2450: /// <summary>
2451: ///
2452: /// </summary>
2453: public static List<Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Router> RouterList
2454: {
2455: get
2456: {
2457: lock (objectLock)
2458: {
2459: if (routerList == null || routerList.Count == 0) routerList = Ia.Ngn.Cl.Model.Data.NetworkDesignDocument._RouterList;
2460:
2461: return routerList;
2462: }
2463: }
2464: }
2465:
2466: ////////////////////////////////////////////////////////////////////////////
2467:
2468: /// <summary>
2469: ///
2470: /// </summary>
2471: private static List<Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Router> _RouterList
2472: {
2473: get
2474: {
2475: int networkId, siteId, id;
2476: string vendorShortName;
2477: #if DEBUG
2478: //Dictionary<int, int> domainDictionary;
2479: #endif
2480: Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Router router;
2481:
2482: #if DEBUG
2483: //domainDictionary = new Dictionary<int, int>(100);
2484: #endif
2485: routerList = new List<Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Router>();
2486:
2487: foreach (XElement x in XDocument.Element("networkDesignDocument").Element("network").Elements("site").Elements("router"))
2488: {
2489: router = new Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Router();
2490: router.Site = new Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Site();
2491:
2492: networkId = int.Parse(x.Parent.Parent.Attribute("id").Value);
2493: siteId = int.Parse(x.Parent.Attribute("id").Value);
2494: id = int.Parse(x.Attribute("id").Value);
2495:
2496: siteId = router.Site.SiteId(networkId, siteId);
2497: router.Id = router.RouterId(siteId, id);
2498: router.Name = x.Attribute("name").Value;
2499:
2500: router.DomainListString = x.Attribute("domainList").Value;
2501:
2502: router.DomainList = Ia.Cl.Model.Default.CommaSeperatedNumberStringToNumberList(router.DomainListString);
2503:
2504: #if DEBUG
2505: /*
2506: foreach (int i in router.DomainList)
2507: {
2508: // this will throw an exception if there are similar domains in routers
2509: if (domainDictionary.ContainsKey(i))
2510: {
2511: throw new ArgumentOutOfRangeException(@"domainDictionary.ContainsKey(" + i + ")");
2512: }
2513: else domainDictionary[i] = 1;
2514: }
2515: */
2516: #endif
2517:
2518: vendorShortName = x.Attribute("vendorShortName").Value;
2519: router.Vendor = (from v in Ia.Ngn.Cl.Model.Data.NetworkDesignDocument.VendorList where v.ShortName == vendorShortName select v).SingleOrDefault();
2520:
2521: router.Site = (from s in SiteList where s.Id == siteId select s).SingleOrDefault();
2522:
2523: routerList.Add(router);
2524: }
2525:
2526: return routerList;
2527: }
2528: }
2529:
2530: ////////////////////////////////////////////////////////////////////////////
2531:
2532: /// <summary>
2533: ///
2534: /// </summary>
2535: public static List<Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Site> SiteList
2536: {
2537: get
2538: {
2539: lock (objectLock)
2540: {
2541: if (siteList == null || siteList.Count == 0) siteList = Ia.Ngn.Cl.Model.Data.NetworkDesignDocument._SiteList;
2542:
2543: return siteList;
2544: }
2545: }
2546: }
2547:
2548: ////////////////////////////////////////////////////////////////////////////
2549:
2550: /// <summary>
2551: ///
2552: /// </summary>
2553: private static List<Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Site> _SiteList
2554: {
2555: get
2556: {
2557: int networkId, id;
2558: Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Site site;
2559:
2560: siteList = new List<Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Site>();
2561:
2562: foreach (XElement x in XDocument.Element("networkDesignDocument").Element("network").Elements("site"))
2563: {
2564: site = new Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Site();
2565: networkId = int.Parse(x.Parent.Attribute("id").Value);
2566: id = int.Parse(x.Attribute("id").Value);
2567:
2568: site.Id = site.SiteId(networkId, id);
2569: site.Name = x.Attribute("name").Value;
2570: site.ArabicName = x.Attribute("arabicName").Value;
2571: site.AreaSymbolList = x.Attribute("areaSymbolList").Value.Split(',').ToList();
2572:
2573: site.Network = (from n in NetworkList where n.Id == networkId select n).SingleOrDefault();
2574:
2575: siteList.Add(site);
2576: }
2577:
2578: return siteList;
2579: }
2580: }
2581:
2582: ////////////////////////////////////////////////////////////////////////////
2583:
2584: /// <summary>
2585: ///
2586: /// </summary>
2587: public static List<Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Network> NetworkList
2588: {
2589: get
2590: {
2591: lock (objectLock)
2592: {
2593: if (networkList == null || networkList.Count == 0)
2594: {
2595: networkList = new List<Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Network> { new Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Network(1, "Next Generation Network") };
2596: }
2597:
2598: return networkList;
2599: }
2600: }
2601: }
2602:
2603: ////////////////////////////////////////////////////////////////////////////
2604:
2605: /// <summary>
2606: ///
2607: /// </summary>
2608: public static List<Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Vendor> VendorList
2609: {
2610: get
2611: {
2612: lock (objectLock)
2613: {
2614: if (vendorList == null || vendorList.Count == 0)
2615: {
2616: vendorList = new List<Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Vendor>
2617: {
2618: new Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Vendor(0, "Undefined", "Un", "غير معرف", @"~\image\undefined.png"),
2619: new Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Vendor(1, "Nokia", "No", "نوكيا", @"~\image\nokia-icon.png"),
2620: new Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Vendor(2, "Huawei", "Hu", "هواوي", @"~\image\huawei-icon.png"),
2621: new Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Vendor(3, "Ericsson", "Er", "إريكسون", @"~\image\ericsson-icon.png"),
2622: new Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Vendor(4, "Siemens", "Si", "سيمينس", @"~\image\siemens-icon.png")
2623: };
2624: }
2625:
2626: return vendorList;
2627: }
2628: }
2629: }
2630:
2631: ////////////////////////////////////////////////////////////////////////////
2632:
2633: /// <summary>
2634: ///
2635: /// </summary>
2636: public static string AmsNameFromOltId(int oltId)
2637: {
2638: string amsName;
2639:
2640: try
2641: {
2642: amsName = (from o in OltList where o.Id == oltId select o.AmsName).FirstOrDefault();
2643: }
2644: catch (Exception)
2645: {
2646: amsName = null;
2647: }
2648:
2649: return amsName;
2650: }
2651:
2652: ////////////////////////////////////////////////////////////////////////////
2653:
2654: /// <summary>
2655: ///
2656: /// </summary>
2657: public static bool CheckIntegrityOfOntList()
2658: {
2659: bool isValid;
2660: string v;
2661: Dictionary<string, string> dic, a, b;
2662:
2663: dic = Ia.Ngn.Cl.Model.Data.NetworkDesignDocument.OntIdToOntAccessNameDictionary;
2664: a = new Dictionary<string, string>();
2665: b = new Dictionary<string, string>();
2666:
2667: isValid = true;
2668:
2669: foreach (string s in dic.Keys)
2670: {
2671: v = dic[s];
2672:
2673: if (!a.ContainsKey(v)) a[v] = "1";
2674: else if (a.ContainsKey(v))
2675: {
2676: if (!v.Contains("RSL"))
2677: {
2678: b[v] = "1";
2679: isValid = false;
2680: }
2681: }
2682: }
2683:
2684: return isValid;
2685: }
2686:
2687: ////////////////////////////////////////////////////////////////////////////
2688: ////////////////////////////////////////////////////////////////////////////
2689:
2690: /// <summary>
2691: ///
2692: /// How to embed and access resources by using Visual C# http://support.microsoft.com/kb/319292/en-us
2693: ///
2694: /// 1. Change the "Build Action" property of your XML file from "Content" to "Embedded Resource".
2695: /// 2. Add "using System.Reflection".
2696: /// 3. See sample below.
2697: ///
2698: /// </summary>
2699: private static XDocument XDocument
2700: {
2701: get
2702: {
2703: if (xDocument == null)
2704: {
2705: Assembly _assembly;
2706: StreamReader streamReader;
2707:
2708: _assembly = Assembly.GetExecutingAssembly();
2709: streamReader = new StreamReader(_assembly.GetManifestResourceStream("Ia.Ngn.Cl.model.data.network-design-document.xml"));
2710:
2711: try
2712: {
2713: if (streamReader.Peek() != -1) xDocument = System.Xml.Linq.XDocument.Load(streamReader);
2714: }
2715: catch (Exception)
2716: {
2717: }
2718: finally
2719: {
2720: }
2721: }
2722:
2723: return xDocument;
2724: }
2725: }
2726:
2727: /*
2728: ////////////////////////////////////////////////////////////////////////////
2729:
2730: /// <summary>
2731: ///
2732: /// </summary>
2733: public static void WriteNddPonsTable()
2734: {
2735: DataTable dataTable;
2736: Ia.Cl.Model.Result result;
2737: Ia.Cl.Model.Db.SqlServer sqlServer;
2738:
2739: sqlServer = new Ia.Cl.Model.Db.SqlServer();
2740:
2741: var _ponList = Ia.Ngn.Cl.Model.Data.NetworkDesignDocument.PonList;
2742:
2743: if (_ponList.Count > 7000)
2744: {
2745: // must seperate using{} to guarantee a clean close of connection before populating
2746: using (var db = new Ia.Ngn.Cl.Model.Ngn())
2747: {
2748: if (db.Database.EnsureCreated())
2749: {
2750: // delete all current records
2751: var all = from c in db.NddPons select c;
2752: db.NddPons.RemoveRange(all);
2753: db.SaveChanges();
2754: }
2755: }
2756:
2757: var nddPonList = new List<Ia.Ngn.Cl.Model.NetworkDesignDocument.NddPon>();
2758:
2759: using (var db = new Ia.Ngn.Cl.Model.Ngn())
2760: {
2761: foreach (var pon in _ponList)
2762: {
2763: var nddPon = new Ia.Ngn.Cl.Model.NetworkDesignDocument.NddPon
2764: {
2765: Id = pon.Id,
2766: Index = pon.Index,
2767: PonGroupPonIndex = pon.PonGroupPonIndex,
2768: Rack = pon.Rack,
2769: Sub = pon.Sub,
2770: CardSlot = pon.CardSlot,
2771: Port = pon.Port,
2772: Number = pon.Number,
2773: ProposedNumber = pon.ProposedNumber,
2774: Position = pon.Position,
2775: Name = pon.Name,
2776: ProposedName = pon.ProposedName,
2777: PonGroupId = pon.PonGroup.Id
2778: };
2779:
2780: nddPonList.Add(nddPon);
2781: }
2782:
2783: dataTable = Ia.Cl.Model.Default.GenerateDataTableFromGenericClassList<Ia.Ngn.Cl.Model.NetworkDesignDocument.NddPon>(nddPonList, "NddPons");
2784:
2785: if (dataTable != null && dataTable.Rows.Count > 0)
2786: {
2787: sqlServer.SqlBulkCopy(dataTable, out result);
2788: }
2789: }
2790: }
2791: else
2792: {
2793:
2794: }
2795: }
2796:
2797: ////////////////////////////////////////////////////////////////////////////
2798:
2799: /// <summary>
2800: ///
2801: /// </summary>
2802: public static List<Ia.Ngn.Cl.Model.NetworkDesignDocument.NddPon> NddPonList()
2803: {
2804: var list = new List<Ia.Ngn.Cl.Model.NetworkDesignDocument.NddPon>();
2805:
2806: using (var db = new Ia.Ngn.Cl.Model.Ngn())
2807: {
2808: list = (from np in db.NddPons select np).ToList();
2809: }
2810:
2811: return list;
2812: }
2813:
2814: ////////////////////////////////////////////////////////////////////////////
2815:
2816: /// <summary>
2817: ///
2818: /// </summary>
2819: public static void WriteNddOntsTable()
2820: {
2821: DataTable dataTable;
2822: Ia.Cl.Model.Result result;
2823: Ia.Cl.Model.Db.SqlServer sqlServer;
2824:
2825: sqlServer = new Ia.Cl.Model.Db.SqlServer();
2826:
2827: var _ontList = Ia.Ngn.Cl.Model.Data.NetworkDesignDocument.OntList;
2828:
2829: if (_ontList.Count == Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.PrecautionaryHardCodedNumberOfOntRecords)
2830: {
2831: // must seperate using{} to guarantee a clean close of connection before populating
2832: using (var db = new Ia.Ngn.Cl.Model.Ngn())
2833: {
2834: if (db.Database.EnsureCreated())
2835: {
2836: // delete all current records
2837: var all = from c in db.NddOnts select c;
2838: db.NddOnts.RemoveRange(all);
2839: db.SaveChanges();
2840: }
2841: }
2842:
2843: var nddOntList = new List<Ia.Ngn.Cl.Model.NetworkDesignDocument.NddOnt>();
2844:
2845: using (var db = new Ia.Ngn.Cl.Model.Ngn())
2846: {
2847: var _nddPonList = Ia.Ngn.Cl.Model.Data.NetworkDesignDocument.NddPonList();
2848:
2849: foreach (var ont in _ontList)
2850: {
2851: var nddOnt = new Ia.Ngn.Cl.Model.NetworkDesignDocument.NddOnt
2852: {
2853: Id = ont.Id,
2854: Rack = ont.Rack,
2855: Sub = ont.Sub,
2856: CardSlot = ont.CardSlot,
2857: Port = ont.Port,
2858: Number = ont.Number,
2859: InternalNumber = ont.InternalNumber,
2860: Position = ont.Position,
2861: Ip = ont.Ip,
2862: ImsBasicServiceMgcIp = ont.ImsBasicService.MgcIp,
2863: NddPon = (from np in _nddPonList where np.Id == ont.Pon.Id select np).Single()
2864: };
2865:
2866: nddOntList.Add(nddOnt);
2867: }
2868:
2869: dataTable = Ia.Cl.Model.Default.GenerateDataTableFromGenericClassList<Ia.Ngn.Cl.Model.NetworkDesignDocument.NddOnt>(nddOntList, "NddOnts");
2870:
2871: if (dataTable != null && dataTable.Rows.Count > 0)
2872: {
2873: if (dataTable.Rows.Count == Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.PrecautionaryHardCodedNumberOfOntRecords)
2874: {
2875: sqlServer.SqlBulkCopy(dataTable, out result);
2876: }
2877: else
2878: {
2879: throw new ArgumentOutOfRangeException(@"(_ontList.Count != " + Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.PrecautionaryHardCodedNumberOfOntRecords);
2880: }
2881: }
2882: else
2883: {
2884: throw new ArgumentOutOfRangeException(@"dataTable is null or empty");
2885: }
2886: }
2887: }
2888: else
2889: {
2890: throw new ArgumentOutOfRangeException(@"(_ontList.Count != " + Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.PrecautionaryHardCodedNumberOfOntRecords);
2891: }
2892: }
2893: */
2894: }
2895:
2896: ////////////////////////////////////////////////////////////////////////////
2897: ////////////////////////////////////////////////////////////////////////////
2898: }