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

Integrated Applications Programming Company

Skip Navigation LinksHome » Code Library » Service

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

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

   1:  using System.Collections.Generic;
   2:  using System.Data;
   3:  using System.Linq;
   4:   
   5:  namespace Ia.Ngn.Cl.Model.Business
   6:  {
   7:      ////////////////////////////////////////////////////////////////////////////
   8:   
   9:      /// <summary publish="true">
  10:      /// Service support class of Next Generation Network'a (NGN's) business model.
  11:      /// </summary>
  12:      /// 
  13:      /// <remarks> 
  14:      /// Copyright © 2006-2019 Jasem Y. Al-Shamlan (info@ia.com.kw), Internet Applications - Kuwait. All Rights Reserved.
  15:      ///
  16:      /// 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
  17:      /// the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
  18:      ///
  19:      /// This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
  20:      /// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
  21:      /// 
  22:      /// You should have received a copy of the GNU General Public License along with this library. If not, see http://www.gnu.org/licenses.
  23:      /// 
  24:      /// Copyright notice: This notice may not be removed or altered from any source distribution.
  25:      /// </remarks> 
  26:      public partial class Service
  27:      {
  28:          /// <summary/>
  29:          public enum SupplementaryService
  30:          {
  31:              CallerId = 1, InternationalCalling, InternationalCallingUserControlled, CallForwarding, CallWaiting, ConferenceCall, WakeupCall, AbbriviatedCalling, ServiceSuspension
  32:          };
  33:   
  34:          ////////////////////////////////////////////////////////////////////////////
  35:   
  36:          /// <summary>
  37:          ///
  38:          /// </summary>
  39:          public static int CountryCode { get { return 965; } }
  40:   
  41:          ////////////////////////////////////////////////////////////////////////////
  42:   
  43:          /// <summary>
  44:          ///
  45:          /// </summary>
  46:          public class ServiceSupplementaryService
  47:          {
  48:              public int Service { get; set; }
  49:              public string Pin { get; set; }
  50:              public bool SubscriberHasPin { get; set; }
  51:              public bool InternationalCallingUserControlledActivated { get; set; }
  52:              public bool ServiceAdministrativelySuspendedByBillingDepartment { get; set; }
  53:              public bool ServiceAdministrativelySuspendedForOtherReasons { get; set; }
  54:              public bool IsPbx { get; set; }
  55:   
  56:              public List<Ia.Ngn.Cl.Model.Business.Service.SupplementaryService> SupplementaryServiceList { get; set; }
  57:   
  58:              public ServiceSupplementaryService()
  59:              {
  60:                  this.Service = 0;
  61:                  this.Pin = string.Empty;
  62:                  this.SubscriberHasPin = false;
  63:                  this.InternationalCallingUserControlledActivated = false;
  64:                  this.ServiceAdministrativelySuspendedByBillingDepartment = false;
  65:                  this.ServiceAdministrativelySuspendedForOtherReasons = false;
  66:                  this.IsPbx = false;
  67:   
  68:                  this.SupplementaryServiceList = new List<Ia.Ngn.Cl.Model.Business.Service.SupplementaryService>();
  69:              }
  70:          }
  71:   
  72:          ////////////////////////////////////////////////////////////////////////////
  73:   
  74:          /// <summary>
  75:          ///
  76:          /// </summary>
  77:          public class ServiceType
  78:          {
  79:              /// <summary/>
  80:              public int Id { get; set; }
  81:              /// <summary/>
  82:              public string Name { get; set; }
  83:              /// <summary/>
  84:              public string NameArabicName { get; set; }
  85:              /// <summary/>
  86:              public string Color { get; set; }
  87:   
  88:              /// <summary/>
  89:              public ServiceType(int id, string name, string nameArabicName, string color)
  90:              {
  91:                  this.Id = id;
  92:                  this.Name = name;
  93:                  this.NameArabicName = nameArabicName;
  94:                  this.Color = color;
  95:              }
  96:   
  97:              /// <summary/>
  98:              public string ColoredNameArabicName
  99:              {
 100:                  get
 101:                  {
 102:                      return @"<span class=""" + this.Color + @""">" + this.NameArabicName + @"</span>";
 103:                  }
 104:              }
 105:   
 106:              /// <summary/>
 107:              public static int NgnService
 108:              {
 109:                  get
 110:                  {
 111:                      return (from s in Ia.Ngn.Cl.Model.Data.Service.ServiceTypeList where s.Name == "Ngn" select s.Id).Single();
 112:                  }
 113:              }
 114:   
 115:              /// <summary/>
 116:              public static int PstnService
 117:              {
 118:                  get
 119:                  {
 120:                      return (from s in Ia.Ngn.Cl.Model.Data.Service.ServiceTypeList where s.Name == "Pstn" select s.Id).Single();
 121:                  }
 122:              }
 123:   
 124:              ////////////////////////////////////////////////////////////////////////////
 125:              ////////////////////////////////////////////////////////////////////////////
 126:          }
 127:   
 128:          ////////////////////////////////////////////////////////////////////////////
 129:   
 130:          /// <summary>
 131:          ///
 132:          /// </summary>
 133:          public Service() { }
 134:   
 135:          ////////////////////////////////////////////////////////////////////////////
 136:   
 137:          /// <summary>
 138:          ///
 139:          /// </summary>
 140:          public static string ServiceName(string service, int serviceType)
 141:          {
 142:              string name;
 143:   
 144:              name = service;
 145:   
 146:              if (name == "0") name = "";
 147:   
 148:              return name;
 149:          }
 150:   
 151:          ////////////////////////////////////////////////////////////////////////////
 152:   
 153:          /// <summary>
 154:          ///
 155:          /// </summary>
 156:          public static string ServiceIdToService(string serviceId)
 157:          {
 158:              string service;
 159:   
 160:              service = serviceId.Substring(0, serviceId.IndexOf(":"));
 161:   
 162:              return service;
 163:          }
 164:   
 165:          ////////////////////////////////////////////////////////////////////////////
 166:   
 167:          /// <summary>
 168:          ///
 169:          /// </summary>
 170:          public static string ServiceToServiceId(string service, int serviceType)
 171:          {
 172:              string serviceId;
 173:   
 174:              serviceId = service + ":" + serviceType + ":" + Ia.Ngn.Cl.Model.Business.Service.CountryCode;
 175:   
 176:              return serviceId;
 177:          }
 178:   
 179:          ////////////////////////////////////////////////////////////////////////////
 180:   
 181:          /// <summary>
 182:          ///
 183:          /// </summary>
 184:          public static int ServiceIdToServiceType(string serviceId)
 185:          {
 186:              int serviceType;
 187:   
 188:              serviceType = int.Parse(serviceId.Substring(serviceId.IndexOf(":") + 1, 1));
 189:   
 190:              return serviceType;
 191:          }
 192:   
 193:          ////////////////////////////////////////////////////////////////////////////
 194:   
 195:          /// <summary>
 196:          ///
 197:          /// </summary>
 198:          public class KuwaitNgnArea
 199:          {
 200:              /// <summary/>
 201:              public KuwaitNgnArea() { }
 202:   
 203:              /// <summary/>
 204:              public KuwaitNgnArea(string name, string arabicName)
 205:              {
 206:                  this.Name = name;
 207:                  this.ArabicName = arabicName;
 208:              }
 209:   
 210:              /// <summary/>
 211:              public int Id { get; set; }
 212:              /// <summary/>
 213:              public string Name { get; set; }
 214:              /// <summary/>
 215:              public string ArabicName { get; set; }
 216:              /// <summary/>
 217:              public string NameArabicName
 218:              {
 219:                  get
 220:                  {
 221:                      return Name + " (" + ArabicName + ")";
 222:                  }
 223:              }
 224:              /// <summary/>
 225:              public string Symbol { get; set; }
 226:              /// <summary/>
 227:              public string ServiceRequestAddressProvinceAreaName { get; set; }
 228:   
 229:              public virtual List<Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Site> SiteList { get; set; }
 230:          }
 231:   
 232:          ////////////////////////////////////////////////////////////////////////////
 233:   
 234:          /// <summary>
 235:          ///
 236:          /// </summary>
 237:          public static List<int> SelectListOfNumbersWithinAllowedDomainList(List<int> inNumberList)
 238:          {
 239:              string numberString;
 240:              List<int> numberList;
 241:   
 242:              numberList = new List<int>();
 243:   
 244:              if (inNumberList.Count > 0)
 245:              {
 246:                  numberList = new List<int>(inNumberList.Count);
 247:   
 248:                  foreach (int i in inNumberList)
 249:                  {
 250:                      numberString = i.ToString();
 251:   
 252:                      if (NumberIsWithinAllowedDomainList(numberString)) numberList.Add(i);
 253:                  }
 254:              }
 255:   
 256:              return numberList;
 257:          }
 258:   
 259:          ////////////////////////////////////////////////////////////////////////////
 260:   
 261:          /// <summary>
 262:          ///
 263:          /// </summary>
 264:          public static bool OltIsWithinAllowedToBeProvisionedOltList(Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Olt olt)
 265:          {
 266:              return Ia.Ngn.Cl.Model.Data.Service.AllowedToBeProvisionedOltList.Any(u => u == olt);
 267:          }
 268:   
 269:          ////////////////////////////////////////////////////////////////////////////
 270:   
 271:          /// <summary>
 272:          ///
 273:          /// </summary>
 274:          public static bool OltIsWithinAllowedToBeMigratedOltList(Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Olt olt)
 275:          {
 276:              return Ia.Ngn.Cl.Model.Data.Service.AllowedToBeMigratedOltList.Any(u => u == olt);
 277:          }
 278:   
 279:          ////////////////////////////////////////////////////////////////////////////
 280:   
 281:          /// <summary>
 282:          ///
 283:          /// </summary>
 284:          public static bool OltIdIsWithinAllowedToBeMigratedOltList(int oltId)
 285:          {
 286:              return Ia.Ngn.Cl.Model.Data.Service.AllowedToBeMigratedOltIdList.Contains(oltId);
 287:          }
 288:   
 289:          ////////////////////////////////////////////////////////////////////////////
 290:   
 291:          /// <summary>
 292:          ///
 293:          /// </summary>
 294:          public static bool OltIsWithinAllowedToBeProvisionedOrMigratedOltList(Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Olt olt)
 295:          {
 296:              return Ia.Ngn.Cl.Model.Data.Service.AllowedToBeProvisionedOltList.Any(u => u == olt) || Ia.Ngn.Cl.Model.Data.Service.AllowedToBeMigratedOltList.Any(u => u == olt);
 297:          }
 298:   
 299:          ////////////////////////////////////////////////////////////////////////////
 300:   
 301:          /// <summary>
 302:          ///
 303:          /// </summary>
 304:          public static bool AreaSymbolIsWithinAnAllowedOltToBeProvisionedDomainList(string areaSymbol)
 305:          {
 306:              bool b;
 307:   
 308:              if (!string.IsNullOrEmpty(areaSymbol))
 309:              {
 310:                  b = Ia.Ngn.Cl.Model.Data.Service.AllowedToBeProvisionedOltList.Any(v => v.Odf.Router.Site.AreaSymbolList.Any(u => areaSymbol == u));
 311:              }
 312:              else
 313:              {
 314:                  b = false;
 315:              }
 316:   
 317:              return b;
 318:          }
 319:   
 320:          ////////////////////////////////////////////////////////////////////////////
 321:   
 322:          /// <summary>
 323:          ///
 324:          /// </summary>
 325:          public static bool NumberIsWithinAnAllowedOltToBeProvisionedDomainList(string service)
 326:          {
 327:              bool b;
 328:   
 329:              if (!string.IsNullOrEmpty(service))
 330:              {
 331:                  b = Ia.Ngn.Cl.Model.Data.Service.AllowedToBeProvisionedOltList.Any(v => v.Odf.Router.DomainList.Any(u => service.StartsWith(u.ToString())));
 332:              }
 333:              else
 334:              {
 335:                  b = false;
 336:              }
 337:   
 338:              return b;
 339:          }
 340:   
 341:          ////////////////////////////////////////////////////////////////////////////
 342:   
 343:          /// <summary>
 344:          ///
 345:          /// </summary>
 346:          public static bool NumberIsWithinAllowedDomainList(long number)
 347:          {
 348:              string numberString;
 349:   
 350:              numberString = number.ToString();
 351:   
 352:              return NumberIsWithinAllowedDomainList(numberString);
 353:          }
 354:   
 355:          ////////////////////////////////////////////////////////////////////////////
 356:   
 357:          /// <summary>
 358:          ///
 359:          /// </summary>
 360:          public static bool NumberIsWithinAllowedRouterDomainList(Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Ont ont, string service)
 361:          {
 362:              bool b;
 363:   
 364:              if (ont != null)
 365:              {
 366:                  b = ont.Pon.PonGroup.Olt.Odf.Router.DomainList.Any(u => service.StartsWith(u.ToString()));
 367:              }
 368:              else b = false;
 369:   
 370:              return b;
 371:          }
 372:   
 373:          ////////////////////////////////////////////////////////////////////////////
 374:   
 375:          /// <summary>
 376:          ///
 377:          /// </summary>
 378:          public static bool NumberIsWithinAllowedDomainList(string number)
 379:          {
 380:              bool isWithinAllowed;
 381:   
 382:              if (!string.IsNullOrEmpty(number))
 383:              {
 384:                  if (Ia.Ngn.Cl.Model.Data.Service.DomainList.Any(u => number.StartsWith(u.ToString()))) isWithinAllowed = true;
 385:                  else isWithinAllowed = false;
 386:              }
 387:              else isWithinAllowed = false;
 388:   
 389:              return isWithinAllowed;
 390:          }
 391:   
 392:          ////////////////////////////////////////////////////////////////////////////
 393:   
 394:          /// <summary>
 395:          ///
 396:          /// </summary>
 397:          public static bool NumberIsWithinAllowedNokiaSwitchDomainList(long number)
 398:          {
 399:              string numberString;
 400:   
 401:              numberString = number.ToString();
 402:   
 403:              return NumberIsWithinAllowedNokiaSwitchDomainList(numberString);
 404:          }
 405:   
 406:          ////////////////////////////////////////////////////////////////////////////
 407:   
 408:          /// <summary>
 409:          ///
 410:          /// </summary>
 411:          public static bool NumberIsWithinAllowedNokiaSwitchDomainList(string number)
 412:          {
 413:              bool isWithinAllowedDomains;
 414:   
 415:              if (NumberIsWithinAllowedDomainList(number))
 416:              {
 417:                  if (Ia.Ngn.Cl.Model.Data.Service.NokiaSwitchDomainList.Any(u => number.StartsWith(u.ToString()))) isWithinAllowedDomains = true;
 418:                  else isWithinAllowedDomains = false;
 419:              }
 420:              else isWithinAllowedDomains = false;
 421:   
 422:              return isWithinAllowedDomains;
 423:          }
 424:   
 425:          ////////////////////////////////////////////////////////////////////////////
 426:   
 427:          /// <summary>
 428:          ///
 429:          /// </summary>
 430:          public static bool NumberIsWithinAllowedHuaweiSwitchDomainList(long number)
 431:          {
 432:              string numberString;
 433:   
 434:              numberString = number.ToString();
 435:   
 436:              return NumberIsWithinAllowedHuaweiSwitchDomainList(numberString);
 437:          }
 438:   
 439:          ////////////////////////////////////////////////////////////////////////////
 440:   
 441:          /// <summary>
 442:          ///
 443:          /// </summary>
 444:          public static bool NumberIsWithinAllowedHuaweiSwitchDomainList(string number)
 445:          {
 446:              bool isWithinAllowedDomains;
 447:   
 448:              if (NumberIsWithinAllowedDomainList(number))
 449:              {
 450:                  if (Ia.Ngn.Cl.Model.Data.Service.HuaweiSwitchDomainList.Any(u => number.StartsWith(u.ToString()))) isWithinAllowedDomains = true;
 451:                  else isWithinAllowedDomains = false;
 452:              }
 453:              else isWithinAllowedDomains = false;
 454:   
 455:              return isWithinAllowedDomains;
 456:          }
 457:   
 458:          ////////////////////////////////////////////////////////////////////////////
 459:   
 460:          /// <summary>
 461:          ///
 462:          /// </summary>
 463:          public static Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Vendor SwitchVendor(string service)
 464:          {
 465:              Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Vendor vendor;
 466:   
 467:              if (NumberIsWithinAllowedNokiaSwitchDomainList(service))
 468:              {
 469:                  vendor = Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Vendor.Nokia;
 470:              }
 471:              else if (NumberIsWithinAllowedHuaweiSwitchDomainList(service))
 472:              {
 473:                  vendor = Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Vendor.Huawei;
 474:              }
 475:              else vendor = Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Vendor.Undefined;
 476:   
 477:              return vendor;
 478:          }
 479:   
 480:          ////////////////////////////////////////////////////////////////////////////
 481:   
 482:          /// <summary>
 483:          ///
 484:          /// </summary>
 485:          public static Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Vendor AccessVendor(string accessName)
 486:          {
 487:              Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Vendor vendor;
 488:   
 489:              vendor = (from v in Ia.Ngn.Cl.Model.Data.NetworkDesignDocument.OntList where v.Access.Name == accessName select v.Pon.PonGroup.Olt.Odf.Vendor).SingleOrDefault();
 490:   
 491:              if (vendor == null) vendor = Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Vendor.Undefined;
 492:   
 493:              return vendor;
 494:          }
 495:   
 496:          ////////////////////////////////////////////////////////////////////////////
 497:   
 498:          /// <summary>
 499:          ///
 500:          /// </summary>
 501:          public static int ConvertEmsVoipPstnUsersPnToServiceRequestServicePosition(int pn)
 502:          {
 503:              /*
 504:               * - All Nokia ONTs (SFUs and MDUs) start at port position 1
 505:               * - Huawei ONTs (SFUs) start at port position 1, while Huawei MDUs start at port position 0
 506:               * - All positions in the Customer Department database will start at position 1 (e.g. port 3 in a Huawei MDU is 4 in the Customer Department database)
 507:               */
 508:   
 509:              // +1 because it has a Huawei MDU. See above.
 510:   
 511:              return pn + 1;
 512:          }
 513:   
 514:          ////////////////////////////////////////////////////////////////////////////
 515:   
 516:          /// <summary>
 517:          ///
 518:          /// </summary>
 519:          public static int ConvertServiceRequestServicePositionToEmsVoipPstnUsersPn(int servicePosition)
 520:          {
 521:              /*
 522:               * - All Nokia ONTs (SFUs and MDUs) start at port position 1
 523:               * - Huawei ONTs (SFUs) start at port position 1, while Huawei MDUs start at port position 0
 524:               * - All positions in the Customer Department database will start at position 1 (e.g. port 3 in a Huawei MDU is 4 in the Customer Department database)
 525:               */
 526:   
 527:              // -1 because it has a Huawei MDU. See above.
 528:   
 529:              return servicePosition - 1;
 530:          }
 531:   
 532:          ////////////////////////////////////////////////////////////////////////////
 533:   
 534:          /// <summary>
 535:          ///
 536:          /// </summary>
 537:          public static int ConvertFlatTermIdPositionToEmsVoipPstnUsersPn(int flatTermId)
 538:          {
 539:              /*
 540:               * - All Nokia ONTs (SFUs and MDUs) start at port position 1
 541:               * - Huawei ONTs (SFUs) start at port position 1, while Huawei MDUs start at port position 0
 542:               * - All positions in the Customer Department database will start at position 1 (e.g. port 3 in a Huawei MDU is 4 in the Customer Department database)
 543:               */
 544:   
 545:              // -1 because it has a Huawei MDU. See above.
 546:   
 547:              return flatTermId - 1;
 548:          }
 549:   
 550:          ////////////////////////////////////////////////////////////////////////////    
 551:          ////////////////////////////////////////////////////////////////////////////
 552:      }
 553:   
 554:      ////////////////////////////////////////////////////////////////////////////
 555:   
 556:      /// <summary>
 557:      ///
 558:      /// </summary>
 559:      public static class ServiceExtension
 560:      {
 561:          ////////////////////////////////////////////////////////////////////////////
 562:   
 563:          /// <summary>
 564:          /// 
 565:          /// <see cref="http://stackoverflow.com/questions/8910588/how-to-override-contains"/>
 566:          /// </summary>
 567:          public static bool Contains(this List<Ia.Ngn.Cl.Model.Business.ServiceRequest.NumberSerial> sourceList, int number, int serial)
 568:          {
 569:              return ((from n in sourceList where n.Number == number && n.Serial == serial select n) != null);
 570:          }
 571:   
 572:          ////////////////////////////////////////////////////////////////////////////    
 573:   
 574:          /// <summary>
 575:          ///
 576:          /// </summary>
 577:          public static List<long> IdList(this List<Ia.Ngn.Cl.Model.Business.ServiceRequest.NumberSerial> sourceList)
 578:          {
 579:              return ((from n in sourceList select (long)((long)n.Number * 100 + n.Serial)).ToList());
 580:          }
 581:   
 582:          ////////////////////////////////////////////////////////////////////////////
 583:          ////////////////////////////////////////////////////////////////////////////
 584:      }
 585:   
 586:      ////////////////////////////////////////////////////////////////////////////
 587:      ////////////////////////////////////////////////////////////////////////////   
 588:  }