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

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:  using System.Text.RegularExpressions;
   7:   
   8:  namespace Ia.Ngn.Cl.Model.Business
   9:  {
  10:      ////////////////////////////////////////////////////////////////////////////
  11:   
  12:      /// <summary publish="true">
  13:      /// Provision support class of Next Generation Network'a (NGN's) business model.
  14:      /// </summary>
  15:      /// 
  16:      /// <remarks> 
  17:      /// Copyright © 2006-2019 Jasem Y. Al-Shamlan (info@ia.com.kw), Integrated Applications - Kuwait. All Rights Reserved.
  18:      ///
  19:      /// 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
  20:      /// the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
  21:      ///
  22:      /// This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
  23:      /// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
  24:      /// 
  25:      /// You should have received a copy of the GNU General Public License along with this library. If not, see http://www.gnu.org/licenses.
  26:      /// 
  27:      /// Copyright notice: This notice may not be removed or altered from any source distribution.
  28:      /// </remarks> 
  29:      public class Provision
  30:      {
  31:          private static int serviceSuspensionQueueOriginalCount;
  32:          private static int sequentialDiscrepancyAndComplementaryServiceMismatchBetweenServiceRequestServiceAndServiceServiceIdQueueOriginalCount;
  33:          private static Queue<string> sequentialDiscrepancyAndComplementaryServiceMismatchBetweenServiceRequestServiceAndServiceServiceIdQueue = new Queue<string>();
  34:          private static Queue<string> serviceSuspensionQueue = new Queue<string>();
  35:   
  36:          ////////////////////////////////////////////////////////////////////////////
  37:   
  38:          /// <summary>
  39:          ///
  40:          /// </summary>
  41:          public Provision() { }
  42:   
  43:          ////////////////////////////////////////////////////////////////////////////
  44:   
  45:          /// <summary>
  46:          ///
  47:          /// </summary>
  48:          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)
  49:          {
  50:              bool executed, isSip;
  51:              int gatewayId;
  52:              string r;
  53:              Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Ont nddOnt;
  54:              Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Vendor switchVendor, accessVendor;
  55:              Ia.Ngn.Cl.Model.Ont ont;
  56:              Ia.Ngn.Cl.Model.Huawei.EmsOnt emsOnt;
  57:   
  58:              executed = false;
  59:              result = string.Empty;
  60:   
  61:              switchVendor = Ia.Ngn.Cl.Model.Data.NetworkDesignDocument.SwitchVendorFromService(service);
  62:   
  63:              if (switchVendor == Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Vendor.Nokia)
  64:              {
  65:                  nddOnt = (from n in Ia.Ngn.Cl.Model.Data.NetworkDesignDocument.OntList where n.Access.Name == accessName select n).SingleOrDefault();
  66:   
  67:                  if (nddOnt != null)
  68:                  {
  69:                      if (Ia.Ngn.Cl.Model.Business.Service.NumberIsWithinAllowedRouterDomainList(nddOnt, service) || ignoreRestrictions)
  70:                      {
  71:                          accessVendor = nddOnt.Pon.PonGroup.Olt.Odf.Vendor;
  72:   
  73:                          if (accessVendor == Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Vendor.Nokia)
  74:                          {
  75:                              ont = Ia.Ngn.Cl.Model.Data.Nokia.Ont.Read(nddOnt.Id);
  76:   
  77:                              if (ont != null)
  78:                              {
  79:                                  if (protocol == Ia.Ngn.Cl.Model.Business.Default.Protocol.DefaultAsInNdd) isSip = nddOnt.Pon.PonGroup.Olt.IsSip;
  80:                                  else isSip = protocol == Ia.Ngn.Cl.Model.Business.Default.Protocol.Sip;
  81:   
  82:                                  if (!isSip) // if H.248
  83:                                  {
  84:                                      gatewayId = Ia.Ngn.Cl.Model.Data.Nokia.AgcfGatewayRecord.GwIdFromIp(nddOnt.Ip);
  85:   
  86:                                      if (gatewayId > 0)
  87:                                      {
  88:                                          port = (port != Ia.Ngn.Cl.Model.Business.Default.PortUndefinedOrInvalidOrUnknown) ? port : Ia.Ngn.Cl.Model.Data.Nokia.Ams.NextVacantFlatTermIdForOnt(ont.FamilyTypeId, ont);
  89:   
  90:                                          if (port != Ia.Ngn.Cl.Model.Business.Default.PortUndefinedOrInvalidOrUnknown)
  91:                                          {
  92:                                              Ia.Ngn.Cl.Model.Data.Nokia.Ims.CreateH248SubscriberAndSubPartyAndAgcfEndpoint(ims, gatewayId, service, port, nddOnt, out r);
  93:                                              result += r + ",";
  94:   
  95:                                              Ia.Ngn.Cl.Model.Data.Nokia.Ims.ReadUpdateAgcfGatewayRecordAndAgcfEndpointListAndSubPartyAndSubscriberAndServiceForGwId(ims, nddOnt, gatewayId, out r);
  96:                                              result += r + ",";
  97:   
  98:                                              executed = true;
  99:                                          }
 100:                                          else
 101:                                          {
 102:                                              result += "port is invalid or does not exist,";
 103:                                          }
 104:                                      }
 105:                                      else
 106:                                      {
 107:                                          result += "gatewayId is invalid or does not exist,";
 108:                                      }
 109:                                  }
 110:                                  else // if IsSip == true
 111:                                  {
 112:   
 113:                                  }
 114:                              }
 115:                              else
 116:                              {
 117:                                  result += "ONT is null for access:" + nddOnt.Access.Name + ",";
 118:                              }
 119:                          }
 120:                          else if (accessVendor == Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Vendor.Huawei)
 121:                          {
 122:                              emsOnt = Ia.Ngn.Cl.Model.Data.Huawei.Ont.Read(nddOnt.Id);
 123:   
 124:                              if (emsOnt != null)
 125:                              {
 126:                                  if (protocol == Ia.Ngn.Cl.Model.Business.Default.Protocol.DefaultAsInNdd) isSip = nddOnt.Pon.PonGroup.Olt.IsSip;
 127:                                  else isSip = protocol == Ia.Ngn.Cl.Model.Business.Default.Protocol.Sip;
 128:   
 129:                                  //onuFamilyType = Ia.Ngn.Cl.Model.Data.Huawei.Default.HuaweiSpecialOnuFamilyTypesForAccessNames(accessName);
 130:                                  // if (flatTermIdOrTelPort == 0) flatTermIdOrTelPort = Ia.Ngn.Cl.Model.Business.Ims.NextVacantFlatTermIdFromAgcfEndpointUsingGwIdForOnu(onuFamilyType, gatewayId);
 131:   
 132:                                  if (!isSip) // if H.248
 133:                                  {
 134:                                      gatewayId = Ia.Ngn.Cl.Model.Data.Nokia.AgcfGatewayRecord.GwIdFromIp(nddOnt.Ip);
 135:   
 136:                                      if (gatewayId > 0)
 137:                                      {
 138:                                          port = (port != Ia.Ngn.Cl.Model.Business.Default.PortUndefinedOrInvalidOrUnknown) ? port : Ia.Ngn.Cl.Model.Data.Default.NextVacantFlatTermIdForHuaweiEmsOntEquipmentTypeIdAndNokiaGatewayId(emsOnt.EquipmentType, gatewayId);
 139:   
 140:                                          if (port != Ia.Ngn.Cl.Model.Business.Default.PortUndefinedOrInvalidOrUnknown)
 141:                                          {
 142:                                              Ia.Ngn.Cl.Model.Data.Nokia.Ims.CreateH248SubscriberAndSubPartyAndAgcfEndpoint(ims, gatewayId, service, port, nddOnt, out r);
 143:                                              result += r + ",";
 144:   
 145:                                              Ia.Ngn.Cl.Model.Data.Nokia.Ims.ReadUpdateAgcfGatewayRecordAndAgcfEndpointListAndSubPartyAndSubscriberAndServiceForGwId(ims, nddOnt, gatewayId, out r);
 146:                                              result += r + ",";
 147:   
 148:                                              executed = true;
 149:                                          }
 150:                                          else
 151:                                          {
 152:                                              result += "port is invalid or does not exist,";
 153:                                          }
 154:                                      }
 155:                                      else
 156:                                      {
 157:                                          result += "gatewayId is invalid or does not exist,";
 158:                                      }
 159:                                  }
 160:                                  else // if IsSip == true
 161:                                  {
 162:                                      Ia.Ngn.Cl.Model.Data.Nokia.Ims.CreateSipSubscriber(ims, service, nddOnt, out r);
 163:                                      result += r + ",";
 164:   
 165:                                      Ia.Ngn.Cl.Model.Data.Nokia.Ims.ReadUpdateSubPartyAndSubscriberAndService(ims, service, nddOnt, out r);
 166:                                      result += r + ",";
 167:   
 168:                                      executed = true;
 169:                                  }
 170:                              }
 171:                              else
 172:                              {
 173:                                  result += "EmsOnt is null, does not exist for access:" + nddOnt.Access.Name + ",";
 174:                              }
 175:                          }
 176:                          else
 177:                          {
 178:                              throw new Exception("accessVendor is unknown. ");
 179:                          }
 180:                      }
 181:                      else
 182:                      {
 183:                          result += "service is not within allowed router domain list. ";
 184:                      }
 185:                  }
 186:                  else
 187:                  {
 188:                      result += "nddOnt is null, does not exist for access:" + accessName + ",";
 189:                  }
 190:              }
 191:              else
 192:              {
 193:                  throw new Exception("switchVendor is null or not Nokia. ");
 194:              }
 195:   
 196:              return executed;
 197:          }
 198:   
 199:          ////////////////////////////////////////////////////////////////////////////
 200:   
 201:          /// <summary>
 202:          ///
 203:          /// </summary>
 204:          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)
 205:          {
 206:              bool executed;
 207:              int gatewayId;
 208:              string r;
 209:              Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Vendor switchVendor, accessVendor;
 210:              Ia.Ngn.Cl.Model.Ont ont;
 211:              Ia.Ngn.Cl.Model.Huawei.EmsOnt emsOnt;
 212:   
 213:              executed = false;
 214:              result = string.Empty;
 215:   
 216:              switchVendor = Ia.Ngn.Cl.Model.Data.NetworkDesignDocument.SwitchVendorFromService(service);
 217:   
 218:              if (switchVendor == Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Vendor.Nokia)
 219:              {
 220:                  if (nddOnt != null)
 221:                  {
 222:                      if (Ia.Ngn.Cl.Model.Business.Service.NumberIsWithinAllowedRouterDomainList(nddOnt, service))
 223:                      {
 224:                          accessVendor = nddOnt.Pon.PonGroup.Olt.Odf.Vendor;
 225:   
 226:                          if (accessVendor == Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Vendor.Nokia)
 227:                          {
 228:                              ont = Ia.Ngn.Cl.Model.Data.Nokia.Ont.Read(nddOnt.Id);
 229:   
 230:                              if (ont != null)
 231:                              {
 232:                                  if (nddOnt.Pon.PonGroup.Olt.IsSip == false) // if H.248
 233:                                  {
 234:                                      gatewayId = Ia.Ngn.Cl.Model.Data.Nokia.AgcfGatewayRecord.GwIdFromIp(nddOnt.Ip);
 235:   
 236:                                      if (gatewayId > 0)
 237:                                      {
 238:                                          //Ia.Ngn.Cl.Model.Data.Nokia.Ims.Modify248SubscriberAndSubPartyAndAgcfEndpointToSip(ims, gatewayId, service, nddOnt, out r);
 239:                                          //result += r + ",";
 240:   
 241:                                          Ia.Ngn.Cl.Model.Data.Nokia.Ims.ReadUpdateAgcfGatewayRecordAndAgcfEndpointListAndSubPartyAndSubscriberAndServiceForGwId(ims, nddOnt, gatewayId, out r);
 242:                                          result += r + ",";
 243:   
 244:                                          executed = true;
 245:                                      }
 246:                                      else
 247:                                      {
 248:                                          result += "gatewayId is invalid or does not exist,";
 249:                                      }
 250:                                  }
 251:                                  else // if IsSip == true
 252:                                  {
 253:                                      result += "error: OLT is already SIP,";
 254:                                  }
 255:                              }
 256:                              else
 257:                              {
 258:                                  result += "ONT is null for access:" + nddOnt.Access.Name + ",";
 259:                              }
 260:                          }
 261:                          else if (accessVendor == Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Vendor.Huawei)
 262:                          {
 263:                              emsOnt = Ia.Ngn.Cl.Model.Data.Huawei.Ont.Read(nddOnt.Id);
 264:   
 265:                              if (emsOnt != null)
 266:                              {
 267:                                  if (nddOnt.Pon.PonGroup.Olt.IsSip == false) // if H.248
 268:                                  {
 269:                                      gatewayId = Ia.Ngn.Cl.Model.Data.Nokia.AgcfGatewayRecord.GwIdFromIp(nddOnt.Ip);
 270:   
 271:                                      if (gatewayId > 0)
 272:                                      {
 273:                                          Ia.Ngn.Cl.Model.Data.Nokia.Ims.Modify248SubscriberAndSubPartyAndDeleteAgcfEndpointToSip(ims, service, nddOnt, out r);
 274:                                          result += r + ",";
 275:   
 276:                                          Ia.Ngn.Cl.Model.Data.Nokia.Ims.ReadUpdateAgcfGatewayRecordAndAgcfEndpointListAndSubPartyAndSubscriberAndServiceForGwId(ims, nddOnt, gatewayId, out r);
 277:                                          result += r + ",";
 278:   
 279:                                          executed = true;
 280:                                      }
 281:                                      else
 282:                                      {
 283:                                          result += "gatewayId is invalid or does not exist,";
 284:                                      }
 285:                                  }
 286:                                  else // if IsSip == true
 287:                                  {
 288:                                      result += "error: OLT is already SIP,";
 289:                                  }
 290:                              }
 291:                              else
 292:                              {
 293:                                  result += "EmsOnt is null, does not exist for access:" + nddOnt.Access.Name + ",";
 294:                              }
 295:                          }
 296:                          else
 297:                          {
 298:                              throw new Exception("accessVendor is unknown. ");
 299:                          }
 300:                      }
 301:                      else
 302:                      {
 303:                          result += "service is not within allowed router domain list. ";
 304:                      }
 305:                  }
 306:                  else
 307:                  {
 308:                      result += "nddOnt is null,";
 309:                  }
 310:              }
 311:              else
 312:              {
 313:                  throw new Exception("switchVendor is null or not Nokia. ");
 314:              }
 315:   
 316:              return executed;
 317:          }
 318:   
 319:          ////////////////////////////////////////////////////////////////////////////
 320:   
 321:          /// <summary>
 322:          ///
 323:          /// </summary>
 324:          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)
 325:          {
 326:              bool executed, isSip;
 327:              int gatewayId;
 328:              string r;
 329:              Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Ont nddOnt;
 330:              Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Vendor switchVendor, accessVendor;
 331:              Ia.Ngn.Cl.Model.Ont ont;
 332:   
 333:              executed = false;
 334:              result = string.Empty;
 335:   
 336:              switchVendor = Ia.Ngn.Cl.Model.Data.NetworkDesignDocument.SwitchVendorFromService(service);
 337:   
 338:              if (switchVendor == Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Vendor.Nokia)
 339:              {
 340:                  nddOnt = (from n in Ia.Ngn.Cl.Model.Data.NetworkDesignDocument.OntList where n.Access.Name == accessName select n).SingleOrDefault();
 341:   
 342:                  if (nddOnt != null)
 343:                  {
 344:                      if (Ia.Ngn.Cl.Model.Business.Service.NumberIsWithinAllowedRouterDomainList(nddOnt, service) || ignoreRestrictions)
 345:                      {
 346:                          accessVendor = nddOnt.Pon.PonGroup.Olt.Odf.Vendor;
 347:   
 348:                          if (accessVendor == Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Vendor.Nokia)
 349:                          {
 350:                              ont = Ia.Ngn.Cl.Model.Data.Nokia.Ont.Read(nddOnt.Id);
 351:   
 352:                              if (ont != null)
 353:                              {
 354:                                  if (protocol == Ia.Ngn.Cl.Model.Business.Default.Protocol.DefaultAsInNdd) isSip = nddOnt.Pon.PonGroup.Olt.IsSip;
 355:                                  else isSip = protocol == Ia.Ngn.Cl.Model.Business.Default.Protocol.Sip;
 356:   
 357:                                  if (!isSip) // if H.248
 358:                                  {
 359:                                      gatewayId = Ia.Ngn.Cl.Model.Data.Nokia.AgcfGatewayRecord.GwIdFromIp(nddOnt.Ip);
 360:   
 361:                                      if (gatewayId > 0)
 362:                                      {
 363:                                          Ia.Ngn.Cl.Model.Data.Nokia.Ims.DeleteAgcfEndpointAndH248SubscriberAndSubParty(ims, service, nddOnt, out r);
 364:                                          result += r + ",";
 365:   
 366:                                          Ia.Ngn.Cl.Model.Data.Nokia.Ims.ReadUpdateAgcfGatewayRecordAndAgcfEndpointListAndSubPartyAndSubscriberAndServiceForGwId(ims, nddOnt, gatewayId, out r);
 367:                                          result += r + ",";
 368:   
 369:                                          executed = true;
 370:                                      }
 371:                                      else
 372:                                      {
 373:                                          result += "gatewayId is invalid or does not exist,";
 374:                                      }
 375:                                  }
 376:                                  else // if IsSip == true
 377:                                  {
 378:   
 379:                                  }
 380:                              }
 381:                              else
 382:                              {
 383:                                  result += "ont is null for access:" + nddOnt.Access.Name + ",";
 384:                              }
 385:                          }
 386:                          else if (accessVendor == Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Vendor.Huawei)
 387:                          {
 388:                              if (protocol == Ia.Ngn.Cl.Model.Business.Default.Protocol.DefaultAsInNdd) isSip = nddOnt.Pon.PonGroup.Olt.IsSip;
 389:                              else isSip = protocol == Ia.Ngn.Cl.Model.Business.Default.Protocol.Sip;
 390:   
 391:                              if (!isSip) // if H.248
 392:                              {
 393:                                  gatewayId = Ia.Ngn.Cl.Model.Data.Nokia.AgcfGatewayRecord.GwIdFromIp(nddOnt.Ip);
 394:   
 395:                                  if (gatewayId > 0)
 396:                                  {
 397:                                      Ia.Ngn.Cl.Model.Data.Nokia.Ims.DeleteAgcfEndpointAndH248SubscriberAndSubParty(ims, service, nddOnt, out r);
 398:                                      result += r + ",";
 399:   
 400:                                      Ia.Ngn.Cl.Model.Data.Nokia.Ims.ReadUpdateAgcfGatewayRecordAndAgcfEndpointListAndSubPartyAndSubscriberAndServiceForGwId(ims, nddOnt, gatewayId, out r);
 401:                                      result += r + ",";
 402:   
 403:                                      executed = true;
 404:                                  }
 405:                                  else
 406:                                  {
 407:                                      result += "gatewayId is invalid or does not exist,";
 408:                                  }
 409:                              }
 410:                              else // if IsSip == true
 411:                              {
 412:                                  Ia.Ngn.Cl.Model.Data.Nokia.Ims.DeleteSipSubscriber(ims, service, nddOnt, out r);
 413:                                  result += r + ",";
 414:   
 415:                                  Ia.Ngn.Cl.Model.Data.Nokia.Ims.ReadUpdateSubPartyAndSubscriberAndService(ims, service, nddOnt, out r);
 416:                                  result += r + ",";
 417:                              }
 418:                          }
 419:                          else
 420:                          {
 421:                              throw new Exception("accessVendor is unknown. ");
 422:                          }
 423:                      }
 424:                      else
 425:                      {
 426:                          result += "service is not within allowed router domain list. ";
 427:                      }
 428:                  }
 429:                  else
 430:                  {
 431:                      result += "nddOnt is null, does not exist for access:" + accessName + ",";
 432:                  }
 433:              }
 434:              else
 435:              {
 436:                  throw new Exception("switchVendor is null or not Nokia. ");
 437:              }
 438:   
 439:              return executed;
 440:          }
 441:   
 442:          ////////////////////////////////////////////////////////////////////////////
 443:   
 444:          /// <summary>
 445:          ///
 446:          /// </summary>
 447:          public static bool DeleteNokiaSwitchAgcfEndpointAndH248SubscriberAndIgnoreAccess(Ia.Ngn.Cl.Model.Client.Nokia.Ims ims, int gatewayId, string service, bool ignoreRestrictions, out string result)
 448:          {
 449:              bool executed;
 450:              string ip;
 451:              Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Ont nddOnt;
 452:              Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Vendor switchVendor;
 453:   
 454:              executed = false;
 455:              result = string.Empty;
 456:   
 457:              switchVendor = Ia.Ngn.Cl.Model.Data.NetworkDesignDocument.SwitchVendorFromService(service);
 458:   
 459:              if (switchVendor == Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Vendor.Nokia)
 460:              {
 461:                  ip = Ia.Ngn.Cl.Model.Data.Nokia.AgcfGatewayRecord.IpFromGatewayId(gatewayId);
 462:   
 463:                  if (!string.IsNullOrEmpty(ip))
 464:                  {
 465:                      //nddOnt = (from o in Ia.Ngn.Cl.Model.Data.NetworkDesignDocument.OntList where o.Ip == ip select o).SingleOrDefault();
 466:                      nddOnt = Ia.Ngn.Cl.Model.Data.NetworkDesignDocument.OntIpToOntDictionary.ContainsKey(ip) ? Ia.Ngn.Cl.Model.Data.NetworkDesignDocument.OntIpToOntDictionary[ip] : null;
 467:   
 468:                      if (nddOnt != null)
 469:                      {
 470:                          if (Ia.Ngn.Cl.Model.Business.Service.NumberIsWithinAllowedRouterDomainList(nddOnt, service) || ignoreRestrictions)
 471:                          {
 472:                              Ia.Ngn.Cl.Model.Data.Nokia.Ims.DeleteAgcfEndpointAndH248SubscriberAndSubParty(ims, service, nddOnt, out string r);
 473:                              result += r + ",";
 474:   
 475:                              Ia.Ngn.Cl.Model.Data.Nokia.Ims.ReadUpdateAgcfGatewayRecordAndAgcfEndpointListAndSubPartyAndSubscriberAndServiceForGwId(ims, nddOnt, gatewayId, out r);
 476:                              result += r + ",";
 477:   
 478:                              executed = true;
 479:                          }
 480:                          else
 481:                          {
 482:                              result += "service is not within allowed router domain list. ";
 483:                          }
 484:                      }
 485:                      else
 486:                      {
 487:                          result += "nddOnt is null, does not exist for ip:" + ip + ",";
 488:                      }
 489:                  }
 490:                  else
 491:                  {
 492:                      result += "For gatewayId: " + gatewayId + " ip is null or empty,";
 493:                  }
 494:              }
 495:              else
 496:              {
 497:                  throw new Exception("switchVendor is null or not Nokia. ");
 498:              }
 499:   
 500:              return executed;
 501:          }
 502:   
 503:          ////////////////////////////////////////////////////////////////////////////
 504:   
 505:          /// <summary>
 506:          ///
 507:          /// </summary>
 508:          public static bool DeleteNokiaSwitchAgcfEndpointAndH248SubscriberFromAnyFsdb(Ia.Ngn.Cl.Model.Client.Nokia.Ims ims, string service, out string result)
 509:          {
 510:              bool executed;
 511:              Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Vendor switchVendor;
 512:   
 513:              executed = false;
 514:              result = string.Empty;
 515:   
 516:              switchVendor = Ia.Ngn.Cl.Model.Data.NetworkDesignDocument.SwitchVendorFromService(service);
 517:   
 518:              if (switchVendor == Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Vendor.Nokia)
 519:              {
 520:                  if (!string.IsNullOrEmpty(service))
 521:                  {
 522:                      if (Ia.Ngn.Cl.Model.Business.Service.NumberIsWithinAllowedNokiaSwitchDomainList(service))
 523:                      {
 524:                          foreach (Ia.Ngn.Cl.Model.Business.Nokia.Ims.ImsBasicService ibs in Ia.Ngn.Cl.Model.Business.Nokia.Ims.ImsBasicServiceList)
 525:                          {
 526:                              Ia.Ngn.Cl.Model.Data.Nokia.Ims.DeleteAgcfEndpointAndH248SubscriberAndSubParty(ims, service, ibs.PrimarySwitch, ibs.Fsdb, out string r);
 527:                              result += r + ",";
 528:   
 529:                              Ia.Ngn.Cl.Model.Data.Nokia.Ims.ReadSubPartyAndSubscriber(ims, service, ibs.PrimarySwitch, ibs.Fsdb, ibs.Service, out r);
 530:                              result += r + ",";
 531:                          }
 532:   
 533:                          executed = true;
 534:                      }
 535:                      else result += "Error: service number does not belong to a valid Nokia switch. ";
 536:                  }
 537:                  else
 538:                  {
 539:                      result += "Error: service null or empty. ";
 540:                  }
 541:              }
 542:              else
 543:              {
 544:                  result += "Error: switchVendor is null or not Nokia. ";
 545:              }
 546:   
 547:              return executed;
 548:          }
 549:   
 550:          ////////////////////////////////////////////////////////////////////////////
 551:          ////////////////////////////////////////////////////////////////////////////
 552:   
 553:          /// <summary>
 554:          ///
 555:          /// </summary>
 556:          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)
 557:          {
 558:              bool executed, created, isSip;
 559:              string r;
 560:              Ia.Ngn.Cl.Model.Business.Huawei.Default.FnSnPn fnSnPn;
 561:              Ia.Ngn.Cl.Model.Business.Huawei.Dev.MduDev mdu;
 562:              Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Ont nddOnt;
 563:              Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Vendor switchVendor, accessVendor;
 564:              Ia.Ngn.Cl.Model.Huawei.EmsOnt emsOnt;
 565:              Ia.Ngn.Cl.Model.Ont ont;
 566:   
 567:              executed = false;
 568:              result = string.Empty;
 569:   
 570:              switchVendor = Ia.Ngn.Cl.Model.Data.NetworkDesignDocument.SwitchVendorFromService(service);
 571:   
 572:              if (switchVendor == Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Vendor.Huawei)
 573:              {
 574:                  nddOnt = (from n in Ia.Ngn.Cl.Model.Data.NetworkDesignDocument.OntList where n.Access.Name == accessName select n).SingleOrDefault();
 575:   
 576:                  if (nddOnt != null)
 577:                  {
 578:                      if (Ia.Ngn.Cl.Model.Business.Service.NumberIsWithinAllowedRouterDomainList(nddOnt, service) || ignoreRestrictions)
 579:                      {
 580:                          accessVendor = nddOnt.Pon.PonGroup.Olt.Odf.Vendor;
 581:   
 582:                          if (accessVendor == Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Vendor.Nokia)
 583:                          {
 584:                              ont = Ia.Ngn.Cl.Model.Data.Nokia.Ont.Read(nddOnt.Id);
 585:   
 586:                              if (ont != null)
 587:                              {
 588:                                  port = (port != Ia.Ngn.Cl.Model.Business.Default.PortUndefinedOrInvalidOrUnknown) ? port : Ia.Ngn.Cl.Model.Data.Nokia.Ams.NextVacantFlatTermIdForOnt(ont.FamilyTypeId, ont);
 589:   
 590:                                  if (port != Ia.Ngn.Cl.Model.Business.Default.PortUndefinedOrInvalidOrUnknown)
 591:                                  {
 592:                                      Ia.Ngn.Cl.Model.Data.Huawei.Ims.CreateSubscriber(ims, service, out r);
 593:                                      result += r + ",";
 594:   
 595:                                      Ia.Ngn.Cl.Model.Business.Huawei.Ims.ReadSbrForService(ims, service, out r);
 596:                                      result += r + ",";
 597:   
 598:                                      // other commands will be issued through NCE NBI to configure H.248 in SKB and TEC softswitch
 599:   
 600:                                      executed = true;
 601:                                  }
 602:                                  else
 603:                                  {
 604:                                      result += "Port is invalid or does not exist,";
 605:                                  }
 606:                              }
 607:                              else
 608:                              {
 609:                                  result += "Ont is null, does not exist for access:" + nddOnt.Access.Name + ",";
 610:                              }
 611:                          }
 612:                          else if (accessVendor == Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Vendor.Huawei)
 613:                          {
 614:                              emsOnt = Ia.Ngn.Cl.Model.Data.Huawei.Ont.Read(nddOnt.Id);
 615:   
 616:                              if (emsOnt != null)
 617:                              {
 618:                                  if (protocol == Ia.Ngn.Cl.Model.Business.Default.Protocol.DefaultAsInNdd) isSip = nddOnt.Pon.PonGroup.Olt.IsSip;
 619:                                  else isSip = protocol == Ia.Ngn.Cl.Model.Business.Default.Protocol.Sip;
 620:   
 621:                                  if (!isSip) // if H.248
 622:                                  {
 623:                                      result += "No procedure defined for an H.248 non-SIP Huawei-Huawei IMS-GPON setting,";
 624:                                  }
 625:                                  else // if IsSip == true
 626:                                  {
 627:                                      if (emsOnt.FamilyType == Ia.Ngn.Cl.Model.Business.Huawei.Ont.FamilyType.Mdu)
 628:                                      {
 629:                                          if (Ia.Ngn.Cl.Model.Data.Huawei.Default.AccessNameToMduDevDictionary.ContainsKey(nddOnt.Access.Name))
 630:                                          {
 631:                                              var pn = port;
 632:   
 633:                                              mdu = Ia.Ngn.Cl.Model.Data.Huawei.Default.AccessNameToMduDevDictionary[nddOnt.Access.Name];
 634:   
 635:                                              var vacantFnSnPnList = Ia.Ngn.Cl.Model.Data.Huawei.Ems.VacantMduFnSnPnForOntList(mdu, emsOnt);
 636:   
 637:                                              if (pn != Ia.Ngn.Cl.Model.Business.Default.PortUndefinedOrInvalidOrUnknown) fnSnPn = vacantFnSnPnList.Where(f => f.Pn == pn).SingleOrDefault();
 638:                                              else fnSnPn = Ia.Ngn.Cl.Model.Data.Huawei.Ems.NextVacantMduFnSnPnForOnt(mdu, emsOnt);
 639:   
 640:                                              if (fnSnPn != null)
 641:                                              {
 642:                                                  port = (port < 0) ? fnSnPn.Pn : port;
 643:   
 644:                                                  created = Ia.Ngn.Cl.Model.Data.Huawei.Ims.CreateSubscriber(ims, service, out r);
 645:   
 646:                                                  result += r + ",";
 647:                                              }
 648:                                              else result += "MDU sn and/or tel is invalid or does not exist. ";
 649:                                          }
 650:                                          else
 651:                                          {
 652:                                              result += "emsOnt.FamilyType == Mdu but MduDictionary does not contain key: " + nddOnt.Access.Name + " for service: " + service + ", and access: " + nddOnt.Access.Name;
 653:                                          }
 654:                                      }
 655:                                      else // if not MDU
 656:                                      {
 657:                                          port = (port != Ia.Ngn.Cl.Model.Business.Default.PortUndefinedOrInvalidOrUnknown) ? port : Ia.Ngn.Cl.Model.Data.Huawei.Ems.NextVacantTelForOnt(emsOnt);
 658:   
 659:                                          if (port != Ia.Ngn.Cl.Model.Business.Default.PortUndefinedOrInvalidOrUnknown)
 660:                                          {
 661:                                              created = Ia.Ngn.Cl.Model.Data.Huawei.Ims.CreateSubscriber(ims, service, out r);
 662:   
 663:                                              result += r + ",";
 664:                                          }
 665:                                          else
 666:                                          {
 667:                                              result += "Port is invalid or does not exist,";
 668:                                          }
 669:                                      }
 670:                                  }
 671:                              }
 672:                              else
 673:                              {
 674:                                  result += "emsOnt is null, does not exist for access:" + nddOnt.Access.Name + ",";
 675:                              }
 676:   
 677:                              Ia.Ngn.Cl.Model.Business.Huawei.Ims.ReadUpdateSbrAndServiceForService(ims, service, nddOnt, out r);
 678:                              result += r + ",";
 679:                          }
 680:                          else
 681:                          {
 682:                              throw new Exception("accessVendor is unknown. ");
 683:                          }
 684:                      }
 685:                      else
 686:                      {
 687:                          result += "service is not within allowed router domain list. ";
 688:                      }
 689:                  }
 690:                  else
 691:                  {
 692:                      result += "nddOnt is null, does not exist for access:" + accessName + ",";
 693:                  }
 694:              }
 695:              else
 696:              {
 697:                  throw new Exception("switchVendor is null or not Huawei. ");
 698:              }
 699:   
 700:              return executed;
 701:          }
 702:   
 703:          ////////////////////////////////////////////////////////////////////////////
 704:   
 705:          /// <summary>
 706:          ///
 707:          /// </summary>
 708:          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)
 709:          {
 710:              bool executed, isSip;
 711:              string r;
 712:              Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Ont nddOnt;
 713:              Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Vendor switchVendor, accessVendor;
 714:              Ia.Ngn.Cl.Model.Ont ont;
 715:   
 716:              executed = false;
 717:              result = string.Empty;
 718:   
 719:              switchVendor = Ia.Ngn.Cl.Model.Data.NetworkDesignDocument.SwitchVendorFromService(service);
 720:   
 721:              if (switchVendor == Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Vendor.Huawei)
 722:              {
 723:                  nddOnt = (from n in Ia.Ngn.Cl.Model.Data.NetworkDesignDocument.OntList where n.Access.Name == accessName select n).SingleOrDefault();
 724:   
 725:                  if (nddOnt != null)
 726:                  {
 727:                      if (Ia.Ngn.Cl.Model.Business.Service.NumberIsWithinAllowedRouterDomainList(nddOnt, service) || ignoreRestrictions)
 728:                      {
 729:                          accessVendor = nddOnt.Pon.PonGroup.Olt.Odf.Vendor;
 730:   
 731:                          if (accessVendor == Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Vendor.Nokia)
 732:                          {
 733:                              ont = Ia.Ngn.Cl.Model.Data.Nokia.Ont.Read(nddOnt.Id);
 734:   
 735:                              if (ont != null)
 736:                              {
 737:                                  Ia.Ngn.Cl.Model.Data.Huawei.Ims.DeleteSubscriber(ims, service, out r);
 738:                                  result += r + ",";
 739:   
 740:                                  Ia.Ngn.Cl.Model.Business.Huawei.Ims.ReadUpdateSbrAndServiceForService(ims, service, nddOnt, out r);
 741:                                  result += r + ",";
 742:   
 743:                                  // other commands will be issued through NCE NBI to configure H.248 in SKB and TEC softswitch
 744:                              }
 745:                              else
 746:                              {
 747:                                  result += "ont is null,";
 748:                              }
 749:                          }
 750:                          else if (accessVendor == Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Vendor.Huawei)
 751:                          {
 752:                              Ia.Ngn.Cl.Model.Data.Huawei.Ims.DeleteSubscriber(ims, service, out r);
 753:                              result += r + ",";
 754:   
 755:                              Ia.Ngn.Cl.Model.Business.Huawei.Ims.ReadUpdateSbrAndServiceForService(ims, service, nddOnt, out r);
 756:                              result += r + ",";
 757:                          }
 758:                          else
 759:                          {
 760:                              throw new Exception("accessVendor is unknown. ");
 761:                          }
 762:                      }
 763:                      else
 764:                      {
 765:                          result += "service is not within allowed router domain list. ";
 766:                      }
 767:                  }
 768:                  else
 769:                  {
 770:                      result += "nddOnt is null, does not exist for access:" + accessName + ",";
 771:                  }
 772:              }
 773:              else
 774:              {
 775:                  throw new Exception("switchVendor is null or not Huawei. ");
 776:              }
 777:   
 778:              return executed;
 779:          }
 780:   
 781:          ////////////////////////////////////////////////////////////////////////////
 782:          ////////////////////////////////////////////////////////////////////////////
 783:   
 784:          /// <summary>
 785:          ///
 786:          /// </summary>
 787:          public static string SequentialServiceSuspensionMismatchBetweenServiceRequestServiceAndServiceServiceIdList(out int serviceSuspensionQueueCount, out string result)
 788:          {
 789:              string service;
 790:   
 791:              if (serviceSuspensionQueue.Count == 0)
 792:              {
 793:                  serviceSuspensionQueue = new Queue<string>(Ia.Ngn.Cl.Model.Data.Provision.ServiceSuspensionMismatchBetweenServiceRequestServiceAndServiceServiceIdList());
 794:   
 795:                  serviceSuspensionQueueOriginalCount = serviceSuspensionQueue.Count;
 796:              }
 797:   
 798:              if (serviceSuspensionQueue.Count > 0) service = serviceSuspensionQueue.Dequeue();
 799:              else service = null;
 800:   
 801:              result = "(" + serviceSuspensionQueue.Count + "/" + serviceSuspensionQueueOriginalCount + ") ";
 802:   
 803:              serviceSuspensionQueueCount = serviceSuspensionQueue.Count;
 804:   
 805:              return service;
 806:          }
 807:   
 808:          ////////////////////////////////////////////////////////////////////////////
 809:   
 810:          /// <summary>
 811:          ///
 812:          /// </summary>
 813:          public static string SequentialDiscrepancyAndComplementaryServiceMismatchBetweenServiceRequestServiceAndServiceListItem(int provisionWithinLastNDays, out int sequentialDiscrepancyAndComplementaryServiceMismatchBetweenServiceRequestServiceAndServiceServiceIdQueueCount, out string progressCounterString)
 814:          {
 815:              string service;
 816:   
 817:              if (sequentialDiscrepancyAndComplementaryServiceMismatchBetweenServiceRequestServiceAndServiceServiceIdQueue.Count == 0)
 818:              {
 819:                  sequentialDiscrepancyAndComplementaryServiceMismatchBetweenServiceRequestServiceAndServiceServiceIdQueue = new Queue<string>(DiscrepancyAndComplementaryServiceMismatchBetweenServiceRequestServiceAndServiceServiceIdList(provisionWithinLastNDays).Keys.ToList());
 820:   
 821:                  sequentialDiscrepancyAndComplementaryServiceMismatchBetweenServiceRequestServiceAndServiceServiceIdQueueOriginalCount = sequentialDiscrepancyAndComplementaryServiceMismatchBetweenServiceRequestServiceAndServiceServiceIdQueue.Count;
 822:              }
 823:   
 824:              if (sequentialDiscrepancyAndComplementaryServiceMismatchBetweenServiceRequestServiceAndServiceServiceIdQueue.Count > 0) service = sequentialDiscrepancyAndComplementaryServiceMismatchBetweenServiceRequestServiceAndServiceServiceIdQueue.Dequeue();
 825:              else service = null;
 826:   
 827:              progressCounterString = "(" + sequentialDiscrepancyAndComplementaryServiceMismatchBetweenServiceRequestServiceAndServiceServiceIdQueue.Count + "/" + sequentialDiscrepancyAndComplementaryServiceMismatchBetweenServiceRequestServiceAndServiceServiceIdQueueOriginalCount + ")";
 828:   
 829:              sequentialDiscrepancyAndComplementaryServiceMismatchBetweenServiceRequestServiceAndServiceServiceIdQueueCount = sequentialDiscrepancyAndComplementaryServiceMismatchBetweenServiceRequestServiceAndServiceServiceIdQueue.Count;
 830:   
 831:              return service;
 832:          }
 833:   
 834:          ////////////////////////////////////////////////////////////////////////////
 835:   
 836:          /// <summary>
 837:          ///
 838:          /// </summary>
 839:          public static Dictionary<string, string> DiscrepancyAndComplementaryServiceMismatchBetweenServiceRequestServiceAndServiceServiceIdList(int provisionWithinLastNDays)
 840:          {
 841:              Dictionary<string, string> dictionary;
 842:   
 843:              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);
 844:   
 845:              dictionary = new Dictionary<string, string>(serviceToUpdateIdAccessIdDictionary.Count + serviceToCreateServiceIdAccessIdDictionary.Count + serviceToDeleteServiceIdAccessIdDictionary.Count);
 846:   
 847:              foreach (KeyValuePair<string, string> s in serviceToUpdateIdAccessIdDictionary) dictionary.Add(s.Key, s.Value);
 848:              foreach (KeyValuePair<string, string> s in serviceToCreateServiceIdAccessIdDictionary) dictionary.Add(s.Key, s.Value);
 849:              foreach (KeyValuePair<string, string> s in serviceToDeleteServiceIdAccessIdDictionary) dictionary.Add(s.Key, s.Value);
 850:   
 851:              return dictionary;
 852:          }
 853:   
 854:          ////////////////////////////////////////////////////////////////////////////
 855:   
 856:          /// <summary>
 857:          ///
 858:          /// </summary>
 859:          public static List<Ia.Ngn.Cl.Model.Business.Procedure.Process> ServiceOntToCreateAndToDeleteInEmsOntSipInfoOrVoipPstnUserListFromThePastNHourList(int provisioningWithinPastNHours)
 860:          {
 861:              DateTime pastNHoursDateTime;
 862:              List<Ia.Ngn.Cl.Model.Business.Procedure.Process> processList, laterProcessList;
 863:   
 864:              processList = new List<Ia.Ngn.Cl.Model.Business.Procedure.Process>();
 865:              laterProcessList = new List<Ia.Ngn.Cl.Model.Business.Procedure.Process>();
 866:   
 867:              pastNHoursDateTime = (provisioningWithinPastNHours > 0) ? DateTime.UtcNow.AddHours(3).AddHours(-provisioningWithinPastNHours) : DateTime.MinValue;
 868:   
 869:              Ia.Ngn.Cl.Model.Business.Provision.ServiceOntToCreateInEmsOntSipInfoOrVoipPstnUserList_ServiceOntToAnnulInEmsOntSipInfoOrVoipPstnUserList(out List<Ia.Ngn.Cl.Model.Business.ServiceOnt> serviceOntToCreateInEmsOntSipInfoOrVoipPstnUserList, out List<Ia.Ngn.Cl.Model.Business.ServiceOnt> serviceOntToAnnulInEmsOntSipInfoOrVoipPstnUseList);
 870:   
 871:              // issue read, execute, then read again commands
 872:              foreach (var serviceOnt in serviceOntToCreateInEmsOntSipInfoOrVoipPstnUserList)
 873:              {
 874:                  if (serviceOnt.CreatedDateTime >= pastNHoursDateTime)
 875:                  {
 876:                      var p = 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 };
 877:                      processList.Add(p);
 878:   
 879:                      p = 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 };
 880:                      processList.Add(p);
 881:                      laterProcessList.Add(p);
 882:                  }
 883:              }
 884:   
 885:              foreach (var serviceOnt in serviceOntToAnnulInEmsOntSipInfoOrVoipPstnUseList)
 886:              {
 887:                  if (serviceOnt.CreatedDateTime >= pastNHoursDateTime)
 888:                  {
 889:                      var p = 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 };
 890:                      processList.Add(p);
 891:   
 892:                      p = 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 };
 893:                      processList.Add(p);
 894:                      laterProcessList.Add(p);
 895:                  }
 896:              }
 897:   
 898:              processList = processList.OrderByDescending(l => l.DateTime).ToList();
 899:   
 900:              processList.AddRange(laterProcessList);
 901:   
 902:              return processList;
 903:          }
 904:   
 905:          ////////////////////////////////////////////////////////////////////////////
 906:   
 907:          /// <summary>
 908:          ///
 909:          /// </summary>
 910:          public static List<Ia.Ngn.Cl.Model.Business.Procedure.Process> ServiceOntToAddAndToRemoveInAsbrList()
 911:          {
 912:              List<Ia.Ngn.Cl.Model.Business.Procedure.Process> processList;
 913:   
 914:              processList = new List<Ia.Ngn.Cl.Model.Business.Procedure.Process>();
 915:   
 916:              Ia.Ngn.Cl.Model.Business.Provision.ServiceOntToAddToAsbrList_ServiceOntToRemoveFromAsbrList(out List<Ia.Ngn.Cl.Model.Business.ServiceOnt> serviceOntToAddToAsbrList, out List<Ia.Ngn.Cl.Model.Business.ServiceOnt> serviceOntToRemoveFromAsbrList);
 917:   
 918:              // issue read, execute, then read again commands
 919:              foreach (var serviceOnt in serviceOntToAddToAsbrList)
 920:              {
 921:                  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 });
 922:                  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 });
 923:              }
 924:   
 925:              foreach (var serviceOnt in serviceOntToRemoveFromAsbrList)
 926:              {
 927:                  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 });
 928:                  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 });
 929:              }
 930:   
 931:              return processList;
 932:          }
 933:   
 934:          ////////////////////////////////////////////////////////////////////////////
 935:   
 936:          /// <summary>
 937:          /// 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.
 938:          /// </summary>
 939:          private static void ServiceOntToCreateInEmsOntSipInfoOrVoipPstnUserList_ServiceOntToAnnulInEmsOntSipInfoOrVoipPstnUserList(out List<Ia.Ngn.Cl.Model.Business.ServiceOnt> serviceOntToCreateInEmsOntSipInfoOrVoipPstnUserList, out List<Ia.Ngn.Cl.Model.Business.ServiceOnt> serviceOntToAnnulInEmsOntSipInfoOrVoipPstnUseList)
 940:          {
 941:              Ia.Ngn.Cl.Model.Business.ServiceOnt serviceOnt2;
 942:              List<string> serviceIdExemptionList;
 943:              List<Ia.Ngn.Cl.Model.Business.ServiceOnt> serviceOntList, serviceOntWithinAllowedToBeProvisionedOrMigratedSipOltList;
 944:              List<Ia.Ngn.Cl.Model.Business.ServiceOnt> ontSipInfoServiceOntWithinAllowedToBeProvisionedOrMigratedSipOltList, voipPstnUserServiceOntWithinAllowedToBeProvisionedOrMigratedSipOltList;
 945:   
 946:              serviceOntToCreateInEmsOntSipInfoOrVoipPstnUserList = new List<Ia.Ngn.Cl.Model.Business.ServiceOnt>();
 947:              serviceOntToAnnulInEmsOntSipInfoOrVoipPstnUseList = new List<Ia.Ngn.Cl.Model.Business.ServiceOnt>();
 948:   
 949:              serviceOntWithinAllowedToBeProvisionedOrMigratedSipOltList = Ia.Ngn.Cl.Model.Data.Service2.ServiceOntWithinAllowedSipOltToBeProvisionedOrMigratedList;
 950:              serviceOntList = Ia.Ngn.Cl.Model.Data.Service2.ServiceOntList;
 951:              ontSipInfoServiceOntWithinAllowedToBeProvisionedOrMigratedSipOltList = Ia.Ngn.Cl.Model.Data.Huawei.OntSipInfo.ServiceOntWithinAllowedSipOltToBeProvisionedOrMigratedList();
 952:              voipPstnUserServiceOntWithinAllowedToBeProvisionedOrMigratedSipOltList = Ia.Ngn.Cl.Model.Data.Huawei.VoipPstnUser.ServiceOntWithinAllowedSipOltToBeProvisionedOrMigratedList();
 953:   
 954:              foreach (var serviceOnt in serviceOntWithinAllowedToBeProvisionedOrMigratedSipOltList)
 955:              {
 956:                  if (!ontSipInfoServiceOntWithinAllowedToBeProvisionedOrMigratedSipOltList.Any(u => u.ServiceId == serviceOnt.ServiceId && u.AccessId == serviceOnt.AccessId)
 957:                      && !voipPstnUserServiceOntWithinAllowedToBeProvisionedOrMigratedSipOltList.Any(u => u.ServiceId == serviceOnt.ServiceId && u.AccessId == serviceOnt.AccessId))
 958:                  {
 959:                      if (!serviceOntToCreateInEmsOntSipInfoOrVoipPstnUserList.Any(u => u.ServiceId == serviceOnt.ServiceId && u.AccessId == serviceOnt.AccessId)) // .Contains(serviceOnt) is disastrous here
 960:                      {
 961:                          serviceOntToCreateInEmsOntSipInfoOrVoipPstnUserList.Add(serviceOnt);
 962:                      }
 963:                  }
 964:              }
 965:   
 966:              // In serviceOntToAnnulInEmsOntSipInfoOrVoipPstnUseList I must make sure that serviceId does not belong to any current service in serviceOntList
 967:              // this is to allow NCE and POTS to GPON migration without interruption or feedback from the vendor. Any number deleted from IMS will be deleted from NCE.
 968:   
 969:              foreach (var serviceOnt in ontSipInfoServiceOntWithinAllowedToBeProvisionedOrMigratedSipOltList)
 970:              {
 971:                  if (!serviceOntWithinAllowedToBeProvisionedOrMigratedSipOltList.Any(u => u.ServiceId == serviceOnt.ServiceId && u.AccessId == serviceOnt.AccessId)) // .Contains(serviceOnt) is disastrous here
 972:                  {
 973:                      if (!serviceOntList.Any(u => u.ServiceId == serviceOnt.ServiceId /*&& u.AccessId == serviceOnt.AccessId*/)) // .Contains(serviceOnt) is disastrous here
 974:                      {
 975:                          if (!serviceOntToAnnulInEmsOntSipInfoOrVoipPstnUseList.Any(u => u.ServiceId == serviceOnt.ServiceId && u.AccessId == serviceOnt.AccessId)) // .Contains(serviceOnt) is disastrous here
 976:                          {
 977:                              serviceOntToAnnulInEmsOntSipInfoOrVoipPstnUseList.Add(serviceOnt);
 978:                          }
 979:                      }
 980:                  }
 981:              }
 982:   
 983:              foreach (var serviceOnt in voipPstnUserServiceOntWithinAllowedToBeProvisionedOrMigratedSipOltList)
 984:              {
 985:                  if (!serviceOntWithinAllowedToBeProvisionedOrMigratedSipOltList.Any(u => u.ServiceId == serviceOnt.ServiceId && u.AccessId == serviceOnt.AccessId)) // .Contains(serviceOnt) is disastrous here
 986:                  {
 987:                      if (!serviceOntList.Any(u => u.ServiceId == serviceOnt.ServiceId /*&& u.AccessId == serviceOnt.AccessId*/)) // .Contains(serviceOnt) is disastrous here
 988:                      {
 989:                          if (!serviceOntToAnnulInEmsOntSipInfoOrVoipPstnUseList.Any(u => u.ServiceId == serviceOnt.ServiceId && u.AccessId == serviceOnt.AccessId)) // .Contains(serviceOnt) is disastrous here
 990:                          {
 991:                              serviceOntToAnnulInEmsOntSipInfoOrVoipPstnUseList.Add(serviceOnt);
 992:                          }
 993:                      }
 994:                  }
 995:              }
 996:   
 997:              // will exclude exempt numbers
 998:              serviceIdExemptionList = Ia.Ngn.Cl.Model.Data.Provision.ServiceIdOfServiceExemptFromProvisionProcessingList();
 999:              foreach (string serviceId in serviceIdExemptionList)
1000:              {
1001:                  serviceOnt2 = serviceOntToCreateInEmsOntSipInfoOrVoipPstnUserList.SingleOrDefault(u => u.ServiceId == serviceId);
1002:                  if (serviceOnt2 != null) serviceOntToCreateInEmsOntSipInfoOrVoipPstnUserList.Remove(serviceOnt2);
1003:   
1004:                  serviceOnt2 = serviceOntToAnnulInEmsOntSipInfoOrVoipPstnUseList.SingleOrDefault(u => u.ServiceId == serviceId);
1005:                  if (serviceOnt2 != null) serviceOntToAnnulInEmsOntSipInfoOrVoipPstnUseList.Remove(serviceOnt2);
1006:              }
1007:          }
1008:   
1009:          ////////////////////////////////////////////////////////////////////////////
1010:   
1011:          /// <summary>
1012:          ///
1013:          /// </summary>
1014:          public static void ServiceOntToAddToAsbrList_ServiceOntToRemoveFromAsbrList(out List<Ia.Ngn.Cl.Model.Business.ServiceOnt> addList, out List<Ia.Ngn.Cl.Model.Business.ServiceOnt> removeList)
1015:          {
1016:              Ia.Ngn.Cl.Model.Business.ServiceOnt serviceOnt2;
1017:              List<string> serviceIdExemptionList;
1018:              List<Ia.Ngn.Cl.Model.Business.ServiceOnt> serviceOntList, serviceOntWithinAllowedToBeProvisionedOrMigratedHuaweiSwitchNokiaGponOltList;
1019:              List<Ia.Ngn.Cl.Model.Business.ServiceOnt> asbrServiceOntWithinAllowedToBeProvisionedOrMigratedHuaweiSwitchNokiaGponOltList;
1020:   
1021:              addList = new List<Ia.Ngn.Cl.Model.Business.ServiceOnt>();
1022:              removeList = new List<Ia.Ngn.Cl.Model.Business.ServiceOnt>();
1023:   
1024:              //List<string> list;
1025:   
1026:              /*
1027:  select s.Service from Service2 s
1028:  inner join ServiceRequestServices srs on s.Id = srs.Id
1029:  inner join Accesses a on a.Id = srs.Access_Id
1030:  inner join HuSbrs sb on 'sip:+965'+ s.Service +'@ims.moc.kw' = sb.IMPU
1031:  left outer join Asbrs asb on sb.IMPU = asb.PUI
1032:  where (a.Olt = 102010101 or a.Olt = 102010201) -- OLT ids MUB:102010101 QRN:102010201
1033:  and srs.Provisioned = 1
1034:  and asb.Id is null
1035:  order by s.Service
1036:               */
1037:   
1038:              /*
1039:              // for oltId intersect AllowedToBeMigrated with Hu-No OLTs
1040:              var oltIdList = Ia.Ngn.Cl.Model.Data.NetworkDesignDocument.HuaweiSwitchNokiaGponOltIdList;
1041:  
1042:              //var i = Ia.Ngn.Cl.Model.Data.NetworkDesignDocument.OntAccessIdToOntAccessNameDictionary;
1043:  
1044:              using (var db = new Ia.Ngn.Cl.Model.Ngn())
1045:              {
1046:                  var list = (from s in db.Service2s
1047:                              join srs in db.ServiceRequestServices on s.Id equals srs.Id
1048:                              join a in db.Accesses on srs.Access.Id equals a.Id
1049:                              //join sbr in db.HuSbrs on "sip:+965" + s.Service + "@ims.moc.kw" equals sbr.IMPU
1050:                              //join asbr in db.Asbrs on sbr.IMPU equals asbr.PUI into gj
1051:                              //from u in gj.DefaultIfEmpty()
1052:                              where oltIdList.Contains(a.Olt) && srs.Provisioned == true //&& u == null
1053:                              orderby s.Service
1054:                              select new { s.Service, AccessId = a.Id }).ToList();
1055:  
1056:                  //var l = (from a in list select i[a.AccessId]).Distinct().ToList();
1057:                  var l = (from a in list select a.AccessId).Distinct().ToList();
1058:              }
1059:  
1060:  
1061:              //return list;
1062:              */
1063:   
1064:              serviceOntWithinAllowedToBeProvisionedOrMigratedHuaweiSwitchNokiaGponOltList = Ia.Ngn.Cl.Model.Data.Service2.ServiceOntWithinAllowedToBeProvisionedOrMigratedHuaweiSwitchNokiaGponOltList();
1065:              serviceOntList = Ia.Ngn.Cl.Model.Data.Service2.ServiceOntList;
1066:              asbrServiceOntWithinAllowedToBeProvisionedOrMigratedHuaweiSwitchNokiaGponOltList = Ia.Ngn.Cl.Model.Data.Huawei.Asbr.ServiceOntWithinAllowedToBeProvisionedOrMigratedHuaweiSwitchNokiaGponOltList();
1067:   
1068:              foreach (var serviceOnt in serviceOntWithinAllowedToBeProvisionedOrMigratedHuaweiSwitchNokiaGponOltList)
1069:              {
1070:                  if (!asbrServiceOntWithinAllowedToBeProvisionedOrMigratedHuaweiSwitchNokiaGponOltList.Any(u => u.ServiceId == serviceOnt.ServiceId && u.AccessId == serviceOnt.AccessId))
1071:                  {
1072:                      if (!addList.Any(u => u.ServiceId == serviceOnt.ServiceId && u.AccessId == serviceOnt.AccessId)) // .Contains(serviceOnt) is disastrous here
1073:                      {
1074:                          addList.Add(serviceOnt);
1075:                      }
1076:                  }
1077:              }
1078:   
1079:              foreach (var serviceOnt in asbrServiceOntWithinAllowedToBeProvisionedOrMigratedHuaweiSwitchNokiaGponOltList)
1080:              {
1081:                  if (!serviceOntWithinAllowedToBeProvisionedOrMigratedHuaweiSwitchNokiaGponOltList.Any(u => u.ServiceId == serviceOnt.ServiceId && u.AccessId == serviceOnt.AccessId)) // .Contains(serviceOnt) is disastrous here
1082:                  {
1083:                      if (!serviceOntList.Any(u => u.ServiceId == serviceOnt.ServiceId /*&& u.AccessId == serviceOnt.AccessId*/)) // .Contains(serviceOnt) is disastrous here
1084:                      {
1085:                          if (!removeList.Any(u => u.ServiceId == serviceOnt.ServiceId && u.AccessId == serviceOnt.AccessId)) // .Contains(serviceOnt) is disastrous here
1086:                          {
1087:                              removeList.Add(serviceOnt);
1088:                          }
1089:                      }
1090:                  }
1091:              }
1092:   
1093:              // will exclude exempt numbers
1094:              serviceIdExemptionList = Ia.Ngn.Cl.Model.Data.Provision.ServiceIdOfServiceExemptFromProvisionProcessingList();
1095:              foreach (string serviceId in serviceIdExemptionList)
1096:              {
1097:                  serviceOnt2 = addList.SingleOrDefault(u => u.ServiceId == serviceId);
1098:                  if (serviceOnt2 != null) addList.Remove(serviceOnt2);
1099:   
1100:                  serviceOnt2 = removeList.SingleOrDefault(u => u.ServiceId == serviceId);
1101:                  if (serviceOnt2 != null) removeList.Remove(serviceOnt2);
1102:              }
1103:          }
1104:   
1105:          ////////////////////////////////////////////////////////////////////////////
1106:          ////////////////////////////////////////////////////////////////////////////
1107:   
1108:          /// <summary>
1109:          ///
1110:          /// </summary>
1111:          public static List<string> ServiceSuspendedInServiceRequestServiceButNotInServiceStringNumberList
1112:          {
1113:              get
1114:              {
1115:                  List<string> list, sList, srsList;
1116:                  SortedList sl;
1117:   
1118:                  sList = Ia.Ngn.Cl.Model.Data.Service2.ServiceSuspensionIsTrueStringNumberList;
1119:                  srsList = Ia.Ngn.Cl.Model.Data.ServiceRequestService.ServiceSuspensionIsTrueAndProvisionedIsTrueStringNumberList;
1120:   
1121:                  if (sList != null && sList.Count > 0)
1122:                  {
1123:                      if (srsList != null && srsList.Count > 0)
1124:                      {
1125:                          list = new List<string>(sList.Count);
1126:   
1127:                          sl = new SortedList(sList.ToDictionary(s => s));
1128:   
1129:                          foreach (string s in srsList)
1130:                          {
1131:                              if (!sl.ContainsKey(s)) list.Add(s);
1132:                          }
1133:                      }
1134:                      else
1135:                      {
1136:                          list = new List<string>();
1137:                      }
1138:                  }
1139:                  else
1140:                  {
1141:                      if (srsList != null && srsList.Count > 0) list = sList;
1142:                      else list = new List<string>();
1143:                  }
1144:   
1145:                  return list;
1146:              }
1147:          }
1148:   
1149:          ////////////////////////////////////////////////////////////////////////////
1150:   
1151:          /// <summary>
1152:          ///
1153:          /// </summary>
1154:          public static List<string> ServiceActiveInServiceRequestServiceButNotInServiceStringNumberList
1155:          {
1156:              get
1157:              {
1158:                  List<string> list, sList, srsList;
1159:                  SortedList sl;
1160:   
1161:                  sList = Ia.Ngn.Cl.Model.Data.Service2.ServiceSuspensionIsFalseStringNumberList;
1162:                  srsList = Ia.Ngn.Cl.Model.Data.ServiceRequestService.ServiceSuspensionIsFalseStringNumberList;
1163:   
1164:                  if (sList != null && sList.Count > 0)
1165:                  {
1166:                      if (srsList != null && srsList.Count > 0)
1167:                      {
1168:                          list = new List<string>(sList.Count);
1169:   
1170:                          sl = new SortedList(sList.ToDictionary(s => s));
1171:   
1172:                          foreach (string s in srsList)
1173:                          {
1174:                              if (!sl.ContainsKey(s)) list.Add(s);
1175:                          }
1176:                      }
1177:                      else
1178:                      {
1179:                          list = new List<string>();
1180:                      }
1181:                  }
1182:                  else
1183:                  {
1184:                      if (srsList != null && srsList.Count > 0) list = sList;
1185:                      else list = new List<string>();
1186:                  }
1187:   
1188:                  return list;
1189:              }
1190:          }
1191:   
1192:          ////////////////////////////////////////////////////////////////////////////
1193:   
1194:          /// <summary>
1195:          ///
1196:          /// </summary>
1197:          public static List<Ia.Ngn.Cl.Model.Business.Procedure.Process> EmsOntToBeUpdatedFromH248ToSipList()
1198:          {
1199:              List<string> oltSymbolList;
1200:              List<Ia.Ngn.Cl.Model.Business.Procedure.Process> processList;
1201:   
1202:              processList = new List<Ia.Ngn.Cl.Model.Business.Procedure.Process>();
1203:   
1204:              oltSymbolList = Ia.Ngn.Cl.Model.Business.Default.H248ToSipUpdateOltSymbolList;
1205:   
1206:              var list = Ia.Ngn.Cl.Model.Data.Default.DistinctNddOntWhereVaprofIsNotAluSipBAndIgnoreMduForOltSymbolListList(oltSymbolList);
1207:   
1208:              foreach (var l in list)
1209:              {
1210:                  processList.Add(new Ia.Ngn.Cl.Model.Business.Procedure.Process { Ont = l.Ont, Type = Ia.Ngn.Cl.Model.Business.Procedure.ProcessType.Update });
1211:                  processList.Add(new Ia.Ngn.Cl.Model.Business.Procedure.Process { Ont = l.Ont, Type = Ia.Ngn.Cl.Model.Business.Procedure.ProcessType.Read });
1212:              }
1213:   
1214:              return processList;
1215:          }
1216:   
1217:          ////////////////////////////////////////////////////////////////////////////
1218:   
1219:          /// <summary>
1220:          ///
1221:          /// </summary>
1222:          public static List<Ia.Ngn.Cl.Model.Business.Procedure.Process> OntSipInfoOrOntVoipPstnUserToBeCreatedForAnOntUpdatedFromH248ToSipList()
1223:          {
1224:              int pn;
1225:              List<string> oltSymbolList;
1226:              List<Ia.Ngn.Cl.Model.Business.Procedure.Process> processList;
1227:   
1228:              processList = new List<Ia.Ngn.Cl.Model.Business.Procedure.Process>();
1229:   
1230:              oltSymbolList = Ia.Ngn.Cl.Model.Business.Default.H248ToSipUpdateOltSymbolList;
1231:   
1232:              var list = Ia.Ngn.Cl.Model.Data.Default.ServiceAndNddOntAndEmsOntFamilyTypeAndPortWhereAgcfEndpointPortIsNot0AndVaprofIsAluSipBAndSfuEmsOntSipInfoTelDoesNotExistOrMduEmsVagIsSipAndMduEmsVoipPstnUserPnDoesNotExistForOltSymbolListList(oltSymbolList);
1233:   
1234:              /*
1235:               * All Nokia ONTs (SFUs and MDUs) start at port position 1.
1236:               * Huawei ONTs (SFUs) start at port position 1, while Huawei MDUs start at port position 0.
1237:               */
1238:   
1239:              // issue update then read commands
1240:              foreach (var l in list)
1241:              {
1242:                  if (l.EmsOntFamilyType == Ia.Ngn.Cl.Model.Business.Huawei.Ont.FamilyType.Sfu)
1243:                  {
1244:                      processList.Add(new Ia.Ngn.Cl.Model.Business.Procedure.Process { Service = l.Service, Ont = l.Ont, EmsOntFamilyType = Ia.Ngn.Cl.Model.Business.Huawei.Ont.FamilyType.Sfu, Port = l.Port, Type = Ia.Ngn.Cl.Model.Business.Procedure.ProcessType.Update });
1245:                      processList.Add(new Ia.Ngn.Cl.Model.Business.Procedure.Process { Service = l.Service, Ont = l.Ont, EmsOntFamilyType = Ia.Ngn.Cl.Model.Business.Huawei.Ont.FamilyType.Sfu, Port = l.Port, Type = Ia.Ngn.Cl.Model.Business.Procedure.ProcessType.Read });
1246:                  }
1247:                  else if (l.EmsOntFamilyType == Ia.Ngn.Cl.Model.Business.Huawei.Ont.FamilyType.Mdu)
1248:                  {
1249:                      pn = Ia.Ngn.Cl.Model.Business.Service.ConvertFlatTermIdPositionToEmsVoipPstnUsersPn(l.Port);
1250:   
1251:                      processList.Add(new Ia.Ngn.Cl.Model.Business.Procedure.Process { Service = l.Service, Ont = l.Ont, EmsOntFamilyType = Ia.Ngn.Cl.Model.Business.Huawei.Ont.FamilyType.Mdu, Port = pn, Type = Ia.Ngn.Cl.Model.Business.Procedure.ProcessType.Update });
1252:                      processList.Add(new Ia.Ngn.Cl.Model.Business.Procedure.Process { Service = l.Service, Ont = l.Ont, EmsOntFamilyType = Ia.Ngn.Cl.Model.Business.Huawei.Ont.FamilyType.Mdu, Port = pn, Type = Ia.Ngn.Cl.Model.Business.Procedure.ProcessType.Read });
1253:                  }
1254:                  else
1255:                  {
1256:                      throw new Exception("EmsOntFamilyType is not concedered. ");
1257:                  }
1258:              }
1259:   
1260:              return processList;
1261:          }
1262:   
1263:          ////////////////////////////////////////////////////////////////////////////
1264:   
1265:          /// <summary>
1266:          ///
1267:          /// </summary>
1268:          public static List<Ia.Ngn.Cl.Model.Business.Procedure.Process> NokiaImsSubscriberToBeUpdatedFromH248ToSipList()
1269:          {
1270:              List<string> oltSymbolList;
1271:              List<Ia.Ngn.Cl.Model.Business.Procedure.Process> processList;
1272:   
1273:              processList = new List<Ia.Ngn.Cl.Model.Business.Procedure.Process>();
1274:   
1275:              oltSymbolList = Ia.Ngn.Cl.Model.Business.Default.H248ToSipUpdateOltSymbolList;
1276:   
1277:              var list = Ia.Ngn.Cl.Model.Data.Default.ServiceAndNddOntWherePrimaryPuidcpeProfileNumberIsNot10AndEmsOntVaprofIsAluSipBAndSfuEmsOntSipInfoTelExistsOrAndMduEmsOntVagIsSipAndMduEmsVoipPstnUserPnExistsForOltSymbolListList(oltSymbolList);
1278:   
1279:              // issue delete then create commands
1280:              foreach (var l in list)
1281:              {
1282:                  processList.Add(new Ia.Ngn.Cl.Model.Business.Procedure.Process { Service = l.Service, Ont = l.Ont, Protocol = Ia.Ngn.Cl.Model.Business.Default.Protocol.H248, Type = Ia.Ngn.Cl.Model.Business.Procedure.ProcessType.DeleteRead });
1283:   
1284:                  processList.Add(new Ia.Ngn.Cl.Model.Business.Procedure.Process { Service = l.Service, Ont = l.Ont, Protocol = Ia.Ngn.Cl.Model.Business.Default.Protocol.Sip, Type = Ia.Ngn.Cl.Model.Business.Procedure.ProcessType.CreateRead });
1285:              }
1286:   
1287:              return processList;
1288:          }
1289:   
1290:          ////////////////////////////////////////////////////////////////////////////
1291:   
1292:          /// <summary>
1293:          ///
1294:          /// </summary>
1295:          public static Ia.Cl.Model.Result ManageServiceProvisioning(Ia.Ngn.Cl.Model.Client.Nokia.Ims nokiaIms, Ia.Ngn.Cl.Model.Client.Huawei.Ims huaweiIms)
1296:          {
1297:              int gwId, number, provisionWithinLastNDays;
1298:              string service, serviceId, progressCounterString, r0, r, r2, r3;
1299:              Ia.Cl.Model.Result result, r4;
1300:              Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Ont srsNddOnt, sNddOnt;
1301:              Ia.Ngn.Cl.Model.Service2 service2;
1302:              Ia.Ngn.Cl.Model.ServiceRequestService serviceRequestService;
1303:              Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Vendor switchVendor;
1304:   
1305:              r = progressCounterString = r2 = r3 = string.Empty;
1306:              r4 = new Ia.Cl.Model.Result();
1307:              result = new Ia.Cl.Model.Result();
1308:   
1309:              provisionWithinLastNDays = 0; // 0 means earliest request datetime huaweiIms, 
1310:   
1311:              serviceId = Ia.Ngn.Cl.Model.Business.Provision.SequentialDiscrepancyAndComplementaryServiceMismatchBetweenServiceRequestServiceAndServiceListItem(provisionWithinLastNDays, out int serviceQueueCount, out progressCounterString);
1312:   
1313:              //serviceId = "23717888:1:965";
1314:   
1315:              if (serviceId != null)
1316:              {
1317:                  r0 = "service: " + serviceId.Replace(":1:965", "") + " " + progressCounterString + ": ";
1318:                  r2 = serviceId;
1319:   
1320:                  service2 = Ia.Ngn.Cl.Model.Data.Service2.ReadByIdIncludeAccess(serviceId);
1321:                  serviceRequestService = Ia.Ngn.Cl.Model.Data.ServiceRequestService.ReadIncludeAccess(serviceId);
1322:   
1323:                  try
1324:                  {
1325:                      if (serviceRequestService != null)
1326:                      {
1327:                          if (serviceRequestService.Provisioned)
1328:                          {
1329:                              service = serviceRequestService.Service;
1330:   
1331:                              if (int.TryParse(service, out number))
1332:                              {
1333:                                  switchVendor = Ia.Ngn.Cl.Model.Data.NetworkDesignDocument.SwitchVendorFromService(service);
1334:   
1335:                                  srsNddOnt = (from n in Ia.Ngn.Cl.Model.Data.NetworkDesignDocument.OntList where serviceRequestService.Access != null && n.Access.Id == serviceRequestService.Access.Id select n).SingleOrDefault();
1336:   
1337:                                  if (service2 == null)
1338:                                  {
1339:                                      // create number in service
1340:                                      r0 += "create: ";
1341:   
1342:                                      if (srsNddOnt != null)
1343:                                      {
1344:                                          if (Ia.Ngn.Cl.Model.Business.Service.OltIsWithinAllowedToBeProvisionedOltList(srsNddOnt.Pon.PonGroup.Olt))
1345:                                          {
1346:                                              if (Ia.Ngn.Cl.Model.Business.Service.NumberIsWithinAllowedRouterDomainList(srsNddOnt, service))
1347:                                              {
1348:                                                  if (switchVendor == Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Vendor.Nokia)
1349:                                                  {
1350:                                                      r0 += "Nokia: ";
1351:   
1352:                                                      // make sure the number is not suspended before creating it
1353:                                                      Ia.Ngn.Cl.Model.Data.ServiceRequestService.UpdateServiceSuspension(service, false, Guid.Empty, out r4);
1354:   
1355:                                                      Ia.Ngn.Cl.Model.Business.Provision.CreateNokiaSwitchSubscriber(nokiaIms, srsNddOnt.Access.Name, service, Ia.Ngn.Cl.Model.Business.Default.PortUndefinedOrInvalidOrUnknown, Ia.Ngn.Cl.Model.Business.Default.Protocol.DefaultAsInNdd, false, out r);
1356:                                                  }
1357:                                                  else if (switchVendor == Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Vendor.Huawei)
1358:                                                  {
1359:                                                      r0 += "Huawei: ";
1360:   
1361:                                                      // make sure the number is not suspend before creating it
1362:                                                      Ia.Ngn.Cl.Model.Data.ServiceRequestService.UpdateServiceSuspension(service, false, Guid.Empty, out r4);
1363:   
1364:                                                      // we I will completely remove any existing number before installing it again to make sure it installs fresh
1365:                                                      Ia.Ngn.Cl.Model.Business.Provision.DeleteHuaweiSwitchSubscriber(huaweiIms, srsNddOnt.Access.Name, service, Ia.Ngn.Cl.Model.Business.Default.Protocol.DefaultAsInNdd, false, out r);
1366:   
1367:                                                      Ia.Ngn.Cl.Model.Business.Provision.CreateHuaweiSwitchSubscriber(huaweiIms, srsNddOnt.Access.Name, service, Ia.Ngn.Cl.Model.Business.Default.PortUndefinedOrInvalidOrUnknown, Ia.Ngn.Cl.Model.Business.Default.Protocol.DefaultAsInNdd, false, out r);
1368:                                                  }
1369:                                                  else
1370:                                                  {
1371:                                                      throw new Exception("switchVendor is undefined, ");
1372:                                                  }
1373:                                              }
1374:                                              else
1375:                                              {
1376:                                                  r0 += "service is not within allowed router domain list. ";
1377:                                              }
1378:   
1379:                                              r0 += r;
1380:                                          }
1381:                                          else
1382:                                          {
1383:                                              r0 += "Access is not in an allowed to be provisioned OLT. ";
1384:                                          }
1385:                                      }
1386:                                      else r0 += "SRS Ont is null. ";
1387:                                  }
1388:                                  else
1389:                                  {
1390:                                      // check services
1391:                                      r0 += "update: ";
1392:   
1393:                                      // note that I will install services according to the Access given by service variable, not SRS access
1394:                                      sNddOnt = (from n in Ia.Ngn.Cl.Model.Data.NetworkDesignDocument.OntList where service2.Access != null && n.Access.Id == service2.Access.Id select n).SingleOrDefault();
1395:   
1396:                                      if (srsNddOnt != null && sNddOnt != null)
1397:                                      {
1398:                                          if (Ia.Ngn.Cl.Model.Business.Service.OltIsWithinAllowedToBeProvisionedOltList(srsNddOnt.Pon.PonGroup.Olt))
1399:                                          {
1400:                                              if (Ia.Ngn.Cl.Model.Business.Service.NumberIsWithinAllowedRouterDomainList(sNddOnt, service))
1401:                                              {
1402:                                                  if (srsNddOnt.Id == sNddOnt.Id)
1403:                                                  {
1404:                                                      r0 += "service: ";
1405:   
1406:                                                      if (switchVendor == Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Vendor.Nokia)
1407:                                                      {
1408:                                                          r0 += "Nokia: ";
1409:   
1410:                                                          // below: send change command to IMS
1411:                                                          if (service2.CallerId != serviceRequestService.CallerId) Ia.Ngn.Cl.Model.Data.Nokia.Ims.AssignSupplementaryService(nokiaIms, service, sNddOnt, Ia.Ngn.Cl.Model.Business.Service.SupplementaryService.CallerId, serviceRequestService.CallerId, out r2);
1412:                                                          else if (service2.CallForwarding != serviceRequestService.CallForwarding) Ia.Ngn.Cl.Model.Data.Nokia.Ims.AssignSupplementaryService(nokiaIms, service, sNddOnt, Ia.Ngn.Cl.Model.Business.Service.SupplementaryService.CallForwarding, serviceRequestService.CallForwarding, out r2);
1413:                                                          else if (service2.ConferenceCall != serviceRequestService.ConferenceCall) Ia.Ngn.Cl.Model.Data.Nokia.Ims.AssignSupplementaryService(nokiaIms, service, sNddOnt, Ia.Ngn.Cl.Model.Business.Service.SupplementaryService.ConferenceCall, serviceRequestService.ConferenceCall, out r2);
1414:                                                          else if (service2.AlarmCall != serviceRequestService.AlarmCall) Ia.Ngn.Cl.Model.Data.Nokia.Ims.AssignSupplementaryService(nokiaIms, service, sNddOnt, Ia.Ngn.Cl.Model.Business.Service.SupplementaryService.WakeupCall, serviceRequestService.AlarmCall, out r2);
1415:                                                          else if (service2.WakeupCall != serviceRequestService.WakeupCall) Ia.Ngn.Cl.Model.Data.Nokia.Ims.AssignSupplementaryService(nokiaIms, service, sNddOnt, Ia.Ngn.Cl.Model.Business.Service.SupplementaryService.WakeupCall, serviceRequestService.WakeupCall, out r2);
1416:                                                          else if (service2.AbbriviatedCalling != serviceRequestService.AbbriviatedCalling) Ia.Ngn.Cl.Model.Data.Nokia.Ims.AssignSupplementaryService(nokiaIms, service, sNddOnt, Ia.Ngn.Cl.Model.Business.Service.SupplementaryService.AbbriviatedCalling, serviceRequestService.AbbriviatedCalling, out r2);
1417:                                                          else if (service2.InternationalCalling != serviceRequestService.InternationalCalling) Ia.Ngn.Cl.Model.Data.Nokia.Ims.AssignSupplementaryService(nokiaIms, service, sNddOnt, Ia.Ngn.Cl.Model.Business.Service.SupplementaryService.InternationalCalling, serviceRequestService.InternationalCalling, out r2);
1418:                                                          else if (service2.InternationalCallingUserControlled != serviceRequestService.InternationalCallingUserControlled) Ia.Ngn.Cl.Model.Data.Nokia.Ims.AssignSupplementaryService(nokiaIms, service, sNddOnt, Ia.Ngn.Cl.Model.Business.Service.SupplementaryService.InternationalCallingUserControlled, serviceRequestService.InternationalCallingUserControlled, out r2);
1419:                                                          // below: CallWaiting is not provisioned for PBX keys. It is placed last in the execution logic so that it does not prevention the flow of logic to other services
1420:                                                          else if (service2.CallWaiting != serviceRequestService.CallWaiting) Ia.Ngn.Cl.Model.Data.Nokia.Ims.AssignSupplementaryService(nokiaIms, service, sNddOnt, Ia.Ngn.Cl.Model.Business.Service.SupplementaryService.CallWaiting, serviceRequestService.CallWaiting, out r2);
1421:   
1422:                                                          // below: a little complicated to decide if number should on or off
1423:                                                          else if (serviceRequestService.CallBarring == false && serviceRequestService.ServiceSuspension == false) Ia.Ngn.Cl.Model.Data.Nokia.Ims.AssignServiceSuspensionStateToServiceSubscriber(nokiaIms, service, sNddOnt, false, out r2);
1424:                                                          else if (serviceRequestService.CallBarring == true && serviceRequestService.ServiceSuspension == false) Ia.Ngn.Cl.Model.Data.Nokia.Ims.AssignServiceSuspensionStateToServiceSubscriber(nokiaIms, service, sNddOnt, true, out r2);
1425:                                                          else if (serviceRequestService.CallBarring == false && serviceRequestService.ServiceSuspension == true) Ia.Ngn.Cl.Model.Data.Nokia.Ims.AssignServiceSuspensionStateToServiceSubscriber(nokiaIms, service, sNddOnt, true, out r2);
1426:                                                          else if (serviceRequestService.CallBarring == true && serviceRequestService.ServiceSuspension == true) Ia.Ngn.Cl.Model.Data.Nokia.Ims.AssignServiceSuspensionStateToServiceSubscriber(nokiaIms, service, sNddOnt, true, out r2);
1427:                                                          else r2 = "no difference in services. ";
1428:   
1429:                                                          if (sNddOnt.Pon.PonGroup.Olt.IsSip == false) // if H.248
1430:                                                          {
1431:                                                              gwId = Ia.Ngn.Cl.Model.Data.Nokia.AgcfGatewayRecord.GwIdFromIp(sNddOnt.Ip);
1432:   
1433:                                                              if (gwId > 0)
1434:                                                              {
1435:                                                                  Ia.Ngn.Cl.Model.Data.Nokia.Ims.ReadUpdateAgcfGatewayRecordAndAgcfEndpointListAndSubPartyAndSubscriberAndServiceForGwId(nokiaIms, sNddOnt, gwId, out r3);
1436:   
1437:                                                                  r0 += r2 + "," + r3 + ". ";
1438:                                                              }
1439:                                                              else
1440:                                                              {
1441:                                                                  r0 += "gwId: 0, " + r2 + "," + r3 + ". ";
1442:                                                              }
1443:                                                          }
1444:                                                          else // if IsSip == true
1445:                                                          {
1446:                                                              Ia.Ngn.Cl.Model.Data.Nokia.Ims.ReadUpdateSubPartyAndSubscriberAndService(nokiaIms, service, sNddOnt, out r3);
1447:                                                              r0 += r2 + "," + r3 + ". ";
1448:                                                          }
1449:                                                      }
1450:                                                      else if (switchVendor == Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Vendor.Huawei)
1451:                                                      {
1452:                                                          r0 += "Huawei: ";
1453:   
1454:                                                          // below: send change command to IMS
1455:                                                          if (service2.CallerId != serviceRequestService.CallerId) Ia.Ngn.Cl.Model.Data.Huawei.Ims.AssignSupplementaryService(huaweiIms, service, Ia.Ngn.Cl.Model.Business.Service.SupplementaryService.CallerId, serviceRequestService.CallerId, out r2);
1456:                                                          else if (service2.CallForwarding != serviceRequestService.CallForwarding) Ia.Ngn.Cl.Model.Data.Huawei.Ims.AssignSupplementaryService(huaweiIms, service, Ia.Ngn.Cl.Model.Business.Service.SupplementaryService.CallForwarding, serviceRequestService.CallForwarding, out r2);
1457:                                                          else if (service2.CallWaiting != serviceRequestService.CallWaiting) Ia.Ngn.Cl.Model.Data.Huawei.Ims.AssignSupplementaryService(huaweiIms, service, Ia.Ngn.Cl.Model.Business.Service.SupplementaryService.CallWaiting, serviceRequestService.CallWaiting, out r2);
1458:                                                          else if (service2.ConferenceCall != serviceRequestService.ConferenceCall) Ia.Ngn.Cl.Model.Data.Huawei.Ims.AssignSupplementaryService(huaweiIms, service, Ia.Ngn.Cl.Model.Business.Service.SupplementaryService.ConferenceCall, serviceRequestService.ConferenceCall, out r2);
1459:                                                          else if (service2.AlarmCall != serviceRequestService.AlarmCall) Ia.Ngn.Cl.Model.Data.Huawei.Ims.AssignSupplementaryService(huaweiIms, service, Ia.Ngn.Cl.Model.Business.Service.SupplementaryService.WakeupCall, serviceRequestService.AlarmCall, out r2);
1460:                                                          else if (service2.WakeupCall != serviceRequestService.WakeupCall) Ia.Ngn.Cl.Model.Data.Huawei.Ims.AssignSupplementaryService(huaweiIms, service, Ia.Ngn.Cl.Model.Business.Service.SupplementaryService.WakeupCall, serviceRequestService.WakeupCall, out r2);
1461:                                                          else if (service2.AbbriviatedCalling != serviceRequestService.AbbriviatedCalling) Ia.Ngn.Cl.Model.Data.Huawei.Ims.AssignSupplementaryService(huaweiIms, service, Ia.Ngn.Cl.Model.Business.Service.SupplementaryService.AbbriviatedCalling, serviceRequestService.AbbriviatedCalling, out r2);
1462:   
1463:                                                          // below: data is insufficient to decide
1464:                                                          else if (service2.InternationalCalling != serviceRequestService.InternationalCalling) Ia.Ngn.Cl.Model.Data.Huawei.Ims.AssignSupplementaryService(huaweiIms, service, Ia.Ngn.Cl.Model.Business.Service.SupplementaryService.InternationalCalling, serviceRequestService.InternationalCalling, out r2);
1465:                                                          else if (service2.InternationalCallingUserControlled != serviceRequestService.InternationalCallingUserControlled) Ia.Ngn.Cl.Model.Data.Huawei.Ims.AssignSupplementaryService(huaweiIms, service, Ia.Ngn.Cl.Model.Business.Service.SupplementaryService.InternationalCallingUserControlled, serviceRequestService.InternationalCallingUserControlled, out r2);
1466:   
1467:                                                          // below: data is insufficient to decide
1468:                                                          // below: a little complicated to decide if number should on or off
1469:                                                          //else if (srs.CallBarring == false && srs.ServiceSuspension == false) Ia.Ngn.Cl.Model.Data.Huawei.Ims.AssignServiceSuspensionStateToServiceSubscriber(huaweiIms, service, false, out r2);
1470:                                                          //else if (srs.CallBarring == true && srs.ServiceSuspension == false) Ia.Ngn.Cl.Model.Data.Huawei.Ims.AssignServiceSuspensionStateToServiceSubscriber(huaweiIms, service, true, out r2);
1471:                                                          //else if (srs.CallBarring == false && srs.ServiceSuspension == true) Ia.Ngn.Cl.Model.Data.Huawei.Ims.AssignServiceSuspensionStateToServiceSubscriber(huaweiIms, service, true, out r2);
1472:                                                          //else if (srs.CallBarring == true && srs.ServiceSuspension == true) Ia.Ngn.Cl.Model.Data.Huawei.Ims.AssignServiceSuspensionStateToServiceSubscriber(huaweiIms, service, true, out r2);
1473:   
1474:                                                          else r2 = "no difference in services. ";
1475:   
1476:                                                          // below: read and update
1477:                                                          Ia.Ngn.Cl.Model.Business.Huawei.Ims.ReadUpdateSbrAndServiceForService(huaweiIms, service, sNddOnt, out r3);
1478:   
1479:                                                          r0 += r2 + "," + r3 + ". ";
1480:                                                      }
1481:                                                      else
1482:                                                      {
1483:                                                          throw new Exception("switchVendor is undefined, ");
1484:                                                      }
1485:                                                  }
1486:                                                  else
1487:                                                  {
1488:                                                      // update service access
1489:                                                      r0 += "service access: ";
1490:                                                      r0 += "delete: ";
1491:   
1492:                                                      if (switchVendor == Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Vendor.Nokia)
1493:                                                      {
1494:                                                          r0 += "Nokia: ";
1495:   
1496:                                                          Ia.Ngn.Cl.Model.Business.Provision.DeleteNokiaSwitchSubscriber(nokiaIms, sNddOnt.Access.Name, service, Ia.Ngn.Cl.Model.Business.Default.Protocol.DefaultAsInNdd, false, out r);
1497:                                                      }
1498:                                                      else if (switchVendor == Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Vendor.Huawei)
1499:                                                      {
1500:                                                          r0 += "Huawei: ";
1501:   
1502:                                                          Ia.Ngn.Cl.Model.Business.Provision.DeleteHuaweiSwitchSubscriber(huaweiIms, sNddOnt.Access.Name, service, Ia.Ngn.Cl.Model.Business.Default.Protocol.DefaultAsInNdd, false, out r);
1503:                                                      }
1504:                                                      else
1505:                                                      {
1506:                                                          throw new Exception("switchVendor is undefined, ");
1507:                                                      }
1508:                                                  }
1509:                                              }
1510:                                              else
1511:                                              {
1512:                                                  r0 += "service is not within allowed router domain list. ";
1513:                                              }
1514:                                          }
1515:                                          else
1516:                                          {
1517:                                              r0 += "Access is not in an allowed to be provisioned OLT. ";
1518:                                          }
1519:                                      }
1520:                                      else
1521:                                      {
1522:                                          // temp 
1523:                                          //Ia.Ngn.Cl.Model.Data.Msmq.ServiceQueue.Enqueue(service);
1524:   
1525:                                          r0 += "Service access and/or service request service access is null. ";
1526:                                      }
1527:                                  }
1528:                              }
1529:                              else
1530:                              {
1531:                                  r0 += "service is not a valid number. ";
1532:                              }
1533:                          }
1534:                          else //if(!serviceRequestService.Provisioned)
1535:                          {
1536:                              service = serviceRequestService.Service;
1537:   
1538:                              if (int.TryParse(service, out number))
1539:                              {
1540:                                  switchVendor = Ia.Ngn.Cl.Model.Data.NetworkDesignDocument.SwitchVendorFromService(service);
1541:   
1542:                                  if (service2 != null)
1543:                                  {
1544:                                      // delete number from service
1545:                                      r0 += "delete: ";
1546:   
1547:                                      sNddOnt = (from n in Ia.Ngn.Cl.Model.Data.NetworkDesignDocument.OntList where service2.Access != null && n.Access.Id == service2.Access.Id select n).SingleOrDefault();
1548:   
1549:                                      if (sNddOnt != null)
1550:                                      {
1551:                                          if (Ia.Ngn.Cl.Model.Business.Service.OltIsWithinAllowedToBeProvisionedOltList(sNddOnt.Pon.PonGroup.Olt))
1552:                                          {
1553:                                              if (Ia.Ngn.Cl.Model.Business.Service.NumberIsWithinAllowedRouterDomainList(sNddOnt, service))
1554:                                              {
1555:                                                  if (switchVendor == Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Vendor.Nokia)
1556:                                                  {
1557:                                                      r0 += "Nokia: ";
1558:   
1559:                                                      Ia.Ngn.Cl.Model.Business.Provision.DeleteNokiaSwitchSubscriber(nokiaIms, sNddOnt.Access.Name, service, Ia.Ngn.Cl.Model.Business.Default.Protocol.DefaultAsInNdd, false, out r);
1560:                                                  }
1561:                                                  else if (switchVendor == Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Vendor.Huawei)
1562:                                                  {
1563:                                                      r0 += "Huawei: ";
1564:   
1565:                                                      Ia.Ngn.Cl.Model.Business.Provision.DeleteHuaweiSwitchSubscriber(huaweiIms, sNddOnt.Access.Name, service, Ia.Ngn.Cl.Model.Business.Default.Protocol.DefaultAsInNdd, false, out r);
1566:                                                  }
1567:                                                  else
1568:                                                  {
1569:                                                      throw new Exception("switchVendor is undefined, ");
1570:                                                  }
1571:                                              }
1572:                                              else
1573:                                              {
1574:                                                  r0 += "service is not within allowed router domain list. ";
1575:                                              }
1576:   
1577:                                              r0 += r;
1578:                                          }
1579:                                          else
1580:                                          {
1581:                                              r0 += "Access is not in an allowed to be provisioned OLT. ";
1582:                                          }
1583:                                      }
1584:                                      else r0 += "SRS Ont is null. ";
1585:                                  }
1586:                                  else
1587:                                  {
1588:                                      throw new Exception("switchVendor is null. ");
1589:                                  }
1590:                              }
1591:                              else
1592:                              {
1593:                                  r0 += "service is not a valid number. ";
1594:                              }
1595:                          }
1596:                      }
1597:                      else
1598:                      {
1599:                          r0 += "serviceRequestService is null. ";
1600:                      }
1601:                  }
1602:                  catch (Exception ex)
1603:                  {
1604:                      r0 += "Exception: " + ex.ToString();
1605:                  }
1606:              }
1607:              else
1608:              {
1609:                  r0 = "No numbers in service discrepancy and complementary service mismatch list. ";
1610:              }
1611:   
1612:              r0 = "Manage: " + r0;
1613:   
1614:              result.AddSuccess(r0);
1615:   
1616:              return result;
1617:          }
1618:   
1619:          ////////////////////////////////////////////////////////////////////////////
1620:   
1621:          /// <summary>
1622:          ///
1623:          /// </summary>
1624:          public static Ia.Cl.Model.Result ManageServiceSuspension(Ia.Ngn.Cl.Model.Client.Nokia.Ims nokiaIms, Ia.Ngn.Cl.Model.Client.Huawei.Ims huaweiIms)
1625:          {
1626:              int gwId;
1627:              string service, serviceId, r0, r, r1, r2, r3;
1628:              Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Ont nddOnt;
1629:              Ia.Ngn.Cl.Model.Service2 s;
1630:              Ia.Ngn.Cl.Model.ServiceRequestService srs;
1631:              Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Vendor switchVendor;
1632:   
1633:              r = r1 = r2 = r3 = string.Empty;
1634:   
1635:              var result = new Ia.Cl.Model.Result();
1636:   
1637:              serviceId = Ia.Ngn.Cl.Model.Business.Provision.SequentialServiceSuspensionMismatchBetweenServiceRequestServiceAndServiceServiceIdList(out int serviceSuspensionQueueCount, out r1);
1638:   
1639:              if (serviceId != null)
1640:              {
1641:                  r0 = "service: " + serviceId.Replace(":1:965", "") + ",";
1642:                  r2 = serviceId;
1643:   
1644:                  s = Ia.Ngn.Cl.Model.Data.Service2.ReadByIdIncludeAccess(serviceId);
1645:                  srs = Ia.Ngn.Cl.Model.Data.ServiceRequestService.ReadIncludeAccess(serviceId);
1646:   
1647:                  try
1648:                  {
1649:                      if (srs != null && s != null)
1650:                      {
1651:                          service = srs.Service;
1652:   
1653:                          switchVendor = Ia.Ngn.Cl.Model.Data.NetworkDesignDocument.SwitchVendorFromService(service);
1654:   
1655:                          nddOnt = (from n in Ia.Ngn.Cl.Model.Data.NetworkDesignDocument.OntList where srs.Access != null && n.Access.Id == srs.Access.Id select n).SingleOrDefault();
1656:   
1657:                          if (nddOnt != null)
1658:                          {
1659:                              if (Ia.Ngn.Cl.Model.Business.Service.OltIsWithinAllowedToBeProvisionedOltList(nddOnt.Pon.PonGroup.Olt))
1660:                              {
1661:                                  r0 += "service: ";
1662:   
1663:                                  if (switchVendor == Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Vendor.Nokia)
1664:                                  {
1665:                                      gwId = Ia.Ngn.Cl.Model.Data.Nokia.AgcfGatewayRecord.GwIdFromIp(nddOnt.Ip);
1666:   
1667:                                      if (gwId > 0)
1668:                                      {
1669:                                          // below: a little complicated to decide if number should on or off
1670:                                          if (srs.CallBarring == false && srs.ServiceSuspension == false) Ia.Ngn.Cl.Model.Data.Nokia.Ims.AssignServiceSuspensionStateToServiceSubscriber(nokiaIms, service, nddOnt, false, out r2);
1671:                                          else if (srs.CallBarring == true && srs.ServiceSuspension == false) Ia.Ngn.Cl.Model.Data.Nokia.Ims.AssignServiceSuspensionStateToServiceSubscriber(nokiaIms, service, nddOnt, true, out r2);
1672:                                          else if (srs.CallBarring == false && srs.ServiceSuspension == true) Ia.Ngn.Cl.Model.Data.Nokia.Ims.AssignServiceSuspensionStateToServiceSubscriber(nokiaIms, service, nddOnt, true, out r2);
1673:                                          else if (srs.CallBarring == true && srs.ServiceSuspension == true) Ia.Ngn.Cl.Model.Data.Nokia.Ims.AssignServiceSuspensionStateToServiceSubscriber(nokiaIms, service, nddOnt, true, out r2);
1674:   
1675:                                          r2 = Regex.Replace(r2, "[\r\n]+", ". ");
1676:   
1677:                                          // below: read and update
1678:                                          Ia.Ngn.Cl.Model.Data.Nokia.Ims.ReadUpdateAgcfGatewayRecordAndAgcfEndpointListAndSubPartyAndSubscriberAndServiceForGwId(nokiaIms, nddOnt, gwId, out r3);
1679:   
1680:                                          r0 += r2 + "," + r3 + ",";
1681:                                      }
1682:                                      else
1683:                                      {
1684:                                          r0 += "gwId: 0, " + r2 + "," + r3 + ",";
1685:                                      }
1686:                                  }
1687:                                  else if (switchVendor == Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Vendor.Huawei)
1688:                                  {
1689:                                      // below: a little complicated to decide if number should on or off
1690:                                      //if (srs.CallBarring == false && srs.ServiceSuspension == false) Ia.Ngn.Cl.Model.Data.Huawei.Ims.AssignServiceSuspensionStateToServiceSubscriber(huaweiIms, service, false, out r2);
1691:                                      //else if (srs.CallBarring == true && srs.ServiceSuspension == false) Ia.Ngn.Cl.Model.Data.Huawei.Ims.AssignServiceSuspensionStateToServiceSubscriber(huaweiIms, service, true, out r2);
1692:                                      //else if (srs.CallBarring == false && srs.ServiceSuspension == true) Ia.Ngn.Cl.Model.Data.Huawei.Ims.AssignServiceSuspensionStateToServiceSubscriber(huaweiIms, service, true, out r2);
1693:                                      //else if (srs.CallBarring == true && srs.ServiceSuspension == true) Ia.Ngn.Cl.Model.Data.Huawei.Ims.AssignServiceSuspensionStateToServiceSubscriber(huaweiIms, service, true, out r2);
1694:   
1695:                                      r2 = Regex.Replace(r2, "[\r\n]+", "\r\n");
1696:   
1697:                                      // below: read and update
1698:                                      //Ia.Ngn.Cl.Model.Business.Huawei.Ims.ReadSbrForService(huaweiIms, service, out r3);
1699:   
1700:                                      r0 += r2 + "," + r3 + ",";
1701:                                      r0 += @"procedure not active for switchVendor.Name == ""Huawei"",";
1702:                                  }
1703:                                  else
1704:                                  {
1705:                                      r0 += "switchVendor is undefined,";
1706:                                  }
1707:                              }
1708:                              else
1709:                              {
1710:                                  r0 += "Access is not in an allowed to be provisioned OLT, ";
1711:                              }
1712:                          }
1713:                          else
1714:                          {
1715:                              r0 += "nddOnt == null,";
1716:                          }
1717:                      }
1718:                  }
1719:                  catch (Exception ex)
1720:                  {
1721:                      r0 += "Exception: " + ex.ToString();
1722:                  }
1723:              }
1724:              else
1725:              {
1726:                  r0 = "No numbers in service suspension mismatch list. ";
1727:              }
1728:   
1729:              r0 = "Manage: " + r0;
1730:   
1731:              result.AddSuccess(r0);
1732:   
1733:              return result;
1734:          }
1735:   
1736:          ////////////////////////////////////////////////////////////////////////////
1737:          ////////////////////////////////////////////////////////////////////////////
1738:   
1739:          /// <summary>
1740:          ///
1741:          /// </summary>
1742:          public static void CreateService(Ia.Ngn.Cl.Model.Client.Nokia.Ims nokiaIms, Ia.Ngn.Cl.Model.Client.Huawei.Ims huaweiIms, string accessName, string service, int port, Ia.Ngn.Cl.Model.Business.Default.Protocol protocol, bool ignoreRestrictions, out string result)
1743:          {
1744:              if (!string.IsNullOrEmpty(service))
1745:              {
1746:                  if (!string.IsNullOrEmpty(accessName))
1747:                  {
1748:                      if (Ia.Ngn.Cl.Model.Business.Service.NumberIsWithinAllowedNokiaSwitchDomainList(service))
1749:                      {
1750:                          Ia.Ngn.Cl.Model.Business.Provision.CreateNokiaSwitchSubscriber(nokiaIms, accessName, service, port, protocol, ignoreRestrictions, out result);
1751:                      }
1752:                      else if (Ia.Ngn.Cl.Model.Business.Service.NumberIsWithinAllowedHuaweiSwitchDomainList(service))
1753:                      {
1754:                          Ia.Ngn.Cl.Model.Business.Provision.CreateHuaweiSwitchSubscriber(huaweiIms, accessName, service, port, protocol, ignoreRestrictions, out result);
1755:                      }
1756:                      else result = "Error: service number does not belong to a valid vendor switch. ";
1757:                  }
1758:                  else result = "Error: accessName null or empty. ";
1759:              }
1760:              else result = "Error: service null or empty. ";
1761:          }
1762:   
1763:          ////////////////////////////////////////////////////////////////////////////
1764:   
1765:          /// <summary>
1766:          ///
1767:          /// </summary>
1768:          public static void DeleteService(Ia.Ngn.Cl.Model.Client.Nokia.Ims nokiaIms, Ia.Ngn.Cl.Model.Client.Huawei.Ims huaweiIms, string accessName, string service, Ia.Ngn.Cl.Model.Business.Default.Protocol protocol, bool ignoreRestrictions, out string result)
1769:          {
1770:              bool b;
1771:   
1772:              if (!string.IsNullOrEmpty(service))
1773:              {
1774:                  if (Ia.Ngn.Cl.Model.Business.Service.NumberIsWithinAllowedNokiaSwitchDomainList(service))
1775:                  {
1776:                      if (!string.IsNullOrEmpty(accessName))
1777:                      {
1778:                          b = Ia.Ngn.Cl.Model.Business.Provision.DeleteNokiaSwitchSubscriber(nokiaIms, accessName, service, protocol, ignoreRestrictions, out result);
1779:                      }
1780:                      else result = "Error: accessName is null or empty. ";
1781:                  }
1782:                  else if (Ia.Ngn.Cl.Model.Business.Service.NumberIsWithinAllowedHuaweiSwitchDomainList(service))
1783:                  {
1784:                      b = Ia.Ngn.Cl.Model.Business.Provision.DeleteHuaweiSwitchSubscriber(huaweiIms, accessName, service, protocol, ignoreRestrictions, out result);
1785:                  }
1786:                  else result = "Error: service number does not belong to a valid vendor switch. ";
1787:              }
1788:              else
1789:              {
1790:                  result = "Error: service null or empty. ";
1791:              }
1792:          }
1793:   
1794:          ////////////////////////////////////////////////////////////////////////////
1795:          ////////////////////////////////////////////////////////////////////////////    
1796:      }
1797:   
1798:      ////////////////////////////////////////////////////////////////////////////
1799:      ////////////////////////////////////////////////////////////////////////////   
1800:  }