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

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 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 void DifferenceBetweenServiceAndServiceRequestOntDetailsOfTheCustomerDepartmentDatabase(out List<Ia.Ngn.Cl.Model.Business.ServiceServiceRequestOnt> toInsertIntoCustomerDepartment, out List<Ia.Ngn.Cl.Model.Business.ServiceServiceRequestOnt> toRemoveFromCustomerDepartment)
  73:          {
  74:              List<Ia.Ngn.Cl.Model.Business.ServiceServiceRequestOnt> 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:                  // insert into db:
  84:                  /*
  85:  select distinct s.Id, s.Service, s.ServiceType, sro.Id from Service2 s
  86:  inner join ServiceRequestOnts sro on s.Access_Id = sro.Access_Id
  87:  inner join ServiceRequestOntDetails srod on sro.Id = srod.ServiceRequestOnt_Id
  88:  left outer join ServiceRequestOntDetails srod2 on s.Service = srod2.Service
  89:  where srod2.Id is null and s.Access_Id is not null and sro.Access_Id is not null 
  90:  order by s.Service
  91:  */
  92:                  toInsertIntoCustomerDepartment = (from s in db.Service2s
  93:                                                    join sro in db.ServiceRequestOnts on s.Access.Id equals sro.Access.Id
  94:                                                    join srod in db.ServiceRequestOntDetails on sro.Id equals srod.ServiceRequestOnt.Id
  95:                                                    join srod2 in db.ServiceRequestOntDetails on s.Service equals srod2.Service
  96:                                                    into gj
  97:                                                    from subsrod2 in gj.DefaultIfEmpty()
  98:                                                    where subsrod2.Id == null && s.Access != null && sro.Access != null
  99:                                                    select new Ia.Ngn.Cl.Model.Business.ServiceServiceRequestOnt()
 100:                                                    {
 101:                                                        ServiceId = s.Id,
 102:                                                        Service = s.Service,
 103:                                                        ServiceType = s.ServiceType, // <type id="1" name="Dn" Idlike="25212254:1:965"/>
 104:                                                        ServiceRequestOnt = sro
 105:                                                    }).Distinct().ToList();
 106:   
 107:                  foreach (var v in toInsertIntoCustomerDepartment)
 108:                  {
 109:                      if (serviceIdPositionDictionary.ContainsKey(v.ServiceId))
 110:                      {
 111:                          v.ServicePosition = serviceIdPositionDictionary[v.ServiceId];
 112:                      }
 113:                      else
 114:                      {
 115:                          toRemoveBecauseServicePositionIsUndefinedList.Add(v);
 116:                      }
 117:                  }
 118:   
 119:                  // I will remove the following from list because the service position is not defined
 120:                  foreach (var v in toRemoveBecauseServicePositionIsUndefinedList) toInsertIntoCustomerDepartment.Remove(v);
 121:   
 122:                  toInsertIntoCustomerDepartment = toInsertIntoCustomerDepartment.OrderBy(u => u.Service).ToList();
 123:   
 124:   
 125:                  // remove from db:
 126:   
 127:                  /*
 128:                   */
 129:   
 130:                  toRemoveFromCustomerDepartment = (from srod in db.ServiceRequestOntDetails
 131:                                                    join sro in db.ServiceRequestOnts on srod.ServiceRequestOnt.Id equals sro.Id
 132:                                                    join s in db.Service2s on srod.Service equals s.Service
 133:                                                    into gj
 134:                                                    from subs in gj.DefaultIfEmpty()
 135:                                                    where subs.Id == null && sro.Access != null
 136:                                                    select new Ia.Ngn.Cl.Model.Business.ServiceServiceRequestOnt()
 137:                                                    {
 138:                                                        Service = srod.Service,
 139:                                                        ServiceRequestOnt = sro
 140:                                                    }).Distinct().ToList();
 141:              }
 142:          }
 143:   
 144:          ////////////////////////////////////////////////////////////////////////////
 145:   
 146:          /// <summary>
 147:          ///
 148:          /// </summary>
 149:          public static List<Ia.Ngn.Cl.Model.Business.ServiceServiceRequestOnt> ServiceServiceRequestOntDetailWithMismatchedInformationInServiceRequestOntDetailList()
 150:          {
 151:              List<Ia.Ngn.Cl.Model.Business.ServiceServiceRequestOnt> list;
 152:              Dictionary<string, int> serviceIdPositionDictionary;
 153:   
 154:              serviceIdPositionDictionary = Ia.Ngn.Cl.Model.Data.Service.ServiceIdPositionDictionary;
 155:   
 156:              using (var db = new Ia.Ngn.Cl.Model.Ngn())
 157:              {
 158:                  list = (from s in db.Service2s
 159:                          join sro in db.ServiceRequestOnts on s.Access.Id equals sro.Access.Id
 160:                          join srod in db.ServiceRequestOntDetails on sro.Id equals srod.ServiceRequestOnt.Id /*into gj
 161:                          from subsrod in gj.DefaultIfEmpty()*/
 162:                          where /*subsrod.Id == null &&*/ s.Access != null && sro.Access != null
 163:                          select new Ia.Ngn.Cl.Model.Business.ServiceServiceRequestOnt()
 164:                          {
 165:                              ServiceId = s.Id,
 166:                              Service = s.Service,
 167:                              ServiceType = s.ServiceType, // <type id="1" name="Dn" Idlike="25212254:1:965"/>
 168:                              ServiceRequestOnt = sro
 169:                          }).ToList();
 170:   
 171:                  foreach (var v in list)
 172:                  {
 173:                      if (serviceIdPositionDictionary.ContainsKey(v.ServiceId))
 174:                      {
 175:                          v.ServicePosition = serviceIdPositionDictionary[v.ServiceId];
 176:                      }
 177:                  }
 178:              }
 179:   
 180:              return list.OrderBy(u => u.Service).ToList();
 181:          }
 182:   
 183:          ////////////////////////////////////////////////////////////////////////////
 184:   
 185:          /// <summary>
 186:          ///
 187:          /// </summary>
 188:          public static Dictionary<string, int> ServiceIdPositionDictionary
 189:          {
 190:              get
 191:              {
 192:                  string key;
 193:                  Dictionary<string, int> dictionary, nokiaToNokiaDictionary, nokiaToHuaweiEmsOntSipInfoesDictionary, nokiaToHuaweiEmsVoipPstnUsersDictionary, huaweiToHuaweiEmsOntSipInfoesDictionary, huaweiToHuaweiEmsVoipPstnUsersDictionary;
 194:   
 195:                  nokiaToNokiaDictionary = new Dictionary<string, int>();
 196:                  nokiaToHuaweiEmsOntSipInfoesDictionary = new Dictionary<string, int>();
 197:                  nokiaToHuaweiEmsVoipPstnUsersDictionary = new Dictionary<string, int>();
 198:                  huaweiToHuaweiEmsOntSipInfoesDictionary = new Dictionary<string, int>();
 199:   
 200:                  var dummyVarToDrawRefractorToBelow = Ia.Ngn.Cl.Model.Business.NumberFormatConverter.Service("0000000");
 201:   
 202:                  using (var db = new Ia.Ngn.Cl.Model.Ngn())
 203:                  {
 204:                      // No-No
 205:                      nokiaToNokiaDictionary = (from s in db.Subscribers
 206:                                                join sp in db.SubParties on s.SubParty.Id equals sp.Id
 207:                                                join ep in db.AgcfEndpoints on sp.AgcfEndpoint.Id equals ep.Id
 208:                                                select new { s.Id, ep.FlatTermID }).Distinct().ToDictionary(u => u.Id, u => u.FlatTermID);
 209:   
 210:   
 211:                      // No-Hu ONT with EmsOntSipInfo
 212:                      // select * from Subscribers as s inner join EmsOntSipInfoes as eosi on s.PartyId = eosi.SIPUSERNAME 
 213:                      var list = (from s in db.Subscribers
 214:                                  join eosi in db.EmsOntSipInfos on s.PartyId equals eosi.SIPUSERNAME
 215:                                  select new { s.Id, eosi.TEL }).ToList();
 216:   
 217:                      foreach (var l in list) if (!nokiaToHuaweiEmsOntSipInfoesDictionary.ContainsKey(l.Id)) nokiaToHuaweiEmsOntSipInfoesDictionary[l.Id] = l.TEL;
 218:   
 219:   
 220:                      // No-Hu MDU
 221:                      // select s.Id, evpu.PN from Subscribers as s inner join EmsVoipPstnUsers as evpu on s.PartyId = '+' + evpu.DN
 222:                      var list2 = (from s in db.Subscribers
 223:                                   join evpu in db.EmsVoipPstnUsers on s.PartyId equals "+" + evpu.DN // see: Ia.Ngn.Cl.Model.Business.NumberFormatConverter.ServiceWithCountryCode()
 224:                                   select new { s.Id, evpu.PN }).ToList();
 225:   
 226:                      foreach (var l in list2) if (!nokiaToHuaweiEmsVoipPstnUsersDictionary.ContainsKey(l.Id)) nokiaToHuaweiEmsVoipPstnUsersDictionary[l.Id] = l.PN;
 227:   
 228:   
 229:                      // Hu-Hu ONT
 230:                      // I will use SIPUSERNAME because looks similar for Nokia and Huawei switches, but SIPNAME sometimes like +96525422460@ims.moc.kw and like priv_96524602282
 231:                      // select s.IMPU, eosi.SIPUSERNAME, eosi.TEL from HuSbrs as s inner join EmsOntSipInfoes as eosi on s.IMPU = 'sip:' + eosi.SIPNAME
 232:                      var list3 = (from s in db.HuSbrs
 233:                                   join eosi in db.EmsOntSipInfos on s.IMPU equals "sip:" + eosi.SIPNAME  // see: Ia.Ngn.Cl.Model.Business.NumberFormatConverter.ImpuSipDomain()
 234:                                   select new { s.IMPU, eosi.TEL }).ToList();
 235:   
 236:                      foreach (var l in list3) if (!huaweiToHuaweiEmsOntSipInfoesDictionary.ContainsKey(l.IMPU)) huaweiToHuaweiEmsOntSipInfoesDictionary[l.IMPU] = l.TEL;
 237:   
 238:   
 239:                      // Hu-Hu MDU
 240:                      // select * from HuSbrs s inner join EmsVoipPstnUsers evpu on s.IMPU = 'sip:+' + evpu.DN + '@ims.moc.kw'
 241:                      huaweiToHuaweiEmsVoipPstnUsersDictionary = (from s in db.HuSbrs
 242:                                                                  join evpu in db.EmsVoipPstnUsers on s.IMPU equals "sip:+" + evpu.DN + "@ims.moc.kw" // see: Ia.Ngn.Cl.Model.Business.NumberFormatConverter.ServiceWithCountryCode()
 243:                                                                  select new { s.IMPU, evpu.PN }).Distinct().ToDictionary(u => u.IMPU, u => u.PN);
 244:   
 245:   
 246:                      dictionary = new Dictionary<string, int>(nokiaToNokiaDictionary.Count + nokiaToHuaweiEmsOntSipInfoesDictionary.Count + huaweiToHuaweiEmsOntSipInfoesDictionary.Count + huaweiToHuaweiEmsVoipPstnUsersDictionary.Count);
 247:   
 248:   
 249:                      foreach (KeyValuePair<string, int> kvp in nokiaToNokiaDictionary)
 250:                      {
 251:                          key = Ia.Ngn.Cl.Model.Business.NumberFormatConverter.Service(kvp.Key);
 252:                          key = Ia.Ngn.Cl.Model.Business.Service.ServiceToServiceId(key, 1);
 253:                          dictionary[key] = kvp.Value;
 254:                      }
 255:   
 256:                      foreach (KeyValuePair<string, int> kvp in nokiaToHuaweiEmsOntSipInfoesDictionary)
 257:                      {
 258:                          key = Ia.Ngn.Cl.Model.Business.NumberFormatConverter.Service(kvp.Key);
 259:                          key = Ia.Ngn.Cl.Model.Business.Service.ServiceToServiceId(key, 1);
 260:                          dictionary[key] = kvp.Value;
 261:                      }
 262:   
 263:                      foreach (KeyValuePair<string, int> kvp in nokiaToHuaweiEmsVoipPstnUsersDictionary)
 264:                      {
 265:                          key = Ia.Ngn.Cl.Model.Business.NumberFormatConverter.Service(kvp.Key);
 266:                          key = Ia.Ngn.Cl.Model.Business.Service.ServiceToServiceId(key, 1);
 267:                          dictionary[key] = ConvertEmsVoipPstnUsersPnToServiceRequestServicePosition(kvp.Value);
 268:                      }
 269:   
 270:                      foreach (KeyValuePair<string, int> kvp in huaweiToHuaweiEmsOntSipInfoesDictionary)
 271:                      {
 272:                          key = Ia.Ngn.Cl.Model.Business.NumberFormatConverter.Service(kvp.Key);
 273:                          key = Ia.Ngn.Cl.Model.Business.Service.ServiceToServiceId(key, 1);
 274:                          dictionary[key] = kvp.Value;
 275:                      }
 276:   
 277:                      foreach (KeyValuePair<string, int> kvp in huaweiToHuaweiEmsVoipPstnUsersDictionary)
 278:                      {
 279:                          key = Ia.Ngn.Cl.Model.Business.NumberFormatConverter.Service(kvp.Key);
 280:                          key = Ia.Ngn.Cl.Model.Business.Service.ServiceToServiceId(key, 1);
 281:                          dictionary[key] = ConvertEmsVoipPstnUsersPnToServiceRequestServicePosition(kvp.Value); 
 282:                      }
 283:                  }
 284:   
 285:                  return dictionary;
 286:              }
 287:          }
 288:   
 289:          ////////////////////////////////////////////////////////////////////////////
 290:   
 291:          /// <summary>
 292:          ///
 293:          /// </summary>
 294:          public static int ConvertEmsVoipPstnUsersPnToServiceRequestServicePosition(int pn)
 295:          {
 296:              /*
 297:               * - All Nokia ONTs and MDUs start at position 1
 298:               * - Huawei ONTs start at 1, and MDUs start at 0
 299:               * - All position in the customer department database will start at position 1
 300:               */
 301:   
 302:              // +1 because it has a Huawei MDU. See above.
 303:   
 304:              return pn + 1;
 305:          }
 306:   
 307:          ////////////////////////////////////////////////////////////////////////////
 308:   
 309:          /// <summary>
 310:          ///
 311:          /// </summary>
 312:          public static int ConvertServiceRequestServicePositionToEmsVoipPstnUsersPn(int servicePosition)
 313:          {
 314:              /*
 315:               * - All Nokia ONTs and MDUs start at position 1
 316:               * - Huawei ONTs start at 1, and MDUs start at 0
 317:               * - All position in the customer department database will start at position 1
 318:               */
 319:   
 320:              // -1 because it has a Huawei MDU. See above.
 321:   
 322:              return servicePosition - 1;
 323:          }
 324:   
 325:          ////////////////////////////////////////////////////////////////////////////
 326:   
 327:          /// <summary>
 328:          ///
 329:          /// </summary>
 330:          public static List<string> MyHiddenNumberList
 331:          {
 332:              get
 333:              {
 334:                  List<string> list;
 335:   
 336:                  list = new List<string>
 337:                  {
 338:                      "24545444",
 339:                      "25240002"
 340:                  };
 341:   
 342:                  return list;
 343:              }
 344:          }
 345:   
 346:          ////////////////////////////////////////////////////////////////////////////
 347:   
 348:          /// <summary>
 349:          ///
 350:          /// </summary>
 351:          public static List<Ia.Ngn.Cl.Model.Business.Service.KuwaitNgnArea> KuwaitNgnAreaList
 352:          {
 353:              get
 354:              {
 355:                  if (kuwaitNgnAreaList == null || kuwaitNgnAreaList.Count == 0)
 356:                  {
 357:                      if (HttpContext.Current != null && HttpContext.Current.Application["kuwaitNgnAreaList"] != null)
 358:                      {
 359:                          kuwaitNgnAreaList = (List<Ia.Ngn.Cl.Model.Business.Service.KuwaitNgnArea>)HttpContext.Current.Application["kuwaitNgnAreaList"];
 360:                      }
 361:                      else
 362:                      {
 363:                          kuwaitNgnAreaList = null;
 364:                          kuwaitNgnAreaList = Ia.Ngn.Cl.Model.Data.Service._KuwaitNgnAreaList;
 365:   
 366:                          if (HttpContext.Current != null) HttpContext.Current.Application["kuwaitNgnAreaList"] = kuwaitNgnAreaList;
 367:                      }
 368:                  }
 369:   
 370:                  return kuwaitNgnAreaList;
 371:              }
 372:          }
 373:   
 374:          ////////////////////////////////////////////////////////////////////////////
 375:   
 376:          /// <summary>
 377:          ///
 378:          /// </summary>
 379:          private static List<Ia.Ngn.Cl.Model.Business.Service.KuwaitNgnArea> _KuwaitNgnAreaList
 380:          {
 381:              get
 382:              {
 383:                  int id;
 384:                  string symbol;
 385:                  Ia.Ngn.Cl.Model.Business.Service.KuwaitNgnArea kuwaitNgnArea;
 386:   
 387:                  kuwaitNgnAreaList = new List<Ia.Ngn.Cl.Model.Business.Service.KuwaitNgnArea>();
 388:   
 389:                  foreach (XElement xe in XDocument.Element("service").Elements("areaList").Elements("area"))
 390:                  {
 391:                      kuwaitNgnArea = new Ia.Ngn.Cl.Model.Business.Service.KuwaitNgnArea();
 392:   
 393:                      id = int.Parse(xe.Attribute("id").Value);
 394:                      kuwaitNgnArea.Id = id;
 395:   
 396:                      symbol = xe.Attribute("symbol").Value;
 397:                      kuwaitNgnArea.Symbol = symbol;
 398:   
 399:                      kuwaitNgnArea.ServiceRequestAddressProvinceAreaName = xe.Attribute("serviceRequestAddressProvinceAreaName").Value;
 400:   
 401:                      kuwaitNgnArea.Name = (from ka in Ia.Cl.Model.Kuwait.KuwaitAreaList where ka.Id == id select ka.Name).SingleOrDefault();
 402:                      kuwaitNgnArea.ArabicName = (from ka in Ia.Cl.Model.Kuwait.KuwaitAreaList where ka.Id == id select ka.ArabicName).SingleOrDefault();
 403:   
 404:                      kuwaitNgnArea.SiteList = (from s in Ia.Ngn.Cl.Model.Data.NetworkDesignDocument.SiteList where s.AreaSymbolList.Contains(symbol) select s).ToList();
 405:   
 406:                      if (kuwaitNgnArea.SiteList != null) kuwaitNgnAreaList.Add(kuwaitNgnArea);
 407:                  }
 408:   
 409:                  return kuwaitNgnAreaList;
 410:              }
 411:          }
 412:   
 413:          ////////////////////////////////////////////////////////////////////////////
 414:   
 415:          /// <summary>
 416:          ///
 417:          /// </summary>
 418:          public static Dictionary<int, string> AreaIdToSymbolDictionary
 419:          {
 420:              get
 421:              {
 422:                  Dictionary<int, string> dictionary;
 423:   
 424:                  dictionary = (from kna in Ia.Ngn.Cl.Model.Data.Service.KuwaitNgnAreaList select new { kna.Id, kna.Symbol }).ToDictionary(u => u.Id, u => u.Symbol);
 425:   
 426:                  return dictionary;
 427:              }
 428:          }
 429:   
 430:          ////////////////////////////////////////////////////////////////////////////
 431:   
 432:          /// <summary>
 433:          ///
 434:          /// </summary>
 435:          public static Dictionary<int, string> AreaIdToNameArabicNameDictionary
 436:          {
 437:              get
 438:              {
 439:                  Dictionary<int, string> dictionary;
 440:   
 441:                  dictionary = (from kna in Ia.Ngn.Cl.Model.Data.Service.KuwaitNgnAreaList select new { kna.Id, kna.NameArabicName }).ToDictionary(u => u.Id, u => u.NameArabicName);
 442:   
 443:                  return dictionary;
 444:              }
 445:          }
 446:   
 447:          ////////////////////////////////////////////////////////////////////////////
 448:          ////////////////////////////////////////////////////////////////////////////
 449:   
 450:          /// <summary>
 451:          ///
 452:          /// </summary>
 453:          public static List<int> DomainList
 454:          {
 455:              get
 456:              {
 457:                  if (domainList == null || domainList.Count == 0)
 458:                  {
 459:                      if (HttpContext.Current != null && HttpContext.Current.Application["domainList"] != null)
 460:                      {
 461:                          domainList = (List<int>)HttpContext.Current.Application["domainList"];
 462:                      }
 463:                      else
 464:                      {
 465:                          domainList = null;
 466:                          domainList = Ia.Ngn.Cl.Model.Data.Service._DomainList;
 467:   
 468:                          if (HttpContext.Current != null) HttpContext.Current.Application["domainList"] = domainList;
 469:                      }
 470:                  }
 471:   
 472:                  return domainList;
 473:              }
 474:          }
 475:   
 476:          ////////////////////////////////////////////////////////////////////////////
 477:   
 478:          /// <summary>
 479:          ///
 480:          /// </summary>
 481:          private static List<int> _DomainList
 482:          {
 483:              get
 484:              {
 485:                  domainList = (from r in Ia.Ngn.Cl.Model.Data.NetworkDesignDocument.RouterList select r).SelectMany(r => r.DomainList).Distinct().ToList();
 486:   
 487:                  domainList.Sort();
 488:   
 489:                  return domainList;
 490:              }
 491:          }
 492:   
 493:          ////////////////////////////////////////////////////////////////////////////
 494:   
 495:          /// <summary>
 496:          ///
 497:          /// </summary>
 498:          public static List<int> NokiaSwitchDomainList
 499:          {
 500:              get
 501:              {
 502:                  if (nokiaSwitchDomainList == null || nokiaSwitchDomainList.Count == 0)
 503:                  {
 504:                      if (HttpContext.Current != null && HttpContext.Current.Application["nokiaSwitchDomainList"] != null)
 505:                      {
 506:                          nokiaSwitchDomainList = (List<int>)HttpContext.Current.Application["nokiaSwitchDomainList"];
 507:                      }
 508:                      else
 509:                      {
 510:                          nokiaSwitchDomainList = null;
 511:                          nokiaSwitchDomainList = Ia.Ngn.Cl.Model.Data.Service._NokiaSwitchDomainList;
 512:   
 513:                          if (HttpContext.Current != null) HttpContext.Current.Application["nokiaSwitchDomainList"] = nokiaSwitchDomainList;
 514:                      }
 515:                  }
 516:   
 517:                  return nokiaSwitchDomainList;
 518:              }
 519:          }
 520:   
 521:          ////////////////////////////////////////////////////////////////////////////
 522:   
 523:          /// <summary>
 524:          ///
 525:          /// </summary>
 526:          private static List<int> _NokiaSwitchDomainList
 527:          {
 528:              get
 529:              {
 530:                  Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Vendor vendor;
 531:   
 532:                  vendor = (from v in Ia.Ngn.Cl.Model.Data.NetworkDesignDocument.VendorList where v == Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Vendor.Nokia select v).Single();
 533:   
 534:                  return DomainListWithinSwitchVendor(vendor);
 535:              }
 536:          }
 537:   
 538:          ////////////////////////////////////////////////////////////////////////////
 539:   
 540:          /// <summary>
 541:          ///
 542:          /// </summary>
 543:          public static List<int> HuaweiSwitchDomainList
 544:          {
 545:              get
 546:              {
 547:                  if (huaweiSwitchDomainList == null || huaweiSwitchDomainList.Count == 0)
 548:                  {
 549:                      if (HttpContext.Current != null && HttpContext.Current.Application["huaweiSwitchDomainList"] != null)
 550:                      {
 551:                          huaweiSwitchDomainList = (List<int>)HttpContext.Current.Application["huaweiSwitchDomainList"];
 552:                      }
 553:                      else
 554:                      {
 555:                          huaweiSwitchDomainList = null;
 556:                          huaweiSwitchDomainList = Ia.Ngn.Cl.Model.Data.Service._HuaweiSwitchDomainList;
 557:   
 558:                          if (HttpContext.Current != null) HttpContext.Current.Application["huaweiSwitchDomainList"] = huaweiSwitchDomainList;
 559:                      }
 560:                  }
 561:   
 562:                  return huaweiSwitchDomainList;
 563:              }
 564:          }
 565:   
 566:          ////////////////////////////////////////////////////////////////////////////
 567:   
 568:          /// <summary>
 569:          ///
 570:          /// </summary>
 571:          private static List<int> _HuaweiSwitchDomainList
 572:          {
 573:              get
 574:              {
 575:                  Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Vendor vendor;
 576:   
 577:                  vendor = (from v in Ia.Ngn.Cl.Model.Data.NetworkDesignDocument.VendorList where v == Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Vendor.Huawei select v).Single();
 578:   
 579:                  return Ia.Ngn.Cl.Model.Data.Service.DomainListWithinSwitchVendor(vendor);
 580:              }
 581:          }
 582:   
 583:          ////////////////////////////////////////////////////////////////////////////
 584:   
 585:          /// <summary>
 586:          ///
 587:          /// </summary>
 588:          private static List<int> DomainListWithinSwitchVendor(Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Vendor vendor)
 589:          {
 590:              List<int> list;
 591:   
 592:              list = (from d in Ia.Ngn.Cl.Model.Data.NetworkDesignDocument.RouterList where d.Vendor == vendor select d).SelectMany(r => r.DomainList).ToList();
 593:   
 594:              list.Sort();
 595:   
 596:              return list;
 597:          }
 598:   
 599:          ////////////////////////////////////////////////////////////////////////////
 600:   
 601:          /// <summary>
 602:          ///
 603:          /// 
 604:          /// </summary>
 605:          private static List<int> DomainListWithinAccessVendor(Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Vendor vendor)
 606:          {
 607:              List<int> list;
 608:   
 609:              list = (from d in Ia.Ngn.Cl.Model.Data.NetworkDesignDocument.OdfList where d.Vendor == vendor select d.Router).SelectMany(r => r.DomainList).ToList();
 610:   
 611:              list.Sort();
 612:   
 613:              return list;
 614:          }
 615:   
 616:          ////////////////////////////////////////////////////////////////////////////
 617:   
 618:          /// <summary>
 619:          ///
 620:          /// </summary>
 621:          public static List<int> AllPossibleServiceNumberList
 622:          {
 623:              get
 624:              {
 625:                  int n, length;
 626:                  string s;
 627:                  List<int> list;
 628:   
 629:                  list = new List<int>(10000 * Ia.Ngn.Cl.Model.Data.Service.DomainList.Count);
 630:   
 631:                  foreach (int d in Ia.Ngn.Cl.Model.Data.Service.DomainList)
 632:                  {
 633:                      s = d.ToString();
 634:   
 635:                      length = s.Length;
 636:   
 637:                      if (length == 4)
 638:                      {
 639:                          for (int i = 0; i < 10000; i++)
 640:                          {
 641:                              n = d * 10000 + i;
 642:   
 643:                              list.Add(n);
 644:                          }
 645:                      }
 646:                      else if (length == 5)
 647:                      {
 648:                          for (int p = 0; p < 1000; p++)
 649:                          {
 650:                              n = d * 1000 + p;
 651:   
 652:                              list.Add(n);
 653:                          }
 654:                      }
 655:                      else
 656:                      {
 657:                          throw new Exception("length " + length + " is unknown");
 658:                      }
 659:                  }
 660:   
 661:                  return list;
 662:              }
 663:          }
 664:   
 665:          ////////////////////////////////////////////////////////////////////////////
 666:   
 667:          /// <summary>
 668:          ///
 669:          /// </summary>
 670:          public static List<int> AllPossibleServiceNumberListWithinDomain(int domain)
 671:          {
 672:              int n, length;
 673:              string s;
 674:              List<int> list;
 675:   
 676:              s = domain.ToString();
 677:   
 678:              length = s.Length;
 679:   
 680:              list = new List<int>(10000);
 681:   
 682:              if (length == 4)
 683:              {
 684:                  for (int i = 0; i < 10000; i++)
 685:                  {
 686:                      n = domain * 10000 + i;
 687:   
 688:                      list.Add(n);
 689:                  }
 690:              }
 691:              else if (length == 5)
 692:              {
 693:                  for (int p = 0; p < 1000; p++)
 694:                  {
 695:                      n = domain * 1000 + p;
 696:   
 697:                      list.Add(n);
 698:                  }
 699:              }
 700:              else
 701:              {
 702:                  throw new Exception("length " + length + " is unknown");
 703:              }
 704:   
 705:              return list;
 706:          }
 707:   
 708:          ////////////////////////////////////////////////////////////////////////////
 709:   
 710:          /// <summary>
 711:          ///
 712:          /// </summary>
 713:          public static List<int> AllPossibleServiceNumberListWithinNokiaSwitch
 714:          {
 715:              get
 716:              {
 717:                  Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Vendor nokia;
 718:                  List<int> list;
 719:   
 720:                  nokia = (from v in Ia.Ngn.Cl.Model.Data.NetworkDesignDocument.VendorList where v == Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Vendor.Nokia select v).Single();
 721:   
 722:                  list = AllPossibleServiceNumberListWithinSwitchVendor(nokia);
 723:   
 724:                  return list;
 725:              }
 726:          }
 727:   
 728:          ////////////////////////////////////////////////////////////////////////////
 729:   
 730:          /// <summary>
 731:          ///
 732:          /// </summary>
 733:          public static List<int> AllPossibleServiceNumberListWithinHuaweiSwitch
 734:          {
 735:              get
 736:              {
 737:                  Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Vendor huawei;
 738:                  List<int> list;
 739:   
 740:                  huawei = (from v in Ia.Ngn.Cl.Model.Data.NetworkDesignDocument.VendorList where v == Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Vendor.Huawei select v).Single();
 741:   
 742:                  list = AllPossibleServiceNumberListWithinSwitchVendor(huawei);
 743:   
 744:                  return list;
 745:              }
 746:          }
 747:   
 748:          ////////////////////////////////////////////////////////////////////////////
 749:   
 750:          /// <summary>
 751:          ///
 752:          /// </summary>
 753:          private static List<int> AllPossibleServiceNumberListWithinSwitchVendor(Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Vendor vendor)
 754:          {
 755:              int n, length;
 756:              string s;
 757:              List<int> list;
 758:              List<int> domainListWithinSwitchVendor;
 759:   
 760:              domainListWithinSwitchVendor = Ia.Ngn.Cl.Model.Data.Service.DomainListWithinSwitchVendor(vendor);
 761:   
 762:              list = new List<int>(10000 * domainListWithinSwitchVendor.Count);
 763:   
 764:              foreach (int domain in domainListWithinSwitchVendor)
 765:              {
 766:                  s = domain.ToString();
 767:   
 768:                  length = s.Length;
 769:   
 770:                  if (length == 4)
 771:                  {
 772:                      for (int i = 0; i < 10000; i++)
 773:                      {
 774:                          n = domain * 10000 + i;
 775:   
 776:                          list.Add(n);
 777:                      }
 778:                  }
 779:                  else if (length == 5)
 780:                  {
 781:                      for (int p = 0; p < 1000; p++)
 782:                      {
 783:                          n = domain * 1000 + p;
 784:   
 785:                          list.Add(n);
 786:                      }
 787:                  }
 788:                  else
 789:                  {
 790:                      throw new Exception("length " + length + " is unknown");
 791:                  }
 792:              }
 793:   
 794:              return list;
 795:          }
 796:   
 797:          ////////////////////////////////////////////////////////////////////////////    
 798:   
 799:          /// <summary>
 800:          ///
 801:          /// </summary>
 802:          public static List<string> ActiveServiceRequestServiceNumbersWithinDomainList(string domain)
 803:          {
 804:              List<string> list;
 805:   
 806:              using (var db = new Ia.Ngn.Cl.Model.Ngn())
 807:              {
 808:                  list = (from srs in db.ServiceRequestServices
 809:                          where srs.ServiceType == 1 && srs.Service.StartsWith(domain) && srs.Provisioned == true
 810:                          select srs.Service).ToList();
 811:              }
 812:   
 813:              return list;
 814:          }
 815:   
 816:          ////////////////////////////////////////////////////////////////////////////    
 817:   
 818:          /// <summary>
 819:          ///
 820:          /// </summary>
 821:          public static List<string> ActiveServiceNumbersWithinDomainList(string domain)
 822:          {
 823:              List<string> list;
 824:   
 825:              using (var db = new Ia.Ngn.Cl.Model.Ngn())
 826:              {
 827:                  list = (from s in db.Service2s
 828:                          where s.ServiceType == 1 && s.Service.StartsWith(domain)
 829:                          select s.Service).ToList();
 830:              }
 831:   
 832:              return list;
 833:          }
 834:   
 835:          ////////////////////////////////////////////////////////////////////////////
 836:   
 837:          /// <summary>
 838:          ///
 839:          /// </summary>
 840:          public static List<string> InactiveServiceRequestServiceNumbersWithinDomainList(string domain)
 841:          {
 842:              List<int> possibleServiceList;
 843:              List<string> serviceList, inactiveServiceList;
 844:   
 845:              serviceList = ActiveServiceRequestServiceNumbersWithinDomainList(domain);
 846:   
 847:              possibleServiceList = Ia.Ngn.Cl.Model.Data.Service.AllPossibleServiceNumberListWithinDomain(int.Parse(domain));
 848:   
 849:              inactiveServiceList = new List<string>(possibleServiceList.Count - serviceList.Count);
 850:   
 851:              // below: extract numbers within possible but not in serviceList
 852:              foreach (int i in possibleServiceList)
 853:              {
 854:                  if (!serviceList.Contains(i.ToString())) inactiveServiceList.Add(i.ToString());
 855:              }
 856:   
 857:              return inactiveServiceList;
 858:          }
 859:   
 860:          ////////////////////////////////////////////////////////////////////////////
 861:   
 862:          /// <summary>
 863:          ///
 864:          /// </summary>
 865:          public static List<string> InactiveServiceNumbersWithinDomainList(string domain)
 866:          {
 867:              List<int> possibleServiceList;
 868:              List<string> serviceList, inactiveServiceList;
 869:   
 870:              serviceList = ActiveServiceNumbersWithinDomainList(domain);
 871:   
 872:              possibleServiceList = Ia.Ngn.Cl.Model.Data.Service.AllPossibleServiceNumberListWithinDomain(int.Parse(domain));
 873:   
 874:              inactiveServiceList = new List<string>(possibleServiceList.Count - serviceList.Count);
 875:   
 876:              // below: extract numbers within possible but not in serviceList
 877:              foreach (int i in possibleServiceList)
 878:              {
 879:                  if (!serviceList.Contains(i.ToString())) inactiveServiceList.Add(i.ToString());
 880:              }
 881:   
 882:              return inactiveServiceList;
 883:          }
 884:   
 885:          ////////////////////////////////////////////////////////////////////////////
 886:   
 887:          /// <summary>
 888:          ///
 889:          /// </summary>
 890:          public static List<string> ServicePbxList
 891:          {
 892:              get
 893:              {
 894:                  List<string> list, nokiaPbxList, huaweiPbxList;
 895:   
 896:                  nokiaPbxList = Ia.Ngn.Cl.Model.Data.Nokia.SubParty.ServicePbxList();
 897:                  huaweiPbxList = new List<string>(); // Ia.Ngn.Cl.Model.Data.Huawei.???.ServicePbxList();
 898:   
 899:                  list = nokiaPbxList.Concat(huaweiPbxList).ToList();
 900:   
 901:                  return list;
 902:              }
 903:          }
 904:   
 905:          ////////////////////////////////////////////////////////////////////////////
 906:   
 907:          /// <summary>
 908:          ///
 909:          /// </summary>
 910:          public static List<Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Olt> AllowedOltToBeProvisionedList
 911:          {
 912:              get
 913:              {
 914:                  return Ia.Ngn.Cl.Model.Data.NetworkDesignDocument.GreenFieldOltList;
 915:              }
 916:          }
 917:   
 918:          ////////////////////////////////////////////////////////////////////////////
 919:   
 920:          /// <summary>
 921:          ///
 922:          /// </summary>
 923:          public static List<int> AllowedOltToBeProvisionedIdList
 924:          {
 925:              get
 926:              {
 927:                  return Ia.Ngn.Cl.Model.Data.NetworkDesignDocument.GreenFieldOltIdList;
 928:              }
 929:          }
 930:   
 931:          ////////////////////////////////////////////////////////////////////////////
 932:   
 933:          /// <summary>
 934:          ///
 935:          /// </summary>
 936:          public static List<Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Olt> AllowedSipOltToBeProvisionedList
 937:          {
 938:              get
 939:              {
 940:                  return Ia.Ngn.Cl.Model.Data.NetworkDesignDocument.GreenFieldSipOltList;
 941:              }
 942:          }
 943:   
 944:          ////////////////////////////////////////////////////////////////////////////
 945:   
 946:          /// <summary>
 947:          ///
 948:          /// </summary>
 949:          public static List<int> AllowedSipOltToBeProvisionedIdList
 950:          {
 951:              get
 952:              {
 953:                  return Ia.Ngn.Cl.Model.Data.NetworkDesignDocument.GreenFieldSipOltIdList;
 954:              }
 955:          }
 956:   
 957:          ////////////////////////////////////////////////////////////////////////////
 958:   
 959:          /// <summary>
 960:          /// 
 961:          /// How to embed and access resources by using Visual C# http://support.microsoft.com/kb/319292/en-us
 962:          /// 
 963:          /// 1. Change the "Build Action" property of your XML file from "Content" to "Embedded Resource".
 964:          /// 2. Add "using System.Reflection".
 965:          /// 3. See sample below.
 966:          /// 
 967:          /// </summary>
 968:   
 969:          private static XDocument XDocument
 970:          {
 971:              get
 972:              {
 973:                  if (xDocument == null)
 974:                  {
 975:                      Assembly _assembly;
 976:                      StreamReader streamReader;
 977:   
 978:                      _assembly = Assembly.GetExecutingAssembly();
 979:                      streamReader = new StreamReader(_assembly.GetManifestResourceStream("Ia.Ngn.Cl.model.data.service.xml"));
 980:   
 981:                      try
 982:                      {
 983:                          if (streamReader.Peek() != -1)
 984:                          {
 985:                              xDocument = System.Xml.Linq.XDocument.Load(streamReader);
 986:                          }
 987:                      }
 988:                      catch (Exception)
 989:                      {
 990:                      }
 991:                      finally
 992:                      {
 993:                      }
 994:                  }
 995:   
 996:                  return xDocument;
 997:              }
 998:          }
 999:   
1000:          ////////////////////////////////////////////////////////////////////////////    
1001:          ////////////////////////////////////////////////////////////////////////////
1002:      }
1003:   
1004:      ////////////////////////////////////////////////////////////////////////////
1005:      ////////////////////////////////////////////////////////////////////////////   
1006:  }