Professional Applications Programmers/Consultants برمجة واستشارات تطبيقات الإنترنت
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.Web;
   3:  using System.Xml;
   4:  using System.Xml.Linq;
   5:  using System.IO;
   6:  using System.Configuration;
   7:  using System.Text;
   8:  using System.Text.RegularExpressions;
   9:  using System.Data;
  10:  using System.Data.SqlClient;
  11:  using System.Web.UI;
  12:  using System.Web.UI.WebControls;
  13:  using System.Collections;
  14:  using System.Collections.Generic;
  15:  using System.Reflection;
  16:  using System.Linq;
  17:   
  18:  namespace Ia.Ngn.Cl.Model.Business.Nokia
  19:  {
  20:      ////////////////////////////////////////////////////////////////////////////
  21:   
  22:      /// <summary publish="true">
  23:      /// Optical Fiber Network Management Intranet Portal (OFN) support class for Nokia's Next Generation Network (NGN) business model.
  24:      /// </summary>
  25:      /// 
  26:      /// <value>
  27:      ///   <appSettings>
  28:      ///     <add key="imsServerHost" value="https://*" />
  29:      ///     <add key="imsServerPort" value="*" />
  30:      ///     <add key="imsServerServiceUrl" value="*" />
  31:      ///     <add key="imsServerUser" value="*" />
  32:      ///     <add key="imsServerUserPassword" value="*" />
  33:      ///   </appSettings>
  34:      /// </value>
  35:      /// 
  36:      /// <remarks> 
  37:      /// Copyright © 2014-2018 Jasem Y. Al-Shamlan (info@ia.com.kw), Internet Applications - Kuwait. All Rights Reserved.
  38:      ///
  39:      /// 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
  40:      /// the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
  41:      ///
  42:      /// This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
  43:      /// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
  44:      /// 
  45:      /// You should have received a copy of the GNU General Public License along with this library. If not, see http://www.gnu.org/licenses.
  46:      /// 
  47:      /// Copyright notice: This notice may not be removed or altered from any source distribution.
  48:      /// </remarks> 
  49:      public class Ims
  50:      {
  51:          // below: this is the almost official GwId range used
  52:   
  53:          private const int gwIdFirst = 2048;
  54:          private const int gwIdLast = 65535;
  55:   
  56:          private const int primaryPUIDCPEProfileNumberForSip = 10;
  57:          private const int primaryPUIDCPEProfileNumberForH248 = 35;
  58:   
  59:          private const string sipSubscriberRegistrationPassword = "1234"; // as per Nokia spec
  60:   
  61:          private static Queue<int> allPossibleGwIdQueue = new Queue<int>();
  62:          private static Queue<int> allPossibleServiceNumbersWithinNetworkQueue = new Queue<int>();
  63:          private static Queue<string> agcfEndpointPrividUserQueue = new Queue<string>();
  64:   
  65:          public class ImsBasicService
  66:          {
  67:              public string MgcIp;
  68:              public string MgcSecondaryIp;
  69:              public string MgcSubnetMask;
  70:              public int Service;
  71:              public string Fsdb;
  72:              public string PrimarySwitch;
  73:          }
  74:   
  75:          public static ImsBasicService[] ImsBasicServiceList =
  76:              {
  77:              new ImsBasicService { MgcIp="10.16.1.31", MgcSecondaryIp="10.16.5.31", MgcSubnetMask="255.255.224.0",Service=0,Fsdb="fsdb0",PrimarySwitch=TEC },
  78:              new ImsBasicService { MgcIp="10.16.1.32", MgcSecondaryIp="10.16.5.32", MgcSubnetMask="255.255.224.0",Service=1,Fsdb="fsdb1",PrimarySwitch=TEC },
  79:              new ImsBasicService { MgcIp="10.16.1.33", MgcSecondaryIp="10.16.5.33", MgcSubnetMask="255.255.224.0",Service=2,Fsdb="fsdb1",PrimarySwitch=TEC },
  80:              new ImsBasicService { MgcIp="10.16.1.34", MgcSecondaryIp="10.16.5.34", MgcSubnetMask="255.255.224.0",Service=3,Fsdb="fsdb1",PrimarySwitch=TEC },
  81:              new ImsBasicService { MgcIp="10.16.1.35", MgcSecondaryIp="10.16.5.35", MgcSubnetMask="255.255.224.0",Service=4,Fsdb="fsdb2",PrimarySwitch=TEC },
  82:              new ImsBasicService { MgcIp="10.16.1.36", MgcSecondaryIp="10.16.5.36", MgcSubnetMask="255.255.224.0",Service=5,Fsdb="fsdb2",PrimarySwitch=TEC },
  83:              new ImsBasicService { MgcIp="10.16.1.37", MgcSecondaryIp="10.16.5.37", MgcSubnetMask="255.255.224.0",Service=6,Fsdb="fsdb2",PrimarySwitch=TEC },
  84:              new ImsBasicService { MgcIp="10.16.1.38", MgcSecondaryIp="10.16.5.38", MgcSubnetMask="255.255.224.0",Service=7,Fsdb="fsdb3",PrimarySwitch=TEC },
  85:              new ImsBasicService { MgcIp="10.16.1.39", MgcSecondaryIp="10.16.5.39", MgcSubnetMask="255.255.224.0",Service=8,Fsdb="fsdb3",PrimarySwitch=TEC },
  86:              new ImsBasicService { MgcIp="10.16.1.40", MgcSecondaryIp="10.16.5.40", MgcSubnetMask="255.255.224.0",Service=9,Fsdb="fsdb3",PrimarySwitch=TEC },
  87:   
  88:              new ImsBasicService { MgcIp="10.16.5.31", MgcSecondaryIp="10.16.1.31", MgcSubnetMask="255.255.224.0",Service=0,Fsdb="fsdb0",PrimarySwitch=SKB },
  89:              new ImsBasicService { MgcIp="10.16.5.32", MgcSecondaryIp="10.16.1.32", MgcSubnetMask="255.255.224.0",Service=1,Fsdb="fsdb1",PrimarySwitch=SKB },
  90:              new ImsBasicService { MgcIp="10.16.5.33", MgcSecondaryIp="10.16.1.33", MgcSubnetMask="255.255.224.0",Service=2,Fsdb="fsdb1",PrimarySwitch=SKB },
  91:              new ImsBasicService { MgcIp="10.16.5.34", MgcSecondaryIp="10.16.1.34", MgcSubnetMask="255.255.224.0",Service=3,Fsdb="fsdb1",PrimarySwitch=SKB },
  92:              new ImsBasicService { MgcIp="10.16.5.35", MgcSecondaryIp="10.16.1.35", MgcSubnetMask="255.255.224.0",Service=4,Fsdb="fsdb2",PrimarySwitch=SKB },
  93:              new ImsBasicService { MgcIp="10.16.5.36", MgcSecondaryIp="10.16.1.36", MgcSubnetMask="255.255.224.0",Service=5,Fsdb="fsdb2",PrimarySwitch=SKB },
  94:              new ImsBasicService { MgcIp="10.16.5.37", MgcSecondaryIp="10.16.1.37", MgcSubnetMask="255.255.224.0",Service=6,Fsdb="fsdb2",PrimarySwitch=SKB },
  95:              new ImsBasicService { MgcIp="10.16.5.38", MgcSecondaryIp="10.16.1.38", MgcSubnetMask="255.255.224.0",Service=7,Fsdb="fsdb3",PrimarySwitch=SKB },
  96:              new ImsBasicService { MgcIp="10.16.5.39", MgcSecondaryIp="10.16.1.39", MgcSubnetMask="255.255.224.0",Service=8,Fsdb="fsdb3",PrimarySwitch=SKB },
  97:              new ImsBasicService { MgcIp="10.16.5.40", MgcSecondaryIp="10.16.1.40", MgcSubnetMask="255.255.224.0",Service=9,Fsdb="fsdb3",PrimarySwitch=SKB },
  98:          };
  99:   
 100:          /// <summary/>
 101:          public static int FirstGatewayId { get { return gwIdFirst; } }
 102:          /// <summary/>
 103:          public static int LastGatewayId { get { return gwIdLast; } }
 104:   
 105:          /// <summary/>
 106:          public static string BaseAddress { get { return ConfigurationManager.AppSettings["imsServerHost"].ToString() + ":" + ConfigurationManager.AppSettings["imsServerPort"].ToString(); } }
 107:          /// <summary/>
 108:          public static string ServiceUrl { get { return ConfigurationManager.AppSettings["imsServerServiceUrl"].ToString(); } }
 109:          /// <summary/>
 110:          public static string UserName { get { return ConfigurationManager.AppSettings["imsServerUser"].ToString(); } }
 111:          /// <summary/>
 112:          public static string Password { get { return ConfigurationManager.AppSettings["imsServerUserPassword"].ToString(); } }
 113:   
 114:          public static string AnyPrimarySwitch { get { return TEC; } }
 115:   
 116:          public static string TEC { get { return "TECICS01"; } }
 117:   
 118:          public static string SKB { get { return "SKBICS02"; } }
 119:   
 120:   
 121:          public const int MaximumCombinedNumberOfAgcfGatewayRecordsInAnyMgcIpAndMgcSecondaryIpPair = 4800; // limit defind by Nokia
 122:   
 123:          public static int PrimaryPUIDCPEProfileNumberForSip { get { return primaryPUIDCPEProfileNumberForSip; } }
 124:   
 125:          public static int PrimaryPUIDCPEProfileNumberForH248 { get { return primaryPUIDCPEProfileNumberForH248; } }
 126:   
 127:          public static string SipSubscriberRegistrationPassword { get { return sipSubscriberRegistrationPassword; } }
 128:   
 129:          public static List<string> FsdbList = new List<string> { "fsdb0", "fsdb1", "fsdb2", "fsdb3" };
 130:   
 131:          ////////////////////////////////////////////////////////////////////////////
 132:   
 133:          /// <summary>
 134:          ///
 135:          /// </summary>
 136:          public Ims()
 137:          {
 138:          }
 139:   
 140:          ////////////////////////////////////////////////////////////////////////////
 141:   
 142:          /// <summary>
 143:          /// 
 144:          /// </summary>
 145:          public static List<string> NumberOfNokiaSubsribersPerFsdb()
 146:          {
 147:              string imsFsdb;
 148:              Dictionary<string, int> dic;
 149:              Dictionary<string, string> ontListNokiaIpToPrimarySwitchImsFsdbDictionary;
 150:              List<string> list;
 151:   
 152:              dic = new Dictionary<string, int>();
 153:   
 154:              ontListNokiaIpToPrimarySwitchImsFsdbDictionary = Ia.Ngn.Cl.Model.Data.NetworkDesignDocument.NokiaOntIpToPrimarySwitchImsFsdbDictionary;
 155:   
 156:              using (var db = new Ia.Ngn.Cl.Model.Ngn())
 157:              {
 158:                  list = (from e in db.AgcfEndpoints
 159:                          join gr in db.AgcfGatewayRecords on e.AgcfGatewayRecord.Id equals gr.Id
 160:                          select gr.IP1).ToList();
 161:              }
 162:   
 163:              foreach (string ip in list)
 164:              {
 165:                  if (ontListNokiaIpToPrimarySwitchImsFsdbDictionary.ContainsKey(ip))
 166:                  {
 167:                      imsFsdb = ontListNokiaIpToPrimarySwitchImsFsdbDictionary[ip];
 168:   
 169:                      if (dic.ContainsKey(imsFsdb)) dic[imsFsdb]++;
 170:                      else dic[imsFsdb] = 1;
 171:                  }
 172:              }
 173:   
 174:              list.Clear();
 175:   
 176:              foreach (KeyValuePair<string, int> kvp in dic)
 177:              {
 178:                  list.Add(kvp.Key + ": " + kvp.Value);
 179:              }
 180:   
 181:              return list;
 182:          }
 183:   
 184:          ////////////////////////////////////////////////////////////////////////////
 185:   
 186:          /// <summary>
 187:          ///
 188:          /// </summary>
 189:          public static int NextVacantFlatTermIdFromAgcfEndpointUsingGwId(Ia.Ngn.Cl.Model.Business.Nokia.Ont.FamilyType familyType, int gwId)
 190:          {
 191:              int ft;
 192:              List<int> list;
 193:   
 194:              list = Ia.Ngn.Cl.Model.Data.Nokia.AgcfEndpoint.UsedFlatTermIdListForGatewayId(gwId);
 195:   
 196:              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
 197:              else
 198:              {
 199:                  // change this later to accommodate the Huawei ONT type
 200:                  list = Ia.Cl.Model.Default.ExcludedNumberListFromNumberListWithinRange(list, Ia.Ngn.Cl.Model.Business.Nokia.Ams.PossibleNumberOfTdForOntFamilyType(familyType));
 201:   
 202:                  if (list.Count > 0) ft = list[0];
 203:                  else ft = 0; // something went wrong
 204:              }
 205:   
 206:              return ft;
 207:          }
 208:   
 209:          ////////////////////////////////////////////////////////////////////////////
 210:   
 211:          /// <summary>
 212:          /// Check the number of combined AGCF gateway records for this MGC IP and its secondary MGC IP if they exceed the MaximumCombinedNumberOfAgcfGatewayRecordsInAnyMgcIpAndMgcSecondaryIpPair 
 213:          /// </summary>
 214:          public static bool MaximumCombinedNumberOfAgcfGatewayRecordsInAnyMgcIpAndMgcSecondaryIpPairIsExceeded(string mgcIp)
 215:          {
 216:              bool isExceeded;
 217:              int count;
 218:              ImsBasicService imsBasicServiceItem;
 219:   
 220:              imsBasicServiceItem = ImsBasicServiceItem(mgcIp);
 221:   
 222:              if (imsBasicServiceItem != null)
 223:              {
 224:                  using (var db = new Ia.Ngn.Cl.Model.Ngn())
 225:                  {
 226:                      count = (from gr in db.AgcfGatewayRecords where gr.MateExternalIPAddr == imsBasicServiceItem.MgcIp || gr.MateExternalIPAddr == imsBasicServiceItem.MgcSecondaryIp select gr.Id).Count();
 227:   
 228:                      isExceeded = (count > MaximumCombinedNumberOfAgcfGatewayRecordsInAnyMgcIpAndMgcSecondaryIpPair);
 229:                  }
 230:              }
 231:              else throw new System.ArgumentException("imsBasicServiceItem cannot be null", "imsBasicServiceItem");
 232:   
 233:              return isExceeded;
 234:          }
 235:   
 236:          ////////////////////////////////////////////////////////////////////////////
 237:   
 238:          /// <summary>
 239:          /// Statistics dictionary of the current AGCF Gateway Record by MGC gateway IP
 240:          /// </summary>
 241:          public static Dictionary<string, int> NumberOfAgcfGatewayRecordInGroupOfMgcIpDictionary
 242:          {
 243:              get
 244:              {
 245:                  Dictionary<string, int> dictionary;
 246:   
 247:                  using (var db = new Ia.Ngn.Cl.Model.Ngn())
 248:                  {
 249:                      dictionary = (from gr in db.AgcfGatewayRecords
 250:                                    group gr.MateExternalIPAddr by gr.MateExternalIPAddr into g
 251:                                    select new { MateExternalIPAddr = g.Key, Count = g.Count() }).ToDictionary(t => t.MateExternalIPAddr, t => t.Count);
 252:                  }
 253:   
 254:                  return dictionary;
 255:              }
 256:          }
 257:   
 258:          ////////////////////////////////////////////////////////////////////////////
 259:   
 260:          /// <summary>
 261:          /// Statistics dictionary of the current AGCF gateway records with corresponding AGCF endpoints by MGC gateway IP
 262:          /// </summary>
 263:          public static Dictionary<string, int> NumberOfAgcfGatewayRecordWithCorrespondingAgcfEndpointInGroupOfMgcIpDictionary
 264:          {
 265:              get
 266:              {
 267:                  Dictionary<string, int> dictionary;
 268:   
 269:                  using (var db = new Ia.Ngn.Cl.Model.Ngn())
 270:                  {
 271:                      dictionary = (from gr in db.AgcfGatewayRecords
 272:                                    join ep in db.AgcfEndpoints on new { gr.Id } equals new { Id = ep.AgcfGatewayRecord.Id }
 273:                                    group gr.MateExternalIPAddr by gr.MateExternalIPAddr into g
 274:                                    select new { MateExternalIPAddr = g.Key, Count = g.Count() }).ToDictionary(t => t.MateExternalIPAddr, t => t.Count);
 275:                  }
 276:   
 277:                  return dictionary;
 278:              }
 279:          }
 280:   
 281:          ////////////////////////////////////////////////////////////////////////////
 282:   
 283:          /// <summary>
 284:          /// Calculate a pseudo random MGC IP from imsBasicServiceList for this ONT IP
 285:          /// </summary>
 286:          public static string PseudoRandomMgcIp(string ontIp)
 287:          {
 288:              uint ui, randomIndex;
 289:              string mgcIp;
 290:   
 291:              if (!string.IsNullOrEmpty(ontIp))
 292:              {
 293:                  ui = Ia.Cl.Model.Default.IpToUint(ontIp);
 294:   
 295:                  // important: any change to imsBasicServiceList length will cause the pseudo random function to produce different values for IPs
 296:                  randomIndex = ui % (uint)ImsBasicServiceList.Count();
 297:   
 298:                  mgcIp = ImsBasicServiceList[randomIndex].MgcIp;
 299:              }
 300:              else mgcIp = string.Empty;
 301:   
 302:              return mgcIp;
 303:          }
 304:   
 305:          ////////////////////////////////////////////////////////////////////////////
 306:   
 307:          /// <summary>
 308:          /// Return the IMS basic service for given MGC IP
 309:          /// </summary>
 310:          public static ImsBasicService ImsBasicServiceItem(string mgcIp)
 311:          {
 312:              ImsBasicService imsBasicService;
 313:   
 314:              imsBasicService = (from ibs in ImsBasicServiceList where ibs.MgcIp == mgcIp select ibs).SingleOrDefault();
 315:   
 316:              return imsBasicService;
 317:          }
 318:   
 319:          ////////////////////////////////////////////////////////////////////////////
 320:   
 321:          /// <summary>
 322:          ///
 323:          /// </summary>
 324:          public static string ImsFsdb(int imsService, string primarySwitch)
 325:          {
 326:              string fsdb;
 327:              ImsBasicService imsBasicService;
 328:   
 329:              if (imsService >= 0)
 330:              {
 331:                  imsBasicService = (from ibs in ImsBasicServiceList where ibs.Service == imsService && ibs.PrimarySwitch == primarySwitch select ibs).SingleOrDefault();
 332:   
 333:                  fsdb = (imsBasicService != null) ? imsBasicService.Fsdb : string.Empty;
 334:              }
 335:              else fsdb = string.Empty;
 336:   
 337:              return fsdb;
 338:          }
 339:   
 340:          ////////////////////////////////////////////////////////////////////////////
 341:   
 342:          /// <summary>
 343:          ///
 344:          /// </summary>
 345:          public static string AgcfSipIaPort(int imsService)
 346:          {
 347:              // see ImsServiceFromAgcfSipIaPort()
 348:              string agcfSipIaPort;
 349:   
 350:              switch (imsService)
 351:              {
 352:                  case 0: agcfSipIaPort = "agcf-stdn.imsgroup0-00" + imsService; break;
 353:                  case 1:
 354:                  case 2:
 355:                  case 3: agcfSipIaPort = "agcf-stdo.imsgroup0-00" + imsService; break;
 356:                  case 4:
 357:                  case 5:
 358:                  case 6: agcfSipIaPort = "agcf-stdp.imsgroup0-00" + imsService; break;
 359:                  case 7:
 360:                  case 8:
 361:                  case 9: agcfSipIaPort = "agcf-stdq.imsgroup0-00" + imsService; break;
 362:                  default: agcfSipIaPort = null; break;
 363:              }
 364:   
 365:              return agcfSipIaPort;
 366:          }
 367:   
 368:          ////////////////////////////////////////////////////////////////////////////
 369:   
 370:          /// <summary>
 371:          ///
 372:          /// </summary>
 373:          public static int ImsServiceFromAgcfSipIaPort(string agcfSipIaPort)
 374:          {
 375:              // see AgcfSipIaPort()
 376:              int imsService;
 377:   
 378:              switch (agcfSipIaPort)
 379:              {
 380:                  case "agcf-stdn.imsgroup0-000": imsService = 0; break;
 381:                  case "agcf-stdo.imsgroup0-001": imsService = 1; break;
 382:                  case "agcf-stdo.imsgroup0-002": imsService = 2; break;
 383:                  case "agcf-stdo.imsgroup0-003": imsService = 3; break;
 384:                  case "agcf-stdp.imsgroup0-004": imsService = 4; break;
 385:                  case "agcf-stdp.imsgroup0-005": imsService = 5; break;
 386:                  case "agcf-stdp.imsgroup0-006": imsService = 6; break;
 387:                  case "agcf-stdq.imsgroup0-007": imsService = 7; break;
 388:                  case "agcf-stdq.imsgroup0-008": imsService = 8; break;
 389:                  case "agcf-stdq.imsgroup0-009": imsService = 9; break;
 390:                  default: imsService = -1; break;
 391:              }
 392:   
 393:              return imsService;
 394:          }
 395:   
 396:          ////////////////////////////////////////////////////////////////////////////
 397:   
 398:          /// <summary>
 399:          ///
 400:          /// </summary>
 401:          public static string AlternateFsdbFqdn(string primarySwitch, string fsdb)
 402:          {
 403:              string alternateFsdbFqdn;
 404:   
 405:              if (primarySwitch == TEC)
 406:              {
 407:                  switch (fsdb)
 408:                  {
 409:                      case "fsdb0": alternateFsdbFqdn = "10.16.0.88"; break;
 410:                      case "fsdb1": alternateFsdbFqdn = "10.16.0.89"; break;
 411:                      case "fsdb2": alternateFsdbFqdn = "10.16.0.90"; break;
 412:                      case "fsdb3": alternateFsdbFqdn = "10.16.0.91"; break;
 413:                      default: alternateFsdbFqdn = string.Empty; break;
 414:                  }
 415:              }
 416:              else if (primarySwitch == SKB)
 417:              {
 418:                  switch (fsdb)
 419:                  {
 420:                      case "fsdb0": alternateFsdbFqdn = "10.16.0.9"; break;
 421:                      case "fsdb1": alternateFsdbFqdn = "10.16.0.10"; break;
 422:                      case "fsdb2": alternateFsdbFqdn = "10.16.0.11"; break;
 423:                      case "fsdb3": alternateFsdbFqdn = "10.16.0.12"; break;
 424:                      default: alternateFsdbFqdn = string.Empty; break;
 425:                  }
 426:              }
 427:              else throw new Exception("Unknown primarySwitch") { };
 428:   
 429:              return alternateFsdbFqdn;
 430:          }
 431:   
 432:          ////////////////////////////////////////////////////////////////////////////
 433:   
 434:          /// <summary>
 435:          ///
 436:          /// </summary>
 437:          public static void AssocAndAlternateOtasRealm(string primarySwitch, string fsdb, out int applicationServerId, out string assocOtasRealm, out string alternateOtasRealm)
 438:          {
 439:              bool randomState;
 440:   
 441:              randomState = Ia.Cl.Model.Default.RandomBool;
 442:   
 443:              switch (fsdb)
 444:              {
 445:                  case "fsdb0": applicationServerId = 0; break;
 446:                  case "fsdb1": applicationServerId = randomState ? 1 : 2; break;
 447:                  case "fsdb2": applicationServerId = randomState ? 3 : 4; break;
 448:                  case "fsdb3": applicationServerId = randomState ? 5 : 6; break;
 449:                  default: throw new Exception("Unknown fsdb") { };
 450:              }
 451:   
 452:              if (primarySwitch == TEC)
 453:              {
 454:                  assocOtasRealm = "stas-stdn.fsimsgroup0-00" + applicationServerId + @".tecics01.ims.moc1.kw";
 455:              }
 456:              else if (primarySwitch == SKB)
 457:              {
 458:                  assocOtasRealm = "stas-stdn.fsimsgroup0-00" + applicationServerId + @".skbics01.ims.moc1.kw";
 459:              }
 460:              else throw new Exception("Unknown primarySwitch") { };
 461:   
 462:              //
 463:              if (assocOtasRealm.Contains("skbics01"))
 464:              {
 465:                  alternateOtasRealm = assocOtasRealm.Replace("skbics01", "tecics01");
 466:              }
 467:              else if (assocOtasRealm.Contains("tecics01"))
 468:              {
 469:                  alternateOtasRealm = assocOtasRealm.Replace("tecics01", "skbics01");
 470:              }
 471:              else throw new Exception("Unknown primarySwitch") { };
 472:          }
 473:   
 474:          ////////////////////////////////////////////////////////////////////////////
 475:   
 476:          /// <summary>
 477:          ///
 478:          /// </summary>
 479:          public static string AssigneCorrectMateExternalIPAddrForIsPrimary(bool isPrimary, string mateExternalIPAddr)
 480:          {
 481:              string mate;
 482:   
 483:              if (isPrimary)
 484:              {
 485:                  mate = mateExternalIPAddr;
 486:              }
 487:              else
 488:              {
 489:                  switch (mateExternalIPAddr)
 490:                  {
 491:                      case "10.16.1.31": mate = "10.16.5.31"; break;
 492:                      case "10.16.1.32": mate = "10.16.5.32"; break;
 493:                      case "10.16.1.33": mate = "10.16.5.33"; break;
 494:                      case "10.16.1.34": mate = "10.16.5.34"; break;
 495:                      case "10.16.1.35": mate = "10.16.5.35"; break;
 496:                      case "10.16.1.36": mate = "10.16.5.36"; break;
 497:                      case "10.16.1.37": mate = "10.16.5.37"; break;
 498:                      case "10.16.1.38": mate = "10.16.5.38"; break;
 499:                      case "10.16.1.39": mate = "10.16.5.39"; break;
 500:                      case "10.16.1.40": mate = "10.16.5.40"; break;
 501:   
 502:                      case "10.16.5.31": mate = "10.16.1.31"; break;
 503:                      case "10.16.5.32": mate = "10.16.1.32"; break;
 504:                      case "10.16.5.33": mate = "10.16.1.33"; break;
 505:                      case "10.16.5.34": mate = "10.16.1.34"; break;
 506:                      case "10.16.5.35": mate = "10.16.1.35"; break;
 507:                      case "10.16.5.36": mate = "10.16.1.36"; break;
 508:                      case "10.16.5.37": mate = "10.16.1.37"; break;
 509:                      case "10.16.5.38": mate = "10.16.1.38"; break;
 510:                      case "10.16.5.39": mate = "10.16.1.39"; break;
 511:                      case "10.16.5.40": mate = "10.16.1.40"; break;
 512:   
 513:                      default: mate = null; break;
 514:                  }
 515:              }
 516:   
 517:              return mate;
 518:          }
 519:   
 520:          ////////////////////////////////////////////////////////////////////////////
 521:   
 522:          /// <summary>
 523:          ///
 524:          /// </summary>
 525:          public static string PrimarySwitchFromAgcfGatewayRecord(bool isPrimary)
 526:          {
 527:              string primarySwitch;
 528:   
 529:              if (isPrimary) primarySwitch = Ia.Ngn.Cl.Model.Business.Nokia.Ims.AnyPrimarySwitch;
 530:              else primarySwitch = Ia.Ngn.Cl.Model.Business.Nokia.Ims.SKB;
 531:   
 532:              return primarySwitch;
 533:          }
 534:   
 535:          ////////////////////////////////////////////////////////////////////////////
 536:   
 537:          /// <summary>
 538:          ///
 539:          /// </summary>
 540:          public static string SecondarySwitchFromAgcfGatewayRecord(bool isPrimary)
 541:          {
 542:              string secondarySwitch;
 543:   
 544:              if (!isPrimary) secondarySwitch = Ia.Ngn.Cl.Model.Business.Nokia.Ims.AnyPrimarySwitch;
 545:              else secondarySwitch = Ia.Ngn.Cl.Model.Business.Nokia.Ims.SKB;
 546:   
 547:              return secondarySwitch;
 548:          }
 549:   
 550:          ////////////////////////////////////////////////////////////////////////////
 551:   
 552:          /// <summary>
 553:          ///
 554:          /// </summary>
 555:          public static int ServiceProfileNumber(int applicationServerId)
 556:          {
 557:              int serviceProfileNumber;
 558:   
 559:              switch (applicationServerId)
 560:              {
 561:                  case 0: serviceProfileNumber = 2; break;
 562:                  case 1: serviceProfileNumber = 10; break;
 563:                  case 2: serviceProfileNumber = 18; break;
 564:                  case 3: serviceProfileNumber = 26; break;
 565:                  case 4: serviceProfileNumber = 34; break;
 566:                  case 5: serviceProfileNumber = 42; break;
 567:                  case 6: serviceProfileNumber = 50; break;
 568:                  default: throw new Exception("Unknown primarySwitch") { };
 569:              }
 570:   
 571:              return serviceProfileNumber;
 572:          }
 573:   
 574:          ////////////////////////////////////////////////////////////////////////////
 575:   
 576:          /// <summary>
 577:          ///
 578:          /// </summary>
 579:          public static int ServiceProfileNumberAgcfGatewayRecord(int imsService)
 580:          {
 581:              bool randomState;
 582:              int serviceProfileNumber;
 583:   
 584:              randomState = Ia.Cl.Model.Default.RandomBool;
 585:   
 586:              switch (imsService)
 587:              {
 588:                  case 0: serviceProfileNumber = 2; break;
 589:                  case 1:
 590:                  case 2:
 591:                  case 3: serviceProfileNumber = randomState ? 10 : 18; break;
 592:                  case 4:
 593:                  case 5:
 594:                  case 6: serviceProfileNumber = randomState ? 26 : 34; break;
 595:                  case 7:
 596:                  case 8:
 597:                  case 9: serviceProfileNumber = randomState ? 42 : 50; break;
 598:                  default: throw new Exception("Unknown primarySwitch") { };
 599:              }
 600:   
 601:              return serviceProfileNumber;
 602:          }
 603:   
 604:          ////////////////////////////////////////////////////////////////////////////
 605:   
 606:          /// <summary>
 607:          ///
 608:          /// </summary>
 609:          public static int SequentialGwIdToReadAgcfGatewayRecordData
 610:          {
 611:              get
 612:              {
 613:                  int number;
 614:   
 615:                  if (allPossibleGwIdQueue.Count == 0) allPossibleGwIdQueue = new Queue<int>(Ia.Ngn.Cl.Model.Data.Nokia.Ims.AllPossibleGatewayIdList);
 616:   
 617:                  number = allPossibleGwIdQueue.Dequeue();
 618:   
 619:                  return number;
 620:              }
 621:          }
 622:   
 623:          ////////////////////////////////////////////////////////////////////////////
 624:   
 625:          /// <summary>
 626:          ///
 627:          /// </summary>
 628:          public static string SequentialServiceToReadServiceData
 629:          {
 630:              get
 631:              {
 632:                  int service;
 633:   
 634:                  if (allPossibleServiceNumbersWithinNetworkQueue.Count == 0) allPossibleServiceNumbersWithinNetworkQueue = new Queue<int>(Ia.Ngn.Cl.Model.Data.Service.AllPossibleServiceNumberListWithinNokiaSwitch);
 635:   
 636:                  service = allPossibleServiceNumbersWithinNetworkQueue.Dequeue();
 637:   
 638:                  return service.ToString();
 639:              }
 640:          }
 641:   
 642:          ////////////////////////////////////////////////////////////////////////////
 643:   
 644:          /// <summary>
 645:          ///
 646:          /// </summary>
 647:          public static string SequentialPrividUserFromAgcfEndpointToReadSubPartyAndSubscriberData
 648:          {
 649:              get
 650:              {
 651:                  string prividUser;
 652:   
 653:                  if (agcfEndpointPrividUserQueue.Count == 0)
 654:                  {
 655:                      agcfEndpointPrividUserQueue = new Queue<string>(Ia.Ngn.Cl.Model.Data.Nokia.AgcfEndpoint.ReadPrividUserList);
 656:                  }
 657:   
 658:                  prividUser = agcfEndpointPrividUserQueue.Dequeue();
 659:   
 660:                  return prividUser;
 661:              }
 662:          }
 663:   
 664:          ////////////////////////////////////////////////////////////////////////////
 665:          ////////////////////////////////////////////////////////////////////////////
 666:      }
 667:   
 668:      ////////////////////////////////////////////////////////////////////////////
 669:      ////////////////////////////////////////////////////////////////////////////
 670:  }