Professional Applications Programmers/Consultants برمجة واستشارات تطبيقات الإنترنت
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.Data;
   2:  using System.Collections.Generic;
   3:  using System.Linq;
   4:  using System;
   5:   
   6:  namespace Ia.Ngn.Cl.Model.Business
   7:  {
   8:      ////////////////////////////////////////////////////////////////////////////
   9:   
  10:      /// <summary publish="true">
  11:      /// Service support class of Next Generation Network'a (NGN's) business model.
  12:      /// </summary>
  13:      /// 
  14:      /// <remarks> 
  15:      /// Copyright © 2006-2017 Jasem Y. Al-Shamlan (info@ia.com.kw), Internet Applications - Kuwait. All Rights Reserved.
  16:      ///
  17:      /// 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
  18:      /// the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
  19:      ///
  20:      /// This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
  21:      /// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
  22:      /// 
  23:      /// You should have received a copy of the GNU General Public License along with this library. If not, see http://www.gnu.org/licenses.
  24:      /// 
  25:      /// Copyright notice: This notice may not be removed or altered from any source distribution.
  26:      /// </remarks> 
  27:      public partial class Service
  28:      {
  29:          /// <summary/>
  30:          /// BELOW: IS THIS NAME CORRECT? SupplementaryService?
  31:          public enum SupplementaryService
  32:          {
  33:              CallerId = 1, InternationalCalling, InternationalCallingUserControlled, CallForwarding, CallWaiting, ConferenceCall, WakeupCall, AbbriviatedCalling, ServiceSuspension
  34:          };
  35:   
  36:          ////////////////////////////////////////////////////////////////////////////
  37:   
  38:          /// <summary>
  39:          ///
  40:          /// </summary>
  41:          public static int CountryCode { get { return 965; } }
  42:   
  43:          ////////////////////////////////////////////////////////////////////////////
  44:   
  45:          /// <summary>
  46:          ///
  47:          /// </summary>
  48:          public Service() { }
  49:   
  50:          ////////////////////////////////////////////////////////////////////////////
  51:   
  52:          /// <summary>
  53:          ///
  54:          /// </summary>
  55:          public static string ServiceName(string service, int serviceType)
  56:          {
  57:              string name;
  58:   
  59:              name = service;
  60:   
  61:              if (name == "0") name = "";
  62:   
  63:              return name;
  64:          }
  65:   
  66:          ////////////////////////////////////////////////////////////////////////////
  67:   
  68:          /// <summary>
  69:          ///
  70:          /// </summary>
  71:          public static string ServiceIdToService(string serviceId)
  72:          {
  73:              string service;
  74:   
  75:              service = serviceId.Substring(0, serviceId.IndexOf(":"));
  76:   
  77:              return service;
  78:          }
  79:   
  80:          ////////////////////////////////////////////////////////////////////////////
  81:   
  82:          /// <summary>
  83:          ///
  84:          /// </summary>
  85:          public static string ServiceToServiceId(string service, int serviceType)
  86:          {
  87:              string serviceId;
  88:   
  89:              serviceId = service + ":" + serviceType + ":" + Ia.Ngn.Cl.Model.Business.Service.CountryCode;
  90:   
  91:              return serviceId;
  92:          }
  93:   
  94:          ////////////////////////////////////////////////////////////////////////////
  95:   
  96:          /// <summary>
  97:          ///
  98:          /// </summary>
  99:          public static int ServiceIdToServiceType(string serviceId)
 100:          {
 101:              int serviceType;
 102:   
 103:              serviceType = int.Parse(serviceId.Substring(serviceId.IndexOf(":") + 1, 1));
 104:   
 105:              return serviceType;
 106:          }
 107:   
 108:          ////////////////////////////////////////////////////////////////////////////
 109:   
 110:          /// <summary>
 111:          ///
 112:          /// </summary>
 113:          public static DateTime EarliestRequestDateTime
 114:          {
 115:              get
 116:              {
 117:                  return DateTime.Parse("1970-01-01");
 118:              }
 119:          }
 120:   
 121:          ////////////////////////////////////////////////////////////////////////////
 122:   
 123:          /// <summary>
 124:          /// List of domains allowed to be created
 125:          /// </summary>
 126:          public static List<string> AllowedDomainsToBeCreatedList
 127:          {
 128:              get
 129:              {
 130:                  return new List<string>() {
 131:                  "2521", "2522", "2523", "2524",
 132:                  "2490", "2466",
 133:                  "2453", "2454",
 134:                  "2497", "2460",
 135:                  "2435", "2436", "2438",
 136:                  "2363", "2374",
 137:                  //"2481", "2482", "2483", "2484",
 138:                  //"2541", "2542", "2543", "2544", "2545",
 139:                  //"2551", "2552",
 140:                  //"2480",
 141:                  "2455", "2456", "2457", "2458",
 142:                  "2361",
 143:                  "2391","2392",
 144:                  "2371","2372","2373",
 145:                  "2467",
 146:                  "2390",
 147:  "2368",
 148:  "2367",
 149:  "2549",
 150:  "25485","25486","25487","25488","25489",
 151:  "2360","2365","2366",
 152:  "2375",
 153:  "2465",
 154:  "2460","2469",
 155:  "25480","25481","25482","25483",
 156:  "24780","24781","24782"
 157:                  };
 158:              }
 159:          }
 160:   
 161:          ////////////////////////////////////////////////////////////////////////////
 162:   
 163:          /// <summary>
 164:          /// List of domains allowed to be updated
 165:          /// </summary>
 166:          public static List<string> AllowedDomainsToBeUpdatedList
 167:          {
 168:              get
 169:              {
 170:                  return new List<string>() {
 171:                      "2521", "2522", "2523", "2524",
 172:                      "2490", "2466",
 173:                      "2453", "2454",
 174:                      "2497", "2460",
 175:                      "2435", "2436", "2438",
 176:                      "2363", "2374",
 177:  "2368",
 178:  "2367",
 179:  "2549",
 180:  "25485","25486","25487","25488","25489",
 181:  "2360","2365","2366",
 182:  "2375",
 183:  "2465",
 184:  "2460","2469",
 185:  "25480","25481","25482","25483",
 186:  "24780","24781","24782"
 187:                  };
 188:              }
 189:          }
 190:   
 191:          ////////////////////////////////////////////////////////////////////////////
 192:   
 193:          /// <summary>
 194:          /// List of domains allowed to be deleted
 195:          /// </summary>
 196:          public static List<string> AllowedDomainsToBeDeletedList
 197:          {
 198:              get
 199:              {
 200:                  return new List<string>() {
 201:                      "2521", "2522", "2523", "2524",
 202:                      "2490", "2466",
 203:                      "2453", "2454",
 204:                      "2497", "2460",
 205:                      "2435", "2436", "2438",
 206:                      "2363", "2374",
 207:                      //"2481", "2482", "2483", "2484",
 208:                      //"2541", "2542", "2543", "2544", "2545",
 209:                      "2551", "2552",
 210:                      //"2480",
 211:                      "2455", "2456", "2457", "2458",
 212:                      "2361",
 213:                      "2391","2392",
 214:                      "2371","2372","2373",
 215:                      "2467",
 216:                      "2390",
 217:  "2368",
 218:  "2367",
 219:  "2549",
 220:  "25485","25486","25487","25488","25489",
 221:  "2360","2365","2366",
 222:  "2375",
 223:  "2465",
 224:  "2460","2469",
 225:  "25480","25481","25482","25483",
 226:  "24780","24781","24782"
 227:                  };
 228:              }
 229:          }
 230:   
 231:          ////////////////////////////////////////////////////////////////////////////
 232:   
 233:          /// <summary>
 234:          /// List of access areas allowed to be created
 235:          /// </summary>
 236:          public static List<string> AllowedAccessAreaToBeCreatedList
 237:          {
 238:              get
 239:              {
 240:                  return new List<string>() { //"SKB",
 241:                      //"MUB","QRN",  stopped due to the use of split Siemens, Huawei exchange in MUB & QRN
 242:                      /*"ADN","QSR",*/"ABW","MSL","ABF","FUN","COB",
 243:                      "SBN","QRW","ADS",
 244:                      "SAA","ESU","WAH","JBA","AGI","NAS",
 245:                      "ABM","ESH",
 246:                      "FHD","MGF","SSB","FNT","EGL","MAH",
 247:                      "SLA","SHD","HIT","ZAH","SDQ","SMC",
 248:                      "ABH","FHH","MGO",
 249:                      "MSF","BYN","MBA","SAB",
 250:                      "KHP","KHR","ABF","FUN","SBA","MAH","NWS","JBA","MSL","ADS"
 251:                  };
 252:              }
 253:          }
 254:   
 255:          ////////////////////////////////////////////////////////////////////////////
 256:   
 257:          /// <summary>
 258:          /// List of access areas allowed to be updated
 259:          /// </summary>
 260:          public static List<string> AllowedAccessAreaToBeUpdatedList
 261:          {
 262:              get
 263:              {
 264:                  return new List<string>() { //"SKB",
 265:                      //"MUB","QRN",  stopped due to the use of split Siemens, Huawei exchange in MUB & QRN
 266:                      /*"ADN","QSR",*/"ABW","MSL","ABF","FUN","COB",
 267:                      "SBN","QRW","ADS",
 268:                      "SAA","ESU","WAH","JBA","AGI","NAS",
 269:                      "ABM","ESH",
 270:                      "FHD","MGF","SSB","FNT","EGL","MAH",
 271:                      "SLA","SHD","HIT","ZAH","SDQ","SMC",
 272:                      "ABH","FHH","MGO",
 273:                      "MSF","BYN","MBA","SAB",
 274:                      "KHP","KHR","ABF","FUN","SBA","MAH","NWS","JBA","MSL","ADS"
 275:                  };
 276:              }
 277:          }
 278:   
 279:          ////////////////////////////////////////////////////////////////////////////
 280:   
 281:          /// <summary>
 282:          /// List of access areas allowed to be deleted
 283:          /// </summary>
 284:          public static List<string> AllowedAccessAreaToBeDeletedList
 285:          {
 286:              get
 287:              {
 288:                  return new List<string>() { //"SKB",
 289:                      //"MUB","QRN",  stopped due to the use of split Siemens, Huawei exchange in MUB & QRN
 290:                      /*"ADN","QSR",*/"ABW","MSL","ABF","FUN","COB",
 291:                      "SBN","QRW","ADS",
 292:                      "SAA","ESU","WAH","JBA","AGI","NAS",
 293:                      "ABM","ESH",
 294:                      "FHD","MGF","SSB","FNT","EGL","MAH",
 295:                      "SLA","SHD","HIT","ZAH","SDQ","SMC",
 296:                      "ABH","FHH","MGO",
 297:                      "MSF","BYN","MBA","SAB",
 298:                      "KHP","KHR","ABF","FUN","SBA","MAH","NWS","JBA","MSL","ADS"
 299:                  };
 300:              }
 301:          }
 302:   
 303:          ////////////////////////////////////////////////////////////////////////////
 304:   
 305:          /// <summary>
 306:          /// List of domains allowed to be created or updated or deleted 
 307:          /// </summary>
 308:          public static List<string> AllowedDomainsToBeCreatedOrUpdatedOrDeletedList
 309:          {
 310:              get
 311:              {
 312:                  List<string> list;
 313:   
 314:                  list = AllowedDomainsToBeCreatedList.Concat(AllowedDomainsToBeUpdatedList).Concat(AllowedDomainsToBeDeletedList).Distinct().ToList();
 315:   
 316:                  return list;
 317:              }
 318:          }
 319:   
 320:          ////////////////////////////////////////////////////////////////////////////
 321:   
 322:          /// <summary>
 323:          ///
 324:          /// </summary>
 325:          public class KuwaitNgnArea
 326:          {
 327:              /// <summary/>
 328:              public KuwaitNgnArea() { }
 329:   
 330:              /// <summary/>
 331:              public KuwaitNgnArea(string name, string arabicName)
 332:              {
 333:                  this.Name = name;
 334:                  this.ArabicName = arabicName;
 335:              }
 336:   
 337:              /// <summary/>
 338:              public int Id { get; set; }
 339:              /// <summary/>
 340:              public string Name { get; set; }
 341:              /// <summary/>
 342:              public string ArabicName { get; set; }
 343:              /// <summary/>
 344:              public string NameArabicName
 345:              {
 346:                  get
 347:                  {
 348:                      return Name + " (" + ArabicName + ")";
 349:                  }
 350:              }
 351:              /// <summary/>
 352:              public string Symbol { get; set; }
 353:              /// <summary/>
 354:              public string ServiceRequestAddressProvinceAreaName { get; set; }
 355:   
 356:              public virtual List<Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Site> SiteList { get; set; }
 357:          }
 358:   
 359:          ////////////////////////////////////////////////////////////////////////////
 360:   
 361:          /// <summary>
 362:          ///
 363:          /// </summary>
 364:          public static List<int> SelectListOfNumbersWithinAllowedDomainList(List<int> inNumberList)
 365:          {
 366:              string numberString;
 367:              List<int> numberList;
 368:   
 369:              numberList = new List<int>();
 370:   
 371:              if (inNumberList.Count > 0)
 372:              {
 373:                  numberList = new List<int>(inNumberList.Count);
 374:   
 375:                  foreach (int i in inNumberList)
 376:                  {
 377:                      numberString = i.ToString();
 378:   
 379:                      if (NumberIsWithinAllowedDomainList(numberString)) numberList.Add(i);
 380:                  }
 381:              }
 382:   
 383:              return numberList;
 384:          }
 385:   
 386:          ////////////////////////////////////////////////////////////////////////////
 387:   
 388:          /// <summary>
 389:          ///
 390:          /// </summary>
 391:          public static bool NumberIsWithinAllowedDomainList(long number)
 392:          {
 393:              string numberString;
 394:   
 395:              numberString = number.ToString();
 396:   
 397:              return NumberIsWithinAllowedDomainList(numberString);
 398:          }
 399:   
 400:          ////////////////////////////////////////////////////////////////////////////
 401:   
 402:          /// <summary>
 403:          ///
 404:          /// </summary>
 405:          public static bool NumberIsWithinAllowedRouterDomainList(Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Ont ont, string service)
 406:          {
 407:              bool b;
 408:   
 409:              if (ont != null)
 410:              {
 411:                  b = ont.Pon.PonGroup.Olt.Odf.Router.DomainList.Any(u => service.StartsWith(u.ToString()));
 412:              }
 413:              else b = false;
 414:   
 415:              return b;
 416:          }
 417:   
 418:          ////////////////////////////////////////////////////////////////////////////
 419:   
 420:          /// <summary>
 421:          ///
 422:          /// </summary>
 423:          public static bool NumberIsWithinAllowedDomainList(string number)
 424:          {
 425:              bool @is;
 426:   
 427:              if (!string.IsNullOrEmpty(number))
 428:              {
 429:                  if (Ia.Ngn.Cl.Model.Data.Service.DomainList.Any(u => number.StartsWith(u.ToString()))) @is = true;
 430:                  else @is = false;
 431:              }
 432:              else @is = false;
 433:   
 434:              return @is;
 435:          }
 436:   
 437:          ////////////////////////////////////////////////////////////////////////////
 438:   
 439:          /// <summary>
 440:          ///
 441:          /// </summary>
 442:          public static bool NumberIsWithinAllowedNokiaSwitchDomainList(long number)
 443:          {
 444:              string numberString;
 445:   
 446:              numberString = number.ToString();
 447:   
 448:              return NumberIsWithinAllowedNokiaSwitchDomainList(numberString);
 449:          }
 450:   
 451:          ////////////////////////////////////////////////////////////////////////////
 452:   
 453:          /// <summary>
 454:          ///
 455:          /// </summary>
 456:          public static bool NumberIsWithinAllowedNokiaSwitchDomainList(string number)
 457:          {
 458:              bool isWithinAllowedDomains;
 459:   
 460:              if (NumberIsWithinAllowedDomainList(number))
 461:              {
 462:                  if (Ia.Ngn.Cl.Model.Data.Service.NokiaSwitchDomainList.Any(u => number.StartsWith(u.ToString()))) isWithinAllowedDomains = true;
 463:                  else isWithinAllowedDomains = false;
 464:              }
 465:              else isWithinAllowedDomains = false;
 466:   
 467:              return isWithinAllowedDomains;
 468:          }
 469:   
 470:          ////////////////////////////////////////////////////////////////////////////
 471:   
 472:          /// <summary>
 473:          ///
 474:          /// </summary>
 475:          public static bool NumberIsWithinAllowedHuaweiSwitchDomainList(long number)
 476:          {
 477:              string numberString;
 478:   
 479:              numberString = number.ToString();
 480:   
 481:              return NumberIsWithinAllowedHuaweiSwitchDomainList(numberString);
 482:          }
 483:   
 484:          ////////////////////////////////////////////////////////////////////////////
 485:   
 486:          /// <summary>
 487:          ///
 488:          /// </summary>
 489:          public static bool NumberIsWithinAllowedHuaweiSwitchDomainList(string number)
 490:          {
 491:              bool isWithinAllowedDomains;
 492:              int i;
 493:   
 494:              if (NumberIsWithinAllowedDomainList(number))
 495:              {
 496:                  if (Ia.Ngn.Cl.Model.Data.Service.HuaweiSwitchDomainList.Any(u => number.StartsWith(u.ToString()))) isWithinAllowedDomains = true;
 497:                  else isWithinAllowedDomains = false;
 498:              }
 499:              else isWithinAllowedDomains = false;
 500:   
 501:              return isWithinAllowedDomains;
 502:          }
 503:   
 504:          ////////////////////////////////////////////////////////////////////////////
 505:   
 506:          /// <summary>
 507:          ///
 508:          /// </summary>
 509:          public static Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Vendor SwitchVendor(string service)
 510:          {
 511:              Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Vendor vendor;
 512:   
 513:              if (NumberIsWithinAllowedNokiaSwitchDomainList(service))
 514:              {
 515:                  vendor = Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Vendor.Nokia;
 516:              }
 517:              else if (NumberIsWithinAllowedHuaweiSwitchDomainList(service))
 518:              {
 519:                  vendor = Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Vendor.Huawei;
 520:              }
 521:              else vendor = Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Vendor.Undefined;
 522:   
 523:              return vendor;
 524:          }
 525:   
 526:          ////////////////////////////////////////////////////////////////////////////
 527:   
 528:          /// <summary>
 529:          ///
 530:          /// </summary>
 531:          public static Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Vendor AccessVendor(string accessName)
 532:          {
 533:              Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Vendor vendor;
 534:   
 535:              vendor = (from v in Ia.Ngn.Cl.Model.Data.NetworkDesignDocument.OntList where v.Access.Name == accessName select v.Pon.PonGroup.Olt.Odf.Vendor).SingleOrDefault();
 536:   
 537:              if (vendor == null) vendor = Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Vendor.Undefined;
 538:   
 539:              return vendor;
 540:          }
 541:   
 542:          ////////////////////////////////////////////////////////////////////////////    
 543:          ////////////////////////////////////////////////////////////////////////////
 544:      }
 545:   
 546:      ////////////////////////////////////////////////////////////////////////////
 547:   
 548:      /// <summary>
 549:      ///
 550:      /// </summary>
 551:      public static class ServiceExtension
 552:      {
 553:          ////////////////////////////////////////////////////////////////////////////
 554:   
 555:          /// <summary>
 556:          /// 
 557:          /// <see cref="http://stackoverflow.com/questions/8910588/how-to-override-contains"/>
 558:          /// </summary>
 559:          public static bool Contains(this List<Ia.Ngn.Cl.Model.Business.ServiceRequest.NumberSerial> sourceList, int number, int serial)
 560:          {
 561:              return ((from n in sourceList where n.Number == number && n.Serial == serial select n) != null);
 562:          }
 563:   
 564:          ////////////////////////////////////////////////////////////////////////////    
 565:   
 566:          /// <summary>
 567:          ///
 568:          /// </summary>
 569:          public static List<long> IdList(this List<Ia.Ngn.Cl.Model.Business.ServiceRequest.NumberSerial> sourceList)
 570:          {
 571:              return ((from n in sourceList select (long)((long)n.Number * 100 + n.Serial)).ToList());
 572:          }
 573:   
 574:          ////////////////////////////////////////////////////////////////////////////
 575:          ////////////////////////////////////////////////////////////////////////////
 576:      }
 577:   
 578:      ////////////////////////////////////////////////////////////////////////////
 579:      ////////////////////////////////////////////////////////////////////////////   
 580:  }