شركة التطبيقات المتكاملة لتصميم النظم البرمجية الخاصة

Integrated Applications Programming Company

Skip Navigation LinksHome » Code Library » Ims

Public general use code classes and xml files that we've compiled and used over the years:

Optical Fiber Network Management Intranet Portal (OFN) support class for Nokia's Next Generation Network (NGN) business model.

   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), Internet 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 Queue<int> allPossibleGwIdQueue = new Queue<int>();
  51:          private static Queue<int> allPossibleServiceNumbersWithinNetworkQueue = new Queue<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:          ///
 126:          /// </summary>
 127:          public Ims()
 128:          {
 129:          }
 130:   
 131:          ////////////////////////////////////////////////////////////////////////////
 132:   
 133:          /// <summary>
 134:          /// 
 135:          /// </summary>
 136:          public static List<string> NumberOfNokiaSubsribersPerFsdb()
 137:          {
 138:              string imsFsdb;
 139:              Dictionary<string, int> dic;
 140:              Dictionary<string, string> ontListNokiaIpToPrimarySwitchImsFsdbDictionary;
 141:              List<string> list;
 142:   
 143:              dic = new Dictionary<string, int>();
 144:   
 145:              ontListNokiaIpToPrimarySwitchImsFsdbDictionary = Ia.Ngn.Cl.Model.Data.NetworkDesignDocument.NokiaOntIpToPrimarySwitchImsFsdbDictionary;
 146:   
 147:              using (var db = new Ia.Ngn.Cl.Model.Ngn())
 148:              {
 149:                  list = (from e in db.AgcfEndpoints
 150:                          join gr in db.AgcfGatewayRecords on e.AgcfGatewayRecord.Id equals gr.Id
 151:                          select gr.IP1).ToList();
 152:              }
 153:   
 154:              foreach (string ip in list)
 155:              {
 156:                  if (ontListNokiaIpToPrimarySwitchImsFsdbDictionary.ContainsKey(ip))
 157:                  {
 158:                      imsFsdb = ontListNokiaIpToPrimarySwitchImsFsdbDictionary[ip];
 159:   
 160:                      if (dic.ContainsKey(imsFsdb)) dic[imsFsdb]++;
 161:                      else dic[imsFsdb] = 1;
 162:                  }
 163:              }
 164:   
 165:              list.Clear();
 166:   
 167:              foreach (KeyValuePair<string, int> kvp in dic)
 168:              {
 169:                  list.Add(kvp.Key + ": " + kvp.Value);
 170:              }
 171:   
 172:              return list;
 173:          }
 174:   
 175:          ////////////////////////////////////////////////////////////////////////////
 176:   
 177:          /// <summary>
 178:          ///
 179:          /// </summary>
 180:          public static int NextVacantFlatTermIdFromAgcfEndpointUsingGwId(Ia.Ngn.Cl.Model.Business.Nokia.Ont.FamilyType familyType, int gwId)
 181:          {
 182:              int ft;
 183:              List<int> list;
 184:   
 185:              list = Ia.Ngn.Cl.Model.Data.Nokia.AgcfEndpoint.UsedFlatTermIdListForGatewayId(gwId);
 186:   
 187:              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
 188:              else
 189:              {
 190:                  // change this later to accommodate the Huawei ONT type
 191:                  list = Ia.Cl.Model.Default.ExcludedNumberListFromNumberListWithinRange(list, Ia.Ngn.Cl.Model.Business.Nokia.Ams.PossibleNumberOfTdForOntFamilyType(familyType));
 192:   
 193:                  if (list.Count > 0) ft = list[0];
 194:                  else ft = 0; // something went wrong
 195:              }
 196:   
 197:              return ft;
 198:          }
 199:   
 200:          ////////////////////////////////////////////////////////////////////////////
 201:   
 202:          /// <summary>
 203:          /// Check the number of combined AGCF gateway records for this MGC IP and its secondary MGC IP if they exceed the MaximumCombinedNumberOfAgcfGatewayRecordsInAnyMgcIpAndMgcSecondaryIpPair 
 204:          /// </summary>
 205:          public static bool MaximumCombinedNumberOfAgcfGatewayRecordsInAnyMgcIpAndMgcSecondaryIpPairIsExceeded(string mgcIp)
 206:          {
 207:              bool isExceeded;
 208:              int count;
 209:              ImsBasicService imsBasicServiceItem;
 210:   
 211:              imsBasicServiceItem = ImsBasicServiceItem(mgcIp);
 212:   
 213:              if (imsBasicServiceItem != null)
 214:              {
 215:                  using (var db = new Ia.Ngn.Cl.Model.Ngn())
 216:                  {
 217:                      count = (from gr in db.AgcfGatewayRecords where gr.MateExternalIPAddr == imsBasicServiceItem.MgcIp || gr.MateExternalIPAddr == imsBasicServiceItem.MgcSecondaryIp select gr.Id).Count();
 218:   
 219:                      isExceeded = (count > MaximumCombinedNumberOfAgcfGatewayRecordsInAnyMgcIpAndMgcSecondaryIpPair);
 220:                  }
 221:              }
 222:              else throw new System.ArgumentException("imsBasicServiceItem cannot be null", "imsBasicServiceItem");
 223:   
 224:              return isExceeded;
 225:          }
 226:   
 227:          ////////////////////////////////////////////////////////////////////////////
 228:   
 229:          /// <summary>
 230:          /// Statistics dictionary of the current AGCF Gateway Record by MGC gateway IP
 231:          /// </summary>
 232:          public static Dictionary<string, int> NumberOfAgcfGatewayRecordInGroupOfMgcIpDictionary
 233:          {
 234:              get
 235:              {
 236:                  Dictionary<string, int> dictionary;
 237:   
 238:                  using (var db = new Ia.Ngn.Cl.Model.Ngn())
 239:                  {
 240:                      dictionary = (from gr in db.AgcfGatewayRecords
 241:                                    group gr.MateExternalIPAddr by gr.MateExternalIPAddr into g
 242:                                    select new { MateExternalIPAddr = g.Key, Count = g.Count() }).ToDictionary(t => t.MateExternalIPAddr, t => t.Count);
 243:                  }
 244:   
 245:                  return dictionary;
 246:              }
 247:          }
 248:   
 249:          ////////////////////////////////////////////////////////////////////////////
 250:   
 251:          /// <summary>
 252:          /// Statistics dictionary of the current AGCF gateway records with corresponding AGCF endpoints by MGC gateway IP
 253:          /// </summary>
 254:          public static Dictionary<string, int> NumberOfAgcfGatewayRecordWithCorrespondingAgcfEndpointInGroupOfMgcIpDictionary
 255:          {
 256:              get
 257:              {
 258:                  Dictionary<string, int> dictionary;
 259:   
 260:                  using (var db = new Ia.Ngn.Cl.Model.Ngn())
 261:                  {
 262:                      dictionary = (from gr in db.AgcfGatewayRecords
 263:                                    join ep in db.AgcfEndpoints on new { gr.Id } equals new { Id = ep.AgcfGatewayRecord.Id }
 264:                                    group gr.MateExternalIPAddr by gr.MateExternalIPAddr into g
 265:                                    select new { MateExternalIPAddr = g.Key, Count = g.Count() }).ToDictionary(t => t.MateExternalIPAddr, t => t.Count);
 266:                  }
 267:   
 268:                  return dictionary;
 269:              }
 270:          }
 271:   
 272:          ////////////////////////////////////////////////////////////////////////////
 273:   
 274:          /// <summary>
 275:          /// Calculate a pseudo random MGC IP from imsBasicServiceList for this ONT IP
 276:          /// </summary>
 277:          public static string PseudoRandomMgcIp(string ontIp)
 278:          {
 279:              uint ui, randomIndex;
 280:              string mgcIp;
 281:   
 282:              if (!string.IsNullOrEmpty(ontIp))
 283:              {
 284:                  ui = Ia.Cl.Model.Default.IpToUint(ontIp);
 285:   
 286:                  // important: any change to imsBasicServiceList length will cause the pseudo random function to produce different values for IPs
 287:                  randomIndex = ui % (uint)ImsBasicServiceList.Count();
 288:   
 289:                  mgcIp = ImsBasicServiceList[randomIndex].MgcIp;
 290:              }
 291:              else mgcIp = string.Empty;
 292:   
 293:              return mgcIp;
 294:          }
 295:   
 296:          ////////////////////////////////////////////////////////////////////////////
 297:   
 298:          /// <summary>
 299:          /// Return the IMS basic service for given MGC IP
 300:          /// </summary>
 301:          public static ImsBasicService ImsBasicServiceItem(string mgcIp)
 302:          {
 303:              ImsBasicService imsBasicService;
 304:   
 305:              imsBasicService = (from ibs in ImsBasicServiceList where ibs.MgcIp == mgcIp select ibs).SingleOrDefault();
 306:   
 307:              return imsBasicService;
 308:          }
 309:   
 310:          ////////////////////////////////////////////////////////////////////////////
 311:   
 312:          /// <summary>
 313:          ///
 314:          /// </summary>
 315:          public static string ImsFsdb(int imsService, string primarySwitch)
 316:          {
 317:              string fsdb;
 318:              ImsBasicService imsBasicService;
 319:   
 320:              if (imsService >= 0)
 321:              {
 322:                  imsBasicService = (from ibs in ImsBasicServiceList where ibs.Service == imsService && ibs.PrimarySwitch == primarySwitch select ibs).SingleOrDefault();
 323:   
 324:                  fsdb = (imsBasicService != null) ? imsBasicService.Fsdb : string.Empty;
 325:              }
 326:              else fsdb = string.Empty;
 327:   
 328:              return fsdb;
 329:          }
 330:   
 331:          ////////////////////////////////////////////////////////////////////////////
 332:   
 333:          /// <summary>
 334:          ///
 335:          /// </summary>
 336:          public static string AgcfSipIaPort(int imsService)
 337:          {
 338:              // see ImsServiceFromAgcfSipIaPort()
 339:              string agcfSipIaPort;
 340:   
 341:              switch (imsService)
 342:              {
 343:                  case 0: agcfSipIaPort = "agcf-stdn.imsgroup0-00" + imsService; break;
 344:                  case 1:
 345:                  case 2:
 346:                  case 3: agcfSipIaPort = "agcf-stdo.imsgroup0-00" + imsService; break;
 347:                  case 4:
 348:                  case 5:
 349:                  case 6: agcfSipIaPort = "agcf-stdp.imsgroup0-00" + imsService; break;
 350:                  case 7:
 351:                  case 8:
 352:                  case 9: agcfSipIaPort = "agcf-stdq.imsgroup0-00" + imsService; break;
 353:                  default: agcfSipIaPort = null; break;
 354:              }
 355:   
 356:              return agcfSipIaPort;
 357:          }
 358:   
 359:          ////////////////////////////////////////////////////////////////////////////
 360:   
 361:          /// <summary>
 362:          ///
 363:          /// </summary>
 364:          public static int ImsServiceFromAgcfSipIaPort(string agcfSipIaPort)
 365:          {
 366:              // see AgcfSipIaPort()
 367:              int imsService;
 368:   
 369:              switch (agcfSipIaPort)
 370:              {
 371:                  case "agcf-stdn.imsgroup0-000": imsService = 0; break;
 372:                  case "agcf-stdo.imsgroup0-001": imsService = 1; break;
 373:                  case "agcf-stdo.imsgroup0-002": imsService = 2; break;
 374:                  case "agcf-stdo.imsgroup0-003": imsService = 3; break;
 375:                  case "agcf-stdp.imsgroup0-004": imsService = 4; break;
 376:                  case "agcf-stdp.imsgroup0-005": imsService = 5; break;
 377:                  case "agcf-stdp.imsgroup0-006": imsService = 6; break;
 378:                  case "agcf-stdq.imsgroup0-007": imsService = 7; break;
 379:                  case "agcf-stdq.imsgroup0-008": imsService = 8; break;
 380:                  case "agcf-stdq.imsgroup0-009": imsService = 9; break;
 381:                  default: imsService = -1; break;
 382:              }
 383:   
 384:              return imsService;
 385:          }
 386:   
 387:          ////////////////////////////////////////////////////////////////////////////
 388:   
 389:          /// <summary>
 390:          ///
 391:          /// </summary>
 392:          public static string AlternateFsdbFqdn(string primarySwitch, string fsdb)
 393:          {
 394:              string alternateFsdbFqdn;
 395:   
 396:              if (primarySwitch == TEC)
 397:              {
 398:                  switch (fsdb)
 399:                  {
 400:                      case "fsdb0": alternateFsdbFqdn = "10.16.0.88"; break;
 401:                      case "fsdb1": alternateFsdbFqdn = "10.16.0.89"; break;
 402:                      case "fsdb2": alternateFsdbFqdn = "10.16.0.90"; break;
 403:                      case "fsdb3": alternateFsdbFqdn = "10.16.0.91"; break;
 404:                      default: alternateFsdbFqdn = string.Empty; break;
 405:                  }
 406:              }
 407:              else if (primarySwitch == SKB)
 408:              {
 409:                  switch (fsdb)
 410:                  {
 411:                      case "fsdb0": alternateFsdbFqdn = "10.16.0.9"; break;
 412:                      case "fsdb1": alternateFsdbFqdn = "10.16.0.10"; break;
 413:                      case "fsdb2": alternateFsdbFqdn = "10.16.0.11"; break;
 414:                      case "fsdb3": alternateFsdbFqdn = "10.16.0.12"; break;
 415:                      default: alternateFsdbFqdn = string.Empty; break;
 416:                  }
 417:              }
 418:              else throw new Exception("Unknown primarySwitch") { };
 419:   
 420:              return alternateFsdbFqdn;
 421:          }
 422:   
 423:          ////////////////////////////////////////////////////////////////////////////
 424:   
 425:          /// <summary>
 426:          ///
 427:          /// </summary>
 428:          public static void AssocAndAlternateOtasRealm(string primarySwitch, string fsdb, out int applicationServerId, out string assocOtasRealm, out string alternateOtasRealm)
 429:          {
 430:              bool randomState;
 431:   
 432:              randomState = Ia.Cl.Model.Default.RandomBool;
 433:   
 434:              switch (fsdb)
 435:              {
 436:                  case "fsdb0": applicationServerId = 0; break;
 437:                  case "fsdb1": applicationServerId = randomState ? 1 : 2; break;
 438:                  case "fsdb2": applicationServerId = randomState ? 3 : 4; break;
 439:                  case "fsdb3": applicationServerId = randomState ? 5 : 6; break;
 440:                  default: throw new Exception("Unknown fsdb") { };
 441:              }
 442:   
 443:              if (primarySwitch == TEC)
 444:              {
 445:                  assocOtasRealm = "stas-stdn.fsimsgroup0-00" + applicationServerId + @".tecics01.ims.moc1.kw";
 446:              }
 447:              else if (primarySwitch == SKB)
 448:              {
 449:                  assocOtasRealm = "stas-stdn.fsimsgroup0-00" + applicationServerId + @".skbics01.ims.moc1.kw";
 450:              }
 451:              else throw new Exception("Unknown primarySwitch") { };
 452:   
 453:              //
 454:              if (assocOtasRealm.Contains("skbics01"))
 455:              {
 456:                  alternateOtasRealm = assocOtasRealm.Replace("skbics01", "tecics01");
 457:              }
 458:              else if (assocOtasRealm.Contains("tecics01"))
 459:              {
 460:                  alternateOtasRealm = assocOtasRealm.Replace("tecics01", "skbics01");
 461:              }
 462:              else throw new Exception("Unknown primarySwitch") { };
 463:          }
 464:   
 465:          ////////////////////////////////////////////////////////////////////////////
 466:   
 467:          /// <summary>
 468:          ///
 469:          /// </summary>
 470:          public static string AssigneCorrectMateExternalIPAddrForIsPrimary(bool isPrimary, string mateExternalIPAddr)
 471:          {
 472:              string mate;
 473:   
 474:              if (isPrimary)
 475:              {
 476:                  mate = mateExternalIPAddr;
 477:              }
 478:              else
 479:              {
 480:                  switch (mateExternalIPAddr)
 481:                  {
 482:                      case "10.16.1.31": mate = "10.16.5.31"; break;
 483:                      case "10.16.1.32": mate = "10.16.5.32"; break;
 484:                      case "10.16.1.33": mate = "10.16.5.33"; break;
 485:                      case "10.16.1.34": mate = "10.16.5.34"; break;
 486:                      case "10.16.1.35": mate = "10.16.5.35"; break;
 487:                      case "10.16.1.36": mate = "10.16.5.36"; break;
 488:                      case "10.16.1.37": mate = "10.16.5.37"; break;
 489:                      case "10.16.1.38": mate = "10.16.5.38"; break;
 490:                      case "10.16.1.39": mate = "10.16.5.39"; break;
 491:                      case "10.16.1.40": mate = "10.16.5.40"; break;
 492:   
 493:                      case "10.16.5.31": mate = "10.16.1.31"; break;
 494:                      case "10.16.5.32": mate = "10.16.1.32"; break;
 495:                      case "10.16.5.33": mate = "10.16.1.33"; break;
 496:                      case "10.16.5.34": mate = "10.16.1.34"; break;
 497:                      case "10.16.5.35": mate = "10.16.1.35"; break;
 498:                      case "10.16.5.36": mate = "10.16.1.36"; break;
 499:                      case "10.16.5.37": mate = "10.16.1.37"; break;
 500:                      case "10.16.5.38": mate = "10.16.1.38"; break;
 501:                      case "10.16.5.39": mate = "10.16.1.39"; break;
 502:                      case "10.16.5.40": mate = "10.16.1.40"; break;
 503:   
 504:                      default: mate = null; break;
 505:                  }
 506:              }
 507:   
 508:              return mate;
 509:          }
 510:   
 511:          ////////////////////////////////////////////////////////////////////////////
 512:   
 513:          /// <summary>
 514:          ///
 515:          /// </summary>
 516:          public static string PrimarySwitchFromAgcfGatewayRecord(bool isPrimary)
 517:          {
 518:              string primarySwitch;
 519:   
 520:              if (isPrimary) primarySwitch = Ia.Ngn.Cl.Model.Business.Nokia.Ims.AnyPrimarySwitch;
 521:              else primarySwitch = Ia.Ngn.Cl.Model.Business.Nokia.Ims.SKB;
 522:   
 523:              return primarySwitch;
 524:          }
 525:   
 526:          ////////////////////////////////////////////////////////////////////////////
 527:   
 528:          /// <summary>
 529:          ///
 530:          /// </summary>
 531:          public static string SecondarySwitchFromAgcfGatewayRecord(bool isPrimary)
 532:          {
 533:              string secondarySwitch;
 534:   
 535:              if (!isPrimary) secondarySwitch = Ia.Ngn.Cl.Model.Business.Nokia.Ims.AnyPrimarySwitch;
 536:              else secondarySwitch = Ia.Ngn.Cl.Model.Business.Nokia.Ims.SKB;
 537:   
 538:              return secondarySwitch;
 539:          }
 540:   
 541:          ////////////////////////////////////////////////////////////////////////////
 542:   
 543:          /// <summary>
 544:          ///
 545:          /// </summary>
 546:          public static int ServiceProfileNumber(int applicationServerId)
 547:          {
 548:              int serviceProfileNumber;
 549:   
 550:              switch (applicationServerId)
 551:              {
 552:                  case 0: serviceProfileNumber = 2; break;
 553:                  case 1: serviceProfileNumber = 10; break;
 554:                  case 2: serviceProfileNumber = 18; break;
 555:                  case 3: serviceProfileNumber = 26; break;
 556:                  case 4: serviceProfileNumber = 34; break;
 557:                  case 5: serviceProfileNumber = 42; break;
 558:                  case 6: serviceProfileNumber = 50; break;
 559:                  default: throw new Exception("Unknown primarySwitch") { };
 560:              }
 561:   
 562:              return serviceProfileNumber;
 563:          }
 564:   
 565:          ////////////////////////////////////////////////////////////////////////////
 566:   
 567:          /// <summary>
 568:          ///
 569:          /// </summary>
 570:          public static int ServiceProfileNumberAgcfGatewayRecord(int imsService)
 571:          {
 572:              bool randomState;
 573:              int serviceProfileNumber;
 574:   
 575:              randomState = Ia.Cl.Model.Default.RandomBool;
 576:   
 577:              switch (imsService)
 578:              {
 579:                  case 0: serviceProfileNumber = 2; break;
 580:                  case 1:
 581:                  case 2:
 582:                  case 3: serviceProfileNumber = randomState ? 10 : 18; break;
 583:                  case 4:
 584:                  case 5:
 585:                  case 6: serviceProfileNumber = randomState ? 26 : 34; break;
 586:                  case 7:
 587:                  case 8:
 588:                  case 9: serviceProfileNumber = randomState ? 42 : 50; break;
 589:                  default: throw new Exception("Unknown primarySwitch") { };
 590:              }
 591:   
 592:              return serviceProfileNumber;
 593:          }
 594:   
 595:          ////////////////////////////////////////////////////////////////////////////
 596:   
 597:          /// <summary>
 598:          ///
 599:          /// </summary>
 600:          public static int SequentialGwIdToReadAgcfGatewayRecordData
 601:          {
 602:              get
 603:              {
 604:                  int number;
 605:   
 606:                  if (allPossibleGwIdQueue.Count == 0) allPossibleGwIdQueue = new Queue<int>(Ia.Ngn.Cl.Model.Data.Nokia.Ims.AllPossibleGatewayIdList);
 607:   
 608:                  number = allPossibleGwIdQueue.Dequeue();
 609:   
 610:                  return number;
 611:              }
 612:          }
 613:   
 614:          ////////////////////////////////////////////////////////////////////////////
 615:   
 616:          /// <summary>
 617:          ///
 618:          /// </summary>
 619:          public static string SequentialServiceToReadServiceData
 620:          {
 621:              get
 622:              {
 623:                  int service;
 624:   
 625:                  if (allPossibleServiceNumbersWithinNetworkQueue.Count == 0) allPossibleServiceNumbersWithinNetworkQueue = new Queue<int>(Ia.Ngn.Cl.Model.Data.Service.AllPossibleServiceNumberListWithinNokiaSwitch);
 626:   
 627:                  service = allPossibleServiceNumbersWithinNetworkQueue.Dequeue();
 628:   
 629:                  return service.ToString();
 630:              }
 631:          }
 632:   
 633:          ////////////////////////////////////////////////////////////////////////////
 634:   
 635:          /// <summary>
 636:          ///
 637:          /// </summary>
 638:          public static string SequentialPrividUserFromAgcfEndpointToReadSubPartyAndSubscriberData
 639:          {
 640:              get
 641:              {
 642:                  string prividUser;
 643:   
 644:                  if (agcfEndpointPrividUserQueue.Count == 0)
 645:                  {
 646:                      agcfEndpointPrividUserQueue = new Queue<string>(Ia.Ngn.Cl.Model.Data.Nokia.AgcfEndpoint.ReadPrividUserList);
 647:                  }
 648:   
 649:                  prividUser = agcfEndpointPrividUserQueue.Dequeue();
 650:   
 651:                  return prividUser;
 652:              }
 653:          }
 654:   
 655:          ////////////////////////////////////////////////////////////////////////////
 656:          ////////////////////////////////////////////////////////////////////////////
 657:   
 658:          /// <summary>
 659:          ///
 660:          /// </summary>
 661:          public static void CreateMissingAgcfGatewayRecordForNokiaSwitchOntInNonSipOlt(Ia.Ngn.Cl.Model.Client.Nokia.Ims nokiaIms, out Ia.Cl.Model.Result result)
 662:          {
 663:              int gwId;
 664:              string r1;
 665:              Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Ont nddOnt;
 666:   
 667:              r1 = "";
 668:   
 669:              result = new Ia.Cl.Model.Result();
 670:   
 671:              nddOnt = Ia.Ngn.Cl.Model.Data.Provision.NddNokiaSwitchOntInNonSipOltWithAccessButNoAgcfGatewayRecord(out string r0);
 672:   
 673:              if (nddOnt != null)
 674:              {
 675:                  gwId = Ia.Ngn.Cl.Model.Business.Nokia.AgcfGatewayRecord.RandomUnusedGwId();
 676:   
 677:                  Ia.Ngn.Cl.Model.Data.Nokia.Ims.CreateAgcfGatewayRecordForGwId(nokiaIms, gwId, nddOnt, out string createResult);
 678:   
 679:                  Ia.Ngn.Cl.Model.Data.Nokia.Ims.ReadUpdateAgcfGatewayRecordAndAgcfEndpointListAndSubPartyAndSubscriberAndServiceForGwId(nokiaIms, gwId, out string readResult);
 680:   
 681:                  r1 = r0 + " " + nddOnt.Access.Name + ", gwId: " + gwId + ", createResult: " + createResult + ", readResult: " + readResult;
 682:              }
 683:              else
 684:              {
 685:                  r1 = "There are no Nokia switch non SIP OLT NDD ONTs with access and without an AgcfGatewayRecord. ";
 686:              }
 687:   
 688:              r1 = "Manage: " + r1;
 689:   
 690:              result.AddSuccess(r1);
 691:          }
 692:   
 693:          ////////////////////////////////////////////////////////////////////////////
 694:   
 695:          /// <summary>
 696:          ///
 697:          /// </summary>
 698:          public static void DeleteAgcfGatewayRecordWithNoNddNokiaSwitchOntInNonSipOltAndNullOrEmptyAgcfEndpoint(Ia.Ngn.Cl.Model.Client.Nokia.Ims nokiaIms, out Ia.Cl.Model.Result result)
 699:          {
 700:              string r0;
 701:              Ia.Ngn.Cl.Model.Nokia.AgcfGatewayRecord agcfGatewayRecord;
 702:   
 703:              r0 = "";
 704:              result = new Ia.Cl.Model.Result();
 705:   
 706:              agcfGatewayRecord = Ia.Ngn.Cl.Model.Data.Provision.AgcfGatewayRecordWithNoNddNokiaSwitchOntInNonSipOltAndNullOrEmptyAgcfEndpoint(out string r1);
 707:   
 708:              try
 709:              {
 710:                  if (agcfGatewayRecord != null)
 711:                  {
 712:                      Ia.Ngn.Cl.Model.Data.Nokia.Ims.DeleteAgcfGatewayRecordForGwId(nokiaIms, agcfGatewayRecord, out string deleteResult);
 713:   
 714:                      Ia.Ngn.Cl.Model.Data.Nokia.Ims.ReadUpdateAgcfGatewayRecordAndAgcfEndpointListAndSubPartyAndSubscriberAndServiceForGwId(nokiaIms, agcfGatewayRecord.GwId, out string readResult);
 715:   
 716:                      r0 = "GwId: " + agcfGatewayRecord.GwId + ", deleteResult: " + deleteResult + ", readResult: " + readResult;
 717:                  }
 718:                  else
 719:                  {
 720:                      r0 = "There are no AgcfGatewayRecords with no Nokia switch, non SIP OLT NDD ONTs and with null or empty AgcfEndpoint. ";
 721:                  }
 722:              }
 723:              catch (Exception)
 724:              {
 725:                  r0 = "Exception: " + r0;
 726:              }
 727:   
 728:              r0 = "Manage: " + r1 + " " + r0;
 729:              result.AddSuccess(r0);
 730:          }
 731:   
 732:          ////////////////////////////////////////////////////////////////////////////
 733:   
 734:          /// <summary>
 735:          ///
 736:          /// </summary>
 737:          private void ManageNokiaUpdateAgcfGatewayRecord(Ia.Ngn.Cl.Model.Client.Nokia.Ims nokiaIms, out string result)
 738:          {
 739:              string r1;
 740:              int gwId;
 741:              Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Ont nddOnt;
 742:              Ia.Ngn.Cl.Model.Nokia.AgcfGatewayRecord agcfGatewayRecord;
 743:   
 744:              r1 = "";
 745:              result = string.Empty;
 746:   
 747:              agcfGatewayRecord = Ia.Ngn.Cl.Model.Data.Nokia.AgcfGatewayRecord.ListByMateExternalIPAddr("10.16.1.36").PickRandom();
 748:   
 749:              try
 750:              {
 751:                  if (agcfGatewayRecord != null)
 752:                  {
 753:                      gwId = agcfGatewayRecord.GwId;
 754:                      nddOnt = (from no in Ia.Ngn.Cl.Model.Data.NetworkDesignDocument.OntList where no.Ip == agcfGatewayRecord.IP1 select no).SingleOrDefault();
 755:   
 756:                      if (nddOnt != null)
 757:                      {
 758:                          nokiaIms.EdNgfsAgcfGatewayRecordV2_MateExternalIPAddr(gwId, "10.16.5.36", nddOnt, out Cl.Model.Client.Nokia.Ims.ResultCode edResultCode);
 759:   
 760:                          Ia.Ngn.Cl.Model.Data.Nokia.Ims.ReadUpdateAgcfGatewayRecordAndAgcfEndpointListAndSubPartyAndSubscriberAndServiceForGwId(nokiaIms, gwId, out result);
 761:   
 762:                          result = nddOnt.Access.Name + ", gwId: " + gwId + ", edResultCode: " + edResultCode.ToString() + ", result: " + result.ToString();
 763:                      }
 764:                      else
 765:                      {
 766:                          result = "nddOnt null. ";
 767:                      }
 768:                  }
 769:                  else
 770:                  {
 771:                      result = "agcfGatewayRecord is null. ";
 772:                  }
 773:              }
 774:              catch (Exception)
 775:              {
 776:                  result = "Exception: " + result;
 777:              }
 778:   
 779:              result = "Updated: " + r1 + " " + result;
 780:          }
 781:   
 782:          ////////////////////////////////////////////////////////////////////////////
 783:   
 784:          /// <summary>
 785:          ///
 786:          /// </summary>
 787:          private void DeleteAgcfGatewayRecordList(Ia.Ngn.Cl.Model.Client.Nokia.Ims nokiaIms, List<int> list, out string result)
 788:          {
 789:              string primarySwitch;
 790:              //Ia.Ngn.Cl.Model.Nokia.AgcfGatewayRecord agcfGatewayRecord;
 791:   
 792:              result = string.Empty;
 793:   
 794:              try
 795:              {
 796:                  foreach (int gwId in list)
 797:                  {
 798:                      //agcfGatewayRecord = Ia.Ngn.Cl.Model.Nokia.AgcfGatewayRecord.ReadByGwId(0);
 799:   
 800:                      //if (agcfGatewayRecord != null)
 801:                      //{
 802:                      primarySwitch = Ia.Ngn.Cl.Model.Business.Nokia.Ims.SKB;// Ia.Ngn.Cl.Model.Business.Nokia.Ims.PrimarySwitchFromAgcfGatewayRecord(agcfGatewayRecord.IsPrimary);
 803:   
 804:                      nokiaIms.DltNgfsAgcfGwCombinedRecV2(gwId, primarySwitch, out Cl.Model.Client.Nokia.Ims.ResultCode dltResultCode);
 805:   
 806:                      Ia.Ngn.Cl.Model.Data.Nokia.Ims.ReadUpdateAgcfGatewayRecordAndAgcfEndpointListAndSubPartyAndSubscriberAndServiceForGwId(nokiaIms, gwId, out result);
 807:   
 808:                      result = "GwId: " + gwId + ", dltResultCode: " + dltResultCode.ToString() + ", result: " + result.ToString();
 809:                      //}
 810:                      //else
 811:                      //{
 812:                      //    result = "agcfGatewayRecord is null. ";
 813:                      //}
 814:                  }
 815:              }
 816:              catch (Exception)
 817:              {
 818:                  result = "Exception: " + result;
 819:              }
 820:   
 821:              result = "Delete AgcfGatewayRecord list: " + result;
 822:          }
 823:   
 824:          ////////////////////////////////////////////////////////////////////////////
 825:          ////////////////////////////////////////////////////////////////////////////
 826:   
 827:          /// <summary>
 828:          ///
 829:          /// </summary>
 830:          public static void ManageModifyNokiaSwitchSubscriberH248ToSip(Ia.Ngn.Cl.Model.Client.Nokia.Ims ims, out Ia.Cl.Model.Result result)
 831:          {
 832:              string r;
 833:              Ia.Ngn.Cl.Model.Business.Procedure.Process process;
 834:   
 835:              result = new Ia.Cl.Model.Result();
 836:   
 837:              process = procedureNokiaImsSubscriberToBeUpdatedFromH248ToSipList.NextProcess();
 838:   
 839:              if (process.Type != Ia.Ngn.Cl.Model.Business.Procedure.ProcessType.None)
 840:              {
 841:                  if (process.Type == Ia.Ngn.Cl.Model.Business.Procedure.ProcessType.Update)
 842:                  {
 843:                      result.AddSuccess("update: " + process.Ont.Access.Name + " " + procedureNokiaImsSubscriberToBeUpdatedFromH248ToSipList.ProgressCounterString);
 844:   
 845:                      Ia.Ngn.Cl.Model.Business.Provision.ModifyNokiaSwitchSubscriberH248ToSip(ims, process.Service, process.Ont, out r);
 846:   
 847:                      result.AddSuccess(r);
 848:                  }
 849:                  else if (process.Type == Ia.Ngn.Cl.Model.Business.Procedure.ProcessType.Read)
 850:                  {
 851:                      result.AddSuccess("read: " + process.Ont.Access.Name + " " + procedureNokiaImsSubscriberToBeUpdatedFromH248ToSipList.ProgressCounterString);
 852:   
 853:                      Ia.Ngn.Cl.Model.Data.Nokia.Ims.ReadUpdateSubPartyAndSubscriberAndService(ims, process.Service, process.Ont, out r);
 854:   
 855:                      result.AddSuccess(r);
 856:                  }
 857:                  else result.AddSuccess("update: undefined procedure. ");
 858:              }
 859:              else result.AddSuccess("update: nothing to update");
 860:          }
 861:   
 862:          ////////////////////////////////////////////////////////////////////////////
 863:          ////////////////////////////////////////////////////////////////////////////
 864:      }
 865:   
 866:      ////////////////////////////////////////////////////////////////////////////
 867:      ////////////////////////////////////////////////////////////////////////////
 868:  }