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 for Next Generation Network (NGN) data model.

   1:  using System;
   2:  using System.Web;
   3:  using System.Xml.Linq;
   4:  using System.IO;
   5:  using System.Data;
   6:  using System.Collections.Generic;
   7:  using System.Reflection;
   8:  using System.Linq;
   9:   
  10:  namespace Ia.Ngn.Cl.Model.Data
  11:  {
  12:      ////////////////////////////////////////////////////////////////////////////
  13:   
  14:      /// <summary publish="true">
  15:      /// Service support class for Next Generation Network (NGN) data model.
  16:      /// </summary>
  17:      /// 
  18:      /// <remarks> 
  19:      /// Copyright © 2006-2017 Jasem Y. Al-Shamlan (info@ia.com.kw), Internet Applications - Kuwait. All Rights Reserved.
  20:      ///
  21:      /// 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
  22:      /// the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
  23:      ///
  24:      /// This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
  25:      /// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
  26:      /// 
  27:      /// You should have received a copy of the GNU General Public License along with this library. If not, see http://www.gnu.org/licenses.
  28:      /// 
  29:      /// Copyright notice: This notice may not be removed or altered from any source distribution.
  30:      /// </remarks> 
  31:      public partial class Service
  32:      {
  33:          private static XDocument xDocument;
  34:          private static Dictionary<string, int> serviceIdPositionDictionary;
  35:          private static List<Ia.Ngn.Cl.Model.Business.Service.KuwaitNgnArea> kuwaitNgnAreaList;
  36:          private static List<int> domainList, nokiaSwitchDomainList, huaweiSwitchDomainList;
  37:   
  38:          ////////////////////////////////////////////////////////////////////////////
  39:   
  40:          /// <summary>
  41:          ///
  42:          /// </summary>
  43:          public Service() { }
  44:   
  45:          ////////////////////////////////////////////////////////////////////////////
  46:   
  47:          /// <summary>
  48:          ///
  49:          /// </summary>
  50:          public static List<string> ServiceThatDoNotExistInServiceRequestServiceServiceIdList()
  51:          {
  52:              List<string> list;
  53:   
  54:              using (var db = new Ia.Ngn.Cl.Model.Ngn())
  55:              {
  56:                  list = (from s in db.Service2s
  57:                          join srs in db.ServiceRequestServices on s.Id equals srs.Id into gj
  58:                          from subsrs in gj.DefaultIfEmpty()
  59:                          where subsrs.Id == null
  60:                          select s.Id).ToList();
  61:   
  62:              }
  63:   
  64:              return list;
  65:          }
  66:   
  67:          ////////////////////////////////////////////////////////////////////////////
  68:   
  69:          /// <summary>
  70:          ///
  71:          /// </summary>
  72:          public static List<Ia.Ngn.Cl.Model.Business.ServiceServiceRequestOnt> ListOfServiceServiceRequestOntDetailsThatDoNotExistInCustomerDepartmentDatabase()
  73:          {
  74:              List<Ia.Ngn.Cl.Model.Business.ServiceServiceRequestOnt> list, toRemoveBecauseServicePositionIsUndefinedList;
  75:              Dictionary<string, int> serviceIdPositionDictionary;
  76:   
  77:              toRemoveBecauseServicePositionIsUndefinedList = new List<Business.ServiceServiceRequestOnt>();
  78:   
  79:              serviceIdPositionDictionary = Ia.Ngn.Cl.Model.Data.Service.ServiceIdPositionDictionary;
  80:   
  81:              using (var db = new Ia.Ngn.Cl.Model.Ngn())
  82:              {
  83:                  list = (from s in db.Service2s
  84:                          join sro in db.ServiceRequestOnts on s.Access.Id equals sro.Access.Id
  85:                          join srod in db.ServiceRequestOntDetails on sro.Id equals srod.ServiceRequestOnt.Id into gj
  86:                          from subsrod in gj.DefaultIfEmpty()
  87:                          where subsrod.Id == null && s.Access != null && sro.Access != null
  88:                          select new Ia.Ngn.Cl.Model.Business.ServiceServiceRequestOnt()
  89:                          {
  90:                              ServiceId = s.Id,
  91:                              Service = s.Service,
  92:                              ServiceType = s.ServiceType, // <type id="1" name="Dn" Idlike="25212254:1:965"/>
  93:                              ServiceRequestOnt = sro
  94:                          }).ToList();
  95:   
  96:                  foreach (var v in list)
  97:                  {
  98:                      if (serviceIdPositionDictionary.ContainsKey(v.ServiceId))
  99:                      {
 100:                          v.ServicePosition = serviceIdPositionDictionary[v.ServiceId];
 101:                      }
 102:                      else
 103:                      {
 104:                          toRemoveBecauseServicePositionIsUndefinedList.Add(v);
 105:                      }
 106:                  }
 107:   
 108:                  // I will remove the following from list because the service position is not defined
 109:                  foreach (var v in toRemoveBecauseServicePositionIsUndefinedList) list.Remove(v);
 110:              }
 111:   
 112:              return list.OrderBy(u => u.Service).ToList();
 113:          }
 114:   
 115:          ////////////////////////////////////////////////////////////////////////////
 116:   
 117:          /// <summary>
 118:          ///
 119:          /// </summary>
 120:          public static List<Ia.Ngn.Cl.Model.Business.ServiceServiceRequestOnt> ServiceServiceRequestOntDetailWithMismatchedInformationInServiceRequestOntDetailList()
 121:          {
 122:              List<Ia.Ngn.Cl.Model.Business.ServiceServiceRequestOnt> list;
 123:              Dictionary<string, int> serviceIdPositionDictionary;
 124:   
 125:              serviceIdPositionDictionary = Ia.Ngn.Cl.Model.Data.Service.ServiceIdPositionDictionary;
 126:   
 127:              using (var db = new Ia.Ngn.Cl.Model.Ngn())
 128:              {
 129:                  list = (from s in db.Service2s
 130:                          join sro in db.ServiceRequestOnts on s.Access.Id equals sro.Access.Id
 131:                          join srod in db.ServiceRequestOntDetails on sro.Id equals srod.ServiceRequestOnt.Id /*into gj
 132:                          from subsrod in gj.DefaultIfEmpty()*/
 133:                          where /*subsrod.Id == null &&*/ s.Access != null && sro.Access != null
 134:                          select new Ia.Ngn.Cl.Model.Business.ServiceServiceRequestOnt()
 135:                          {
 136:                              ServiceId = s.Id,
 137:                              Service = s.Service,
 138:                              ServiceType = s.ServiceType, // <type id="1" name="Dn" Idlike="25212254:1:965"/>
 139:                              ServiceRequestOnt = sro
 140:                          }).ToList();
 141:   
 142:                  foreach (var v in list)
 143:                  {
 144:                      if (serviceIdPositionDictionary.ContainsKey(v.ServiceId))
 145:                      {
 146:                          v.ServicePosition = serviceIdPositionDictionary[v.ServiceId];
 147:                      }
 148:                  }
 149:              }
 150:   
 151:              return list.OrderBy(u => u.Service).ToList();
 152:          }
 153:   
 154:          ////////////////////////////////////////////////////////////////////////////
 155:   
 156:          /// <summary>
 157:          ///
 158:          /// </summary>
 159:          private static Dictionary<string, int> ServiceIdPositionDictionary
 160:          {
 161:              get
 162:              {
 163:                  /*
 164:                   * All Nokia ONTs and MDUs start at position 1
 165:                   * Huaweil ONTs start at 1, and MDUs start at 0
 166:                   */
 167:   
 168:                  string key;
 169:                  Dictionary<string, int> dictionary, nokiaToNokiaDictionary, nokiaToHuaweiEmsOntSipInfoesDictionary, nokiaToHuaweiEmsVoipPstnUsersDictionary, huaweiToHuaweiEmsOntSipInfoesDictionary, huaweiToHuaweiEmsVoipPstnUsersDictionary;
 170:   
 171:                  nokiaToHuaweiEmsOntSipInfoesDictionary = new Dictionary<string, int>();
 172:                  nokiaToHuaweiEmsVoipPstnUsersDictionary = new Dictionary<string, int>();
 173:                  huaweiToHuaweiEmsOntSipInfoesDictionary = new Dictionary<string, int>();
 174:   
 175:                  var dummyVarToDrawRefractorToBelow = Ia.Ngn.Cl.Model.Business.NumberFormatConverter.Service("0000000");
 176:   
 177:                  using (var db = new Ia.Ngn.Cl.Model.Ngn())
 178:                  {
 179:                      // No-No
 180:                      nokiaToNokiaDictionary = (from s in db.Subscribers
 181:                                                join sp in db.SubParties on s.SubParty.Id equals sp.Id
 182:                                                join ep in db.AgcfEndpoints on sp.AgcfEndpoint.Id equals ep.Id
 183:                                                select new { s.Id, ep.FlatTermID }).Distinct().ToDictionary(u => u.Id, u => u.FlatTermID);
 184:   
 185:   
 186:                      // No-Hu ONT
 187:                      // select * from Subscribers as s inner join EmsOntSipInfoes as eosi on s.PartyId = eosi.SIPUSERNAME 
 188:                      var list = (from s in db.Subscribers
 189:                                  join eosi in db.EmsOntSipInfos on s.PartyId equals eosi.SIPUSERNAME
 190:                                  select new { s.Id, eosi.TEL }).ToList();
 191:   
 192:                      foreach (var l in list) if (!nokiaToHuaweiEmsOntSipInfoesDictionary.ContainsKey(l.Id)) nokiaToHuaweiEmsOntSipInfoesDictionary[l.Id] = l.TEL;
 193:   
 194:   
 195:                      // No-Hu MDU
 196:                      // select * from Subscribers as s inner join EmsOntSipInfoes as eosi on s.PartyId = eosi.SIPUSERNAME 
 197:                      var list2 = (from s in db.Subscribers
 198:                                    join evpu in db.EmsVoipPstnUsers on s.PartyId.Replace("+", "") equals evpu.DN // see: Ia.Ngn.Cl.Model.Business.NumberFormatConverter.ServiceWithCountryCode()
 199:                                    select new { s.Id, evpu.PN }).ToList();
 200:   
 201:                      foreach (var l in list2) if (!nokiaToHuaweiEmsVoipPstnUsersDictionary.ContainsKey(l.Id)) nokiaToHuaweiEmsVoipPstnUsersDictionary[l.Id] = l.PN;
 202:   
 203:   
 204:                      // Hu-Hu ONT
 205:                      // I will use SIPUSERNAME because looks similar for Nokia and Huawei switches, but SIPNAME sometimes like +96525422460@ims.moc.kw and like priv_96524602282
 206:                      // select s.IMPU, SUBSTRING(s.IMPU, 5, 12),eosi.SIPUSERNAME, eosi.SIPUSERNAME, eosi.TEL from HuSbrs as s inner join EmsOntSipInfoes as eosi on SUBSTRING(s.IMPU, 5, 12) = eosi.SIPUSERNAME
 207:                      var list3 = (from s in db.HuSbrs
 208:                                   join eosi in db.EmsOntSipInfos on s.IMPU.Substring(4, 12) equals eosi.SIPUSERNAME //.Replace("sip:", "")  // see: Ia.Ngn.Cl.Model.Business.NumberFormatConverter.ImpuSipDomain()
 209:                                   select new { s.IMPU, eosi.TEL }).ToList();
 210:   
 211:                      foreach (var l in list3) if (!huaweiToHuaweiEmsOntSipInfoesDictionary.ContainsKey(l.IMPU)) huaweiToHuaweiEmsOntSipInfoesDictionary[l.IMPU] = l.TEL;
 212:   
 213:   
 214:                      // Hu-Hu MDU
 215:                      huaweiToHuaweiEmsVoipPstnUsersDictionary = (from s in db.HuSbrs
 216:                                                                  join evpu in db.EmsVoipPstnUsers on s.IMPU.Replace("sip:", "").Replace("@ims.moc.kw", "") equals evpu.DN // see: Ia.Ngn.Cl.Model.Business.NumberFormatConverter.ServiceWithCountryCode()
 217:                                                                  select new { s.IMPU, evpu.PN }).Distinct().ToDictionary(u => u.IMPU, u => u.PN);
 218:   
 219:   
 220:                      dictionary = new Dictionary<string, int>(nokiaToNokiaDictionary.Count + nokiaToHuaweiEmsOntSipInfoesDictionary.Count + huaweiToHuaweiEmsOntSipInfoesDictionary.Count + huaweiToHuaweiEmsVoipPstnUsersDictionary.Count);
 221:   
 222:   
 223:                      foreach (KeyValuePair<string, int> kvp in nokiaToNokiaDictionary)
 224:                      {
 225:                          key = Ia.Ngn.Cl.Model.Business.NumberFormatConverter.Service(kvp.Key);
 226:                          key = Ia.Ngn.Cl.Model.Business.Service.ServiceToServiceId(key, 1);
 227:                          dictionary[key] = kvp.Value;
 228:                      }
 229:   
 230:                      foreach (KeyValuePair<string, int> kvp in nokiaToHuaweiEmsOntSipInfoesDictionary)
 231:                      {
 232:                          key = Ia.Ngn.Cl.Model.Business.NumberFormatConverter.Service(kvp.Key);
 233:                          key = Ia.Ngn.Cl.Model.Business.Service.ServiceToServiceId(key, 1);
 234:                          dictionary[key] = kvp.Value;
 235:                      }
 236:   
 237:                      foreach (KeyValuePair<string, int> kvp in nokiaToHuaweiEmsVoipPstnUsersDictionary)
 238:                      {
 239:                          key = Ia.Ngn.Cl.Model.Business.NumberFormatConverter.Service(kvp.Key);
 240:                          key = Ia.Ngn.Cl.Model.Business.Service.ServiceToServiceId(key, 1);
 241:                          dictionary[key] = kvp.Value - 1; // -1 because it has a Huawei MDU. See above.
 242:                      }
 243:   
 244:                      foreach (KeyValuePair<string, int> kvp in huaweiToHuaweiEmsOntSipInfoesDictionary)
 245:                      {
 246:                          key = Ia.Ngn.Cl.Model.Business.NumberFormatConverter.Service(kvp.Key);
 247:                          key = Ia.Ngn.Cl.Model.Business.Service.ServiceToServiceId(key, 1);
 248:                          dictionary[key] = kvp.Value;
 249:                      }
 250:   
 251:                      foreach (KeyValuePair<string, int> kvp in huaweiToHuaweiEmsVoipPstnUsersDictionary)
 252:                      {
 253:                          key = Ia.Ngn.Cl.Model.Business.NumberFormatConverter.Service(kvp.Key);
 254:                          key = Ia.Ngn.Cl.Model.Business.Service.ServiceToServiceId(key, 1);
 255:                          dictionary[key] = kvp.Value - 1; // -1 because it has a Huawei MDU. See above.
 256:                      }
 257:                  }
 258:   
 259:                  return dictionary;
 260:              }
 261:          }
 262:   
 263:          ////////////////////////////////////////////////////////////////////////////
 264:   
 265:          /// <summary>
 266:          ///
 267:          /// </summary>
 268:          public static List<string> MyHiddenNumberList
 269:          {
 270:              get
 271:              {
 272:                  List<string> list;
 273:   
 274:                  list = new List<string>
 275:                  {
 276:                      "24545444",
 277:                      "25240002"
 278:                  };
 279:   
 280:                  return list;
 281:              }
 282:          }
 283:   
 284:          ////////////////////////////////////////////////////////////////////////////
 285:   
 286:          /// <summary>
 287:          ///
 288:          /// </summary>
 289:          public static List<Ia.Ngn.Cl.Model.Business.Service.KuwaitNgnArea> KuwaitNgnAreaList
 290:          {
 291:              get
 292:              {
 293:                  if (kuwaitNgnAreaList == null || kuwaitNgnAreaList.Count == 0)
 294:                  {
 295:                      if (HttpContext.Current != null && HttpContext.Current.Application["kuwaitNgnAreaList"] != null)
 296:                      {
 297:                          kuwaitNgnAreaList = (List<Ia.Ngn.Cl.Model.Business.Service.KuwaitNgnArea>)HttpContext.Current.Application["kuwaitNgnAreaList"];
 298:                      }
 299:                      else
 300:                      {
 301:                          kuwaitNgnAreaList = null;
 302:                          kuwaitNgnAreaList = Ia.Ngn.Cl.Model.Data.Service._KuwaitNgnAreaList;
 303:   
 304:                          if (HttpContext.Current != null) HttpContext.Current.Application["kuwaitNgnAreaList"] = kuwaitNgnAreaList;
 305:                      }
 306:                  }
 307:   
 308:                  return kuwaitNgnAreaList;
 309:              }
 310:          }
 311:   
 312:          ////////////////////////////////////////////////////////////////////////////
 313:   
 314:          /// <summary>
 315:          ///
 316:          /// </summary>
 317:          private static List<Ia.Ngn.Cl.Model.Business.Service.KuwaitNgnArea> _KuwaitNgnAreaList
 318:          {
 319:              get
 320:              {
 321:                  int id;
 322:                  string symbol;
 323:                  Ia.Ngn.Cl.Model.Business.Service.KuwaitNgnArea kuwaitNgnArea;
 324:   
 325:                  kuwaitNgnAreaList = new List<Ia.Ngn.Cl.Model.Business.Service.KuwaitNgnArea>();
 326:   
 327:                  foreach (XElement xe in XDocument.Element("service").Elements("areaList").Elements("area"))
 328:                  {
 329:                      kuwaitNgnArea = new Ia.Ngn.Cl.Model.Business.Service.KuwaitNgnArea();
 330:   
 331:                      id = int.Parse(xe.Attribute("id").Value);
 332:                      kuwaitNgnArea.Id = id;
 333:   
 334:                      symbol = xe.Attribute("symbol").Value;
 335:                      kuwaitNgnArea.Symbol = symbol;
 336:   
 337:                      kuwaitNgnArea.ServiceRequestAddressProvinceAreaName = xe.Attribute("serviceRequestAddressProvinceAreaName").Value;
 338:   
 339:                      kuwaitNgnArea.Name = (from ka in Ia.Cl.Model.Kuwait.KuwaitAreaList where ka.Id == id select ka.Name).SingleOrDefault();
 340:                      kuwaitNgnArea.ArabicName = (from ka in Ia.Cl.Model.Kuwait.KuwaitAreaList where ka.Id == id select ka.ArabicName).SingleOrDefault();
 341:   
 342:                      kuwaitNgnArea.SiteList = (from s in Ia.Ngn.Cl.Model.Data.NetworkDesignDocument.SiteList where s.AreaSymbolList.Contains(symbol) select s).ToList();
 343:   
 344:                      if (kuwaitNgnArea.SiteList != null) kuwaitNgnAreaList.Add(kuwaitNgnArea);
 345:                  }
 346:   
 347:                  return kuwaitNgnAreaList;
 348:              }
 349:          }
 350:   
 351:          ////////////////////////////////////////////////////////////////////////////
 352:   
 353:          /// <summary>
 354:          ///
 355:          /// </summary>
 356:          public static Dictionary<int, string> AreaIdToSymbolDictionary
 357:          {
 358:              get
 359:              {
 360:                  Dictionary<int, string> dictionary;
 361:   
 362:                  dictionary = (from kna in Ia.Ngn.Cl.Model.Data.Service.KuwaitNgnAreaList select new { kna.Id, kna.Symbol }).ToDictionary(u => u.Id, u => u.Symbol);
 363:   
 364:                  return dictionary;
 365:              }
 366:          }
 367:   
 368:          ////////////////////////////////////////////////////////////////////////////
 369:   
 370:          /// <summary>
 371:          ///
 372:          /// </summary>
 373:          public static Dictionary<int, string> AreaIdToNameArabicNameDictionary
 374:          {
 375:              get
 376:              {
 377:                  Dictionary<int, string> dictionary;
 378:   
 379:                  dictionary = (from kna in Ia.Ngn.Cl.Model.Data.Service.KuwaitNgnAreaList select new { kna.Id, kna.NameArabicName }).ToDictionary(u => u.Id, u => u.NameArabicName);
 380:   
 381:                  return dictionary;
 382:              }
 383:          }
 384:   
 385:          ////////////////////////////////////////////////////////////////////////////
 386:          ////////////////////////////////////////////////////////////////////////////
 387:   
 388:          /// <summary>
 389:          ///
 390:          /// </summary>
 391:          public static List<int> DomainList
 392:          {
 393:              get
 394:              {
 395:                  if (domainList == null || domainList.Count == 0)
 396:                  {
 397:                      if (HttpContext.Current != null && HttpContext.Current.Application["domainList"] != null)
 398:                      {
 399:                          domainList = (List<int>)HttpContext.Current.Application["domainList"];
 400:                      }
 401:                      else
 402:                      {
 403:                          domainList = null;
 404:                          domainList = Ia.Ngn.Cl.Model.Data.Service._DomainList;
 405:   
 406:                          if (HttpContext.Current != null) HttpContext.Current.Application["domainList"] = domainList;
 407:                      }
 408:                  }
 409:   
 410:                  return domainList;
 411:              }
 412:          }
 413:   
 414:          ////////////////////////////////////////////////////////////////////////////
 415:   
 416:          /// <summary>
 417:          ///
 418:          /// </summary>
 419:          private static List<int> _DomainList
 420:          {
 421:              get
 422:              {
 423:                  domainList = (from r in Ia.Ngn.Cl.Model.Data.NetworkDesignDocument.RouterList select r).SelectMany(r => r.DomainList).Distinct().ToList();
 424:   
 425:                  domainList.Sort();
 426:   
 427:                  return domainList;
 428:              }
 429:          }
 430:   
 431:          ////////////////////////////////////////////////////////////////////////////
 432:   
 433:          /// <summary>
 434:          ///
 435:          /// </summary>
 436:          public static List<int> NokiaSwitchDomainList
 437:          {
 438:              get
 439:              {
 440:                  if (nokiaSwitchDomainList == null || nokiaSwitchDomainList.Count == 0)
 441:                  {
 442:                      if (HttpContext.Current != null && HttpContext.Current.Application["nokiaSwitchDomainList"] != null)
 443:                      {
 444:                          nokiaSwitchDomainList = (List<int>)HttpContext.Current.Application["nokiaSwitchDomainList"];
 445:                      }
 446:                      else
 447:                      {
 448:                          nokiaSwitchDomainList = null;
 449:                          nokiaSwitchDomainList = Ia.Ngn.Cl.Model.Data.Service._NokiaSwitchDomainList;
 450:   
 451:                          if (HttpContext.Current != null) HttpContext.Current.Application["nokiaSwitchDomainList"] = nokiaSwitchDomainList;
 452:                      }
 453:                  }
 454:   
 455:                  return nokiaSwitchDomainList;
 456:              }
 457:          }
 458:   
 459:          ////////////////////////////////////////////////////////////////////////////
 460:   
 461:          /// <summary>
 462:          ///
 463:          /// </summary>
 464:          private static List<int> _NokiaSwitchDomainList
 465:          {
 466:              get
 467:              {
 468:                  Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Vendor vendor;
 469:   
 470:                  vendor = (from v in Ia.Ngn.Cl.Model.Data.NetworkDesignDocument.VendorList where v == Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Vendor.Nokia select v).Single();
 471:   
 472:                  return DomainListWithinSwitchVendor(vendor);
 473:              }
 474:          }
 475:   
 476:          ////////////////////////////////////////////////////////////////////////////
 477:   
 478:          /// <summary>
 479:          ///
 480:          /// </summary>
 481:          public static List<int> HuaweiSwitchDomainList
 482:          {
 483:              get
 484:              {
 485:                  if (huaweiSwitchDomainList == null || huaweiSwitchDomainList.Count == 0)
 486:                  {
 487:                      if (HttpContext.Current != null && HttpContext.Current.Application["huaweiSwitchDomainList"] != null)
 488:                      {
 489:                          huaweiSwitchDomainList = (List<int>)HttpContext.Current.Application["huaweiSwitchDomainList"];
 490:                      }
 491:                      else
 492:                      {
 493:                          huaweiSwitchDomainList = null;
 494:                          huaweiSwitchDomainList = Ia.Ngn.Cl.Model.Data.Service._HuaweiSwitchDomainList;
 495:   
 496:                          if (HttpContext.Current != null) HttpContext.Current.Application["huaweiSwitchDomainList"] = huaweiSwitchDomainList;
 497:                      }
 498:                  }
 499:   
 500:                  return huaweiSwitchDomainList;
 501:              }
 502:          }
 503:   
 504:          ////////////////////////////////////////////////////////////////////////////
 505:   
 506:          /// <summary>
 507:          ///
 508:          /// </summary>
 509:          private static List<int> _HuaweiSwitchDomainList
 510:          {
 511:              get
 512:              {
 513:                  Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Vendor vendor;
 514:   
 515:                  vendor = (from v in Ia.Ngn.Cl.Model.Data.NetworkDesignDocument.VendorList where v == Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Vendor.Huawei select v).Single();
 516:   
 517:                  return Ia.Ngn.Cl.Model.Data.Service.DomainListWithinSwitchVendor(vendor);
 518:              }
 519:          }
 520:   
 521:          ////////////////////////////////////////////////////////////////////////////
 522:   
 523:          /// <summary>
 524:          ///
 525:          /// </summary>
 526:          private static List<int> DomainListWithinSwitchVendor(Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Vendor vendor)
 527:          {
 528:              List<int> list;
 529:   
 530:              list = (from d in Ia.Ngn.Cl.Model.Data.NetworkDesignDocument.RouterList where d.Vendor == vendor select d).SelectMany(r => r.DomainList).ToList();
 531:   
 532:              list.Sort();
 533:   
 534:              return list;
 535:          }
 536:   
 537:          ////////////////////////////////////////////////////////////////////////////
 538:   
 539:          /// <summary>
 540:          ///
 541:          /// 
 542:          /// </summary>
 543:          private static List<int> DomainListWithinAccessVendor(Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Vendor vendor)
 544:          {
 545:              List<int> list;
 546:   
 547:              list = (from d in Ia.Ngn.Cl.Model.Data.NetworkDesignDocument.OdfList where d.Vendor == vendor select d.Router).SelectMany(r => r.DomainList).ToList();
 548:   
 549:              list.Sort();
 550:   
 551:              return list;
 552:          }
 553:   
 554:          ////////////////////////////////////////////////////////////////////////////
 555:   
 556:          /// <summary>
 557:          ///
 558:          /// </summary>
 559:          public static List<int> AllPossibleServiceNumberList
 560:          {
 561:              get
 562:              {
 563:                  int n, length;
 564:                  string s;
 565:                  List<int> list;
 566:   
 567:                  list = new List<int>(10000 * Ia.Ngn.Cl.Model.Data.Service.DomainList.Count);
 568:   
 569:                  foreach (int d in Ia.Ngn.Cl.Model.Data.Service.DomainList)
 570:                  {
 571:                      s = d.ToString();
 572:   
 573:                      length = s.Length;
 574:   
 575:                      if (length == 4)
 576:                      {
 577:                          for (int i = 0; i < 10000; i++)
 578:                          {
 579:                              n = d * 10000 + i;
 580:   
 581:                              list.Add(n);
 582:                          }
 583:                      }
 584:                      else if (length == 5)
 585:                      {
 586:                          for (int p = 0; p < 1000; p++)
 587:                          {
 588:                              n = d * 1000 + p;
 589:   
 590:                              list.Add(n);
 591:                          }
 592:                      }
 593:                      else
 594:                      {
 595:                          throw new Exception("length " + length + " is unknown");
 596:                      }
 597:                  }
 598:   
 599:                  return list;
 600:              }
 601:          }
 602:   
 603:          ////////////////////////////////////////////////////////////////////////////
 604:   
 605:          /// <summary>
 606:          ///
 607:          /// </summary>
 608:          public static List<int> AllPossibleServiceNumberListWithinDomain(int domain)
 609:          {
 610:              int n, length;
 611:              string s;
 612:              List<int> list;
 613:   
 614:              s = domain.ToString();
 615:   
 616:              length = s.Length;
 617:   
 618:              list = new List<int>(10000);
 619:   
 620:              if (length == 4)
 621:              {
 622:                  for (int i = 0; i < 10000; i++)
 623:                  {
 624:                      n = domain * 10000 + i;
 625:   
 626:                      list.Add(n);
 627:                  }
 628:              }
 629:              else if (length == 5)
 630:              {
 631:                  for (int p = 0; p < 1000; p++)
 632:                  {
 633:                      n = domain * 1000 + p;
 634:   
 635:                      list.Add(n);
 636:                  }
 637:              }
 638:              else
 639:              {
 640:                  throw new Exception("length " + length + " is unknown");
 641:              }
 642:   
 643:              return list;
 644:          }
 645:   
 646:          ////////////////////////////////////////////////////////////////////////////
 647:   
 648:          /// <summary>
 649:          ///
 650:          /// </summary>
 651:          public static List<int> AllPossibleServiceNumberListWithinNokiaSwitch
 652:          {
 653:              get
 654:              {
 655:                  Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Vendor nokia;
 656:                  List<int> list;
 657:   
 658:                  nokia = (from v in Ia.Ngn.Cl.Model.Data.NetworkDesignDocument.VendorList where v == Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Vendor.Nokia select v).Single();
 659:   
 660:                  list = AllPossibleServiceNumberListWithinSwitchVendor(nokia);
 661:   
 662:                  return list;
 663:              }
 664:          }
 665:   
 666:          ////////////////////////////////////////////////////////////////////////////
 667:   
 668:          /// <summary>
 669:          ///
 670:          /// </summary>
 671:          public static List<int> AllPossibleServiceNumberListWithinHuaweiSwitch
 672:          {
 673:              get
 674:              {
 675:                  Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Vendor huawei;
 676:                  List<int> list;
 677:   
 678:                  huawei = (from v in Ia.Ngn.Cl.Model.Data.NetworkDesignDocument.VendorList where v == Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Vendor.Huawei select v).Single();
 679:   
 680:                  list = AllPossibleServiceNumberListWithinSwitchVendor(huawei);
 681:   
 682:                  return list;
 683:              }
 684:          }
 685:   
 686:          ////////////////////////////////////////////////////////////////////////////
 687:   
 688:          /// <summary>
 689:          ///
 690:          /// </summary>
 691:          private static List<int> AllPossibleServiceNumberListWithinSwitchVendor(Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Vendor vendor)
 692:          {
 693:              int n, length;
 694:              string s;
 695:              List<int> list;
 696:              List<int> domainListWithinSwitchVendor;
 697:   
 698:              domainListWithinSwitchVendor = Ia.Ngn.Cl.Model.Data.Service.DomainListWithinSwitchVendor(vendor);
 699:   
 700:              list = new List<int>(10000 * domainListWithinSwitchVendor.Count);
 701:   
 702:              foreach (int domain in domainListWithinSwitchVendor)
 703:              {
 704:                  s = domain.ToString();
 705:   
 706:                  length = s.Length;
 707:   
 708:                  if (length == 4)
 709:                  {
 710:                      for (int i = 0; i < 10000; i++)
 711:                      {
 712:                          n = domain * 10000 + i;
 713:   
 714:                          list.Add(n);
 715:                      }
 716:                  }
 717:                  else if (length == 5)
 718:                  {
 719:                      for (int p = 0; p < 1000; p++)
 720:                      {
 721:                          n = domain * 1000 + p;
 722:   
 723:                          list.Add(n);
 724:                      }
 725:                  }
 726:                  else
 727:                  {
 728:                      throw new Exception("length " + length + " is unknown");
 729:                  }
 730:              }
 731:   
 732:              return list;
 733:          }
 734:   
 735:          ////////////////////////////////////////////////////////////////////////////    
 736:   
 737:          /// <summary>
 738:          ///
 739:          /// </summary>
 740:          public static List<string> ActiveServiceRequestServiceNumbersWithinDomainList(string domain)
 741:          {
 742:              List<string> list;
 743:   
 744:              using (var db = new Ia.Ngn.Cl.Model.Ngn())
 745:              {
 746:                  list = (from srs in db.ServiceRequestServices
 747:                          where srs.ServiceType == 1 && srs.Service.StartsWith(domain) && srs.Provisioned == true
 748:                          select srs.Service).ToList();
 749:              }
 750:   
 751:              return list;
 752:          }
 753:   
 754:          ////////////////////////////////////////////////////////////////////////////    
 755:   
 756:          /// <summary>
 757:          ///
 758:          /// </summary>
 759:          public static List<string> ActiveServiceNumbersWithinDomainList(string domain)
 760:          {
 761:              List<string> list;
 762:   
 763:              using (var db = new Ia.Ngn.Cl.Model.Ngn())
 764:              {
 765:                  list = (from s in db.Service2s
 766:                          where s.ServiceType == 1 && s.Service.StartsWith(domain)
 767:                          select s.Service).ToList();
 768:              }
 769:   
 770:              return list;
 771:          }
 772:   
 773:          ////////////////////////////////////////////////////////////////////////////
 774:   
 775:          /// <summary>
 776:          ///
 777:          /// </summary>
 778:          public static List<string> InactiveServiceRequestServiceNumbersWithinDomainList(string domain)
 779:          {
 780:              List<int> possibleServiceList;
 781:              List<string> serviceList, inactiveServiceList;
 782:   
 783:              serviceList = ActiveServiceRequestServiceNumbersWithinDomainList(domain);
 784:   
 785:              possibleServiceList = Ia.Ngn.Cl.Model.Data.Service.AllPossibleServiceNumberListWithinDomain(int.Parse(domain));
 786:   
 787:              inactiveServiceList = new List<string>(possibleServiceList.Count - serviceList.Count);
 788:   
 789:              // below: extract numbers within possible but not in serviceList
 790:              foreach (int i in possibleServiceList)
 791:              {
 792:                  if (!serviceList.Contains(i.ToString())) inactiveServiceList.Add(i.ToString());
 793:              }
 794:   
 795:              return inactiveServiceList;
 796:          }
 797:   
 798:          ////////////////////////////////////////////////////////////////////////////
 799:   
 800:          /// <summary>
 801:          ///
 802:          /// </summary>
 803:          public static List<string> InactiveServiceNumbersWithinDomainList(string domain)
 804:          {
 805:              List<int> possibleServiceList;
 806:              List<string> serviceList, inactiveServiceList;
 807:   
 808:              serviceList = ActiveServiceNumbersWithinDomainList(domain);
 809:   
 810:              possibleServiceList = Ia.Ngn.Cl.Model.Data.Service.AllPossibleServiceNumberListWithinDomain(int.Parse(domain));
 811:   
 812:              inactiveServiceList = new List<string>(possibleServiceList.Count - serviceList.Count);
 813:   
 814:              // below: extract numbers within possible but not in serviceList
 815:              foreach (int i in possibleServiceList)
 816:              {
 817:                  if (!serviceList.Contains(i.ToString())) inactiveServiceList.Add(i.ToString());
 818:              }
 819:   
 820:              return inactiveServiceList;
 821:          }
 822:   
 823:          ////////////////////////////////////////////////////////////////////////////
 824:   
 825:          /// <summary>
 826:          ///
 827:          /// </summary>
 828:          public static List<string> ServicePbxList
 829:          {
 830:              get
 831:              {
 832:                  List<string> list, nokiaPbxList, huaweiPbxList;
 833:   
 834:                  nokiaPbxList = Ia.Ngn.Cl.Model.Data.Nokia.SubParty.ServicePbxList();
 835:                  huaweiPbxList = new List<string>(); // Ia.Ngn.Cl.Model.Data.Huawei.???.ServicePbxList();
 836:   
 837:                  list = nokiaPbxList.Concat(huaweiPbxList).ToList();
 838:   
 839:                  return list;
 840:              }
 841:          }
 842:   
 843:          ////////////////////////////////////////////////////////////////////////////
 844:   
 845:          /// <summary>
 846:          /// 
 847:          /// How to embed and access resources by using Visual C# http://support.microsoft.com/kb/319292/en-us
 848:          /// 
 849:          /// 1. Change the "Build Action" property of your XML file from "Content" to "Embedded Resource".
 850:          /// 2. Add "using System.Reflection".
 851:          /// 3. See sample below.
 852:          /// 
 853:          /// </summary>
 854:   
 855:          private static XDocument XDocument
 856:          {
 857:              get
 858:              {
 859:                  if (xDocument == null)
 860:                  {
 861:                      Assembly _assembly;
 862:                      StreamReader streamReader;
 863:   
 864:                      _assembly = Assembly.GetExecutingAssembly();
 865:                      streamReader = new StreamReader(_assembly.GetManifestResourceStream("Ia.Ngn.Cl.model.data.service.xml"));
 866:   
 867:                      try
 868:                      {
 869:                          if (streamReader.Peek() != -1)
 870:                          {
 871:                              xDocument = System.Xml.Linq.XDocument.Load(streamReader);
 872:                          }
 873:                      }
 874:                      catch (Exception)
 875:                      {
 876:                      }
 877:                      finally
 878:                      {
 879:                      }
 880:                  }
 881:   
 882:                  return xDocument;
 883:              }
 884:          }
 885:   
 886:          ////////////////////////////////////////////////////////////////////////////    
 887:          ////////////////////////////////////////////////////////////////////////////
 888:      }
 889:   
 890:      ////////////////////////////////////////////////////////////////////////////
 891:      ////////////////////////////////////////////////////////////////////////////   
 892:  }