1: using Microsoft.EntityFrameworkCore;
2: using System;
3: using System.Collections;
4: using System.Collections.Generic;
5: using System.Data;
6: using System.Linq;
7: using System.Text.RegularExpressions;
8:
9: namespace Ia.Ngn.Cl.Model.Data
10: {
11: ////////////////////////////////////////////////////////////////////////////
12:
13: /// <summary publish="true">
14: /// Service Request Service support class for Next Generation Network (NGN) data model.
15: /// </summary>
16: ///
17: /// <remarks>
18: /// Copyright © 2006-2019 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 partial class ServiceRequestService
31: {
32: /// <summary/>
33: public ServiceRequestService() { }
34:
35: ////////////////////////////////////////////////////////////////////////////
36:
37: /// <summary>
38: /// Read service
39: /// </summary>
40: public static Ia.Ngn.Cl.Model.ServiceRequestService Read(string service)
41: {
42: Ia.Ngn.Cl.Model.ServiceRequestService serviceRequestService;
43:
44: using (var db = new Ia.Ngn.Cl.Model.Ngn())
45: {
46: serviceRequestService = (from srs in db.ServiceRequestServices where srs.Service == service select srs).SingleOrDefault();
47: }
48:
49: return serviceRequestService;
50: }
51:
52: ////////////////////////////////////////////////////////////////////////////
53:
54: /// <summary>
55: /// Read service
56: /// </summary>
57: public static Ia.Ngn.Cl.Model.ServiceRequestService ReadIncludeServiceRequests(string service)
58: {
59: Ia.Ngn.Cl.Model.ServiceRequestService serviceRequestService;
60:
61: using (var db = new Ia.Ngn.Cl.Model.Ngn())
62: {
63: serviceRequestService = (from srs in db.ServiceRequestServices.Include(a => a.ServiceRequests) where srs.Service == service select srs).SingleOrDefault();
64: }
65:
66: return serviceRequestService;
67: }
68:
69: ////////////////////////////////////////////////////////////////////////////
70:
71: /// <summary>
72: /// Read service using id
73: /// </summary>
74: public static Ia.Ngn.Cl.Model.ServiceRequestService ReadById(string id)
75: {
76: Ia.Ngn.Cl.Model.ServiceRequestService serviceRequestService;
77:
78: using (var db = new Ia.Ngn.Cl.Model.Ngn())
79: {
80: serviceRequestService = (from srs in db.ServiceRequestServices where srs.Id == id select srs).SingleOrDefault();
81: }
82:
83: return serviceRequestService;
84: }
85:
86: ////////////////////////////////////////////////////////////////////////////
87:
88: /// <summary>
89: /// Service request services within a SIP designated OLT
90: /// </summary>
91: public static List<Ia.Ngn.Cl.Model.ServiceRequestService> WithinSipOltList()
92: {
93: List<int> sipOltIdList;
94: List<Ia.Ngn.Cl.Model.ServiceRequestService> list;
95:
96: sipOltIdList = Ia.Ngn.Cl.Model.Data.NetworkDesignDocument.SipOltIdList;
97:
98: using (var db = new Ia.Ngn.Cl.Model.Ngn())
99: {
100: list = (from srs in db.ServiceRequestServices
101: where srs.Access != null && sipOltIdList.Contains(srs.Access.Olt)
102: select srs).ToList();
103: }
104:
105: return list;
106: }
107:
108: ////////////////////////////////////////////////////////////////////////////
109:
110: /// <summary>
111: /// Service request services within a designated OLT
112: /// </summary>
113: public static List<Ia.Ngn.Cl.Model.ServiceRequestService> WithinOltList(int oltId)
114: {
115: List<Ia.Ngn.Cl.Model.ServiceRequestService> list;
116:
117: if (oltId > 0)
118: {
119: using (var db = new Ia.Ngn.Cl.Model.Ngn())
120: {
121: list = (from srs in db.ServiceRequestServices.Include(a => a.Access)
122: where srs.Access != null && srs.Access.Olt == oltId
123: select srs).ToList();
124: }
125: }
126: else list = new List<Ia.Ngn.Cl.Model.ServiceRequestService>();
127:
128: return list;
129: }
130:
131: ////////////////////////////////////////////////////////////////////////////
132:
133: /// <summary>
134: /// Services within a SIP designated OLT
135: /// </summary>
136: public static List<string> ServiceWithinSipOltList()
137: {
138: List<int> sipOltIdList;
139: List<string> list;
140:
141: sipOltIdList = Ia.Ngn.Cl.Model.Data.NetworkDesignDocument.SipOltIdList;
142:
143: using (var db = new Ia.Ngn.Cl.Model.Ngn())
144: {
145: list = (from srs in db.ServiceRequestServices
146: where srs.Access != null && sipOltIdList.Contains(srs.Access.Olt)
147: select srs.Service).ToList();
148: }
149:
150: return list;
151: }
152:
153: ////////////////////////////////////////////////////////////////////////////
154:
155: /// <summary>
156: /// Read service using id
157: /// </summary>
158: public static Ia.Ngn.Cl.Model.ServiceRequestService ReadIncludeAccess(string id)
159: {
160: Ia.Ngn.Cl.Model.ServiceRequestService serviceRequestService;
161:
162: using (var db = new Ia.Ngn.Cl.Model.Ngn())
163: {
164: serviceRequestService = (from srs in db.ServiceRequestServices.Include(a => a.Access) where srs.Id == id select srs).SingleOrDefault();
165: }
166:
167: return serviceRequestService;
168: }
169:
170: ////////////////////////////////////////////////////////////////////////////
171:
172: /// <summary>
173: /// Read service of a number
174: /// </summary>
175: public static Ia.Ngn.Cl.Model.ServiceRequestService Read(long number)
176: {
177: Ia.Ngn.Cl.Model.ServiceRequestService serviceRequestService;
178:
179: using (var db = new Ia.Ngn.Cl.Model.Ngn())
180: {
181: serviceRequestService = (from srs in db.ServiceRequestServices where srs.Service == number.ToString() select srs).SingleOrDefault();
182: }
183:
184: return serviceRequestService;
185: }
186:
187: ////////////////////////////////////////////////////////////////////////////
188:
189: /// <summary>
190: /// Read all services for a number list
191: /// </summary>
192: public static List<Ia.Ngn.Cl.Model.ServiceRequestService> ReadList(ArrayList numberList)
193: {
194: long i;
195: long[] sp;
196: List<Ia.Ngn.Cl.Model.ServiceRequestService> serviceRequestServiceList;
197:
198: i = 0;
199: sp = new long[numberList.Count];
200:
201: foreach (long l in numberList) sp[i++] = l;
202:
203: using (var db = new Ia.Ngn.Cl.Model.Ngn())
204: {
205: //serviceList = (from q in db.Services where dnList.Contains(q.DN) select q).ToList();
206:
207: // var pages = context.Pages.Where(x => keys.Any(key => x.Title.Contains(key)));
208: serviceRequestServiceList = db.ServiceRequestServices.Where(q => sp.Any(v => q.Service == v.ToString())).ToList();
209: }
210:
211: return serviceRequestServiceList;
212: }
213:
214: ////////////////////////////////////////////////////////////////////////////
215:
216: /// <summary>
217: /// Update the service request service table with a list using a service list as referece
218: /// </summary>
219: public static void UpdateWithServiceList(List<string> serviceList, List<Ia.Ngn.Cl.Model.ServiceRequestService> newServiceRequestServiceList, out string result)
220: {
221: int readItemCount, existingItemCount, insertedItemCount, updatedItemCount, deletedItemCount;
222: Ia.Ngn.Cl.Model.ServiceRequestService serviceRequestService, newServiceRequestService;
223:
224: readItemCount = existingItemCount = insertedItemCount = updatedItemCount = deletedItemCount = 0;
225: result = string.Empty;
226:
227: readItemCount = newServiceRequestServiceList.Count;
228:
229: using (var db = new Ia.Ngn.Cl.Model.Ngn())
230: {
231: // Create SRS from newServiceRequestServiceList
232: foreach (Ia.Ngn.Cl.Model.ServiceRequestService srs in newServiceRequestServiceList)
233: {
234: if (Ia.Ngn.Cl.Model.Business.Service.ServiceHasEightDigits(srs.Service))
235: {
236: newServiceRequestService = new Ia.Ngn.Cl.Model.ServiceRequestService();
237:
238: newServiceRequestService.Copy(srs);
239:
240: // important: ServiceRequestService.Update() will only update stored.Access if it is null, or (stored.userId == Guid.Empty && update.Id > stored.Id)
241: if (srs.Access != null) newServiceRequestService.Access = (from a in db.Accesses where a.Id == srs.Access.Id select a).SingleOrDefault();
242: else newServiceRequestService.Access = null;
243:
244: serviceRequestService = (from srs2 in db.ServiceRequestServices where srs2.Id == srs.Id select srs2).SingleOrDefault();
245:
246: existingItemCount = (serviceRequestService != null) ? 1 : 0;
247:
248: if (serviceRequestService == null)
249: {
250: newServiceRequestService.Created = newServiceRequestService.Updated = DateTime.UtcNow.AddHours(3);
251:
252: db.ServiceRequestServices.Add(newServiceRequestService);
253:
254: //Ia.Ngn.Cl.Model.Data.Msmq.ServiceQueue.Enqueue(newServiceRequestService.Service);
255: //if (newServiceRequestService.Access != null) Ia.Ngn.Cl.Model.Data.Msmq.AccessNameQueue.Enqueue(newServiceRequestService.Access.Name);
256:
257: insertedItemCount++;
258: }
259: else
260: {
261: // below: copy values from newServiceRequestService to serviceRequestService
262:
263: if (serviceRequestService.Update(newServiceRequestService))
264: {
265: db.ServiceRequestServices.Attach(serviceRequestService);
266: db.Entry(serviceRequestService).State = Microsoft.EntityFrameworkCore.EntityState.Modified;
267:
268: //Ia.Ngn.Cl.Model.Data.Msmq.ServiceQueue.Enqueue(serviceRequestService.Service);
269: //if (serviceRequestService.Access != null) Ia.Ngn.Cl.Model.Data.Msmq.AccessNameQueue.Enqueue(serviceRequestService.Access.Name);
270:
271: updatedItemCount++;
272: }
273:
274: }
275: }
276: else
277: {
278: throw new System.ArgumentOutOfRangeException("Service " + srs.Service + " string format is not legal");
279: }
280: }
281:
282: /*
283: // remove SRS that were not present in newServiceRequestServiceList
284: foreach (string service in serviceList)
285: {
286: newServiceRequestService = (from srs in newServiceRequestServiceList where srs.Service == service select srs).SingleOrDefault();
287:
288: if (newServiceRequestService == null)
289: {
290: serviceRequestService = (from srs in db.ServiceRequestServices where srs.Service == service select srs).SingleOrDefault();
291:
292: if (serviceRequestService != null)
293: {
294: // below: will set all references to this SRS from all SR to null
295:
296: serviceRequestList = (from sr in db.ServiceRequests where sr.ServiceRequestService != null && sr.ServiceRequestService.Id == serviceRequestService.Id select sr).ToList();
297:
298: foreach (Ia.Ngn.Cl.Model.ServiceRequest sr in serviceRequestList)
299: {
300: //sr.ServiceRequestService = null;
301: }
302:
303: Ia.Ngn.Cl.Model.Data.Msmq.ServiceQueue.Enqueue(serviceRequestService.Service);
304: if (serviceRequestService.Access != null) Ia.Ngn.Cl.Model.Data.Msmq.AccessNameQueue.Enqueue(serviceRequestService.Access.Name);
305:
306: db.ServiceRequestServices.Remove(serviceRequestService); // I will not delete any SRS record
307:
308: deletedItemCount++;
309: }
310: }
311: }
312: */
313:
314: db.SaveChanges();
315:
316: result = "(" + readItemCount + "/" + existingItemCount + "/" + insertedItemCount + "," + updatedItemCount + "," + deletedItemCount + ") ";
317: }
318: }
319:
320: /*
321: ////////////////////////////////////////////////////////////////////////////
322:
323: /// <summary>
324: /// Update the ServiceRequestService table's ServiceSuspension and ServiceSuspensionTypeId to the specified state for a number list
325: /// </summary>
326: public static bool UpdateServiceSuspensionAndServiceSuspensionTypeIdToSpecifiedSuspensionStateForAServiceStringList(List<string> serviceList, bool state, Guid userId)
327: {
328: bool b;
329: Ia.Ngn.Cl.Model.ServiceRequestService serviceRequestService;
330:
331: b = false;
332:
333: if (serviceList.Count > 0)
334: {
335: using (var db = new Ia.Ngn.Cl.Model.Ngn())
336: {
337: // below:
338: foreach (string service in serviceList)
339: {
340: serviceRequestService = (from q in db.ServiceRequestServices where q.Service == service select q).SingleOrDefault();
341:
342: if (serviceRequestService != null)
343: {
344: if (serviceRequestService.ServiceSuspension != state)
345: {
346: serviceRequestService.ServiceSuspension = state;
347: serviceRequestService.Updated = DateTime.UtcNow.AddHours(3);
348: serviceRequestService.UserId = userId;
349:
350: db.ServiceRequestServices.Attach(serviceRequestService);
351: db.Entry(serviceRequestService).State = Microsoft.EntityFrameworkCore.EntityState.Modified;
352:
353: b = true;
354: }
355: }
356: }
357:
358: db.SaveChanges();
359: }
360: }
361: else
362: {
363: }
364:
365: return b;
366: }
367: */
368:
369: ////////////////////////////////////////////////////////////////////////////
370:
371: /// <summary>
372: ///
373: /// </summary>
374: public static List<Ia.Ngn.Cl.Model.ServiceRequestService> ReadSingleAsList(string id)
375: {
376: List<Ia.Ngn.Cl.Model.ServiceRequestService> serviceRequestServiceList;
377:
378: using (var db = new Ia.Ngn.Cl.Model.Ngn())
379: {
380: serviceRequestServiceList = (from srs in db.ServiceRequestServices where srs.Id == id select srs).ToList();
381: }
382:
383: return serviceRequestServiceList;
384: }
385:
386: ////////////////////////////////////////////////////////////////////////////
387:
388: /// <summary>
389: ///
390: /// </summary>
391: public static List<string> ServiceList()
392: {
393: List<string> list;
394:
395: using (var db = new Ia.Ngn.Cl.Model.Ngn())
396: {
397: list = (from srs in db.ServiceRequestServices select srs.Service).ToList();
398: }
399:
400: return list;
401: }
402:
403: ////////////////////////////////////////////////////////////////////////////
404:
405: /// <summary>
406: ///
407: /// </summary>
408: public static Dictionary<string, string> ServiceDictionary()
409: {
410: Dictionary<string, string> dictionary;
411:
412: using (var db = new Ia.Ngn.Cl.Model.Ngn())
413: {
414: dictionary = (from srs in db.ServiceRequestServices select new { srs.Service }).ToDictionary(u => u.Service, u => u.Service);
415: }
416:
417: return dictionary.ToDictionary(u => u.Key, u => u.Value);
418: }
419:
420: ////////////////////////////////////////////////////////////////////////////
421:
422: /// <summary>
423: ///
424: /// </summary>
425: public static List<string> ServiceIdList
426: {
427: get
428: {
429: List<string> list;
430:
431: using (var db = new Ia.Ngn.Cl.Model.Ngn())
432: {
433: list = (from srs in db.ServiceRequestServices select srs.Id).ToList();
434: }
435:
436: return list;
437: }
438: }
439:
440: ////////////////////////////////////////////////////////////////////////////
441:
442: /// <summary>
443: ///
444: /// </summary>
445: public static List<Ia.Ngn.Cl.Model.ServiceRequestService> List()
446: {
447: List<Ia.Ngn.Cl.Model.ServiceRequestService> serviceRequestServiceList;
448:
449: using (var db = new Ia.Ngn.Cl.Model.Ngn())
450: {
451: serviceRequestServiceList = (from srs in db.ServiceRequestServices select srs).ToList();
452: }
453:
454: return serviceRequestServiceList;
455: }
456:
457: ////////////////////////////////////////////////////////////////////////////
458:
459: /// <summary>
460: ///
461: /// </summary>
462: public static List<Ia.Ngn.Cl.Model.ServiceRequestService> List(string service)
463: {
464: List<Ia.Ngn.Cl.Model.ServiceRequestService> serviceRequestServiceList;
465:
466: if (!string.IsNullOrEmpty(service))
467: {
468: using (var db = new Ia.Ngn.Cl.Model.Ngn())
469: {
470: serviceRequestServiceList = (from srs in db.ServiceRequestServices where srs.Service == service select srs).ToList();
471: }
472: }
473: else serviceRequestServiceList = new List<Model.ServiceRequestService>();
474:
475: return serviceRequestServiceList;
476: }
477:
478: ////////////////////////////////////////////////////////////////////////////
479:
480: /// <summary>
481: ///
482: /// </summary>
483: public static List<Ia.Ngn.Cl.Model.ServiceRequestService> ListIncludeAccess()
484: {
485: List<Ia.Ngn.Cl.Model.ServiceRequestService> serviceRequestServiceList;
486:
487: using (var db = new Ia.Ngn.Cl.Model.Ngn())
488: {
489: serviceRequestServiceList = (from srs in db.ServiceRequestServices select srs).Include(u => u.Access).ToList();
490: }
491:
492: return serviceRequestServiceList;
493: }
494:
495: ////////////////////////////////////////////////////////////////////////////
496:
497: /// <summary>
498: ///
499: /// </summary>
500: public static List<Ia.Ngn.Cl.Model.Ui.ServiceRequestService> UiServiceRequestServiceList()
501: {
502: List<Ia.Ngn.Cl.Model.ServiceRequestService> srsList;
503: List<Ia.Ngn.Cl.Model.Ui.ServiceRequestService> list;
504:
505: using (var db = new Ia.Ngn.Cl.Model.Ngn())
506: {
507: srsList = (from srs in db.ServiceRequestServices select srs).ToList();
508:
509: list = (from srs in srsList
510: select new Ia.Ngn.Cl.Model.Ui.ServiceRequestService()
511: {
512: Id = srs.Id,
513: AbbriviatedCalling = srs.AbbriviatedCalling,
514: Access = srs.Access,
515: AlarmCall = srs.AlarmCall,
516: CallBarring = srs.CallBarring,
517: CallerId = srs.CallerId,
518: CallForwarding = srs.CallForwarding,
519: CallWaiting = srs.CallWaiting,
520: ConferenceCall = srs.ConferenceCall,
521: Created = srs.Created,
522: InternationalCalling = srs.InternationalCalling,
523: InternationalCallingUserControlled = srs.InternationalCallingUserControlled,
524: LastRequestDateTime = srs.LastRequestDateTime,
525: Provisioned = srs.Provisioned,
526: Service = srs.Service,
527: Serial = srs.Serial,
528: ServiceType = srs.ServiceType,
529: ServiceSuspension = srs.ServiceSuspension,
530: Type = srs.Type,
531: Updated = srs.Updated
532: }).ToList();
533:
534: return list.Distinct().ToList();
535: }
536: }
537:
538: ////////////////////////////////////////////////////////////////////////////
539:
540: /// <summary>
541: ///
542: /// </summary>
543: public static List<Ia.Ngn.Cl.Model.Ui.ServiceRequestService> UiServiceRequestServiceList(string service)
544: {
545: List<Ia.Ngn.Cl.Model.ServiceRequestService> srsList;
546: List<Ia.Ngn.Cl.Model.Ui.ServiceRequestService> list;
547:
548: if (!string.IsNullOrEmpty(service))
549: {
550: using (var db = new Ia.Ngn.Cl.Model.Ngn())
551: {
552: srsList = (from srs in db.ServiceRequestServices where srs.Service == service select srs).ToList();
553:
554: list = (from srs in srsList
555: select new Ia.Ngn.Cl.Model.Ui.ServiceRequestService()
556: {
557: Id = srs.Id,
558: AbbriviatedCalling = srs.AbbriviatedCalling,
559: Access = srs.Access,
560: AlarmCall = srs.AlarmCall,
561: CallBarring = srs.CallBarring,
562: CallerId = srs.CallerId,
563: CallForwarding = srs.CallForwarding,
564: CallWaiting = srs.CallWaiting,
565: ConferenceCall = srs.ConferenceCall,
566: Created = srs.Created,
567: InternationalCalling = srs.InternationalCalling,
568: InternationalCallingUserControlled = srs.InternationalCallingUserControlled,
569: LastRequestDateTime = srs.LastRequestDateTime,
570: Provisioned = srs.Provisioned,
571: Service = srs.Service,
572: Serial = srs.Serial,
573: ServiceType = srs.ServiceType,
574: ServiceSuspension = srs.ServiceSuspension,
575: Type = srs.Type,
576: Updated = srs.Updated
577: }).ToList();
578: }
579: }
580: else list = new List<Ia.Ngn.Cl.Model.Ui.ServiceRequestService>();
581:
582: return list.Distinct().ToList();
583: }
584:
585: ////////////////////////////////////////////////////////////////////////////
586:
587: /// <summary>
588: ///
589: /// </summary>
590: public static List<Ia.Ngn.Cl.Model.Business.ServiceSerialRequestService> ServiceSerialRequestServiceList()
591: {
592: List<Ia.Ngn.Cl.Model.ServiceRequestService> srsList;
593: List<Ia.Ngn.Cl.Model.Business.ServiceSerialRequestService> list;
594:
595: using (var db = new Ia.Ngn.Cl.Model.Ngn())
596: {
597: srsList = (from srs in db.ServiceRequestServices select srs).ToList();
598:
599: list = (from srs in srsList
600: select new Ia.Ngn.Cl.Model.Business.ServiceSerialRequestService()
601: {
602: Id = srs.Service + ":" + srs.Serial,
603: AbbriviatedCalling = srs.AbbriviatedCalling,
604: //Access = srs.Access,
605: AlarmCall = srs.AlarmCall,
606: WakeupCall = srs.WakeupCall,
607: CallBarring = srs.CallBarring,
608: CallerId = srs.CallerId,
609: CallForwarding = srs.CallForwarding,
610: CallWaiting = srs.CallWaiting,
611: ConferenceCall = srs.ConferenceCall,
612: InternationalCalling = srs.InternationalCalling,
613: InternationalCallingUserControlled = srs.InternationalCallingUserControlled,
614: Provisioned = srs.Provisioned,
615: Service = srs.Service,
616: Serial = srs.Serial,
617: }).ToList();
618:
619: return list.Distinct().ToList();
620: }
621: }
622:
623: ////////////////////////////////////////////////////////////////////////////
624:
625: /// <summary>
626: ///
627: /// </summary>
628: public static List<Ia.Ngn.Cl.Model.Business.ServiceSerialRequestService> ServiceSerialRequestServiceList(string service)
629: {
630: List<Ia.Ngn.Cl.Model.ServiceRequestService> srsList;
631: List<Ia.Ngn.Cl.Model.Business.ServiceSerialRequestService> list;
632:
633: if (!string.IsNullOrEmpty(service))
634: {
635: using (var db = new Ia.Ngn.Cl.Model.Ngn())
636: {
637: srsList = (from srs in db.ServiceRequestServices where srs.Service == service select srs).ToList();
638:
639: list = (from srs in srsList
640: select new Ia.Ngn.Cl.Model.Business.ServiceSerialRequestService()
641: {
642: Id = srs.Service + ":" + srs.Serial,
643: AbbriviatedCalling = srs.AbbriviatedCalling,
644: //Access = srs.Access,
645: AlarmCall = srs.AlarmCall,
646: WakeupCall = srs.WakeupCall,
647: CallBarring = srs.CallBarring,
648: CallerId = srs.CallerId,
649: CallForwarding = srs.CallForwarding,
650: CallWaiting = srs.CallWaiting,
651: ConferenceCall = srs.ConferenceCall,
652: InternationalCalling = srs.InternationalCalling,
653: InternationalCallingUserControlled = srs.InternationalCallingUserControlled,
654: Provisioned = srs.Provisioned,
655: Service = srs.Service,
656: Serial = srs.Serial,
657: }).ToList();
658: }
659: }
660: else list = new List<Ia.Ngn.Cl.Model.Business.ServiceSerialRequestService>();
661:
662: return list.Distinct().ToList();
663: }
664:
665: ////////////////////////////////////////////////////////////////////////////
666: ////////////////////////////////////////////////////////////////////////////
667:
668: /// <summary>
669: ///
670: /// </summary>
671: public static Dictionary<string, string> ServiceIdToAccessIdDictionary
672: {
673: get
674: {
675: Dictionary<string, string> dictionary, nullAccessDictionary;
676:
677: using (var db = new Ia.Ngn.Cl.Model.Ngn())
678: {
679: dictionary = (from srs in db.ServiceRequestServices where srs.Access != null select new { srs.Id, srs.Access }).ToDictionary(u => u.Id, u => u.Access.Id);
680: nullAccessDictionary = (from s in db.ServiceRequestServices where s.Access == null select new { s.Id, s.Access }).ToDictionary(u => u.Id, u => string.Empty);
681: }
682:
683: return dictionary.Union(nullAccessDictionary).ToDictionary(u => u.Key, u => u.Value);
684: }
685: }
686:
687: ////////////////////////////////////////////////////////////////////////////
688:
689: /// <summary>
690: ///
691: /// </summary>
692: public static Dictionary<string, string> ServiceToAccessIdDictionary
693: {
694: get
695: {
696: string key;
697: Dictionary<string, string> serviceToAccessIdDictionary, serviceIdToAccessIdDictionary;
698:
699: serviceIdToAccessIdDictionary = Ia.Ngn.Cl.Model.Data.ServiceRequestService.ServiceIdToAccessIdDictionary;
700:
701: serviceToAccessIdDictionary = new Dictionary<string, string>(serviceIdToAccessIdDictionary.Count);
702:
703: foreach (KeyValuePair<string, string> kvp in serviceIdToAccessIdDictionary)
704: {
705: key = Ia.Ngn.Cl.Model.Business.ServiceRequestService.ServiceIdToService(kvp.Key);
706:
707: serviceToAccessIdDictionary[key] = kvp.Value;
708: }
709:
710: return serviceToAccessIdDictionary;
711: }
712: }
713:
714: ////////////////////////////////////////////////////////////////////////////
715:
716: /// <summary>
717: ///
718: /// </summary>
719: public static List<string> ProvisionedServiceIdList
720: {
721: get
722: {
723: List<string> serviceRequestServiceList;
724:
725: using (var db = new Ia.Ngn.Cl.Model.Ngn())
726: {
727: serviceRequestServiceList = (from srs in db.ServiceRequestServices where srs.Provisioned == true select srs.Id).ToList();
728: }
729:
730: return serviceRequestServiceList;
731: }
732: }
733:
734: ////////////////////////////////////////////////////////////////////////////
735:
736: /// <summary>
737: ///
738: /// </summary>
739: public static Dictionary<string, string> ProvisionedServiceIdToAccessIdDictionary
740: {
741: get
742: {
743: Dictionary<string, string> dictionary, nullAccessDictionary;
744:
745: using (var db = new Ia.Ngn.Cl.Model.Ngn())
746: {
747: dictionary = (from srs in db.ServiceRequestServices where srs.Provisioned == true && srs.Access != null select new { srs.Id, srs.Access }).ToDictionary(u => u.Id, u => u.Access.Id);
748: nullAccessDictionary = (from s in db.ServiceRequestServices where s.Provisioned == true && s.Access == null select new { s.Id, s.Access }).ToDictionary(u => u.Id, u => string.Empty);
749: }
750:
751: return dictionary.Union(nullAccessDictionary).ToDictionary(u => u.Key, u => u.Value);
752: }
753: }
754:
755: ////////////////////////////////////////////////////////////////////////////
756:
757: /// <summary>
758: ///
759: /// </summary>
760: public static Dictionary<string, string> ProvisionedServiceToAccessIdDictionary
761: {
762: get
763: {
764: string key;
765: Dictionary<string, string> serviceToAccessIdDictionary, serviceIdToAccessIdDictionary;
766:
767: serviceIdToAccessIdDictionary = Ia.Ngn.Cl.Model.Data.ServiceRequestService.ProvisionedServiceIdToAccessIdDictionary;
768:
769: serviceToAccessIdDictionary = new Dictionary<string, string>(serviceIdToAccessIdDictionary.Count);
770:
771: foreach (KeyValuePair<string, string> kvp in serviceIdToAccessIdDictionary)
772: {
773: key = Ia.Ngn.Cl.Model.Business.ServiceRequestService.ServiceIdToService(kvp.Key);
774:
775: serviceToAccessIdDictionary[key] = kvp.Value;
776: }
777:
778: return serviceToAccessIdDictionary;
779: }
780: }
781:
782: ////////////////////////////////////////////////////////////////////////////
783: ////////////////////////////////////////////////////////////////////////////
784:
785: /// <summary>
786: ///
787: /// </summary>
788: public static Dictionary<string, Ia.Ngn.Cl.Model.ServiceRequestService> ServiceToServiceRequestServiceDictionary(List<int> domainList)
789: {
790: string key;
791: List<string> stringDomainList;
792: List<Ia.Ngn.Cl.Model.ServiceRequestService> list;
793: Dictionary<string, Ia.Ngn.Cl.Model.ServiceRequestService> dictionary;
794:
795: stringDomainList = new List<string>();
796:
797: using (var db = new Ia.Ngn.Cl.Model.Ngn())
798: {
799: if (domainList != null)
800: {
801: foreach (int i in domainList) stringDomainList.Add(i.ToString());
802:
803: list = (from srs in db.ServiceRequestServices.Include(a => a.ServiceRequests).ThenInclude(u => u.ServiceRequestTypes)
804: where stringDomainList.Any(u => srs.Service.StartsWith(u.ToString()))
805: select srs).ToList();
806:
807: dictionary = new Dictionary<string, Ia.Ngn.Cl.Model.ServiceRequestService>(list.Count);
808:
809: foreach (var srs in list)
810: {
811: key = srs.Service;
812:
813: if (dictionary.ContainsKey(key))
814: {
815: dictionary[key] = srs;
816: }
817: else dictionary[key] = srs;
818: }
819: }
820: else
821: {
822: dictionary = new Dictionary<string, Ia.Ngn.Cl.Model.ServiceRequestService>();
823: }
824: }
825:
826: return dictionary;
827: }
828:
829: ////////////////////////////////////////////////////////////////////////////
830:
831: /// <summary>
832: ///
833: /// </summary>
834: public static void UpdateServiceSuspension(string service, bool serviceSuspensionState, Guid userId, out Ia.Cl.Model.Result result)
835: {
836: string serviceRequestServiceId;
837: Ia.Ngn.Cl.Model.ServiceRequestService serviceRequestService;
838:
839: result = new Ia.Cl.Model.Result();
840: serviceRequestServiceId = Ia.Ngn.Cl.Model.Business.ServiceRequestService.ServiceRequestServiceId(service, Ia.Ngn.Cl.Model.Business.Service.ServiceType.GponService);
841:
842: using (var db = new Ia.Ngn.Cl.Model.Ngn())
843: {
844: serviceRequestService = (from srs in db.ServiceRequestServices where srs.Id == serviceRequestServiceId select srs).SingleOrDefault();
845:
846: if (serviceRequestService != null)
847: {
848: if (serviceRequestService.ServiceSuspension != serviceSuspensionState)
849: {
850: serviceRequestService.ServiceSuspension = serviceSuspensionState;
851: serviceRequestService.Updated = DateTime.UtcNow.AddHours(3);
852: serviceRequestService.UserId = userId;
853:
854: db.ServiceRequestServices.Attach(serviceRequestService);
855: db.Entry(serviceRequestService).Property(u => u.ServiceSuspension).IsModified = true;
856:
857: db.SaveChanges();
858:
859: result.AddSuccess("ServiceSuspension updated. ");
860: }
861: else
862: {
863: result.AddWarning("Warning: ServiceRequestService ServiceSuspension value was not updated because its the same. ");
864: }
865: }
866: else
867: {
868: result.AddError("Error: serviceRequestService is null. ");
869: }
870: }
871: }
872:
873: /*
874: ////////////////////////////////////////////////////////////////////////////
875:
876: /// <summary>
877: ///
878: /// </summary>
879: public static Dictionary<string, string> ReadServiceAndOntNameDictionaryWithFourDigitNumberDomain(int fourDigitNumberDomain)
880: {
881: string s;
882: Dictionary<string, string> dictionary;
883:
884: dictionary = new Dictionary<string, string>(10000);
885:
886: using (var db = new Ia.Ngn.Cl.Model.Ngn())
887: {
888: var list = (from srs in db.ServiceRequestServices
889: where SqlFunctions.PatIndex(fourDigitNumberDomain.ToString() + "%", srs.Service) > 0
890: orderby srs.Service ascending
891: select new
892: {
893: Service = srs.Service,
894: Access = srs.Access
895: }).ToList();
896:
897: foreach (var v in list)
898: {
899: if (v.Access != null) s = v.Service + " (" + v.Access.Name + ")";
900: else s = v.Service;
901:
902: dictionary[v.Service] = s;
903: }
904: }
905:
906: return dictionary;
907: }
908: */
909:
910: ////////////////////////////////////////////////////////////////////////////
911:
912: /// <summary>
913: ///
914: /// </summary>
915: public static List<Ia.Ngn.Cl.Model.ServiceRequestService> ReadListOfServiceRequestServicesWithSimilarServiceNumbers(List<Ia.Ngn.Cl.Model.ServiceRequest> serviceRequestList)
916: {
917: int i;
918: string[] sp;
919: List<Ia.Ngn.Cl.Model.ServiceRequestService> serviceRequestServiceList;
920:
921: sp = new string[serviceRequestList.Count];
922:
923: i = 0;
924:
925: foreach (Ia.Ngn.Cl.Model.ServiceRequest serviceRequest in serviceRequestList) sp[i++] = serviceRequest.Number.ToString();
926:
927: using (var db = new Ia.Ngn.Cl.Model.Ngn())
928: {
929: serviceRequestServiceList = (from srs in db.ServiceRequestServices where sp.Contains(srs.Service) select srs).ToList();
930: }
931:
932: return serviceRequestServiceList;
933: }
934:
935: ////////////////////////////////////////////////////////////////////////////
936:
937: /// <summary>
938: ///
939: /// </summary>
940: public static List<string> ServiceStringList()
941: {
942: List<string> serviceStringList;
943:
944: using (var db = new Ia.Ngn.Cl.Model.Ngn())
945: {
946: serviceStringList = (from srs in db.ServiceRequestServices
947: where srs.ServiceType == Ia.Ngn.Cl.Model.Business.Service.ServiceType.GponService
948: orderby srs.Service ascending
949: select srs.Service).ToList();
950: }
951:
952: return serviceStringList;
953: }
954:
955: ////////////////////////////////////////////////////////////////////////////
956:
957: /// <summary>
958: ///
959: /// </summary>
960: public static List<string> ServiceStringWithNonNullAccessList()
961: {
962: List<string> serviceStringList;
963:
964: using (var db = new Ia.Ngn.Cl.Model.Ngn())
965: {
966: serviceStringList = (from srs in db.ServiceRequestServices
967: where srs.ServiceType == Ia.Ngn.Cl.Model.Business.Service.ServiceType.GponService && srs.Access != null
968: orderby srs.Service ascending select srs.Service).ToList();
969: }
970:
971: return serviceStringList;
972: }
973:
974: ////////////////////////////////////////////////////////////////////////////
975:
976: /// <summary>
977: ///
978: /// </summary>
979: public static List<Ia.Ngn.Cl.Model.ServiceRequestService> WithNullAccessList()
980: {
981: List<Ia.Ngn.Cl.Model.ServiceRequestService> serviceRequestServiceList;
982:
983: using (var db = new Ia.Ngn.Cl.Model.Ngn())
984: {
985: // below: Take(100) temp
986: serviceRequestServiceList = (from srs in db.ServiceRequestServices where srs.Access == null orderby srs.Service ascending select srs).Take(100).ToList();
987: }
988:
989: return serviceRequestServiceList;
990: }
991:
992: ////////////////////////////////////////////////////////////////////////////
993:
994: /// <summary>
995: ///
996: /// </summary>
997: public static List<Ia.Ngn.Cl.Model.ServiceRequestService> ServiceSuspensionIsTrueAndProvisionedIsTrueList()
998: {
999: List<Ia.Ngn.Cl.Model.ServiceRequestService> serviceRequestServiceList;
1000:
1001: using (var db = new Ia.Ngn.Cl.Model.Ngn())
1002: {
1003: serviceRequestServiceList = (from s in db.ServiceRequestServices where s.ServiceSuspension == true && s.Provisioned == true select s).ToList();
1004: }
1005:
1006: return serviceRequestServiceList;
1007: }
1008:
1009: ////////////////////////////////////////////////////////////////////////////
1010:
1011: /// <summary>
1012: ///
1013: /// </summary>
1014: public static List<Ia.Ngn.Cl.Model.ServiceRequestService> ServiceSuspensionIsFalseList()
1015: {
1016: List<Ia.Ngn.Cl.Model.ServiceRequestService> serviceRequestServiceList;
1017:
1018: using (var db = new Ia.Ngn.Cl.Model.Ngn())
1019: {
1020: serviceRequestServiceList = (from s in db.ServiceRequestServices where s.ServiceSuspension == false select s).ToList();
1021: }
1022:
1023: return serviceRequestServiceList;
1024: }
1025:
1026: ////////////////////////////////////////////////////////////////////////////
1027:
1028: /// <summary>
1029: ///
1030: /// </summary>
1031: public static List<string> ServiceSuspensionIsTrueAndProvisionedIsTrueStringNumberList
1032: {
1033: get
1034: {
1035: List<string> serviceRequestServiceNumberStringList;
1036: List<Ia.Ngn.Cl.Model.ServiceRequestService> serviceRequestServiceList;
1037:
1038: using (var db = new Ia.Ngn.Cl.Model.Ngn())
1039: {
1040: // below:
1041: serviceRequestServiceList = ServiceSuspensionIsTrueAndProvisionedIsTrueList();
1042:
1043: if (serviceRequestServiceList.Count > 0)
1044: {
1045: serviceRequestServiceNumberStringList = new List<string>(serviceRequestServiceList.Count);
1046:
1047: foreach (Ia.Ngn.Cl.Model.ServiceRequestService srs in serviceRequestServiceList)
1048: {
1049: serviceRequestServiceNumberStringList.Add(srs.Service);
1050: }
1051: }
1052: else
1053: {
1054: // below: not null
1055: serviceRequestServiceNumberStringList = new List<string>(1);
1056: }
1057: }
1058:
1059: return serviceRequestServiceNumberStringList;
1060: }
1061: }
1062:
1063: ////////////////////////////////////////////////////////////////////////////
1064:
1065: /// <summary>
1066: ///
1067: /// </summary>
1068: public static List<string> ServiceSuspensionIsFalseStringNumberList
1069: {
1070: get
1071: {
1072: List<string> serviceRequestServiceNumberStringList;
1073: List<Ia.Ngn.Cl.Model.ServiceRequestService> serviceRequestServiceList;
1074:
1075: using (var db = new Ia.Ngn.Cl.Model.Ngn())
1076: {
1077: // below:
1078: serviceRequestServiceList = ServiceSuspensionIsFalseList();
1079:
1080: if (serviceRequestServiceList.Count > 0)
1081: {
1082: serviceRequestServiceNumberStringList = new List<string>(serviceRequestServiceList.Count);
1083:
1084: foreach (Ia.Ngn.Cl.Model.ServiceRequestService srs in serviceRequestServiceList)
1085: {
1086: serviceRequestServiceNumberStringList.Add(srs.Service);
1087: }
1088: }
1089: else
1090: {
1091: // below: not null
1092: serviceRequestServiceNumberStringList = new List<string>(1);
1093: }
1094: }
1095:
1096: return serviceRequestServiceNumberStringList;
1097: }
1098: }
1099:
1100: ////////////////////////////////////////////////////////////////////////////
1101:
1102: /// <summary>
1103: ///
1104: /// </summary>
1105: public static List<Ia.Ngn.Cl.Model.ServiceRequestService> ServiceRequestServiceWithNullAccessList
1106: {
1107: get
1108: {
1109: List<Ia.Ngn.Cl.Model.ServiceRequestService> serviceRequestServiceList;
1110:
1111: using (var db = new Ia.Ngn.Cl.Model.Ngn())
1112: {
1113: serviceRequestServiceList = (from srs in db.ServiceRequestServices where srs.Access == null select srs).ToList();
1114: }
1115:
1116: return serviceRequestServiceList;
1117: }
1118: }
1119:
1120: ////////////////////////////////////////////////////////////////////////////
1121:
1122: /// <summary>
1123: ///
1124: /// </summary>
1125: public static List<string> ServiceRequestServiceServiceIdWhereProvisionedIsTrueAndAccessIsNullList()
1126: {
1127: List<string> list;
1128:
1129: using (var db = new Ia.Ngn.Cl.Model.Ngn())
1130: {
1131: list = (from srs in db.ServiceRequestServices where srs.Provisioned == true && srs.Access == null select srs.Id).ToList();
1132: }
1133:
1134: return list;
1135: }
1136:
1137: ////////////////////////////////////////////////////////////////////////////
1138:
1139: /// <summary>
1140: ///
1141: /// </summary>
1142: public static List<Ia.Ngn.Cl.Model.ServiceRequestService> WithinSiteList(int siteId)
1143: {
1144: Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Site site;
1145: List<int> siteRouterDomainList;
1146: List<Ia.Ngn.Cl.Model.ServiceRequestService> list;
1147: //Dictionary<int, string> areaIdToSymbolDictionary;
1148:
1149: // areaIdToSymbolDictionary = Ia.Ngn.Cl.Model.Data.Service.AreaIdToSymbolDictionary;
1150:
1151: site = (from s in Ia.Ngn.Cl.Model.Data.NetworkDesignDocument.SiteList where s.Id == siteId select s).SingleOrDefault();
1152:
1153: if (site != null)
1154: {
1155: siteRouterDomainList = (from r in Ia.Ngn.Cl.Model.Data.NetworkDesignDocument.RouterList where r.Site.Id == site.Id select r).SelectMany(d => d.DomainList).ToList();
1156:
1157: using (var db = new Ia.Ngn.Cl.Model.Ngn())
1158: {
1159: list = (from srs in db.ServiceRequestServices
1160: where srs.Provisioned == true && siteRouterDomainList.Any(u => srs.Service.StartsWith(u.ToString()))
1161: select srs).Include(u => u.Access).ToList();
1162: }
1163: }
1164: else
1165: {
1166: list = new List<Model.ServiceRequestService>();
1167: }
1168:
1169: return list;
1170: }
1171:
1172: ////////////////////////////////////////////////////////////////////////////
1173:
1174: /// <summary>
1175: ///
1176: /// </summary>
1177: public static bool NullifyAccessIdByAccessId(string accessId, out string result)
1178: {
1179: bool b;
1180: int numberOfRecordsWhereAccessIsNullified;
1181: Ia.Ngn.Cl.Model.ServiceRequestService serviceRequestService;
1182:
1183: b = false;
1184: numberOfRecordsWhereAccessIsNullified = 0;
1185:
1186: using (var db = new Ia.Ngn.Cl.Model.Ngn())
1187: {
1188: // --update ServiceRequestServices set Access_Id = null where Access_Id = '1040101010040004'
1189: //var query = (from srs in db.ServiceRequestServices where srs.Access.Id == accessId select srs).ToList();
1190:
1191: //foreach (var v in query)
1192: //{
1193: serviceRequestService = (from srs in db.ServiceRequestServices where srs.Access.Id == accessId select srs).FirstOrDefault(); //.SingleOrDefault();
1194:
1195: if (serviceRequestService != null)
1196: {
1197: serviceRequestService.Access = null;
1198: serviceRequestService.Updated = DateTime.UtcNow.AddHours(3);
1199:
1200: db.ServiceRequestServices.Attach(serviceRequestService);
1201: db.Entry(serviceRequestService).Property(u => u.Updated).IsModified = true;
1202:
1203: db.SaveChanges();
1204:
1205: numberOfRecordsWhereAccessIsNullified++;
1206: }
1207: //}
1208:
1209: b = true;
1210: }
1211:
1212: result = "Number of records where access is nullified: " + numberOfRecordsWhereAccessIsNullified;
1213:
1214: return b;
1215: }
1216:
1217: ////////////////////////////////////////////////////////////////////////////
1218:
1219: /// <summary>
1220: ///
1221: /// </summary>
1222: public static void UpdateServiceRequestServiceAccess(string service, string updatedAccessId, Guid userId, out Ia.Cl.Model.Result result)
1223: {
1224: bool saveUpdate;
1225: string serviceRequestServiceId;
1226: Ia.Ngn.Cl.Model.ServiceRequestService serviceRequestService;
1227:
1228: saveUpdate = false;
1229: result = new Ia.Cl.Model.Result();
1230: serviceRequestServiceId = Ia.Ngn.Cl.Model.Business.ServiceRequestService.ServiceRequestServiceId(service, Ia.Ngn.Cl.Model.Business.Service.ServiceType.GponService);
1231:
1232: using (var db = new Ia.Ngn.Cl.Model.Ngn())
1233: {
1234: serviceRequestService = (from srs in db.ServiceRequestServices where srs.Id == serviceRequestServiceId select srs).SingleOrDefault();
1235:
1236: if (serviceRequestService != null)
1237: {
1238: if (serviceRequestService.Access != null && serviceRequestService.Access.Id != updatedAccessId
1239: || serviceRequestService.Access == null && !string.IsNullOrEmpty(updatedAccessId))
1240: {
1241: serviceRequestService.Access = (from a in db.Accesses where a.Id == updatedAccessId select a).SingleOrDefault();
1242: serviceRequestService.UserId = userId;
1243: serviceRequestService.Updated = DateTime.UtcNow.AddHours(3);
1244: saveUpdate = true;
1245: }
1246: else if (string.IsNullOrEmpty(updatedAccessId))
1247: {
1248: // nulling
1249: serviceRequestService.Access = null;
1250: serviceRequestService.UserId = userId;
1251: serviceRequestService.Updated = DateTime.UtcNow.AddHours(3);
1252: saveUpdate = true;
1253: }
1254:
1255: if (saveUpdate)
1256: {
1257: db.ServiceRequestServices.Attach(serviceRequestService);
1258:
1259: //db.Entry(serviceRequestService).Property(u => u.Access).IsModified = true;
1260: db.Entry(serviceRequestService).Property(u => u.UserId).IsModified = true;
1261: db.Entry(serviceRequestService).Property(u => u.Updated).IsModified = true;
1262:
1263: db.SaveChanges();
1264:
1265: result.AddSuccess("Service " + service + " access updated. ");
1266: }
1267: else
1268: {
1269: result.AddWarning("Warning: ServiceRequestService Access value was not updated. ");
1270: }
1271: }
1272: else
1273: {
1274: result.AddWarning("Warning: ServiceRequestService is null. ");
1275: }
1276: }
1277: }
1278:
1279: ////////////////////////////////////////////////////////////////////////////
1280:
1281: /// <summary>
1282: ///
1283: /// </summary>
1284: public static Dictionary<string, Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Ont> ProvisionedServiceToNddOntDictionary
1285: {
1286: get
1287: {
1288: string key;
1289: Dictionary<string, Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Ont> dictionary;
1290:
1291: var serviceIdToAccessIdDictionary = Ia.Ngn.Cl.Model.Data.ServiceRequestService.ProvisionedServiceIdToAccessIdDictionary;
1292: var ontAccessIdToOntDictionary = Ia.Ngn.Cl.Model.Data.NetworkDesignDocument.OntAccessIdToOntDictionary;
1293:
1294: dictionary = new Dictionary<string, Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Ont>(serviceIdToAccessIdDictionary.Count);
1295:
1296: foreach (KeyValuePair<string, string> kvp in serviceIdToAccessIdDictionary)
1297: {
1298: key = Ia.Ngn.Cl.Model.Business.ServiceRequestService.ServiceIdToService(kvp.Key);
1299:
1300: if (!string.IsNullOrEmpty(kvp.Value)) dictionary[key] = ontAccessIdToOntDictionary[kvp.Value];
1301: else dictionary[key] = null;
1302: }
1303:
1304: return dictionary;
1305: }
1306: }
1307:
1308: ////////////////////////////////////////////////////////////////////////////
1309:
1310: /// <summary>
1311: ///
1312: /// </summary>
1313: public static Dictionary<string, Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Site> ServiceToSiteDictionary
1314: {
1315: get
1316: {
1317: int fourLetterServiceDomain, fiveLetterServiceDomain;
1318: string service;
1319: Dictionary<string, Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Site> dictionary;
1320:
1321: var serviceIdList = Ia.Ngn.Cl.Model.Data.ServiceRequestService.ServiceIdList;
1322: var routerDomainToSiteDictionary = Ia.Ngn.Cl.Model.Data.NetworkDesignDocument.RouterDomainToSiteDictionary;
1323:
1324: dictionary = new Dictionary<string, Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Site>(serviceIdList.Count);
1325:
1326: foreach (string s in serviceIdList)
1327: {
1328: service = Ia.Ngn.Cl.Model.Business.Service.ServiceIdToService(s);
1329:
1330: if (service.Length >= 5)
1331: {
1332: fourLetterServiceDomain = int.Parse(service.Substring(0, 4));
1333: fiveLetterServiceDomain = int.Parse(service.Substring(0, 5));
1334:
1335: if (routerDomainToSiteDictionary.ContainsKey(fiveLetterServiceDomain)) dictionary[service] = routerDomainToSiteDictionary[fiveLetterServiceDomain];
1336: else if (routerDomainToSiteDictionary.ContainsKey(fourLetterServiceDomain)) dictionary[service] = routerDomainToSiteDictionary[fourLetterServiceDomain];
1337: //else throw new System.ArgumentOutOfRangeException("Service number " + service + " is out of range");
1338: }
1339: //else throw new System.ArgumentOutOfRangeException("Service number " + service + " is out of range");
1340: }
1341:
1342: return dictionary;
1343: }
1344: }
1345:
1346: ////////////////////////////////////////////////////////////////////////////
1347:
1348: /// <summary>
1349: ///
1350: /// </summary>
1351: public static Dictionary<string, Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Site> ProvisionedServiceToSiteDictionary
1352: {
1353: get
1354: {
1355: int fourLetterServiceDomain, fiveLetterServiceDomain;
1356: string service;
1357: Dictionary<string, Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Site> dictionary;
1358:
1359: var serviceIdList = Ia.Ngn.Cl.Model.Data.ServiceRequestService.ProvisionedServiceIdList;
1360: var routerDomainToSiteDictionary = Ia.Ngn.Cl.Model.Data.NetworkDesignDocument.RouterDomainToSiteDictionary;
1361:
1362: dictionary = new Dictionary<string, Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Site>(serviceIdList.Count);
1363:
1364: foreach (string s in serviceIdList)
1365: {
1366: service = Ia.Ngn.Cl.Model.Business.Service.ServiceIdToService(s);
1367:
1368: if (service.Length >= 5)
1369: {
1370: fourLetterServiceDomain = int.Parse(service.Substring(0, 4));
1371: fiveLetterServiceDomain = int.Parse(service.Substring(0, 5));
1372:
1373: if (routerDomainToSiteDictionary.ContainsKey(fiveLetterServiceDomain)) dictionary[service] = routerDomainToSiteDictionary[fiveLetterServiceDomain];
1374: else if (routerDomainToSiteDictionary.ContainsKey(fourLetterServiceDomain)) dictionary[service] = routerDomainToSiteDictionary[fourLetterServiceDomain];
1375: //else throw new System.ArgumentOutOfRangeException("Service number " + service + " is out of range");
1376: }
1377: //else throw new System.ArgumentOutOfRangeException("Service number " + service + " is out of range");
1378: }
1379:
1380: return dictionary;
1381: }
1382: }
1383:
1384: ////////////////////////////////////////////////////////////////////////////
1385: ////////////////////////////////////////////////////////////////////////////
1386: }
1387:
1388: ////////////////////////////////////////////////////////////////////////////
1389: ////////////////////////////////////////////////////////////////////////////
1390: }