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

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 CreateReadNokiaSwitchSubscriber(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, 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, 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.ReadUpdateSubPartyAndSubscriberAndServiceForService(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 ModifyReadNokiaSwitchSubscriberH248ToSip(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, 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, 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 DeleteReadNokiaSwitchSubscriber(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, 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, 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.ReadUpdateSubPartyAndSubscriberAndServiceForService(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, 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 DeleteReadNokiaSwitchAgcfEndpointAndH248SubscriberFromAnyFsdb(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 CreateReadHuaweiSwitchSubscriber(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.Access.Id, 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 DeleteReadHuaweiSwitchSubscriber(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.Access.Id, 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.Access.Id, 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>(DiscrepancyAndComplementaryServiceMismatchBetweenServiceRequestServiceAndServiceServiceIdAccessIdList(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> DiscrepancyAndComplementaryServiceMismatchBetweenServiceRequestServiceAndServiceServiceIdAccessIdList(int provisionWithinLastNDays)
 840:          {
 841:              Dictionary<string, string> dictionary;
 842:   
 843:              Ia.Ngn.Cl.Model.Data.Provision.ServiceToUpdateServiceIdAccessIdDictionary_ServiceToCreateServiceIdAccessIdDictionary_ServiceToDeleteServiceIdAccessIdDictionary(provisionWithinLastNDays, out Dictionary<string, string> serviceToUpdateServiceIdAccessIdDictionary, out Dictionary<string, string> serviceToCreateServiceIdAccessIdDictionary, out Dictionary<string, string> serviceToDeleteServiceIdAccessIdDictionary);
 844:   
 845:              dictionary = new Dictionary<string, string>(serviceToUpdateServiceIdAccessIdDictionary.Count + serviceToCreateServiceIdAccessIdDictionary.Count + serviceToDeleteServiceIdAccessIdDictionary.Count);
 846:   
 847:              foreach (KeyValuePair<string, string> s in serviceToUpdateServiceIdAccessIdDictionary) 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:          public /*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:   
 967:              // In serviceOntToAnnulInEmsOntSipInfoOrVoipPstnUseList I must make sure that serviceId does not belong to any current service in serviceOntList
 968:              // 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.
 969:   
 970:              foreach (var ontSipInfoServiceOnt in ontSipInfoServiceOntWithinAllowedToBeProvisionedOrMigratedSipOltList)
 971:              {
 972:                  if (!serviceOntWithinAllowedToBeProvisionedOrMigratedSipOltList.Any(u => u.ServiceId == ontSipInfoServiceOnt.ServiceId && u.AccessId == ontSipInfoServiceOnt.AccessId)) // .Contains(serviceOnt) is disastrous here
 973:                  {
 974:                      if (!serviceOntList.Any(u => u.ServiceId == ontSipInfoServiceOnt.ServiceId /*&& u.AccessId == serviceOnt.AccessId*/)) // .Contains(serviceOnt) is disastrous here
 975:                      {
 976:                          if (!serviceOntToAnnulInEmsOntSipInfoOrVoipPstnUseList.Any(u => u.ServiceId == ontSipInfoServiceOnt.ServiceId && u.AccessId == ontSipInfoServiceOnt.AccessId)) // .Contains(serviceOnt) is disastrous here
 977:                          {
 978:                              serviceOntToAnnulInEmsOntSipInfoOrVoipPstnUseList.Add(ontSipInfoServiceOnt);
 979:                          }
 980:                      }
 981:                  }
 982:   
 983:                  /*
 984:                  // below: we will check for and add all NCE records that were created *before* the IMS records
 985:                  if (serviceOntWithinAllowedToBeProvisionedOrMigratedSipOltList.Any(u => u.ServiceId == ontSipInfoServiceOnt.ServiceId && u.AccessId == ontSipInfoServiceOnt.AccessId && u.CreatedDateTime > ontSipInfoServiceOnt.CreatedDateTime))
 986:                  {
 987:                      if (!serviceOntToAnnulInEmsOntSipInfoOrVoipPstnUseList.Any(u => u.ServiceId == ontSipInfoServiceOnt.ServiceId && u.AccessId == ontSipInfoServiceOnt.AccessId))
 988:                      {
 989:                          serviceOntToAnnulInEmsOntSipInfoOrVoipPstnUseList.Add(ontSipInfoServiceOnt);
 990:                      }
 991:                  }
 992:                  */
 993:              }
 994:   
 995:              foreach (var voipPstnUserServiceOnt in voipPstnUserServiceOntWithinAllowedToBeProvisionedOrMigratedSipOltList)
 996:              {
 997:                  if (!serviceOntWithinAllowedToBeProvisionedOrMigratedSipOltList.Any(u => u.ServiceId == voipPstnUserServiceOnt.ServiceId && u.AccessId == voipPstnUserServiceOnt.AccessId)) // .Contains(serviceOnt) is disastrous here
 998:                  {
 999:                      if (!serviceOntList.Any(u => u.ServiceId == voipPstnUserServiceOnt.ServiceId /*&& u.AccessId == serviceOnt.AccessId*/)) // .Contains(serviceOnt) is disastrous here
1000:                      {
1001:                          if (!serviceOntToAnnulInEmsOntSipInfoOrVoipPstnUseList.Any(u => u.ServiceId == voipPstnUserServiceOnt.ServiceId && u.AccessId == voipPstnUserServiceOnt.AccessId)) // .Contains(serviceOnt) is disastrous here
1002:                          {
1003:                              serviceOntToAnnulInEmsOntSipInfoOrVoipPstnUseList.Add(voipPstnUserServiceOnt);
1004:                          }
1005:                      }
1006:                  }
1007:   
1008:                  /*
1009:                  // below: we will check for and add all NCE records that were created *before* the IMS records
1010:                  if (serviceOntWithinAllowedToBeProvisionedOrMigratedSipOltList.Any(u => u.ServiceId == voipPstnUserServiceOnt.ServiceId && u.AccessId == voipPstnUserServiceOnt.AccessId && u.CreatedDateTime > voipPstnUserServiceOnt.CreatedDateTime))
1011:                  {
1012:                      if (!serviceOntToAnnulInEmsOntSipInfoOrVoipPstnUseList.Any(u => u.ServiceId == voipPstnUserServiceOnt.ServiceId && u.AccessId == voipPstnUserServiceOnt.AccessId))
1013:                      {
1014:                          serviceOntToAnnulInEmsOntSipInfoOrVoipPstnUseList.Add(voipPstnUserServiceOnt);
1015:                      }
1016:                  }
1017:                  */
1018:              }
1019:   
1020:              // will exclude exempt numbers
1021:              serviceIdExemptionList = Ia.Ngn.Cl.Model.Data.Provision.ServiceIdOfServiceExemptFromProvisionProcessingList();
1022:              foreach (string serviceId in serviceIdExemptionList)
1023:              {
1024:                  serviceOnt2 = serviceOntToCreateInEmsOntSipInfoOrVoipPstnUserList.SingleOrDefault(u => u.ServiceId == serviceId);
1025:                  if (serviceOnt2 != null) serviceOntToCreateInEmsOntSipInfoOrVoipPstnUserList.Remove(serviceOnt2);
1026:   
1027:                  serviceOnt2 = serviceOntToAnnulInEmsOntSipInfoOrVoipPstnUseList.SingleOrDefault(u => u.ServiceId == serviceId);
1028:                  if (serviceOnt2 != null) serviceOntToAnnulInEmsOntSipInfoOrVoipPstnUseList.Remove(serviceOnt2);
1029:              }
1030:          }
1031:   
1032:          ////////////////////////////////////////////////////////////////////////////
1033:   
1034:          /// <summary>
1035:          ///
1036:          /// </summary>
1037:          public static void ServiceOntToAddToAsbrList_ServiceOntToRemoveFromAsbrList(out List<Ia.Ngn.Cl.Model.Business.ServiceOnt> addList, out List<Ia.Ngn.Cl.Model.Business.ServiceOnt> removeList)
1038:          {
1039:              Ia.Ngn.Cl.Model.Business.ServiceOnt serviceOnt2;
1040:              List<string> serviceIdExemptionList;
1041:              List<Ia.Ngn.Cl.Model.Business.ServiceOnt> serviceOntList, serviceOntWithinAllowedToBeProvisionedOrMigratedHuaweiSwitchNokiaGponOltList;
1042:              List<Ia.Ngn.Cl.Model.Business.ServiceOnt> asbrServiceOntWithinAllowedToBeProvisionedOrMigratedHuaweiSwitchNokiaGponOltList;
1043:   
1044:              addList = new List<Ia.Ngn.Cl.Model.Business.ServiceOnt>();
1045:              removeList = new List<Ia.Ngn.Cl.Model.Business.ServiceOnt>();
1046:   
1047:              //List<string> list;
1048:   
1049:              /*
1050:  select s.Service from Service2 s
1051:  inner join ServiceRequestServices srs on s.Id = srs.Id
1052:  inner join Accesses a on a.Id = srs.Access_Id
1053:  inner join HuSbrs sb on 'sip:+965'+ s.Service +'@ims.moc.kw' = sb.IMPU
1054:  left outer join Asbrs asb on sb.IMPU = asb.PUI
1055:  where (a.Olt = 102010101 or a.Olt = 102010201) -- OLT ids MUB:102010101 QRN:102010201
1056:  and srs.Provisioned = 1
1057:  and asb.Id is null
1058:  order by s.Service
1059:               */
1060:   
1061:              /*
1062:              // for oltId intersect AllowedToBeMigrated with Hu-No OLTs
1063:              var oltIdList = Ia.Ngn.Cl.Model.Data.NetworkDesignDocument.HuaweiSwitchNokiaGponOltIdList;
1064:  
1065:              //var i = Ia.Ngn.Cl.Model.Data.NetworkDesignDocument.OntAccessIdToOntAccessNameDictionary;
1066:  
1067:              using (var db = new Ia.Ngn.Cl.Model.Ngn())
1068:              {
1069:                  var list = (from s in db.Service2s
1070:                              join srs in db.ServiceRequestServices on s.Id equals srs.Id
1071:                              join a in db.Accesses on srs.Access.Id equals a.Id
1072:                              //join sbr in db.HuSbrs on "sip:+965" + s.Service + "@ims.moc.kw" equals sbr.IMPU
1073:                              //join asbr in db.Asbrs on sbr.IMPU equals asbr.PUI into gj
1074:                              //from u in gj.DefaultIfEmpty()
1075:                              where oltIdList.Contains(a.Olt) && srs.Provisioned == true //&& u == null
1076:                              orderby s.Service
1077:                              select new { s.Service, AccessId = a.Id }).ToList();
1078:  
1079:                  //var l = (from a in list select i[a.AccessId]).Distinct().ToList();
1080:                  var l = (from a in list select a.AccessId).Distinct().ToList();
1081:              }
1082:  
1083:  
1084:              //return list;
1085:              */
1086:   
1087:              serviceOntWithinAllowedToBeProvisionedOrMigratedHuaweiSwitchNokiaGponOltList = Ia.Ngn.Cl.Model.Data.Service2.ServiceOntWithinAllowedToBeProvisionedOrMigratedHuaweiSwitchNokiaGponOltList();
1088:              serviceOntList = Ia.Ngn.Cl.Model.Data.Service2.ServiceOntList;
1089:              asbrServiceOntWithinAllowedToBeProvisionedOrMigratedHuaweiSwitchNokiaGponOltList = Ia.Ngn.Cl.Model.Data.Huawei.Asbr.ServiceOntWithinAllowedToBeProvisionedOrMigratedHuaweiSwitchNokiaGponOltList();
1090:   
1091:              foreach (var serviceOnt in serviceOntWithinAllowedToBeProvisionedOrMigratedHuaweiSwitchNokiaGponOltList)
1092:              {
1093:                  if (!asbrServiceOntWithinAllowedToBeProvisionedOrMigratedHuaweiSwitchNokiaGponOltList.Any(u => u.ServiceId == serviceOnt.ServiceId && u.AccessId == serviceOnt.AccessId))
1094:                  {
1095:                      if (!addList.Any(u => u.ServiceId == serviceOnt.ServiceId && u.AccessId == serviceOnt.AccessId)) // .Contains(serviceOnt) is disastrous here
1096:                      {
1097:                          addList.Add(serviceOnt);
1098:                      }
1099:                  }
1100:              }
1101:   
1102:              foreach (var serviceOnt in asbrServiceOntWithinAllowedToBeProvisionedOrMigratedHuaweiSwitchNokiaGponOltList)
1103:              {
1104:                  if (!serviceOntWithinAllowedToBeProvisionedOrMigratedHuaweiSwitchNokiaGponOltList.Any(u => u.ServiceId == serviceOnt.ServiceId && u.AccessId == serviceOnt.AccessId)) // .Contains(serviceOnt) is disastrous here
1105:                  {
1106:                      if (!serviceOntList.Any(u => u.ServiceId == serviceOnt.ServiceId /*&& u.AccessId == serviceOnt.AccessId*/)) // .Contains(serviceOnt) is disastrous here
1107:                      {
1108:                          if (!removeList.Any(u => u.ServiceId == serviceOnt.ServiceId && u.AccessId == serviceOnt.AccessId)) // .Contains(serviceOnt) is disastrous here
1109:                          {
1110:                              removeList.Add(serviceOnt);
1111:                          }
1112:                      }
1113:                  }
1114:              }
1115:   
1116:              // will exclude exempt numbers
1117:              serviceIdExemptionList = Ia.Ngn.Cl.Model.Data.Provision.ServiceIdOfServiceExemptFromProvisionProcessingList();
1118:              foreach (string serviceId in serviceIdExemptionList)
1119:              {
1120:                  serviceOnt2 = addList.SingleOrDefault(u => u.ServiceId == serviceId);
1121:                  if (serviceOnt2 != null) addList.Remove(serviceOnt2);
1122:   
1123:                  serviceOnt2 = removeList.SingleOrDefault(u => u.ServiceId == serviceId);
1124:                  if (serviceOnt2 != null) removeList.Remove(serviceOnt2);
1125:              }
1126:          }
1127:   
1128:          ////////////////////////////////////////////////////////////////////////////
1129:          ////////////////////////////////////////////////////////////////////////////
1130:   
1131:          /// <summary>
1132:          ///
1133:          /// </summary>
1134:          public static List<string> ServiceSuspendedInServiceRequestServiceButNotInServiceStringNumberList
1135:          {
1136:              get
1137:              {
1138:                  List<string> list, sList, srsList;
1139:                  SortedList sl;
1140:   
1141:                  sList = Ia.Ngn.Cl.Model.Data.Service2.ServiceSuspensionIsTrueStringNumberList;
1142:                  srsList = Ia.Ngn.Cl.Model.Data.ServiceRequestService.ServiceSuspensionIsTrueAndProvisionedIsTrueStringNumberList;
1143:   
1144:                  if (sList != null && sList.Count > 0)
1145:                  {
1146:                      if (srsList != null && srsList.Count > 0)
1147:                      {
1148:                          list = new List<string>(sList.Count);
1149:   
1150:                          sl = new SortedList(sList.ToDictionary(s => s));
1151:   
1152:                          foreach (string s in srsList)
1153:                          {
1154:                              if (!sl.ContainsKey(s)) list.Add(s);
1155:                          }
1156:                      }
1157:                      else
1158:                      {
1159:                          list = new List<string>();
1160:                      }
1161:                  }
1162:                  else
1163:                  {
1164:                      if (srsList != null && srsList.Count > 0) list = sList;
1165:                      else list = new List<string>();
1166:                  }
1167:   
1168:                  return list;
1169:              }
1170:          }
1171:   
1172:          ////////////////////////////////////////////////////////////////////////////
1173:   
1174:          /// <summary>
1175:          ///
1176:          /// </summary>
1177:          public static List<string> ServiceActiveInServiceRequestServiceButNotInServiceStringNumberList
1178:          {
1179:              get
1180:              {
1181:                  List<string> list, sList, srsList;
1182:                  SortedList sl;
1183:   
1184:                  sList = Ia.Ngn.Cl.Model.Data.Service2.ServiceSuspensionIsFalseStringNumberList;
1185:                  srsList = Ia.Ngn.Cl.Model.Data.ServiceRequestService.ServiceSuspensionIsFalseStringNumberList;
1186:   
1187:                  if (sList != null && sList.Count > 0)
1188:                  {
1189:                      if (srsList != null && srsList.Count > 0)
1190:                      {
1191:                          list = new List<string>(sList.Count);
1192:   
1193:                          sl = new SortedList(sList.ToDictionary(s => s));
1194:   
1195:                          foreach (string s in srsList)
1196:                          {
1197:                              if (!sl.ContainsKey(s)) list.Add(s);
1198:                          }
1199:                      }
1200:                      else
1201:                      {
1202:                          list = new List<string>();
1203:                      }
1204:                  }
1205:                  else
1206:                  {
1207:                      if (srsList != null && srsList.Count > 0) list = sList;
1208:                      else list = new List<string>();
1209:                  }
1210:   
1211:                  return list;
1212:              }
1213:          }
1214:   
1215:          ////////////////////////////////////////////////////////////////////////////
1216:   
1217:          /// <summary>
1218:          ///
1219:          /// </summary>
1220:          public static List<Ia.Ngn.Cl.Model.Business.Procedure.Process> EmsOntToBeUpdatedFromH248ToSipList()
1221:          {
1222:              List<string> oltSymbolList;
1223:              List<Ia.Ngn.Cl.Model.Business.Procedure.Process> processList;
1224:   
1225:              processList = new List<Ia.Ngn.Cl.Model.Business.Procedure.Process>();
1226:   
1227:              oltSymbolList = Ia.Ngn.Cl.Model.Business.Default.H248ToSipUpdateOltSymbolList;
1228:   
1229:              var list = Ia.Ngn.Cl.Model.Data.Default.DistinctNddOntWhereVaprofIsNotAluSipBAndIgnoreMduForOltSymbolListList(oltSymbolList);
1230:   
1231:              foreach (var l in list)
1232:              {
1233:                  processList.Add(new Ia.Ngn.Cl.Model.Business.Procedure.Process { Ont = l.Ont, Type = Ia.Ngn.Cl.Model.Business.Procedure.ProcessType.Update });
1234:                  processList.Add(new Ia.Ngn.Cl.Model.Business.Procedure.Process { Ont = l.Ont, Type = Ia.Ngn.Cl.Model.Business.Procedure.ProcessType.Read });
1235:              }
1236:   
1237:              return processList;
1238:          }
1239:   
1240:          ////////////////////////////////////////////////////////////////////////////
1241:   
1242:          /// <summary>
1243:          ///
1244:          /// </summary>
1245:          public static List<Ia.Ngn.Cl.Model.Business.Procedure.Process> OntSipInfoOrOntVoipPstnUserToBeCreatedForAnOntUpdatedFromH248ToSipList()
1246:          {
1247:              int pn;
1248:              List<string> oltSymbolList;
1249:              List<Ia.Ngn.Cl.Model.Business.Procedure.Process> processList;
1250:   
1251:              processList = new List<Ia.Ngn.Cl.Model.Business.Procedure.Process>();
1252:   
1253:              oltSymbolList = Ia.Ngn.Cl.Model.Business.Default.H248ToSipUpdateOltSymbolList;
1254:   
1255:              var list = Ia.Ngn.Cl.Model.Data.Default.ServiceAndNddOntAndEmsOntFamilyTypeAndPortWhereAgcfEndpointPortIsNot0AndVaprofIsAluSipBAndSfuEmsOntSipInfoTelDoesNotExistOrMduEmsVagIsSipAndMduEmsVoipPstnUserPnDoesNotExistForOltSymbolListList(oltSymbolList);
1256:   
1257:              /*
1258:               * All Nokia ONTs (SFUs and MDUs) start at port position 1.
1259:               * Huawei ONTs (SFUs) start at port position 1, while Huawei MDUs start at port position 0.
1260:               */
1261:   
1262:              // issue update then read commands
1263:              foreach (var l in list)
1264:              {
1265:                  if (l.EmsOntFamilyType == Ia.Ngn.Cl.Model.Business.Huawei.Ont.FamilyType.Sfu)
1266:                  {
1267:                      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 });
1268:                      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 });
1269:                  }
1270:                  else if (l.EmsOntFamilyType == Ia.Ngn.Cl.Model.Business.Huawei.Ont.FamilyType.Mdu)
1271:                  {
1272:                      pn = Ia.Ngn.Cl.Model.Business.Service.ConvertFlatTermIdPositionToEmsVoipPstnUsersPn(l.Port);
1273:   
1274:                      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 });
1275:                      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 });
1276:                  }
1277:                  else
1278:                  {
1279:                      throw new Exception("EmsOntFamilyType is not concedered. ");
1280:                  }
1281:              }
1282:   
1283:              return processList;
1284:          }
1285:   
1286:          ////////////////////////////////////////////////////////////////////////////
1287:   
1288:          /// <summary>
1289:          ///
1290:          /// </summary>
1291:          public static List<Ia.Ngn.Cl.Model.Business.Procedure.Process> NokiaImsSubscriberToBeUpdatedFromH248ToSipList()
1292:          {
1293:              List<string> oltSymbolList;
1294:              List<Ia.Ngn.Cl.Model.Business.Procedure.Process> processList;
1295:   
1296:              processList = new List<Ia.Ngn.Cl.Model.Business.Procedure.Process>();
1297:   
1298:              oltSymbolList = Ia.Ngn.Cl.Model.Business.Default.H248ToSipUpdateOltSymbolList;
1299:   
1300:              var list = Ia.Ngn.Cl.Model.Data.Default.ServiceAndNddOntWherePrimaryPuidcpeProfileNumberIsNot10AndEmsOntVaprofIsAluSipBAndSfuEmsOntSipInfoTelExistsOrAndMduEmsOntVagIsSipAndMduEmsVoipPstnUserPnExistsForOltSymbolListList(oltSymbolList);
1301:   
1302:              // issue delete then create commands
1303:              foreach (var l in list)
1304:              {
1305:                  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 });
1306:   
1307:                  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 });
1308:              }
1309:   
1310:              return processList;
1311:          }
1312:   
1313:          ////////////////////////////////////////////////////////////////////////////    
1314:          ////////////////////////////////////////////////////////////////////////////    
1315:   
1316:          /// <summary>
1317:          ///
1318:          /// </summary>
1319:          public static void ReadService(Ia.Ngn.Cl.Model.Client.Nokia.Ims nokiaIms, Ia.Ngn.Cl.Model.Client.Huawei.Ims huaweiIms, string input, out Ia.Cl.Model.Result result)
1320:          {
1321:              int gatewayId;
1322:              long number;
1323:              string partyId, r;
1324:              string accessId, service;
1325:              Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Ont nddOnt;
1326:              Ia.Ngn.Cl.Model.Service2 service2;
1327:              Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Vendor switchVendor, accessVendor;
1328:   
1329:              result = new Ia.Cl.Model.Result();
1330:   
1331:              if (!string.IsNullOrEmpty(input))
1332:              {
1333:                  input = input.Trim();
1334:                  input = input.ToLower();
1335:   
1336:                  if (Ia.Ngn.Cl.Model.Business.Service.ServiceHasEightDigits(input))
1337:                  {
1338:                      number = long.Parse(input);
1339:   
1340:                      if (Ia.Ngn.Cl.Model.Business.Service.NumberIsWithinAllowedDomainList(number))
1341:                      {
1342:                          service = number.ToString();
1343:   
1344:                          result.AddSuccess("Service: " + service + " ");
1345:   
1346:                          accessId = Ia.Ngn.Cl.Model.Data.Default.AccessIdFromSwitchInformation(service);
1347:   
1348:                          // below: I should remove the whole section within if(){} below
1349:                          if (string.IsNullOrEmpty(accessId))
1350:                          {
1351:                              var serviceType = Ia.Ngn.Cl.Model.Business.Service.ServiceType.GponService;
1352:                              var serviceId = Ia.Ngn.Cl.Model.Business.Service.ServiceToServiceId(service, serviceType);
1353:   
1354:                              // attempt a read from Service2
1355:                              service2 = Ia.Ngn.Cl.Model.Data.Service2.ReadByIdIncludeAccess(serviceId);
1356:   
1357:                              if (service2 != null && service2.Access != null) accessId = service2.Access.Id;
1358:                              else
1359:                              {
1360:                                  // attempt a read from ServiceRequestService
1361:                                  var serviceRequestService = Ia.Ngn.Cl.Model.Data.ServiceRequestService.ReadIncludeAccess(serviceId);
1362:   
1363:                                  if (serviceRequestService != null && serviceRequestService.Access != null) accessId = serviceRequestService.Access.Id;
1364:                                  else accessId = string.Empty;
1365:                              }
1366:                          }
1367:   
1368:                          if (!string.IsNullOrEmpty(accessId))
1369:                          {
1370:                              // get service information using accessId
1371:   
1372:                              nddOnt = Ia.Ngn.Cl.Model.Data.NetworkDesignDocument.OntAccessIdToOntDictionary.ContainsKey(accessId) ? Ia.Ngn.Cl.Model.Data.NetworkDesignDocument.OntAccessIdToOntDictionary[accessId] : null;
1373:   
1374:                              if (nddOnt != null)
1375:                              {
1376:                                  switchVendor = nddOnt.Pon.PonGroup.Olt.Odf.Router.Vendor;
1377:                                  accessVendor = nddOnt.Pon.PonGroup.Olt.Odf.Vendor;
1378:   
1379:                                  try
1380:                                  {
1381:                                      if (switchVendor == Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Vendor.Nokia)
1382:                                      {
1383:                                          partyId = Ia.Ngn.Cl.Model.Business.NumberFormatConverter.PartyId(service);
1384:                                          gatewayId = Ia.Ngn.Cl.Model.Data.Nokia.AgcfGatewayRecord.GwIdFromPartyId(partyId);
1385:   
1386:                                          if (accessVendor == Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Vendor.Nokia)
1387:                                          {
1388:                                              if (nddOnt.Pon.PonGroup.Olt.IsSip == false) // if H.248
1389:                                              {
1390:                                                  Ia.Ngn.Cl.Model.Data.Nokia.Ims.ReadUpdateAgcfGatewayRecordAndAgcfEndpointListAndSubPartyAndSubscriberAndServiceForGwId(nokiaIms, gatewayId, out r);
1391:   
1392:                                                  result.AddSuccess(r);
1393:                                              }
1394:                                              else // if IsSip == true
1395:                                              {
1396:                                                  result.AddSuccess("SIP process is undefined for No/No");
1397:                                              }
1398:                                          }
1399:                                          else if (accessVendor == Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Vendor.Huawei)
1400:                                          {
1401:                                              if (nddOnt.Pon.PonGroup.Olt.IsSip == false) // if H.248
1402:                                              {
1403:                                                  Ia.Ngn.Cl.Model.Data.Nokia.Ims.ReadUpdateAgcfGatewayRecordAndAgcfEndpointListAndSubPartyAndSubscriberAndServiceForGwId(nokiaIms, gatewayId, out r);
1404:                                              }
1405:                                              else // if IsSip == true
1406:                                              {
1407:                                                  Ia.Ngn.Cl.Model.Data.Nokia.Ims.ReadUpdateSubPartyAndSubscriberAndServiceForService(nokiaIms, service, nddOnt, out r);
1408:                                              }
1409:   
1410:                                              result.AddSuccess(r);
1411:                                          }
1412:                                          else throw new Exception("AccessVendor is undefined");
1413:                                      }
1414:                                      else if (switchVendor == Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Vendor.Huawei)
1415:                                      {
1416:                                          Ia.Ngn.Cl.Model.Business.Huawei.Ims.ReadSbrForService(huaweiIms, service, out string readHuaweiResult);
1417:   
1418:                                          result.AddSuccess(readHuaweiResult);
1419:   
1420:                                          if (accessVendor == Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Vendor.Nokia || accessVendor == Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Vendor.Huawei)
1421:                                          {
1422:                                              Ia.Ngn.Cl.Model.Business.Huawei.Ims.ReadUpdateSbrAndServiceForService(huaweiIms, service, accessId, out r);
1423:   
1424:                                              result.AddSuccess(r);
1425:                                          }
1426:                                          else throw new Exception("accessVendor is undefined");
1427:                                      }
1428:                                      else throw new Exception("switchVendor is undefined");
1429:                                  }
1430:                                  catch (Exception ex)
1431:                                  {
1432:                                      result.AddError("Exception: " + ex.ToString());
1433:                                  }
1434:                              }
1435:                              else result.AddError("NDD ONT is null, does not exist for service: " + service);
1436:                          }
1437:                          else
1438:                          {
1439:                              // get service without knowing accessId
1440:   
1441:                              if (Ia.Ngn.Cl.Model.Business.Service.NumberIsWithinAllowedNokiaSwitchDomainList(service))
1442:                              {
1443:                                  /*
1444:                                  partyId = Ia.Ngn.Cl.Model.Business.NumberFormatConverter.PartyId(service);
1445:                                  gatewayId = Ia.Ngn.Cl.Model.Data.Nokia.AgcfGatewayRecord.GwIdFromPartyId(partyId);
1446:  
1447:                                  Ia.Ngn.Cl.Model.Data.Nokia.Ims.ReadUpdateAgcfGatewayRecordAndAgcfEndpointListAndSubPartyAndSubscriberAndServiceForGwId(nokiaIms, gatewayId, out r);
1448:                                  Ia.Ngn.Cl.Model.Data.Nokia.Ims.ReadUpdateSubPartyAndSubscriberAndServiceForService(nokiaIms, service, null, out r);
1449:                                  */
1450:   
1451:                                  result.AddError("(Service2 is null or service.Access is null) and (serviceRequestService is null or serviceRequestService.Access is null) and (number is not within allowed Huawei switch domain list) for service: " + service);
1452:                              }
1453:                              else if (Ia.Ngn.Cl.Model.Business.Service.NumberIsWithinAllowedHuaweiSwitchDomainList(service))
1454:                              {
1455:                                  Ia.Ngn.Cl.Model.Business.Huawei.Ims.ReadUpdateSbrAndServiceForService(huaweiIms, service, string.Empty, out r);
1456:   
1457:                                  result.AddSuccess(r);
1458:                              }
1459:                              else
1460:                              {
1461:                                  throw new Exception("switchVendor is undefined");
1462:                              }
1463:                          }
1464:   
1465:   
1466:                          // this is a sensitive issue. later I will allow storing empty accessId
1467:                          accessId = Ia.Ngn.Cl.Model.Data.Default.AccessIdFromSwitchInformation(service);
1468:   
1469:                          //if (!string.IsNullOrEmpty(accessId))
1470:                          //{
1471:                          Ia.Ngn.Cl.Model.Data.Service2.UpdateGponServiceAccess(service, accessId, Guid.Empty, out Ia.Cl.Model.Result updateServiceAccessResult);
1472:   
1473:                          result.AddResult(updateServiceAccessResult);
1474:                          //}
1475:                      }
1476:                      else result.AddError("Number \"" + number + "\" does not belong to the network");
1477:                  }
1478:                  else result.AddError("Input is not an eight digit number");
1479:              }
1480:              else result.AddError("No input was entered");
1481:          }
1482:   
1483:          ////////////////////////////////////////////////////////////////////////////    
1484:   
1485:          /// <summary>
1486:          ///
1487:          /// </summary>
1488:          public static void UpdateSupplementaryService(Ia.Ngn.Cl.Model.Client.Nokia.Ims nokiaIms, Ia.Ngn.Cl.Model.Client.Huawei.Ims huaweiIms, string input, Ia.Ngn.Cl.Model.Business.Service.SupplementaryService supplementaryService, bool supplementaryServiceState, out Ia.Cl.Model.Result result)
1489:          {
1490:              long number;
1491:              string r;
1492:              string accessId, service;
1493:              Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Ont nddOnt;
1494:              Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Vendor switchVendor, accessVendor;
1495:   
1496:              result = new Ia.Cl.Model.Result();
1497:   
1498:              if (!string.IsNullOrEmpty(input))
1499:              {
1500:                  input = input.Trim();
1501:                  input = input.ToLower();
1502:   
1503:                  if (Ia.Ngn.Cl.Model.Business.Service.ServiceHasEightDigits(input))
1504:                  {
1505:                      number = long.Parse(input);
1506:   
1507:                      if (Ia.Ngn.Cl.Model.Business.Service.NumberIsWithinAllowedDomainList(number))
1508:                      {
1509:                          service = number.ToString();
1510:   
1511:                          result.AddSuccess("Service: " + service + " ");
1512:   
1513:                          accessId = Ia.Ngn.Cl.Model.Data.Default.AccessIdFromSwitchInformation(service);
1514:   
1515:                          if (!string.IsNullOrEmpty(accessId))
1516:                          {
1517:                              nddOnt = Ia.Ngn.Cl.Model.Data.NetworkDesignDocument.OntAccessIdToOntDictionary.ContainsKey(accessId) ? Ia.Ngn.Cl.Model.Data.NetworkDesignDocument.OntAccessIdToOntDictionary[accessId] : null;
1518:   
1519:                              if (nddOnt != null)
1520:                              {
1521:                                  switchVendor = nddOnt.Pon.PonGroup.Olt.Odf.Router.Vendor;
1522:                                  accessVendor = nddOnt.Pon.PonGroup.Olt.Odf.Vendor;
1523:   
1524:                                  try
1525:                                  {
1526:                                      if (switchVendor == Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Vendor.Nokia)
1527:                                      {
1528:                                          Ia.Ngn.Cl.Model.Data.Nokia.Ims.AssignSupplementaryService(nokiaIms, service, nddOnt, supplementaryService, supplementaryServiceState, out r);
1529:   
1530:                                          result.AddSuccess(r);
1531:                                      }
1532:                                      else if (switchVendor == Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Vendor.Huawei)
1533:                                      {
1534:                                          Ia.Ngn.Cl.Model.Data.Huawei.Ims.AssignSupplementaryService(huaweiIms, service, supplementaryService, supplementaryServiceState, out r);
1535:   
1536:                                          result.AddSuccess(r);
1537:                                      }
1538:                                      else
1539:                                      {
1540:                                          throw new Exception("switchVendor is undefined, ");
1541:                                      }
1542:                                  }
1543:                                  catch (Exception ex)
1544:                                  {
1545:                                      result.AddError("Exception: " + ex.ToString());
1546:                                  }
1547:                              }
1548:                              else result.AddError("NDD ONT is null, does not exist for service: " + service);
1549:                          }
1550:                          else result.AddError("AccessId is null or does not exist for service: " + service);
1551:                      }
1552:                      else result.AddError("Number \"" + number + "\" does not belong to the network");
1553:                  }
1554:                  else result.AddError("Input is not an eight digit number");
1555:              }
1556:              else result.AddError("No input was entered");
1557:          }
1558:   
1559:          ////////////////////////////////////////////////////////////////////////////
1560:   
1561:          /// <summary>
1562:          ///
1563:          /// </summary>
1564:          public static Ia.Cl.Model.Result ManageServiceProvisioning(Ia.Ngn.Cl.Model.Client.Nokia.Ims nokiaIms, Ia.Ngn.Cl.Model.Client.Huawei.Ims huaweiIms)
1565:          {
1566:              int gwId, number, provisionWithinLastNDays;
1567:              string service, serviceId, progressCounterString, r0, r, r2, r3;
1568:              Ia.Cl.Model.Result result, r4;
1569:              Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Ont srsNddOnt, sNddOnt;
1570:              Ia.Ngn.Cl.Model.Service2 service2;
1571:              Ia.Ngn.Cl.Model.ServiceRequestService serviceRequestService;
1572:              Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Vendor switchVendor;
1573:   
1574:              r = progressCounterString = r2 = r3 = string.Empty;
1575:              r4 = new Ia.Cl.Model.Result();
1576:              result = new Ia.Cl.Model.Result();
1577:   
1578:              provisionWithinLastNDays = 0; // 0 means earliest request datetime huaweiIms, 
1579:   
1580:              serviceId = Ia.Ngn.Cl.Model.Business.Provision.SequentialDiscrepancyAndComplementaryServiceMismatchBetweenServiceRequestServiceAndServiceListItem(provisionWithinLastNDays, out int serviceQueueCount, out progressCounterString);
1581:   
1582:              //serviceId = "23717888:1:965";
1583:   
1584:              if (serviceId != null)
1585:              {
1586:                  r0 = "service: " + serviceId.Replace(":1:965", "") + " " + progressCounterString + ": ";
1587:                  r2 = serviceId;
1588:   
1589:                  service2 = Ia.Ngn.Cl.Model.Data.Service2.ReadByIdIncludeAccess(serviceId);
1590:                  serviceRequestService = Ia.Ngn.Cl.Model.Data.ServiceRequestService.ReadIncludeAccess(serviceId);
1591:   
1592:                  try
1593:                  {
1594:                      if (serviceRequestService != null)
1595:                      {
1596:                          if (serviceRequestService.Provisioned)
1597:                          {
1598:                              service = serviceRequestService.Service;
1599:   
1600:                              if (int.TryParse(service, out number))
1601:                              {
1602:                                  switchVendor = Ia.Ngn.Cl.Model.Data.NetworkDesignDocument.SwitchVendorFromService(service);
1603:   
1604:                                  srsNddOnt = (from n in Ia.Ngn.Cl.Model.Data.NetworkDesignDocument.OntList 
1605:                                               where serviceRequestService.Access != null && n.Access.Id == serviceRequestService.Access.Id 
1606:                                               select n).SingleOrDefault();
1607:   
1608:                                  if (service2 == null)
1609:                                  {
1610:                                      // create number in service
1611:                                      r0 += "create: ";
1612:   
1613:                                      if (srsNddOnt != null)
1614:                                      {
1615:                                          if (Ia.Ngn.Cl.Model.Business.Service.OltIsWithinAllowedToBeProvisionedOltList(srsNddOnt.Pon.PonGroup.Olt))
1616:                                          {
1617:                                              if (Ia.Ngn.Cl.Model.Business.Service.NumberIsWithinAllowedRouterDomainList(srsNddOnt, service))
1618:                                              {
1619:                                                  if (switchVendor == Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Vendor.Nokia)
1620:                                                  {
1621:                                                      r0 += "Nokia: ";
1622:   
1623:                                                      // make sure the number is not suspended before creating it
1624:                                                      Ia.Ngn.Cl.Model.Data.ServiceRequestService.UpdateServiceSuspension(service, false, Guid.Empty, out r4);
1625:   
1626:                                                      Ia.Ngn.Cl.Model.Business.Provision.CreateReadNokiaSwitchSubscriber(nokiaIms, srsNddOnt.Access.Name, service, Ia.Ngn.Cl.Model.Business.Default.PortUndefinedOrInvalidOrUnknown, Ia.Ngn.Cl.Model.Business.Default.Protocol.DefaultAsInNdd, false, out r);
1627:                                                  }
1628:                                                  else if (switchVendor == Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Vendor.Huawei)
1629:                                                  {
1630:                                                      r0 += "Huawei: ";
1631:   
1632:                                                      // make sure the number is not suspend before creating it
1633:                                                      Ia.Ngn.Cl.Model.Data.ServiceRequestService.UpdateServiceSuspension(service, false, Guid.Empty, out r4);
1634:   
1635:                                                      // we I will completely remove any existing number before installing it again to make sure it installs fresh
1636:                                                      Ia.Ngn.Cl.Model.Business.Provision.DeleteReadHuaweiSwitchSubscriber(huaweiIms, srsNddOnt.Access.Name, service, Ia.Ngn.Cl.Model.Business.Default.Protocol.DefaultAsInNdd, false, out r);
1637:   
1638:                                                      Ia.Ngn.Cl.Model.Business.Provision.CreateReadHuaweiSwitchSubscriber(huaweiIms, srsNddOnt.Access.Name, service, Ia.Ngn.Cl.Model.Business.Default.PortUndefinedOrInvalidOrUnknown, Ia.Ngn.Cl.Model.Business.Default.Protocol.DefaultAsInNdd, false, out r);
1639:                                                  }
1640:                                                  else
1641:                                                  {
1642:                                                      throw new Exception("switchVendor is undefined, ");
1643:                                                  }
1644:                                              }
1645:                                              else
1646:                                              {
1647:                                                  r0 += "service is not within allowed router domain list. ";
1648:                                              }
1649:   
1650:                                              r0 += r;
1651:                                          }
1652:                                          else
1653:                                          {
1654:                                              r0 += "Access is not in an allowed to be provisioned OLT. ";
1655:                                          }
1656:                                      }
1657:                                      else r0 += "SRS Ont is null. ";
1658:                                  }
1659:                                  else
1660:                                  {
1661:                                      // check services
1662:                                      r0 += "update: ";
1663:   
1664:                                      // note that I will install services according to the Access given by service variable, not SRS access
1665:                                      sNddOnt = (from n in Ia.Ngn.Cl.Model.Data.NetworkDesignDocument.OntList where service2.Access != null && n.Access.Id == service2.Access.Id select n).SingleOrDefault();
1666:   
1667:                                      if (/*srsNddOnt != null &&*/ sNddOnt != null)
1668:                                      {
1669:                                          //if (Ia.Ngn.Cl.Model.Business.Service.OltIsWithinAllowedToBeProvisionedOltList(srsNddOnt.Pon.PonGroup.Olt))
1670:                                          if (Ia.Ngn.Cl.Model.Business.Service.OltIsWithinAllowedToBeProvisionedOltList(sNddOnt.Pon.PonGroup.Olt))
1671:                                          {
1672:                                              if (Ia.Ngn.Cl.Model.Business.Service.NumberIsWithinAllowedRouterDomainList(sNddOnt, service))
1673:                                              {
1674:                                                  //if (srsNddOnt.Id == sNddOnt.Id)
1675:                                                  //{
1676:                                                  r0 += "service: ";
1677:   
1678:                                                  if (switchVendor == Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Vendor.Nokia)
1679:                                                  {
1680:                                                      r0 += "Nokia: ";
1681:   
1682:                                                      // below: send change command to IMS
1683:                                                      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);
1684:                                                      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);
1685:                                                      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);
1686:                                                      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); // do not change
1687:                                                      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);
1688:                                                      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);
1689:                                                      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);
1690:                                                      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);
1691:                                                      // 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
1692:                                                      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);
1693:   
1694:                                                      // below: a little complicated to decide if number should on or off
1695:                                                      else if (serviceRequestService.CallBarring == false && serviceRequestService.ServiceSuspension == false) Ia.Ngn.Cl.Model.Data.Nokia.Ims.AssignServiceSuspensionStateToServiceSubscriber(nokiaIms, service, sNddOnt, false, out r2);
1696:                                                      else if (serviceRequestService.CallBarring == true && serviceRequestService.ServiceSuspension == false) Ia.Ngn.Cl.Model.Data.Nokia.Ims.AssignServiceSuspensionStateToServiceSubscriber(nokiaIms, service, sNddOnt, true, out r2);
1697:                                                      else if (serviceRequestService.CallBarring == false && serviceRequestService.ServiceSuspension == true) Ia.Ngn.Cl.Model.Data.Nokia.Ims.AssignServiceSuspensionStateToServiceSubscriber(nokiaIms, service, sNddOnt, true, out r2);
1698:                                                      else if (serviceRequestService.CallBarring == true && serviceRequestService.ServiceSuspension == true) Ia.Ngn.Cl.Model.Data.Nokia.Ims.AssignServiceSuspensionStateToServiceSubscriber(nokiaIms, service, sNddOnt, true, out r2);
1699:                                                      else r2 = "no difference in services. ";
1700:   
1701:                                                      if (sNddOnt.Pon.PonGroup.Olt.IsSip == false) // if H.248
1702:                                                      {
1703:                                                          gwId = Ia.Ngn.Cl.Model.Data.Nokia.AgcfGatewayRecord.GwIdFromIp(sNddOnt.Ip);
1704:   
1705:                                                          if (gwId > 0)
1706:                                                          {
1707:                                                              Ia.Ngn.Cl.Model.Data.Nokia.Ims.ReadUpdateAgcfGatewayRecordAndAgcfEndpointListAndSubPartyAndSubscriberAndServiceForGwId(nokiaIms/*, sNddOnt*/, gwId, out r3);
1708:   
1709:                                                              r0 += r2 + "," + r3 + ". ";
1710:                                                          }
1711:                                                          else
1712:                                                          {
1713:                                                              r0 += "gwId: 0, " + r2 + "," + r3 + ". ";
1714:                                                          }
1715:                                                      }
1716:                                                      else // if IsSip == true
1717:                                                      {
1718:                                                          Ia.Ngn.Cl.Model.Data.Nokia.Ims.ReadUpdateSubPartyAndSubscriberAndServiceForService(nokiaIms, service, sNddOnt, out r3);
1719:                                                          r0 += r2 + "," + r3 + ". ";
1720:                                                      }
1721:                                                  }
1722:                                                  else if (switchVendor == Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Vendor.Huawei)
1723:                                                  {
1724:                                                      r0 += "Huawei: ";
1725:   
1726:                                                      // below: send change command to IMS
1727:                                                      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);
1728:                                                      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);
1729:                                                      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);
1730:                                                      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);
1731:                                                      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); // do not change
1732:                                                      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);
1733:                                                      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);
1734:   
1735:                                                      // below: data is insufficient to decide
1736:                                                      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);
1737:                                                      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);
1738:   
1739:                                                      // below: data is insufficient to decide
1740:                                                      // below: a little complicated to decide if number should on or off
1741:                                                      //else if (srs.CallBarring == false && srs.ServiceSuspension == false) Ia.Ngn.Cl.Model.Data.Huawei.Ims.AssignServiceSuspensionStateToServiceSubscriber(huaweiIms, service, false, out r2);
1742:                                                      //else if (srs.CallBarring == true && srs.ServiceSuspension == false) Ia.Ngn.Cl.Model.Data.Huawei.Ims.AssignServiceSuspensionStateToServiceSubscriber(huaweiIms, service, true, out r2);
1743:                                                      //else if (srs.CallBarring == false && srs.ServiceSuspension == true) Ia.Ngn.Cl.Model.Data.Huawei.Ims.AssignServiceSuspensionStateToServiceSubscriber(huaweiIms, service, true, out r2);
1744:                                                      //else if (srs.CallBarring == true && srs.ServiceSuspension == true) Ia.Ngn.Cl.Model.Data.Huawei.Ims.AssignServiceSuspensionStateToServiceSubscriber(huaweiIms, service, true, out r2);
1745:   
1746:                                                      else r2 = "no difference in services. ";
1747:   
1748:                                                      // below: read and update
1749:                                                      Ia.Ngn.Cl.Model.Business.Huawei.Ims.ReadUpdateSbrAndServiceForService(huaweiIms, service, sNddOnt.Access.Id, out r3);
1750:   
1751:                                                      r0 += r2 + "," + r3 + ". ";
1752:                                                  }
1753:                                                  else
1754:                                                  {
1755:                                                      throw new Exception("switchVendor is undefined, ");
1756:                                                  }
1757:                                                  /*
1758:                                                  }
1759:                                                      else
1760:                                                      {
1761:                                                          // update service access
1762:                                                          r0 += "update service access: delete: function suspended pending investigation. Service.NddAccess:" + sNddOnt.Access.Name;// + ", SRS.NddAccess:" + srsNddOnt.Access.Name;
1763:  
1764:                                                          /*
1765:                                                          if (switchVendor == Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Vendor.Nokia)
1766:                                                          {
1767:                                                              r0 += "Nokia: ";
1768:  
1769:                                                              Ia.Ngn.Cl.Model.Business.Provision.DeleteNokiaSwitchSubscriber(nokiaIms, sNddOnt.Access.Name, service, Ia.Ngn.Cl.Model.Business.Default.Protocol.DefaultAsInNdd, false, out r);
1770:                                                          }
1771:                                                          else if (switchVendor == Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Vendor.Huawei)
1772:                                                          {
1773:                                                              r0 += "Huawei: ";
1774:  
1775:                                                              Ia.Ngn.Cl.Model.Business.Provision.DeleteHuaweiSwitchSubscriber(huaweiIms, sNddOnt.Access.Name, service, Ia.Ngn.Cl.Model.Business.Default.Protocol.DefaultAsInNdd, false, out r);
1776:                                                          }
1777:                                                          else
1778:                                                          {
1779:                                                              throw new Exception("switchVendor is undefined, ");
1780:                                                          }
1781:                                                          * /
1782:                                                      }
1783:                                                          */
1784:                                              }
1785:                                              else
1786:                                              {
1787:                                                  r0 += "service is not within allowed router domain list. ";
1788:                                              }
1789:                                          }
1790:                                          else
1791:                                          {
1792:                                              r0 += "Access is not in an allowed to be provisioned OLT. ";
1793:                                          }
1794:                                      }
1795:                                      else
1796:                                      {
1797:                                          // temp 
1798:                                          //Ia.Ngn.Cl.Model.Data.Msmq.ServiceQueue.Enqueue(service);
1799:   
1800:                                          r0 += "Service access and/or service request service access is null. ";
1801:                                      }
1802:                                  }
1803:                              }
1804:                              else
1805:                              {
1806:                                  r0 += "service is not a valid number. ";
1807:                              }
1808:                          }
1809:                          else //if(!serviceRequestService.Provisioned)
1810:                          {
1811:                              service = serviceRequestService.Service;
1812:   
1813:                              if (int.TryParse(service, out number))
1814:                              {
1815:                                  switchVendor = Ia.Ngn.Cl.Model.Data.NetworkDesignDocument.SwitchVendorFromService(service);
1816:   
1817:                                  if (service2 != null)
1818:                                  {
1819:                                      // delete number from service
1820:                                      r0 += "delete: ";
1821:   
1822:                                      sNddOnt = (from n in Ia.Ngn.Cl.Model.Data.NetworkDesignDocument.OntList where service2.Access != null && n.Access.Id == service2.Access.Id select n).SingleOrDefault();
1823:   
1824:                                      if (sNddOnt != null)
1825:                                      {
1826:                                          if (Ia.Ngn.Cl.Model.Business.Service.OltIsWithinAllowedToBeProvisionedOltList(sNddOnt.Pon.PonGroup.Olt))
1827:                                          {
1828:                                              if (Ia.Ngn.Cl.Model.Business.Service.NumberIsWithinAllowedRouterDomainList(sNddOnt, service))
1829:                                              {
1830:                                                  if (switchVendor == Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Vendor.Nokia)
1831:                                                  {
1832:                                                      r0 += "Nokia: ";
1833:   
1834:                                                      Ia.Ngn.Cl.Model.Business.Provision.DeleteReadNokiaSwitchSubscriber(nokiaIms, sNddOnt.Access.Name, service, Ia.Ngn.Cl.Model.Business.Default.Protocol.DefaultAsInNdd, false, out r);
1835:                                                  }
1836:                                                  else if (switchVendor == Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Vendor.Huawei)
1837:                                                  {
1838:                                                      r0 += "Huawei: ";
1839:   
1840:                                                      Ia.Ngn.Cl.Model.Business.Provision.DeleteReadHuaweiSwitchSubscriber(huaweiIms, sNddOnt.Access.Name, service, Ia.Ngn.Cl.Model.Business.Default.Protocol.DefaultAsInNdd, false, out r);
1841:                                                  }
1842:                                                  else
1843:                                                  {
1844:                                                      throw new Exception("switchVendor is undefined, ");
1845:                                                  }
1846:                                              }
1847:                                              else
1848:                                              {
1849:                                                  r0 += "service is not within allowed router domain list. ";
1850:                                              }
1851:   
1852:                                              r0 += r;
1853:                                          }
1854:                                          else
1855:                                          {
1856:                                              r0 += "Access is not in an allowed to be provisioned OLT. ";
1857:                                          }
1858:                                      }
1859:                                      else r0 += "SRS Ont is null. ";
1860:                                  }
1861:                                  else
1862:                                  {
1863:                                      throw new Exception("switchVendor is null. ");
1864:                                  }
1865:                              }
1866:                              else
1867:                              {
1868:                                  r0 += "service is not a valid number. ";
1869:                              }
1870:                          }
1871:                      }
1872:                      else
1873:                      {
1874:                          r0 += "serviceRequestService is null. ";
1875:                      }
1876:                  }
1877:                  catch (Exception ex)
1878:                  {
1879:                      r0 += "Exception: " + ex.ToString();
1880:                  }
1881:              }
1882:              else
1883:              {
1884:                  r0 = "No numbers in service discrepancy and complementary service mismatch list. ";
1885:              }
1886:   
1887:              r0 = "Manage: " + r0;
1888:   
1889:              result.AddSuccess(r0);
1890:   
1891:              return result;
1892:          }
1893:   
1894:          ////////////////////////////////////////////////////////////////////////////
1895:   
1896:          /// <summary>
1897:          ///
1898:          /// </summary>
1899:          public static Ia.Cl.Model.Result ManageServiceSuspension(Ia.Ngn.Cl.Model.Client.Nokia.Ims nokiaIms, Ia.Ngn.Cl.Model.Client.Huawei.Ims huaweiIms)
1900:          {
1901:              int gwId;
1902:              string service, serviceId, r0, r, r1, r2, r3;
1903:              Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Ont nddOnt;
1904:              Ia.Ngn.Cl.Model.Service2 s;
1905:              Ia.Ngn.Cl.Model.ServiceRequestService srs;
1906:              Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Vendor switchVendor;
1907:   
1908:              r = r1 = r2 = r3 = string.Empty;
1909:   
1910:              var result = new Ia.Cl.Model.Result();
1911:   
1912:              serviceId = Ia.Ngn.Cl.Model.Business.Provision.SequentialServiceSuspensionMismatchBetweenServiceRequestServiceAndServiceServiceIdList(out int serviceSuspensionQueueCount, out r1);
1913:   
1914:              if (serviceId != null)
1915:              {
1916:                  r0 = "service: " + serviceId.Replace(":1:965", "") + ",";
1917:                  r2 = serviceId;
1918:   
1919:                  s = Ia.Ngn.Cl.Model.Data.Service2.ReadByIdIncludeAccess(serviceId);
1920:                  srs = Ia.Ngn.Cl.Model.Data.ServiceRequestService.ReadIncludeAccess(serviceId);
1921:   
1922:                  try
1923:                  {
1924:                      if (srs != null && s != null)
1925:                      {
1926:                          service = srs.Service;
1927:   
1928:                          switchVendor = Ia.Ngn.Cl.Model.Data.NetworkDesignDocument.SwitchVendorFromService(service);
1929:   
1930:                          nddOnt = (from n in Ia.Ngn.Cl.Model.Data.NetworkDesignDocument.OntList where srs.Access != null && n.Access.Id == srs.Access.Id select n).SingleOrDefault();
1931:   
1932:                          if (nddOnt != null)
1933:                          {
1934:                              if (Ia.Ngn.Cl.Model.Business.Service.OltIsWithinAllowedToBeProvisionedOltList(nddOnt.Pon.PonGroup.Olt))
1935:                              {
1936:                                  r0 += "service: ";
1937:   
1938:                                  if (switchVendor == Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Vendor.Nokia)
1939:                                  {
1940:                                      gwId = Ia.Ngn.Cl.Model.Data.Nokia.AgcfGatewayRecord.GwIdFromIp(nddOnt.Ip);
1941:   
1942:                                      if (gwId > 0)
1943:                                      {
1944:                                          // below: a little complicated to decide if number should on or off
1945:                                          if (srs.CallBarring == false && srs.ServiceSuspension == false) Ia.Ngn.Cl.Model.Data.Nokia.Ims.AssignServiceSuspensionStateToServiceSubscriber(nokiaIms, service, nddOnt, false, out r2);
1946:                                          else if (srs.CallBarring == true && srs.ServiceSuspension == false) Ia.Ngn.Cl.Model.Data.Nokia.Ims.AssignServiceSuspensionStateToServiceSubscriber(nokiaIms, service, nddOnt, true, out r2);
1947:                                          else if (srs.CallBarring == false && srs.ServiceSuspension == true) Ia.Ngn.Cl.Model.Data.Nokia.Ims.AssignServiceSuspensionStateToServiceSubscriber(nokiaIms, service, nddOnt, true, out r2);
1948:                                          else if (srs.CallBarring == true && srs.ServiceSuspension == true) Ia.Ngn.Cl.Model.Data.Nokia.Ims.AssignServiceSuspensionStateToServiceSubscriber(nokiaIms, service, nddOnt, true, out r2);
1949:   
1950:                                          r2 = Regex.Replace(r2, "[\r\n]+", ". ");
1951:   
1952:                                          // below: read and update
1953:                                          Ia.Ngn.Cl.Model.Data.Nokia.Ims.ReadUpdateAgcfGatewayRecordAndAgcfEndpointListAndSubPartyAndSubscriberAndServiceForGwId(nokiaIms, gwId, out r3);
1954:   
1955:                                          r0 += r2 + "," + r3 + ",";
1956:                                      }
1957:                                      else
1958:                                      {
1959:                                          r0 += "gwId: 0, " + r2 + "," + r3 + ",";
1960:                                      }
1961:                                  }
1962:                                  else if (switchVendor == Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Vendor.Huawei)
1963:                                  {
1964:                                      // below: a little complicated to decide if number should on or off
1965:                                      //if (srs.CallBarring == false && srs.ServiceSuspension == false) Ia.Ngn.Cl.Model.Data.Huawei.Ims.AssignServiceSuspensionStateToServiceSubscriber(huaweiIms, service, false, out r2);
1966:                                      //else if (srs.CallBarring == true && srs.ServiceSuspension == false) Ia.Ngn.Cl.Model.Data.Huawei.Ims.AssignServiceSuspensionStateToServiceSubscriber(huaweiIms, service, true, out r2);
1967:                                      //else if (srs.CallBarring == false && srs.ServiceSuspension == true) Ia.Ngn.Cl.Model.Data.Huawei.Ims.AssignServiceSuspensionStateToServiceSubscriber(huaweiIms, service, true, out r2);
1968:                                      //else if (srs.CallBarring == true && srs.ServiceSuspension == true) Ia.Ngn.Cl.Model.Data.Huawei.Ims.AssignServiceSuspensionStateToServiceSubscriber(huaweiIms, service, true, out r2);
1969:   
1970:                                      r2 = Regex.Replace(r2, "[\r\n]+", "\r\n");
1971:   
1972:                                      // below: read and update
1973:                                      //Ia.Ngn.Cl.Model.Business.Huawei.Ims.ReadSbrForService(huaweiIms, service, out r3);
1974:   
1975:                                      r0 += r2 + "," + r3 + ",";
1976:                                      r0 += @"procedure not active for switchVendor.Name == ""Huawei"",";
1977:                                  }
1978:                                  else
1979:                                  {
1980:                                      r0 += "switchVendor is undefined,";
1981:                                  }
1982:                              }
1983:                              else
1984:                              {
1985:                                  r0 += "Access is not in an allowed to be provisioned OLT, ";
1986:                              }
1987:                          }
1988:                          else
1989:                          {
1990:                              r0 += "nddOnt == null,";
1991:                          }
1992:                      }
1993:                  }
1994:                  catch (Exception ex)
1995:                  {
1996:                      r0 += "Exception: " + ex.ToString();
1997:                  }
1998:              }
1999:              else
2000:              {
2001:                  r0 = "No numbers in service suspension mismatch list. ";
2002:              }
2003:   
2004:              r0 = "Manage: " + r0;
2005:   
2006:              result.AddSuccess(r0);
2007:   
2008:              return result;
2009:          }
2010:   
2011:          ////////////////////////////////////////////////////////////////////////////
2012:   
2013:          /// <summary>
2014:          ///
2015:          /// </summary>
2016:          public static Ia.Cl.Model.Result ManageProvisionQueue(Ia.Ngn.Cl.Model.Client.Nokia.Ims nokiaIms, Ia.Ngn.Cl.Model.Client.Huawei.Ims huaweiIms)
2017:          {
2018:              string r;
2019:              Ia.Cl.Model.Result result;
2020:   
2021:              result = new Ia.Cl.Model.Result();
2022:   
2023:              var message = Ia.Ngn.Cl.Model.Data.Msmq.ProvisionQueue.ProvisionApplication.Dequeue;
2024:   
2025:              if (message.Process == Ia.Ngn.Cl.Model.Data.Msmq.Queue.Process.CreateReadServiceAccess)
2026:              {
2027:                  var port = Ia.Ngn.Cl.Model.Business.Default.PortUndefinedOrInvalidOrUnknown;
2028:                  var ignoreRestrictions = false;
2029:                  var protocol = Ia.Ngn.Cl.Model.Business.Default.Protocol.DefaultAsInNdd;
2030:   
2031:                  Ia.Ngn.Cl.Model.Business.Provision.CreateReadService(nokiaIms, huaweiIms, message.AccessName, message.Service, port, protocol, ignoreRestrictions, out r);
2032:   
2033:                  result.AddSuccess("Create/Read service: " + r);
2034:              }
2035:              else if (message.Process == Ia.Ngn.Cl.Model.Data.Msmq.Queue.Process.DeleteReadServiceAccess)
2036:              {
2037:                  var ignoreRestrictions = false;
2038:                  var protocol = Ia.Ngn.Cl.Model.Business.Default.Protocol.DefaultAsInNdd;
2039:   
2040:                  Ia.Ngn.Cl.Model.Business.Provision.DeleteReadService(nokiaIms, huaweiIms, message.AccessName, message.Service, protocol, ignoreRestrictions, out r);
2041:   
2042:                  result.AddSuccess("Delete/Read service: " + r);
2043:              }
2044:              else if (message.Process == Ia.Ngn.Cl.Model.Data.Msmq.Queue.Process.UpdateServiceSupplementaryService)
2045:              {
2046:                  Ia.Ngn.Cl.Model.Business.Provision.UpdateSupplementaryService(nokiaIms, huaweiIms, message.Service, message.ServiceSupplementaryService, message.ServiceSupplementaryServiceState, out Ia.Cl.Model.Result r2);
2047:   
2048:                  result.AddSuccess("Set/Reset Service Supplementary Service: " + r2.Message);
2049:              }
2050:              else
2051:              {
2052:                  throw new Exception("Unknown process");
2053:              }
2054:   
2055:              return result;
2056:          }
2057:   
2058:          ////////////////////////////////////////////////////////////////////////////
2059:          ////////////////////////////////////////////////////////////////////////////
2060:   
2061:          /// <summary>
2062:          ///
2063:          /// </summary>
2064:          public static void CreateReadService(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)
2065:          {
2066:              if (!string.IsNullOrEmpty(service))
2067:              {
2068:                  if (!string.IsNullOrEmpty(accessName))
2069:                  {
2070:                      if (Ia.Ngn.Cl.Model.Business.Service.NumberIsWithinAllowedNokiaSwitchDomainList(service))
2071:                      {
2072:                          Ia.Ngn.Cl.Model.Business.Provision.CreateReadNokiaSwitchSubscriber(nokiaIms, accessName, service, port, protocol, ignoreRestrictions, out result);
2073:                      }
2074:                      else if (Ia.Ngn.Cl.Model.Business.Service.NumberIsWithinAllowedHuaweiSwitchDomainList(service))
2075:                      {
2076:                          Ia.Ngn.Cl.Model.Business.Provision.CreateReadHuaweiSwitchSubscriber(huaweiIms, accessName, service, port, protocol, ignoreRestrictions, out result);
2077:                      }
2078:                      else result = "Error: service number does not belong to a valid vendor switch. ";
2079:                  }
2080:                  else result = "Error: accessName null or empty. ";
2081:              }
2082:              else result = "Error: service null or empty. ";
2083:          }
2084:   
2085:          ////////////////////////////////////////////////////////////////////////////
2086:   
2087:          /// <summary>
2088:          ///
2089:          /// </summary>
2090:          public static void DeleteReadService(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)
2091:          {
2092:              bool b;
2093:   
2094:              if (!string.IsNullOrEmpty(service))
2095:              {
2096:                  if (Ia.Ngn.Cl.Model.Business.Service.NumberIsWithinAllowedNokiaSwitchDomainList(service))
2097:                  {
2098:                      if (!string.IsNullOrEmpty(accessName))
2099:                      {
2100:                          b = Ia.Ngn.Cl.Model.Business.Provision.DeleteReadNokiaSwitchSubscriber(nokiaIms, accessName, service, protocol, ignoreRestrictions, out result);
2101:                      }
2102:                      else result = "Error: accessName is null or empty. ";
2103:                  }
2104:                  else if (Ia.Ngn.Cl.Model.Business.Service.NumberIsWithinAllowedHuaweiSwitchDomainList(service))
2105:                  {
2106:                      b = Ia.Ngn.Cl.Model.Business.Provision.DeleteReadHuaweiSwitchSubscriber(huaweiIms, accessName, service, protocol, ignoreRestrictions, out result);
2107:                  }
2108:                  else result = "Error: service number does not belong to a valid vendor switch. ";
2109:              }
2110:              else
2111:              {
2112:                  result = "Error: service null or empty. ";
2113:              }
2114:          }
2115:   
2116:          ////////////////////////////////////////////////////////////////////////////
2117:          ////////////////////////////////////////////////////////////////////////////    
2118:      }
2119:   
2120:      ////////////////////////////////////////////////////////////////////////////
2121:      ////////////////////////////////////////////////////////////////////////////   
2122:  }