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

Integrated Applications Programming Company

Skip Navigation LinksHome » Code Library » Provision

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

Provision support class of Next Generation Network'a (NGN's) business model.

   1:  using System;
   2:  using System.Collections;
   3:  using System.Collections.Generic;
   4:  using System.Data;
   5:  using System.Linq;
   6:   
   7:  namespace Ia.Ngn.Cl.Model.Business
   8:  {
   9:      ////////////////////////////////////////////////////////////////////////////
  10:   
  11:      /// <summary publish="true">
  12:      /// Provision support class of Next Generation Network'a (NGN's) business model.
  13:      /// </summary>
  14:      /// 
  15:      /// <remarks> 
  16:      /// Copyright © 2006-2019 Jasem Y. Al-Shamlan (info@ia.com.kw), Internet Applications - Kuwait. All Rights Reserved.
  17:      ///
  18:      /// 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
  19:      /// the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
  20:      ///
  21:      /// This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
  22:      /// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
  23:      /// 
  24:      /// You should have received a copy of the GNU General Public License along with this library. If not, see http://www.gnu.org/licenses.
  25:      /// 
  26:      /// Copyright notice: This notice may not be removed or altered from any source distribution.
  27:      /// </remarks> 
  28:      public class Provision
  29:      {
  30:          private static int serviceSuspensionQueueOriginalCount;
  31:          private static int sequentialDiscrepancyAndComplementaryServiceMismatchBetweenServiceRequestServiceAndServiceServiceIdQueueOriginalCount;
  32:          private static Queue<string> sequentialDiscrepancyAndComplementaryServiceMismatchBetweenServiceRequestServiceAndServiceServiceIdQueue = new Queue<string>();
  33:          private static Queue<string> serviceSuspensionQueue = new Queue<string>();
  34:   
  35:          ////////////////////////////////////////////////////////////////////////////
  36:   
  37:          /// <summary>
  38:          ///
  39:          /// </summary>
  40:          public Provision() { }
  41:   
  42:          ////////////////////////////////////////////////////////////////////////////
  43:   
  44:          /// <summary>
  45:          ///
  46:          /// </summary>
  47:          public static bool CreateNokiaSwitchSubscriber(Ia.Ngn.Cl.Model.Client.Nokia.Ims ims, string accessName, string service, int port, Ia.Ngn.Cl.Model.Business.Default.Protocol protocol, bool ignoreRestrictions, out string result)
  48:          {
  49:              bool executed, isSip;
  50:              int gatewayId;
  51:              string r;
  52:              Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Ont nddOnt;
  53:              Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Vendor switchVendor, accessVendor;
  54:              Ia.Ngn.Cl.Model.Ont ont;
  55:              Ia.Ngn.Cl.Model.Huawei.EmsOnt emsOnt;
  56:   
  57:              executed = false;
  58:              result = string.Empty;
  59:   
  60:              switchVendor = Ia.Ngn.Cl.Model.Data.NetworkDesignDocument.SwitchVendorFromService(service);
  61:   
  62:              if (switchVendor == Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Vendor.Nokia)
  63:              {
  64:                  nddOnt = (from n in Ia.Ngn.Cl.Model.Data.NetworkDesignDocument.OntList where n.Access.Name == accessName select n).SingleOrDefault();
  65:   
  66:                  if (nddOnt != null)
  67:                  {
  68:                      if (Ia.Ngn.Cl.Model.Business.Service.NumberIsWithinAllowedRouterDomainList(nddOnt, service) || ignoreRestrictions)
  69:                      {
  70:                          accessVendor = nddOnt.Pon.PonGroup.Olt.Odf.Vendor;
  71:   
  72:                          if (accessVendor == Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Vendor.Nokia)
  73:                          {
  74:                              ont = Ia.Ngn.Cl.Model.Data.Nokia.Ont.Read(nddOnt.Id);
  75:   
  76:                              if (ont != null)
  77:                              {
  78:                                  if (protocol == Ia.Ngn.Cl.Model.Business.Default.Protocol.DefaultAsInNdd) isSip = nddOnt.Pon.PonGroup.Olt.IsSip;
  79:                                  else isSip = protocol == Ia.Ngn.Cl.Model.Business.Default.Protocol.Sip;
  80:   
  81:                                  if (!isSip) // if H.248
  82:                                  {
  83:                                      gatewayId = Ia.Ngn.Cl.Model.Data.Nokia.AgcfGatewayRecord.GwIdFromIp(nddOnt.Ip);
  84:   
  85:                                      if (gatewayId > 0)
  86:                                      {
  87:                                          port = (port != Ia.Ngn.Cl.Model.Business.Default.PortUndefinedOrInvalidOrUnknown) ? port : Ia.Ngn.Cl.Model.Data.Nokia.Ams.NextVacantFlatTermIdForOnt(ont.FamilyTypeId, ont);
  88:   
  89:                                          if (port != Ia.Ngn.Cl.Model.Business.Default.PortUndefinedOrInvalidOrUnknown)
  90:                                          {
  91:                                              Ia.Ngn.Cl.Model.Data.Nokia.Ims.CreateH248SubscriberAndSubPartyAndAgcfEndpoint(ims, gatewayId, service, port, nddOnt, out r);
  92:                                              result += r + ",";
  93:   
  94:                                              Ia.Ngn.Cl.Model.Data.Nokia.Ims.ReadUpdateAgcfGatewayRecordAndAgcfEndpointListAndSubPartyAndSubscriberAndServiceForGwId(ims, gatewayId, out r);
  95:                                              result += r + ",";
  96:   
  97:                                              executed = true;
  98:                                          }
  99:                                          else
 100:                                          {
 101:                                              result += "port is invalid or does not exist,";
 102:                                          }
 103:                                      }
 104:                                      else
 105:                                      {
 106:                                          result += "gatewayId is invalid or does not exist,";
 107:                                      }
 108:                                  }
 109:                                  else // if IsSip == true
 110:                                  {
 111:   
 112:                                  }
 113:                              }
 114:                              else
 115:                              {
 116:                                  result += "ONT is null for access:" + nddOnt.Access.Name + ",";
 117:                              }
 118:                          }
 119:                          else if (accessVendor == Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Vendor.Huawei)
 120:                          {
 121:                              emsOnt = Ia.Ngn.Cl.Model.Data.Huawei.Ont.Read(nddOnt.Id);
 122:   
 123:                              if (emsOnt != null)
 124:                              {
 125:                                  if (protocol == Ia.Ngn.Cl.Model.Business.Default.Protocol.DefaultAsInNdd) isSip = nddOnt.Pon.PonGroup.Olt.IsSip;
 126:                                  else isSip = protocol == Ia.Ngn.Cl.Model.Business.Default.Protocol.Sip;
 127:   
 128:                                  //onuFamilyType = Ia.Ngn.Cl.Model.Data.Huawei.Default.HuaweiSpecialOnuFamilyTypesForAccessNames(accessName);
 129:                                  // if (flatTermIdOrTelPort == 0) flatTermIdOrTelPort = Ia.Ngn.Cl.Model.Business.Ims.NextVacantFlatTermIdFromAgcfEndpointUsingGwIdForOnu(onuFamilyType, gatewayId);
 130:   
 131:                                  if (!isSip) // if H.248
 132:                                  {
 133:                                      gatewayId = Ia.Ngn.Cl.Model.Data.Nokia.AgcfGatewayRecord.GwIdFromIp(nddOnt.Ip);
 134:   
 135:                                      if (gatewayId > 0)
 136:                                      {
 137:                                          port = (port != Ia.Ngn.Cl.Model.Business.Default.PortUndefinedOrInvalidOrUnknown) ? port : Ia.Ngn.Cl.Model.Data.Default.NextVacantFlatTermIdForHuaweiEmsOntEquipmentTypeIdAndNokiaGatewayId(emsOnt.EquipmentType, gatewayId);
 138:   
 139:                                          if (port != Ia.Ngn.Cl.Model.Business.Default.PortUndefinedOrInvalidOrUnknown)
 140:                                          {
 141:                                              Ia.Ngn.Cl.Model.Data.Nokia.Ims.CreateH248SubscriberAndSubPartyAndAgcfEndpoint(ims, gatewayId, service, port, nddOnt, out r);
 142:                                              result += r + ",";
 143:   
 144:                                              Ia.Ngn.Cl.Model.Data.Nokia.Ims.ReadUpdateAgcfGatewayRecordAndAgcfEndpointListAndSubPartyAndSubscriberAndServiceForGwId(ims, gatewayId, out r);
 145:                                              result += r + ",";
 146:   
 147:                                              executed = true;
 148:                                          }
 149:                                          else
 150:                                          {
 151:                                              result += "port is invalid or does not exist,";
 152:                                          }
 153:                                      }
 154:                                      else
 155:                                      {
 156:                                          result += "gatewayId is invalid or does not exist,";
 157:                                      }
 158:                                  }
 159:                                  else // if IsSip == true
 160:                                  {
 161:                                      Ia.Ngn.Cl.Model.Data.Nokia.Ims.CreateSipSubscriber(ims, service, nddOnt, out r);
 162:                                      result += r + ",";
 163:   
 164:                                      Ia.Ngn.Cl.Model.Data.Nokia.Ims.ReadUpdateSubPartyAndSubscriberAndService(ims, service, nddOnt, out r);
 165:                                      result += r + ",";
 166:   
 167:                                      executed = true;
 168:                                  }
 169:                              }
 170:                              else
 171:                              {
 172:                                  result += "EmsOnt is null, does not exist for access:" + nddOnt.Access.Name + ",";
 173:                              }
 174:                          }
 175:                          else
 176:                          {
 177:                              throw new Exception("accessVendor is unknown. ");
 178:                          }
 179:                      }
 180:                      else
 181:                      {
 182:                          result += "service is not within allowed router domain list. ";
 183:                      }
 184:                  }
 185:                  else
 186:                  {
 187:                      result += "nddOnt is null, does not exist for access:" + accessName + ",";
 188:                  }
 189:              }
 190:              else
 191:              {
 192:                  throw new Exception("switchVendor is null or not Nokia. ");
 193:              }
 194:   
 195:              return executed;
 196:          }
 197:   
 198:          ////////////////////////////////////////////////////////////////////////////
 199:   
 200:          /// <summary>
 201:          ///
 202:          /// </summary>
 203:          public static bool ModifyNokiaSwitchSubscriberH248ToSip(Ia.Ngn.Cl.Model.Client.Nokia.Ims ims, string service, Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Ont nddOnt, out string result)
 204:          {
 205:              bool executed;
 206:              int gatewayId;
 207:              string r;
 208:              Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Vendor switchVendor, accessVendor;
 209:              Ia.Ngn.Cl.Model.Ont ont;
 210:              Ia.Ngn.Cl.Model.Huawei.EmsOnt emsOnt;
 211:   
 212:              executed = false;
 213:              result = string.Empty;
 214:   
 215:              switchVendor = Ia.Ngn.Cl.Model.Data.NetworkDesignDocument.SwitchVendorFromService(service);
 216:   
 217:              if (switchVendor == Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Vendor.Nokia)
 218:              {
 219:                  if (nddOnt != null)
 220:                  {
 221:                      if (Ia.Ngn.Cl.Model.Business.Service.NumberIsWithinAllowedRouterDomainList(nddOnt, service))
 222:                      {
 223:                          accessVendor = nddOnt.Pon.PonGroup.Olt.Odf.Vendor;
 224:   
 225:                          if (accessVendor == Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Vendor.Nokia)
 226:                          {
 227:                              ont = Ia.Ngn.Cl.Model.Data.Nokia.Ont.Read(nddOnt.Id);
 228:   
 229:                              if (ont != null)
 230:                              {
 231:                                  if (nddOnt.Pon.PonGroup.Olt.IsSip == false) // if H.248
 232:                                  {
 233:                                      gatewayId = Ia.Ngn.Cl.Model.Data.Nokia.AgcfGatewayRecord.GwIdFromIp(nddOnt.Ip);
 234:   
 235:                                      if (gatewayId > 0)
 236:                                      {
 237:                                          //Ia.Ngn.Cl.Model.Data.Nokia.Ims.Modify248SubscriberAndSubPartyAndAgcfEndpointToSip(ims, gatewayId, service, nddOnt, out r);
 238:                                          //result += r + ",";
 239:   
 240:                                          Ia.Ngn.Cl.Model.Data.Nokia.Ims.ReadUpdateAgcfGatewayRecordAndAgcfEndpointListAndSubPartyAndSubscriberAndServiceForGwId(ims, gatewayId, out r);
 241:                                          result += r + ",";
 242:   
 243:                                          executed = true;
 244:                                      }
 245:                                      else
 246:                                      {
 247:                                          result += "gatewayId is invalid or does not exist,";
 248:                                      }
 249:                                  }
 250:                                  else // if IsSip == true
 251:                                  {
 252:                                      result += "error: OLT is already SIP,";
 253:                                  }
 254:                              }
 255:                              else
 256:                              {
 257:                                  result += "ONT is null for access:" + nddOnt.Access.Name + ",";
 258:                              }
 259:                          }
 260:                          else if (accessVendor == Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Vendor.Huawei)
 261:                          {
 262:                              emsOnt = Ia.Ngn.Cl.Model.Data.Huawei.Ont.Read(nddOnt.Id);
 263:   
 264:                              if (emsOnt != null)
 265:                              {
 266:                                  if (nddOnt.Pon.PonGroup.Olt.IsSip == false) // if H.248
 267:                                  {
 268:                                      gatewayId = Ia.Ngn.Cl.Model.Data.Nokia.AgcfGatewayRecord.GwIdFromIp(nddOnt.Ip);
 269:   
 270:                                      if (gatewayId > 0)
 271:                                      {
 272:                                          Ia.Ngn.Cl.Model.Data.Nokia.Ims.Modify248SubscriberAndSubPartyAndDeleteAgcfEndpointToSip(ims, service, nddOnt, out r);
 273:                                          result += r + ",";
 274:   
 275:                                          Ia.Ngn.Cl.Model.Data.Nokia.Ims.ReadUpdateAgcfGatewayRecordAndAgcfEndpointListAndSubPartyAndSubscriberAndServiceForGwId(ims, gatewayId, out r);
 276:                                          result += r + ",";
 277:   
 278:                                          executed = true;
 279:                                      }
 280:                                      else
 281:                                      {
 282:                                          result += "gatewayId is invalid or does not exist,";
 283:                                      }
 284:                                  }
 285:                                  else // if IsSip == true
 286:                                  {
 287:                                      result += "error: OLT is already SIP,";
 288:                                  }
 289:                              }
 290:                              else
 291:                              {
 292:                                  result += "EmsOnt is null, does not exist for access:" + nddOnt.Access.Name + ",";
 293:                              }
 294:                          }
 295:                          else
 296:                          {
 297:                              throw new Exception("accessVendor is unknown. ");
 298:                          }
 299:                      }
 300:                      else
 301:                      {
 302:                          result += "service is not within allowed router domain list. ";
 303:                      }
 304:                  }
 305:                  else
 306:                  {
 307:                      result += "nddOnt is null,";
 308:                  }
 309:              }
 310:              else
 311:              {
 312:                  throw new Exception("switchVendor is null or not Nokia. ");
 313:              }
 314:   
 315:              return executed;
 316:          }
 317:   
 318:          ////////////////////////////////////////////////////////////////////////////
 319:   
 320:          /// <summary>
 321:          ///
 322:          /// </summary>
 323:          public static bool DeleteNokiaSwitchSubscriber(Ia.Ngn.Cl.Model.Client.Nokia.Ims ims, string accessName, string service, Ia.Ngn.Cl.Model.Business.Default.Protocol protocol, bool ignoreRestrictions, out string result)
 324:          {
 325:              bool executed, isSip;
 326:              int gatewayId;
 327:              string r;
 328:              Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Ont nddOnt;
 329:              Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Vendor switchVendor, accessVendor;
 330:              Ia.Ngn.Cl.Model.Ont ont;
 331:   
 332:              executed = false;
 333:              result = string.Empty;
 334:   
 335:              switchVendor = Ia.Ngn.Cl.Model.Data.NetworkDesignDocument.SwitchVendorFromService(service);
 336:   
 337:              if (switchVendor == Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Vendor.Nokia)
 338:              {
 339:                  nddOnt = (from n in Ia.Ngn.Cl.Model.Data.NetworkDesignDocument.OntList where n.Access.Name == accessName select n).SingleOrDefault();
 340:   
 341:                  if (nddOnt != null)
 342:                  {
 343:                      if (Ia.Ngn.Cl.Model.Business.Service.NumberIsWithinAllowedRouterDomainList(nddOnt, service) || ignoreRestrictions)
 344:                      {
 345:                          accessVendor = nddOnt.Pon.PonGroup.Olt.Odf.Vendor;
 346:   
 347:                          if (accessVendor == Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Vendor.Nokia)
 348:                          {
 349:                              ont = Ia.Ngn.Cl.Model.Data.Nokia.Ont.Read(nddOnt.Id);
 350:   
 351:                              if (ont != null)
 352:                              {
 353:                                  if (protocol == Ia.Ngn.Cl.Model.Business.Default.Protocol.DefaultAsInNdd) isSip = nddOnt.Pon.PonGroup.Olt.IsSip;
 354:                                  else isSip = protocol == Ia.Ngn.Cl.Model.Business.Default.Protocol.Sip;
 355:   
 356:                                  if (!isSip) // if H.248
 357:                                  {
 358:                                      gatewayId = Ia.Ngn.Cl.Model.Data.Nokia.AgcfGatewayRecord.GwIdFromIp(nddOnt.Ip);
 359:   
 360:                                      if (gatewayId > 0)
 361:                                      {
 362:                                          Ia.Ngn.Cl.Model.Data.Nokia.Ims.DeleteAgcfEndpointAndH248SubscriberAndSubParty(ims, service, nddOnt, out r);
 363:                                          result += r + ",";
 364:   
 365:                                          Ia.Ngn.Cl.Model.Data.Nokia.Ims.ReadUpdateAgcfGatewayRecordAndAgcfEndpointListAndSubPartyAndSubscriberAndServiceForGwId(ims, gatewayId, out r);
 366:                                          result += r + ",";
 367:   
 368:                                          executed = true;
 369:                                      }
 370:                                      else
 371:                                      {
 372:                                          result += "gatewayId is invalid or does not exist,";
 373:                                      }
 374:                                  }
 375:                                  else // if IsSip == true
 376:                                  {
 377:   
 378:                                  }
 379:                              }
 380:                              else
 381:                              {
 382:                                  result += "ont is null for access:" + nddOnt.Access.Name + ",";
 383:                              }
 384:                          }
 385:                          else if (accessVendor == Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Vendor.Huawei)
 386:                          {
 387:                              if (protocol == Ia.Ngn.Cl.Model.Business.Default.Protocol.DefaultAsInNdd) isSip = nddOnt.Pon.PonGroup.Olt.IsSip;
 388:                              else isSip = protocol == Ia.Ngn.Cl.Model.Business.Default.Protocol.Sip;
 389:   
 390:                              if (!isSip) // if H.248
 391:                              {
 392:                                  gatewayId = Ia.Ngn.Cl.Model.Data.Nokia.AgcfGatewayRecord.GwIdFromIp(nddOnt.Ip);
 393:   
 394:                                  if (gatewayId > 0)
 395:                                  {
 396:                                      Ia.Ngn.Cl.Model.Data.Nokia.Ims.DeleteAgcfEndpointAndH248SubscriberAndSubParty(ims, service, nddOnt, out r);
 397:                                      result += r + ",";
 398:   
 399:                                      Ia.Ngn.Cl.Model.Data.Nokia.Ims.ReadUpdateAgcfGatewayRecordAndAgcfEndpointListAndSubPartyAndSubscriberAndServiceForGwId(ims, gatewayId, out r);
 400:                                      result += r + ",";
 401:   
 402:                                      executed = true;
 403:                                  }
 404:                                  else
 405:                                  {
 406:                                      result += "gatewayId is invalid or does not exist,";
 407:                                  }
 408:                              }
 409:                              else // if IsSip == true
 410:                              {
 411:                                  Ia.Ngn.Cl.Model.Data.Nokia.Ims.DeleteSipSubscriber(ims, service, nddOnt, out r);
 412:                                  result += r + ",";
 413:   
 414:                                  Ia.Ngn.Cl.Model.Data.Nokia.Ims.ReadUpdateSubPartyAndSubscriberAndService(ims, service, nddOnt, out r);
 415:                                  result += r + ",";
 416:                              }
 417:                          }
 418:                          else
 419:                          {
 420:                              throw new Exception("accessVendor is unknown. ");
 421:                          }
 422:                      }
 423:                      else
 424:                      {
 425:                          result += "service is not within allowed router domain list. ";
 426:                      }
 427:                  }
 428:                  else
 429:                  {
 430:                      result += "nddOnt is null, does not exist for access:" + accessName + ",";
 431:                  }
 432:              }
 433:              else
 434:              {
 435:                  throw new Exception("switchVendor is null or not Nokia. ");
 436:              }
 437:   
 438:              return executed;
 439:          }
 440:   
 441:          ////////////////////////////////////////////////////////////////////////////
 442:   
 443:          /// <summary>
 444:          ///
 445:          /// </summary>
 446:          public static bool DeleteNokiaSwitchAgcfEndpointAndH248SubscriberAndIgnoreAccess(Ia.Ngn.Cl.Model.Client.Nokia.Ims ims, int gatewayId, string service, bool ignoreRestrictions, out string result)
 447:          {
 448:              bool executed;
 449:              string ip;
 450:              Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Ont nddOnt;
 451:              Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Vendor switchVendor;
 452:   
 453:              executed = false;
 454:              result = string.Empty;
 455:   
 456:              switchVendor = Ia.Ngn.Cl.Model.Data.NetworkDesignDocument.SwitchVendorFromService(service);
 457:   
 458:              if (switchVendor == Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Vendor.Nokia)
 459:              {
 460:                  ip = Ia.Ngn.Cl.Model.Data.Nokia.AgcfGatewayRecord.IpFromGatewayId(gatewayId);
 461:   
 462:                  if (!string.IsNullOrEmpty(ip))
 463:                  {
 464:                      nddOnt = (from o in Ia.Ngn.Cl.Model.Data.NetworkDesignDocument.OntList where o.Ip == ip select o).SingleOrDefault();
 465:   
 466:                      if (nddOnt != null)
 467:                      {
 468:                          if (Ia.Ngn.Cl.Model.Business.Service.NumberIsWithinAllowedRouterDomainList(nddOnt, service) || ignoreRestrictions)
 469:                          {
 470:                              Ia.Ngn.Cl.Model.Data.Nokia.Ims.DeleteAgcfEndpointAndH248SubscriberAndSubParty(ims, service, nddOnt, out string r);
 471:                              result += r + ",";
 472:   
 473:                              Ia.Ngn.Cl.Model.Data.Nokia.Ims.ReadUpdateAgcfGatewayRecordAndAgcfEndpointListAndSubPartyAndSubscriberAndServiceForGwId(ims, gatewayId, out r);
 474:                              result += r + ",";
 475:   
 476:                              executed = true;
 477:                          }
 478:                          else
 479:                          {
 480:                              result += "service is not within allowed router domain list. ";
 481:                          }
 482:                      }
 483:                      else
 484:                      {
 485:                          result += "nddOnt is null, does not exist for ip:" + ip + ",";
 486:                      }
 487:                  }
 488:                  else
 489:                  {
 490:                      result += "For gatewayId: " + gatewayId + " ip is null or empty,";
 491:                  }
 492:              }
 493:              else
 494:              {
 495:                  throw new Exception("switchVendor is null or not Nokia. ");
 496:              }
 497:   
 498:              return executed;
 499:          }
 500:   
 501:          ////////////////////////////////////////////////////////////////////////////
 502:   
 503:          /// <summary>
 504:          ///
 505:          /// </summary>
 506:          public static bool DeleteNokiaSwitchAgcfEndpointAndH248SubscriberFromAnyFsdb(Ia.Ngn.Cl.Model.Client.Nokia.Ims ims, string service, out string result)
 507:          {
 508:              bool executed;
 509:              Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Vendor switchVendor;
 510:   
 511:              executed = false;
 512:              result = string.Empty;
 513:   
 514:              switchVendor = Ia.Ngn.Cl.Model.Data.NetworkDesignDocument.SwitchVendorFromService(service);
 515:   
 516:              if (switchVendor == Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Vendor.Nokia)
 517:              {
 518:                  foreach (Ia.Ngn.Cl.Model.Business.Nokia.Ims.ImsBasicService ibs in Ia.Ngn.Cl.Model.Business.Nokia.Ims.ImsBasicServiceList)
 519:                  {
 520:                      Ia.Ngn.Cl.Model.Data.Nokia.Ims.DeleteAgcfEndpointAndH248SubscriberAndSubParty(ims, service, ibs.PrimarySwitch, ibs.Fsdb, out string r);
 521:                      result += r + ",";
 522:   
 523:                      Ia.Ngn.Cl.Model.Data.Nokia.Ims.ReadSubPartyAndSubscriber(ims, service, ibs.PrimarySwitch, ibs.Fsdb, ibs.Service, out r);
 524:                      result += r + ",";
 525:                  }
 526:   
 527:                  executed = true;
 528:              }
 529:              else
 530:              {
 531:                  throw new Exception("switchVendor is null or not Nokia. ");
 532:              }
 533:   
 534:              return executed;
 535:          }
 536:   
 537:          ////////////////////////////////////////////////////////////////////////////
 538:          ////////////////////////////////////////////////////////////////////////////
 539:   
 540:          /// <summary>
 541:          ///
 542:          /// </summary>
 543:          public static bool CreateHuaweiSwitchSubscriber(Ia.Ngn.Cl.Model.Client.Huawei.Ims ims, string accessName, string service, int port, Ia.Ngn.Cl.Model.Business.Default.Protocol protocol, bool ignoreRestrictions, out string result)
 544:          {
 545:              bool executed, created, isSip;
 546:              string r;
 547:              Ia.Ngn.Cl.Model.Business.Huawei.Default.FnSnPn fnSnPn;
 548:              Ia.Ngn.Cl.Model.Business.Huawei.Dev.MduDev mdu;
 549:              Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Ont nddOnt;
 550:              Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Vendor switchVendor, accessVendor;
 551:              Ia.Ngn.Cl.Model.Huawei.EmsOnt emsOnt;
 552:              Ia.Ngn.Cl.Model.Ont ont;
 553:   
 554:              executed = false;
 555:              result = string.Empty;
 556:   
 557:              switchVendor = Ia.Ngn.Cl.Model.Data.NetworkDesignDocument.SwitchVendorFromService(service);
 558:   
 559:              if (switchVendor == Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Vendor.Huawei)
 560:              {
 561:                  nddOnt = (from n in Ia.Ngn.Cl.Model.Data.NetworkDesignDocument.OntList where n.Access.Name == accessName select n).SingleOrDefault();
 562:   
 563:                  if (nddOnt != null)
 564:                  {
 565:                      if (Ia.Ngn.Cl.Model.Business.Service.NumberIsWithinAllowedRouterDomainList(nddOnt, service) || ignoreRestrictions)
 566:                      {
 567:                          accessVendor = nddOnt.Pon.PonGroup.Olt.Odf.Vendor;
 568:   
 569:                          if (accessVendor == Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Vendor.Nokia)
 570:                          {
 571:                              ont = Ia.Ngn.Cl.Model.Data.Nokia.Ont.Read(nddOnt.Id);
 572:   
 573:                              if (ont != null)
 574:                              {
 575:                                  port = (port != Ia.Ngn.Cl.Model.Business.Default.PortUndefinedOrInvalidOrUnknown) ? port : Ia.Ngn.Cl.Model.Data.Nokia.Ams.NextVacantFlatTermIdForOnt(ont.FamilyTypeId, ont);
 576:   
 577:                                  if (port != Ia.Ngn.Cl.Model.Business.Default.PortUndefinedOrInvalidOrUnknown)
 578:                                  {
 579:                                      Ia.Ngn.Cl.Model.Data.Huawei.Ims.CreateSubscriber(ims, service, nddOnt, out r);
 580:                                      result += r + ",";
 581:   
 582:                                      Ia.Ngn.Cl.Model.Business.Huawei.Ims.ReadSbrForService(ims, service, out r);
 583:                                      result += r + ",";
 584:   
 585:                                      // other commands will be issued through U2000 NBI to configure H.248 in SKB and TEC softswitch
 586:   
 587:                                      executed = true;
 588:                                  }
 589:                                  else
 590:                                  {
 591:                                      result += "Port is invalid or does not exist,";
 592:                                  }
 593:                              }
 594:                              else
 595:                              {
 596:                                  result += "Ont is null, does not exist for access:" + nddOnt.Access.Name + ",";
 597:                              }
 598:                          }
 599:                          else if (accessVendor == Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Vendor.Huawei)
 600:                          {
 601:                              emsOnt = Ia.Ngn.Cl.Model.Data.Huawei.Ont.Read(nddOnt.Id);
 602:   
 603:                              if (emsOnt != null)
 604:                              {
 605:                                  if (protocol == Ia.Ngn.Cl.Model.Business.Default.Protocol.DefaultAsInNdd) isSip = nddOnt.Pon.PonGroup.Olt.IsSip;
 606:                                  else isSip = protocol == Ia.Ngn.Cl.Model.Business.Default.Protocol.Sip;
 607:   
 608:                                  if (!isSip) // if H.248
 609:                                  {
 610:                                  }
 611:                                  else // if IsSip == true
 612:                                  {
 613:                                      if (emsOnt.FamilyType == Ia.Ngn.Cl.Model.Business.Huawei.Ont.FamilyType.Mdu)
 614:                                      {
 615:                                          if (Ia.Ngn.Cl.Model.Data.Huawei.Default.MduDevDictionary.ContainsKey(nddOnt.Access.Name))
 616:                                          {
 617:                                              var pn = port;
 618:   
 619:                                              mdu = Ia.Ngn.Cl.Model.Data.Huawei.Default.MduDevDictionary[nddOnt.Access.Name];
 620:   
 621:                                              var vacantFnSnPnList = Ia.Ngn.Cl.Model.Data.Huawei.Ems.VacantMduFnSnPnForOntList(mdu, emsOnt);
 622:   
 623:                                              if (pn != Ia.Ngn.Cl.Model.Business.Default.PortUndefinedOrInvalidOrUnknown) fnSnPn = vacantFnSnPnList.Where(f => f.Pn == pn).SingleOrDefault();
 624:                                              else fnSnPn = Ia.Ngn.Cl.Model.Data.Huawei.Ems.NextVacantMduFnSnPnForOnt(mdu, emsOnt);
 625:   
 626:                                              if (fnSnPn != null)
 627:                                              {
 628:                                                  port = (port < 0) ? fnSnPn.Pn : port;
 629:   
 630:                                                  created = Ia.Ngn.Cl.Model.Data.Huawei.Ims.CreateSubscriber(ims, service, nddOnt, out r);
 631:   
 632:                                                  result += r + ",";
 633:                                              }
 634:                                              else result += "MDU sn and/or tel is invalid or does not exist. ";
 635:                                          }
 636:                                          else
 637:                                          {
 638:                                              result += "emsOnt.FamilyType == Mdu but MduDictionary does not contain key: " + nddOnt.Access.Name + " for service: " + service + ", and access: " + nddOnt.Access.Name;
 639:                                          }
 640:                                      }
 641:                                      else // if not MDU
 642:                                      {
 643:                                          port = (port != Ia.Ngn.Cl.Model.Business.Default.PortUndefinedOrInvalidOrUnknown) ? port : Ia.Ngn.Cl.Model.Data.Huawei.Ems.NextVacantTelForOnt(emsOnt);
 644:   
 645:                                          if (port != Ia.Ngn.Cl.Model.Business.Default.PortUndefinedOrInvalidOrUnknown)
 646:                                          {
 647:                                              created = Ia.Ngn.Cl.Model.Data.Huawei.Ims.CreateSubscriber(ims, service, nddOnt, out r);
 648:   
 649:                                              result += r + ",";
 650:                                          }
 651:                                          else
 652:                                          {
 653:                                              result += "Port is invalid or does not exist,";
 654:                                          }
 655:                                      }
 656:                                  }
 657:                              }
 658:                              else
 659:                              {
 660:                                  result += "emsOnt is null, does not exist for access:" + nddOnt.Access.Name + ",";
 661:                              }
 662:   
 663:                              Ia.Ngn.Cl.Model.Business.Huawei.Ims.ReadUpdateSbrAndServiceForService(ims, service, nddOnt, out r);
 664:                              result += r + ",";
 665:                          }
 666:                          else
 667:                          {
 668:                              throw new Exception("accessVendor is unknown. ");
 669:                          }
 670:                      }
 671:                      else
 672:                      {
 673:                          result += "service is not within allowed router domain list. ";
 674:                      }
 675:                  }
 676:                  else
 677:                  {
 678:                      result += "nddOnt is null, does not exist for access:" + accessName + ",";
 679:                  }
 680:              }
 681:              else
 682:              {
 683:                  throw new Exception("switchVendor is null or not Huawei. ");
 684:              }
 685:   
 686:              return executed;
 687:          }
 688:   
 689:          ////////////////////////////////////////////////////////////////////////////
 690:   
 691:          /// <summary>
 692:          ///
 693:          /// </summary>
 694:          public static bool DeleteHuaweiSwitchSubscriber(Ia.Ngn.Cl.Model.Client.Huawei.Ims ims, string accessName, string service, Ia.Ngn.Cl.Model.Business.Default.Protocol protocol, bool ignoreRestrictions, out string result)
 695:          {
 696:              bool executed, isSip;
 697:              string r;
 698:              Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Ont nddOnt;
 699:              Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Vendor switchVendor, accessVendor;
 700:              Ia.Ngn.Cl.Model.Ont ont;
 701:   
 702:              executed = false;
 703:              result = string.Empty;
 704:   
 705:              switchVendor = Ia.Ngn.Cl.Model.Data.NetworkDesignDocument.SwitchVendorFromService(service);
 706:   
 707:              if (switchVendor == Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Vendor.Huawei)
 708:              {
 709:                  nddOnt = (from n in Ia.Ngn.Cl.Model.Data.NetworkDesignDocument.OntList where n.Access.Name == accessName select n).SingleOrDefault();
 710:   
 711:                  if (nddOnt != null)
 712:                  {
 713:                      if (Ia.Ngn.Cl.Model.Business.Service.NumberIsWithinAllowedRouterDomainList(nddOnt, service) || ignoreRestrictions)
 714:                      {
 715:                          accessVendor = nddOnt.Pon.PonGroup.Olt.Odf.Vendor;
 716:   
 717:                          if (accessVendor == Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Vendor.Nokia)
 718:                          {
 719:                              ont = Ia.Ngn.Cl.Model.Data.Nokia.Ont.Read(nddOnt.Id);
 720:   
 721:                              if (ont != null)
 722:                              {
 723:                                  Ia.Ngn.Cl.Model.Data.Huawei.Ims.DeleteSubscriber(ims, service, out r);
 724:                                  result += r + ",";
 725:   
 726:                                  Ia.Ngn.Cl.Model.Business.Huawei.Ims.ReadUpdateSbrAndServiceForService(ims, service, nddOnt, out r);
 727:                                  result += r + ",";
 728:   
 729:                                  // other commands will be issued through U2000 NBI to configure H.248 in SKB and TEC softswitch
 730:                              }
 731:                              else
 732:                              {
 733:                                  result += "ont is null,";
 734:                              }
 735:                          }
 736:                          else if (accessVendor == Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Vendor.Huawei)
 737:                          {
 738:                              Ia.Ngn.Cl.Model.Data.Huawei.Ims.DeleteSubscriber(ims, service, out r);
 739:                              result += r + ",";
 740:   
 741:                              Ia.Ngn.Cl.Model.Business.Huawei.Ims.ReadUpdateSbrAndServiceForService(ims, service, nddOnt, out r);
 742:                              result += r + ",";
 743:                          }
 744:                          else
 745:                          {
 746:                              throw new Exception("accessVendor is unknown. ");
 747:                          }
 748:                      }
 749:                      else
 750:                      {
 751:                          result += "service is not within allowed router domain list. ";
 752:                      }
 753:                  }
 754:                  else
 755:                  {
 756:                      result += "nddOnt is null, does not exist for access:" + accessName + ",";
 757:                  }
 758:              }
 759:              else
 760:              {
 761:                  throw new Exception("switchVendor is null or not Huawei. ");
 762:              }
 763:   
 764:              return executed;
 765:          }
 766:   
 767:          ////////////////////////////////////////////////////////////////////////////
 768:          ////////////////////////////////////////////////////////////////////////////
 769:   
 770:          /// <summary>
 771:          ///
 772:          /// </summary>
 773:          public static string SequentialServiceSuspensionMismatchBetweenServiceRequestServiceAndServiceServiceIdList(out int serviceSuspensionQueueCount, out string result)
 774:          {
 775:              string service;
 776:   
 777:              if (serviceSuspensionQueue.Count == 0)
 778:              {
 779:                  serviceSuspensionQueue = new Queue<string>(Ia.Ngn.Cl.Model.Data.Provision.ServiceSuspensionMismatchBetweenServiceRequestServiceAndServiceServiceIdList());
 780:   
 781:                  serviceSuspensionQueueOriginalCount = serviceSuspensionQueue.Count;
 782:              }
 783:   
 784:              if (serviceSuspensionQueue.Count > 0) service = serviceSuspensionQueue.Dequeue();
 785:              else service = null;
 786:   
 787:              result = "(" + serviceSuspensionQueue.Count + "/" + serviceSuspensionQueueOriginalCount + ") ";
 788:   
 789:              serviceSuspensionQueueCount = serviceSuspensionQueue.Count;
 790:   
 791:              return service;
 792:          }
 793:   
 794:          ////////////////////////////////////////////////////////////////////////////
 795:   
 796:          /// <summary>
 797:          ///
 798:          /// </summary>
 799:          public static string SequentialDiscrepancyAndComplementaryServiceMismatchBetweenServiceRequestServiceAndServiceListItem(int provisionWithinLastNDays, out int sequentialDiscrepancyAndComplementaryServiceMismatchBetweenServiceRequestServiceAndServiceServiceIdQueueCount, out string progressCounterString)
 800:          {
 801:              string service;
 802:   
 803:              if (sequentialDiscrepancyAndComplementaryServiceMismatchBetweenServiceRequestServiceAndServiceServiceIdQueue.Count == 0)
 804:              {
 805:                  sequentialDiscrepancyAndComplementaryServiceMismatchBetweenServiceRequestServiceAndServiceServiceIdQueue = new Queue<string>(DiscrepancyAndComplementaryServiceMismatchBetweenServiceRequestServiceAndServiceServiceIdList(provisionWithinLastNDays).Keys.ToList());
 806:   
 807:                  sequentialDiscrepancyAndComplementaryServiceMismatchBetweenServiceRequestServiceAndServiceServiceIdQueueOriginalCount = sequentialDiscrepancyAndComplementaryServiceMismatchBetweenServiceRequestServiceAndServiceServiceIdQueue.Count;
 808:              }
 809:   
 810:              if (sequentialDiscrepancyAndComplementaryServiceMismatchBetweenServiceRequestServiceAndServiceServiceIdQueue.Count > 0) service = sequentialDiscrepancyAndComplementaryServiceMismatchBetweenServiceRequestServiceAndServiceServiceIdQueue.Dequeue();
 811:              else service = null;
 812:   
 813:              progressCounterString = "(" + sequentialDiscrepancyAndComplementaryServiceMismatchBetweenServiceRequestServiceAndServiceServiceIdQueue.Count + "/" + sequentialDiscrepancyAndComplementaryServiceMismatchBetweenServiceRequestServiceAndServiceServiceIdQueueOriginalCount + ")";
 814:   
 815:              sequentialDiscrepancyAndComplementaryServiceMismatchBetweenServiceRequestServiceAndServiceServiceIdQueueCount = sequentialDiscrepancyAndComplementaryServiceMismatchBetweenServiceRequestServiceAndServiceServiceIdQueue.Count;
 816:   
 817:              return service;
 818:          }
 819:   
 820:          ////////////////////////////////////////////////////////////////////////////
 821:   
 822:          /// <summary>
 823:          ///
 824:          /// </summary>
 825:          public static Dictionary<string, string> DiscrepancyAndComplementaryServiceMismatchBetweenServiceRequestServiceAndServiceServiceIdList(int provisionWithinLastNDays)
 826:          {
 827:              Dictionary<string, string> dictionary;
 828:   
 829:              Ia.Ngn.Cl.Model.Data.Provision.ServiceToUpdateServiceIdAccessIdDictionary_ServiceToCreateServiceIdAccessIdDictionary_ServiceToDeleteServiceIdAccessIdDictionary(provisionWithinLastNDays, out Dictionary<string, string> serviceToUpdateIdAccessIdDictionary, out Dictionary<string, string> serviceToCreateServiceIdAccessIdDictionary, out Dictionary<string, string> serviceToDeleteServiceIdAccessIdDictionary);
 830:   
 831:              dictionary = new Dictionary<string, string>(serviceToUpdateIdAccessIdDictionary.Count + serviceToCreateServiceIdAccessIdDictionary.Count + serviceToDeleteServiceIdAccessIdDictionary.Count);
 832:   
 833:              foreach (KeyValuePair<string, string> s in serviceToUpdateIdAccessIdDictionary) dictionary.Add(s.Key, s.Value);
 834:              foreach (KeyValuePair<string, string> s in serviceToCreateServiceIdAccessIdDictionary) dictionary.Add(s.Key, s.Value);
 835:              foreach (KeyValuePair<string, string> s in serviceToDeleteServiceIdAccessIdDictionary) dictionary.Add(s.Key, s.Value);
 836:   
 837:              return dictionary;
 838:          }
 839:   
 840:          /*
 841:          ////////////////////////////////////////////////////////////////////////////
 842:          ////////////////////////////////////////////////////////////////////////////
 843:  
 844:          /// <summary>
 845:          ///
 846:          /// </summary>
 847:          public static Ia.Ngn.Cl.Model.Business.Procedure.Process SequentialProvisioningWorkflowOfServiceToCreateAndToDeleteInEmsOntSipInfoOrVoipPstnUserListItem(int provisioningWorkflowWithinPastNHours, out int sequentialProvisioningWorkflowQueueCount, out string progressCounterString)
 848:          {
 849:              Ia.Ngn.Cl.Model.Business.Procedure.Process process;
 850:  
 851:              if (provisioningWorkflowWithinPastNHours == 0) process = SequentialProvisioningWorkflowOfServiceToCreateAndToDeleteInEmsOntSipInfoOrVoipPstnUserListWithIssueItem(out sequentialProvisioningWorkflowQueueCount, out progressCounterString);
 852:              else process = SequentialProvisioningWorkflowOfServiceToCreateAndToDeleteInEmsOntSipInfoOrVoipPstnUserListFromThePastNHoursItem(provisioningWorkflowWithinPastNHours, out sequentialProvisioningWorkflowQueueCount, out progressCounterString);
 853:  
 854:              return process;
 855:          }
 856:  
 857:          ////////////////////////////////////////////////////////////////////////////
 858:  
 859:          /// <summary>
 860:          ///
 861:          /// </summary>
 862:          private static Ia.Ngn.Cl.Model.Business.Procedure.Process SequentialProvisioningWorkflowOfServiceToCreateAndToDeleteInEmsOntSipInfoOrVoipPstnUserListFromThePastNHoursItem(int provisioningWorkflowWithinPastNHours, out int sequentialProvisioningWorkflowQueueCount, out string progressCounterString)
 863:          {
 864:              Ia.Ngn.Cl.Model.Business.Procedure.Process process;
 865:              List<Ia.Ngn.Cl.Model.Business.Procedure.Process> list;
 866:  
 867:              if (sequentialProvisioningWorkflowQueue.Count == 0)
 868:              {
 869:                  list = Ia.Ngn.Cl.Model.Business.Provision.ServiceToCreateAndToDeleteInEmsOntSipInfoOrVoipPstnUserListFromThePastNHourList(provisioningWorkflowWithinPastNHours);
 870:  
 871:                  sequentialProvisioningWorkflowQueue = new Queue<Ia.Ngn.Cl.Model.Business.Procedure.Process>(list.OrderByDescending(l => l.DateTime)); // don't shuffle
 872:  
 873:                  sequentialProvisioningWorkflowQueueOriginalCount = sequentialProvisioningWorkflowQueue.Count;
 874:              }
 875:  
 876:              if (sequentialProvisioningWorkflowQueue.Count > 0) process = sequentialProvisioningWorkflowQueue.Dequeue();
 877:              else process = new Ia.Ngn.Cl.Model.Business.Procedure.Process { Type = Ia.Ngn.Cl.Model.Business.Procedure.ProcessType.None };
 878:  
 879:              progressCounterString = "(" + sequentialProvisioningWorkflowQueue.Count + "/" + sequentialProvisioningWorkflowQueueOriginalCount + ")";
 880:  
 881:              sequentialProvisioningWorkflowQueueCount = sequentialProvisioningWorkflowQueue.Count;
 882:  
 883:              return process;
 884:          }
 885:  
 886:          ////////////////////////////////////////////////////////////////////////////
 887:  
 888:          /// <summary>
 889:          ///
 890:          /// </summary>
 891:          private static Ia.Ngn.Cl.Model.Business.Procedure.Process SequentialProvisioningWorkflowOfServiceToCreateAndToDeleteInEmsOntSipInfoOrVoipPstnUserListWithIssueItem(out int sequentialProvisioningWorkflowQueueCount, out string progressCounterString)
 892:          {
 893:              Ia.Ngn.Cl.Model.Business.Procedure.Process pw;
 894:              List<Ia.Ngn.Cl.Model.Business.Procedure.Process> list;
 895:  
 896:              if (sequentialProvisioningWorkflowWithIssueQueue.Count == 0)
 897:              {
 898:                  list = Ia.Ngn.Cl.Model.Business.Provision.ServiceToCreateAndToDeleteInEmsOntSipInfoOrVoipPstnUserListFromThePastNHourList(0);
 899:  
 900:                  sequentialProvisioningWorkflowWithIssueQueue = new Queue<Ia.Ngn.Cl.Model.Business.Procedure.Process>(list.OrderByDescending(l => l.DateTime)); // don't shuffle
 901:  
 902:                  sequentialProvisioningWorkflowWithIssueQueueOriginalCount = sequentialProvisioningWorkflowWithIssueQueue.Count;
 903:              }
 904:  
 905:              if (sequentialProvisioningWorkflowWithIssueQueue.Count > 0) pw = sequentialProvisioningWorkflowWithIssueQueue.Dequeue();
 906:              else pw = new Ia.Ngn.Cl.Model.Business.Procedure.Process { Type = Ia.Ngn.Cl.Model.Business.Procedure.ProcessType.None };
 907:  
 908:              progressCounterString = "(" + sequentialProvisioningWorkflowWithIssueQueue.Count + "/" + sequentialProvisioningWorkflowWithIssueQueueOriginalCount + ")";
 909:  
 910:              sequentialProvisioningWorkflowQueueCount = sequentialProvisioningWorkflowWithIssueQueue.Count;
 911:  
 912:              return pw;
 913:          }
 914:          */
 915:   
 916:          ////////////////////////////////////////////////////////////////////////////
 917:   
 918:          /// <summary>
 919:          ///
 920:          /// </summary>
 921:          public static List<Ia.Ngn.Cl.Model.Business.Procedure.Process> ServiceToCreateAndToDeleteInEmsOntSipInfoOrVoipPstnUserListFromThePastNHourList(int provisioningWithinPastNHours)
 922:          {
 923:              DateTime pastNHoursDateTime;
 924:              List<Ia.Ngn.Cl.Model.Business.Procedure.Process> processList;
 925:   
 926:              processList = new List<Ia.Ngn.Cl.Model.Business.Procedure.Process>();
 927:   
 928:              pastNHoursDateTime = (provisioningWithinPastNHours > 0) ? DateTime.UtcNow.AddHours(3).AddHours(-provisioningWithinPastNHours) : DateTime.MinValue;
 929:   
 930:              Ia.Ngn.Cl.Model.Business.Provision.ServiceIdToCreateInEmsOntSipInfoOrVoipPstnUserList_ServiceIdToAnnulInEmsOntSipInfoOrVoipPstnUserList(out List<Ia.Ngn.Cl.Model.Business.ServiceOnt> serviceOntToCreateInEmsOntSipInfoOrVoipPstnUserList, out List<Ia.Ngn.Cl.Model.Business.ServiceOnt> serviceOntToAnnulInEmsOntSipInfoOrVoipPstnUseList);
 931:   
 932:              // issue read, execute, then read again commands
 933:              foreach (var serviceOnt in serviceOntToCreateInEmsOntSipInfoOrVoipPstnUserList)
 934:              {
 935:                  if (serviceOnt.CreatedDateTime >= pastNHoursDateTime)
 936:                  {
 937:                      processList.Add(new Ia.Ngn.Cl.Model.Business.Procedure.Process { ServiceId = serviceOnt.ServiceId, Service = serviceOnt.Service, Ont = serviceOnt.Ont, Port = Ia.Ngn.Cl.Model.Business.Default.PortUndefinedOrInvalidOrUnknown, Type = Ia.Ngn.Cl.Model.Business.Procedure.ProcessType.Create, DateTime = serviceOnt.CreatedDateTime });
 938:                      processList.Add(new Ia.Ngn.Cl.Model.Business.Procedure.Process { ServiceId = serviceOnt.ServiceId, Service = serviceOnt.Service, Ont = serviceOnt.Ont, Port = Ia.Ngn.Cl.Model.Business.Default.PortUndefinedOrInvalidOrUnknown, Type = Ia.Ngn.Cl.Model.Business.Procedure.ProcessType.Read, DateTime = serviceOnt.CreatedDateTime });
 939:                  }
 940:              }
 941:   
 942:              foreach (var serviceOnt in serviceOntToAnnulInEmsOntSipInfoOrVoipPstnUseList)
 943:              {
 944:                  if (serviceOnt.CreatedDateTime > pastNHoursDateTime)
 945:                  {
 946:                      processList.Add(new Ia.Ngn.Cl.Model.Business.Procedure.Process { ServiceId = serviceOnt.ServiceId, Service = serviceOnt.Service, Ont = serviceOnt.Ont, Port = Ia.Ngn.Cl.Model.Business.Default.PortUndefinedOrInvalidOrUnknown, Type = Ia.Ngn.Cl.Model.Business.Procedure.ProcessType.Delete, DateTime = serviceOnt.CreatedDateTime });
 947:                      processList.Add(new Ia.Ngn.Cl.Model.Business.Procedure.Process { ServiceId = serviceOnt.ServiceId, Service = serviceOnt.Service, Ont = serviceOnt.Ont, Port = Ia.Ngn.Cl.Model.Business.Default.PortUndefinedOrInvalidOrUnknown, Type = Ia.Ngn.Cl.Model.Business.Procedure.ProcessType.Read, DateTime = serviceOnt.CreatedDateTime });
 948:                  }
 949:              }
 950:   
 951:              return processList;
 952:          }
 953:   
 954:          ////////////////////////////////////////////////////////////////////////////
 955:   
 956:          /// <summary>
 957:          /// Find the provisioned services within SIP OLTs that do not have equivalent OntSipInfo or VoipPstnUser records, and all OntSipInfo and VoipPstnUser records that do note have equivalent services within SIP OLTs.
 958:          /// </summary>
 959:          private static void ServiceIdToCreateInEmsOntSipInfoOrVoipPstnUserList_ServiceIdToAnnulInEmsOntSipInfoOrVoipPstnUserList(out List<Ia.Ngn.Cl.Model.Business.ServiceOnt> serviceOntToCreateInEmsOntSipInfoOrVoipPstnUserList, out List<Ia.Ngn.Cl.Model.Business.ServiceOnt> serviceOntToAnnulInEmsOntSipInfoOrVoipPstnUseList)
 960:          {
 961:              string _serviceId;
 962:              Ia.Ngn.Cl.Model.Business.ServiceOnt serviceOnt2;
 963:              List<string> serviceIdExemptionList, ontSipInfoServiceIdWithinAllowedToBeProvisionedOrMigratedSipOltList, voipPstnUserServiceIdWithinAllowedToBeProvisionedOrMigratedSipOltList;
 964:              List<Ia.Ngn.Cl.Model.Business.ServiceOnt> serviceOntList, serviceOntWithinAllowedToBeProvisionedOrMigratedSipOltList;
 965:   
 966:              serviceOntToCreateInEmsOntSipInfoOrVoipPstnUserList = new List<Ia.Ngn.Cl.Model.Business.ServiceOnt>();
 967:              serviceOntToAnnulInEmsOntSipInfoOrVoipPstnUseList = new List<Ia.Ngn.Cl.Model.Business.ServiceOnt>();
 968:   
 969:              serviceOntWithinAllowedToBeProvisionedOrMigratedSipOltList = Ia.Ngn.Cl.Model.Data.Service2.ServiceOntWithinAllowedSipOltToBeProvisionedOrMigratedList;
 970:              serviceOntList = Ia.Ngn.Cl.Model.Data.Service2.ServiceOntList;
 971:              ontSipInfoServiceIdWithinAllowedToBeProvisionedOrMigratedSipOltList = Ia.Ngn.Cl.Model.Data.Huawei.OntSipInfo.ServiceIdWithinAllowedSipOltToBeProvisionedOrMigratedList();
 972:              voipPstnUserServiceIdWithinAllowedToBeProvisionedOrMigratedSipOltList = Ia.Ngn.Cl.Model.Data.Huawei.VoipPstnUser.ServiceIdWithinAllowedSipOltToBeProvisionedOrMigratedList();
 973:   
 974:              foreach (var serviceOnt in serviceOntWithinAllowedToBeProvisionedOrMigratedSipOltList)
 975:              {
 976:                  _serviceId = serviceOnt.ServiceId;
 977:   
 978:                  if (!ontSipInfoServiceIdWithinAllowedToBeProvisionedOrMigratedSipOltList.Contains(_serviceId) && !voipPstnUserServiceIdWithinAllowedToBeProvisionedOrMigratedSipOltList.Contains(_serviceId))
 979:                  {
 980:                      if (!serviceOntToCreateInEmsOntSipInfoOrVoipPstnUserList.Contains(serviceOnt))
 981:                      {
 982:                          serviceOntToCreateInEmsOntSipInfoOrVoipPstnUserList.Add(serviceOnt);
 983:                      }
 984:                  }
 985:              }
 986:   
 987:              // In serviceIdToAnnulInEmsOntSipInfoOrVoipPstnUserList I must make sure that serviceId does not belong to any current service in serviceIdWithinHuaweiSwitchDomainList
 988:              // this is to allow MSAN and POTS to GPON migration without interruption or feedback from the vendor. Any number deleted from IMS will be deleted from U2000.
 989:   
 990:              foreach (var serviceId in ontSipInfoServiceIdWithinAllowedToBeProvisionedOrMigratedSipOltList)
 991:              {
 992:                  if (!serviceOntWithinAllowedToBeProvisionedOrMigratedSipOltList.Any(u => u.ServiceId == serviceId))
 993:                  {
 994:                      if (!serviceOntList.Any(u => u.ServiceId == serviceId))
 995:                      {
 996:                          if (!serviceOntToAnnulInEmsOntSipInfoOrVoipPstnUseList.Any(u => u.ServiceId == serviceId))
 997:                          {
 998:                              serviceOntToAnnulInEmsOntSipInfoOrVoipPstnUseList.Add(new Ia.Ngn.Cl.Model.Business.ServiceOnt { ServiceId = serviceId, CreatedDateTime = DateTime.MinValue });
 999:                          }
1000:                      }
1001:                  }
1002:              }
1003:   
1004:              foreach (var serviceId in voipPstnUserServiceIdWithinAllowedToBeProvisionedOrMigratedSipOltList)
1005:              {
1006:                  if (!serviceOntWithinAllowedToBeProvisionedOrMigratedSipOltList.Any(u => u.ServiceId == serviceId))
1007:                  {
1008:                      if (!serviceOntList.Any(u => u.ServiceId == serviceId))
1009:                      {
1010:                          if (!serviceOntToAnnulInEmsOntSipInfoOrVoipPstnUseList.Any(u => u.ServiceId == serviceId))
1011:                          {
1012:                              serviceOntToAnnulInEmsOntSipInfoOrVoipPstnUseList.Add(new Ia.Ngn.Cl.Model.Business.ServiceOnt { ServiceId = serviceId, CreatedDateTime = DateTime.MinValue });
1013:                          }
1014:                      }
1015:                  }
1016:              }
1017:   
1018:              // will exclude exempt numbers
1019:              serviceIdExemptionList = Ia.Ngn.Cl.Model.Data.Provision.ServiceIdOfServiceExemptFromProvisionProcessingList();
1020:              foreach (string serviceId in serviceIdExemptionList)
1021:              {
1022:                  serviceOnt2 = serviceOntToCreateInEmsOntSipInfoOrVoipPstnUserList.SingleOrDefault(u => u.ServiceId == serviceId);
1023:                  if (serviceOnt2 != null) serviceOntToCreateInEmsOntSipInfoOrVoipPstnUserList.Remove(serviceOnt2);
1024:   
1025:                  serviceOnt2 = serviceOntToAnnulInEmsOntSipInfoOrVoipPstnUseList.SingleOrDefault(u => u.ServiceId == serviceId);
1026:                  if (serviceOnt2 != null) serviceOntToAnnulInEmsOntSipInfoOrVoipPstnUseList.Remove(serviceOnt2);
1027:              }
1028:          }
1029:   
1030:          ////////////////////////////////////////////////////////////////////////////
1031:          ////////////////////////////////////////////////////////////////////////////
1032:   
1033:          /// <summary>
1034:          ///
1035:          /// </summary>
1036:          public static List<string> ServiceSuspendedInServiceRequestServiceButNotInServiceStringNumberList
1037:          {
1038:              get
1039:              {
1040:                  List<string> list, sList, srsList;
1041:                  SortedList sl;
1042:   
1043:                  sList = Ia.Ngn.Cl.Model.Data.Service2.ServiceSuspensionIsTrueStringNumberList;
1044:                  srsList = Ia.Ngn.Cl.Model.Data.ServiceRequestService.ServiceSuspensionIsTrueAndProvisionedIsTrueStringNumberList;
1045:   
1046:                  if (sList != null && sList.Count > 0)
1047:                  {
1048:                      if (srsList != null && srsList.Count > 0)
1049:                      {
1050:                          list = new List<string>(sList.Count);
1051:   
1052:                          sl = new SortedList(sList.ToDictionary(s => s));
1053:   
1054:                          foreach (string s in srsList)
1055:                          {
1056:                              if (!sl.ContainsKey(s)) list.Add(s);
1057:                          }
1058:                      }
1059:                      else
1060:                      {
1061:                          list = new List<string>();
1062:                      }
1063:                  }
1064:                  else
1065:                  {
1066:                      if (srsList != null && srsList.Count > 0) list = sList;
1067:                      else list = new List<string>();
1068:                  }
1069:   
1070:                  return list;
1071:              }
1072:          }
1073:   
1074:          ////////////////////////////////////////////////////////////////////////////
1075:   
1076:          /// <summary>
1077:          ///
1078:          /// </summary>
1079:          public static List<string> ServiceActiveInServiceRequestServiceButNotInServiceStringNumberList
1080:          {
1081:              get
1082:              {
1083:                  List<string> list, sList, srsList;
1084:                  SortedList sl;
1085:   
1086:                  sList = Ia.Ngn.Cl.Model.Data.Service2.ServiceSuspensionIsFalseStringNumberList;
1087:                  srsList = Ia.Ngn.Cl.Model.Data.ServiceRequestService.ServiceSuspensionIsFalseStringNumberList;
1088:   
1089:                  if (sList != null && sList.Count > 0)
1090:                  {
1091:                      if (srsList != null && srsList.Count > 0)
1092:                      {
1093:                          list = new List<string>(sList.Count);
1094:   
1095:                          sl = new SortedList(sList.ToDictionary(s => s));
1096:   
1097:                          foreach (string s in srsList)
1098:                          {
1099:                              if (!sl.ContainsKey(s)) list.Add(s);
1100:                          }
1101:                      }
1102:                      else
1103:                      {
1104:                          list = new List<string>();
1105:                      }
1106:                  }
1107:                  else
1108:                  {
1109:                      if (srsList != null && srsList.Count > 0) list = sList;
1110:                      else list = new List<string>();
1111:                  }
1112:   
1113:                  return list;
1114:              }
1115:          }
1116:   
1117:          ////////////////////////////////////////////////////////////////////////////
1118:   
1119:          /// <summary>
1120:          ///
1121:          /// </summary>
1122:          public static List<Ia.Ngn.Cl.Model.Business.Procedure.Process> EmsOntToBeUpdatedFromH248ToSipList()
1123:          {
1124:              List<string> oltSymbolList;
1125:              List<Ia.Ngn.Cl.Model.Business.Procedure.Process> processList;
1126:   
1127:              processList = new List<Ia.Ngn.Cl.Model.Business.Procedure.Process>();
1128:   
1129:              oltSymbolList = Ia.Ngn.Cl.Model.Business.Default.H248ToSipUpdateOltSymbolList;
1130:   
1131:              var list = Ia.Ngn.Cl.Model.Data.Default.AccessIdNddOntDevFnSnPnOntIdVaprofWhereVaprofIsNotAluSipBForOltSymbolListList(oltSymbolList);
1132:   
1133:              // issue update then read commands
1134:              foreach (var l in list)
1135:              {
1136:                  processList.Add(new Ia.Ngn.Cl.Model.Business.Procedure.Process { Service = l.Service, Ont = l.Ont, Type = Ia.Ngn.Cl.Model.Business.Procedure.ProcessType.Update });
1137:                  processList.Add(new Ia.Ngn.Cl.Model.Business.Procedure.Process { Service = l.Service, Ont = l.Ont, Type = Ia.Ngn.Cl.Model.Business.Procedure.ProcessType.Read });
1138:              }
1139:   
1140:              return processList;
1141:          }
1142:   
1143:          ////////////////////////////////////////////////////////////////////////////
1144:   
1145:          /// <summary>
1146:          ///
1147:          /// </summary>
1148:          public static List<Ia.Ngn.Cl.Model.Business.Procedure.Process> OntSipInfoOrOntVoipPstnUserToBeCreatedForAnOntUpdatedFromH248ToSipList()
1149:          {
1150:              int pn;
1151:              List<string> oltSymbolList;
1152:              List<Ia.Ngn.Cl.Model.Business.Procedure.Process> processList;
1153:   
1154:              processList = new List<Ia.Ngn.Cl.Model.Business.Procedure.Process>();
1155:   
1156:              oltSymbolList = Ia.Ngn.Cl.Model.Business.Default.H248ToSipUpdateOltSymbolList;
1157:   
1158:              var list = Ia.Ngn.Cl.Model.Data.Default.ServiceAndNddOntAndEmsOntFamilyTypeAndPortWhereVaprofIsAluSipBAndAgcfEndpointPortIsNot0AndSfuEmsOntSipInfoTelDoesNotExistOrMduEmsVoipPstnUserPnDoesNotExistForOltSymbolListList(oltSymbolList);
1159:   
1160:              /*
1161:               * All Nokia ONTs (SFUs and MDUs) start at port position 1.
1162:               * Huawei ONTs (SFUs) start at port position 1, while Huawei MDUs start at port position 0.
1163:               */
1164:   
1165:              // issue update then read commands
1166:              foreach (var l in list)
1167:              {
1168:                  if (l.EmsOntFamilyType == Ia.Ngn.Cl.Model.Business.Huawei.Ont.FamilyType.Sfu)
1169:                  {
1170:                      processList.Add(new Ia.Ngn.Cl.Model.Business.Procedure.Process { Service = l.Service, Ont = l.Ont, EmsOntFamilyType = l.EmsOntFamilyType, Port = l.Port, Type = Ia.Ngn.Cl.Model.Business.Procedure.ProcessType.Update });
1171:                      processList.Add(new Ia.Ngn.Cl.Model.Business.Procedure.Process { Service = l.Service, Ont = l.Ont, EmsOntFamilyType = l.EmsOntFamilyType, Port = l.Port, Type = Ia.Ngn.Cl.Model.Business.Procedure.ProcessType.Read });
1172:                  }
1173:                  else if(l.EmsOntFamilyType == Ia.Ngn.Cl.Model.Business.Huawei.Ont.FamilyType.Mdu)
1174:                  {
1175:                      pn = Ia.Ngn.Cl.Model.Business.Service.ConvertFlatTermIdPositionToEmsVoipPstnUsersPn(l.Port);
1176:   
1177:                      processList.Add(new Ia.Ngn.Cl.Model.Business.Procedure.Process { Service = l.Service, Ont = l.Ont, EmsOntFamilyType = l.EmsOntFamilyType, Port = pn, Type = Ia.Ngn.Cl.Model.Business.Procedure.ProcessType.Update });
1178:                      processList.Add(new Ia.Ngn.Cl.Model.Business.Procedure.Process { Service = l.Service, Ont = l.Ont, EmsOntFamilyType = l.EmsOntFamilyType, Port = pn, Type = Ia.Ngn.Cl.Model.Business.Procedure.ProcessType.Read });
1179:                  }
1180:                  else
1181:                  {
1182:                      throw new Exception("EmsOntFamilyType is not concedered. ");
1183:                  }
1184:              }
1185:   
1186:              return processList;
1187:          }
1188:   
1189:          ////////////////////////////////////////////////////////////////////////////
1190:   
1191:          /// <summary>
1192:          ///
1193:          /// </summary>
1194:          public static List<Ia.Ngn.Cl.Model.Business.Procedure.Process> NokiaImsSubscriberToBeUpdatedFromH248ToSipList()
1195:          {
1196:              List<string> oltSymbolList;
1197:              List<Ia.Ngn.Cl.Model.Business.Procedure.Process> processList;
1198:   
1199:              processList = new List<Ia.Ngn.Cl.Model.Business.Procedure.Process>();
1200:   
1201:              oltSymbolList = Ia.Ngn.Cl.Model.Business.Default.H248ToSipUpdateOltSymbolList;
1202:   
1203:              var list = Ia.Ngn.Cl.Model.Data.Default.ServiceAndNddOntWherePrimaryPuidcpeProfileNumberIsNot10AndEmsOntVaprofIsAluSipBAndSfuEmsOntSipInfoTelExistsOrMduEmsVoipPstnUserPnExistsForOltSymbolListList(oltSymbolList);
1204:   
1205:              // issue update then read commands
1206:              foreach (var l in list)
1207:              {
1208:                  processList.Add(new Ia.Ngn.Cl.Model.Business.Procedure.Process { Service = l.Service, Ont = l.Ont, Type = Ia.Ngn.Cl.Model.Business.Procedure.ProcessType.Update });
1209:                  processList.Add(new Ia.Ngn.Cl.Model.Business.Procedure.Process { Service = l.Service, Ont = l.Ont, Type = Ia.Ngn.Cl.Model.Business.Procedure.ProcessType.Read });
1210:              }
1211:   
1212:              return processList;
1213:          }
1214:   
1215:          ////////////////////////////////////////////////////////////////////////////
1216:          ////////////////////////////////////////////////////////////////////////////    
1217:      }
1218:   
1219:      ////////////////////////////////////////////////////////////////////////////
1220:      ////////////////////////////////////////////////////////////////////////////   
1221:  }