1: using System;
2: using System.Collections;
3: using System.Collections.Generic;
4: using System.Data;
5: using System.Data.Entity;
6: using System.Linq;
7:
8: namespace Ia.Ngn.Cl.Model.Data
9: {
10: ////////////////////////////////////////////////////////////////////////////
11:
12: /// <summary publish="true">
13: /// Service support class for Next Generation Network (NGN) data model.
14: /// </summary>
15: ///
16: /// <remarks>
17: /// Copyright © 2006-2020 Jasem Y. Al-Shamlan (info@ia.com.kw), Integrated Applications - Kuwait. All Rights Reserved.
18: ///
19: /// 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
20: /// the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
21: ///
22: /// This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
23: /// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
24: ///
25: /// You should have received a copy of the GNU General Public License along with this library. If not, see http://www.gnu.org/licenses.
26: ///
27: /// Copyright notice: This notice may not be removed or altered from any source distribution.
28: /// </remarks>
29: public partial class Service2
30: {
31: public Service2() { }
32:
33: ////////////////////////////////////////////////////////////////////////////
34:
35: /// <summary>
36: /// Read service2
37: /// </summary>
38: public static Ia.Ngn.Cl.Model.Service2 Read(string service)
39: {
40: Ia.Ngn.Cl.Model.Service2 service2;
41:
42: using (var db = new Ia.Ngn.Cl.Model.Ngn())
43: {
44: service2 = (from s in db.Service2s
45: where s.ServiceType == Ia.Ngn.Cl.Model.Business.Service.ServiceType.GponService && s.Service == service
46: select s).SingleOrDefault();
47: }
48:
49: return service2;
50: }
51:
52: ////////////////////////////////////////////////////////////////////////////
53:
54: /// <summary>
55: /// Read service2s for service list
56: /// </summary>
57: public static List<Ia.Ngn.Cl.Model.Service2> ReadList(List<string> serviceList)
58: {
59: List<Ia.Ngn.Cl.Model.Service2> service2List;
60:
61: using (var db = new Ia.Ngn.Cl.Model.Ngn())
62: {
63: service2List = (from s in db.Service2s
64: where s.ServiceType == Ia.Ngn.Cl.Model.Business.Service.ServiceType.GponService && serviceList.Contains(s.Service)
65: select s).ToList();
66: }
67:
68: return service2List;
69: }
70:
71: ////////////////////////////////////////////////////////////////////////////
72:
73: /// <summary>
74: /// Read PSTN service2
75: /// </summary>
76: public static Ia.Ngn.Cl.Model.Service2 ReadPstn(string service)
77: {
78: Ia.Ngn.Cl.Model.Service2 service2;
79:
80: using (var db = new Ia.Ngn.Cl.Model.Ngn())
81: {
82: service2 = (from s in db.Service2s
83: where s.ServiceType == Ia.Ngn.Cl.Model.Business.Service.ServiceType.PstnService && s.Service == service
84: select s).SingleOrDefault();
85: }
86:
87: return service2;
88: }
89:
90: ////////////////////////////////////////////////////////////////////////////
91:
92: /// <summary>
93: /// Read PSTN service2s for service list
94: /// </summary>
95: public static List<Ia.Ngn.Cl.Model.Service2> ReadPstnList(List<string> serviceList)
96: {
97: List<Ia.Ngn.Cl.Model.Service2> service2List;
98:
99: using (var db = new Ia.Ngn.Cl.Model.Ngn())
100: {
101: service2List = (from s in db.Service2s
102: where s.ServiceType == Ia.Ngn.Cl.Model.Business.Service.ServiceType.PstnService && serviceList.Contains(s.Service)
103: select s).ToList();
104: }
105:
106: return service2List;
107: }
108:
109: ////////////////////////////////////////////////////////////////////////////
110:
111: /// <summary>
112: /// Read service of a number
113: /// </summary>
114: public static Ia.Ngn.Cl.Model.Service2 Read(long number)
115: {
116: Ia.Ngn.Cl.Model.Service2 service;
117:
118: using (var db = new Ia.Ngn.Cl.Model.Ngn())
119: {
120: service = (from s in db.Service2s
121: where s.ServiceType == Ia.Ngn.Cl.Model.Business.Service.ServiceType.GponService && s.Service == number.ToString()
122: select s).SingleOrDefault();
123: }
124:
125: return service;
126: }
127:
128: ////////////////////////////////////////////////////////////////////////////
129:
130: /// <summary>
131: /// Read service from Id
132: /// </summary>
133: public static Ia.Ngn.Cl.Model.Service2 ReadByIdIncludeAccess(string serviceId)
134: {
135: Ia.Ngn.Cl.Model.Service2 service2;
136:
137: using (var db = new Ia.Ngn.Cl.Model.Ngn())
138: {
139: service2 = (from s in db.Service2s.Include(a => a.Access)
140: where s.ServiceType == Ia.Ngn.Cl.Model.Business.Service.ServiceType.GponService && s.Id == serviceId
141: select s).SingleOrDefault();
142: }
143:
144: return service2;
145: }
146:
147: ////////////////////////////////////////////////////////////////////////////
148:
149: /// <summary>
150: /// Read service of a number
151: /// </summary>
152: public static Ia.Ngn.Cl.Model.Service2 ReadWithAccess(string service)
153: {
154: Ia.Ngn.Cl.Model.Service2 service2;
155:
156: using (var db = new Ia.Ngn.Cl.Model.Ngn())
157: {
158: service2 = (from s in db.Service2s.Include(a => a.Access)
159: where s.ServiceType == Ia.Ngn.Cl.Model.Business.Service.ServiceType.GponService && s.Service == service
160: select s).SingleOrDefault();
161: }
162:
163: return service2;
164: }
165:
166: ////////////////////////////////////////////////////////////////////////////
167:
168: /// <summary>
169: ///
170: /// </summary>
171: public static List<Ia.Ngn.Cl.Model.Service2> List()
172: {
173: List<Ia.Ngn.Cl.Model.Service2> serviceList;
174:
175: using (var db = new Ia.Ngn.Cl.Model.Ngn())
176: {
177: serviceList = (from s in db.Service2s where s.ServiceType == Ia.Ngn.Cl.Model.Business.Service.ServiceType.GponService select s).ToList();
178: }
179:
180: return serviceList;
181: }
182:
183: ////////////////////////////////////////////////////////////////////////////
184:
185: /// <summary>
186: ///
187: /// </summary>
188: public static List<string> List(List<int> domainList)
189: {
190: List<string> stringDomainList;
191: List<string> serviceList;
192:
193: stringDomainList = new List<string>();
194:
195: using (var db = new Ia.Ngn.Cl.Model.Ngn())
196: {
197: if (domainList != null)
198: {
199: foreach (int i in domainList) stringDomainList.Add(i.ToString());
200:
201: serviceList = (from s in db.Service2s
202: where s.ServiceType == Ia.Ngn.Cl.Model.Business.Service.ServiceType.GponService && stringDomainList.Any(u => s.Service.StartsWith(u.ToString()))
203: select s.Service).ToList();
204: }
205: else
206: {
207: serviceList = (from s in db.Service2s where s.ServiceType == Ia.Ngn.Cl.Model.Business.Service.ServiceType.GponService select s.Service).ToList();
208: }
209: }
210:
211: return serviceList;
212: }
213:
214: ////////////////////////////////////////////////////////////////////////////
215:
216: /// <summary>
217: ///
218: /// </summary>
219: public static List<string> ServiceList
220: {
221: get
222: {
223: List<string> list;
224:
225: using (var db = new Ia.Ngn.Cl.Model.Ngn())
226: {
227: list = (from s in db.Service2s where s.ServiceType == Ia.Ngn.Cl.Model.Business.Service.ServiceType.GponService select s.Service).ToList();
228: }
229:
230: return list;
231: }
232: }
233:
234: ////////////////////////////////////////////////////////////////////////////
235:
236: /// <summary>
237: ///
238: /// </summary>
239: public static List<string> NgnAndPstnServiceIdList
240: {
241: get
242: {
243: List<string> list;
244:
245: using (var db = new Ia.Ngn.Cl.Model.Ngn())
246: {
247: list = (from s in db.Service2s select s.Id).ToList();
248: }
249:
250: return list.ToList();
251: }
252: }
253:
254: ////////////////////////////////////////////////////////////////////////////
255:
256: /// <summary>
257: ///
258: /// </summary>
259: public static List<string> ServiceIdList
260: {
261: get
262: {
263: List<string> list;
264:
265: using (var db = new Ia.Ngn.Cl.Model.Ngn())
266: {
267: list = (from s in db.Service2s /*where s.ServiceType == Ia.Ngn.Cl.Model.Business.Service.ServiceType.GponService*/ select s.Id).ToList();
268: }
269:
270: return list.ToList();
271: }
272: }
273:
274: ////////////////////////////////////////////////////////////////////////////
275:
276: /// <summary>
277: ///
278: /// </summary>
279: public static List<Ia.Ngn.Cl.Model.Business.ServiceOnt> ServiceOntList
280: {
281: get
282: {
283: List<Ia.Ngn.Cl.Model.Business.ServiceOnt> list;
284:
285: var ontAccessIdToOntForOltIdListDictionary = Ia.Ngn.Cl.Model.Data.NetworkDesignDocument.OntAccessIdToOntDictionary;
286:
287: using (var db = new Ia.Ngn.Cl.Model.Ngn())
288: {
289: list = (from s in db.Service2s
290: where s.ServiceType == Ia.Ngn.Cl.Model.Business.Service.ServiceType.GponService
291: select new Ia.Ngn.Cl.Model.Business.ServiceOnt { ServiceId = s.Id, Service = s.Service, AccessId = s.Access != null ? s.Access.Id : string.Empty, CreatedDateTime = s.Created }).ToList();
292: }
293:
294: foreach (var l in list)
295: {
296: l.Ont = ontAccessIdToOntForOltIdListDictionary.ContainsKey(l.AccessId) ? ontAccessIdToOntForOltIdListDictionary[l.AccessId] : null;
297: }
298:
299: return list;
300: }
301: }
302:
303: ////////////////////////////////////////////////////////////////////////////
304:
305: /// <summary>
306: ///
307: /// </summary>
308: public static List<Ia.Ngn.Cl.Model.Service2> PstnServiceList
309: {
310: get
311: {
312: List<Ia.Ngn.Cl.Model.Service2> list;
313:
314: using (var db = new Ia.Ngn.Cl.Model.Ngn())
315: {
316: list = (from s in db.Service2s where s.ServiceType == Ia.Ngn.Cl.Model.Business.Service.ServiceType.PstnService select s).Include(s => s.Access).ToList();
317: }
318:
319: return list.ToList();
320: }
321: }
322:
323: ////////////////////////////////////////////////////////////////////////////
324:
325: /// <summary>
326: ///
327: /// </summary>
328: public static Dictionary<string, int> ServiceIdToPortDictionary
329: {
330: get
331: {
332: Dictionary<string, int> dictionary;
333:
334: using (var db = new Ia.Ngn.Cl.Model.Ngn())
335: {
336: dictionary = (from s in db.Service2s
337: where s.ServiceType == Ia.Ngn.Cl.Model.Business.Service.ServiceType.GponService && s.Access != null
338: select new { s.Id, s.Port }).ToDictionary(m => m.Id, m => m.Port);
339: }
340:
341: return dictionary;
342: }
343: }
344:
345: ////////////////////////////////////////////////////////////////////////////
346:
347: /// <summary>
348: ///
349: /// </summary>
350: public static Ia.Ngn.Cl.Model.Access ReadAccess(string id)
351: {
352: Ia.Ngn.Cl.Model.Access access;
353:
354: using (var db = new Ia.Ngn.Cl.Model.Ngn())
355: {
356: access = (from s in db.Service2s
357: where s.ServiceType == Ia.Ngn.Cl.Model.Business.Service.ServiceType.GponService && s.Id == id
358: select s.Access).SingleOrDefault();
359: }
360:
361: return access;
362: }
363:
364: ////////////////////////////////////////////////////////////////////////////
365:
366: /// <summary>
367: ///
368: /// </summary>
369: public static Dictionary<string, int> ServicePortDictionary
370: {
371: get
372: {
373: Dictionary<string, int> dictionary;
374:
375: using (var db = new Ia.Ngn.Cl.Model.Ngn())
376: {
377: dictionary = (from s in db.Service2s
378: where s.ServiceType == Ia.Ngn.Cl.Model.Business.Service.ServiceType.GponService && s.Port > -1
379: select new { s.Service, s.Port }).ToDictionary(m => m.Service, m => m.Port);
380: }
381:
382: return dictionary;
383: }
384: }
385:
386: ////////////////////////////////////////////////////////////////////////////
387:
388: /// <summary>
389: ///
390: /// </summary>
391: public static Ia.Ngn.Cl.Model.Access ReadAccess(Ia.Ngn.Cl.Model.Ngn db, string id)
392: {
393: Ia.Ngn.Cl.Model.Access access;
394:
395: access = (from s in db.Service2s
396: where s.ServiceType == Ia.Ngn.Cl.Model.Business.Service.ServiceType.GponService && s.Id == id
397: select s.Access).SingleOrDefault();
398:
399: return access;
400: }
401:
402: ////////////////////////////////////////////////////////////////////////////
403:
404: /// <summary>
405: ///
406: /// </summary>
407: public static bool UpdatePort(Ia.Ngn.Cl.Model.Service2 service, int port, out string result)
408: {
409: bool b;
410:
411: using (var db = new Ia.Ngn.Cl.Model.Ngn())
412: {
413: service = (from s in db.Service2s
414: where s.ServiceType == Ia.Ngn.Cl.Model.Business.Service.ServiceType.GponService && s.Id == service.Id
415: select s).SingleOrDefault();
416:
417: if (service.Port != port)
418: {
419: service.Port = port;
420:
421: db.Service2s.Attach(service);
422: db.Entry(service).Property(x => x.Port).IsModified = true;
423:
424: db.SaveChanges();
425:
426: result = "Success: Service Port updated. ";
427: b = true;
428: }
429: else
430: {
431: result = "Warning: Service Port value was not updated because its the same. ";
432:
433: b = false;
434: }
435: }
436:
437: return b;
438: }
439:
440: ////////////////////////////////////////////////////////////////////////////
441:
442: /// <summary>
443: ///
444: /// </summary>
445: public static List<Ia.Ngn.Cl.Model.Service2> ServiceWithNullAccessList
446: {
447: get
448: {
449: List<Ia.Ngn.Cl.Model.Service2> serviceList;
450:
451: using (var db = new Ia.Ngn.Cl.Model.Ngn())
452: {
453: serviceList = (from s in db.Service2s
454: where s.ServiceType == Ia.Ngn.Cl.Model.Business.Service.ServiceType.GponService && s.Access == null
455: select s).ToList();
456: }
457:
458: return serviceList;
459: }
460: }
461:
462: ////////////////////////////////////////////////////////////////////////////
463:
464: /// <summary>
465: /// Services within a SIP designated OLT
466: /// </summary>
467: public static List<string> ServiceIdWithinSipOltList()
468: {
469: List<int> sipOltIdList;
470: List<string> list, list2;
471:
472: sipOltIdList = Ia.Ngn.Cl.Model.Data.NetworkDesignDocument.SipOltIdList;
473:
474: using (var db = new Ia.Ngn.Cl.Model.Ngn())
475: {
476: // services with access
477: list = (from s in db.Service2s
478: where s.ServiceType == Ia.Ngn.Cl.Model.Business.Service.ServiceType.GponService && s.Access != null && sipOltIdList.Contains(s.Access.Olt)
479: select s.Id).ToList();
480:
481: // services without access might be newly installed
482: list2 = (from s in db.Service2s
483: join srs in db.ServiceRequestServices on s.Service equals srs.Service
484: where s.ServiceType == Ia.Ngn.Cl.Model.Business.Service.ServiceType.GponService && s.Access == null && srs.Access != null && srs.Provisioned == true && sipOltIdList.Contains(srs.Access.Olt)
485: select s.Id).ToList();
486: }
487:
488: return list.Union(list2).Distinct().ToList();
489: }
490:
491: ////////////////////////////////////////////////////////////////////////////
492:
493: /// <summary>
494: /// Services within a SIP allowed to be provisioned or migrated OLT
495: /// </summary>
496: public static List<string> ServiceIdWithinAllowedSipOltToBeProvisionedOrMigratedList()
497: {
498: List<int> sipOltIdList;
499: List<string> list, list2;
500:
501: sipOltIdList = Ia.Ngn.Cl.Model.Data.Service.AllowedToBeProvisionedSipOltIdList.Union(Ia.Ngn.Cl.Model.Data.Service.AllowedToBeMigratedSipOltIdList).ToList();
502:
503: using (var db = new Ia.Ngn.Cl.Model.Ngn())
504: {
505: // services with access
506: list = (from s in db.Service2s where s.ServiceType == Ia.Ngn.Cl.Model.Business.Service.ServiceType.GponService && s.Access != null && sipOltIdList.Contains(s.Access.Olt) select s.Id).ToList();
507:
508: // services without access might be newly installed
509: list2 = (from s in db.Service2s
510: join srs in db.ServiceRequestServices on s.Service equals srs.Service
511: where s.ServiceType == Ia.Ngn.Cl.Model.Business.Service.ServiceType.GponService && s.Access == null && srs.Access != null && srs.Provisioned == true && sipOltIdList.Contains(srs.Access.Olt)
512: select s.Id).ToList();
513: }
514:
515: return list.Union(list2).Distinct().ToList();
516: }
517:
518: ////////////////////////////////////////////////////////////////////////////
519:
520: /// <summary>
521: /// ServiceOnts within a SIP allowed to be provisioned or migrated OLT
522: /// </summary>
523: public static List<Ia.Ngn.Cl.Model.Business.ServiceOnt> ServiceOntWithinAllowedSipOltToBeProvisionedOrMigratedList
524: {
525: get
526: {
527: List<int> oltIdList;
528: List<Ia.Ngn.Cl.Model.Business.ServiceOnt> list1, list2, list;
529:
530: oltIdList = Ia.Ngn.Cl.Model.Data.Service.AllowedToBeProvisionedSipOltIdList.Union(Ia.Ngn.Cl.Model.Data.Service.AllowedToBeMigratedSipOltIdList).ToList();
531:
532: var ontAccessIdToOntForOltIdListDictionary = Ia.Ngn.Cl.Model.Data.NetworkDesignDocument.OntAccessIdToOntForOltIdListDictionary(oltIdList);
533:
534: using (var db = new Ia.Ngn.Cl.Model.Ngn())
535: {
536: // services with access
537: list1 = (from s in db.Service2s
538: where s.ServiceType == Ia.Ngn.Cl.Model.Business.Service.ServiceType.GponService && s.Access != null && oltIdList.Contains(s.Access.Olt)
539: select new Ia.Ngn.Cl.Model.Business.ServiceOnt { ServiceId = s.Id, Service = s.Service, AccessId = s.Access.Id, CreatedDateTime = s.Created }).ToList();
540:
541: // services without access might be newly installed
542: list2 = (from s in db.Service2s
543: join srs in db.ServiceRequestServices on s.Service equals srs.Service
544: where s.ServiceType == Ia.Ngn.Cl.Model.Business.Service.ServiceType.GponService && s.Access == null && srs.Access != null && srs.Provisioned == true && oltIdList.Contains(srs.Access.Olt)
545: select new Ia.Ngn.Cl.Model.Business.ServiceOnt { ServiceId = s.Id, Service = s.Service, AccessId = srs.Access.Id, CreatedDateTime = s.Created }).ToList();
546: }
547:
548: list = list1.Concat(list2).ToList();
549:
550: foreach (var l in list)
551: {
552: l.Ont = ontAccessIdToOntForOltIdListDictionary.ContainsKey(l.AccessId) ? ontAccessIdToOntForOltIdListDictionary[l.AccessId] : null;
553: }
554:
555: return list;
556: }
557: }
558:
559: ////////////////////////////////////////////////////////////////////////////
560:
561: /// <summary>
562: ///
563: /// </summary>
564: public static List<Ia.Ngn.Cl.Model.Business.ServiceOnt> ServiceOntWithinAllowedToBeProvisionedOrMigratedHuaweiSwitchNokiaGponOltList()
565: {
566: List<int> oltIdList;
567: List<Ia.Ngn.Cl.Model.Business.ServiceOnt> list1, list2, list;
568:
569: //oltIdList = Ia.Ngn.Cl.Model.Data.Service.AllowedToBeProvisionedOltIdList.Intersect(Ia.Ngn.Cl.Model.Data.NetworkDesignDocument.HuaweiSwitchNokiaGponOltIdList).ToList();
570: oltIdList = Ia.Ngn.Cl.Model.Data.NetworkDesignDocument.HuaweiSwitchNokiaGponOltIdList;
571:
572: var ontAccessIdToOntForOltIdListDictionary = Ia.Ngn.Cl.Model.Data.NetworkDesignDocument.OntAccessIdToOntForOltIdListDictionary(oltIdList);
573:
574: using (var db = new Ia.Ngn.Cl.Model.Ngn())
575: {
576: // services with access
577: list1 = (from s in db.Service2s
578: where s.ServiceType == Ia.Ngn.Cl.Model.Business.Service.ServiceType.GponService && s.Access != null && oltIdList.Contains(s.Access.Olt)
579: select new Ia.Ngn.Cl.Model.Business.ServiceOnt { ServiceId = s.Id, Service = s.Service, AccessId = s.Access.Id, CreatedDateTime = s.Created }).ToList();
580:
581: // services without access might be newly installed
582: list2 = (from s in db.Service2s
583: join srs in db.ServiceRequestServices on s.Service equals srs.Service
584: where s.ServiceType == Ia.Ngn.Cl.Model.Business.Service.ServiceType.GponService && s.Access == null && srs.Access != null && srs.Provisioned == true && oltIdList.Contains(srs.Access.Olt)
585: select new Ia.Ngn.Cl.Model.Business.ServiceOnt { ServiceId = s.Id, Service = s.Service, AccessId = srs.Access.Id, CreatedDateTime = s.Created }).ToList();
586: }
587:
588: list = list1.Concat(list2).ToList();
589:
590: foreach (var l in list)
591: {
592: l.Ont = ontAccessIdToOntForOltIdListDictionary.ContainsKey(l.AccessId) ? ontAccessIdToOntForOltIdListDictionary[l.AccessId] : null;
593: }
594:
595: return list;
596: }
597:
598: ////////////////////////////////////////////////////////////////////////////
599:
600: /// <summary>
601: /// Services within Huawei switch domain list
602: /// </summary>
603: public static List<string> ServiceIdWithinHuaweiSwitchDomainList()
604: {
605: List<int> huaweiSwitchDomainList;
606: List<string> list;
607:
608: huaweiSwitchDomainList = Ia.Ngn.Cl.Model.Data.Service.HuaweiSwitchDomainList;
609:
610: using (var db = new Ia.Ngn.Cl.Model.Ngn())
611: {
612: list = (from s in db.Service2s
613: where s.ServiceType == Ia.Ngn.Cl.Model.Business.Service.ServiceType.GponService && huaweiSwitchDomainList.Any(u => s.Service.StartsWith(u.ToString()))
614: select s.Id).ToList();
615: }
616:
617: return list.ToList();
618: }
619:
620: ////////////////////////////////////////////////////////////////////////////
621:
622: /// <summary>
623: /// Services within Nokia switch domain list
624: /// </summary>
625: public static List<string> ServiceIdWithinNokiaSwitchDomainList()
626: {
627: List<int> nokiaSwitchDomainList;
628: List<string> list;
629:
630: nokiaSwitchDomainList = Ia.Ngn.Cl.Model.Data.Service.NokiaSwitchDomainList;
631:
632: using (var db = new Ia.Ngn.Cl.Model.Ngn())
633: {
634: list = (from s in db.Service2s
635: where s.ServiceType == Ia.Ngn.Cl.Model.Business.Service.ServiceType.GponService && nokiaSwitchDomainList.Any(u => s.Service.StartsWith(u.ToString()))
636: select s.Id).ToList();
637: }
638:
639: return list.ToList();
640: }
641:
642: ////////////////////////////////////////////////////////////////////////////
643:
644: /// <summary>
645: ///
646: /// </summary>
647: public static List<string> ServiceIdWithNullAccessList()
648: {
649: List<string> list;
650:
651: using (var db = new Ia.Ngn.Cl.Model.Ngn())
652: {
653: list = (from s in db.Service2s
654: where s.ServiceType == Ia.Ngn.Cl.Model.Business.Service.ServiceType.GponService && s.Access == null
655: select s.Id).ToList();
656: }
657:
658: return list;
659: }
660:
661: ////////////////////////////////////////////////////////////////////////////
662:
663: /// <summary>
664: ///
665: /// </summary>
666: public static List<Ia.Ngn.Cl.Model.Service2> ServiceSuspensionIsTrueList
667: {
668: get
669: {
670: List<Ia.Ngn.Cl.Model.Service2> serviceList;
671:
672: using (var db = new Ia.Ngn.Cl.Model.Ngn())
673: {
674: serviceList = (from s in db.Service2s
675: where s.ServiceType == Ia.Ngn.Cl.Model.Business.Service.ServiceType.GponService && s.ServiceSuspension == true
676: select s).ToList();
677: }
678:
679: return serviceList;
680: }
681: }
682:
683: ////////////////////////////////////////////////////////////////////////////
684:
685: /// <summary>
686: ///
687: /// </summary>
688: public static int ServiceSuspensionIsTrueListCount
689: {
690: get
691: {
692: int c;
693:
694: using (var db = new Ia.Ngn.Cl.Model.Ngn())
695: {
696: c = (from s in db.Service2s
697: where s.ServiceType == Ia.Ngn.Cl.Model.Business.Service.ServiceType.GponService && s.ServiceSuspension == true
698: select s).Count();
699: }
700:
701: return c;
702: }
703: }
704:
705: ////////////////////////////////////////////////////////////////////////////
706:
707: /// <summary>
708: ///
709: /// </summary>
710: public static List<Ia.Ngn.Cl.Model.Service2> ServiceSuspensionIsFalseList
711: {
712: get
713: {
714: List<Ia.Ngn.Cl.Model.Service2> serviceList;
715:
716: using (var db = new Ia.Ngn.Cl.Model.Ngn())
717: {
718: serviceList = (from s in db.Service2s
719: where s.ServiceType == Ia.Ngn.Cl.Model.Business.Service.ServiceType.GponService && s.ServiceSuspension == false
720: select s).ToList();
721: }
722:
723: return serviceList;
724: }
725: }
726:
727: ////////////////////////////////////////////////////////////////////////////
728:
729: /// <summary>
730: ///
731: /// </summary>
732: public static List<string> ServiceSuspensionIsTrueStringNumberList
733: {
734: get
735: {
736: List<string> serviceNumberStringList;
737: List<Ia.Ngn.Cl.Model.Service2> serviceList;
738:
739: using (var db = new Ia.Ngn.Cl.Model.Ngn())
740: {
741: // below:
742: serviceList = ServiceSuspensionIsTrueList;
743:
744: if (serviceList.Count > 0)
745: {
746: serviceNumberStringList = new List<string>(serviceList.Count);
747:
748: foreach (Ia.Ngn.Cl.Model.Service2 srs in serviceList)
749: {
750: serviceNumberStringList.Add(srs.Service);
751: }
752: }
753: else
754: {
755: // below: not null
756: serviceNumberStringList = new List<string>(1);
757: }
758: }
759:
760: return serviceNumberStringList;
761: }
762: }
763:
764: ////////////////////////////////////////////////////////////////////////////
765:
766: /// <summary>
767: ///
768: /// </summary>
769: public static List<string> ServiceSuspensionIsFalseStringNumberList
770: {
771: get
772: {
773: List<string> serviceNumberStringList;
774: List<Ia.Ngn.Cl.Model.Service2> serviceList;
775:
776: using (var db = new Ia.Ngn.Cl.Model.Ngn())
777: {
778: // below:
779: serviceList = ServiceSuspensionIsFalseList;
780:
781: if (serviceList.Count > 0)
782: {
783: serviceNumberStringList = new List<string>(serviceList.Count);
784:
785: foreach (Ia.Ngn.Cl.Model.Service2 srs in serviceList)
786: {
787: serviceNumberStringList.Add(srs.Service);
788: }
789: }
790: else
791: {
792: // below: not null
793: serviceNumberStringList = new List<string>(1);
794: }
795: }
796:
797: return serviceNumberStringList;
798: }
799: }
800:
801: ////////////////////////////////////////////////////////////////////////////
802:
803: /// <summary>
804: ///
805: /// </summary>
806: public static Dictionary<string, string> ServiceIdToAccessIdDictionary
807: {
808: get
809: {
810: Dictionary<string, string> dictionary, nullAccessDictionary;
811:
812: using (var db = new Ia.Ngn.Cl.Model.Ngn())
813: {
814: dictionary = (from s in db.Service2s
815: where s.ServiceType == Ia.Ngn.Cl.Model.Business.Service.ServiceType.GponService && s.Access != null
816: select new { s.Id, s.Access }).ToDictionary(u => u.Id, u => u.Access.Id);
817:
818: nullAccessDictionary = (from s in db.Service2s
819: where s.ServiceType == Ia.Ngn.Cl.Model.Business.Service.ServiceType.GponService && s.Access == null
820: select new { s.Id, s.Access }).ToDictionary(u => u.Id, u => string.Empty);
821: }
822:
823: return dictionary.Union(nullAccessDictionary).ToDictionary(u => u.Key, u => u.Value);
824: }
825: }
826:
827: ////////////////////////////////////////////////////////////////////////////
828:
829: /// <summary>
830: ///
831: /// </summary>
832: public static Dictionary<string, string> PstnServiceIdToAccessIdDictionary
833: {
834: get
835: {
836: Dictionary<string, string> dictionary, nullAccessDictionary;
837:
838: using (var db = new Ia.Ngn.Cl.Model.Ngn())
839: {
840: dictionary = (from s in db.Service2s
841: where s.ServiceType == Ia.Ngn.Cl.Model.Business.Service.ServiceType.PstnService && s.Access != null
842: select new { s.Id, s.Access }).ToDictionary(u => u.Id, u => u.Access.Id);
843:
844: nullAccessDictionary = (from s in db.Service2s
845: where s.ServiceType == Ia.Ngn.Cl.Model.Business.Service.ServiceType.PstnService && s.Access == null
846: select new { s.Id, s.Access }).ToDictionary(u => u.Id, u => string.Empty);
847: }
848:
849: return dictionary.Union(nullAccessDictionary).ToDictionary(u => u.Key, u => u.Value);
850: }
851: }
852:
853: ////////////////////////////////////////////////////////////////////////////
854:
855: /// <summary>
856: ///
857: /// </summary>
858: public static Dictionary<string, string> MigratedServiceIdToAccessIdDictionary
859: {
860: get
861: {
862: Dictionary<string, string> dictionary, nullAccessDictionary;
863:
864: var migrationDomainList = Ia.Ngn.Cl.Model.Data.Service.MigrationDomainList;
865: var migrationDomainStringList = migrationDomainList.ConvertAll<string>(delegate (int i) { return i.ToString(); });
866:
867: using (var db = new Ia.Ngn.Cl.Model.Ngn())
868: {
869: dictionary = (from s in db.Service2s
870: where s.Access != null && migrationDomainStringList.Any(u => s.Service.StartsWith(u))
871: select new { s.Id, s.Access }).ToDictionary(u => u.Id, u => u.Access.Id);
872:
873: nullAccessDictionary = (from s in db.Service2s
874: where s.Access == null && migrationDomainStringList.Any(u => s.Service.StartsWith(u))
875: select new { s.Id, s.Access }).ToDictionary(u => u.Id, u => string.Empty);
876: }
877:
878: return dictionary.Union(nullAccessDictionary).ToDictionary(u => u.Key, u => u.Value);
879: }
880: }
881:
882: ////////////////////////////////////////////////////////////////////////////
883:
884: /// <summary>
885: ///
886: /// </summary>
887: public static Dictionary<string, string> MigratedServiceIdToAccessIdInAllowedToBeMigratedOltDictionary
888: {
889: get
890: {
891: Dictionary<string, string> dictionary;
892:
893: var allowedToBeMigratedOltIdList = Ia.Ngn.Cl.Model.Data.Service.AllowedToBeMigratedOltIdList;
894:
895: var migrationDomainList = Ia.Ngn.Cl.Model.Data.Service.MigrationDomainList;
896: var migrationDomainStringList = migrationDomainList.ConvertAll<string>(delegate (int i) { return i.ToString(); });
897:
898: using (var db = new Ia.Ngn.Cl.Model.Ngn())
899: {
900: dictionary = (from s in db.Service2s
901: 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.GponService
902: select new { s.Id, s.Access }).ToDictionary(u => u.Id, u => u.Access.Id);
903: }
904:
905: return dictionary.ToDictionary(u => u.Key, u => u.Value);
906: }
907: }
908:
909: ////////////////////////////////////////////////////////////////////////////
910:
911: /// <summary>
912: ///
913: /// </summary>
914: public static Dictionary<string, string> GponServiceToAccessIdInAllowedToBeMigratedOltDictionary
915: {
916: get
917: {
918: Dictionary<string, string> dictionary;
919:
920: var allowedToBeMigratedOltIdList = Ia.Ngn.Cl.Model.Data.Service.AllowedToBeMigratedOltIdList;
921:
922: var migrationDomainList = Ia.Ngn.Cl.Model.Data.Service.MigrationDomainList;
923: var migrationDomainStringList = migrationDomainList.ConvertAll<string>(delegate (int i) { return i.ToString(); });
924:
925: using (var db = new Ia.Ngn.Cl.Model.Ngn())
926: {
927: dictionary = (from s in db.Service2s
928: 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.GponService
929: select new { s.Service, s.Access }).ToDictionary(u => u.Service, u => u.Access.Id);
930: }
931:
932: return dictionary.ToDictionary(u => u.Key, u => u.Value);
933: }
934: }
935:
936: ////////////////////////////////////////////////////////////////////////////
937:
938: /// <summary>
939: ///
940: /// </summary>
941: public static Dictionary<string, string> ServiceToAccessIdDictionary
942: {
943: get
944: {
945: string key;
946: Dictionary<string, string> serviceToAccessIdDictionary, serviceIdToAccessIdDictionary;
947:
948: serviceIdToAccessIdDictionary = ServiceIdToAccessIdDictionary;
949:
950: serviceToAccessIdDictionary = new Dictionary<string, string>(serviceIdToAccessIdDictionary.Count);
951:
952: foreach (KeyValuePair<string, string> kvp in serviceIdToAccessIdDictionary)
953: {
954: key = Ia.Ngn.Cl.Model.Business.Service.ServiceIdToService(kvp.Key);
955:
956: serviceToAccessIdDictionary[key] = kvp.Value;
957: }
958:
959: return serviceToAccessIdDictionary;
960: }
961: }
962:
963: ////////////////////////////////////////////////////////////////////////////
964:
965: /// <summary>
966: ///
967: /// </summary>
968: public static Dictionary<string, string> ServiceIdToAccessNameDictionary
969: {
970: get
971: {
972: Dictionary<string, string> dictionary, nullAccessDictionary;
973:
974: using (var db = new Ia.Ngn.Cl.Model.Ngn())
975: {
976: dictionary = (from s in db.Service2s
977: where s.ServiceType == Ia.Ngn.Cl.Model.Business.Service.ServiceType.GponService && s.Access != null
978: select new { s.Id, s.Access }).ToDictionary(u => u.Id, u => u.Access.Name);
979:
980: nullAccessDictionary = (from s in db.Service2s
981: where s.ServiceType == Ia.Ngn.Cl.Model.Business.Service.ServiceType.GponService && s.Access == null
982: select s.Id).ToDictionary(u => u, null);
983: }
984:
985: return dictionary.Union(nullAccessDictionary).ToDictionary(u => u.Key, u => u.Value);
986: }
987: }
988:
989: ////////////////////////////////////////////////////////////////////////////
990:
991: /// <summary>
992: ///
993: /// </summary>
994: public static Dictionary<string, int> AccessNameToSeviceCountDictionary()
995: {
996: string accessName;
997: Dictionary<string, int> dictionary;
998:
999: using (var db = new Ia.Ngn.Cl.Model.Ngn())
1000: {
1001: var accessIdToAccessNameDictionary = Ia.Ngn.Cl.Model.Data.NetworkDesignDocument.OntAccessIdToOntAccessNameDictionary;
1002:
1003: var serviceToAccessIdDictionary = (from s in db.Service2s
1004: where s.ServiceType == Ia.Ngn.Cl.Model.Business.Service.ServiceType.GponService && s.Access != null
1005: select new { s.Service, AccessId = s.Access.Id }).ToDictionary(u => u.Service, u => u.AccessId);
1006:
1007: dictionary = new Dictionary<string, int>(serviceToAccessIdDictionary.Count);
1008:
1009: foreach (KeyValuePair<string, string> kvp in serviceToAccessIdDictionary)
1010: {
1011: accessName = accessIdToAccessNameDictionary[kvp.Value];
1012:
1013: if (!string.IsNullOrEmpty(accessName))
1014: {
1015: if (dictionary.ContainsKey(accessName))
1016: {
1017: dictionary[accessName] = dictionary[accessName] + 1;
1018: }
1019: else dictionary[accessName] = 1;
1020: }
1021: }
1022: }
1023:
1024: return dictionary.ToDictionary(u => u.Key, u => u.Value);
1025: }
1026:
1027: ////////////////////////////////////////////////////////////////////////////
1028:
1029: /// <summary>
1030: ///
1031: /// </summary>
1032: public static Dictionary<string, Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Ont> ServiceToNddOntDictionary
1033: {
1034: get
1035: {
1036: string key;
1037: Dictionary<string, Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Ont> dictionary;
1038:
1039: var serviceIdToAccessIdDictionary = Ia.Ngn.Cl.Model.Data.Service2.ServiceIdToAccessIdDictionary;
1040: var ontAccessIdToOntDictionary = Ia.Ngn.Cl.Model.Data.NetworkDesignDocument.OntAccessIdToOntDictionary;
1041:
1042: dictionary = new Dictionary<string, Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Ont>(serviceIdToAccessIdDictionary.Count);
1043:
1044: foreach (KeyValuePair<string, string> kvp in serviceIdToAccessIdDictionary)
1045: {
1046: key = Ia.Ngn.Cl.Model.Business.Service.ServiceIdToService(kvp.Key);
1047:
1048: if (!string.IsNullOrEmpty(kvp.Value)) dictionary[key] = ontAccessIdToOntDictionary[kvp.Value];
1049: else dictionary[key] = null;
1050: }
1051:
1052: return dictionary;
1053: }
1054: }
1055:
1056: ////////////////////////////////////////////////////////////////////////////
1057:
1058: /// <summary>
1059: ///
1060: /// </summary>
1061: public static Dictionary<string, Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Ont> PstnServiceToNddOntDictionary
1062: {
1063: get
1064: {
1065: string key;
1066: Dictionary<string, Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Ont> dictionary;
1067:
1068: var pstnServiceIdToAccessIdDictionary = Ia.Ngn.Cl.Model.Data.Service2.PstnServiceIdToAccessIdDictionary;
1069: var ontAccessIdToOntDictionary = Ia.Ngn.Cl.Model.Data.NetworkDesignDocument.OntAccessIdToOntDictionary;
1070:
1071: dictionary = new Dictionary<string, Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Ont>(pstnServiceIdToAccessIdDictionary.Count);
1072:
1073: foreach (KeyValuePair<string, string> kvp in pstnServiceIdToAccessIdDictionary)
1074: {
1075: key = Ia.Ngn.Cl.Model.Business.Service.ServiceIdToService(kvp.Key);
1076:
1077: if (!string.IsNullOrEmpty(kvp.Value)) dictionary[key] = ontAccessIdToOntDictionary[kvp.Value];
1078: //else dictionary[key] = null;
1079: }
1080:
1081: return dictionary;
1082: }
1083: }
1084:
1085: ////////////////////////////////////////////////////////////////////////////
1086:
1087: /// <summary>
1088: ///
1089: /// </summary>
1090: public static Dictionary<string, Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Vendor> MigratedServiceToNddOntRouterVendorDictionary
1091: {
1092: get
1093: {
1094: string key;
1095: Dictionary<string, Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Vendor> dictionary;
1096:
1097: var migratedServiceIdToAccessIdDictionary = Ia.Ngn.Cl.Model.Data.Service2.MigratedServiceIdToAccessIdDictionary;
1098: var ontAccessIdToOntDictionary = Ia.Ngn.Cl.Model.Data.NetworkDesignDocument.OntAccessIdToOntDictionary;
1099:
1100: dictionary = new Dictionary<string, Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Vendor>(migratedServiceIdToAccessIdDictionary.Count);
1101:
1102: foreach (KeyValuePair<string, string> kvp in migratedServiceIdToAccessIdDictionary)
1103: {
1104: key = Ia.Ngn.Cl.Model.Business.Service.ServiceIdToService(kvp.Key);
1105:
1106: //if (!string.IsNullOrEmpty(kvp.Value)) dictionary[key] = ontAccessIdToOntDictionary[kvp.Value];
1107: //else dictionary[key] = null;
1108: }
1109:
1110: return dictionary;
1111: }
1112: }
1113:
1114: ////////////////////////////////////////////////////////////////////////////
1115:
1116: /// <summary>
1117: ///
1118: /// </summary>
1119: public static Dictionary<string, Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Site> ServiceToSiteDictionary
1120: {
1121: get
1122: {
1123: int fourLetterServiceDomain, fiveLetterServiceDomain;
1124: string service;
1125: Dictionary<string, Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Site> dictionary;
1126:
1127: var serviceIdList = Ia.Ngn.Cl.Model.Data.Service2.ServiceIdList;
1128: var routerDomainToSiteDictionary = Ia.Ngn.Cl.Model.Data.NetworkDesignDocument.RouterDomainToSiteDictionary;
1129:
1130: dictionary = new Dictionary<string, Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Site>(serviceIdList.Count);
1131:
1132: foreach (string s in serviceIdList)
1133: {
1134: service = Ia.Ngn.Cl.Model.Business.Service.ServiceIdToService(s);
1135:
1136: if (service.Length >= 5)
1137: {
1138: fourLetterServiceDomain = int.Parse(service.Substring(0, 4));
1139: fiveLetterServiceDomain = int.Parse(service.Substring(0, 5));
1140:
1141: if (routerDomainToSiteDictionary.ContainsKey(fiveLetterServiceDomain)) dictionary[service] = routerDomainToSiteDictionary[fiveLetterServiceDomain];
1142: else if (routerDomainToSiteDictionary.ContainsKey(fourLetterServiceDomain)) dictionary[service] = routerDomainToSiteDictionary[fourLetterServiceDomain];
1143: //else throw new System.ArgumentOutOfRangeException("Service number " + service + " is out of range");
1144: }
1145: //else throw new System.ArgumentOutOfRangeException("Service number " + service + " is out of range");
1146: }
1147:
1148: return dictionary;
1149: }
1150: }
1151:
1152: ////////////////////////////////////////////////////////////////////////////
1153:
1154: /// <summary>
1155: ///
1156: /// </summary>
1157: public static Dictionary<string, string> ServiceNotInServiceRequestServiceToSiteDictionary
1158: {
1159: get
1160: {
1161: string service, siteName;
1162: Dictionary<string, string> dictionary;
1163:
1164: var serviceToSiteNameDictionary = Ia.Ngn.Cl.Model.Data.Service2.ServiceToSiteDictionary;
1165: var serviceRequestServiceServiceToSiteNameDictionary = Ia.Ngn.Cl.Model.Data.ServiceRequestService.ServiceToSiteDictionary;
1166:
1167: dictionary = new Dictionary<string, string>();
1168:
1169: foreach (var kvp in serviceToSiteNameDictionary)
1170: {
1171: service = kvp.Key;
1172: siteName = kvp.Value.Name;
1173:
1174: if (!serviceRequestServiceServiceToSiteNameDictionary.ContainsKey(service)) dictionary.Add(service, siteName);
1175: }
1176:
1177: return dictionary;
1178: }
1179: }
1180:
1181: ////////////////////////////////////////////////////////////////////////////
1182:
1183: /// <summary>
1184: ///
1185: /// </summary>
1186: public static Dictionary<string, string> ServiceNotInProvisionedServiceRequestServiceToSiteDictionary
1187: {
1188: get
1189: {
1190: string service, siteName;
1191: Dictionary<string, string> dictionary;
1192:
1193: var serviceToSiteNameDictionary = Ia.Ngn.Cl.Model.Data.Service2.ServiceToSiteDictionary;
1194: var serviceRequestServiceProvisionedServiceToSiteNameDictionary = Ia.Ngn.Cl.Model.Data.ServiceRequestService.ProvisionedServiceToSiteDictionary;
1195:
1196: dictionary = new Dictionary<string, string>();
1197:
1198: foreach (var kvp in serviceToSiteNameDictionary)
1199: {
1200: service = kvp.Key;
1201: siteName = kvp.Value.Name;
1202:
1203: if (!serviceRequestServiceProvisionedServiceToSiteNameDictionary.ContainsKey(service)) dictionary.Add(service, siteName);
1204: }
1205:
1206: return dictionary;
1207: }
1208: }
1209:
1210: ////////////////////////////////////////////////////////////////////////////
1211:
1212: /// <summary>
1213: ///
1214: /// </summary>
1215: public static Dictionary<string, int> PstnFiveDigitDomainToCountOfServicesDictionary()
1216: {
1217: var dictionary = new Dictionary<string, int>();
1218:
1219: using (var db = new Ia.Ngn.Cl.Model.Ngn())
1220: {
1221: /*
1222: select substring(s.Service,1,5), count(s.Service)
1223: from Service2 s
1224: where ServiceType = 2 -- PSTN
1225: group by substring(s.Service,1,5)
1226: */
1227:
1228: dictionary = (from s in db.Service2s
1229: where s.ServiceType == Ia.Ngn.Cl.Model.Business.Service.ServiceType.PstnService
1230: group s.Service.Substring(0, 5) by s.Service.Substring(0, 5) into g
1231: select new { PstnFiveDigitDomain = g.Key, ServiceCount = g.Count() }).ToDictionary(t => t.PstnFiveDigitDomain, t => t.ServiceCount);
1232: }
1233:
1234: return dictionary;
1235: }
1236:
1237: ////////////////////////////////////////////////////////////////////////////
1238:
1239: /// <summary>
1240: ///
1241: /// </summary>
1242: public static void UpdatePstnServiceAccess(string service, string newAccessId, Guid userId, out Ia.Cl.Model.Result result)
1243: {
1244: int serviceType;
1245: string service2Id;
1246: Ia.Ngn.Cl.Model.Service2 service2;
1247:
1248: result = new Ia.Cl.Model.Result();
1249:
1250: serviceType = Ia.Ngn.Cl.Model.Business.Service.ServiceType.PstnService; // PSTN
1251: service2Id = Ia.Ngn.Cl.Model.Business.Service2.ServiceId(service, serviceType);
1252:
1253: using (var db = new Ia.Ngn.Cl.Model.Ngn())
1254: {
1255: service2 = (from s in db.Service2s where s.Id == service2Id select s).SingleOrDefault();
1256:
1257: if (service2 != null)
1258: {
1259: if (!string.IsNullOrEmpty(newAccessId))
1260: {
1261: if (service2.Access == null || service2.Access != null && service2.Access.Id != newAccessId)
1262: {
1263: service2.Access = (from a in db.Accesses where a.Id == newAccessId select a).SingleOrDefault();
1264: service2.UserId = userId;
1265:
1266: db.Service2s.Attach(service2);
1267: db.Entry(service2).State = System.Data.Entity.EntityState.Modified;
1268:
1269: db.SaveChanges();
1270:
1271: result.AddSuccess("Service " + service + " was updated with access " + service2.Access.Name + " (تم تحديث ربط الجهاز بالرقم). ");
1272: }
1273: else
1274: {
1275: result.AddWarning("Service access value was not updated because submitted data is the same as current data and because access is not null (لم يتم تغيير الجهاز المربوط بالرقم لأن المعلومات المعطاة هي ذاتها لم تتغير ولأن الجهاز معرف). ");
1276: }
1277: }
1278: else //if(string.IsNullOrEmpty(updatedAccessId))
1279: {
1280: if (service2.Access != null)
1281: {
1282: service2.Access = (from a in db.Accesses where a.Id == string.Empty select a).SingleOrDefault();
1283: service2.Port = Ia.Ngn.Cl.Model.Business.Default.PortUndefinedOrInvalidOrUnknown;
1284: service2.UserId = userId;
1285:
1286: db.Service2s.Attach(service2);
1287: db.Entry(service2).State = System.Data.Entity.EntityState.Modified;
1288:
1289: db.SaveChanges();
1290:
1291: result.AddSuccess("Service " + service + " was updated with null access and " + Ia.Ngn.Cl.Model.Business.Default.PortUndefinedOrInvalidOrUnknown + " port (تم مسح ربط الجهاز بالرقم ومسح المنفذ). ");
1292: }
1293: else
1294: {
1295: result.AddWarning("Service access and port values were not resetted because submitted data (access null and port " + Ia.Ngn.Cl.Model.Business.Default.PortUndefinedOrInvalidOrUnknown + ") is the same as current data (لم يتم تغيير الجهاز المربوط بالرقم أو المنفذ لأن المعلومات المعطاة هي ذاتها لم تتغير). ");
1296: }
1297: }
1298: }
1299: else
1300: {
1301: result.AddWarning("Service " + service + " does not exist (رقم الخدمة غير موجود). ");
1302: }
1303: }
1304: }
1305:
1306: ////////////////////////////////////////////////////////////////////////////
1307:
1308: /// <summary>
1309: ///
1310: /// </summary>
1311: public static void UpdateGponServiceAccess(string service, string newAccessId, Guid userId, out Ia.Cl.Model.Result result)
1312: {
1313: int serviceType;
1314: string service2Id;
1315: Ia.Ngn.Cl.Model.Service2 service2;
1316:
1317: result = new Ia.Cl.Model.Result();
1318:
1319: serviceType = Ia.Ngn.Cl.Model.Business.Service.ServiceType.GponService;
1320: service2Id = Ia.Ngn.Cl.Model.Business.Service2.ServiceId(service, serviceType);
1321:
1322: using (var db = new Ia.Ngn.Cl.Model.Ngn())
1323: {
1324: service2 = (from s in db.Service2s where s.Id == service2Id select s).SingleOrDefault();
1325:
1326: if (service2 != null)
1327: {
1328: if (!string.IsNullOrEmpty(newAccessId))
1329: {
1330: if (service2.Access == null || service2.Access != null && service2.Access.Id != newAccessId)
1331: {
1332: service2.Access = (from a in db.Accesses where a.Id == newAccessId select a).SingleOrDefault();
1333: service2.UserId = userId;
1334:
1335: db.Service2s.Attach(service2);
1336: db.Entry(service2).State = System.Data.Entity.EntityState.Modified;
1337:
1338: db.SaveChanges();
1339:
1340: result.AddSuccess("Service " + service + " was updated with access " + service2.Access.Name + ". ");
1341: }
1342: else
1343: {
1344: result.AddWarning("Service access value was not updated because submitted data is the same as current data and because access is not null. ");
1345: }
1346: }
1347: else
1348: {
1349: if (service2.Access != null)
1350: {
1351: service2.Access = (from a in db.Accesses where a.Id == string.Empty select a).SingleOrDefault();
1352: service2.Port = Ia.Ngn.Cl.Model.Business.Default.PortUndefinedOrInvalidOrUnknown;
1353: service2.UserId = userId;
1354:
1355: db.Service2s.Attach(service2);
1356: db.Entry(service2).State = System.Data.Entity.EntityState.Modified;
1357:
1358: db.SaveChanges();
1359:
1360: result.AddSuccess("Service " + service + " was updated with null access and " + Ia.Ngn.Cl.Model.Business.Default.PortUndefinedOrInvalidOrUnknown + " port. ");
1361: }
1362: else
1363: {
1364: result.AddWarning("Service access and port values were not resetted because submitted data (access null and port " + Ia.Ngn.Cl.Model.Business.Default.PortUndefinedOrInvalidOrUnknown + ") is the same as current data (لم يتم تغيير الجهاز المربوط بالرقم أو المنفذ لأن المعلومات المعطاة هي ذاتها لم تتغير). ");
1365: }
1366: }
1367: }
1368: else
1369: {
1370: result.AddWarning("Service " + service + " does not exist. ");
1371: }
1372: }
1373: }
1374:
1375: ////////////////////////////////////////////////////////////////////////////
1376: ////////////////////////////////////////////////////////////////////////////
1377: }
1378:
1379: ////////////////////////////////////////////////////////////////////////////
1380: ////////////////////////////////////////////////////////////////////////////
1381: }