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

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