1: using System;
2: using System.Collections.Generic;
3: using System.Data;
4: using System.Linq;
5: using System.Text;
6:
7: namespace Ia.Ngn.Cl.Model.Business
8: {
9: ////////////////////////////////////////////////////////////////////////////
10:
11: /// <summary publish="true">
12: /// Network Design Document support class for Next Generation Network (NGN) business model.
13: /// </summary>
14: ///
15: /// <remarks>
16: /// Copyright © 2006-2019 Jasem Y. Al-Shamlan (info@ia.com.kw), Integrated Applications - Kuwait. All Rights Reserved.
17: ///
18: /// 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
19: /// the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
20: ///
21: /// This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
22: /// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
23: ///
24: /// You should have received a copy of the GNU General Public License along with this library. If not, see http://www.gnu.org/licenses.
25: ///
26: /// Copyright notice: This notice may not be removed or altered from any source distribution.
27: /// </remarks>
28: public partial class NetworkDesignDocument
29: {
30: public const int PrecautionaryHardCodedNumberOfOntRecords = 223320;
31:
32: public enum FieldType { Green = 1, Brown = 2 };
33:
34: public enum PstnExchangeType { EricssonAxe = 1, SiemensEwsd = 2 };
35:
36: ////////////////////////////////////////////////////////////////////////////
37:
38: /// <summary>
39: ///
40: /// </summary>
41: public NetworkDesignDocument() { }
42:
43: ////////////////////////////////////////////////////////////////////////////
44:
45: /// <summary>
46: ///
47: /// </summary>
48: public static string FieldTypeColoredString(Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.FieldType fieldType)
49: {
50: string fieldTypeColoredString;
51:
52: switch (fieldType)
53: {
54: case FieldType.Green: fieldTypeColoredString = "<span style=\"color:green\">Green</span>"; break;
55: case FieldType.Brown: fieldTypeColoredString = "<span style=\"color:brown\">Brown</span>"; break;
56: default: fieldTypeColoredString = string.Empty; break;
57: }
58:
59: return fieldTypeColoredString;
60: }
61:
62: ////////////////////////////////////////////////////////////////////////////
63:
64: /// <summary>
65: ///
66: /// </summary>
67: public static string FieldTypeString(Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.FieldType fieldType)
68: {
69: string fieldTypeColoredString;
70:
71: switch (fieldType)
72: {
73: case FieldType.Green: fieldTypeColoredString = "Green"; break;
74: case FieldType.Brown: fieldTypeColoredString = "Brown"; break;
75: default: fieldTypeColoredString = string.Empty; break;
76: }
77:
78: return fieldTypeColoredString;
79: }
80:
81: ////////////////////////////////////////////////////////////////////////////
82:
83: /// <summary>
84: ///
85: /// </summary>
86: public class Vendor
87: {
88: public int Id { get; set; }
89: public string Name { get; set; }
90: public string ShortName { get; set; }
91: public string ArabicName { get; set; }
92: public string ImageUrl { get; set; }
93:
94: public Vendor(int id, string name, string shortName, string arabicName, string imageUrl)
95: {
96: this.Id = id;
97: this.Name = name;
98: this.ShortName = shortName;
99: this.ArabicName = arabicName;
100: this.ImageUrl = imageUrl;
101: }
102:
103: public virtual ICollection<Router> Routers
104: {
105: get
106: {
107: return (from r in Ia.Ngn.Cl.Model.Data.NetworkDesignDocument.RouterList where r.Vendor == this select r).ToList();
108: }
109: }
110:
111: public virtual ICollection<Odf> Odfs
112: {
113: get
114: {
115: return (from o in Ia.Ngn.Cl.Model.Data.NetworkDesignDocument.OdfList where o.Vendor == this select o).ToList();
116: }
117: }
118:
119: public static Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Vendor Nokia
120: {
121: get
122: {
123: return (from v in Ia.Ngn.Cl.Model.Data.NetworkDesignDocument.VendorList where v.ShortName == "No" select v).Single();
124: }
125: }
126:
127: public static Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Vendor Huawei
128: {
129: get
130: {
131: return (from v in Ia.Ngn.Cl.Model.Data.NetworkDesignDocument.VendorList where v.ShortName == "Hu" select v).Single();
132: }
133: }
134:
135: public static Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Vendor Ericsson
136: {
137: get
138: {
139: return (from v in Ia.Ngn.Cl.Model.Data.NetworkDesignDocument.VendorList where v.ShortName == "Er" select v).Single();
140: }
141: }
142:
143: public static Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Vendor Siemens
144: {
145: get
146: {
147: return (from v in Ia.Ngn.Cl.Model.Data.NetworkDesignDocument.VendorList where v.ShortName == "Si" select v).Single();
148: }
149: }
150:
151: public static Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Vendor Undefined
152: {
153: get
154: {
155: return (from v in Ia.Ngn.Cl.Model.Data.NetworkDesignDocument.VendorList where v.ShortName == "Un" select v).Single();
156: }
157: }
158:
159: ////////////////////////////////////////////////////////////////////////////
160:
161: /// <summary>
162: ///
163: /// </summary>
164: public static string VendorNameFromId(int id)
165: {
166: return (from v in Ia.Ngn.Cl.Model.Data.NetworkDesignDocument.VendorList where v.Id == id select v.Name).SingleOrDefault();
167: }
168:
169: ////////////////////////////////////////////////////////////////////////////
170:
171: /// <summary>
172: ///
173: /// </summary>
174: public static int VendorIdFromName(string name)
175: {
176: int id;
177:
178: switch (name)
179: {
180: case "Nokia": id = 1; break;
181: case "ALCL": id = 1; break;
182: case "Huawei": id = 2; break;
183: case "Nokia-Siemens": id = 3; break;
184: default: id = 0; break;
185: }
186:
187: return id;
188: }
189:
190: ////////////////////////////////////////////////////////////////////////////
191: ////////////////////////////////////////////////////////////////////////////
192: }
193:
194: ////////////////////////////////////////////////////////////////////////////
195:
196: /// <summary>
197: ///
198: /// </summary>
199: public class Network
200: {
201: public int Id { get; set; }
202: public string Name { get; set; }
203:
204: public Network(int id, string name)
205: {
206: this.Id = id;
207: this.Name = name;
208: }
209:
210: public virtual ICollection<Site> Sites
211: {
212: get
213: {
214: return (from s in Ia.Ngn.Cl.Model.Data.NetworkDesignDocument.SiteList where s.Network == this select s).ToList();
215: }
216: }
217: }
218:
219: ////////////////////////////////////////////////////////////////////////////
220:
221: /// <summary>
222: ///
223: /// </summary>
224: public class Site
225: {
226: public Site() { }
227:
228: public int Id { get; set; }
229: public string Name { get; set; }
230: public string ArabicName { get; set; }
231: public string NameArabicName
232: {
233: get
234: {
235: return Name + " (" + ArabicName + ")";
236: }
237: }
238: public List<string> AreaSymbolList { get; set; }
239: public virtual Network Network { get; set; }
240:
241: public virtual ICollection<Pstn> Pstns
242: {
243: get
244: {
245: return (from p in Ia.Ngn.Cl.Model.Data.NetworkDesignDocument.PstnList where p.Site == this select p).ToList();
246: }
247: }
248:
249: public virtual ICollection<Router> Routers
250: {
251: get
252: {
253: return (from r in Ia.Ngn.Cl.Model.Data.NetworkDesignDocument.RouterList where r.Site == this select r).ToList();
254: }
255: }
256:
257: public virtual ICollection<Ia.Ngn.Cl.Model.Business.Service.KuwaitNgnArea> KuwaitNgnAreas
258: {
259: get
260: {
261: ICollection<Ia.Ngn.Cl.Model.Business.Service.KuwaitNgnArea> ic;
262:
263: ic = (from kna in Ia.Ngn.Cl.Model.Data.Service.KuwaitNgnAreaList where this.AreaSymbolList.Contains(kna.Symbol) select kna).ToList();
264:
265: return ic;
266: }
267: }
268:
269: public List<int> DomainList
270: {
271: get
272: {
273: var siteRouterDomainList = (from r in Ia.Ngn.Cl.Model.Data.NetworkDesignDocument.RouterList where r.Site.Id == this.Id select r).SelectMany(z => z.DomainList).ToList();
274:
275: return siteRouterDomainList;
276: }
277: }
278:
279: public int NumberOfPossibleServicesWithinDomainList
280: {
281: get
282: {
283: return Ia.Ngn.Cl.Model.Data.Service.NumberOfPossibleServicesWithinDomainList(this.DomainList);
284: }
285: }
286:
287: public int SiteId(int networkId, int siteId)
288: {
289: return networkId * 100 + siteId;
290: }
291: }
292:
293: ////////////////////////////////////////////////////////////////////////////
294:
295: /// <summary>
296: ///
297: /// </summary>
298: public class Pstn
299: {
300: public Pstn() { }
301:
302: public int Id { get; set; }
303: public string Name { get; set; }
304: public PstnExchangeType PstnExchangeType { get; set; }
305: public bool UsesLnpServer { get; set; }
306: public string DomainListString { get; set; }
307: public List<int> DomainList { get; set; }
308: public virtual Site Site { get; set; }
309:
310: public int PstnId(int siteId, int pstnId)
311: {
312: return siteId * 100 + pstnId;
313: }
314: }
315:
316:
317: ////////////////////////////////////////////////////////////////////////////
318:
319: /// <summary>
320: ///
321: /// </summary>
322: public class Router
323: {
324: public Router() { }
325:
326: public int Id { get; set; }
327: public string Name { get; set; }
328: public string DomainListString { get; set; }
329: public List<int> DomainList { get; set; }
330: public virtual Vendor Vendor { get; set; }
331: public virtual Site Site { get; set; }
332: public virtual ICollection<Oam> Oams
333: {
334: get
335: {
336: return (from r in Ia.Ngn.Cl.Model.Data.NetworkDesignDocument.OamList where r.Router == this select r).ToList();
337: }
338: }
339:
340: public virtual ICollection<Odf> Odfs
341: {
342: get
343: {
344: return (from o in Ia.Ngn.Cl.Model.Data.NetworkDesignDocument.OdfList where o.Router == this select o).ToList();
345: }
346: }
347:
348: public int RouterId(int siteId, int routerId)
349: {
350: return siteId * 100 + routerId;
351: }
352: }
353:
354: ////////////////////////////////////////////////////////////////////////////
355:
356: /// <summary>
357: ///
358: /// </summary>
359: public class Oam
360: {
361: public Oam() { }
362:
363: public int Id { get; set; }
364: public string Network { get; set; }
365: public string Gateway { get; set; }
366: public int Vlan { get; set; }
367: public int Vpls { get; set; }
368: public string FtpIp { get; set; }
369: public string ConfigFile { get; set; }
370: public virtual Router Router { get; set; }
371:
372: public int OamId(int routerId, int oamId)
373: {
374: return routerId * 100 + oamId;
375: }
376: }
377:
378: ////////////////////////////////////////////////////////////////////////////
379:
380: /// <summary>
381: ///
382: /// </summary>
383: public class Odf
384: {
385: public Odf() { }
386:
387: public int Id { get; set; }
388: public string Name { get; set; }
389: public string GatewayIp { get; set; }
390: public string MgcIp { get; set; }
391: public virtual Vendor Vendor { get; set; }
392: public virtual Router Router { get; set; }
393: public virtual ICollection<Olt> Olts
394: {
395: get
396: {
397: return (from o in Ia.Ngn.Cl.Model.Data.NetworkDesignDocument.OltList where o.Odf == this select o).ToList();
398: }
399: }
400:
401: public int OdfId(int routerId, int odfId)
402: {
403: return routerId * 100 + odfId;
404: }
405: }
406:
407: ////////////////////////////////////////////////////////////////////////////
408:
409: /// <summary>
410: ///
411: /// </summary>
412: public class Olt
413: {
414: public Olt() { }
415:
416: public int Id { get; set; }
417: public string Type { get; set; }
418: public int StateId { get; set; }
419: public bool IsSip { get; set; }
420: public int Rack { get; set; }
421: public int Sub { get; set; }
422: public string GatewayIp { get; set; }
423: public string MgcIp { get; set; }
424: public string Name { get; set; }
425: public string AmsName { get; set; }
426: public string EmsName
427: {
428: get
429: {
430: return this.AmsName;
431: }
432:
433: set
434: {
435: this.AmsName = value;
436: }
437: }
438: public int Did { get; set; }
439: public Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.FieldType FieldType { get; set; }
440: public string Symbol { get; set; }
441: public int NumberOfLts { get; set; }
442: public int NumberOfPonsPerLt { get; set; }
443: public int NumberOfPons { get; set; }
444: public int NumberOfOntsInPon { get; set; }
445: public int NumberOfFirstSlot { get; set; }
446: public virtual Odf Odf { get; set; }
447: public virtual ICollection<Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.PonGroup> PonGroupList
448: {
449: get
450: {
451: return (from l in Ia.Ngn.Cl.Model.Data.NetworkDesignDocument.PonGroupList where l.Olt == this select l).ToList();
452: }
453: }
454:
455: public int OltId(int odfId, int oltId)
456: {
457: return odfId * 100 + oltId;
458: }
459: }
460:
461: ////////////////////////////////////////////////////////////////////////////
462:
463: /// <summary>
464: ///
465: /// </summary>
466: public class PonGroup
467: {
468: public PonGroup() { }
469:
470: public long Id { get; set; }
471: public string Symbol { get; set; }
472: public int Number { get; set; }
473: public string PonListString { get; set; }
474: public string ProposedPonListString { get; set; }
475: public List<int> UsedPonInPonGroupList { get; set; }
476: public List<int> UsedProposedPonInPonGroupList { get; set; }
477: public string NetworkNumber { get; set; }
478: public string GatewayIp { get; set; }
479: public string MgcIp { get; set; }
480: public virtual Olt Olt { get; set; }
481: public virtual ICollection<Pon> PonList
482: {
483: get
484: {
485: return (from p in Ia.Ngn.Cl.Model.Data.NetworkDesignDocument.PonList where p.PonGroup == this select p).ToList();
486: }
487: }
488:
489: public bool HasNewProposedPonList
490: {
491: get
492: {
493: return !string.IsNullOrEmpty(this.ProposedPonListString) && this.ProposedPonListString != this.PonListString;
494: }
495: }
496:
497: public long PonGroupId(int oltId, int ponGroupId)
498: {
499: return (long)oltId * 100 + ponGroupId;
500: }
501: }
502:
503: ////////////////////////////////////////////////////////////////////////////
504:
505: /// <summary>
506: ///
507: /// </summary>
508: public class Pon
509: {
510: private const int FixedLengthOfId = 14;
511:
512: public Pon() { }
513:
514: public string Id { get; set; }
515: public int Index { get; set; }
516: public int PonGroupPonIndex { get; set; }
517: public int Rack { get; set; }
518: public int Sub { get; set; }
519: public int CardSlot { get; set; }
520: public int Port { get; set; }
521: public int Number { get; set; }
522: public int ProposedNumber { get; set; }
523: public string Position { get; set; }
524: public string Name { get; set; }
525: public string ProposedName { get; set; }
526: public virtual PonGroup PonGroup { get; set; }
527: public virtual ICollection<Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Ont> OntList
528: {
529: get
530: {
531: return (from o in Ia.Ngn.Cl.Model.Data.NetworkDesignDocument.OntList where o.Pon == this select o).ToList();
532: }
533: }
534:
535: public string PonId(int oltId, int oltPonIndex)
536: {
537: string id;
538:
539: // "01" to indicate PonGroup 1. This is the case in almost all PONs. I will remove 01 later
540: id = oltId.ToString() + "01" + oltPonIndex.ToString().PadLeft(3, '0');
541:
542: if (id.Length != FixedLengthOfId)
543: {
544: throw new ArgumentOutOfRangeException(@"PonId(): Id length is not " + FixedLengthOfId);
545: }
546:
547: return id;
548: }
549:
550: public string RxSxLtxPonx
551: {
552: get
553: {
554: int ltNumber, ponNumber;
555: string rxSxLtxPonx;
556:
557: ltNumber = this.Number / this.PonGroup.Olt.NumberOfPonsPerLt + 1;
558: ponNumber = this.Number - (ltNumber - 1) * this.PonGroup.Olt.NumberOfPonsPerLt;
559:
560: rxSxLtxPonx = "R1.S1.LT" + ltNumber + ".PON" + ponNumber;
561:
562: //rxSxLtxPonx = "R1.S1.LT7.PON1";
563:
564: return rxSxLtxPonx;
565: }
566: }
567: }
568:
569: ////////////////////////////////////////////////////////////////////////////
570:
571: /// <summary>
572: ///
573: /// </summary>
574: public class Ont
575: {
576: public Ont() { }
577:
578: public string Id { get; set; }
579: public int Rack { get; set; }
580: public int Sub { get; set; }
581: public int CardSlot { get; set; }
582: public int Port { get; set; }
583: public int Number { get; set; }
584: public int InternalNumber { get; set; }
585: public string Position { get; set; }
586: public string Ip { get; set; }
587:
588: public Ia.Ngn.Cl.Model.Business.Ims.ImsBasicService ImsBasicService { get; set; }
589:
590: public string MgcIp
591: {
592: get
593: {
594: return ImsBasicService.MgcIp;
595: }
596: }
597: public string MgcSecondaryIp
598: {
599: get
600: {
601: return ImsBasicService.MgcSecondaryIp;
602: }
603: }
604: public string MgcSubnetMask
605: {
606: get
607: {
608: return ImsBasicService.MgcSubnetMask;
609: }
610: }
611: public int ImsService
612: {
613: get
614: {
615: return ImsBasicService.Service;
616: }
617: }
618: public string ImsFsdb
619: {
620: get
621: {
622: return ImsBasicService.Fsdb;
623: }
624: }
625: public string PrimarySwitch
626: {
627: get
628: {
629: return ImsBasicService.PrimarySwitch;
630: }
631: }
632:
633: public virtual Pon Pon { get; set; }
634: public virtual Access Access { get; set; }
635:
636: ////////////////////////////////////////////////////////////////////////////
637:
638: /// <summary>
639: ///
640: /// </summary>
641: public string ToSimpleTextString()
642: {
643: StringBuilder sb;
644: Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Vendor switchVendor, accessVendor;
645:
646: sb = new StringBuilder();
647:
648: switchVendor = (from o in Ia.Ngn.Cl.Model.Data.NetworkDesignDocument.OntList where o.Id == this.Id select o.Pon.PonGroup.Olt.Odf.Router.Vendor).SingleOrDefault();
649: accessVendor = (from o in Ia.Ngn.Cl.Model.Data.NetworkDesignDocument.OntList where o.Id == this.Id select o.Pon.PonGroup.Olt.Odf.Vendor).SingleOrDefault();
650:
651: sb.AppendLine("SwitchVendor: " + switchVendor.Name);
652: sb.AppendLine("AccessVendor: " + accessVendor.Name);
653: sb.AppendLine("AccessName: " + ((this.Access != null) ? this.Access.Name : string.Empty));
654: sb.AppendLine("Position: " + this.Position);
655: sb.AppendLine("Ip: " + this.Ip);
656: sb.AppendLine("Site Name: " + this.Pon.PonGroup.Olt.Odf.Router.Site.Name);
657: sb.AppendLine("PrimarySwitch: " + this.PrimarySwitch);
658: sb.AppendLine("Olt Field Type: " + Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.FieldTypeString(this.Pon.PonGroup.Olt.FieldType));
659: sb.AppendLine("Olt IsSip: " + Ia.Cl.Model.Default.YesNoText(this.Pon.PonGroup.Olt.IsSip));
660: sb.AppendLine("NetworkNumber: " + this.Pon.PonGroup.NetworkNumber);
661: sb.AppendLine("GatewayIp: " + this.Pon.PonGroup.GatewayIp);
662: sb.AppendLine("MgcIp: " + this.MgcIp);
663: sb.AppendLine("MgcSecondaryIp: " + this.MgcSecondaryIp);
664: sb.AppendLine("ImsService: " + this.ImsService);
665: sb.AppendLine("ImsFsdb: " + this.ImsFsdb);
666:
667: return sb.ToString();
668: }
669: }
670:
671: ////////////////////////////////////////////////////////////////////////////
672:
673: /// <summary>
674: ///
675: /// </summary>
676: public class Access
677: {
678: public Access() { }
679:
680: public string Id { get; set; }
681: public string Name { get; set; }
682: public string ProposedName { get; set; }
683: public int Ont { get; set; }
684: public int Pon { get; set; }
685: public int ProposedPon { get; set; }
686: public string Symbol { get; set; }
687:
688: public string AccessId(int oltId, int ponNumber, int ontNumber)
689: {
690: return Ia.Ngn.Cl.Model.Business.Access.AccessId(oltId, ponNumber, ontNumber);
691: }
692: }
693:
694: ////////////////////////////////////////////////////////////////////////////
695: ////////////////////////////////////////////////////////////////////////////
696: }
697: }