1: using System;
2: using System.Web;
3: using System.Xml.Linq;
4: using System.IO;
5: using System.Data;
6: using System.Collections;
7: using System.Collections.Generic;
8: using System.Reflection;
9: using System.Linq;
10: using System.Text;
11: using System.Text.RegularExpressions;
12:
13: namespace Ia.Ngn.Cl.Model.Data
14: {
15: ////////////////////////////////////////////////////////////////////////////
16:
17: /// <summary publish="true">
18: /// Network Design Document support class for Next Generation Network (NGN) data model.
19: /// </summary>
20: ///
21: /// <remarks>
22: /// Copyright © 2006-2018 Jasem Y. Al-Shamlan (info@ia.com.kw), Internet Applications - Kuwait. All Rights Reserved.
23: ///
24: /// 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
25: /// the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
26: ///
27: /// This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
28: /// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
29: ///
30: /// You should have received a copy of the GNU General Public License along with this library. If not, see http://www.gnu.org/licenses.
31: ///
32: /// Copyright notice: This notice may not be removed or altered from any source distribution.
33: /// </remarks>
34: public partial class NetworkDesignDocument
35: {
36: private static Hashtable ponNameToPonIdHashtable;
37: private static XDocument xDocument;
38: private static Dictionary<string, int> ontIdToOntPonPonGroupOltIdDictionary;
39: private static Dictionary<string, string> ontAccessIdToOntIdDictionary, ontIdToOntAccessNameDictionary, ontAccessNameToOntAccessIdDictionary, ontAccessNameToOntIdDictionary, ontAccessIdToOntAccessNameDictionary, ontIpToOntAccessNameDictionary, ontAccessNameToOntIpDictionary, ontAccessNameToOntMgcIpDictionary, ontAccessNameToOntPositionDictionary, ontIdDictionary, ontIpDictionary, ponNameToPonIdDictionary;
40: private static Dictionary<string, Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Ont> ontAccessIdToOntDictionary, ontIdToOntDictionary;
41: private static Dictionary<string, Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Pon> ponIdToPonDictionary, ponNameToPonDictionary;
42: private static List<Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Network> networkList;
43: private static List<Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Vendor> vendorList;
44: private static List<Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Site> siteList;
45: private static List<Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Router> routerList;
46: private static List<Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Oam> oamList;
47: private static List<Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Odf> odfList;
48: private static List<Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Olt> oltList;
49: private static List<Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.PonGroup> ponGroupList;
50: private static List<Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Pon> ponList;
51: private static List<Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Ont> ontList;
52:
53: private static object objectLock = new object();
54:
55: /// <summary/>
56: public enum BellcoreState { Undefined = 0, IsNr = 1, OosAu, OosMa, OosAuma };
57:
58: ////////////////////////////////////////////////////////////////////////////
59:
60: /// <summary>
61: ///
62: /// </summary>
63: public NetworkDesignDocument() { }
64:
65: ////////////////////////////////////////////////////////////////////////////
66:
67: /// <summary>
68: ///
69: /// </summary>
70: public static List<Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Ont> OntList
71: {
72: get
73: {
74: if (ontList == null || ontList.Count == 0)
75: {
76: if (HttpContext.Current != null && HttpContext.Current.Application["ontList"] != null)
77: {
78: ontList = (List<Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Ont>)HttpContext.Current.Application["ontList"];
79: }
80: else
81: {
82: ontList = null;
83: ontList = Ia.Ngn.Cl.Model.Data.NetworkDesignDocument._OntList;
84:
85: if (HttpContext.Current != null) HttpContext.Current.Application["ontList"] = ontList;
86: }
87: }
88:
89: return ontList;
90: }
91: }
92:
93: ////////////////////////////////////////////////////////////////////////////
94:
95: /// <summary>
96: ///
97: /// </summary>
98: private static List<Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Ont> _OntList
99: {
100: get
101: {
102: if (ontList == null || ontList.Count == 0)
103: {
104: bool nokiaRouter, huaweiRouter, nokiaOdf, huaweiOdf;
105: long networkNumberIpLong, ipLong, diff, l;
106: string oltSymbol;
107: //List<string> list;
108: //Dictionary<string, Ia.Ngn.Cl.Model.Business.Huawei.Dev.MduDev> mduDictionary;
109:
110: #if DEBUG
111: Dictionary<string, string> ontDictionary, proposedOntDictionary, ipDictionary;
112: #endif
113: Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Ont ont;
114: Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Access access;
115:
116: //list = new List<string>();
117:
118: lock (objectLock)
119: {
120: ontList = new List<Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Ont>(Ia.Ngn.Cl.Model.Data.NetworkDesignDocument.PonList.Count * 32);
121: #if DEBUG
122: ontDictionary = new Dictionary<string, string>(Ia.Ngn.Cl.Model.Data.NetworkDesignDocument.PonList.Count * 32);
123: proposedOntDictionary = new Dictionary<string, string>(Ia.Ngn.Cl.Model.Data.NetworkDesignDocument.PonList.Count * 32);
124: ipDictionary = new Dictionary<string, string>(Ia.Ngn.Cl.Model.Data.NetworkDesignDocument.PonList.Count * 32);
125: #endif
126:
127: //mduDictionary = Ia.Ngn.Cl.Model.Data.Huawei.Default.MduDictionary;
128:
129: foreach (Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Pon pon in Ia.Ngn.Cl.Model.Data.NetworkDesignDocument.PonList)
130: {
131: nokiaRouter = (pon.PonGroup.Olt.Odf.Router.Vendor == Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Vendor.Nokia) ? true : false; // false for Huawei
132: huaweiRouter = !nokiaRouter;
133:
134: nokiaOdf = (pon.PonGroup.Olt.Odf.Vendor == Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Vendor.Nokia) ? true : false; // false for Huawei
135: huaweiOdf = !nokiaOdf;
136:
137: oltSymbol = pon.PonGroup.Olt.Symbol;
138:
139: networkNumberIpLong = Ia.Cl.Model.Default.IpToDec(pon.PonGroup.NetworkNumber);
140:
141: if (pon.Name == "SAB.1402" || pon.Name == "BYN.702")
142: {
143:
144: }
145:
146: for (int ontNumber = 1; ontNumber <= pon.PonGroup.Olt.NumberOfOntsInPon; ontNumber++)
147: {
148: ont = new Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Ont();
149: access = new Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Access();
150:
151: ont.Pon = pon;
152:
153: ont.Rack = ont.Pon.PonGroup.Olt.Rack;
154: ont.Sub = ont.Pon.PonGroup.Olt.Sub;
155: ont.CardSlot = ont.Pon.CardSlot; // CardSlot might change for MDUs below
156: ont.Port = ont.Pon.Port;
157:
158: ont.Number = ontNumber;
159:
160: ont.InternalNumber = (ont.Pon.Index * pon.PonGroup.Olt.NumberOfOntsInPon) % 32 + ont.Number;
161:
162: ont.Position = ont.Pon.PonGroup.Olt.AmsName + "-" + ont.CardSlot + "-" + ont.Port + "-" + ont.InternalNumber;
163:
164: access.Id = access.AccessId(ont.Pon.PonGroup.Olt.Id, ont.Pon.Number, ont.Number);
165: access.Pon = ont.Pon.Number;
166: access.ProposedPon = ont.Pon.ProposedNumber;
167: access.Ont = ont.Number;
168:
169: access.Symbol = ont.Pon.PonGroup.Olt.Symbol;
170: access.Name = ont.Pon.PonGroup.Symbol + "." + ont.Pon.Number + "." + ont.Number;
171: access.ProposedName = ont.Pon.PonGroup.Symbol + "." + ont.Pon.ProposedNumber + "." + ont.Number;
172:
173: /*
174: if (mduDictionary.ContainsKey(access.Name))
175: {
176: ont.CardSlot = 0; // mduDictionary[access.Name].SlotId;
177: }
178: */
179:
180: if (access.Name == "SSB.44.27")
181: {
182:
183: }
184:
185: ont.Access = access;
186:
187: //ipLong = networkNumberIpLong + pon.Index * pon.PonGroup.Olt.NumberOfOntsInPon + ont.Number; // or ont.InternalNumber
188: ipLong = networkNumberIpLong + pon.PonGroupPonIndex * pon.PonGroup.Olt.NumberOfOntsInPon + ont.Number; // or ont.InternalNumber
189: diff = ipLong - networkNumberIpLong;
190:
191: if (nokiaOdf)
192: {
193: // below: skip *.*.*.0 only for Nokia ONTs
194: if (diff >= 5611) l = 22;
195: else if (diff >= 5356) l = 21;
196: else if (diff >= 5101) l = 20;
197: else if (diff >= 4846) l = 19;
198: else if (diff >= 4591) l = 18;
199: else if (diff >= 4336) l = 17;
200: else if (diff >= 4081) l = 16;
201: else if (diff >= 3826) l = 15;
202: else if (diff >= 3571) l = 14;
203: else if (diff >= 3316) l = 13;
204: else if (diff >= 3061) l = 12;
205: else if (diff >= 2806) l = 11;
206: else if (diff >= 2551) l = 10;
207: else if (diff >= 2296) l = 9;
208: else if (diff >= 2041) l = 8;
209: else if (diff >= 1786) l = 7;
210: else if (diff >= 1531) l = 6;
211: else if (diff >= 1276) l = 5;
212: else if (diff >= 1021) l = 4;
213: else if (diff >= 766) l = 3;
214: else if (diff >= 511) l = 2;
215: else if (diff >= 256) l = 1;
216: else l = 0;
217:
218: ipLong += l;
219: }
220: else //if(huaweiOdf)
221: {
222: if (nokiaRouter)
223: {
224: }
225: else //if (huaweiRouter)
226: {
227: // Huawei router and ODF. Here we will skip *.*.*.0 and *.*.*.1. Go figure!
228: ipLong += 1;
229: }
230: }
231:
232: ont.Ip = Ia.Cl.Model.Default.DecToIp((int)ipLong);
233:
234: // ont.Id is used in functions below
235: ont.Id = Ia.Ngn.Cl.Model.Business.Nokia.Ont.OntId(ont.Pon.Id, ont.InternalNumber);
236:
237: if (nokiaRouter)
238: {
239: // Nokia switch
240:
241: if (nokiaOdf)
242: {
243: ont.ImsBasicService = Ia.Ngn.Cl.Model.Business.Ims.NokiaImsBasicServiceItem(ont);
244: }
245: else
246: {
247: ont.ImsBasicService = Ia.Ngn.Cl.Model.Business.Ims.SpecialHuaweiIpHandlingForNokiaImsBasicServiceItem(ont);
248: }
249: }
250: else
251: {
252: ont.ImsBasicService = Ia.Ngn.Cl.Model.Business.Ims.HuaweiImsBasicServiceItem(ont.Pon.PonGroup.MgcIp);
253: }
254:
255: #if DEBUG
256: // this will throw an exception if there is a duplicate ont.Access.Name
257: if (ontDictionary.ContainsKey(ont.Access.Name))
258: {
259: throw new ArgumentOutOfRangeException(@"ontDictionary.ContainsKey(ont.Access.Name)");
260: }
261: else ontDictionary[ont.Access.Name] = ont.Id;
262:
263: // this will throw an exception if there is a duplicate ont.Access.ProposedName
264: if (proposedOntDictionary.ContainsKey(ont.Access.ProposedName))
265: {
266: throw new ArgumentOutOfRangeException(@"proposedOntDictionary.ContainsKey(ont.Access.ProposedName)");
267: }
268: else proposedOntDictionary[ont.Access.ProposedName] = ont.Id;
269:
270: /*
271: // this will throw an exception if an IP has *.*.*.0
272: // over 400 Huawei ONTs with *.*.*.0 IPs
273: if (Regex.IsMatch(ont.Ip, @"\d{1,3}\.\d{1,3}\.\d{1,3}\.0"))
274: {
275: list.Add(ont.Access.Name);
276: }
277: */
278:
279: // this will throw an exception if there is a duplicate ont.Ip
280: if (ipDictionary.ContainsKey(ont.Ip))
281: {
282: throw new ArgumentOutOfRangeException(@"ipDictionary.ContainsKey(ont.Ip)");
283: }
284: else ipDictionary[ont.Ip] = ont.Id;
285: #endif
286: ontList.Add(ont);
287: }
288: }
289: }
290: }
291:
292: return ontList.ToList();
293: }
294: }
295:
296: ////////////////////////////////////////////////////////////////////////////
297:
298: /// <summary>
299: /// A Hashtable "faster" version of OntList for frequent use
300: /// </summary>
301: public static Hashtable OntAccessIdToAccessVendorHashtable
302: {
303: get
304: {
305: Hashtable ht;
306:
307: ht = new Hashtable(Ia.Ngn.Cl.Model.Data.NetworkDesignDocument.OntList.Count);
308:
309: foreach (Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Ont ont in Ia.Ngn.Cl.Model.Data.NetworkDesignDocument.OntList)
310: {
311: ht[ont.Access.Id] = ont.Pon.PonGroup.Olt.Odf.Vendor;
312: }
313:
314: return ht;
315: }
316: }
317:
318: ////////////////////////////////////////////////////////////////////////////
319:
320: /// <summary>
321: ///
322: /// </summary>
323: public static List<string> OntAccessIdList
324: {
325: get
326: {
327: List<string> list;
328:
329: list = (from o in Ia.Ngn.Cl.Model.Data.NetworkDesignDocument.OntList orderby o.Access.Id select o.Access.Id).ToList();
330:
331: return list;
332: }
333: }
334:
335: ////////////////////////////////////////////////////////////////////////////
336:
337: /// <summary>
338: ///
339: /// </summary>
340: public static Dictionary<string, int> OntAccessIdDictionary
341: {
342: get
343: {
344: Dictionary<string, int> dictionary;
345:
346: dictionary = (from o in Ia.Ngn.Cl.Model.Data.NetworkDesignDocument.OntList select o.Access.Id).ToDictionary(n => n, n => 1);
347:
348: return dictionary;
349: }
350: }
351:
352: ////////////////////////////////////////////////////////////////////////////
353:
354: /// <summary>
355: ///
356: /// </summary>
357: public static Dictionary<string, string> OntAccessIdToOntIdDictionary
358: {
359: get
360: {
361: if (ontAccessIdToOntIdDictionary == null || ontAccessIdToOntIdDictionary.Count == 0)
362: {
363: ontAccessIdToOntIdDictionary = (from o in Ia.Ngn.Cl.Model.Data.NetworkDesignDocument.OntList select new { AccessId = o.Access.Id, OntId = o.Id }).ToDictionary(n => n.AccessId, n => n.OntId);
364: }
365:
366: return ontAccessIdToOntIdDictionary;
367: }
368: }
369:
370: ////////////////////////////////////////////////////////////////////////////
371:
372: /// <summary>
373: ///
374: /// </summary>
375: public static Dictionary<string, Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Ont> OntAccessIdToOntDictionary
376: {
377: get
378: {
379: if (ontAccessIdToOntDictionary == null || ontAccessIdToOntDictionary.Count == 0)
380: {
381: ontAccessIdToOntDictionary = (from o in Ia.Ngn.Cl.Model.Data.NetworkDesignDocument.OntList select new { AccessId = o.Access.Id, Ont = o }).ToDictionary(n => n.AccessId, n => n.Ont);
382: }
383:
384: return ontAccessIdToOntDictionary;
385: }
386: }
387:
388: ////////////////////////////////////////////////////////////////////////////
389:
390: /// <summary>
391: ///
392: /// </summary>
393: public static Dictionary<string, Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Ont> OntIdToOntDictionary
394: {
395: get
396: {
397: if (ontIdToOntDictionary == null || ontIdToOntDictionary.Count == 0)
398: {
399: ontIdToOntDictionary = (from o in Ia.Ngn.Cl.Model.Data.NetworkDesignDocument.OntList select new { OntId = o.Id, Ont = o }).ToDictionary(n => n.OntId, n => n.Ont);
400: }
401:
402: return ontIdToOntDictionary;
403: }
404: }
405:
406: ////////////////////////////////////////////////////////////////////////////
407:
408: /// <summary>
409: ///
410: /// </summary>
411: public static Dictionary<string, string> OntIdToOntAccessNameDictionary
412: {
413: get
414: {
415: if (ontIdToOntAccessNameDictionary == null || ontIdToOntAccessNameDictionary.Count == 0)
416: {
417: ontIdToOntAccessNameDictionary = (from o in Ia.Ngn.Cl.Model.Data.NetworkDesignDocument.OntList select new { OntId = o.Id, OntAccessName = o.Access.Name }).ToDictionary(n => n.OntId, n => n.OntAccessName);
418: }
419:
420: return ontIdToOntAccessNameDictionary;
421: }
422: }
423:
424: ////////////////////////////////////////////////////////////////////////////
425:
426: /// <summary>
427: ///
428: /// </summary>
429: public static Dictionary<string, string> OntAccessNameToOntIdDictionary
430: {
431: get
432: {
433: if (ontAccessNameToOntIdDictionary == null || ontAccessNameToOntIdDictionary.Count == 0)
434: {
435: ontAccessNameToOntIdDictionary = (from o in Ia.Ngn.Cl.Model.Data.NetworkDesignDocument.OntList select new { OntAccessName = o.Access.Name, OntId = o.Id, }).ToDictionary(n => n.OntAccessName, n => n.OntId);
436: }
437:
438: return ontAccessNameToOntIdDictionary;
439: }
440: }
441:
442: ////////////////////////////////////////////////////////////////////////////
443:
444: /// <summary>
445: ///
446: /// </summary>
447: public static Dictionary<string, string> OntAccessNameToOntAccessIdDictionary
448: {
449: get
450: {
451: if (ontAccessNameToOntAccessIdDictionary == null || ontAccessNameToOntAccessIdDictionary.Count == 0)
452: {
453: ontAccessNameToOntAccessIdDictionary = (from o in Ia.Ngn.Cl.Model.Data.NetworkDesignDocument.OntList select new { OntAccessName = o.Access.Name, OntAccessId = o.Access.Id, }).ToDictionary(n => n.OntAccessName, n => n.OntAccessId);
454: }
455:
456: return ontAccessNameToOntAccessIdDictionary;
457: }
458: }
459:
460: ////////////////////////////////////////////////////////////////////////////
461:
462: /// <summary>
463: ///
464: /// </summary>
465: public static Dictionary<string, string> OntAccessIdToOntAccessNameDictionary
466: {
467: get
468: {
469: if (ontAccessIdToOntAccessNameDictionary == null || ontAccessIdToOntAccessNameDictionary.Count == 0)
470: {
471: ontAccessIdToOntAccessNameDictionary = (from o in Ia.Ngn.Cl.Model.Data.NetworkDesignDocument.OntList select new { OntAccessId = o.Access.Id, OntAccessName = o.Access.Name }).ToDictionary(n => n.OntAccessId, n => n.OntAccessName);
472: }
473:
474: return ontAccessIdToOntAccessNameDictionary;
475: }
476: }
477:
478: ////////////////////////////////////////////////////////////////////////////
479:
480: /// <summary>
481: ///
482: /// </summary>
483: public static Dictionary<string, string> OntIpToOntAccessNameDictionary
484: {
485: get
486: {
487: if (ontIpToOntAccessNameDictionary == null || ontIpToOntAccessNameDictionary.Count == 0)
488: {
489: ontIpToOntAccessNameDictionary = (from o in Ia.Ngn.Cl.Model.Data.NetworkDesignDocument.OntList select new { OntIp = o.Ip, OntAccessName = o.Access.Name }).ToDictionary(n => n.OntIp, n => n.OntAccessName);
490: }
491:
492: return ontIpToOntAccessNameDictionary;
493: }
494: }
495:
496: ////////////////////////////////////////////////////////////////////////////
497:
498: /// <summary>
499: ///
500: /// </summary>
501: public static Dictionary<string, string> OntAccessNameToOntIpDictionary
502: {
503: get
504: {
505: if (ontAccessNameToOntIpDictionary == null || ontAccessNameToOntIpDictionary.Count == 0)
506: {
507: ontAccessNameToOntIpDictionary = (from o in Ia.Ngn.Cl.Model.Data.NetworkDesignDocument.OntList select new { OntAccessName = o.Access.Name, OntIp = o.Ip }).ToDictionary(n => n.OntAccessName, n => n.OntIp);
508: }
509:
510: return ontAccessNameToOntIpDictionary;
511: }
512: }
513:
514: ////////////////////////////////////////////////////////////////////////////
515:
516: /// <summary>
517: ///
518: /// </summary>
519: public static Dictionary<string, string> OntAccessNameToOntMgcIpDictionary
520: {
521: get
522: {
523: if (ontAccessNameToOntMgcIpDictionary == null || ontAccessNameToOntMgcIpDictionary.Count == 0)
524: {
525: ontAccessNameToOntMgcIpDictionary = (from o in Ia.Ngn.Cl.Model.Data.NetworkDesignDocument.OntList select new { OntAccessName = o.Access.Name, OntMgcIp = o.MgcIp }).ToDictionary(n => n.OntAccessName, n => n.OntMgcIp);
526: }
527:
528: return ontAccessNameToOntMgcIpDictionary;
529: }
530: }
531:
532: ////////////////////////////////////////////////////////////////////////////
533:
534: /// <summary>
535: ///
536: /// </summary>
537: public static Dictionary<string, string> OntAccessNameToOntPositionDictionary
538: {
539: get
540: {
541: if (ontAccessNameToOntPositionDictionary == null || ontAccessNameToOntPositionDictionary.Count == 0)
542: {
543: ontAccessNameToOntPositionDictionary = (from o in Ia.Ngn.Cl.Model.Data.NetworkDesignDocument.OntList select new { OntAccessName = o.Access.Name, OntPosition = o.Position }).ToDictionary(n => n.OntAccessName, n => n.OntPosition);
544: }
545:
546: return ontAccessNameToOntPositionDictionary;
547: }
548: }
549:
550: ////////////////////////////////////////////////////////////////////////////
551:
552: /// <summary>
553: ///
554: /// </summary>
555: public static Dictionary<string, int> OntIdToOntPonPonGroupOltIdDictionary
556: {
557: get
558: {
559: if (ontIdToOntPonPonGroupOltIdDictionary == null || ontIdToOntPonPonGroupOltIdDictionary.Count == 0)
560: {
561: ontIdToOntPonPonGroupOltIdDictionary = (from o in Ia.Ngn.Cl.Model.Data.NetworkDesignDocument.OntList select new { OntId = o.Id, OntPonPonGroupOltId = o.Pon.PonGroup.Olt.Id }).ToDictionary(n => n.OntId, n => n.OntPonPonGroupOltId);
562: }
563:
564: return ontIdToOntPonPonGroupOltIdDictionary;
565: }
566: }
567:
568: ////////////////////////////////////////////////////////////////////////////
569:
570: /// <summary>
571: ///
572: /// </summary>
573: public static Dictionary<string, string> OntIdDictionary
574: {
575: get
576: {
577: if (ontIdDictionary == null || ontIdDictionary.Count == 0)
578: {
579: ontIdDictionary = (from o in Ia.Ngn.Cl.Model.Data.NetworkDesignDocument.OntList select o.Id).ToDictionary(n => n, n => n);
580: }
581:
582: return ontIdDictionary;
583: }
584: }
585:
586: ////////////////////////////////////////////////////////////////////////////
587:
588: /// <summary>
589: ///
590: /// </summary>
591: public static Dictionary<string, string> OntIpDictionary
592: {
593: get
594: {
595: if (ontIpDictionary == null || ontIpDictionary.Count == 0)
596: {
597: ontIpDictionary = (from o in Ia.Ngn.Cl.Model.Data.NetworkDesignDocument.OntList select o.Ip).ToDictionary(n => n, n => n);
598: }
599:
600: return ontIpDictionary;
601: }
602: }
603:
604: ////////////////////////////////////////////////////////////////////////////
605:
606: /// <summary>
607: ///
608: /// </summary>
609: public static Dictionary<string, string> NokiaOntIpToPrimarySwitchImsFsdbDictionary
610: {
611: get
612: {
613: Dictionary<string, string> dictionary;
614:
615: dictionary = (from o in Ia.Ngn.Cl.Model.Data.NetworkDesignDocument.OntList
616: where o.Pon.PonGroup.Olt.Odf.Vendor == Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Vendor.Nokia
617: select o).Distinct().ToDictionary(n => n.Ip, n => n.PrimarySwitch + "(" + n.ImsFsdb + ")");
618:
619: return dictionary;
620: }
621: }
622:
623: ////////////////////////////////////////////////////////////////////////////
624:
625: /// <summary>
626: ///
627: /// </summary>
628: public static Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Ont OntByOltIdCardPortOntNumber(int oltId, int cardSlot, int port, int ontInternalNumber)
629: {
630: Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Ont item;
631:
632: item = (from o in Ia.Ngn.Cl.Model.Data.NetworkDesignDocument.OntList where o.Pon.PonGroup.Olt.Id == oltId && o.CardSlot == cardSlot && o.Port == port && o.InternalNumber == ontInternalNumber select o).SingleOrDefault();
633:
634: return item;
635: }
636:
637: ////////////////////////////////////////////////////////////////////////////
638:
639: /// <summary>
640: ///
641: /// </summary>
642: public static Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Ont OntByOltIdPonIdOntNumber(int oltId, string ponId, int ontInternalNumber)
643: {
644: Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Ont item;
645:
646: item = (from o in Ia.Ngn.Cl.Model.Data.NetworkDesignDocument.OntList where o.Pon.PonGroup.Olt.Id == oltId && o.Pon.Id == ponId && o.InternalNumber == ontInternalNumber select o).SingleOrDefault();
647:
648: return item;
649: }
650:
651: ////////////////////////////////////////////////////////////////////////////
652:
653: /// <summary>
654: ///
655: /// </summary>
656: public static bool AccessNameIsWithinAllowedOntList(string accessName)
657: {
658: // below: this checks that this accessName is within the standard possible values in network
659:
660: bool isWithinAllowedOnts;
661:
662: isWithinAllowedOnts = (from o in OntList where o.Access.Name == accessName select o).SingleOrDefault() != null;
663:
664: return isWithinAllowedOnts;
665: }
666:
667: ////////////////////////////////////////////////////////////////////////////
668:
669: /// <summary>
670: ///
671: /// </summary>
672: public static Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Ont ReadOnt(string ontId)
673: {
674: return (from o in OntList where o.Id == ontId select o).SingleOrDefault();
675: }
676:
677: ////////////////////////////////////////////////////////////////////////////
678:
679: /// <summary>
680: ///
681: /// </summary>
682: public static Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Ont OntByAccessName(string accessName)
683: {
684: return (from o in OntList where o.Access.Name == accessName select o).SingleOrDefault();
685: }
686:
687: ////////////////////////////////////////////////////////////////////////////
688:
689: /// <summary>
690: ///
691: /// </summary>
692: public static Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Vendor AccessVendorByOntId(string ontId)
693: {
694: return (from o in OntList where o.Id == ontId select o.Pon.PonGroup.Olt.Odf.Vendor).SingleOrDefault();
695: }
696:
697: ////////////////////////////////////////////////////////////////////////////
698:
699: /// <summary>
700: ///
701: /// </summary>
702: public static Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Vendor AccessVendorByAccessName(string accessName)
703: {
704: return (from o in OntList where o.Access.Name == accessName select o.Pon.PonGroup.Olt.Odf.Vendor).SingleOrDefault();
705: }
706:
707: ////////////////////////////////////////////////////////////////////////////
708:
709: /// <summary>
710: ///
711: /// </summary>
712: public static Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Vendor SwitchVendorByAccessName(string accessName)
713: {
714: return (from o in OntList where o.Access.Name == accessName select o.Pon.PonGroup.Olt.Odf.Router.Vendor).SingleOrDefault();
715: }
716:
717: ////////////////////////////////////////////////////////////////////////////
718:
719: /// <summary>
720: ///
721: /// </summary>
722: public static bool PonNameIsWithinAllowedOntList(string ontAreaPon)
723: {
724: // below: this checks that this accessName is within the standard possible values in network
725:
726: bool isWithinAllowedOnts;
727:
728: if (ontAreaPon == null || ontAreaPon.Length == 0) isWithinAllowedOnts = false;
729: else
730: {
731: isWithinAllowedOnts = (from o in OntList where o.Access.Name.Contains(ontAreaPon + ".") select o).FirstOrDefault() != null;
732: }
733:
734: return isWithinAllowedOnts;
735: }
736:
737: ////////////////////////////////////////////////////////////////////////////
738:
739: /// <summary>
740: ///
741: /// </summary>
742: public static string OntIdFromPosition(string position)
743: {
744: string id;
745:
746: id = (from o in Ia.Ngn.Cl.Model.Data.NetworkDesignDocument.OntList where o.Position == position select o.Id).FirstOrDefault();
747:
748: return id;
749: }
750:
751: ////////////////////////////////////////////////////////////////////////////
752:
753: /// <summary>
754: ///
755: /// </summary>
756: public static void ExportOntListToText()
757: {
758: string filePath;
759: StringBuilder sb;
760:
761: sb = new StringBuilder();
762:
763: foreach (var o in OntList) sb.AppendLine(o.Access.Name + " " + o.Position + " " + o.Id);
764:
765: filePath = Environment.GetFolderPath(Environment.SpecialFolder.Desktop) + "\\ont-list.txt";
766: File.WriteAllText(filePath, sb.ToString());
767: }
768:
769: ////////////////////////////////////////////////////////////////////////////
770: ////////////////////////////////////////////////////////////////////////////
771:
772:
773:
774:
775:
776:
777:
778: ////////////////////////////////////////////////////////////////////////////
779: ////////////////////////////////////////////////////////////////////////////
780:
781: /// <summary>
782: ///
783: /// </summary>
784: public static List<Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Pon> PonList
785: {
786: get
787: {
788: if (ponList == null || ponList.Count == 0)
789: {
790: if (HttpContext.Current != null && HttpContext.Current.Application["ponList"] != null)
791: {
792: ponList = (List<Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Pon>)HttpContext.Current.Application["ponList"];
793: }
794: else
795: {
796: ponList = null;
797: ponList = Ia.Ngn.Cl.Model.Data.NetworkDesignDocument._PonList;
798:
799: if (HttpContext.Current != null) HttpContext.Current.Application["ponList"] = ponList;
800: }
801: }
802:
803: return ponList;
804: }
805: }
806:
807: ////////////////////////////////////////////////////////////////////////////
808:
809: /// <summary>
810: ///
811: /// </summary>
812: private static List<Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Pon> _PonList
813: {
814: get
815: {
816: if (ponList == null || ponList.Count == 0)
817: {
818: bool nokiaRouter, huaweiRouter, nokiaOdf, huaweiOdf, useNewList;
819: int ponNumber, proposedPonNumber, slot, oltPonIndex, oltPonCount, oltProposedPonCount;
820: string odfName;
821: #if DEBUG
822: Dictionary<string, string> ponIdDictionary;
823: #endif
824: Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Pon pon;
825:
826: lock (objectLock)
827: {
828: 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)
829: #if DEBUG
830: ponIdDictionary = new Dictionary<string, string>(Ia.Ngn.Cl.Model.Data.NetworkDesignDocument.PonGroupList.Count * 32);
831: #endif
832: foreach (Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Olt olt in Ia.Ngn.Cl.Model.Data.NetworkDesignDocument.OltList)
833: {
834: oltPonIndex = 0;
835:
836: nokiaRouter = (olt.Odf.Router.Vendor == Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Vendor.Nokia) ? true : false; // false for Huawei
837: huaweiRouter = !nokiaRouter;
838:
839: nokiaOdf = (olt.Odf.Vendor == Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Vendor.Nokia) ? true : false; // false for Huawei
840: huaweiOdf = !nokiaOdf;
841:
842: odfName = olt.Odf.Name;
843:
844: oltPonCount = oltProposedPonCount = 0;
845:
846: foreach (Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.PonGroup ponGroup in olt.PonGroupList)
847: {
848: oltPonCount += ponGroup.UsedPonInPonGroupList.Count;
849:
850: if (ponGroup.HasNewProposedPonList) oltProposedPonCount += ponGroup.UsedProposedPonInPonGroupList.Count;
851: }
852:
853: if (((oltPonCount == oltProposedPonCount) || oltProposedPonCount == 0) && oltPonCount % 32 == 0)
854: {
855: foreach (Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.PonGroup ponGroup in olt.PonGroupList)
856: {
857: if (!ponGroup.HasNewProposedPonList || ponGroup.UsedPonInPonGroupList.Count == ponGroup.UsedProposedPonInPonGroupList.Count)
858: {
859: //if (ponGroup.UsedPonInPonGroupList.Count == olt.NumberOfPonsPerLt * 2)
860: //{
861: // 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
862: // to match this index with that from the Ip, position list, because that list does not recognize PONs.
863: for (int ponGroupPonIndex = 0; ponGroupPonIndex < ponGroup.UsedPonInPonGroupList.Count; ponGroupPonIndex++)
864: {
865: if ((int)ponGroup.UsedPonInPonGroupList[ponGroupPonIndex] != 0 && (!ponGroup.HasNewProposedPonList || (int)ponGroup.UsedProposedPonInPonGroupList[ponGroupPonIndex] != 0))
866: {
867: pon = new Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Pon();
868:
869: ponNumber = (int)ponGroup.UsedPonInPonGroupList[ponGroupPonIndex];
870:
871: if (ponGroup.HasNewProposedPonList) proposedPonNumber = (int)ponGroup.UsedProposedPonInPonGroupList[ponGroupPonIndex];
872: else proposedPonNumber = ponNumber;
873:
874: pon.Id = pon.PonId(ponGroup.Olt.Id, oltPonIndex);
875:
876: pon.Index = oltPonIndex;
877: pon.PonGroupPonIndex = ponGroupPonIndex;
878:
879: pon.PonGroup = (from l in PonGroupList where l.Id == ponGroup.Id select l).SingleOrDefault();
880:
881: pon.Rack = pon.PonGroup.Olt.Rack;
882: pon.Sub = pon.PonGroup.Olt.Sub;
883:
884: if (nokiaOdf)
885: {
886: pon.CardSlot = oltPonIndex / olt.NumberOfLts + 1;
887: pon.Port = oltPonIndex % olt.NumberOfLts + 1;
888: }
889: else //if(huaweiOdf)
890: {
891: // Huawei skips slots 9 and 10 and goes directly from 8 to 11
892:
893: slot = oltPonIndex / (olt.NumberOfPonsPerLt * olt.NumberOfLts / 16) + 1;
894:
895: if (slot > 8) slot += 2;
896:
897: if (ponGroup.Olt.NumberOfFirstSlot == 0) slot--;
898:
899: pon.CardSlot = slot;
900:
901: pon.Port = (16 * oltPonIndex % olt.NumberOfPons) / (32 / olt.NumberOfOntsInPon) / 16;
902:
903: //if (ponGroup.Olt.NumberOfFirstSlot == 0) pon.Port++;
904: }
905:
906: pon.Number = ponNumber;
907: pon.ProposedNumber = proposedPonNumber;
908: pon.Position = pon.PonGroup.Olt.AmsName + "-" + pon.CardSlot + "-" + pon.Port;
909: pon.Name = pon.PonGroup.Symbol + "." + pon.Number;
910:
911: if (pon.Name == "ABW.202" || pon.Name == "ABW.203")
912: {
913:
914: }
915:
916: #if DEBUG
917: // this will throw an exception if there is a duplicate pon.Id
918: if (ponIdDictionary.ContainsKey(pon.Id))
919: {
920: throw new ArgumentOutOfRangeException(@"ponDictionary.ContainsKey(pon.Id)");
921: }
922: else ponIdDictionary[pon.Id] = pon.Name;
923: #endif
924:
925: ponList.Add(pon);
926: }
927: #if DEBUG
928: else if ((int)ponGroup.UsedPonInPonGroupList[ponGroupPonIndex] != 0 && (ponGroup.HasNewProposedPonList && (int)ponGroup.UsedProposedPonInPonGroupList[ponGroupPonIndex] == 0))
929: {
930: throw new ArgumentOutOfRangeException(@"Fault condition met: (int)ponGroup.UsedPonInPonGroupList[ponGroupPonIndex] != 0 && (!ponGroup.UsesProposedList || (int)ponGroup.UsedProposedPonInPonGroupList[ponGroupPonIndex] == 0)");
931: }
932: else if ((int)ponGroup.UsedPonInPonGroupList[ponGroupPonIndex] == 0 && (ponGroup.HasNewProposedPonList && (int)ponGroup.UsedProposedPonInPonGroupList[ponGroupPonIndex] != 0))
933: {
934: throw new ArgumentOutOfRangeException(@"Fault condition met: (int)ponGroup.UsedPonInPonGroupList[ponGroupPonIndex] == 0 && (!ponGroup.UsesProposedList || (int)ponGroup.UsedProposedPonInPonGroupList[ponGroupPonIndex] != 0)");
935: }
936: else
937: {
938: }
939: #endif
940: oltPonIndex++;
941: }
942: //}
943: //else throw new ArgumentOutOfRangeException(@"ponGroup.UsedPonInLtList.Count != ponGroup.Olt.NumberOfPonsPerLt * 2");
944: }
945: else throw new ArgumentOutOfRangeException(@"Condition not met: (!ponGroup.UsesProposedList || ponGroup.UsedPonInPonGroupList.Count == ponGroup.UsedProposedPonInPonGroupList.Count)");
946: }
947: }
948: else throw new ArgumentOutOfRangeException(@"Condition not met: ((oltPonCount == oltProposedPonCount) || oltProposedPonCount == 0) && oltPonCount % 32 == 0");
949:
950: //if (newI != olt.NumberOfPonsPerLt * olt.PonGroupList.Count * 2) throw new ArgumentOutOfRangeException(@"newI != olt.NumberOfPonsPerLt * olt.NumberOfLts");
951: }
952: }
953: }
954:
955: return ponList.ToList();
956: }
957: }
958:
959: ////////////////////////////////////////////////////////////////////////////
960:
961: /// <summary>
962: ///
963: /// </summary>
964: public static Dictionary<string, string> PonNameToPonIdDictionary
965: {
966: get
967: {
968: if (ponNameToPonIdDictionary == null || ponNameToPonIdDictionary.Count == 0)
969: {
970: ponNameToPonIdDictionary = (from p in Ia.Ngn.Cl.Model.Data.NetworkDesignDocument.PonList select new { p.Name, p.Id }).ToDictionary(n => n.Name, n => n.Id);
971: }
972:
973: return ponNameToPonIdDictionary;
974: }
975: }
976:
977: ////////////////////////////////////////////////////////////////////////////
978:
979: /// <summary>
980: ///
981: /// </summary>
982: public static Dictionary<string, Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Pon> PonIdToPonDictionary
983: {
984: get
985: {
986: if (ponIdToPonDictionary == null || ponIdToPonDictionary.Count == 0)
987: {
988: ponIdToPonDictionary = (from p in Ia.Ngn.Cl.Model.Data.NetworkDesignDocument.PonList select new { p.Id, Pon = p }).ToDictionary(n => n.Id, n => n.Pon);
989: }
990:
991: return ponIdToPonDictionary;
992: }
993: }
994:
995: ////////////////////////////////////////////////////////////////////////////
996:
997: /// <summary>
998: ///
999: /// </summary>
1000: public static Dictionary<string, Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Pon> PonNameToPonDictionary
1001: {
1002: get
1003: {
1004: if (ponNameToPonDictionary == null || ponNameToPonDictionary.Count == 0)
1005: {
1006: ponNameToPonDictionary = (from p in Ia.Ngn.Cl.Model.Data.NetworkDesignDocument.PonList select new { p.Name, Pon = p }).ToDictionary(n => n.Name, n => n.Pon);
1007: }
1008:
1009: return ponNameToPonDictionary;
1010: }
1011: }
1012:
1013: ////////////////////////////////////////////////////////////////////////////
1014:
1015: /// <summary>
1016: ///
1017: /// </summary>
1018: public static Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Pon PonByOltEmsNameAndSnAndPn(string emsName, int sn, int pn)
1019: {
1020: Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Pon pon;
1021: Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Olt olt;
1022:
1023: olt = Ia.Ngn.Cl.Model.Data.NetworkDesignDocument.OltByEmsName(emsName);
1024:
1025: if (olt.EmsName == "OLT-QRN-ABW-01") // ABW is all screwed up with multiple PON grouped and I will use .FirstOrDefault();
1026: {
1027: 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).FirstOrDefault();
1028: }
1029: else
1030: {
1031: 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();
1032: }
1033:
1034: return pon;
1035: }
1036:
1037: ////////////////////////////////////////////////////////////////////////////
1038: ////////////////////////////////////////////////////////////////////////////
1039:
1040: /// <summary>
1041: ///
1042: /// </summary>
1043: public static List<Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.PonGroup> PonGroupList
1044: {
1045: get
1046: {
1047: if (ponGroupList == null || ponGroupList.Count == 0)
1048: {
1049: if (HttpContext.Current != null && HttpContext.Current.Application["ltList"] != null)
1050: {
1051: ponGroupList = (List<Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.PonGroup>)HttpContext.Current.Application["ltList"];
1052: }
1053: else
1054: {
1055: ponGroupList = null;
1056: ponGroupList = Ia.Ngn.Cl.Model.Data.NetworkDesignDocument._PonGroupList;
1057:
1058: if (HttpContext.Current != null) HttpContext.Current.Application["ltList"] = ponGroupList;
1059: }
1060: }
1061:
1062: return ponGroupList;
1063: }
1064: }
1065:
1066: ////////////////////////////////////////////////////////////////////////////
1067:
1068: /// <summary>
1069: ///
1070: /// </summary>
1071: private static List<Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.PonGroup> _PonGroupList
1072: {
1073: get
1074: {
1075: if (ponGroupList == null || ponGroupList.Count == 0)
1076: {
1077: int networkId, siteId, routerId, odfId, oltId, id, i;
1078: Hashtable idHashtable, networkNumberHashtable;
1079: #if DEBUG
1080: Hashtable gatewayIpHashtable;
1081: #endif
1082: Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.PonGroup ponGroup;
1083:
1084: lock (objectLock)
1085: {
1086: ponGroupList = new List<Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.PonGroup>(16); // 16 is max number of ponGroup in ONT
1087: idHashtable = new Hashtable();
1088: networkNumberHashtable = new Hashtable();
1089: #if DEBUG
1090: gatewayIpHashtable = new Hashtable();
1091: #endif
1092:
1093: foreach (XElement x in XDocument.Element("networkDesignDocument").Elements("network").Elements("site").Elements("router").Elements("odf").Elements("olt").Elements("ponGroup"))
1094: {
1095: ponGroup = new Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.PonGroup
1096: {
1097: Olt = new Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Olt()
1098: };
1099: ponGroup.Olt.Odf = new Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Odf();
1100: ponGroup.Olt.Odf.Router = new Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Router();
1101: ponGroup.Olt.Odf.Router.Site = new Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Site();
1102:
1103: networkId = int.Parse(x.Parent.Parent.Parent.Parent.Parent.Attribute("id").Value);
1104: siteId = int.Parse(x.Parent.Parent.Parent.Parent.Attribute("id").Value);
1105: routerId = int.Parse(x.Parent.Parent.Parent.Attribute("id").Value);
1106: odfId = int.Parse(x.Parent.Parent.Attribute("id").Value);
1107: oltId = int.Parse(x.Parent.Attribute("id").Value);
1108: id = int.Parse(x.Attribute("id").Value);
1109:
1110: siteId = ponGroup.Olt.Odf.Router.Site.SiteId(networkId, siteId);
1111: routerId = ponGroup.Olt.Odf.Router.RouterId(siteId, routerId);
1112: odfId = ponGroup.Olt.Odf.OdfId(routerId, odfId);
1113: oltId = ponGroup.Olt.OltId(odfId, oltId);
1114: ponGroup.Id = ponGroup.PonGroupId(oltId, id);
1115:
1116: ponGroup.Number = id;
1117:
1118: ponGroup.Olt = (from o in OltList where o.Id == oltId select o).SingleOrDefault();
1119:
1120: if (x.Attribute("symbol") != null) ponGroup.Symbol = x.Attribute("symbol").Value;
1121: else ponGroup.Symbol = ponGroup.Olt.Symbol;
1122:
1123: ponGroup.NetworkNumber = x.Attribute("networkNumber").Value;
1124: // Network number must be unique and must end with *.*.*.0
1125: if (networkNumberHashtable.ContainsKey(ponGroup.NetworkNumber)) throw new ArgumentException(@"Lt.NetworkNumber is not unique for LT under OLT name=" + ponGroup.Olt.Name + ". ");
1126: else if (!Regex.IsMatch(ponGroup.NetworkNumber, @"\d{1,3}\.\d{1,3}\.\d{1,3}\.0")) throw new ArgumentException(@"Lt.NetworkNumber is not if format *.*.*.0 OLT name=" + ponGroup.Olt.Name + ". ");
1127: else networkNumberHashtable[ponGroup.NetworkNumber] = 1;
1128:
1129:
1130: ponGroup.PonListString = x.Attribute("list").Value;
1131: // below: pass ponList and change "*" to "0"
1132: ponGroup.UsedPonInPonGroupList = Ia.Cl.Model.Default.ConvertHyphenAndCommaSeperatedNumberStringToNumberList(ponGroup.PonListString.Replace("*", "0"));
1133:
1134: if (x.Attribute("proposedList") != null && x.Attribute("proposedList").Value.Length > 0)
1135: {
1136: ponGroup.ProposedPonListString = x.Attribute("proposedList").Value;
1137:
1138: // below: pass ponList and change "*" to "0"
1139: ponGroup.UsedProposedPonInPonGroupList = Ia.Cl.Model.Default.ConvertHyphenAndCommaSeperatedNumberStringToNumberList(ponGroup.ProposedPonListString.Replace("*", "0"));
1140: }
1141: else
1142: {
1143: ponGroup.ProposedPonListString = string.Empty;
1144: ponGroup.UsedProposedPonInPonGroupList = new List<int>();
1145: }
1146:
1147: if (x.Attribute("gatewayIp") != null) ponGroup.GatewayIp = x.Attribute("gatewayIp").Value;
1148: else if (x.Parent.Attribute("gatewayIp") != null) ponGroup.GatewayIp = x.Parent.Attribute("gatewayIp").Value;
1149: else if (x.Parent.Parent.Attribute("gatewayIp") != null) ponGroup.GatewayIp = x.Parent.Parent.Attribute("gatewayIp").Value;
1150: else throw new ArgumentException(@"ponGroup.GatewayIp could not be produced from XML document. ");
1151:
1152: if (x.Attribute("mgcIp") != null) ponGroup.MgcIp = x.Attribute("mgcIp").Value;
1153: else if (x.Parent.Attribute("mgcIp") != null) ponGroup.MgcIp = x.Parent.Attribute("mgcIp").Value;
1154: else if (x.Parent.Parent.Attribute("mgcIp") != null) ponGroup.MgcIp = x.Parent.Parent.Attribute("mgcIp").Value;
1155: else if (ponGroup.Olt.Name != "SAA-1" && (ponGroup.Olt.Name != "SDQ-1")) throw new ArgumentException(@"ponGroup.MgcIp could not be produced from XML document. ");
1156: // note that MgcIp need some special handling on the PON.ONT level
1157:
1158: #if DEBUG
1159: // GatewayIp number must be unique
1160: /*if (gatewayIpHashtable.ContainsKey(ponGroup.GatewayIp)) throw new ArgumentException(@"Lt.GatewayIp is not unique for LT under OLT name=" + ponGroup.Olt.Name + ". ");
1161: else*/
1162: gatewayIpHashtable[ponGroup.GatewayIp] = 1;
1163:
1164: // Id
1165: if (idHashtable.ContainsKey(ponGroup.Id)) throw new ArgumentException(@"ponGroup.Id is not unique for LT under OLT name=" + ponGroup.Olt.Name + ". ");
1166: else idHashtable[ponGroup.Id] = 1;
1167: #endif
1168: ponGroupList.Add(ponGroup);
1169: }
1170: }
1171: }
1172:
1173: return ponGroupList.ToList();
1174: }
1175: }
1176:
1177: ////////////////////////////////////////////////////////////////////////////
1178:
1179: /// <summary>
1180: ///
1181: /// </summary>
1182: public static List<Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Olt> OltList
1183: {
1184: get
1185: {
1186: if (oltList == null || oltList.Count == 0)
1187: {
1188: if (HttpContext.Current != null && HttpContext.Current.Application["oltList"] != null)
1189: {
1190: oltList = (List<Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Olt>)HttpContext.Current.Application["oltList"];
1191: }
1192: else
1193: {
1194: oltList = null;
1195: oltList = Ia.Ngn.Cl.Model.Data.NetworkDesignDocument._OltList;
1196:
1197: if (HttpContext.Current != null) HttpContext.Current.Application["oltList"] = oltList;
1198: }
1199: }
1200:
1201: return oltList;
1202: }
1203: }
1204:
1205: ////////////////////////////////////////////////////////////////////////////
1206:
1207: /// <summary>
1208: ///
1209: /// </summary>
1210: private static List<Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Olt> _OltList
1211: {
1212: get
1213: {
1214: if (oltList == null || oltList.Count == 0)
1215: {
1216: int networkId, siteId, routerId, odfId, id, i;
1217: Hashtable networkNumberHashtable;
1218: Ia.Ngn.Cl.Model.Data.NetworkDesignDocument.BellcoreState state;
1219: Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Olt olt;
1220:
1221: lock (objectLock)
1222: {
1223: oltList = new List<Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Olt>(100);
1224: networkNumberHashtable = new Hashtable();
1225:
1226: foreach (XElement x in XDocument.Element("networkDesignDocument").Elements("network").Elements("site").Elements("router").Elements("odf").Elements("olt"))
1227: {
1228: olt = new Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Olt();
1229: olt.Odf = new Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Odf();
1230: olt.Odf.Router = new Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Router();
1231: olt.Odf.Router.Site = new Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Site();
1232:
1233: networkId = int.Parse(x.Parent.Parent.Parent.Parent.Attribute("id").Value);
1234: siteId = int.Parse(x.Parent.Parent.Parent.Attribute("id").Value);
1235: routerId = int.Parse(x.Parent.Parent.Attribute("id").Value);
1236: odfId = int.Parse(x.Parent.Attribute("id").Value);
1237: id = int.Parse(x.Attribute("id").Value);
1238:
1239: siteId = olt.Odf.Router.Site.SiteId(networkId, siteId);
1240: routerId = olt.Odf.Router.RouterId(siteId, routerId);
1241: odfId = olt.Odf.OdfId(routerId, odfId);
1242: olt.Id = olt.OltId(odfId, id);
1243:
1244: olt.Odf = (from o in OdfList where o.Id == odfId select o).SingleOrDefault();
1245:
1246: olt.Name = x.Attribute("name").Value;
1247: olt.AmsName = x.Attribute("amsName").Value;
1248:
1249: if (x.Attribute("did") != null) olt.Did = int.Parse(x.Attribute("did").Value);
1250:
1251: olt.Type = x.Attribute("type").Value;
1252:
1253: if (x.Attribute("state") != null)
1254: {
1255: switch (x.Attribute("state").Value)
1256: {
1257: case "is-nr": state = Ia.Ngn.Cl.Model.Data.NetworkDesignDocument.BellcoreState.IsNr; break;
1258: case "oos-au": state = Ia.Ngn.Cl.Model.Data.NetworkDesignDocument.BellcoreState.OosAu; break;
1259: case "oos-ma": state = Ia.Ngn.Cl.Model.Data.NetworkDesignDocument.BellcoreState.OosMa; break;
1260: case "oos-auma": state = Ia.Ngn.Cl.Model.Data.NetworkDesignDocument.BellcoreState.OosAuma; break;
1261: default: state = Ia.Ngn.Cl.Model.Data.NetworkDesignDocument.BellcoreState.Undefined; break;
1262: }
1263: }
1264: else state = Ia.Ngn.Cl.Model.Data.NetworkDesignDocument.BellcoreState.Undefined;
1265:
1266: olt.StateId = (int)state;
1267:
1268: olt.IsSip = x.Attribute("isSip").Value == "true";
1269:
1270: if (olt.Odf.Vendor == Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Vendor.Nokia)
1271: {
1272: olt.Rack = 1;
1273: olt.Sub = 1;
1274: }
1275: else //if (olt.Odf.Vendor == Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Vendor.Huawei)
1276: {
1277: olt.Rack = 0;
1278: olt.Sub = 0;
1279: }
1280:
1281: if (x.Attribute("gatewayIp") != null) olt.GatewayIp = x.Attribute("gatewayIp").Value;
1282: else if (x.Parent.Attribute("gatewayIp") != null) olt.GatewayIp = x.Parent.Attribute("gatewayIp").Value;
1283: else olt.GatewayIp = string.Empty;
1284:
1285: if (x.Attribute("mgcIp") != null) olt.MgcIp = x.Attribute("mgcIp").Value;
1286: else if (x.Parent.Attribute("mgcIp") != null) olt.MgcIp = x.Parent.Attribute("mgcIp").Value;
1287: else olt.MgcIp = string.Empty;
1288:
1289: olt.Symbol = x.Attribute("symbol").Value;
1290:
1291: // below: the number of possible PONs differs between Nokia OLT types and Huawei
1292: if (olt.Odf.Vendor == Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Vendor.Nokia)
1293: {
1294: olt.NumberOfPonsPerLt = 16;
1295: olt.NumberOfOntsInPon = 32;
1296: olt.NumberOfFirstSlot = 1;
1297:
1298: if (olt.Type == "7342")
1299: {
1300: olt.NumberOfLts = 2;
1301: }
1302: else if (olt.Type == "7360")
1303: {
1304: olt.NumberOfLts = 16;
1305: }
1306: else
1307: {
1308: throw new ArgumentException(@"Nokia olt.Type unrecognized. ");
1309: }
1310: }
1311: else if (olt.Odf.Vendor == Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Vendor.Huawei)
1312: {
1313: olt.NumberOfLts = 2;
1314:
1315: if (olt.Type == "MA5600T")
1316: {
1317: olt.NumberOfPonsPerLt = 128;
1318: olt.NumberOfOntsInPon = 32;
1319: olt.NumberOfFirstSlot = 1;
1320: }
1321: else if (olt.Type == "MA5600T-temp")
1322: {
1323: olt.NumberOfPonsPerLt = 128 * 8;
1324: olt.NumberOfOntsInPon = 4;
1325: olt.NumberOfFirstSlot = 1;
1326: }
1327: else if (olt.Type == "MA5603T")
1328: {
1329: olt.NumberOfPonsPerLt = 128;
1330: olt.NumberOfOntsInPon = 32;
1331: olt.NumberOfFirstSlot = 0;
1332: }
1333: else
1334: {
1335: throw new ArgumentException(@"Huawei olt.Type unrecognized. ");
1336: }
1337: }
1338: else
1339: {
1340: throw new ArgumentException(@"olt.Odf.Vendor unrecognized. ");
1341: }
1342:
1343: olt.NumberOfPons = olt.NumberOfLts * olt.NumberOfPonsPerLt;
1344: #if DEBUG
1345: if ((olt.NumberOfPons * olt.NumberOfOntsInPon % 1024) != 0) throw new ArgumentException(@"(olt.NumberOfPons * olt.NumberOfOntsInPon % 1024) != 0");
1346: if (olt.NumberOfFirstSlot != 0 && olt.NumberOfFirstSlot != 1) throw new ArgumentException(@"olt.NumberOfFirstSlot == 0 || olt.NumberOfFirstSlot == 1");
1347: #endif
1348: oltList.Add(olt);
1349: }
1350: }
1351: }
1352:
1353: return oltList.ToList();
1354: }
1355: }
1356:
1357: ////////////////////////////////////////////////////////////////////////////
1358: ////////////////////////////////////////////////////////////////////////////
1359:
1360: /// <summary>
1361: ///
1362: /// </summary>
1363: public static List<Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Olt> NokiaOltList
1364: {
1365: get
1366: {
1367: return VendorOltList(Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Vendor.Nokia, 0);
1368: }
1369: }
1370:
1371: ////////////////////////////////////////////////////////////////////////////
1372:
1373: /// <summary>
1374: ///
1375: /// </summary>
1376: public static List<Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Olt> HuaweiOltList
1377: {
1378: get
1379: {
1380: return VendorOltList(Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Vendor.Huawei, 0);
1381: }
1382: }
1383:
1384: /*
1385: ////////////////////////////////////////////////////////////////////////////
1386:
1387: /// <summary>
1388: ///
1389: /// </summary>
1390: public static List<Ia.Ngn.Cl.Model.Data.NewNetworkDesignDocument.Olt> NokiaOltList(int siteId)
1391: {
1392: return VendorOltList("No", siteId);
1393: }
1394:
1395: ////////////////////////////////////////////////////////////////////////////
1396:
1397: /// <summary>
1398: ///
1399: /// </summary>
1400: public static List<Ia.Ngn.Cl.Model.Data.NewNetworkDesignDocument.Olt> HuaweiOltList(int siteId)
1401: {
1402: return VendorOltList("Hu", siteId);
1403: }
1404: */
1405:
1406: ////////////////////////////////////////////////////////////////////////////
1407:
1408: /// <summary>
1409: ///
1410: /// </summary>
1411: public static List<Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Olt> VendorOltList(Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Vendor vendor, int siteId)
1412: {
1413: List<Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Olt> list;
1414:
1415: list = (from o in Ia.Ngn.Cl.Model.Data.NetworkDesignDocument.OltList where o.Odf.Vendor == vendor && (o.Odf.Router.Site.Id == siteId || siteId == 0) select o).ToList();
1416:
1417: return list;
1418: }
1419:
1420: /*
1421: ////////////////////////////////////////////////////////////////////////////
1422:
1423: /// <summary>
1424: ///
1425: /// </summary>
1426: public static List<Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Olt> HuaweiOltTempList
1427: {
1428: get
1429: {
1430: List<Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Olt> list;
1431:
1432: list = (from o in Ia.Ngn.Cl.Model.Data.NetworkDesignDocument.OltList
1433: 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"
1434: select o).ToList();
1435:
1436: return list;
1437: }
1438: }
1439: */
1440:
1441: ////////////////////////////////////////////////////////////////////////////
1442:
1443: /// <summary>
1444: ///
1445: /// </summary>
1446: public static List<int> NokiaOltIdList()
1447: {
1448: return OltIdByVendorAndSiteIdList("No", 0);
1449: }
1450:
1451: ////////////////////////////////////////////////////////////////////////////
1452:
1453: /// <summary>
1454: ///
1455: /// </summary>
1456: public static List<int> NokiaOltIdList(int siteId)
1457: {
1458: return OltIdByVendorAndSiteIdList("No", siteId);
1459: }
1460:
1461: ////////////////////////////////////////////////////////////////////////////
1462:
1463: /// <summary>
1464: ///
1465: /// </summary>
1466: public static List<int> HuaweiOltIdList()
1467: {
1468: return OltIdByVendorAndSiteIdList("Hu", 0);
1469: }
1470:
1471: /*
1472: ////////////////////////////////////////////////////////////////////////////
1473:
1474: /// <summary>
1475: ///
1476: /// </summary>
1477: public static List<int> HuaweiOltIdTempList()
1478: {
1479: List<int> list;
1480:
1481: list = (from o in HuaweiOltTempList select o.Id).ToList();
1482:
1483: return list;
1484: }
1485: */
1486:
1487: ////////////////////////////////////////////////////////////////////////////
1488:
1489: /// <summary>
1490: ///
1491: /// </summary>
1492: public static List<int> HuaweiOltIdList(int siteId)
1493: {
1494: return OltIdByVendorAndSiteIdList("Hu", siteId);
1495: }
1496:
1497: ////////////////////////////////////////////////////////////////////////////
1498:
1499: /// <summary>
1500: ///
1501: /// </summary>
1502: public static List<int> OltIdByVendorAndSiteIdList(string vendorShortName, int siteId)
1503: {
1504: List<int> list;
1505:
1506: list = new List<int>();
1507:
1508: foreach (var olt in Ia.Ngn.Cl.Model.Data.NetworkDesignDocument.OltList)
1509: {
1510: // siteId 0 will return all sites
1511:
1512: if (olt.Odf.Vendor.ShortName == vendorShortName && (olt.Odf.Router.Site.Id == siteId || siteId == 0))
1513: {
1514: list.Add(olt.Id);
1515: }
1516: }
1517:
1518: return list;
1519: }
1520:
1521: ////////////////////////////////////////////////////////////////////////////
1522:
1523: /// <summary>
1524: ///
1525: /// </summary>
1526: public static List<int> OltIdList
1527: {
1528: get
1529: {
1530: List<int> list;
1531:
1532: list = (from o in Ia.Ngn.Cl.Model.Data.NetworkDesignDocument.OltList select o.Id).ToList();
1533:
1534: return list;
1535: }
1536: }
1537:
1538: ////////////////////////////////////////////////////////////////////////////
1539:
1540: /// <summary>
1541: ///
1542: /// </summary>
1543: public static Hashtable OltAmsNameToIdList
1544: {
1545: get
1546: {
1547: Hashtable ht;
1548:
1549: ht = new Hashtable(Ia.Ngn.Cl.Model.Data.NetworkDesignDocument.OltList.Count);
1550:
1551: foreach (Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Olt olt in Ia.Ngn.Cl.Model.Data.NetworkDesignDocument.OltList)
1552: {
1553: ht[olt.AmsName] = olt.Id;
1554: }
1555:
1556: return ht;
1557: }
1558: }
1559:
1560: ////////////////////////////////////////////////////////////////////////////
1561:
1562: /// <summary>
1563: ///
1564: /// </summary>
1565: public static Hashtable FirstPonNameInOltToOltIdList
1566: {
1567: get
1568: {
1569: Hashtable ht;
1570:
1571: ht = new Hashtable(Ia.Ngn.Cl.Model.Data.NetworkDesignDocument.OltList.Count);
1572:
1573: foreach (Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Olt olt in Ia.Ngn.Cl.Model.Data.NetworkDesignDocument.OltList)
1574: {
1575: foreach (Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.PonGroup ponGroup in olt.PonGroupList)
1576: {
1577: ht[ponGroup.PonList.First().Name] = olt.Id;
1578: }
1579: }
1580:
1581: return ht;
1582: }
1583: }
1584:
1585: ////////////////////////////////////////////////////////////////////////////
1586:
1587: /// <summary>
1588: ///
1589: /// </summary>
1590: public static Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Olt OltByEmsName(string emsName)
1591: {
1592: Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Olt olt;
1593:
1594: olt = (from o in Ia.Ngn.Cl.Model.Data.NetworkDesignDocument.OltList where o.EmsName == emsName select o).SingleOrDefault();
1595:
1596: return olt;
1597: }
1598:
1599: ////////////////////////////////////////////////////////////////////////////
1600:
1601: /// <summary>
1602: ///
1603: /// </summary>
1604: public static Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Olt OltByDid(int did)
1605: {
1606: Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Olt olt;
1607:
1608: olt = (from o in Ia.Ngn.Cl.Model.Data.NetworkDesignDocument.OltList where o.Did == did select o).SingleOrDefault();
1609:
1610: return olt;
1611: }
1612:
1613: /*
1614: ////////////////////////////////////////////////////////////////////////////
1615:
1616: /// <summary>
1617: ///
1618: /// </summary>
1619: public static Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Olt OltByDid(int did)
1620: {
1621: string emsName;
1622: Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Olt item;
1623:
1624: if (Ia.Ngn.Cl.Model.Data.Huawei.Ont.OltDidToEmsName.ContainsKey(did))
1625: {
1626: emsName = Ia.Ngn.Cl.Model.Data.Huawei.Ont.OltDidToEmsName[did];
1627:
1628: item = (from o in Ia.Ngn.Cl.Model.Data.NetworkDesignDocument.OltList where o.EmsName == emsName select o).SingleOrDefault();
1629: }
1630: else item = null;
1631:
1632: return item;
1633: }
1634: */
1635:
1636: /*
1637: ////////////////////////////////////////////////////////////////////////////
1638:
1639: /// <summary>
1640: ///
1641: /// </summary>
1642: public static int DidByOlt(Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Olt olt)
1643: {
1644: int did;
1645: string emsName;
1646:
1647: emsName = olt.EmsName;
1648:
1649: if (Ia.Ngn.Cl.Model.Data.Huawei.Ont.OltDidToEmsName.ContainsValue(emsName))
1650: {
1651: did = (from odem in Ia.Ngn.Cl.Model.Data.Huawei.Ont.OltDidToEmsName where odem.Value == emsName select odem.Key).SingleOrDefault();
1652: }
1653: else did = 0;
1654:
1655: return did;
1656: }
1657: */
1658:
1659: ////////////////////////////////////////////////////////////////////////////
1660:
1661: /// <summary>
1662: ///
1663: /// </summary>
1664: public static List<int> SipOltIdList
1665: {
1666: get
1667: {
1668: return (from o in Ia.Ngn.Cl.Model.Data.NetworkDesignDocument.OltList where o.IsSip == true select o.Id).ToList();
1669: }
1670: }
1671:
1672: ////////////////////////////////////////////////////////////////////////////
1673:
1674: /// <summary>
1675: ///
1676: /// </summary>
1677: public static List<string> IsNrNokiaOltAmsNameList
1678: {
1679: get
1680: {
1681: List<string> list;
1682:
1683: list = (from o in Ia.Ngn.Cl.Model.Data.NetworkDesignDocument.OltList
1684: where o.Odf.Vendor == Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Vendor.Nokia
1685: && o.StateId == (int)Ia.Ngn.Cl.Model.Data.NetworkDesignDocument.BellcoreState.IsNr
1686: select o.AmsName).ToList();
1687:
1688: return list;
1689: }
1690: }
1691:
1692: ////////////////////////////////////////////////////////////////////////////
1693:
1694: /// <summary>
1695: ///
1696: /// </summary>
1697: public static List<string> IsNrHuaweiOltAmsNameList
1698: {
1699: get
1700: {
1701: List<string> list;
1702:
1703: list = (from o in Ia.Ngn.Cl.Model.Data.NetworkDesignDocument.OltList
1704: where o.Odf.Vendor == Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Vendor.Huawei
1705: && o.StateId == (int)Ia.Ngn.Cl.Model.Data.NetworkDesignDocument.BellcoreState.IsNr
1706: select o.AmsName).ToList();
1707:
1708: return list;
1709: }
1710: }
1711:
1712: ////////////////////////////////////////////////////////////////////////////
1713:
1714: /// <summary>
1715: ///
1716: /// </summary>
1717: public static List<Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Odf> OdfList
1718: {
1719: get
1720: {
1721: if (odfList == null || odfList.Count == 0)
1722: {
1723: if (HttpContext.Current != null && HttpContext.Current.Application["odfList"] != null)
1724: {
1725: odfList = (List<Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Odf>)HttpContext.Current.Application["odfList"];
1726: }
1727: else
1728: {
1729: odfList = null;
1730: odfList = Ia.Ngn.Cl.Model.Data.NetworkDesignDocument._OdfList;
1731:
1732: if (HttpContext.Current != null) HttpContext.Current.Application["odfList"] = odfList;
1733: }
1734: }
1735:
1736: return odfList;
1737: }
1738: }
1739:
1740: ////////////////////////////////////////////////////////////////////////////
1741:
1742: /// <summary>
1743: ///
1744: /// </summary>
1745: private static List<Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Odf> _OdfList
1746: {
1747: get
1748: {
1749: if (odfList == null || odfList.Count == 0)
1750: {
1751: int networkId, siteId, routerId, id;
1752: string vendorShortName;
1753: Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Odf odf;
1754:
1755: lock (objectLock)
1756: {
1757: odfList = new List<Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Odf>();
1758:
1759: foreach (XElement x in XDocument.Element("networkDesignDocument").Element("network").Elements("site").Elements("router").Elements("odf"))
1760: {
1761: odf = new Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Odf();
1762: odf.Router = new Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Router();
1763: odf.Router.Site = new Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Site();
1764:
1765: networkId = int.Parse(x.Parent.Parent.Parent.Attribute("id").Value);
1766: siteId = int.Parse(x.Parent.Parent.Attribute("id").Value);
1767: routerId = int.Parse(x.Parent.Attribute("id").Value);
1768: id = int.Parse(x.Attribute("id").Value);
1769:
1770: siteId = odf.Router.Site.SiteId(networkId, siteId);
1771: routerId = odf.Router.RouterId(siteId, routerId);
1772: odf.Id = odf.OdfId(routerId, id);
1773:
1774: odf.Name = x.Attribute("name").Value;
1775:
1776: odf.GatewayIp = (x.Attribute("gatewayIp") != null) ? x.Attribute("gatewayIp").Value : string.Empty;
1777: odf.MgcIp = (x.Attribute("mgcIp") != null) ? x.Attribute("mgcIp").Value : string.Empty;
1778:
1779: vendorShortName = x.Attribute("vendorShortName").Value;
1780: odf.Vendor = (from v in Ia.Ngn.Cl.Model.Data.NetworkDesignDocument.VendorList where v.ShortName == vendorShortName select v).SingleOrDefault();
1781:
1782: odf.Router = (from r in RouterList where r.Id == routerId select r).SingleOrDefault();
1783:
1784: odfList.Add(odf);
1785: }
1786: }
1787: }
1788:
1789: return odfList.ToList();
1790: }
1791: }
1792:
1793: ////////////////////////////////////////////////////////////////////////////
1794:
1795: /// <summary>
1796: ///
1797: /// </summary>
1798: public static List<Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Oam> OamList
1799: {
1800: get
1801: {
1802: if (oamList == null || oamList.Count == 0)
1803: {
1804: if (HttpContext.Current != null && HttpContext.Current.Application["oamList"] != null)
1805: {
1806: oamList = (List<Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Oam>)HttpContext.Current.Application["oamList"];
1807: }
1808: else
1809: {
1810: oamList = null;
1811: oamList = Ia.Ngn.Cl.Model.Data.NetworkDesignDocument._OamList;
1812:
1813: if (HttpContext.Current != null) HttpContext.Current.Application["oamList"] = oamList;
1814: }
1815: }
1816:
1817: return oamList;
1818: }
1819: }
1820:
1821: ////////////////////////////////////////////////////////////////////////////
1822:
1823: /// <summary>
1824: ///
1825: /// </summary>
1826: private static List<Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Oam> _OamList
1827: {
1828: get
1829: {
1830: if (oamList == null || oamList.Count == 0)
1831: {
1832: int networkId, siteId, routerId, id;
1833: Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Oam oam;
1834:
1835: lock (objectLock)
1836: {
1837: oamList = new List<Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Oam>();
1838:
1839: foreach (XElement x in XDocument.Element("networkDesignDocument").Element("network").Elements("site").Elements("router").Elements("oam"))
1840: {
1841: oam = new Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Oam();
1842: oam.Router = new Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Router();
1843: oam.Router.Site = new Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Site();
1844:
1845: networkId = int.Parse(x.Parent.Parent.Parent.Attribute("id").Value);
1846: siteId = int.Parse(x.Parent.Parent.Attribute("id").Value);
1847: routerId = int.Parse(x.Parent.Attribute("id").Value);
1848: id = int.Parse(x.Attribute("id").Value);
1849:
1850: siteId = oam.Router.Site.SiteId(networkId, siteId);
1851: routerId = oam.Router.RouterId(siteId, routerId);
1852: oam.Id = oam.OamId(routerId, id);
1853:
1854: oam.Network = x.Attribute("network").Value;
1855: oam.Gateway = x.Attribute("gateway").Value;
1856: oam.Vlan = int.Parse(x.Attribute("vlan").Value);
1857: oam.Vpls = int.Parse(x.Attribute("vpls").Value);
1858: oam.FtpIp = x.Attribute("ftpIp").Value;
1859: oam.ConfigFile = x.Attribute("configFile").Value;
1860:
1861: oam.Router = (from r in RouterList where r.Id == routerId select r).SingleOrDefault();
1862:
1863: oamList.Add(oam);
1864: }
1865: }
1866: }
1867:
1868: return oamList.ToList();
1869: }
1870: }
1871:
1872: ////////////////////////////////////////////////////////////////////////////
1873:
1874: /// <summary>
1875: /// Return router (switch) vendor from service number
1876: /// </summary>
1877: public static Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Vendor SwitchVendorFromService(string service)
1878: {
1879: Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Vendor switchVendor;
1880:
1881: if (int.TryParse(service, out int i))
1882: {
1883: 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();
1884:
1885: if (switchVendor == null) switchVendor = Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Vendor.Undefined;
1886: }
1887: else switchVendor = Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Vendor.Undefined;
1888:
1889: return switchVendor;
1890: }
1891:
1892: ////////////////////////////////////////////////////////////////////////////
1893:
1894: /// <summary>
1895: ///
1896: /// </summary>
1897: public static List<Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Router> RouterList
1898: {
1899: get
1900: {
1901: if (routerList == null || routerList.Count == 0)
1902: {
1903: if (HttpContext.Current != null && HttpContext.Current.Application["routerList"] != null)
1904: {
1905: routerList = (List<Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Router>)HttpContext.Current.Application["routerList"];
1906: }
1907: else
1908: {
1909: routerList = null;
1910: routerList = Ia.Ngn.Cl.Model.Data.NetworkDesignDocument._RouterList;
1911:
1912: if (HttpContext.Current != null) HttpContext.Current.Application["routerList"] = routerList;
1913: }
1914: }
1915:
1916: return routerList;
1917: }
1918: }
1919:
1920: ////////////////////////////////////////////////////////////////////////////
1921:
1922: /// <summary>
1923: ///
1924: /// </summary>
1925: private static List<Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Router> _RouterList
1926: {
1927: get
1928: {
1929: if (routerList == null || routerList.Count == 0)
1930: {
1931: int networkId, siteId, id;
1932: string vendorShortName;
1933: #if DEBUG
1934: //Dictionary<int, int> domainDictionary;
1935: #endif
1936: Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Router router;
1937:
1938: lock (objectLock)
1939: {
1940: #if DEBUG
1941: //domainDictionary = new Dictionary<int, int>(100);
1942: #endif
1943: routerList = new List<Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Router>();
1944:
1945: foreach (XElement x in XDocument.Element("networkDesignDocument").Element("network").Elements("site").Elements("router"))
1946: {
1947: router = new Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Router();
1948: router.Site = new Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Site();
1949:
1950: networkId = int.Parse(x.Parent.Parent.Attribute("id").Value);
1951: siteId = int.Parse(x.Parent.Attribute("id").Value);
1952: id = int.Parse(x.Attribute("id").Value);
1953:
1954: siteId = router.Site.SiteId(networkId, siteId);
1955: router.Id = router.RouterId(siteId, id);
1956: router.Name = x.Attribute("name").Value;
1957:
1958: router.DomainListString = x.Attribute("domainList").Value;
1959:
1960: router.DomainList = Ia.Cl.Model.Default.CommaSeperatedNumberStringToNumberList(router.DomainListString);
1961:
1962: #if DEBUG
1963: /*
1964: foreach (int i in router.DomainList)
1965: {
1966: // this will throw an exception if there are similar domains in routers
1967: if (domainDictionary.ContainsKey(i))
1968: {
1969: throw new ArgumentOutOfRangeException(@"domainDictionary.ContainsKey(" + i + ")");
1970: }
1971: else domainDictionary[i] = 1;
1972: }
1973: */
1974: #endif
1975:
1976: vendorShortName = x.Attribute("vendorShortName").Value;
1977: router.Vendor = (from v in Ia.Ngn.Cl.Model.Data.NetworkDesignDocument.VendorList where v.ShortName == vendorShortName select v).SingleOrDefault();
1978:
1979: router.Site = (from s in SiteList where s.Id == siteId select s).SingleOrDefault();
1980:
1981: routerList.Add(router);
1982: }
1983: }
1984: }
1985:
1986: return routerList.ToList();
1987: }
1988: }
1989:
1990: ////////////////////////////////////////////////////////////////////////////
1991:
1992: /// <summary>
1993: ///
1994: /// </summary>
1995: public static List<Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Site> SiteList
1996: {
1997: get
1998: {
1999: if (siteList == null || siteList.Count == 0)
2000: {
2001: if (HttpContext.Current != null && HttpContext.Current.Application["siteList"] != null)
2002: {
2003: siteList = (List<Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Site>)HttpContext.Current.Application["siteList"];
2004: }
2005: else
2006: {
2007: siteList = null;
2008: siteList = Ia.Ngn.Cl.Model.Data.NetworkDesignDocument._SiteList;
2009:
2010: if (HttpContext.Current != null) HttpContext.Current.Application["siteList"] = siteList;
2011: }
2012: }
2013:
2014: return siteList;
2015: }
2016: }
2017:
2018: ////////////////////////////////////////////////////////////////////////////
2019:
2020: /// <summary>
2021: ///
2022: /// </summary>
2023: private static List<Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Site> _SiteList
2024: {
2025: get
2026: {
2027: if (siteList == null || siteList.Count == 0)
2028: {
2029: int networkId, id;
2030: Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Site site;
2031:
2032: lock (objectLock)
2033: {
2034: siteList = new List<Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Site>();
2035:
2036: foreach (XElement x in XDocument.Element("networkDesignDocument").Element("network").Elements("site"))
2037: {
2038: site = new Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Site();
2039: networkId = int.Parse(x.Parent.Attribute("id").Value);
2040: id = int.Parse(x.Attribute("id").Value);
2041:
2042: site.Id = site.SiteId(networkId, id);
2043: site.Name = x.Attribute("name").Value;
2044: site.ArabicName = x.Attribute("arabicName").Value;
2045: site.AreaSymbolList = x.Attribute("areaSymbolList").Value.Split(',').ToList();
2046:
2047: site.Network = (from n in NetworkList where n.Id == networkId select n).SingleOrDefault();
2048:
2049: siteList.Add(site);
2050: }
2051: }
2052: }
2053:
2054: return siteList.ToList();
2055: }
2056: }
2057:
2058: ////////////////////////////////////////////////////////////////////////////
2059:
2060: /// <summary>
2061: ///
2062: /// </summary>
2063: public static List<Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Network> NetworkList
2064: {
2065: get
2066: {
2067: if (networkList == null || networkList.Count == 0)
2068: {
2069: networkList = new List<Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Network>
2070: {
2071: new Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Network(1, "Next Generation Network")
2072: };
2073: }
2074:
2075: return networkList.ToList();
2076: }
2077: }
2078:
2079: ////////////////////////////////////////////////////////////////////////////
2080:
2081: /// <summary>
2082: ///
2083: /// </summary>
2084: public static List<Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Vendor> VendorList
2085: {
2086: get
2087: {
2088: if (vendorList == null || vendorList.Count == 0)
2089: {
2090: vendorList = new List<Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Vendor>();
2091:
2092: vendorList.Add(new Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Vendor(0, "Undefined", "Un", "غير معرف", @"~\image\undefined.png"));
2093: vendorList.Add(new Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Vendor(1, "Nokia", "No", "نوكيا", @"~\image\nokia-icon.png"));
2094: vendorList.Add(new Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Vendor(2, "Huawei", "Hu", "هواوي", @"~\image\huawei-icon.png"));
2095: }
2096:
2097: return vendorList.ToList();
2098: }
2099: }
2100:
2101: ////////////////////////////////////////////////////////////////////////////
2102:
2103: /// <summary>
2104: ///
2105: /// </summary>
2106: public static string AmsNameFromOltId(int oltId)
2107: {
2108: string amsName;
2109:
2110: try
2111: {
2112: amsName = (from o in OltList where o.Id == oltId select o.AmsName).FirstOrDefault();
2113: }
2114: catch (Exception)
2115: {
2116: amsName = null;
2117: }
2118:
2119: return amsName;
2120: }
2121:
2122: ////////////////////////////////////////////////////////////////////////////
2123:
2124: /// <summary>
2125: ///
2126: /// </summary>
2127: public static bool CheckIntegrityOfOntList()
2128: {
2129: bool isValid;
2130: string v;
2131: Dictionary<string, string> dic, a, b;
2132:
2133: dic = Ia.Ngn.Cl.Model.Data.NetworkDesignDocument.OntIdToOntAccessNameDictionary;
2134: a = new Dictionary<string, string>();
2135: b = new Dictionary<string, string>();
2136:
2137: isValid = true;
2138:
2139: foreach (string s in dic.Keys)
2140: {
2141: v = dic[s];
2142:
2143: if (!a.ContainsKey(v)) a[v] = "1";
2144: else if (a.ContainsKey(v))
2145: {
2146: if (!v.Contains("RSL"))
2147: {
2148: b[v] = "1";
2149: isValid = false;
2150: }
2151: }
2152: }
2153:
2154: return isValid;
2155: }
2156:
2157: ////////////////////////////////////////////////////////////////////////////
2158: ////////////////////////////////////////////////////////////////////////////
2159:
2160: /// <summary>
2161: ///
2162: /// How to embed and access resources by using Visual C# http://support.microsoft.com/kb/319292/en-us
2163: ///
2164: /// 1. Change the "Build Action" property of your XML file from "Content" to "Embedded Resource".
2165: /// 2. Add "using System.Reflection".
2166: /// 3. See sample below.
2167: ///
2168: /// </summary>
2169:
2170: private static XDocument XDocument
2171: {
2172: get
2173: {
2174: if (xDocument == null)
2175: {
2176: Assembly _assembly;
2177: StreamReader streamReader;
2178:
2179: _assembly = Assembly.GetExecutingAssembly();
2180: streamReader = new StreamReader(_assembly.GetManifestResourceStream("Ia.Ngn.Cl.model.data.network-design-document.xml"));
2181:
2182: try
2183: {
2184: if (streamReader.Peek() != -1)
2185: {
2186: xDocument = System.Xml.Linq.XDocument.Load(streamReader);
2187: }
2188: }
2189: catch (Exception)
2190: {
2191: }
2192: finally
2193: {
2194: }
2195: }
2196:
2197: return xDocument;
2198: }
2199: }
2200:
2201: ////////////////////////////////////////////////////////////////////////////
2202: ////////////////////////////////////////////////////////////////////////////
2203: }
2204: }