1: using Microsoft.EntityFrameworkCore;
2: using Microsoft.EntityFrameworkCore.Internal;
3: using System;
4: using System.Collections;
5: using System.Collections.Generic;
6: using System.Data;
7: using System.Linq;
8:
9: namespace Ia.Ngn.Cl.Model.Data
10: {
11: ////////////////////////////////////////////////////////////////////////////
12:
13: /// <summary publish="true">
14: /// Service support class for Optical Fiber Network (OFN) data model.
15: /// </summary>
16: ///
17: /// <remarks>
18: /// Copyright © 2006-2021 Jasem Y. Al-Shamlan (info@ia.com.kw), Integrated Applications - Kuwait. All Rights Reserved.
19: ///
20: /// This library is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by
21: /// the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
22: ///
23: /// This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
24: /// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
25: ///
26: /// You should have received a copy of the GNU General Public License along with this library. If not, see http://www.gnu.org/licenses.
27: ///
28: /// Copyright notice: This notice may not be removed or altered from any source distribution.
29: /// </remarks>
30: public class Service2
31: {
32: public Service2() { }
33:
34: ////////////////////////////////////////////////////////////////////////////
35:
36: /// <summary>
37: ///
38: /// </summary>
39: public static Ia.Ngn.Cl.Model.Service2 Read(string service)
40: {
41: Ia.Ngn.Cl.Model.Service2 service2;
42:
43: using (var db = new Ia.Ngn.Cl.Model.Ngn())
44: {
45: service2 = (from s in db.Service2
46: where s.ServiceType == Ia.Ngn.Cl.Model.Business.Service.ServiceType.ImsService && s.Service == service
47: select s).SingleOrDefault();
48: }
49:
50: return service2;
51: }
52:
53: ////////////////////////////////////////////////////////////////////////////
54:
55: /// <summary>
56: ///
57: /// </summary>
58: public static List<Ia.Ngn.Cl.Model.Service2> ReadList(List<string> serviceList)
59: {
60: List<Ia.Ngn.Cl.Model.Service2> list;
61:
62: using (var db = new Ia.Ngn.Cl.Model.Ngn())
63: {
64: if (serviceList.Count > 0)
65: {
66: list = (from s in db.Service2
67: where s.ServiceType == Ia.Ngn.Cl.Model.Business.Service.ServiceType.ImsService && serviceList.Contains(s.Service)
68: select s).ToList();
69: }
70: else list = new List<Ia.Ngn.Cl.Model.Service2>();
71: }
72:
73: return list;
74: }
75:
76: ////////////////////////////////////////////////////////////////////////////
77:
78: /// <summary>
79: ///
80: /// </summary>
81: public static Ia.Ngn.Cl.Model.Service2 ReadMsan(string service)
82: {
83: Ia.Ngn.Cl.Model.Service2 service2;
84:
85: #if DEBUG
86: var dummyVarToDrawRefractorToBelow = Ia.Ngn.Cl.Model.Business.NumberFormatConverter.Dn("0000000");
87: #endif
88:
89: using (var db = new Ia.Ngn.Cl.Model.Ngn())
90: {
91: service2 = (from s in db.Service2
92: join evpu in db.EmsVoipPstnUsers on "+965" + s.Service equals evpu.DN // see: Ia.Ngn.Cl.Model.Business.NumberFormatConverter.Dn()
93: where s.ServiceType == Ia.Ngn.Cl.Model.Business.Service.ServiceType.ImsService && s.Service == service
94: select s).SingleOrDefault();
95: }
96:
97: return service2;
98: }
99:
100: ////////////////////////////////////////////////////////////////////////////
101:
102: /// <summary>
103: ///
104: /// </summary>
105: public static List<Ia.Ngn.Cl.Model.Service2> ReadMsanList(List<string> serviceList)
106: {
107: List<Ia.Ngn.Cl.Model.Service2> list;
108:
109: #if DEBUG
110: var dummyVarToDrawRefractorToBelow = Ia.Ngn.Cl.Model.Business.NumberFormatConverter.Dn("0000000");
111: #endif
112:
113: using (var db = new Ia.Ngn.Cl.Model.Ngn())
114: {
115: if (serviceList.Count > 0)
116: {
117: list = (from s in db.Service2
118: join evpu in db.EmsVoipPstnUsers on "+965" + s.Service equals evpu.DN // see: Ia.Ngn.Cl.Model.Business.NumberFormatConverter.Dn()
119: where s.ServiceType == Ia.Ngn.Cl.Model.Business.Service.ServiceType.ImsService && serviceList.Contains(s.Service)
120: select s).ToList();
121:
122: }
123: else list = new List<Ia.Ngn.Cl.Model.Service2>();
124: }
125:
126: return list;
127: }
128:
129: ////////////////////////////////////////////////////////////////////////////
130:
131: /// <summary>
132: ///
133: /// </summary>
134: public static Ia.Ngn.Cl.Model.Service2 ReadPstn(string service)
135: {
136: Ia.Ngn.Cl.Model.Service2 service2;
137:
138: using (var db = new Ia.Ngn.Cl.Model.Ngn())
139: {
140: service2 = (from s in db.Service2
141: where s.ServiceType == Ia.Ngn.Cl.Model.Business.Service.ServiceType.PstnService && s.Service == service
142: select s).SingleOrDefault();
143: }
144:
145: return service2;
146: }
147:
148: ////////////////////////////////////////////////////////////////////////////
149:
150: /// <summary>
151: ///
152: /// </summary>
153: public static List<Ia.Ngn.Cl.Model.Service2> ReadPstnList(List<string> serviceList)
154: {
155: List<Ia.Ngn.Cl.Model.Service2> list;
156:
157: using (var db = new Ia.Ngn.Cl.Model.Ngn())
158: {
159: if (serviceList.Count > 0)
160: {
161: list = (from s in db.Service2
162: where s.ServiceType == Ia.Ngn.Cl.Model.Business.Service.ServiceType.PstnService && serviceList.Contains(s.Service)
163: select s).ToList();
164: }
165: else list = new List<Ia.Ngn.Cl.Model.Service2>();
166: }
167:
168: return list;
169: }
170:
171: ////////////////////////////////////////////////////////////////////////////
172:
173: /// <summary>
174: ///
175: /// </summary>
176: public static Ia.Ngn.Cl.Model.Service2 Read(long number)
177: {
178: Ia.Ngn.Cl.Model.Service2 service;
179:
180: using (var db = new Ia.Ngn.Cl.Model.Ngn())
181: {
182: service = (from s in db.Service2
183: where s.ServiceType == Ia.Ngn.Cl.Model.Business.Service.ServiceType.ImsService && s.Service == number.ToString()
184: select s).SingleOrDefault();
185: }
186:
187: return service;
188: }
189:
190: ////////////////////////////////////////////////////////////////////////////
191:
192: /// <summary>
193: ///
194: /// </summary>
195: public static Ia.Ngn.Cl.Model.Service2 ReadByIdIncludeAccess(string serviceId)
196: {
197: Ia.Ngn.Cl.Model.Service2 service2;
198:
199: using (var db = new Ia.Ngn.Cl.Model.Ngn())
200: {
201: service2 = (from s in db.Service2.Include(a => a.Access)
202: where s.ServiceType == Ia.Ngn.Cl.Model.Business.Service.ServiceType.ImsService && s.Id == serviceId
203: select s).AsNoTracking().SingleOrDefault();
204: }
205:
206: return service2;
207: }
208:
209: ////////////////////////////////////////////////////////////////////////////
210:
211: /// <summary>
212: ///
213: /// </summary>
214: public static Ia.Ngn.Cl.Model.Service2 ReadWithAccess(string service)
215: {
216: Ia.Ngn.Cl.Model.Service2 service2;
217:
218: using (var db = new Ia.Ngn.Cl.Model.Ngn())
219: {
220: service2 = (from s in db.Service2.Include(a => a.Access)
221: where s.ServiceType == Ia.Ngn.Cl.Model.Business.Service.ServiceType.ImsService && s.Service == service
222: select s).SingleOrDefault();
223: }
224:
225: return service2;
226: }
227:
228: ////////////////////////////////////////////////////////////////////////////
229:
230: /// <summary>
231: ///
232: /// </summary>
233: public static List<Ia.Ngn.Cl.Model.Service2> List()
234: {
235: List<Ia.Ngn.Cl.Model.Service2> serviceList;
236:
237: using (var db = new Ia.Ngn.Cl.Model.Ngn())
238: {
239: serviceList = (from s in db.Service2
240: where s.ServiceType == Ia.Ngn.Cl.Model.Business.Service.ServiceType.ImsService
241: select s).ToList();
242: }
243:
244: return serviceList;
245: }
246:
247: ////////////////////////////////////////////////////////////////////////////
248:
249: /// <summary>
250: ///
251: /// </summary>
252: public static List<string> List(List<int> domainList)
253: {
254: List<string> stringDomainList;
255: List<string> serviceList;
256:
257: using (var db = new Ia.Ngn.Cl.Model.Ngn())
258: {
259: if (domainList.Count > 0)
260: {
261: stringDomainList = new List<string>();
262:
263: foreach (int i in domainList) stringDomainList.Add(i.ToString());
264:
265: serviceList = (from s in db.Service2
266: where s.ServiceType == Ia.Ngn.Cl.Model.Business.Service.ServiceType.ImsService && stringDomainList.Any(u => s.Service.StartsWith(u.ToString()))
267: select s.Service).ToList();
268: }
269: else serviceList = new List<string>();
270: }
271:
272: return serviceList;
273: }
274:
275: ////////////////////////////////////////////////////////////////////////////
276:
277: /// <summary>
278: ///
279: /// </summary>
280: public static List<string> ServiceList
281: {
282: get
283: {
284: List<string> list;
285:
286: using (var db = new Ia.Ngn.Cl.Model.Ngn())
287: {
288: list = (from s in db.Service2
289: where s.ServiceType == Ia.Ngn.Cl.Model.Business.Service.ServiceType.ImsService
290: select s.Service).ToList();
291: }
292:
293: return list;
294: }
295: }
296:
297: ////////////////////////////////////////////////////////////////////////////
298:
299: /// <summary>
300: ///
301: /// </summary>
302: public static List<string> ImsServiceList
303: {
304: get
305: {
306: List<string> list;
307:
308: using (var db = new Ia.Ngn.Cl.Model.Ngn())
309: {
310: list = (from s in db.Service2
311: where s.ServiceType == Ia.Ngn.Cl.Model.Business.Service.ServiceType.ImsService
312: select s.Service).ToList();
313: }
314:
315: return list;
316: }
317: }
318:
319: ////////////////////////////////////////////////////////////////////////////
320:
321: /// <summary>
322: ///
323: /// </summary>
324: public static bool IsImsService(string service)
325: {
326: bool isImsService;
327:
328: using (var db = new Ia.Ngn.Cl.Model.Ngn())
329: {
330: isImsService = (from s in db.Service2
331: where s.Service == service && s.ServiceType == Ia.Ngn.Cl.Model.Business.Service.ServiceType.ImsService
332: select s.Service).Any();
333: }
334:
335: return isImsService;
336: }
337:
338: ////////////////////////////////////////////////////////////////////////////
339:
340: /// <summary>
341: ///
342: /// </summary>
343: public static List<string> ImsServiceWithAccessNullList
344: {
345: get
346: {
347: List<string> list;
348:
349: using (var db = new Ia.Ngn.Cl.Model.Ngn())
350: {
351: list = (from s in db.Service2
352: where s.Access == null && s.ServiceType == Ia.Ngn.Cl.Model.Business.Service.ServiceType.ImsService
353: select s.Service).ToList();
354: }
355:
356: return list;
357: }
358: }
359:
360: ////////////////////////////////////////////////////////////////////////////
361:
362: /// <summary>
363: ///
364: /// </summary>
365: public static List<string> MsanServiceList
366: {
367: get
368: {
369: List<string> list;
370:
371: #if DEBUG
372: var dummyVarToDrawRefractorToBelow = Ia.Ngn.Cl.Model.Business.NumberFormatConverter.Dn("0000000");
373: #endif
374:
375: using (var db = new Ia.Ngn.Cl.Model.Ngn())
376: {
377: list = (from s in db.Service2
378: join evpu in db.EmsVoipPstnUsers on "+965" + s.Service equals evpu.DN // see: Ia.Ngn.Cl.Model.Business.NumberFormatConverter.Dn()
379: where s.ServiceType == Ia.Ngn.Cl.Model.Business.Service.ServiceType.ImsService
380: select s.Service).ToList();
381: }
382:
383: return list;
384: }
385: }
386:
387: ////////////////////////////////////////////////////////////////////////////
388:
389: /// <summary>
390: ///
391: /// </summary>
392: public static List<string> PstnServiceList
393: {
394: get
395: {
396: List<string> list;
397:
398: using (var db = new Ia.Ngn.Cl.Model.Ngn())
399: {
400: list = (from s in db.Service2
401: where s.ServiceType == Ia.Ngn.Cl.Model.Business.Service.ServiceType.PstnService
402: select s.Service).ToList();
403: }
404:
405: return list.ToList();
406: }
407: }
408:
409: ////////////////////////////////////////////////////////////////////////////
410:
411: /// <summary>
412: ///
413: /// </summary>
414: public static bool IsPstnService(string service)
415: {
416: bool isPstnService;
417:
418:
419: using (var db = new Ia.Ngn.Cl.Model.Ngn())
420: {
421: isPstnService = (from s in db.Service2
422: where s.Service == service && s.ServiceType == Ia.Ngn.Cl.Model.Business.Service.ServiceType.PstnService
423: select s.Service).Any();
424: }
425:
426: return isPstnService;
427: }
428:
429: ////////////////////////////////////////////////////////////////////////////
430:
431: /// <summary>
432: ///
433: /// </summary>
434: public static List<string> ServiceIdList
435: {
436: get
437: {
438: List<string> list;
439:
440: using (var db = new Ia.Ngn.Cl.Model.Ngn())
441: {
442: list = (from s in db.Service2 /*where s.ServiceType == Ia.Ngn.Cl.Model.Business.Service.ServiceType.ImsService*/ select s.Id).ToList();
443: }
444:
445: return list.ToList();
446: }
447: }
448:
449: ////////////////////////////////////////////////////////////////////////////
450:
451: /// <summary>
452: ///
453: /// </summary>
454: public static List<string> ImsServiceIdList
455: {
456: get
457: {
458: List<string> list;
459:
460: using (var db = new Ia.Ngn.Cl.Model.Ngn())
461: {
462: list = (from s in db.Service2
463: where s.ServiceType == Ia.Ngn.Cl.Model.Business.Service.ServiceType.ImsService
464: select s.Id).ToList();
465: }
466:
467: return list.ToList();
468: }
469: }
470:
471: ////////////////////////////////////////////////////////////////////////////
472:
473: /// <summary>
474: ///
475: /// </summary>
476: public static List<string> PstnServiceIdList
477: {
478: get
479: {
480: List<string> list;
481:
482: using (var db = new Ia.Ngn.Cl.Model.Ngn())
483: {
484: list = (from s in db.Service2
485: where s.ServiceType == Ia.Ngn.Cl.Model.Business.Service.ServiceType.PstnService
486: select s.Id).ToList();
487: }
488:
489: return list.ToList();
490: }
491: }
492:
493: ////////////////////////////////////////////////////////////////////////////
494:
495: /// <summary>
496: ///
497: /// </summary>
498: public static List<Ia.Ngn.Cl.Model.Business.ServiceAccessIpOntCreated> ServiceOntList
499: {
500: get
501: {
502: List<Ia.Ngn.Cl.Model.Business.ServiceAccessIpOntCreated> list;
503:
504: var ontAccessIdToOntForOltIdListDictionary = Ia.Ngn.Cl.Model.Data.NetworkDesignDocument.OntAccessIdToOntDictionary;
505:
506: using (var db = new Ia.Ngn.Cl.Model.Ngn())
507: {
508: list = (from s in db.Service2
509: where s.ServiceType == Ia.Ngn.Cl.Model.Business.Service.ServiceType.ImsService
510: select new Ia.Ngn.Cl.Model.Business.ServiceAccessIpOntCreated { ServiceId = s.Id, Service = s.Service, AccessId = s.Access != null ? s.Access.Id : string.Empty, CreatedDateTime = s.Created }).AsNoTracking().ToList();
511: }
512:
513: foreach (var l in list)
514: {
515: l.Ont = ontAccessIdToOntForOltIdListDictionary.ContainsKey(l.AccessId) ? ontAccessIdToOntForOltIdListDictionary[l.AccessId] : null;
516: }
517:
518: return list;
519: }
520: }
521:
522: ////////////////////////////////////////////////////////////////////////////
523:
524: /// <summary>
525: ///
526: /// </summary>
527: public static List<Ia.Ngn.Cl.Model.Business.ServiceAccessIpOntCreated> ServiceOntBySiteIdList(int siteId)
528: {
529: List<Ia.Ngn.Cl.Model.Business.ServiceAccessIpOntCreated> list;
530:
531: var ontAccessIdToOntForOltIdListDictionary = Ia.Ngn.Cl.Model.Data.NetworkDesignDocument.OntAccessIdToOntDictionary;
532:
533: var site = (from s in Ia.Ngn.Cl.Model.Data.NetworkDesignDocument.SiteList
534: where s.Id == siteId
535: select s).SingleOrDefault();
536:
537: if (site != null)
538: {
539: var siteRouterDomainList = (from r in Ia.Ngn.Cl.Model.Data.NetworkDesignDocument.RouterList
540: where r.Site.Id == site.Id
541: select r).SelectMany(d => d.DomainList).ToList();
542:
543: using (var db = new Ia.Ngn.Cl.Model.Ngn())
544: {
545: var list0 = (from s in db.Service2
546: where s.ServiceType == Ia.Ngn.Cl.Model.Business.Service.ServiceType.ImsService
547: select new Ia.Ngn.Cl.Model.Business.ServiceAccessIpOntCreated { ServiceId = s.Id, Service = s.Service, AccessId = s.Access != null ? s.Access.Id : string.Empty, CreatedDateTime = s.Created }).AsNoTracking().ToList();
548:
549: list = new List<Ia.Ngn.Cl.Model.Business.ServiceAccessIpOntCreated>();
550:
551: foreach (var l in list0)
552: {
553: if (!string.IsNullOrEmpty(l.AccessId))
554: {
555: if (ontAccessIdToOntForOltIdListDictionary.ContainsKey(l.AccessId))
556: {
557: l.Ont = ontAccessIdToOntForOltIdListDictionary[l.AccessId];
558:
559: if (l.Ont.Pon.PonGroup.Olt.Odf.Router.Site.Id == siteId)
560: {
561: list.Add(l);
562: }
563: else
564: {
565:
566: }
567: }
568: else
569: {
570:
571: }
572: }
573: else
574: {
575: if (siteRouterDomainList.Any(u => l.Service.StartsWith(u.ToString())))
576: {
577: list.Add(l);
578: }
579: }
580: }
581: }
582:
583: var msanServiceList = Ia.Ngn.Cl.Model.Data.Huawei.Default.MsanServiceListBySiteId(siteId);
584:
585: foreach (var msanService in msanServiceList)
586: {
587: list.Add(new Business.ServiceAccessIpOntCreated { Service = msanService, AccessId = string.Empty });
588: }
589: }
590: else
591: {
592: list = new List<Ia.Ngn.Cl.Model.Business.ServiceAccessIpOntCreated>();
593: }
594:
595: return list;
596: }
597:
598: ////////////////////////////////////////////////////////////////////////////
599:
600: /// <summary>
601: ///
602: /// </summary>
603: public static List<Ia.Ngn.Cl.Model.Business.ServiceAccessIpOntCreated> ServiceOntByAreaIdList(int areaId)
604: {
605: List<Ia.Ngn.Cl.Model.Business.ServiceAccessIpOntCreated> list;
606:
607: var ontAccessIdToOntForOltIdListDictionary = Ia.Ngn.Cl.Model.Data.NetworkDesignDocument.OntAccessIdToOntDictionary;
608:
609: var area = (from a in Ia.Ngn.Cl.Model.Data.Service.KuwaitOfnAreaList
610: where a.Id == areaId
611: select a).SingleOrDefault();
612:
613: if (area != null)
614: {
615: using (var db = new Ia.Ngn.Cl.Model.Ngn())
616: {
617: var list0 = (from s in db.Service2
618: where s.ServiceType == Ia.Ngn.Cl.Model.Business.Service.ServiceType.ImsService
619: select new Ia.Ngn.Cl.Model.Business.ServiceAccessIpOntCreated { ServiceId = s.Id, Service = s.Service, AccessId = s.Access != null ? s.Access.Id : string.Empty }).AsNoTracking().ToList();
620:
621: list = new List<Ia.Ngn.Cl.Model.Business.ServiceAccessIpOntCreated>();
622:
623: foreach (var l in list0)
624: {
625: if (!string.IsNullOrEmpty(l.AccessId))
626: {
627: if (ontAccessIdToOntForOltIdListDictionary.ContainsKey(l.AccessId))
628: {
629: l.Ont = ontAccessIdToOntForOltIdListDictionary[l.AccessId];
630:
631: if (l.Ont.Pon.PonGroup.Symbol == area.Symbol)
632: {
633: list.Add(l);
634: }
635: else
636: {
637:
638: }
639: }
640: else
641: {
642:
643: }
644: }
645: else
646: {
647: }
648: }
649: }
650: }
651: else
652: {
653: list = new List<Ia.Ngn.Cl.Model.Business.ServiceAccessIpOntCreated>();
654: }
655:
656: return list;
657: }
658:
659: ////////////////////////////////////////////////////////////////////////////
660:
661: /// <summary>
662: ///
663: /// </summary>
664: public static List<Ia.Ngn.Cl.Model.Business.ServiceAccessIpOntCreated> ServiceOntByDomainList(string domain)
665: {
666: List<Ia.Ngn.Cl.Model.Business.ServiceAccessIpOntCreated> list;
667:
668: var ontAccessIdToOntForOltIdListDictionary = Ia.Ngn.Cl.Model.Data.NetworkDesignDocument.OntAccessIdToOntDictionary;
669:
670: using (var db = new Ia.Ngn.Cl.Model.Ngn())
671: {
672: var list0 = (from s in db.Service2
673: where s.ServiceType == Ia.Ngn.Cl.Model.Business.Service.ServiceType.ImsService && s.Service.StartsWith(domain)
674: select new Ia.Ngn.Cl.Model.Business.ServiceAccessIpOntCreated { ServiceId = s.Id, Service = s.Service, AccessId = s.Access != null ? s.Access.Id : string.Empty }).AsNoTracking().ToList();
675:
676: list = new List<Ia.Ngn.Cl.Model.Business.ServiceAccessIpOntCreated>();
677:
678: foreach (var l in list0)
679: {
680: if (!string.IsNullOrEmpty(l.AccessId))
681: {
682: if (ontAccessIdToOntForOltIdListDictionary.ContainsKey(l.AccessId))
683: {
684: l.Ont = ontAccessIdToOntForOltIdListDictionary[l.AccessId];
685:
686: list.Add(l);
687: }
688: else
689: {
690:
691: }
692: }
693: else
694: {
695: }
696: }
697: }
698:
699: return list;
700: }
701:
702: ////////////////////////////////////////////////////////////////////////////
703:
704: /// <summary>
705: ///
706: /// </summary>
707: public static List<Ia.Ngn.Cl.Model.Service2> WithinSiteList(int siteId)
708: {
709: List<Ia.Ngn.Cl.Model.Service2> list;
710:
711: var site = (from s in Ia.Ngn.Cl.Model.Data.NetworkDesignDocument.SiteList
712: where s.Id == siteId
713: select s).SingleOrDefault();
714:
715: if (site != null)
716: {
717: var siteRouterDomainList = (from r in Ia.Ngn.Cl.Model.Data.NetworkDesignDocument.RouterList
718: where r.Site.Id == site.Id
719: select r).SelectMany(d => d.DomainList).ToList();
720:
721: using (var db = new Ia.Ngn.Cl.Model.Ngn())
722: {
723: var list0 = (from s in db.Service2
724: select s).Include(u => u.Access).ToList();
725:
726: list = (from s in list0
727: where siteRouterDomainList.Any(u => s.Service.StartsWith(u.ToString()))
728: select s).ToList();
729: }
730: }
731: else
732: {
733: list = new List<Ia.Ngn.Cl.Model.Service2>();
734: }
735:
736: return list;
737: }
738:
739: ////////////////////////////////////////////////////////////////////////////
740:
741: /// <summary>
742: ///
743: /// </summary>
744: public static List<Ia.Ngn.Cl.Model.Service2> PstnService2List
745: {
746: get
747: {
748: List<Ia.Ngn.Cl.Model.Service2> list;
749:
750: using (var db = new Ia.Ngn.Cl.Model.Ngn())
751: {
752: list = (from s in db.Service2
753: where s.ServiceType == Ia.Ngn.Cl.Model.Business.Service.ServiceType.PstnService
754: select s).Include(s => s.Access).ToList();
755: }
756:
757: return list.ToList();
758: }
759: }
760:
761: ////////////////////////////////////////////////////////////////////////////
762:
763: /// <summary>
764: ///
765: /// </summary>
766: public static Dictionary<string, int> ServiceIdToPortDictionary
767: {
768: get
769: {
770: Dictionary<string, int> dictionary;
771:
772: using (var db = new Ia.Ngn.Cl.Model.Ngn())
773: {
774: dictionary = (from s in db.Service2
775: where s.ServiceType == Ia.Ngn.Cl.Model.Business.Service.ServiceType.ImsService && s.Access != null
776: select new { s.Id, s.Port }).ToDictionary(m => m.Id, m => m.Port);
777: }
778:
779: return dictionary;
780: }
781: }
782:
783: ////////////////////////////////////////////////////////////////////////////
784:
785: /// <summary>
786: ///
787: /// </summary>
788: public static Ia.Ngn.Cl.Model.Access ReadAccess(string id)
789: {
790: Ia.Ngn.Cl.Model.Access access;
791:
792: using (var db = new Ia.Ngn.Cl.Model.Ngn())
793: {
794: access = (from s in db.Service2
795: where s.ServiceType == Ia.Ngn.Cl.Model.Business.Service.ServiceType.ImsService && s.Id == id
796: select s.Access).SingleOrDefault();
797: }
798:
799: return access;
800: }
801:
802: ////////////////////////////////////////////////////////////////////////////
803:
804: /// <summary>
805: ///
806: /// </summary>
807: public static Dictionary<string, int> ServicePortDictionary
808: {
809: get
810: {
811: Dictionary<string, int> dictionary;
812:
813: using (var db = new Ia.Ngn.Cl.Model.Ngn())
814: {
815: dictionary = (from s in db.Service2
816: where s.ServiceType == Ia.Ngn.Cl.Model.Business.Service.ServiceType.ImsService && s.Port > -1
817: select new { s.Service, s.Port }).ToDictionary(m => m.Service, m => m.Port);
818: }
819:
820: return dictionary;
821: }
822: }
823:
824: ////////////////////////////////////////////////////////////////////////////
825:
826: /// <summary>
827: ///
828: /// </summary>
829: public static Ia.Ngn.Cl.Model.Access ReadAccess(Ia.Ngn.Cl.Model.Ngn db, string id)
830: {
831: Ia.Ngn.Cl.Model.Access access;
832:
833: access = (from s in db.Service2
834: where s.ServiceType == Ia.Ngn.Cl.Model.Business.Service.ServiceType.ImsService && s.Id == id
835: select s.Access).SingleOrDefault();
836:
837: return access;
838: }
839:
840: ////////////////////////////////////////////////////////////////////////////
841:
842: /// <summary>
843: ///
844: /// </summary>
845: public static bool UpdatePort(Ia.Ngn.Cl.Model.Service2 service, int port, out string result)
846: {
847: bool b;
848:
849: using (var db = new Ia.Ngn.Cl.Model.Ngn())
850: {
851: service = (from s in db.Service2
852: where s.ServiceType == Ia.Ngn.Cl.Model.Business.Service.ServiceType.ImsService && s.Id == service.Id
853: select s).SingleOrDefault();
854:
855: if (service.Port != port)
856: {
857: service.Port = port;
858:
859: db.Service2.Attach(service);
860: db.Entry(service).Property(u => u.Port).IsModified = true;
861:
862: db.SaveChanges();
863:
864: result = "Success: Service Port updated. ";
865: b = true;
866: }
867: else
868: {
869: result = "Warning: Service Port value was not updated because its the same. ";
870:
871: b = false;
872: }
873: }
874:
875: return b;
876: }
877:
878: ////////////////////////////////////////////////////////////////////////////
879:
880: /// <summary>
881: ///
882: /// </summary>
883: public static List<Ia.Ngn.Cl.Model.Service2> ServiceWithNullAccessList
884: {
885: get
886: {
887: List<Ia.Ngn.Cl.Model.Service2> serviceList;
888:
889: using (var db = new Ia.Ngn.Cl.Model.Ngn())
890: {
891: serviceList = (from s in db.Service2
892: where s.ServiceType == Ia.Ngn.Cl.Model.Business.Service.ServiceType.ImsService && s.Access == null
893: select s).ToList();
894: }
895:
896: return serviceList;
897: }
898: }
899:
900: ////////////////////////////////////////////////////////////////////////////
901:
902: /// <summary>
903: ///
904: /// </summary>
905: public static List<string> ServiceIdWithinSipOltList()
906: {
907: List<int> sipOltIdList;
908: List<string> list, list2;
909:
910: sipOltIdList = Ia.Ngn.Cl.Model.Data.NetworkDesignDocument.SipOltIdList;
911:
912: using (var db = new Ia.Ngn.Cl.Model.Ngn())
913: {
914: // services with access
915: list = (from s in db.Service2
916: where s.ServiceType == Ia.Ngn.Cl.Model.Business.Service.ServiceType.ImsService && s.Access != null && sipOltIdList.Contains(s.Access.Olt)
917: select s.Id).ToList();
918:
919: // services without access might be newly installed
920: list2 = (from s in db.Service2
921: join srs in db.ServiceRequestServices on s.Service equals srs.Service
922: where s.ServiceType == Ia.Ngn.Cl.Model.Business.Service.ServiceType.ImsService && s.Access == null && srs.Access != null && srs.Provisioned == true && sipOltIdList.Contains(srs.Access.Olt)
923: select s.Id).ToList();
924: }
925:
926: return list.Union(list2).Distinct().ToList();
927: }
928:
929: ////////////////////////////////////////////////////////////////////////////
930:
931: /// <summary>
932: ///
933: /// </summary>
934: public static List<string> ServiceIdWithinAllowedSipOltToBeProvisionedOrMigratedList()
935: {
936: List<int> sipOltIdList;
937: List<string> list, list2;
938:
939: sipOltIdList = Ia.Ngn.Cl.Model.Data.Service.AllowedToBeProvisionedSipOltIdList.Union(Ia.Ngn.Cl.Model.Data.Service.AllowedToBeMigratedSipOltIdList).ToList();
940:
941: using (var db = new Ia.Ngn.Cl.Model.Ngn())
942: {
943: // services with access
944: list = (from s in db.Service2
945: where s.ServiceType == Ia.Ngn.Cl.Model.Business.Service.ServiceType.ImsService && s.Access != null && sipOltIdList.Contains(s.Access.Olt)
946: select s.Id).ToList();
947:
948: // services without access might be newly installed
949: list2 = (from s in db.Service2
950: join srs in db.ServiceRequestServices on s.Service equals srs.Service
951: where s.ServiceType == Ia.Ngn.Cl.Model.Business.Service.ServiceType.ImsService && s.Access == null && srs.Access != null && srs.Provisioned == true && sipOltIdList.Contains(srs.Access.Olt)
952: select s.Id).ToList();
953: }
954:
955: return list.Union(list2).Distinct().ToList();
956: }
957:
958: ////////////////////////////////////////////////////////////////////////////
959:
960: /// <summary>
961: ///
962: /// </summary>
963: public static List<Ia.Ngn.Cl.Model.Business.ServiceAccessIpOntCreated> ServiceOntWithinAllowedSipOltToBeProvisionedOrMigratedList
964: {
965: get
966: {
967: List<int> oltIdList;
968: List<Ia.Ngn.Cl.Model.Business.ServiceAccessIpOntCreated> list1, list2, list;
969:
970: oltIdList = Ia.Ngn.Cl.Model.Data.Service.AllowedToBeProvisionedSipOltIdList.Union(Ia.Ngn.Cl.Model.Data.Service.AllowedToBeMigratedSipOltIdList).ToList();
971:
972: var ontAccessIdToOntForOltIdListDictionary = Ia.Ngn.Cl.Model.Data.NetworkDesignDocument.OntAccessIdToOntForOltIdListDictionary(oltIdList);
973:
974: using (var db = new Ia.Ngn.Cl.Model.Ngn())
975: {
976: // services with access
977: list1 = (from s in db.Service2
978: where s.ServiceType == Ia.Ngn.Cl.Model.Business.Service.ServiceType.ImsService && s.Access != null && oltIdList.Contains(s.Access.Olt)
979: select new Ia.Ngn.Cl.Model.Business.ServiceAccessIpOntCreated { ServiceId = s.Id, Service = s.Service, AccessId = s.Access.Id, CreatedDateTime = s.Created }).AsNoTracking().ToList();
980:
981: // services without access might be newly installed
982: list2 = (from s in db.Service2
983: join srs in db.ServiceRequestServices on s.Service equals srs.Service
984: where s.ServiceType == Ia.Ngn.Cl.Model.Business.Service.ServiceType.ImsService && s.Access == null && srs.Access != null && srs.Provisioned == true && oltIdList.Contains(srs.Access.Olt)
985: select new Ia.Ngn.Cl.Model.Business.ServiceAccessIpOntCreated { ServiceId = s.Id, Service = s.Service, AccessId = srs.Access.Id, CreatedDateTime = s.Created }).AsNoTracking().ToList();
986: }
987:
988: list = list1.Concat(list2).ToList();
989:
990: foreach (var l in list)
991: {
992: l.Ont = ontAccessIdToOntForOltIdListDictionary.ContainsKey(l.AccessId) ? ontAccessIdToOntForOltIdListDictionary[l.AccessId] : null;
993: }
994:
995: return list;
996: }
997: }
998:
999: ////////////////////////////////////////////////////////////////////////////
1000:
1001: /// <summary>
1002: ///
1003: /// </summary>
1004: public static Dictionary<string, int> ServiceToOltIdWithinNokiaSwitchHuaweiAccessOltListDictionary
1005: {
1006: get
1007: {
1008: List<int> oltIdList;
1009: Dictionary<string, int> dictionary, dictionary1, dictionary2;
1010:
1011: oltIdList = Ia.Ngn.Cl.Model.Data.NetworkDesignDocument.NokiaRouterHuaweiAccessOltIdList;
1012:
1013: using (var db = new Ia.Ngn.Cl.Model.Ngn())
1014: {
1015: // services with access
1016: dictionary1 = (from s in db.Service2
1017: where s.ServiceType == Ia.Ngn.Cl.Model.Business.Service.ServiceType.ImsService && s.Access != null && oltIdList.Contains(s.Access.Olt)
1018: select new { s.Service, s.Access.Olt }).AsNoTracking().ToDictionary(u => u.Service, u => u.Olt);
1019:
1020: /*
1021: // services without access might be newly installed
1022: dictionary2 = (from s in db.Service2
1023: join srs in db.ServiceRequestServices on s.Service equals srs.Service
1024: where s.ServiceType == Ia.Ngn.Cl.Model.Business.Service.ServiceType.ImsService && s.Access == null && srs.Access != null && srs.Provisioned == true && oltIdList.Contains(srs.Access.Olt)
1025: select new { s.Service, s.Access.Olt }).AsNoTracking().ToDictionary(u => u.Service, u => u.Olt);
1026: */
1027: }
1028:
1029: dictionary = dictionary1;//.Union(dictionary2).ToDictionary(u => u.Key, u => u.Value);
1030:
1031: return dictionary;
1032: }
1033: }
1034:
1035: ////////////////////////////////////////////////////////////////////////////
1036:
1037: /// <summary>
1038: ///
1039: /// </summary>
1040: public static List<Ia.Ngn.Cl.Model.Business.ServiceAccessIpOntCreated> ServiceOntWithinAllowedToBeProvisionedOrMigratedHuaweiSwitchNokiaAccessOltList()
1041: {
1042: List<int> oltIdList;
1043: List<Ia.Ngn.Cl.Model.Business.ServiceAccessIpOntCreated> list1, list2, list;
1044:
1045: oltIdList = Ia.Ngn.Cl.Model.Data.NetworkDesignDocument.HuaweiSwitchNokiaAccessOltIdList;
1046:
1047: var ontAccessIdToOntForOltIdListDictionary = Ia.Ngn.Cl.Model.Data.NetworkDesignDocument.OntAccessIdToOntForOltIdListDictionary(oltIdList);
1048:
1049: using (var db = new Ia.Ngn.Cl.Model.Ngn())
1050: {
1051: // services with access
1052: list1 = (from s in db.Service2
1053: where s.ServiceType == Ia.Ngn.Cl.Model.Business.Service.ServiceType.ImsService && s.Access != null && oltIdList.Contains(s.Access.Olt)
1054: select new Ia.Ngn.Cl.Model.Business.ServiceAccessIpOntCreated { ServiceId = s.Id, Service = s.Service, AccessId = s.Access.Id, CreatedDateTime = s.Created }).AsNoTracking().ToList();
1055:
1056: // services without access might be newly installed
1057: list2 = (from s in db.Service2
1058: join srs in db.ServiceRequestServices on s.Service equals srs.Service
1059: where s.ServiceType == Ia.Ngn.Cl.Model.Business.Service.ServiceType.ImsService && s.Access == null && srs.Access != null && srs.Provisioned == true && oltIdList.Contains(srs.Access.Olt)
1060: select new Ia.Ngn.Cl.Model.Business.ServiceAccessIpOntCreated { ServiceId = s.Id, Service = s.Service, AccessId = srs.Access.Id, CreatedDateTime = s.Created }).AsNoTracking().ToList();
1061: }
1062:
1063: list = list1.Concat(list2).ToList();
1064:
1065: foreach (var l in list)
1066: {
1067: l.Ont = ontAccessIdToOntForOltIdListDictionary.ContainsKey(l.AccessId) ? ontAccessIdToOntForOltIdListDictionary[l.AccessId] : null;
1068: }
1069:
1070: return list;
1071: }
1072:
1073: ////////////////////////////////////////////////////////////////////////////
1074:
1075: /// <summary>
1076: ///
1077: /// </summary>
1078: public static List<string> ServiceIdWithinHuaweiSwitchDomainList()
1079: {
1080: List<int> huaweiSwitchDomainList;
1081: List<string> list;
1082:
1083: huaweiSwitchDomainList = Ia.Ngn.Cl.Model.Data.Service.HuaweiSwitchDomainList;
1084:
1085: using (var db = new Ia.Ngn.Cl.Model.Ngn())
1086: {
1087: list = (from s in db.Service2
1088: where s.ServiceType == Ia.Ngn.Cl.Model.Business.Service.ServiceType.ImsService && huaweiSwitchDomainList.Any(u => s.Service.StartsWith(u.ToString()))
1089: select s.Id).ToList();
1090: }
1091:
1092: return list.ToList();
1093: }
1094:
1095: ////////////////////////////////////////////////////////////////////////////
1096:
1097: /// <summary>
1098: ///
1099: /// </summary>
1100: public static List<string> ServiceIdWithinNokiaSwitchDomainList()
1101: {
1102: List<int> nokiaSwitchDomainList;
1103: List<string> list;
1104:
1105: nokiaSwitchDomainList = Ia.Ngn.Cl.Model.Data.Service.NokiaSwitchDomainList;
1106:
1107: using (var db = new Ia.Ngn.Cl.Model.Ngn())
1108: {
1109: list = (from s in db.Service2
1110: where s.ServiceType == Ia.Ngn.Cl.Model.Business.Service.ServiceType.ImsService && nokiaSwitchDomainList.Any(u => s.Service.StartsWith(u.ToString()))
1111: select s.Id).ToList();
1112: }
1113:
1114: return list.ToList();
1115: }
1116:
1117: ////////////////////////////////////////////////////////////////////////////
1118:
1119: /// <summary>
1120: ///
1121: /// </summary>
1122: public static List<string> ServiceIdWithNullAccessList()
1123: {
1124: List<string> list;
1125:
1126: using (var db = new Ia.Ngn.Cl.Model.Ngn())
1127: {
1128: list = (from s in db.Service2
1129: where s.ServiceType == Ia.Ngn.Cl.Model.Business.Service.ServiceType.ImsService && s.Access == null
1130: select s.Id).ToList();
1131: }
1132:
1133: return list;
1134: }
1135:
1136: ////////////////////////////////////////////////////////////////////////////
1137:
1138: /// <summary>
1139: ///
1140: /// </summary>
1141: public static List<Ia.Ngn.Cl.Model.Service2> ServiceSuspensionIsTrueList
1142: {
1143: get
1144: {
1145: List<Ia.Ngn.Cl.Model.Service2> serviceList;
1146:
1147: using (var db = new Ia.Ngn.Cl.Model.Ngn())
1148: {
1149: serviceList = (from s in db.Service2
1150: where s.ServiceType == Ia.Ngn.Cl.Model.Business.Service.ServiceType.ImsService && s.ServiceSuspension == true
1151: select s).ToList();
1152: }
1153:
1154: return serviceList;
1155: }
1156: }
1157:
1158: ////////////////////////////////////////////////////////////////////////////
1159:
1160: /// <summary>
1161: ///
1162: /// </summary>
1163: public static int ServiceSuspensionIsTrueListCount
1164: {
1165: get
1166: {
1167: int c;
1168:
1169: using (var db = new Ia.Ngn.Cl.Model.Ngn())
1170: {
1171: c = (from s in db.Service2
1172: where s.ServiceType == Ia.Ngn.Cl.Model.Business.Service.ServiceType.ImsService && s.ServiceSuspension == true
1173: select s).Count();
1174: }
1175:
1176: return c;
1177: }
1178: }
1179:
1180: ////////////////////////////////////////////////////////////////////////////
1181:
1182: /// <summary>
1183: ///
1184: /// </summary>
1185: public static List<Ia.Ngn.Cl.Model.Service2> ServiceSuspensionIsFalseList
1186: {
1187: get
1188: {
1189: List<Ia.Ngn.Cl.Model.Service2> serviceList;
1190:
1191: using (var db = new Ia.Ngn.Cl.Model.Ngn())
1192: {
1193: serviceList = (from s in db.Service2
1194: where s.ServiceType == Ia.Ngn.Cl.Model.Business.Service.ServiceType.ImsService && s.ServiceSuspension == false
1195: select s).ToList();
1196: }
1197:
1198: return serviceList;
1199: }
1200: }
1201:
1202: ////////////////////////////////////////////////////////////////////////////
1203:
1204: /// <summary>
1205: ///
1206: /// </summary>
1207: public static List<string> ServiceSuspensionIsTrueStringNumberList
1208: {
1209: get
1210: {
1211: List<string> serviceNumberStringList;
1212: List<Ia.Ngn.Cl.Model.Service2> serviceList;
1213:
1214: using (var db = new Ia.Ngn.Cl.Model.Ngn())
1215: {
1216: // below:
1217: serviceList = ServiceSuspensionIsTrueList;
1218:
1219: if (serviceList.Count > 0)
1220: {
1221: serviceNumberStringList = new List<string>(serviceList.Count);
1222:
1223: foreach (Ia.Ngn.Cl.Model.Service2 srs in serviceList)
1224: {
1225: serviceNumberStringList.Add(srs.Service);
1226: }
1227: }
1228: else
1229: {
1230: // below: not null
1231: serviceNumberStringList = new List<string>(1);
1232: }
1233: }
1234:
1235: return serviceNumberStringList;
1236: }
1237: }
1238:
1239: ////////////////////////////////////////////////////////////////////////////
1240:
1241: /// <summary>
1242: ///
1243: /// </summary>
1244: public static List<string> ServiceSuspensionIsFalseStringNumberList
1245: {
1246: get
1247: {
1248: List<string> serviceNumberStringList;
1249: List<Ia.Ngn.Cl.Model.Service2> serviceList;
1250:
1251: using (var db = new Ia.Ngn.Cl.Model.Ngn())
1252: {
1253: // below:
1254: serviceList = ServiceSuspensionIsFalseList;
1255:
1256: if (serviceList.Count > 0)
1257: {
1258: serviceNumberStringList = new List<string>(serviceList.Count);
1259:
1260: foreach (Ia.Ngn.Cl.Model.Service2 srs in serviceList)
1261: {
1262: serviceNumberStringList.Add(srs.Service);
1263: }
1264: }
1265: else
1266: {
1267: // below: not null
1268: serviceNumberStringList = new List<string>(1);
1269: }
1270: }
1271:
1272: return serviceNumberStringList;
1273: }
1274: }
1275:
1276: ////////////////////////////////////////////////////////////////////////////
1277:
1278: /// <summary>
1279: ///
1280: /// </summary>
1281: public static bool IsSuspended(string service)
1282: {
1283: bool isSuspended;
1284:
1285: using (var db = new Ia.Ngn.Cl.Model.Ngn())
1286: {
1287: isSuspended = (from s in db.Service2
1288: where s.Service == service && s.ServiceSuspension == true
1289: select s.Service).Any();
1290: }
1291:
1292: return isSuspended;
1293: }
1294:
1295: ////////////////////////////////////////////////////////////////////////////
1296:
1297: /// <summary>
1298: ///
1299: /// </summary>
1300: public static bool HasInternationalCalling(string service)
1301: {
1302: return InternationalCallingIsAssigned(service);
1303: }
1304:
1305: ////////////////////////////////////////////////////////////////////////////
1306:
1307: /// <summary>
1308: ///
1309: /// </summary>
1310: public static bool InternationalCallingIsAssigned(string service)
1311: {
1312: bool isAssigned;
1313:
1314: using (var db = new Ia.Ngn.Cl.Model.Ngn())
1315: {
1316: isAssigned = (from s in db.Service2
1317: where s.Service == service && s.InternationalCalling == true
1318: select s.Service).Any();
1319: }
1320:
1321: return isAssigned;
1322: }
1323:
1324: ////////////////////////////////////////////////////////////////////////////
1325:
1326: /// <summary>
1327: ///
1328: /// </summary>
1329: public static Dictionary<string, string> ServiceIdToAccessIdDictionary
1330: {
1331: get
1332: {
1333: Dictionary<string, string> dictionary, nullAccessDictionary;
1334:
1335: using (var db = new Ia.Ngn.Cl.Model.Ngn())
1336: {
1337: dictionary = (from s in db.Service2
1338: where s.ServiceType == Ia.Ngn.Cl.Model.Business.Service.ServiceType.ImsService && s.Access != null
1339: select new { s.Id, s.Access }).AsNoTracking().ToDictionary(u => u.Id, u => u.Access.Id);
1340:
1341: nullAccessDictionary = (from s in db.Service2
1342: where s.ServiceType == Ia.Ngn.Cl.Model.Business.Service.ServiceType.ImsService && s.Access == null
1343: select new { s.Id, s.Access }).AsNoTracking().ToDictionary(u => u.Id, u => string.Empty);
1344: }
1345:
1346: return dictionary.Union(nullAccessDictionary).ToDictionary(u => u.Key, u => u.Value);
1347: }
1348: }
1349:
1350: ////////////////////////////////////////////////////////////////////////////
1351:
1352: /// <summary>
1353: ///
1354: /// </summary>
1355: public static Dictionary<string, string> PstnServiceIdToAccessIdDictionary
1356: {
1357: get
1358: {
1359: Dictionary<string, string> dictionary, nullAccessDictionary;
1360:
1361: using (var db = new Ia.Ngn.Cl.Model.Ngn())
1362: {
1363: dictionary = (from s in db.Service2
1364: where s.ServiceType == Ia.Ngn.Cl.Model.Business.Service.ServiceType.PstnService && s.Access != null
1365: select new { s.Id, s.Access }).ToDictionary(u => u.Id, u => u.Access.Id);
1366:
1367: nullAccessDictionary = (from s in db.Service2
1368: where s.ServiceType == Ia.Ngn.Cl.Model.Business.Service.ServiceType.PstnService && s.Access == null
1369: select new { s.Id, s.Access }).ToDictionary(u => u.Id, u => string.Empty);
1370: }
1371:
1372: return dictionary.Union(nullAccessDictionary).ToDictionary(u => u.Key, u => u.Value);
1373: }
1374: }
1375:
1376: ////////////////////////////////////////////////////////////////////////////
1377: ////////////////////////////////////////////////////////////////////////////
1378:
1379: /// <summary>
1380: ///
1381: /// </summary>
1382: public static bool NullifyAccessIdByAccessId(string accessId, out string result)
1383: {
1384: bool b;
1385: int numberOfRecordsWhereAccessIsNullified;
1386: Ia.Ngn.Cl.Model.Service2 service2;
1387:
1388: b = false;
1389: numberOfRecordsWhereAccessIsNullified = 0;
1390:
1391: using (var db = new Ia.Ngn.Cl.Model.Ngn())
1392: {
1393: service2 = (from s in db.Service2 where s.Access.Id == accessId select s).Include(u => u.Access).FirstOrDefault(); //.SingleOrDefault();
1394:
1395: if (service2 != null)
1396: {
1397: service2.Access = null;
1398: service2.Updated = DateTime.UtcNow.AddHours(3);
1399:
1400: db.Service2.Attach(service2);
1401: db.Entry(service2).Property(u => u.Updated).IsModified = true;
1402:
1403: db.SaveChanges();
1404:
1405: numberOfRecordsWhereAccessIsNullified++;
1406: }
1407:
1408: b = true;
1409: }
1410:
1411: result = "Number of records where access is nullified: " + numberOfRecordsWhereAccessIsNullified;
1412:
1413: return b;
1414: }
1415:
1416: ////////////////////////////////////////////////////////////////////////////
1417: ////////////////////////////////////////////////////////////////////////////
1418:
1419: /// <summary>
1420: ///
1421: /// </summary>
1422: public static Dictionary<string, string> MigratedServiceIdToAccessIdDictionary
1423: {
1424: get
1425: {
1426: Dictionary<string, string> dictionary, nullAccessDictionary;
1427:
1428: var migrationDomainList = Ia.Ngn.Cl.Model.Data.Service.MigrationDomainList;
1429: var migrationDomainStringList = migrationDomainList.ConvertAll<string>(delegate (int i) { return i.ToString(); });
1430:
1431: using (var db = new Ia.Ngn.Cl.Model.Ngn())
1432: {
1433: dictionary = (from s in db.Service2
1434: where s.Access != null && migrationDomainStringList.Any(u => s.Service.StartsWith(u))
1435: select new { s.Id, s.Access }).AsNoTracking().ToDictionary(u => u.Id, u => u.Access.Id);
1436:
1437: nullAccessDictionary = (from s in db.Service2
1438: where s.Access == null && migrationDomainStringList.Any(u => s.Service.StartsWith(u))
1439: select new { s.Id, s.Access }).AsNoTracking().ToDictionary(u => u.Id, u => string.Empty);
1440: }
1441:
1442: return dictionary.Union(nullAccessDictionary).ToDictionary(u => u.Key, u => u.Value);
1443: }
1444: }
1445:
1446: ////////////////////////////////////////////////////////////////////////////
1447:
1448: /// <summary>
1449: ///
1450: /// </summary>
1451: public static Dictionary<string, string> MigratedServiceIdToAccessIdInAllowedToBeMigratedOltDictionary
1452: {
1453: get
1454: {
1455: Dictionary<string, string> dictionary;
1456:
1457: var allowedToBeMigratedOltIdList = Ia.Ngn.Cl.Model.Data.Service.AllowedToBeMigratedOltIdList;
1458:
1459: var migrationDomainList = Ia.Ngn.Cl.Model.Data.Service.MigrationDomainList;
1460: var migrationDomainStringList = migrationDomainList.ConvertAll<string>(delegate (int i) { return i.ToString(); });
1461:
1462: using (var db = new Ia.Ngn.Cl.Model.Ngn())
1463: {
1464: dictionary = (from s in db.Service2
1465: where s.Access != null && migrationDomainStringList.Any(u => s.Service.StartsWith(u)) && allowedToBeMigratedOltIdList.Contains(s.Access.Olt) && s.ServiceType == Ia.Ngn.Cl.Model.Business.Service.ServiceType.ImsService
1466: select new { s.Id, s.Access }).ToDictionary(u => u.Id, u => u.Access.Id);
1467: }
1468:
1469: return dictionary.ToDictionary(u => u.Key, u => u.Value);
1470: }
1471: }
1472:
1473: ////////////////////////////////////////////////////////////////////////////
1474:
1475: /// <summary>
1476: ///
1477: /// </summary>
1478: public static List<string> ImsServiceInAllowedToBeMigratedOltList
1479: {
1480: get
1481: {
1482: List<string> list;
1483:
1484: var allowedToBeMigratedOltIdList = Ia.Ngn.Cl.Model.Data.Service.AllowedToBeMigratedOltIdList;
1485:
1486: var migrationDomainList = Ia.Ngn.Cl.Model.Data.Service.MigrationDomainList;
1487: var migrationDomainStringList = migrationDomainList.ConvertAll<string>(delegate (int i) { return i.ToString(); });
1488:
1489: using (var db = new Ia.Ngn.Cl.Model.Ngn())
1490: {
1491: var list0 = (from s in db.Service2
1492: where s.Access != null && s.ServiceType == Ia.Ngn.Cl.Model.Business.Service.ServiceType.ImsService
1493: select new { s.Service, AccessOlt = s.Access.Olt }).AsNoTracking().ToList();
1494:
1495: list = (from l in list0
1496: where migrationDomainStringList.Any(u => l.Service.StartsWith(u)) && allowedToBeMigratedOltIdList.Contains(l.AccessOlt)
1497: select l.Service).ToList();
1498: }
1499:
1500: return list;
1501: }
1502: }
1503:
1504: ////////////////////////////////////////////////////////////////////////////
1505:
1506: /// <summary>
1507: ///
1508: /// </summary>
1509: public static Dictionary<string, string> ImsServiceToAccessIdInAllowedToBeMigratedOltDictionary
1510: {
1511: get
1512: {
1513: Dictionary<string, string> dictionary;
1514:
1515: var allowedToBeMigratedOltIdList = Ia.Ngn.Cl.Model.Data.Service.AllowedToBeMigratedOltIdList;
1516:
1517: var migrationDomainList = Ia.Ngn.Cl.Model.Data.Service.MigrationDomainList;
1518: var migrationDomainStringList = migrationDomainList.ConvertAll<string>(delegate (int i) { return i.ToString(); });
1519:
1520: using (var db = new Ia.Ngn.Cl.Model.Ngn())
1521: {
1522: var list = (from s in db.Service2
1523: where s.Access != null && s.ServiceType == Ia.Ngn.Cl.Model.Business.Service.ServiceType.ImsService
1524: select new { s.Service, AccessId = s.Access.Id, AccessOlt = s.Access.Olt }).AsNoTracking().ToList();
1525:
1526: dictionary = (from l in list
1527: where migrationDomainStringList.Any(u => l.Service.StartsWith(u)) && allowedToBeMigratedOltIdList.Contains(l.AccessOlt)
1528: select l).ToDictionary(u => u.Service, u => u.AccessId);
1529: }
1530:
1531: return dictionary.ToDictionary(u => u.Key, u => u.Value);
1532: }
1533: }
1534:
1535: ////////////////////////////////////////////////////////////////////////////
1536:
1537: /// <summary>
1538: ///
1539: /// </summary>
1540: public static List<string> MsanServiceInAllowedToBeMigratedDomainList
1541: {
1542: get
1543: {
1544: List<string> list;
1545:
1546: var migrationDomainList = Ia.Ngn.Cl.Model.Data.Service.MigrationDomainList;
1547: var migrationDomainStringList = migrationDomainList.ConvertAll<string>(delegate (int i) { return i.ToString(); });
1548:
1549: var msanServiceList = Ia.Ngn.Cl.Model.Data.Service2.MsanServiceList;
1550:
1551: list = (from l in msanServiceList
1552: where migrationDomainStringList.Any(u => l.StartsWith(u))
1553: select l).ToList();
1554:
1555: return list;
1556: }
1557: }
1558:
1559: ////////////////////////////////////////////////////////////////////////////
1560:
1561: /// <summary>
1562: ///
1563: /// </summary>
1564: public static Dictionary<string, string> ServiceToAccessIdDictionary
1565: {
1566: get
1567: {
1568: string key;
1569: Dictionary<string, string> serviceToAccessIdDictionary, serviceIdToAccessIdDictionary;
1570:
1571: serviceIdToAccessIdDictionary = ServiceIdToAccessIdDictionary;
1572:
1573: serviceToAccessIdDictionary = new Dictionary<string, string>(serviceIdToAccessIdDictionary.Count);
1574:
1575: foreach (KeyValuePair<string, string> kvp in serviceIdToAccessIdDictionary)
1576: {
1577: key = Ia.Ngn.Cl.Model.Business.Service.ServiceIdToService(kvp.Key);
1578:
1579: serviceToAccessIdDictionary[key] = kvp.Value;
1580: }
1581:
1582: return serviceToAccessIdDictionary;
1583: }
1584: }
1585:
1586: ////////////////////////////////////////////////////////////////////////////
1587:
1588: /// <summary>
1589: ///
1590: /// </summary>
1591: public static Dictionary<string, string> ServiceIdToAccessNameDictionary
1592: {
1593: get
1594: {
1595: Dictionary<string, string> dictionary, nullAccessDictionary;
1596:
1597: using (var db = new Ia.Ngn.Cl.Model.Ngn())
1598: {
1599: dictionary = (from s in db.Service2
1600: where s.ServiceType == Ia.Ngn.Cl.Model.Business.Service.ServiceType.ImsService && s.Access != null
1601: select new { s.Id, s.Access }).ToDictionary(u => u.Id, u => u.Access.Name);
1602:
1603: nullAccessDictionary = (from s in db.Service2
1604: where s.ServiceType == Ia.Ngn.Cl.Model.Business.Service.ServiceType.ImsService && s.Access == null
1605: select s.Id).ToDictionary(u => u, null);
1606: }
1607:
1608: return dictionary.Union(nullAccessDictionary).ToDictionary(u => u.Key, u => u.Value);
1609: }
1610: }
1611:
1612: ////////////////////////////////////////////////////////////////////////////
1613:
1614: /// <summary>
1615: ///
1616: /// </summary>
1617: public static Dictionary<string, int> AccessNameToSeviceCountDictionary()
1618: {
1619: string accessName;
1620: Dictionary<string, int> dictionary;
1621:
1622: using (var db = new Ia.Ngn.Cl.Model.Ngn())
1623: {
1624: var accessIdToAccessNameDictionary = Ia.Ngn.Cl.Model.Data.NetworkDesignDocument.OntAccessIdToOntAccessNameDictionary;
1625:
1626: var serviceToAccessIdDictionary = (from s in db.Service2
1627: where s.ServiceType == Ia.Ngn.Cl.Model.Business.Service.ServiceType.ImsService && s.Access != null
1628: select new { s.Service, AccessId = s.Access.Id }).ToDictionary(u => u.Service, u => u.AccessId);
1629:
1630: dictionary = new Dictionary<string, int>(serviceToAccessIdDictionary.Count);
1631:
1632: foreach (var accessName0 in accessIdToAccessNameDictionary.Values)
1633: {
1634: dictionary[accessName0] = 0;
1635: }
1636:
1637: foreach (KeyValuePair<string, string> kvp in serviceToAccessIdDictionary)
1638: {
1639: accessName = accessIdToAccessNameDictionary[kvp.Value];
1640:
1641: if (!string.IsNullOrEmpty(accessName))
1642: {
1643: if (dictionary.ContainsKey(accessName))
1644: {
1645: dictionary[accessName] = dictionary[accessName] + 1;
1646: }
1647: else dictionary[accessName] = 1;
1648: }
1649: }
1650: }
1651:
1652: return dictionary.ToDictionary(u => u.Key, u => u.Value);
1653: }
1654:
1655: ////////////////////////////////////////////////////////////////////////////
1656:
1657: /// <summary>
1658: ///
1659: /// </summary>
1660: public static Dictionary<string, List<string>> OntAccessIdToSeviceListDictionary()
1661: {
1662: string service, accessId;
1663: Dictionary<string, List<string>> dictionary;
1664:
1665: using (var db = new Ia.Ngn.Cl.Model.Ngn())
1666: {
1667: var ontAccessIdList = Ia.Ngn.Cl.Model.Data.NetworkDesignDocument.OntAccessIdList;
1668:
1669: var serviceToAccessIdDictionary = (from s in db.Service2
1670: where s.ServiceType == Ia.Ngn.Cl.Model.Business.Service.ServiceType.ImsService && s.Access != null
1671: select new { s.Service, AccessId = s.Access.Id }).ToDictionary(u => u.Service, u => u.AccessId);
1672:
1673: dictionary = new Dictionary<string, List<string>>(serviceToAccessIdDictionary.Count);
1674:
1675: foreach (var ontAccessId in ontAccessIdList) dictionary[ontAccessId] = new List<string>();
1676:
1677: foreach (var kvp in serviceToAccessIdDictionary)
1678: {
1679: service = kvp.Key;
1680: accessId = kvp.Value;
1681:
1682: dictionary[accessId].Add(service);
1683: }
1684: }
1685:
1686: return dictionary;
1687: }
1688:
1689: ////////////////////////////////////////////////////////////////////////////
1690:
1691: /// <summary>
1692: ///
1693: /// </summary>
1694: public static Dictionary<string, Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Ont> ServiceToNddOntDictionary
1695: {
1696: get
1697: {
1698: string key;
1699: Dictionary<string, Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Ont> dictionary;
1700:
1701: var serviceIdToAccessIdDictionary = Ia.Ngn.Cl.Model.Data.Service2.ServiceIdToAccessIdDictionary;
1702: var ontAccessIdToOntDictionary = Ia.Ngn.Cl.Model.Data.NetworkDesignDocument.OntAccessIdToOntDictionary;
1703:
1704: dictionary = new Dictionary<string, Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Ont>(serviceIdToAccessIdDictionary.Count);
1705:
1706: foreach (KeyValuePair<string, string> kvp in serviceIdToAccessIdDictionary)
1707: {
1708: key = Ia.Ngn.Cl.Model.Business.Service.ServiceIdToService(kvp.Key);
1709:
1710: if (!string.IsNullOrEmpty(kvp.Value)) dictionary[key] = ontAccessIdToOntDictionary[kvp.Value];
1711: else dictionary[key] = null;
1712: }
1713:
1714: return dictionary;
1715: }
1716: }
1717:
1718: ////////////////////////////////////////////////////////////////////////////
1719:
1720: /// <summary>
1721: ///
1722: /// </summary>
1723: public static Dictionary<string, Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Ont> PstnServiceToNddOntDictionary
1724: {
1725: get
1726: {
1727: string key;
1728: Dictionary<string, Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Ont> dictionary;
1729:
1730: var pstnServiceIdToAccessIdDictionary = Ia.Ngn.Cl.Model.Data.Service2.PstnServiceIdToAccessIdDictionary;
1731: var ontAccessIdToOntDictionary = Ia.Ngn.Cl.Model.Data.NetworkDesignDocument.OntAccessIdToOntDictionary;
1732:
1733: dictionary = new Dictionary<string, Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Ont>(pstnServiceIdToAccessIdDictionary.Count);
1734:
1735: foreach (KeyValuePair<string, string> kvp in pstnServiceIdToAccessIdDictionary)
1736: {
1737: key = Ia.Ngn.Cl.Model.Business.Service.ServiceIdToService(kvp.Key);
1738:
1739: if (!string.IsNullOrEmpty(kvp.Value)) dictionary[key] = ontAccessIdToOntDictionary[kvp.Value];
1740: //else dictionary[key] = null;
1741: }
1742:
1743: return dictionary;
1744: }
1745: }
1746:
1747: ////////////////////////////////////////////////////////////////////////////
1748:
1749: /// <summary>
1750: ///
1751: /// </summary>
1752: public static Dictionary<string, Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Vendor> MigratedServiceToNddOntRouterVendorDictionary
1753: {
1754: get
1755: {
1756: string key;
1757: Dictionary<string, Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Vendor> dictionary;
1758:
1759: var migratedServiceIdToAccessIdDictionary = Ia.Ngn.Cl.Model.Data.Service2.MigratedServiceIdToAccessIdDictionary;
1760: var ontAccessIdToOntDictionary = Ia.Ngn.Cl.Model.Data.NetworkDesignDocument.OntAccessIdToOntDictionary;
1761:
1762: dictionary = new Dictionary<string, Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Vendor>(migratedServiceIdToAccessIdDictionary.Count);
1763:
1764: foreach (KeyValuePair<string, string> kvp in migratedServiceIdToAccessIdDictionary)
1765: {
1766: key = Ia.Ngn.Cl.Model.Business.Service.ServiceIdToService(kvp.Key);
1767:
1768: //if (!string.IsNullOrEmpty(kvp.Value)) dictionary[key] = ontAccessIdToOntDictionary[kvp.Value];
1769: //else dictionary[key] = null;
1770: }
1771:
1772: return dictionary;
1773: }
1774: }
1775:
1776: ////////////////////////////////////////////////////////////////////////////
1777:
1778: /// <summary>
1779: ///
1780: /// </summary>
1781: public static Dictionary<string, Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Site> ServiceToSiteDictionary
1782: {
1783: get
1784: {
1785: int fourLetterServiceDomain, fiveLetterServiceDomain;
1786: string service;
1787: Dictionary<string, Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Site> dictionary;
1788:
1789: var serviceIdList = Ia.Ngn.Cl.Model.Data.Service2.ServiceIdList;
1790: var routerDomainToSiteDictionary = Ia.Ngn.Cl.Model.Data.NetworkDesignDocument.RouterDomainToSiteDictionary;
1791:
1792: dictionary = new Dictionary<string, Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Site>(serviceIdList.Count);
1793:
1794: foreach (string s in serviceIdList)
1795: {
1796: service = Ia.Ngn.Cl.Model.Business.Service.ServiceIdToService(s);
1797:
1798: if (service.Length >= 5)
1799: {
1800: fourLetterServiceDomain = int.Parse(service.Substring(0, 4));
1801: fiveLetterServiceDomain = int.Parse(service.Substring(0, 5));
1802:
1803: if (routerDomainToSiteDictionary.ContainsKey(fiveLetterServiceDomain)) dictionary[service] = routerDomainToSiteDictionary[fiveLetterServiceDomain];
1804: else if (routerDomainToSiteDictionary.ContainsKey(fourLetterServiceDomain)) dictionary[service] = routerDomainToSiteDictionary[fourLetterServiceDomain];
1805: //else throw new System.ArgumentOutOfRangeException("Service number " + service + " is out of range");
1806: }
1807: //else throw new System.ArgumentOutOfRangeException("Service number " + service + " is out of range");
1808: }
1809:
1810: return dictionary;
1811: }
1812: }
1813:
1814: ////////////////////////////////////////////////////////////////////////////
1815:
1816: /// <summary>
1817: ///
1818: /// </summary>
1819: public static Dictionary<string, Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Site> ImsServiceToSiteDictionary
1820: {
1821: get
1822: {
1823: int fourLetterServiceDomain, fiveLetterServiceDomain;
1824: string service;
1825: Dictionary<string, Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Site> dictionary;
1826:
1827: var serviceIdList = Ia.Ngn.Cl.Model.Data.Service2.ImsServiceIdList;
1828: var routerDomainToSiteDictionary = Ia.Ngn.Cl.Model.Data.NetworkDesignDocument.RouterDomainToSiteDictionary;
1829:
1830: dictionary = new Dictionary<string, Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Site>(serviceIdList.Count);
1831:
1832: foreach (string s in serviceIdList)
1833: {
1834: service = Ia.Ngn.Cl.Model.Business.Service.ServiceIdToService(s);
1835:
1836: if (service.Length >= 5)
1837: {
1838: fourLetterServiceDomain = int.Parse(service.Substring(0, 4));
1839: fiveLetterServiceDomain = int.Parse(service.Substring(0, 5));
1840:
1841: if (routerDomainToSiteDictionary.ContainsKey(fiveLetterServiceDomain)) dictionary[service] = routerDomainToSiteDictionary[fiveLetterServiceDomain];
1842: else if (routerDomainToSiteDictionary.ContainsKey(fourLetterServiceDomain)) dictionary[service] = routerDomainToSiteDictionary[fourLetterServiceDomain];
1843: //else throw new System.ArgumentOutOfRangeException("Service number " + service + " is out of range");
1844: }
1845: //else throw new System.ArgumentOutOfRangeException("Service number " + service + " is out of range");
1846: }
1847:
1848: return dictionary;
1849: }
1850: }
1851:
1852: ////////////////////////////////////////////////////////////////////////////
1853:
1854: /// <summary>
1855: ///
1856: /// </summary>
1857: public static Dictionary<string, Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Site> MsanServiceToSiteDictionary
1858: {
1859: get
1860: {
1861: Dictionary<string, Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Site> dictionary;
1862:
1863: var imsServiceToSiteDictionary = Ia.Ngn.Cl.Model.Data.Service2.ImsServiceToSiteDictionary;
1864:
1865: var msanServiceList = Ia.Ngn.Cl.Model.Data.Service2.MsanServiceList;
1866:
1867: dictionary = new Dictionary<string, Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Site>(msanServiceList.Count);
1868:
1869: foreach (string service in msanServiceList)
1870: {
1871: if (imsServiceToSiteDictionary.ContainsKey(service)) // I had to add this because the systems sees 2489 numbers in MSAN
1872: {
1873: dictionary[service] = imsServiceToSiteDictionary[service];
1874: }
1875: }
1876:
1877: return dictionary;
1878: }
1879: }
1880:
1881: ////////////////////////////////////////////////////////////////////////////
1882:
1883: /// <summary>
1884: ///
1885: /// </summary>
1886: public static Dictionary<string, Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Site> MsanServiceToSiteInAllowedToBeMigratedDomainListDictionary
1887: {
1888: get
1889: {
1890: Dictionary<string, Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Site> dictionary;
1891:
1892: var msanServiceInAllowedToBeMigratedDomainList = Ia.Ngn.Cl.Model.Data.Service2.MsanServiceInAllowedToBeMigratedDomainList;
1893: var msanServiceToSiteDictionary = Ia.Ngn.Cl.Model.Data.Service2.MsanServiceToSiteDictionary;
1894:
1895: dictionary = new Dictionary<string, Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Site>(msanServiceInAllowedToBeMigratedDomainList.Count);
1896:
1897: foreach (string service in msanServiceInAllowedToBeMigratedDomainList)
1898: {
1899: if (msanServiceToSiteDictionary.ContainsKey(service)) // I had to add this because the systems sees 2489 numbers in MSAN
1900: {
1901: dictionary[service] = msanServiceToSiteDictionary[service];
1902: }
1903: }
1904:
1905: return dictionary;
1906: }
1907: }
1908:
1909: ////////////////////////////////////////////////////////////////////////////
1910:
1911: /// <summary>
1912: ///
1913: /// </summary>
1914: public static Dictionary<string, Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Site> PstnServiceToSiteDictionary
1915: {
1916: get
1917: {
1918: int fourLetterServiceDomain, fiveLetterServiceDomain;
1919: string service;
1920: Dictionary<string, Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Site> dictionary;
1921:
1922: var serviceIdList = Ia.Ngn.Cl.Model.Data.Service2.PstnServiceIdList;
1923: var routerDomainToSiteDictionary = Ia.Ngn.Cl.Model.Data.NetworkDesignDocument.RouterDomainToSiteDictionary;
1924:
1925: dictionary = new Dictionary<string, Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Site>(serviceIdList.Count);
1926:
1927: foreach (string s in serviceIdList)
1928: {
1929: service = Ia.Ngn.Cl.Model.Business.Service.ServiceIdToService(s);
1930:
1931: if (service.Length >= 5)
1932: {
1933: fourLetterServiceDomain = int.Parse(service.Substring(0, 4));
1934: fiveLetterServiceDomain = int.Parse(service.Substring(0, 5));
1935:
1936: if (routerDomainToSiteDictionary.ContainsKey(fiveLetterServiceDomain)) dictionary[service] = routerDomainToSiteDictionary[fiveLetterServiceDomain];
1937: else if (routerDomainToSiteDictionary.ContainsKey(fourLetterServiceDomain)) dictionary[service] = routerDomainToSiteDictionary[fourLetterServiceDomain];
1938: //else throw new System.ArgumentOutOfRangeException("Service number " + service + " is out of range");
1939: }
1940: //else throw new System.ArgumentOutOfRangeException("Service number " + service + " is out of range");
1941: }
1942:
1943: return dictionary;
1944: }
1945: }
1946:
1947: ////////////////////////////////////////////////////////////////////////////
1948:
1949: /// <summary>
1950: ///
1951: /// </summary>
1952: public static Dictionary<string, string> ServiceNotInServiceRequestServiceToSiteDictionary
1953: {
1954: get
1955: {
1956: string service, siteName;
1957: Dictionary<string, string> dictionary;
1958:
1959: var serviceToSiteNameDictionary = Ia.Ngn.Cl.Model.Data.Service2.ServiceToSiteDictionary;
1960: var serviceRequestServiceServiceToSiteNameDictionary = Ia.Ngn.Cl.Model.Data.ServiceRequestService.ServiceToSiteDictionary;
1961:
1962: dictionary = new Dictionary<string, string>();
1963:
1964: foreach (var kvp in serviceToSiteNameDictionary)
1965: {
1966: service = kvp.Key;
1967: siteName = kvp.Value.Name;
1968:
1969: if (!serviceRequestServiceServiceToSiteNameDictionary.ContainsKey(service)) dictionary.Add(service, siteName);
1970: }
1971:
1972: return dictionary;
1973: }
1974: }
1975:
1976: ////////////////////////////////////////////////////////////////////////////
1977:
1978: /// <summary>
1979: ///
1980: /// </summary>
1981: public static Dictionary<string, string> ServiceNotInProvisionedServiceRequestServiceToSiteDictionary
1982: {
1983: get
1984: {
1985: string service, siteName;
1986: Dictionary<string, string> dictionary;
1987:
1988: var serviceToSiteNameDictionary = Ia.Ngn.Cl.Model.Data.Service2.ServiceToSiteDictionary;
1989: var serviceRequestServiceProvisionedServiceToSiteNameDictionary = Ia.Ngn.Cl.Model.Data.ServiceRequestService.ProvisionedServiceToSiteDictionary;
1990:
1991: dictionary = new Dictionary<string, string>();
1992:
1993: foreach (var kvp in serviceToSiteNameDictionary)
1994: {
1995: service = kvp.Key;
1996: siteName = kvp.Value.Name;
1997:
1998: if (!serviceRequestServiceProvisionedServiceToSiteNameDictionary.ContainsKey(service)) dictionary.Add(service, siteName);
1999: }
2000:
2001: return dictionary;
2002: }
2003: }
2004:
2005: ////////////////////////////////////////////////////////////////////////////
2006:
2007: /// <summary>
2008: ///
2009: /// </summary>
2010: public static Dictionary<string, string> ImsServiceNotInProvisionedServiceRequestServiceToSiteDictionary
2011: {
2012: get
2013: {
2014: string service, siteName;
2015: Dictionary<string, string> dictionary;
2016:
2017: var serviceToSiteNameDictionary = Ia.Ngn.Cl.Model.Data.Service2.ImsServiceToSiteDictionary;
2018: var serviceRequestServiceProvisionedServiceToSiteNameDictionary = Ia.Ngn.Cl.Model.Data.ServiceRequestService.ProvisionedServiceToSiteDictionary;
2019:
2020: var doesNotExistInSrsList = Ia.Ngn.Cl.Model.Data.Service2.ServiceImsServicesThatDoNotExistInServiceRequestServicesList();
2021:
2022: dictionary = new Dictionary<string, string>();
2023:
2024: foreach (var kvp in serviceToSiteNameDictionary)
2025: {
2026: service = kvp.Key;
2027: siteName = kvp.Value.Name;
2028:
2029: if (!serviceRequestServiceProvisionedServiceToSiteNameDictionary.ContainsKey(service))
2030: {
2031: if (!doesNotExistInSrsList.Contains(service))
2032: {
2033: dictionary.Add(service, siteName);
2034: }
2035: }
2036: }
2037:
2038: return dictionary;
2039: }
2040: }
2041:
2042:
2043: ////////////////////////////////////////////////////////////////////////////
2044:
2045: /// <summary>
2046: ///
2047: /// </summary>
2048: public static List<string> ServiceImsServicesThatDoNotExistInServiceRequestServicesList()
2049: {
2050: List<string> list;
2051:
2052: using (var db = new Ia.Ngn.Cl.Model.Ngn())
2053: {
2054: /*
2055: select s.Service from Service2 s
2056: left outer join ServiceRequestServices srs on srs.Service = s.Service
2057: where s.ServiceType = 1 and srs.Id is null
2058: */
2059:
2060: list = (from s in db.Service2
2061: join srs in db.ServiceRequestServices on s.Service equals srs.Service into srs2
2062: from srs3 in srs2.DefaultIfEmpty()
2063: where srs3 == null && s.ServiceType == Ia.Ngn.Cl.Model.Business.Service.ServiceType.ImsService
2064: select s.Service).ToList();
2065: }
2066:
2067: return list;
2068: }
2069:
2070: ////////////////////////////////////////////////////////////////////////////
2071:
2072: /// <summary>
2073: ///
2074: /// </summary>
2075: public static Dictionary<string, string> PstnServiceNotInProvisionedServiceRequestServiceToSiteDictionary
2076: {
2077: get
2078: {
2079: string service, siteName;
2080: Dictionary<string, string> dictionary;
2081:
2082: var serviceToSiteNameDictionary = Ia.Ngn.Cl.Model.Data.Service2.PstnServiceToSiteDictionary;
2083: var serviceRequestServiceProvisionedServiceToSiteNameDictionary = Ia.Ngn.Cl.Model.Data.ServiceRequestService.ProvisionedServiceToSiteDictionary;
2084:
2085: var doesNotExistInSrsList = Ia.Ngn.Cl.Model.Data.Service2.ServiceImsServicesThatDoNotExistInServiceRequestServicesList();
2086:
2087: dictionary = new Dictionary<string, string>();
2088:
2089: foreach (var kvp in serviceToSiteNameDictionary)
2090: {
2091: service = kvp.Key;
2092: siteName = kvp.Value.Name;
2093:
2094: if (!serviceRequestServiceProvisionedServiceToSiteNameDictionary.ContainsKey(service))
2095: {
2096: if (!doesNotExistInSrsList.Contains(service))
2097: {
2098: dictionary.Add(service, siteName);
2099: }
2100: }
2101: }
2102:
2103: return dictionary;
2104: }
2105: }
2106:
2107: ////////////////////////////////////////////////////////////////////////////
2108:
2109: /// <summary>
2110: ///
2111: /// </summary>
2112: public static Dictionary<string, int> PstnFiveDigitDomainToCountOfServicesDictionary()
2113: {
2114: var dictionary = new Dictionary<string, int>();
2115:
2116: using (var db = new Ia.Ngn.Cl.Model.Ngn())
2117: {
2118: /*
2119: select substring(s.Service,1,5), count(s.Service)
2120: from Service2 s
2121: where ServiceType = 2 -- PSTN
2122: group by substring(s.Service,1,5)
2123: */
2124:
2125: dictionary = (from s in db.Service2
2126: where s.ServiceType == Ia.Ngn.Cl.Model.Business.Service.ServiceType.PstnService
2127: group s.Service.Substring(0, 5) by s.Service.Substring(0, 5) into g
2128: select new { PstnFiveDigitDomain = g.Key, ServiceCount = g.Count() }).AsNoTracking().ToDictionary(t => t.PstnFiveDigitDomain, t => t.ServiceCount);
2129: }
2130:
2131: return dictionary;
2132: }
2133:
2134: ////////////////////////////////////////////////////////////////////////////
2135:
2136: /// <summary>
2137: ///
2138: /// </summary>
2139: public static void UpdatePstnServiceAccess(string service, string newAccessId, Guid userId, out Ia.Cl.Model.Result result)
2140: {
2141: int serviceType;
2142: string service2Id;
2143: Ia.Ngn.Cl.Model.Service2 service2;
2144:
2145: result = new Ia.Cl.Model.Result();
2146:
2147: serviceType = Ia.Ngn.Cl.Model.Business.Service.ServiceType.PstnService; // PSTN
2148: service2Id = Ia.Ngn.Cl.Model.Business.Service2.ServiceId(service, serviceType);
2149:
2150: using (var db = new Ia.Ngn.Cl.Model.Ngn())
2151: {
2152: service2 = (from s in db.Service2 where s.Id == service2Id select s).SingleOrDefault();
2153:
2154: if (service2 != null)
2155: {
2156: if (!string.IsNullOrEmpty(newAccessId))
2157: {
2158: if (service2.Access == null || service2.Access != null && service2.Access.Id != newAccessId)
2159: {
2160: service2.Access = (from a in db.Accesses where a.Id == newAccessId select a).SingleOrDefault();
2161: service2.UserId = userId;
2162:
2163: db.Service2.Attach(service2);
2164: db.Entry(service2).State = Microsoft.EntityFrameworkCore.EntityState.Modified;
2165:
2166: db.SaveChanges();
2167:
2168: result.AddSuccess("Service " + service + " was updated with access " + service2.Access.Name + " (تم تحديث ربط الجهاز بالرقم). ");
2169: }
2170: else
2171: {
2172: result.AddWarning("Service access value was not updated because submitted data is the same as current data and because access is not null (لم يتم تغيير الجهاز المربوط بالرقم لأن المعلومات المعطاة هي ذاتها لم تتغير ولأن الجهاز معرف). ");
2173: }
2174: }
2175: else //if(string.IsNullOrEmpty(updatedAccessId))
2176: {
2177: if (service2.Access != null)
2178: {
2179: service2.Access = (from a in db.Accesses where a.Id == string.Empty select a).SingleOrDefault();
2180: service2.Port = Ia.Ngn.Cl.Model.Business.Default.PortUndefinedOrInvalidOrUnknown;
2181: service2.UserId = userId;
2182:
2183: db.Service2.Attach(service2);
2184: db.Entry(service2).State = Microsoft.EntityFrameworkCore.EntityState.Modified;
2185:
2186: db.SaveChanges();
2187:
2188: result.AddSuccess("Service " + service + " was updated with null access and " + Ia.Ngn.Cl.Model.Business.Default.PortUndefinedOrInvalidOrUnknown + " port (تم مسح ربط الجهاز بالرقم ومسح المنفذ). ");
2189: }
2190: else
2191: {
2192: result.AddWarning("Service access and port values were not reset because submitted data (access null and port " + Ia.Ngn.Cl.Model.Business.Default.PortUndefinedOrInvalidOrUnknown + ") is the same as current data (لم يتم تغيير الجهاز المربوط بالرقم أو المنفذ لأن المعلومات المعطاة هي ذاتها لم تتغير). ");
2193: }
2194: }
2195: }
2196: else
2197: {
2198: result.AddWarning("Service " + service + " does not exist (رقم الخدمة غير موجود). ");
2199: }
2200: }
2201: }
2202:
2203: ////////////////////////////////////////////////////////////////////////////
2204:
2205: /// <summary>
2206: ///
2207: /// </summary>
2208: public static void UpdateImsServiceAccessAndPort(string service, string accessId, int port, Guid userId, out Ia.Cl.Model.Result result)
2209: {
2210: int serviceType;
2211: string service2Id;
2212: Ia.Ngn.Cl.Model.Service2 service2;
2213:
2214: result = new Ia.Cl.Model.Result();
2215:
2216: serviceType = Ia.Ngn.Cl.Model.Business.Service.ServiceType.ImsService;
2217: service2Id = Ia.Ngn.Cl.Model.Business.Service2.ServiceId(service, serviceType);
2218:
2219: using (var db = new Ia.Ngn.Cl.Model.Ngn())
2220: {
2221: service2 = (from s in db.Service2 where s.Id == service2Id select s).Include(s => s.Access).SingleOrDefault();
2222:
2223: if (service2 != null)
2224: {
2225: if (!string.IsNullOrEmpty(accessId))
2226: {
2227: if (service2.Access == null || service2.Access != null && (service2.Access.Id != accessId || service2.Port != port))
2228: {
2229: service2.Access = (from a in db.Accesses where a.Id == accessId select a).SingleOrDefault();
2230: service2.Port = port;
2231: service2.UserId = userId;
2232:
2233: db.Service2.Attach(service2);
2234: db.Entry(service2).State = Microsoft.EntityFrameworkCore.EntityState.Modified;
2235:
2236: db.SaveChanges();
2237:
2238: result.AddSuccess("Service " + service + " was updated with access " + service2.Access.Name + " and port " + port);
2239: }
2240: else
2241: {
2242: result.AddWarning("Service access not updated");
2243: }
2244: }
2245: else
2246: {
2247: if (service2.Access != null)
2248: {
2249: service2.Access = (from a in db.Accesses where a.Id == string.Empty select a).SingleOrDefault();
2250: service2.Port = Ia.Ngn.Cl.Model.Business.Default.PortUndefinedOrInvalidOrUnknown;
2251: service2.UserId = userId;
2252:
2253: db.Service2.Attach(service2);
2254: db.Entry(service2).State = Microsoft.EntityFrameworkCore.EntityState.Modified;
2255:
2256: db.SaveChanges();
2257:
2258: result.AddSuccess("Service " + service + " was updated with null access and " + Ia.Ngn.Cl.Model.Business.Default.PortUndefinedOrInvalidOrUnknown + " port.");
2259: }
2260: else
2261: {
2262: result.AddWarning("Service access not reset.");
2263: }
2264: }
2265: }
2266: else
2267: {
2268: result.AddWarning("Service " + service + " does not exist.");
2269: }
2270: }
2271: }
2272:
2273: ////////////////////////////////////////////////////////////////////////////
2274:
2275: /// <summary>
2276: ///
2277: /// </summary>
2278: public static void ProvisioningStateOfServicesWithinPstnSite(int siteId, out List<string> provisionedServiceList, out List<string> unprovisionedServiceList)
2279: {
2280: var site = (from s in Ia.Ngn.Cl.Model.Data.NetworkDesignDocument.PstnList
2281: where s.Id == siteId
2282: select s).SingleOrDefault();
2283:
2284: if (site != null)
2285: {
2286: provisionedServiceList = new List<string>();
2287: unprovisionedServiceList = new List<string>();
2288:
2289: using (var db = new Ia.Ngn.Cl.Model.Ngn())
2290: {
2291: var provisionedService0List = (from s in db.Service2
2292: join srs in db.ServiceRequestServices on s.Service equals srs.Service
2293: where s.ServiceType == Ia.Ngn.Cl.Model.Business.Service.ServiceType.PstnService && srs.Provisioned == true
2294: select s.Service).AsNoTracking().ToList();
2295:
2296: foreach (var s in provisionedService0List)
2297: {
2298: if (site.DomainList.Any(u => s.StartsWith(u.ToString()))) provisionedServiceList.Add(s);
2299: }
2300:
2301: var unprovisionedService0List = (from s in db.Service2
2302: join srs in db.ServiceRequestServices on s.Service equals srs.Service
2303: where s.ServiceType == Ia.Ngn.Cl.Model.Business.Service.ServiceType.PstnService && srs.Provisioned == false
2304: select s.Service).AsNoTracking().ToList();
2305:
2306: foreach (var s in unprovisionedService0List)
2307: {
2308: if (site.DomainList.Any(u => s.StartsWith(u.ToString()))) unprovisionedServiceList.Add(s);
2309: }
2310: }
2311: }
2312: else
2313: {
2314: provisionedServiceList = new List<string>();
2315: unprovisionedServiceList = new List<string>();
2316: }
2317: }
2318:
2319: ////////////////////////////////////////////////////////////////////////////
2320: ////////////////////////////////////////////////////////////////////////////
2321: }
2322:
2323: ////////////////////////////////////////////////////////////////////////////
2324: ////////////////////////////////////////////////////////////////////////////
2325: }