1: using System;
2: using System.Collections.Generic;
3: using System.Configuration;
4: using System.Data;
5: using System.Linq;
6:
7: namespace Ia.Ngn.Cl.Model.Business.Nokia
8: {
9: ////////////////////////////////////////////////////////////////////////////
10:
11: /// <summary publish="true">
12: /// Optical Fiber Network Management Intranet Portal (OFN) support class for Nokia's Next Generation Network (NGN) business model.
13: /// </summary>
14: ///
15: /// <value>
16: /// <appSettings>
17: /// <add key="imsServerHost" value="https://*" />
18: /// <add key="imsServerPort" value="*" />
19: /// <add key="imsServerServiceUrl" value="*" />
20: /// <add key="imsServerUser" value="*" />
21: /// <add key="imsServerUserPassword" value="*" />
22: /// </appSettings>
23: /// </value>
24: ///
25: /// <remarks>
26: /// Copyright © 2014-2018 Jasem Y. Al-Shamlan (info@ia.com.kw), Integrated Applications - Kuwait. All Rights Reserved.
27: ///
28: /// 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
29: /// the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
30: ///
31: /// This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
32: /// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
33: ///
34: /// You should have received a copy of the GNU General Public License along with this library. If not, see http://www.gnu.org/licenses.
35: ///
36: /// Copyright notice: This notice may not be removed or altered from any source distribution.
37: /// </remarks>
38: public class Ims
39: {
40: // below: this is the almost official GwId range used
41:
42: private const int gwIdFirst = 2048;
43: private const int gwIdLast = 65535;
44:
45: private const int primaryPUIDCPEProfileNumberForSip = 10;
46: private const int primaryPUIDCPEProfileNumberForH248 = 35;
47:
48: private const string sipSubscriberRegistrationPassword = "1234"; // as per Nokia spec
49:
50: private static List<int> allPossibleGwIdList = new List<int>();
51: private static List<int> allPossibleServiceNumberList = new List<int>();
52: private static Queue<string> agcfEndpointPrividUserQueue = new Queue<string>();
53:
54: private static Ia.Ngn.Cl.Model.Business.Procedure procedureNokiaImsSubscriberToBeUpdatedFromH248ToSipList = new Ia.Ngn.Cl.Model.Business.Procedure(Ia.Ngn.Cl.Model.Business.Provision.NokiaImsSubscriberToBeUpdatedFromH248ToSipList);
55:
56: public class ImsBasicService
57: {
58: public string MgcIp;
59: public string MgcSecondaryIp;
60: public string MgcSubnetMask;
61: public int Service;
62: public string Fsdb;
63: public string PrimarySwitch;
64: }
65:
66: public static ImsBasicService[] ImsBasicServiceList =
67: {
68: new ImsBasicService { MgcIp="10.16.1.31", MgcSecondaryIp="10.16.5.31", MgcSubnetMask="255.255.224.0",Service=0,Fsdb="fsdb0",PrimarySwitch=TEC },
69: new ImsBasicService { MgcIp="10.16.1.32", MgcSecondaryIp="10.16.5.32", MgcSubnetMask="255.255.224.0",Service=1,Fsdb="fsdb1",PrimarySwitch=TEC },
70: new ImsBasicService { MgcIp="10.16.1.33", MgcSecondaryIp="10.16.5.33", MgcSubnetMask="255.255.224.0",Service=2,Fsdb="fsdb1",PrimarySwitch=TEC },
71: new ImsBasicService { MgcIp="10.16.1.34", MgcSecondaryIp="10.16.5.34", MgcSubnetMask="255.255.224.0",Service=3,Fsdb="fsdb1",PrimarySwitch=TEC },
72: new ImsBasicService { MgcIp="10.16.1.35", MgcSecondaryIp="10.16.5.35", MgcSubnetMask="255.255.224.0",Service=4,Fsdb="fsdb2",PrimarySwitch=TEC },
73: new ImsBasicService { MgcIp="10.16.1.36", MgcSecondaryIp="10.16.5.36", MgcSubnetMask="255.255.224.0",Service=5,Fsdb="fsdb2",PrimarySwitch=TEC },
74: new ImsBasicService { MgcIp="10.16.1.37", MgcSecondaryIp="10.16.5.37", MgcSubnetMask="255.255.224.0",Service=6,Fsdb="fsdb2",PrimarySwitch=TEC },
75: new ImsBasicService { MgcIp="10.16.1.38", MgcSecondaryIp="10.16.5.38", MgcSubnetMask="255.255.224.0",Service=7,Fsdb="fsdb3",PrimarySwitch=TEC },
76: new ImsBasicService { MgcIp="10.16.1.39", MgcSecondaryIp="10.16.5.39", MgcSubnetMask="255.255.224.0",Service=8,Fsdb="fsdb3",PrimarySwitch=TEC },
77: new ImsBasicService { MgcIp="10.16.1.40", MgcSecondaryIp="10.16.5.40", MgcSubnetMask="255.255.224.0",Service=9,Fsdb="fsdb3",PrimarySwitch=TEC },
78:
79: new ImsBasicService { MgcIp="10.16.5.31", MgcSecondaryIp="10.16.1.31", MgcSubnetMask="255.255.224.0",Service=0,Fsdb="fsdb0",PrimarySwitch=SKB },
80: new ImsBasicService { MgcIp="10.16.5.32", MgcSecondaryIp="10.16.1.32", MgcSubnetMask="255.255.224.0",Service=1,Fsdb="fsdb1",PrimarySwitch=SKB },
81: new ImsBasicService { MgcIp="10.16.5.33", MgcSecondaryIp="10.16.1.33", MgcSubnetMask="255.255.224.0",Service=2,Fsdb="fsdb1",PrimarySwitch=SKB },
82: new ImsBasicService { MgcIp="10.16.5.34", MgcSecondaryIp="10.16.1.34", MgcSubnetMask="255.255.224.0",Service=3,Fsdb="fsdb1",PrimarySwitch=SKB },
83: new ImsBasicService { MgcIp="10.16.5.35", MgcSecondaryIp="10.16.1.35", MgcSubnetMask="255.255.224.0",Service=4,Fsdb="fsdb2",PrimarySwitch=SKB },
84: new ImsBasicService { MgcIp="10.16.5.36", MgcSecondaryIp="10.16.1.36", MgcSubnetMask="255.255.224.0",Service=5,Fsdb="fsdb2",PrimarySwitch=SKB },
85: new ImsBasicService { MgcIp="10.16.5.37", MgcSecondaryIp="10.16.1.37", MgcSubnetMask="255.255.224.0",Service=6,Fsdb="fsdb2",PrimarySwitch=SKB },
86: new ImsBasicService { MgcIp="10.16.5.38", MgcSecondaryIp="10.16.1.38", MgcSubnetMask="255.255.224.0",Service=7,Fsdb="fsdb3",PrimarySwitch=SKB },
87: new ImsBasicService { MgcIp="10.16.5.39", MgcSecondaryIp="10.16.1.39", MgcSubnetMask="255.255.224.0",Service=8,Fsdb="fsdb3",PrimarySwitch=SKB },
88: new ImsBasicService { MgcIp="10.16.5.40", MgcSecondaryIp="10.16.1.40", MgcSubnetMask="255.255.224.0",Service=9,Fsdb="fsdb3",PrimarySwitch=SKB },
89: };
90:
91: /// <summary/>
92: public static int FirstGatewayId { get { return gwIdFirst; } }
93: /// <summary/>
94: public static int LastGatewayId { get { return gwIdLast; } }
95:
96: /// <summary/>
97: public static string BaseAddress { get { return ConfigurationManager.AppSettings["imsServerHost"].ToString() + ":" + ConfigurationManager.AppSettings["imsServerPort"].ToString(); } }
98: /// <summary/>
99: public static string ServiceUrl { get { return ConfigurationManager.AppSettings["imsServerServiceUrl"].ToString(); } }
100: /// <summary/>
101: public static string UserName { get { return ConfigurationManager.AppSettings["imsServerUser"].ToString(); } }
102: /// <summary/>
103: public static string Password { get { return ConfigurationManager.AppSettings["imsServerUserPassword"].ToString(); } }
104:
105: public static string AnyPrimarySwitch { get { return TEC; } }
106:
107: public static string TEC { get { return "TECICS01"; } }
108:
109: public static string SKB { get { return "SKBICS02"; } }
110:
111:
112: public const int MaximumCombinedNumberOfAgcfGatewayRecordsInAnyMgcIpAndMgcSecondaryIpPair = 4800; // limit defind by Nokia
113:
114: public static int PrimaryPUIDCPEProfileNumberForSip { get { return primaryPUIDCPEProfileNumberForSip; } }
115:
116: public static int PrimaryPUIDCPEProfileNumberForH248 { get { return primaryPUIDCPEProfileNumberForH248; } }
117:
118: public static string SipSubscriberRegistrationPassword { get { return sipSubscriberRegistrationPassword; } }
119:
120: public static List<string> FsdbList = new List<string> { "fsdb0", "fsdb1", "fsdb2", "fsdb3" };
121:
122: ////////////////////////////////////////////////////////////////////////////
123:
124: /// <summary>
125: /// Response of IMS
126: /// </summary>
127: public class Response
128: {
129: /// <summary/>
130: public int Service { get; set; }
131:
132: /// <summary/>
133: public bool IsSuccess { get { return ResultCode == Ia.Ngn.Cl.Model.Client.Nokia.Ims.ResultCode.Successful; } }
134:
135: /// <summary/>
136: public bool IsProvisioned { get; set; }
137:
138: /// <summary/>
139: public Ia.Ngn.Cl.Model.Client.Nokia.Ims.ResultCode ResultCode { get; set; }
140:
141: /// <summary/>
142: //public string Ctag { get; set; } // no need because the commad string is included in response body
143:
144: /// <summary/>
145: public DateTime DateTime { get; set; }
146:
147: /// <summary/>
148: public string CommandString { get; set; }
149:
150: /// <summary/>
151: public string FailureReason { get; set; }
152:
153: /// <summary/>
154: public string FailureCode { get; set; }
155:
156: /// <summary/>
157: //public Dictionary<string, string> ParameterDictionary { get; set; }
158:
159: /// <summary/>
160: public List<Dictionary<string, string>> ParameterDictionaryList { get; set; }
161:
162: /// <summary/>
163: public Response() { }
164: }
165:
166: ////////////////////////////////////////////////////////////////////////////
167:
168: /// <summary>
169: ///
170: /// </summary>
171: public Ims()
172: {
173: }
174:
175: ////////////////////////////////////////////////////////////////////////////
176:
177: /// <summary>
178: ///
179: /// </summary>
180: public static List<string> NumberOfNokiaSubsribersPerFsdb()
181: {
182: string imsFsdb;
183: Dictionary<string, int> dic;
184: Dictionary<string, string> ontListNokiaIpToPrimarySwitchImsFsdbDictionary;
185: List<string> list;
186:
187: dic = new Dictionary<string, int>();
188:
189: ontListNokiaIpToPrimarySwitchImsFsdbDictionary = Ia.Ngn.Cl.Model.Data.NetworkDesignDocument.NokiaOntIpToPrimarySwitchImsFsdbDictionary;
190:
191: using (var db = new Ia.Ngn.Cl.Model.Ngn())
192: {
193: list = (from e in db.AgcfEndpoints
194: join gr in db.AgcfGatewayRecords on e.AgcfGatewayRecord.Id equals gr.Id
195: select gr.IP1).ToList();
196: }
197:
198: foreach (string ip in list)
199: {
200: if (ontListNokiaIpToPrimarySwitchImsFsdbDictionary.ContainsKey(ip))
201: {
202: imsFsdb = ontListNokiaIpToPrimarySwitchImsFsdbDictionary[ip];
203:
204: if (dic.ContainsKey(imsFsdb)) dic[imsFsdb]++;
205: else dic[imsFsdb] = 1;
206: }
207: }
208:
209: list.Clear();
210:
211: foreach (KeyValuePair<string, int> kvp in dic)
212: {
213: list.Add(kvp.Key + ": " + kvp.Value);
214: }
215:
216: return list;
217: }
218:
219: ////////////////////////////////////////////////////////////////////////////
220:
221: /// <summary>
222: ///
223: /// </summary>
224: public static int NextVacantFlatTermIdFromAgcfEndpointUsingGwId(Ia.Ngn.Cl.Model.Business.Nokia.Ont.FamilyType familyType, int gwId)
225: {
226: int ft;
227: List<int> list;
228:
229: list = Ia.Ngn.Cl.Model.Data.Nokia.AgcfEndpoint.UsedFlatTermIdListForGatewayId(gwId);
230:
231: if (list.Count == 0) ft = 1; // this means agcfEndpoint does not exist for any number and the box is empty, and we should create agcfEndpoint at 1
232: else
233: {
234: // change this later to accommodate the Huawei ONT type
235: list = Ia.Cl.Model.Default.ExcludedNumberListFromNumberListWithinRange(list, Ia.Ngn.Cl.Model.Business.Nokia.Ams.PossibleNumberOfTdForOntFamilyType(familyType));
236:
237: if (list.Count > 0) ft = list[0];
238: else ft = 0; // something went wrong
239: }
240:
241: return ft;
242: }
243:
244: ////////////////////////////////////////////////////////////////////////////
245:
246: /// <summary>
247: /// Check the number of combined AGCF gateway records for this MGC IP and its secondary MGC IP if they exceed the MaximumCombinedNumberOfAgcfGatewayRecordsInAnyMgcIpAndMgcSecondaryIpPair
248: /// </summary>
249: public static bool MaximumCombinedNumberOfAgcfGatewayRecordsInAnyMgcIpAndMgcSecondaryIpPairIsExceeded(string mgcIp)
250: {
251: bool isExceeded;
252: int count;
253: ImsBasicService imsBasicServiceItem;
254:
255: imsBasicServiceItem = ImsBasicServiceItem(mgcIp);
256:
257: if (imsBasicServiceItem != null)
258: {
259: using (var db = new Ia.Ngn.Cl.Model.Ngn())
260: {
261: count = (from gr in db.AgcfGatewayRecords where gr.MateExternalIPAddr == imsBasicServiceItem.MgcIp || gr.MateExternalIPAddr == imsBasicServiceItem.MgcSecondaryIp select gr.Id).Count();
262:
263: isExceeded = (count > MaximumCombinedNumberOfAgcfGatewayRecordsInAnyMgcIpAndMgcSecondaryIpPair);
264: }
265: }
266: else throw new System.ArgumentException("imsBasicServiceItem cannot be null", "imsBasicServiceItem");
267:
268: return isExceeded;
269: }
270:
271: ////////////////////////////////////////////////////////////////////////////
272:
273: /// <summary>
274: /// Statistics dictionary of the current AGCF Gateway Record by MGC gateway IP
275: /// </summary>
276: public static Dictionary<string, int> NumberOfAgcfGatewayRecordInGroupOfMgcIpDictionary
277: {
278: get
279: {
280: Dictionary<string, int> dictionary;
281:
282: using (var db = new Ia.Ngn.Cl.Model.Ngn())
283: {
284: dictionary = (from gr in db.AgcfGatewayRecords
285: group gr.MateExternalIPAddr by gr.MateExternalIPAddr into g
286: select new { MateExternalIPAddr = g.Key, Count = g.Count() }).ToDictionary(t => t.MateExternalIPAddr, t => t.Count);
287: }
288:
289: return dictionary;
290: }
291: }
292:
293: ////////////////////////////////////////////////////////////////////////////
294:
295: /// <summary>
296: /// Statistics dictionary of the current AGCF gateway records with corresponding AGCF endpoints by MGC gateway IP
297: /// </summary>
298: public static Dictionary<string, int> NumberOfAgcfGatewayRecordWithCorrespondingAgcfEndpointInGroupOfMgcIpDictionary
299: {
300: get
301: {
302: Dictionary<string, int> dictionary;
303:
304: using (var db = new Ia.Ngn.Cl.Model.Ngn())
305: {
306: dictionary = (from gr in db.AgcfGatewayRecords
307: join ep in db.AgcfEndpoints on new { gr.Id } equals new { ep.AgcfGatewayRecord.Id }
308: group gr.MateExternalIPAddr by gr.MateExternalIPAddr into g
309: select new { MateExternalIPAddr = g.Key, Count = g.Count() }).ToDictionary(t => t.MateExternalIPAddr, t => t.Count);
310: }
311:
312: return dictionary;
313: }
314: }
315:
316: ////////////////////////////////////////////////////////////////////////////
317:
318: /// <summary>
319: /// Calculate a pseudo random MGC IP from imsBasicServiceList for this ONT IP
320: /// </summary>
321: public static string PseudoRandomMgcIp(string ontIp)
322: {
323: uint ui, randomIndex;
324: string mgcIp;
325:
326: if (!string.IsNullOrEmpty(ontIp))
327: {
328: ui = Ia.Cl.Model.Default.IpToUint(ontIp);
329:
330: // important: any change to imsBasicServiceList length will cause the pseudo random function to produce different values for IPs
331: randomIndex = ui % (uint)ImsBasicServiceList.Count();
332:
333: mgcIp = ImsBasicServiceList[randomIndex].MgcIp;
334: }
335: else mgcIp = string.Empty;
336:
337: return mgcIp;
338: }
339:
340: ////////////////////////////////////////////////////////////////////////////
341:
342: /// <summary>
343: /// Return the IMS basic service for given MGC IP
344: /// </summary>
345: public static ImsBasicService ImsBasicServiceItem(string mgcIp)
346: {
347: ImsBasicService imsBasicService;
348:
349: imsBasicService = (from ibs in ImsBasicServiceList where ibs.MgcIp == mgcIp select ibs).SingleOrDefault();
350:
351: return imsBasicService;
352: }
353:
354: ////////////////////////////////////////////////////////////////////////////
355:
356: /// <summary>
357: ///
358: /// </summary>
359: public static string ImsFsdb(int imsService, string primarySwitch)
360: {
361: string fsdb;
362: ImsBasicService imsBasicService;
363:
364: if (imsService >= 0)
365: {
366: imsBasicService = (from ibs in ImsBasicServiceList where ibs.Service == imsService && ibs.PrimarySwitch == primarySwitch select ibs).SingleOrDefault();
367:
368: fsdb = (imsBasicService != null) ? imsBasicService.Fsdb : string.Empty;
369: }
370: else fsdb = string.Empty;
371:
372: return fsdb;
373: }
374:
375: ////////////////////////////////////////////////////////////////////////////
376:
377: /// <summary>
378: ///
379: /// </summary>
380: public static string AgcfSipIaPort(int imsService)
381: {
382: // see ImsServiceFromAgcfSipIaPort()
383: string agcfSipIaPort;
384:
385: switch (imsService)
386: {
387: case 0: agcfSipIaPort = "agcf-stdn.imsgroup0-00" + imsService; break;
388: case 1:
389: case 2:
390: case 3: agcfSipIaPort = "agcf-stdo.imsgroup0-00" + imsService; break;
391: case 4:
392: case 5:
393: case 6: agcfSipIaPort = "agcf-stdp.imsgroup0-00" + imsService; break;
394: case 7:
395: case 8:
396: case 9: agcfSipIaPort = "agcf-stdq.imsgroup0-00" + imsService; break;
397: default: agcfSipIaPort = null; break;
398: }
399:
400: return agcfSipIaPort;
401: }
402:
403: ////////////////////////////////////////////////////////////////////////////
404:
405: /// <summary>
406: ///
407: /// </summary>
408: public static int ImsServiceFromAgcfSipIaPort(string agcfSipIaPort)
409: {
410: // see AgcfSipIaPort()
411: int imsService;
412:
413: switch (agcfSipIaPort)
414: {
415: case "agcf-stdn.imsgroup0-000": imsService = 0; break;
416: case "agcf-stdo.imsgroup0-001": imsService = 1; break;
417: case "agcf-stdo.imsgroup0-002": imsService = 2; break;
418: case "agcf-stdo.imsgroup0-003": imsService = 3; break;
419: case "agcf-stdp.imsgroup0-004": imsService = 4; break;
420: case "agcf-stdp.imsgroup0-005": imsService = 5; break;
421: case "agcf-stdp.imsgroup0-006": imsService = 6; break;
422: case "agcf-stdq.imsgroup0-007": imsService = 7; break;
423: case "agcf-stdq.imsgroup0-008": imsService = 8; break;
424: case "agcf-stdq.imsgroup0-009": imsService = 9; break;
425: default: imsService = -1; break;
426: }
427:
428: return imsService;
429: }
430:
431: ////////////////////////////////////////////////////////////////////////////
432:
433: /// <summary>
434: ///
435: /// </summary>
436: public static string AlternateFsdbFqdn(string primarySwitch, string fsdb)
437: {
438: string alternateFsdbFqdn;
439:
440: if (primarySwitch == TEC)
441: {
442: switch (fsdb)
443: {
444: case "fsdb0": alternateFsdbFqdn = "10.16.0.88"; break;
445: case "fsdb1": alternateFsdbFqdn = "10.16.0.89"; break;
446: case "fsdb2": alternateFsdbFqdn = "10.16.0.90"; break;
447: case "fsdb3": alternateFsdbFqdn = "10.16.0.91"; break;
448: default: alternateFsdbFqdn = string.Empty; break;
449: }
450: }
451: else if (primarySwitch == SKB)
452: {
453: switch (fsdb)
454: {
455: case "fsdb0": alternateFsdbFqdn = "10.16.0.9"; break;
456: case "fsdb1": alternateFsdbFqdn = "10.16.0.10"; break;
457: case "fsdb2": alternateFsdbFqdn = "10.16.0.11"; break;
458: case "fsdb3": alternateFsdbFqdn = "10.16.0.12"; break;
459: default: alternateFsdbFqdn = string.Empty; break;
460: }
461: }
462: else throw new Exception("Unknown primarySwitch") { };
463:
464: return alternateFsdbFqdn;
465: }
466:
467: ////////////////////////////////////////////////////////////////////////////
468:
469: /// <summary>
470: ///
471: /// </summary>
472: public static void AssocAndAlternateOtasRealm(string primarySwitch, string fsdb, out int applicationServerId, out string assocOtasRealm, out string alternateOtasRealm)
473: {
474: bool randomState;
475:
476: randomState = Ia.Cl.Model.Default.RandomBool;
477:
478: switch (fsdb)
479: {
480: case "fsdb0": applicationServerId = 0; break;
481: case "fsdb1": applicationServerId = randomState ? 1 : 2; break;
482: case "fsdb2": applicationServerId = randomState ? 3 : 4; break;
483: case "fsdb3": applicationServerId = randomState ? 5 : 6; break;
484: default: throw new Exception("Unknown fsdb") { };
485: }
486:
487: if (primarySwitch == TEC)
488: {
489: assocOtasRealm = "stas-stdn.fsimsgroup0-00" + applicationServerId + @".tecics01.ims.moc1.kw";
490: }
491: else if (primarySwitch == SKB)
492: {
493: assocOtasRealm = "stas-stdn.fsimsgroup0-00" + applicationServerId + @".skbics01.ims.moc1.kw";
494: }
495: else throw new Exception("Unknown primarySwitch") { };
496:
497: //
498: if (assocOtasRealm.Contains("skbics01"))
499: {
500: alternateOtasRealm = assocOtasRealm.Replace("skbics01", "tecics01");
501: }
502: else if (assocOtasRealm.Contains("tecics01"))
503: {
504: alternateOtasRealm = assocOtasRealm.Replace("tecics01", "skbics01");
505: }
506: else throw new Exception("Unknown primarySwitch") { };
507: }
508:
509: ////////////////////////////////////////////////////////////////////////////
510:
511: /// <summary>
512: ///
513: /// </summary>
514: public static string AssigneCorrectMateExternalIPAddrForIsPrimary(bool isPrimary, string mateExternalIPAddr)
515: {
516: string mate;
517:
518: if (isPrimary)
519: {
520: mate = mateExternalIPAddr;
521: }
522: else
523: {
524: switch (mateExternalIPAddr)
525: {
526: case "10.16.1.31": mate = "10.16.5.31"; break;
527: case "10.16.1.32": mate = "10.16.5.32"; break;
528: case "10.16.1.33": mate = "10.16.5.33"; break;
529: case "10.16.1.34": mate = "10.16.5.34"; break;
530: case "10.16.1.35": mate = "10.16.5.35"; break;
531: case "10.16.1.36": mate = "10.16.5.36"; break;
532: case "10.16.1.37": mate = "10.16.5.37"; break;
533: case "10.16.1.38": mate = "10.16.5.38"; break;
534: case "10.16.1.39": mate = "10.16.5.39"; break;
535: case "10.16.1.40": mate = "10.16.5.40"; break;
536:
537: case "10.16.5.31": mate = "10.16.1.31"; break;
538: case "10.16.5.32": mate = "10.16.1.32"; break;
539: case "10.16.5.33": mate = "10.16.1.33"; break;
540: case "10.16.5.34": mate = "10.16.1.34"; break;
541: case "10.16.5.35": mate = "10.16.1.35"; break;
542: case "10.16.5.36": mate = "10.16.1.36"; break;
543: case "10.16.5.37": mate = "10.16.1.37"; break;
544: case "10.16.5.38": mate = "10.16.1.38"; break;
545: case "10.16.5.39": mate = "10.16.1.39"; break;
546: case "10.16.5.40": mate = "10.16.1.40"; break;
547:
548: default: mate = null; break;
549: }
550: }
551:
552: return mate;
553: }
554:
555: ////////////////////////////////////////////////////////////////////////////
556:
557: /// <summary>
558: ///
559: /// </summary>
560: public static string PrimarySwitchFromAgcfGatewayRecord(bool isPrimary)
561: {
562: string primarySwitch;
563:
564: if (isPrimary) primarySwitch = Ia.Ngn.Cl.Model.Business.Nokia.Ims.AnyPrimarySwitch;
565: else primarySwitch = Ia.Ngn.Cl.Model.Business.Nokia.Ims.SKB;
566:
567: return primarySwitch;
568: }
569:
570: ////////////////////////////////////////////////////////////////////////////
571:
572: /// <summary>
573: ///
574: /// </summary>
575: public static string SecondarySwitchFromAgcfGatewayRecord(bool isPrimary)
576: {
577: string secondarySwitch;
578:
579: if (!isPrimary) secondarySwitch = Ia.Ngn.Cl.Model.Business.Nokia.Ims.AnyPrimarySwitch;
580: else secondarySwitch = Ia.Ngn.Cl.Model.Business.Nokia.Ims.SKB;
581:
582: return secondarySwitch;
583: }
584:
585: ////////////////////////////////////////////////////////////////////////////
586:
587: /// <summary>
588: ///
589: /// </summary>
590: public static int ServiceProfileNumber(int applicationServerId)
591: {
592: int serviceProfileNumber;
593:
594: switch (applicationServerId)
595: {
596: case 0: serviceProfileNumber = 2; break;
597: case 1: serviceProfileNumber = 10; break;
598: case 2: serviceProfileNumber = 18; break;
599: case 3: serviceProfileNumber = 26; break;
600: case 4: serviceProfileNumber = 34; break;
601: case 5: serviceProfileNumber = 42; break;
602: case 6: serviceProfileNumber = 50; break;
603: default: throw new Exception("Unknown primarySwitch") { };
604: }
605:
606: return serviceProfileNumber;
607: }
608:
609: ////////////////////////////////////////////////////////////////////////////
610:
611: /// <summary>
612: ///
613: /// </summary>
614: public static int ServiceProfileNumberAgcfGatewayRecord(int imsService)
615: {
616: bool randomState;
617: int serviceProfileNumber;
618:
619: randomState = Ia.Cl.Model.Default.RandomBool;
620:
621: switch (imsService)
622: {
623: case 0: serviceProfileNumber = 2; break;
624: case 1:
625: case 2:
626: case 3: serviceProfileNumber = randomState ? 10 : 18; break;
627: case 4:
628: case 5:
629: case 6: serviceProfileNumber = randomState ? 26 : 34; break;
630: case 7:
631: case 8:
632: case 9: serviceProfileNumber = randomState ? 42 : 50; break;
633: default: throw new Exception("Unknown primarySwitch") { };
634: }
635:
636: return serviceProfileNumber;
637: }
638:
639: ////////////////////////////////////////////////////////////////////////////
640:
641: /// <summary>
642: ///
643: /// </summary>
644: public static int GwIdToReadAgcfGatewayRecordData(ref int referenceIndex, out int itemIndex, out int listCount)
645: {
646: if (allPossibleGwIdList.JustStartedOrRolledOver())
647: {
648: allPossibleGwIdList = Ia.Ngn.Cl.Model.Data.Nokia.Ims.AllPossibleGatewayIdList;
649: }
650:
651: var number = allPossibleGwIdList.Next(ref referenceIndex, out itemIndex, out listCount);
652:
653: return number;
654: }
655:
656: ////////////////////////////////////////////////////////////////////////////
657:
658: /// <summary>
659: ///
660: /// </summary>
661: public static string ServiceToReadServiceData(ref int referenceIndex, out int itemIndex, out int listCount)
662: {
663: if (allPossibleServiceNumberList.JustStartedOrRolledOver())
664: {
665: allPossibleServiceNumberList = Ia.Ngn.Cl.Model.Data.Service.AllPossibleServiceNumberListWithinNokiaSwitch;
666: }
667:
668: var service = allPossibleServiceNumberList.Next(ref referenceIndex, out itemIndex, out listCount);
669:
670: return service.ToString();
671: }
672:
673: ////////////////////////////////////////////////////////////////////////////
674:
675: /// <summary>
676: ///
677: /// </summary>
678: public static string SequentialPrividUserFromAgcfEndpointToReadSubPartyAndSubscriberData
679: {
680: get
681: {
682: string prividUser;
683:
684: if (agcfEndpointPrividUserQueue.Count == 0)
685: {
686: agcfEndpointPrividUserQueue = new Queue<string>(Ia.Ngn.Cl.Model.Data.Nokia.AgcfEndpoint.ReadPrividUserList);
687: }
688:
689: prividUser = agcfEndpointPrividUserQueue.Dequeue();
690:
691: return prividUser;
692: }
693: }
694:
695: ////////////////////////////////////////////////////////////////////////////
696: ////////////////////////////////////////////////////////////////////////////
697:
698: /// <summary>
699: ///
700: /// </summary>
701: public static Ia.Cl.Model.Result CreateMissingAgcfGatewayRecordForNokiaSwitchOntInNonSipOlt(Ia.Ngn.Cl.Model.Client.Nokia.Ims nokiaIms)
702: {
703: int gwId;
704: string r1;
705: Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Ont nddOnt;
706:
707: var result = new Ia.Cl.Model.Result();
708:
709: nddOnt = Ia.Ngn.Cl.Model.Data.Provision.NddNokiaSwitchOntInNonSipOltWithAccessButNoAgcfGatewayRecord(out string r0);
710:
711: if (nddOnt != null)
712: {
713: gwId = Ia.Ngn.Cl.Model.Business.Nokia.AgcfGatewayRecord.RandomUnusedGwId();
714:
715: Ia.Ngn.Cl.Model.Data.Nokia.Ims.CreateAgcfGatewayRecordForGwId(nokiaIms, gwId, nddOnt, out string createResult);
716:
717: Ia.Ngn.Cl.Model.Data.Nokia.Ims.ReadUpdateAgcfGatewayRecordAndAgcfEndpointListAndSubPartyAndSubscriberAndServiceForGwId(nokiaIms, gwId, out string readResult);
718:
719: r1 = r0 + " " + nddOnt.Access.Name + ", gwId: " + gwId + ", createResult: " + createResult + ", readResult: " + readResult;
720: }
721: else
722: {
723: r1 = "There are no Nokia switch non SIP OLT NDD ONTs with access and without an AgcfGatewayRecord. ";
724: }
725:
726: r1 = "Manage: " + r1;
727:
728: result.AddSuccess(r1);
729:
730: return result;
731: }
732:
733: ////////////////////////////////////////////////////////////////////////////
734:
735: /// <summary>
736: ///
737: /// </summary>
738: public static Ia.Cl.Model.Result DeleteAgcfGatewayRecordWithNoNddNokiaSwitchOntInNonSipOltAndNullOrEmptyAgcfEndpoint(Ia.Ngn.Cl.Model.Client.Nokia.Ims nokiaIms)
739: {
740: string r0;
741: Ia.Ngn.Cl.Model.Nokia.AgcfGatewayRecord agcfGatewayRecord;
742:
743: r0 = string.Empty;
744: var result = new Ia.Cl.Model.Result();
745:
746: agcfGatewayRecord = Ia.Ngn.Cl.Model.Data.Provision.AgcfGatewayRecordWithNoNddNokiaSwitchOntInNonSipOltAndNullOrEmptyAgcfEndpoint(out string r1);
747:
748: try
749: {
750: if (agcfGatewayRecord != null)
751: {
752: Ia.Ngn.Cl.Model.Data.Nokia.Ims.DeleteAgcfGatewayRecordForGwId(nokiaIms, agcfGatewayRecord, out string deleteResult);
753:
754: Ia.Ngn.Cl.Model.Data.Nokia.Ims.ReadUpdateAgcfGatewayRecordAndAgcfEndpointListAndSubPartyAndSubscriberAndServiceForGwId(nokiaIms/*, null*/, agcfGatewayRecord.GwId, out string readResult);
755:
756: r0 = "GwId: " + agcfGatewayRecord.GwId + ", deleteResult: " + deleteResult + ", readResult: " + readResult;
757: }
758: else
759: {
760: r0 = "There are no AgcfGatewayRecords with no Nokia switch, non SIP OLT NDD ONTs and with null or empty AgcfEndpoint. ";
761: }
762: }
763: catch (Exception)
764: {
765: r0 = "Exception: " + r0;
766: }
767:
768: r0 = "Manage: " + r1 + " " + r0;
769: result.AddSuccess(r0);
770:
771: return result;
772: }
773:
774: ////////////////////////////////////////////////////////////////////////////
775:
776: /// <summary>
777: ///
778: /// </summary>
779: private void ManageNokiaUpdateAgcfGatewayRecord(Ia.Ngn.Cl.Model.Client.Nokia.Ims nokiaIms, out string result)
780: {
781: string r1;
782: int gwId;
783: Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Ont nddOnt;
784: Ia.Ngn.Cl.Model.Nokia.AgcfGatewayRecord agcfGatewayRecord;
785:
786: r1 = string.Empty;
787: result = string.Empty;
788:
789: agcfGatewayRecord = Ia.Ngn.Cl.Model.Data.Nokia.AgcfGatewayRecord.ListByMateExternalIPAddr("10.16.1.36").PickRandom();
790:
791: try
792: {
793: if (agcfGatewayRecord != null)
794: {
795: gwId = agcfGatewayRecord.GwId;
796: nddOnt = (from no in Ia.Ngn.Cl.Model.Data.NetworkDesignDocument.OntList where no.Ip == agcfGatewayRecord.IP1 select no).SingleOrDefault();
797:
798: if (nddOnt != null)
799: {
800: nokiaIms.EdNgfsAgcfGatewayRecordV2_MateExternalIPAddr(gwId, "10.16.5.36", nddOnt, out Ia.Ngn.Cl.Model.Business.Nokia.Ims.Response response);
801:
802: Ia.Ngn.Cl.Model.Data.Nokia.Ims.ReadUpdateAgcfGatewayRecordAndAgcfEndpointListAndSubPartyAndSubscriberAndServiceForGwId(nokiaIms, gwId, out result);
803:
804: result = nddOnt.Access.Name + ", gwId: " + gwId + ", ResultCode: " + response.ResultCode.ToString() + ", result: " + result.ToString();
805: }
806: else
807: {
808: result = "nddOnt null. ";
809: }
810: }
811: else
812: {
813: result = "agcfGatewayRecord is null. ";
814: }
815: }
816: catch (Exception)
817: {
818: result = "Exception: " + result;
819: }
820:
821: result = "Updated: " + r1 + " " + result;
822: }
823:
824: ////////////////////////////////////////////////////////////////////////////
825:
826: /// <summary>
827: ///
828: /// </summary>
829: private void DeleteAgcfGatewayRecordList(Ia.Ngn.Cl.Model.Client.Nokia.Ims nokiaIms, List<int> list, out string result)
830: {
831: string primarySwitch;
832: //Ia.Ngn.Cl.Model.Nokia.AgcfGatewayRecord agcfGatewayRecord;
833:
834: result = string.Empty;
835:
836: try
837: {
838: foreach (int gwId in list)
839: {
840: //agcfGatewayRecord = Ia.Ngn.Cl.Model.Nokia.AgcfGatewayRecord.ReadByGwId(0);
841:
842: //if (agcfGatewayRecord != null)
843: //{
844: primarySwitch = Ia.Ngn.Cl.Model.Business.Nokia.Ims.SKB;// Ia.Ngn.Cl.Model.Business.Nokia.Ims.PrimarySwitchFromAgcfGatewayRecord(agcfGatewayRecord.IsPrimary);
845:
846: nokiaIms.DltNgfsAgcfGwCombinedRecV2(gwId, primarySwitch, out Ia.Ngn.Cl.Model.Business.Nokia.Ims.Response response);
847:
848: Ia.Ngn.Cl.Model.Data.Nokia.Ims.ReadUpdateAgcfGatewayRecordAndAgcfEndpointListAndSubPartyAndSubscriberAndServiceForGwId(nokiaIms/*, null*/, gwId, out result);
849:
850: result = "GwId: " + gwId + ", dltResultCode: " + response.ResultCode.ToString() + ", result: " + result.ToString();
851: //}
852: //else
853: //{
854: // result = "agcfGatewayRecord is null. ";
855: //}
856: }
857: }
858: catch (Exception)
859: {
860: result = "Exception: " + result;
861: }
862:
863: result = "Delete AgcfGatewayRecord list: " + result;
864: }
865:
866: ////////////////////////////////////////////////////////////////////////////
867: ////////////////////////////////////////////////////////////////////////////
868:
869: /// <summary>
870: ///
871: /// </summary>
872: public static void ManageModifyNokiaSwitchSubscriberH248ToSip(Ia.Ngn.Cl.Model.Client.Nokia.Ims ims, out Ia.Cl.Model.Result result)
873: {
874: string r;
875: Ia.Ngn.Cl.Model.Business.Procedure.Process process;
876:
877: result = new Ia.Cl.Model.Result();
878:
879: process = procedureNokiaImsSubscriberToBeUpdatedFromH248ToSipList.NextProcess();
880:
881: if (process.Type != Ia.Ngn.Cl.Model.Business.Procedure.ProcessType.None)
882: {
883: if (process.Type == Ia.Ngn.Cl.Model.Business.Procedure.ProcessType.DeleteRead)
884: {
885: result.AddSuccess("delete-read H.248: " + process.Ont.Access.Name + " " + procedureNokiaImsSubscriberToBeUpdatedFromH248ToSipList.ProgressCounterString);
886:
887: Ia.Ngn.Cl.Model.Business.Provision.DeleteReadNokiaSwitchSubscriber(ims, process.Ont.Access.Name, process.Service, process.Protocol, false, out r);
888:
889: result.AddSuccess(r);
890: }
891: else if (process.Type == Ia.Ngn.Cl.Model.Business.Procedure.ProcessType.CreateRead)
892: {
893: result.AddSuccess("create-read SIP: " + process.Ont.Access.Name + " " + procedureNokiaImsSubscriberToBeUpdatedFromH248ToSipList.ProgressCounterString);
894:
895: Ia.Ngn.Cl.Model.Business.Provision.CreateReadNokiaSwitchSubscriber(ims, process.Ont.Access.Name, process.Service, Ia.Ngn.Cl.Model.Business.Default.PortUndefinedOrInvalidOrUnknown, process.Protocol, false, out r);
896:
897: result.AddSuccess(r);
898: }
899: else result.AddSuccess("delete-read, create-read: undefined procedure. ");
900: }
901: else result.AddSuccess("delete-read, create-read: nothing to update");
902: }
903:
904: ////////////////////////////////////////////////////////////////////////////
905: ////////////////////////////////////////////////////////////////////////////
906: }
907:
908: ////////////////////////////////////////////////////////////////////////////
909: ////////////////////////////////////////////////////////////////////////////
910: }