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

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.Collections.Generic;
   3:  using System.Data;
   4:  using System.IO;
   5:  using System.Linq;
   6:  using System.Reflection;
   7:  using System.Web;
   8:  using System.Xml.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-2019 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 List<Ia.Ngn.Cl.Model.Business.Service.KuwaitNgnArea> kuwaitNgnAreaList;
  35:          private static List<int> domainList, pstnDomainList, migrationDomainList, nokiaSwitchDomainList, huaweiSwitchDomainList;
  36:          private static List<Ia.Ngn.Cl.Model.Business.Service.ServiceType> serviceTypeList;
  37:          private static Dictionary<string, int> serviceIdPositionDictionary;
  38:          private static readonly object objectLock = new object();
  39:   
  40:          ////////////////////////////////////////////////////////////////////////////
  41:   
  42:          /// <summary>
  43:          ///
  44:          /// </summary>
  45:          public Service() { }
  46:   
  47:   
  48:          ////////////////////////////////////////////////////////////////////////////
  49:   
  50:          /// <summary>
  51:          ///
  52:          /// </summary>
  53:          public static Dictionary<string, Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Vendor> ServiceToOntRouterVendorInAllowedToBeMigratedOltDictionary
  54:          {
  55:              get
  56:              {
  57:                  string service, accessId;
  58:                  Dictionary<string, Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Vendor> dictionary;
  59:   
  60:                  var serviceToAccessIdInAllowedToBeMigratedOltDictionary = Ia.Ngn.Cl.Model.Data.Service2.ServiceToAccessIdInAllowedToBeMigratedOltDictionary;
  61:   
  62:                  var allowedToBeMigratedAccessIdToOntDictionary = Ia.Ngn.Cl.Model.Data.Service.AllowedToBeMigratedAccessIdToOntDictionary;
  63:   
  64:                  dictionary = new Dictionary<string, Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Vendor>();
  65:   
  66:                  foreach (KeyValuePair<string, string> kvp in serviceToAccessIdInAllowedToBeMigratedOltDictionary)
  67:                  {
  68:                      service = kvp.Key;
  69:                      accessId = kvp.Value;
  70:   
  71:                      dictionary[service] = allowedToBeMigratedAccessIdToOntDictionary[accessId].Pon.PonGroup.Olt.Odf.Router.Vendor;
  72:                  }
  73:   
  74:                  return dictionary;
  75:              }
  76:          }
  77:   
  78:          ////////////////////////////////////////////////////////////////////////////
  79:   
  80:          /// <summary>
  81:          ///
  82:          /// </summary>
  83:          public static List<string> ServiceThatDoNotExistInServiceRequestServiceServiceIdList()
  84:          {
  85:              List<string> list;
  86:   
  87:              using (var db = new Ia.Ngn.Cl.Model.Ngn())
  88:              {
  89:                  list = (from s in db.Service2s
  90:                          join srs in db.ServiceRequestServices on s.Id equals srs.Id into gj
  91:                          from subsrs in gj.DefaultIfEmpty()
  92:                          where s.ServiceType == Ia.Ngn.Cl.Model.Business.Service.ServiceType.NgnService && subsrs.Id == null
  93:                          select s.Id).ToList();
  94:              }
  95:   
  96:              return list;
  97:          }
  98:   
  99:          ////////////////////////////////////////////////////////////////////////////
 100:   
 101:          /// <summary>
 102:          ///
 103:          /// </summary>
 104:          public static void DifferenceBetweenServiceAndServiceRequestOntDetailsOfTheCustomerDepartmentDatabase(out List<Ia.Ngn.Cl.Model.Business.ServiceServiceRequestOnt> toInsertIntoCustomerDepartment, out List<Ia.Ngn.Cl.Model.Business.ServiceServiceRequestOnt> toRemoveFromCustomerDepartment)
 105:          {
 106:              List<Ia.Ngn.Cl.Model.Business.ServiceServiceRequestOnt> toRemoveBecauseServicePositionIsUndefinedList, toRemoveFromCustomerDepartmentBecauseDoesNotExistInService, toOverwriteByRemovingFirstInCustomerDepartment;
 107:              Dictionary<string, int> serviceIdPositionDictionary;
 108:   
 109:              toRemoveBecauseServicePositionIsUndefinedList = new List<Business.ServiceServiceRequestOnt>();
 110:   
 111:              serviceIdPositionDictionary = Ia.Ngn.Cl.Model.Data.Service.ServiceIdPositionDictionary;
 112:   
 113:              using (var db = new Ia.Ngn.Cl.Model.Ngn())
 114:              {
 115:                  // insert into db:
 116:                  /*
 117:  select distinct s.Id, s.Service, s.ServiceType, sro.Id from Service2 s
 118:  inner join ServiceRequestOnts sro on s.Access_Id = sro.Access_Id
 119:  left outer join ServiceRequestOntDetails srod on sro.Id = srod.ServiceRequestOnt_Id
 120:  where srod.Id is null and s.Access_Id is not null and sro.Access_Id is not null 
 121:  order by s.Service
 122:  */
 123:                  toInsertIntoCustomerDepartment = (from s in db.Service2s
 124:                                                    join sro in db.ServiceRequestOnts on s.Access.Id equals sro.Access.Id
 125:                                                    join srod in db.ServiceRequestOntDetails on sro.Id equals srod.ServiceRequestOnt.Id
 126:                                                    into gj
 127:                                                    from srodgj in gj.DefaultIfEmpty()
 128:                                                    where s.ServiceType == Ia.Ngn.Cl.Model.Business.Service.ServiceType.NgnService && srodgj.Id == null && s.Access != null && sro.Access != null
 129:                                                    select new Ia.Ngn.Cl.Model.Business.ServiceServiceRequestOnt()
 130:                                                    {
 131:                                                        ServiceId = s.Id,
 132:                                                        Service = s.Service,
 133:                                                        ServiceType = s.ServiceType,
 134:                                                        ServiceRequestOnt = sro
 135:                                                    }).Distinct().ToList();
 136:   
 137:                  foreach (var v in toInsertIntoCustomerDepartment)
 138:                  {
 139:                      if (serviceIdPositionDictionary.ContainsKey(v.ServiceId))
 140:                      {
 141:                          v.ServicePosition = serviceIdPositionDictionary[v.ServiceId];
 142:                      }
 143:                      else
 144:                      {
 145:                          toRemoveBecauseServicePositionIsUndefinedList.Add(v);
 146:                      }
 147:                  }
 148:   
 149:                  // I will remove the following from list because the service position is not defined
 150:                  foreach (var v in toRemoveBecauseServicePositionIsUndefinedList) toInsertIntoCustomerDepartment.Remove(v);
 151:   
 152:                  toInsertIntoCustomerDepartment = toInsertIntoCustomerDepartment.OrderBy(u => u.Service).ToList();
 153:   
 154:   
 155:                  // remove from db:
 156:   
 157:                  toOverwriteByRemovingFirstInCustomerDepartment = (from s in db.Service2s
 158:                                                                    join sro in db.ServiceRequestOnts on s.Access.Id equals sro.Access.Id
 159:                                                                    join srod in db.ServiceRequestOntDetails on s.Service equals srod.Service
 160:                                                                    where s.ServiceType == Ia.Ngn.Cl.Model.Business.Service.ServiceType.NgnService && srod.ServiceRequestOnt != null && srod.ServiceRequestOnt.Id != sro.Access.Id //&& s.Service == "25488888"
 161:                                                                    select new Ia.Ngn.Cl.Model.Business.ServiceServiceRequestOnt()
 162:                                                                    {
 163:                                                                        ServiceId = s.Id,
 164:                                                                        Service = s.Service,
 165:                                                                        ServiceType = s.ServiceType,
 166:                                                                        ServiceRequestOnt = srod.ServiceRequestOnt
 167:                                                                    }).Distinct().ToList();
 168:   
 169:                  toRemoveFromCustomerDepartmentBecauseDoesNotExistInService = (from srod in db.ServiceRequestOntDetails
 170:                                                                                join sro in db.ServiceRequestOnts on srod.ServiceRequestOnt.Id equals sro.Id
 171:                                                                                join s in db.Service2s on srod.Service equals s.Service
 172:                                                                                into gj
 173:                                                                                from subs in gj.DefaultIfEmpty()
 174:                                                                                where subs.ServiceType == Ia.Ngn.Cl.Model.Business.Service.ServiceType.NgnService && subs.Id == null && sro.Access != null //&& srod.Service == "25488888"
 175:                                                                                select new Ia.Ngn.Cl.Model.Business.ServiceServiceRequestOnt()
 176:                                                                                {
 177:                                                                                    Service = srod.Service,
 178:                                                                                    ServiceRequestOnt = sro
 179:                                                                                }).Distinct().ToList();
 180:   
 181:                  toRemoveFromCustomerDepartment = toRemoveFromCustomerDepartmentBecauseDoesNotExistInService.Union(toOverwriteByRemovingFirstInCustomerDepartment).Distinct().ToList();
 182:              }
 183:          }
 184:   
 185:          ////////////////////////////////////////////////////////////////////////////
 186:   
 187:          /// <summary>
 188:          ///
 189:          /// </summary>
 190:          public static List<Ia.Ngn.Cl.Model.Business.ServiceServiceRequestOnt> ServiceServiceRequestOntDetailWithMismatchedInformationInServiceRequestOntDetailList()
 191:          {
 192:              List<Ia.Ngn.Cl.Model.Business.ServiceServiceRequestOnt> list;
 193:              Dictionary<string, int> serviceIdPositionDictionary;
 194:   
 195:              serviceIdPositionDictionary = Ia.Ngn.Cl.Model.Data.Service.ServiceIdPositionDictionary;
 196:   
 197:              using (var db = new Ia.Ngn.Cl.Model.Ngn())
 198:              {
 199:                  list = (from s in db.Service2s
 200:                          join sro in db.ServiceRequestOnts on s.Access.Id equals sro.Access.Id
 201:                          join srod in db.ServiceRequestOntDetails on sro.Id equals srod.ServiceRequestOnt.Id /*into gj
 202:                          from subsrod in gj.DefaultIfEmpty()*/
 203:                          where s.ServiceType == Ia.Ngn.Cl.Model.Business.Service.ServiceType.NgnService && /*subsrod.Id == null &&*/ s.Access != null && sro.Access != null
 204:                          select new Ia.Ngn.Cl.Model.Business.ServiceServiceRequestOnt()
 205:                          {
 206:                              ServiceId = s.Id,
 207:                              Service = s.Service,
 208:                              ServiceType = s.ServiceType,
 209:                              ServiceRequestOnt = sro
 210:                          }).ToList();
 211:   
 212:                  foreach (var v in list)
 213:                  {
 214:                      if (serviceIdPositionDictionary.ContainsKey(v.ServiceId))
 215:                      {
 216:                          v.ServicePosition = serviceIdPositionDictionary[v.ServiceId];
 217:                      }
 218:                  }
 219:              }
 220:   
 221:              return list.OrderBy(u => u.Service).ToList();
 222:          }
 223:   
 224:          ////////////////////////////////////////////////////////////////////////////
 225:   
 226:          /// <summary>
 227:          ///
 228:          /// </summary>
 229:          public static Dictionary<string, int> ServiceIdPositionDictionary
 230:          {
 231:              get
 232:              {
 233:                  if (serviceIdPositionDictionary == null || serviceIdPositionDictionary.Count == 0)
 234:                  {
 235:                      if (HttpContext.Current != null && HttpContext.Current.Application["serviceIdPositionDictionary"] != null)
 236:                      {
 237:                          serviceIdPositionDictionary = HttpContext.Current.Application["serviceIdPositionDictionary"] as Dictionary<string, int>;
 238:                      }
 239:                      else
 240:                      {
 241:                          lock (objectLock)
 242:                          {
 243:                              serviceIdPositionDictionary = null;
 244:                              serviceIdPositionDictionary = Ia.Ngn.Cl.Model.Data.Service._ServiceIdPositionDictionary;
 245:   
 246:                              if (HttpContext.Current != null) HttpContext.Current.Application["serviceIdPositionDictionary"] = serviceIdPositionDictionary;
 247:                          }
 248:                      }
 249:                  }
 250:   
 251:                  return serviceIdPositionDictionary;
 252:              }
 253:          }
 254:   
 255:          ////////////////////////////////////////////////////////////////////////////
 256:   
 257:          /// <summary>
 258:          ///
 259:          /// </summary>
 260:          private static Dictionary<string, int> _ServiceIdPositionDictionary
 261:          {
 262:              get
 263:              {
 264:                  string key;
 265:                  Dictionary<string, int> dictionary, nokiaToNokiaDictionary, nokiaToHuaweiEmsOntSipInfoesDictionary, nokiaToHuaweiEmsVoipPstnUsersDictionary, huaweiToHuaweiEmsOntSipInfoesDictionary, huaweiToHuaweiEmsVoipPstnUsersDictionary;
 266:   
 267:                  nokiaToNokiaDictionary = new Dictionary<string, int>();
 268:                  nokiaToHuaweiEmsOntSipInfoesDictionary = new Dictionary<string, int>();
 269:                  nokiaToHuaweiEmsVoipPstnUsersDictionary = new Dictionary<string, int>();
 270:                  huaweiToHuaweiEmsOntSipInfoesDictionary = new Dictionary<string, int>();
 271:   
 272:                  var dummyVarToDrawRefractorToBelow = Ia.Ngn.Cl.Model.Business.NumberFormatConverter.Service("0000000");
 273:   
 274:                  using (var db = new Ia.Ngn.Cl.Model.Ngn())
 275:                  {
 276:                      // No-No
 277:                      nokiaToNokiaDictionary = (from s in db.Subscribers
 278:                                                join sp in db.SubParties on s.SubParty.Id equals sp.Id
 279:                                                join ep in db.AgcfEndpoints on sp.AgcfEndpoint.Id equals ep.Id
 280:                                                select new { s.Id, ep.FlatTermID }).Distinct().ToDictionary(u => u.Id, u => u.FlatTermID);
 281:   
 282:   
 283:                      // No-Hu ONT with EmsOntSipInfo
 284:                      // select * from Subscribers as s inner join EmsOntSipInfoes as eosi on s.PartyId = eosi.SIPUSERNAME 
 285:                      var list = (from s in db.Subscribers
 286:                                  join eosi in db.EmsOntSipInfos on s.PartyId equals eosi.SIPUSERNAME
 287:                                  select new { s.Id, eosi.TEL }).ToList();
 288:   
 289:                      foreach (var l in list) if (!nokiaToHuaweiEmsOntSipInfoesDictionary.ContainsKey(l.Id)) nokiaToHuaweiEmsOntSipInfoesDictionary[l.Id] = l.TEL;
 290:   
 291:   
 292:                      // No-Hu MDU
 293:                      // select s.Id, evpu.PN from Subscribers as s inner join EmsVoipPstnUsers as evpu on s.PartyId = '+' + evpu.DN
 294:                      var list2 = (from s in db.Subscribers
 295:                                   join evpu in db.EmsVoipPstnUsers on s.PartyId equals "+" + evpu.DN // see: Ia.Ngn.Cl.Model.Business.NumberFormatConverter.ServiceWithCountryCode()
 296:                                   select new { s.Id, evpu.PN }).ToList();
 297:   
 298:                      foreach (var l in list2) if (!nokiaToHuaweiEmsVoipPstnUsersDictionary.ContainsKey(l.Id)) nokiaToHuaweiEmsVoipPstnUsersDictionary[l.Id] = l.PN;
 299:   
 300:   
 301:                      // Hu-Hu ONT
 302:                      // I will use SIPUSERNAME because looks similar for Nokia and Huawei switches, but SIPNAME sometimes like +96525422460@ims.moc.kw and like priv_96524602282
 303:                      // select s.IMPU, eosi.SIPUSERNAME, eosi.TEL from HuSbrs as s inner join EmsOntSipInfoes as eosi on s.IMPU = 'sip:' + eosi.SIPNAME
 304:                      var list3 = (from s in db.HuSbrs
 305:                                   join eosi in db.EmsOntSipInfos on s.IMPU equals "sip:" + eosi.SIPNAME  // see: Ia.Ngn.Cl.Model.Business.NumberFormatConverter.ImpuSipDomain()
 306:                                   select new { s.IMPU, eosi.TEL }).ToList();
 307:   
 308:                      foreach (var l in list3) if (!huaweiToHuaweiEmsOntSipInfoesDictionary.ContainsKey(l.IMPU)) huaweiToHuaweiEmsOntSipInfoesDictionary[l.IMPU] = l.TEL;
 309:   
 310:   
 311:                      // Hu-Hu MDU
 312:                      // select * from HuSbrs s inner join EmsVoipPstnUsers evpu on s.IMPU = 'sip:+' + evpu.DN + '@ims.moc.kw'
 313:                      huaweiToHuaweiEmsVoipPstnUsersDictionary = (from s in db.HuSbrs
 314:                                                                  join evpu in db.EmsVoipPstnUsers on s.IMPU equals "sip:+" + evpu.DN + "@ims.moc.kw" // see: Ia.Ngn.Cl.Model.Business.NumberFormatConverter.ServiceWithCountryCode()
 315:                                                                  select new { s.IMPU, evpu.PN }).Distinct().ToDictionary(u => u.IMPU, u => u.PN);
 316:   
 317:   
 318:                      dictionary = new Dictionary<string, int>(nokiaToNokiaDictionary.Count + nokiaToHuaweiEmsOntSipInfoesDictionary.Count + huaweiToHuaweiEmsOntSipInfoesDictionary.Count + huaweiToHuaweiEmsVoipPstnUsersDictionary.Count);
 319:   
 320:   
 321:                      foreach (KeyValuePair<string, int> kvp in nokiaToNokiaDictionary)
 322:                      {
 323:                          key = Ia.Ngn.Cl.Model.Business.NumberFormatConverter.Service(kvp.Key);
 324:                          key = Ia.Ngn.Cl.Model.Business.Service.ServiceToServiceId(key, 1);
 325:                          dictionary[key] = kvp.Value;
 326:                      }
 327:   
 328:                      foreach (KeyValuePair<string, int> kvp in nokiaToHuaweiEmsOntSipInfoesDictionary)
 329:                      {
 330:                          key = Ia.Ngn.Cl.Model.Business.NumberFormatConverter.Service(kvp.Key);
 331:                          key = Ia.Ngn.Cl.Model.Business.Service.ServiceToServiceId(key, 1);
 332:                          dictionary[key] = kvp.Value;
 333:                      }
 334:   
 335:                      foreach (KeyValuePair<string, int> kvp in nokiaToHuaweiEmsVoipPstnUsersDictionary)
 336:                      {
 337:                          key = Ia.Ngn.Cl.Model.Business.NumberFormatConverter.Service(kvp.Key);
 338:                          key = Ia.Ngn.Cl.Model.Business.Service.ServiceToServiceId(key, 1);
 339:                          dictionary[key] = Ia.Ngn.Cl.Model.Business.Service.ConvertEmsVoipPstnUsersPnToServiceRequestServicePosition(kvp.Value);
 340:                      }
 341:   
 342:                      foreach (KeyValuePair<string, int> kvp in huaweiToHuaweiEmsOntSipInfoesDictionary)
 343:                      {
 344:                          key = Ia.Ngn.Cl.Model.Business.NumberFormatConverter.Service(kvp.Key);
 345:                          key = Ia.Ngn.Cl.Model.Business.Service.ServiceToServiceId(key, 1);
 346:                          dictionary[key] = kvp.Value;
 347:                      }
 348:   
 349:                      foreach (KeyValuePair<string, int> kvp in huaweiToHuaweiEmsVoipPstnUsersDictionary)
 350:                      {
 351:                          key = Ia.Ngn.Cl.Model.Business.NumberFormatConverter.Service(kvp.Key);
 352:                          key = Ia.Ngn.Cl.Model.Business.Service.ServiceToServiceId(key, 1);
 353:                          dictionary[key] = Ia.Ngn.Cl.Model.Business.Service.ConvertEmsVoipPstnUsersPnToServiceRequestServicePosition(kvp.Value);
 354:                      }
 355:                  }
 356:   
 357:                  return dictionary;
 358:              }
 359:          }
 360:   
 361:          ////////////////////////////////////////////////////////////////////////////
 362:   
 363:          /// <summary>
 364:          ///
 365:          /// </summary>
 366:          public static int ServicePosition(string service)
 367:          {
 368:              int port;
 369:              string partyId, impu;
 370:              Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Vendor switchVendor;
 371:   
 372:              switchVendor = Ia.Ngn.Cl.Model.Business.Service.SwitchVendor(service);
 373:   
 374:              using (var db = new Ia.Ngn.Cl.Model.Ngn())
 375:              {
 376:                  if (switchVendor == Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Vendor.Nokia)
 377:                  {
 378:                      partyId = Ia.Ngn.Cl.Model.Business.NumberFormatConverter.PartyId(service);
 379:   
 380:                      // No-No (db.Subscribers partyId and Id format +96523230000)
 381:                      var ep1 = (from s in db.Subscribers
 382:                                 join sp in db.SubParties on s.SubParty.Id equals sp.Id
 383:                                 join ep in db.AgcfEndpoints on sp.AgcfEndpoint.Id equals ep.Id
 384:                                 where s.PartyId == partyId
 385:                                 select ep).SingleOrDefault();
 386:   
 387:                      if (ep1 != null) port = ep1.FlatTermID;
 388:                      else
 389:                      {
 390:                          // No-Hu ONT with EmsOntSipInfo (db.Subscribers partyId and Id have format +96523230000)
 391:                          var eosi1 = (from s in db.Subscribers
 392:                                       join eosi in db.EmsOntSipInfos on s.PartyId equals eosi.SIPUSERNAME
 393:                                       where s.PartyId == partyId
 394:                                       select eosi).SingleOrDefault();
 395:   
 396:                          if (eosi1 != null) port = eosi1.TEL;
 397:                          else
 398:                          {
 399:                              // No-Hu MDU (db.Subscribers partyId and Id have format +96523230000)
 400:                              var evpu1 = (from s in db.Subscribers
 401:                                           join evpu in db.EmsVoipPstnUsers on s.PartyId equals "+" + evpu.DN
 402:                                           where s.PartyId == partyId
 403:                                           select evpu).SingleOrDefault();
 404:   
 405:                              if (evpu1 != null)
 406:                              {
 407:                                  port = evpu1.PN;
 408:                                  port = Ia.Ngn.Cl.Model.Business.Service.ConvertEmsVoipPstnUsersPnToServiceRequestServicePosition(port);
 409:                              }
 410:                              else port = Ia.Ngn.Cl.Model.Business.Default.PortUndefinedOrInvalidOrUnknown;
 411:                          }
 412:                      }
 413:                  }
 414:                  else if (switchVendor == Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Vendor.Huawei)
 415:                  {
 416:                      impu = Ia.Ngn.Cl.Model.Business.NumberFormatConverter.ImpuSipDomain(service);
 417:   
 418:                      // Hu-Hu ONT (db.HuSbrs IMPU have format sip:+96523610000@ims.moc.kw)
 419:                      var eosi1 = (from s in db.HuSbrs
 420:                                   join eosi in db.EmsOntSipInfos on s.IMPU equals "sip:" + eosi.SIPNAME
 421:                                   where s.IMPU == impu
 422:                                   select eosi).SingleOrDefault();
 423:   
 424:                      if (eosi1 != null) port = eosi1.TEL;
 425:                      else
 426:                      {
 427:                          // Hu-Hu MDU (db.HuSbrs IMPU have format sip:+96523610000@ims.moc.kw)
 428:                          var evpu1 = (from s in db.HuSbrs
 429:                                       join evpu in db.EmsVoipPstnUsers on s.IMPU equals "sip:+" + evpu.DN + "@ims.moc.kw"
 430:                                       where s.IMPU == impu
 431:                                       select evpu).SingleOrDefault();
 432:   
 433:                          if (evpu1 != null)
 434:                          {
 435:                              port = evpu1.PN;
 436:                              port = Ia.Ngn.Cl.Model.Business.Service.ConvertEmsVoipPstnUsersPnToServiceRequestServicePosition(port);
 437:                          }
 438:                          else port = Ia.Ngn.Cl.Model.Business.Default.PortUndefinedOrInvalidOrUnknown;
 439:                      }
 440:                  }
 441:                  else //if (switchVendor == Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Vendor.Undefined)
 442:                  {
 443:                      port = Ia.Ngn.Cl.Model.Business.Default.PortUndefinedOrInvalidOrUnknown;
 444:                  }
 445:              }
 446:   
 447:              return port;
 448:          }
 449:   
 450:          ////////////////////////////////////////////////////////////////////////////
 451:   
 452:          /// <summary>
 453:          ///
 454:          /// </summary>
 455:          public static List<Ia.Ngn.Cl.Model.Business.Service.KuwaitNgnArea> KuwaitNgnAreaList
 456:          {
 457:              get
 458:              {
 459:                  if (kuwaitNgnAreaList == null || kuwaitNgnAreaList.Count == 0)
 460:                  {
 461:                      if (HttpContext.Current != null && HttpContext.Current.Application["kuwaitNgnAreaList"] != null)
 462:                      {
 463:                          kuwaitNgnAreaList = HttpContext.Current.Application["kuwaitNgnAreaList"] as List<Ia.Ngn.Cl.Model.Business.Service.KuwaitNgnArea>;
 464:                      }
 465:                      else
 466:                      {
 467:                          lock (objectLock)
 468:                          {
 469:                              kuwaitNgnAreaList = null;
 470:                              kuwaitNgnAreaList = Ia.Ngn.Cl.Model.Data.Service._KuwaitNgnAreaList;
 471:   
 472:                              if (HttpContext.Current != null) HttpContext.Current.Application["kuwaitNgnAreaList"] = kuwaitNgnAreaList;
 473:                          }
 474:                      }
 475:                  }
 476:   
 477:                  return kuwaitNgnAreaList;
 478:              }
 479:          }
 480:   
 481:          ////////////////////////////////////////////////////////////////////////////
 482:   
 483:          /// <summary>
 484:          ///
 485:          /// </summary>
 486:          private static List<Ia.Ngn.Cl.Model.Business.Service.KuwaitNgnArea> _KuwaitNgnAreaList
 487:          {
 488:              get
 489:              {
 490:                  int id;
 491:                  string symbol;
 492:                  Ia.Ngn.Cl.Model.Business.Service.KuwaitNgnArea kuwaitNgnArea;
 493:   
 494:                  kuwaitNgnAreaList = new List<Ia.Ngn.Cl.Model.Business.Service.KuwaitNgnArea>();
 495:   
 496:                  foreach (XElement xe in XDocument.Element("service").Elements("areaList").Elements("area"))
 497:                  {
 498:                      kuwaitNgnArea = new Ia.Ngn.Cl.Model.Business.Service.KuwaitNgnArea();
 499:   
 500:                      id = int.Parse(xe.Attribute("id").Value);
 501:                      kuwaitNgnArea.Id = id;
 502:   
 503:                      symbol = xe.Attribute("symbol").Value;
 504:                      kuwaitNgnArea.Symbol = symbol;
 505:   
 506:                      kuwaitNgnArea.ServiceRequestAddressProvinceAreaName = xe.Attribute("serviceRequestAddressProvinceAreaName").Value;
 507:   
 508:                      kuwaitNgnArea.Name = (from ka in Ia.Cl.Model.Kuwait.KuwaitAreaList where ka.Id == id select ka.Name).SingleOrDefault();
 509:                      kuwaitNgnArea.ArabicName = (from ka in Ia.Cl.Model.Kuwait.KuwaitAreaList where ka.Id == id select ka.ArabicName).SingleOrDefault();
 510:   
 511:                      kuwaitNgnArea.SiteList = (from s in Ia.Ngn.Cl.Model.Data.NetworkDesignDocument.SiteList where s.AreaSymbolList.Contains(symbol) select s).ToList();
 512:   
 513:                      if (kuwaitNgnArea.SiteList != null) kuwaitNgnAreaList.Add(kuwaitNgnArea);
 514:                  }
 515:   
 516:                  return kuwaitNgnAreaList;
 517:              }
 518:          }
 519:   
 520:          ////////////////////////////////////////////////////////////////////////////
 521:   
 522:          /// <summary>
 523:          ///
 524:          /// </summary>
 525:          public static Dictionary<int, string> AreaIdToSymbolDictionary
 526:          {
 527:              get
 528:              {
 529:                  Dictionary<int, string> dictionary;
 530:   
 531:                  dictionary = (from kna in Ia.Ngn.Cl.Model.Data.Service.KuwaitNgnAreaList select new { kna.Id, kna.Symbol }).ToDictionary(u => u.Id, u => u.Symbol);
 532:   
 533:                  return dictionary;
 534:              }
 535:          }
 536:   
 537:          ////////////////////////////////////////////////////////////////////////////
 538:   
 539:          /// <summary>
 540:          ///
 541:          /// </summary>
 542:          public static Dictionary<int, string> AreaIdToNameArabicNameDictionary
 543:          {
 544:              get
 545:              {
 546:                  Dictionary<int, string> dictionary;
 547:   
 548:                  dictionary = (from kna in Ia.Ngn.Cl.Model.Data.Service.KuwaitNgnAreaList select new { kna.Id, kna.NameArabicName }).ToDictionary(u => u.Id, u => u.NameArabicName);
 549:   
 550:                  return dictionary;
 551:              }
 552:          }
 553:   
 554:          ////////////////////////////////////////////////////////////////////////////
 555:   
 556:          /// <summary>
 557:          ///
 558:          /// </summary>
 559:          public static Dictionary<int, int> AreaIdToSiteIdDictionary
 560:          {
 561:              get
 562:              {
 563:                  Dictionary<int, int> dictionary;
 564:   
 565:                  dictionary = (from kna in Ia.Ngn.Cl.Model.Data.Service.KuwaitNgnAreaList where kna.SiteList.Count > 0 select new { kna.Id, SiteId = kna.SiteList.FirstOrDefault().Id }).ToDictionary(u => u.Id, u => u.SiteId);
 566:   
 567:                  return dictionary;
 568:              }
 569:          }
 570:   
 571:          ////////////////////////////////////////////////////////////////////////////
 572:          ////////////////////////////////////////////////////////////////////////////
 573:   
 574:          /// <summary>
 575:          ///
 576:          /// </summary>
 577:          public static List<int> DomainList
 578:          {
 579:              get
 580:              {
 581:                  if (domainList == null || domainList.Count == 0)
 582:                  {
 583:                      if (HttpContext.Current != null && HttpContext.Current.Application["domainList"] != null)
 584:                      {
 585:                          domainList = HttpContext.Current.Application["domainList"] as List<int>;
 586:                      }
 587:                      else
 588:                      {
 589:                          lock (objectLock)
 590:                          {
 591:                              domainList = null;
 592:                              domainList = Ia.Ngn.Cl.Model.Data.Service._DomainList;
 593:   
 594:                              if (HttpContext.Current != null) HttpContext.Current.Application["domainList"] = domainList;
 595:                          }
 596:                      }
 597:                  }
 598:   
 599:                  return domainList;
 600:              }
 601:          }
 602:   
 603:          ////////////////////////////////////////////////////////////////////////////
 604:   
 605:          /// <summary>
 606:          ///
 607:          /// </summary>
 608:          private static List<int> _DomainList
 609:          {
 610:              get
 611:              {
 612:                  domainList = (from r in Ia.Ngn.Cl.Model.Data.NetworkDesignDocument.RouterList select r).SelectMany(r => r.DomainList).Distinct().ToList();
 613:   
 614:                  domainList.Sort();
 615:   
 616:                  return domainList;
 617:              }
 618:          }
 619:   
 620:          ////////////////////////////////////////////////////////////////////////////
 621:          ////////////////////////////////////////////////////////////////////////////
 622:   
 623:          /// <summary>
 624:          ///
 625:          /// </summary>
 626:          public static List<int> PstnDomainList
 627:          {
 628:              get
 629:              {
 630:                  if (pstnDomainList == null || pstnDomainList.Count == 0)
 631:                  {
 632:                      if (HttpContext.Current != null && HttpContext.Current.Application["pstnDomainList"] != null)
 633:                      {
 634:                          pstnDomainList = HttpContext.Current.Application["pstnDomainList"] as List<int>;
 635:                      }
 636:                      else
 637:                      {
 638:                          lock (objectLock)
 639:                          {
 640:                              pstnDomainList = null;
 641:                              pstnDomainList = Ia.Ngn.Cl.Model.Data.Service._PstnDomainList;
 642:   
 643:                              if (HttpContext.Current != null) HttpContext.Current.Application["pstnDomainList"] = pstnDomainList;
 644:                          }
 645:                      }
 646:                  }
 647:   
 648:                  return pstnDomainList;
 649:              }
 650:          }
 651:   
 652:          ////////////////////////////////////////////////////////////////////////////
 653:   
 654:          /// <summary>
 655:          ///
 656:          /// </summary>
 657:          private static List<int> _PstnDomainList
 658:          {
 659:              get
 660:              {
 661:                  pstnDomainList = (from p in Ia.Ngn.Cl.Model.Data.NetworkDesignDocument.PstnList select p).SelectMany(r => r.DomainList).Distinct().ToList();
 662:   
 663:                  pstnDomainList.Sort();
 664:   
 665:                  return pstnDomainList;
 666:              }
 667:          }
 668:   
 669:          ////////////////////////////////////////////////////////////////////////////
 670:          ////////////////////////////////////////////////////////////////////////////
 671:   
 672:          /// <summary>
 673:          ///
 674:          /// </summary>
 675:          public static List<int> MigrationDomainList
 676:          {
 677:              get
 678:              {
 679:                  if (migrationDomainList == null || migrationDomainList.Count == 0)
 680:                  {
 681:                      if (HttpContext.Current != null && HttpContext.Current.Application["migrationDomainList"] != null)
 682:                      {
 683:                          migrationDomainList = HttpContext.Current.Application["migrationDomainList"] as List<int>;
 684:                      }
 685:                      else
 686:                      {
 687:                          lock (objectLock)
 688:                          {
 689:                              migrationDomainList = null;
 690:                              migrationDomainList = Ia.Ngn.Cl.Model.Data.Service._MigrationDomainList;
 691:   
 692:                              if (HttpContext.Current != null) HttpContext.Current.Application["migrationDomainList"] = migrationDomainList;
 693:                          }
 694:                      }
 695:                  }
 696:   
 697:                  return migrationDomainList;
 698:              }
 699:          }
 700:   
 701:          ////////////////////////////////////////////////////////////////////////////
 702:   
 703:          /// <summary>
 704:          ///
 705:          /// </summary>
 706:          private static List<int> _MigrationDomainList
 707:          {
 708:              get
 709:              {
 710:                  var pstnDomainList = Ia.Ngn.Cl.Model.Data.Service.PstnDomainList;
 711:                  var domainList = Ia.Ngn.Cl.Model.Data.Service.DomainList;
 712:   
 713:                  var list = domainList.Intersect(pstnDomainList);
 714:   
 715:                  return pstnDomainList;
 716:              }
 717:          }
 718:   
 719:          ////////////////////////////////////////////////////////////////////////////
 720:   
 721:          /// <summary>
 722:          ///
 723:          /// </summary>
 724:          public static List<int> NokiaSwitchDomainList
 725:          {
 726:              get
 727:              {
 728:                  if (nokiaSwitchDomainList == null || nokiaSwitchDomainList.Count == 0)
 729:                  {
 730:                      if (HttpContext.Current != null && HttpContext.Current.Application["nokiaSwitchDomainList"] != null)
 731:                      {
 732:                          nokiaSwitchDomainList = HttpContext.Current.Application["nokiaSwitchDomainList"] as List<int>;
 733:                      }
 734:                      else
 735:                      {
 736:                          lock (objectLock)
 737:                          {
 738:                              nokiaSwitchDomainList = null;
 739:                              nokiaSwitchDomainList = Ia.Ngn.Cl.Model.Data.Service._NokiaSwitchDomainList;
 740:   
 741:                              if (HttpContext.Current != null) HttpContext.Current.Application["nokiaSwitchDomainList"] = nokiaSwitchDomainList;
 742:                          }
 743:                      }
 744:                  }
 745:   
 746:                  return nokiaSwitchDomainList;
 747:              }
 748:          }
 749:   
 750:          ////////////////////////////////////////////////////////////////////////////
 751:   
 752:          /// <summary>
 753:          ///
 754:          /// </summary>
 755:          private static List<int> _NokiaSwitchDomainList
 756:          {
 757:              get
 758:              {
 759:                  Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Vendor vendor;
 760:   
 761:                  vendor = (from v in Ia.Ngn.Cl.Model.Data.NetworkDesignDocument.VendorList where v == Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Vendor.Nokia select v).Single();
 762:   
 763:                  return DomainListWithinSwitchVendor(vendor);
 764:              }
 765:          }
 766:   
 767:          ////////////////////////////////////////////////////////////////////////////
 768:   
 769:          /// <summary>
 770:          ///
 771:          /// </summary>
 772:          public static List<int> HuaweiSwitchDomainList
 773:          {
 774:              get
 775:              {
 776:                  if (huaweiSwitchDomainList == null || huaweiSwitchDomainList.Count == 0)
 777:                  {
 778:                      if (HttpContext.Current != null && HttpContext.Current.Application["huaweiSwitchDomainList"] != null)
 779:                      {
 780:                          huaweiSwitchDomainList = HttpContext.Current.Application["huaweiSwitchDomainList"] as List<int>;
 781:                      }
 782:                      else
 783:                      {
 784:                          lock (objectLock)
 785:                          {
 786:                              huaweiSwitchDomainList = null;
 787:                              huaweiSwitchDomainList = Ia.Ngn.Cl.Model.Data.Service._HuaweiSwitchDomainList;
 788:   
 789:                              if (HttpContext.Current != null) HttpContext.Current.Application["huaweiSwitchDomainList"] = huaweiSwitchDomainList;
 790:                          }
 791:                      }
 792:                  }
 793:   
 794:                  return huaweiSwitchDomainList;
 795:              }
 796:          }
 797:   
 798:          ////////////////////////////////////////////////////////////////////////////
 799:   
 800:          /// <summary>
 801:          ///
 802:          /// </summary>
 803:          private static List<int> _HuaweiSwitchDomainList
 804:          {
 805:              get
 806:              {
 807:                  Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Vendor vendor;
 808:   
 809:                  vendor = (from v in Ia.Ngn.Cl.Model.Data.NetworkDesignDocument.VendorList where v == Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Vendor.Huawei select v).Single();
 810:   
 811:                  return Ia.Ngn.Cl.Model.Data.Service.DomainListWithinSwitchVendor(vendor);
 812:              }
 813:          }
 814:   
 815:          ////////////////////////////////////////////////////////////////////////////
 816:   
 817:          /// <summary>
 818:          ///
 819:          /// </summary>
 820:          private static List<int> DomainListWithinSwitchVendor(Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Vendor vendor)
 821:          {
 822:              List<int> list;
 823:   
 824:              list = (from d in Ia.Ngn.Cl.Model.Data.NetworkDesignDocument.RouterList where d.Vendor == vendor select d).SelectMany(r => r.DomainList).ToList();
 825:   
 826:              list.Sort();
 827:   
 828:              return list;
 829:          }
 830:   
 831:          ////////////////////////////////////////////////////////////////////////////
 832:   
 833:          /// <summary>
 834:          ///
 835:          /// 
 836:          /// </summary>
 837:          private static List<int> DomainListWithinAccessVendor(Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Vendor vendor)
 838:          {
 839:              List<int> list;
 840:   
 841:              list = (from d in Ia.Ngn.Cl.Model.Data.NetworkDesignDocument.OdfList where d.Vendor == vendor select d.Router).SelectMany(r => r.DomainList).ToList();
 842:   
 843:              list.Sort();
 844:   
 845:              return list;
 846:          }
 847:   
 848:          ////////////////////////////////////////////////////////////////////////////
 849:   
 850:          /// <summary>
 851:          ///
 852:          /// </summary>
 853:          public static List<int> AllPossibleServiceNumberList
 854:          {
 855:              get
 856:              {
 857:                  int n, length;
 858:                  string s;
 859:                  List<int> list;
 860:   
 861:                  list = new List<int>(10000 * Ia.Ngn.Cl.Model.Data.Service.DomainList.Count);
 862:   
 863:                  foreach (int d in Ia.Ngn.Cl.Model.Data.Service.DomainList)
 864:                  {
 865:                      s = d.ToString();
 866:   
 867:                      length = s.Length;
 868:   
 869:                      if (length == 4)
 870:                      {
 871:                          for (int i = 0; i < 10000; i++)
 872:                          {
 873:                              n = d * 10000 + i;
 874:   
 875:                              list.Add(n);
 876:                          }
 877:                      }
 878:                      else if (length == 5)
 879:                      {
 880:                          for (int p = 0; p < 1000; p++)
 881:                          {
 882:                              n = d * 1000 + p;
 883:   
 884:                              list.Add(n);
 885:                          }
 886:                      }
 887:                      else
 888:                      {
 889:                          throw new Exception("length " + length + " is unknown");
 890:                      }
 891:                  }
 892:   
 893:                  return list;
 894:              }
 895:          }
 896:   
 897:          ////////////////////////////////////////////////////////////////////////////
 898:   
 899:          /// <summary>
 900:          ///
 901:          /// </summary>
 902:          public static List<int> AllPossiblePstnServiceNumberList
 903:          {
 904:              get
 905:              {
 906:                  int n, length;
 907:                  string s;
 908:                  List<int> list;
 909:   
 910:                  list = new List<int>(10000 * Ia.Ngn.Cl.Model.Data.Service.PstnDomainList.Count);
 911:   
 912:                  foreach (int d in Ia.Ngn.Cl.Model.Data.Service.PstnDomainList)
 913:                  {
 914:                      s = d.ToString();
 915:   
 916:                      length = s.Length;
 917:   
 918:                      if (length == 4)
 919:                      {
 920:                          for (int i = 0; i < 10000; i++)
 921:                          {
 922:                              n = d * 10000 + i;
 923:   
 924:                              list.Add(n);
 925:                          }
 926:                      }
 927:                      else if (length == 5)
 928:                      {
 929:                          for (int p = 0; p < 1000; p++)
 930:                          {
 931:                              n = d * 1000 + p;
 932:   
 933:                              list.Add(n);
 934:                          }
 935:                      }
 936:                      else
 937:                      {
 938:                          throw new Exception("length " + length + " is unknown");
 939:                      }
 940:                  }
 941:   
 942:                  return list;
 943:              }
 944:          }
 945:   
 946:          ////////////////////////////////////////////////////////////////////////////
 947:   
 948:          /// <summary>
 949:          ///
 950:          /// </summary>
 951:          public static List<int> AllPossibleServiceNumberListWithinDomain(int domain)
 952:          {
 953:              int n, length;
 954:              string s;
 955:              List<int> list;
 956:   
 957:              s = domain.ToString();
 958:   
 959:              length = s.Length;
 960:   
 961:              list = new List<int>(10000);
 962:   
 963:              if (length == 4)
 964:              {
 965:                  for (int i = 0; i < 10000; i++)
 966:                  {
 967:                      n = domain * 10000 + i;
 968:   
 969:                      list.Add(n);
 970:                  }
 971:              }
 972:              else if (length == 5)
 973:              {
 974:                  for (int p = 0; p < 1000; p++)
 975:                  {
 976:                      n = domain * 1000 + p;
 977:   
 978:                      list.Add(n);
 979:                  }
 980:              }
 981:              else
 982:              {
 983:                  throw new Exception("length " + length + " is unknown");
 984:              }
 985:   
 986:              return list;
 987:          }
 988:   
 989:          ////////////////////////////////////////////////////////////////////////////
 990:   
 991:          /// <summary>
 992:          ///
 993:          /// </summary>
 994:          public static int NumberOfPossibleServicesWithinDomainList(List<int> domainList)
 995:          {
 996:              int n, length;
 997:   
 998:              n = 0;
 999:   
1000:              foreach (int domain in domainList)
1001:              {
1002:                  length = domain.ToString().Length;
1003:   
1004:                  if (length == 4) n += 10000;
1005:                  else if (length == 5) n += 1000;
1006:                  else
1007:                  {
1008:                      throw new Exception("length " + length + " is unknown");
1009:                  }
1010:              }
1011:   
1012:              return n;
1013:          }
1014:   
1015:          ////////////////////////////////////////////////////////////////////////////
1016:   
1017:          /// <summary>
1018:          ///
1019:          /// </summary>
1020:          public static List<int> AllPossibleServiceNumberListWithinNokiaSwitch
1021:          {
1022:              get
1023:              {
1024:                  Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Vendor nokia;
1025:                  List<int> list;
1026:   
1027:                  nokia = (from v in Ia.Ngn.Cl.Model.Data.NetworkDesignDocument.VendorList where v == Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Vendor.Nokia select v).Single();
1028:   
1029:                  list = AllPossibleServiceNumberListWithinSwitchVendor(nokia);
1030:   
1031:                  return list;
1032:              }
1033:          }
1034:   
1035:          ////////////////////////////////////////////////////////////////////////////
1036:   
1037:          /// <summary>
1038:          ///
1039:          /// </summary>
1040:          public static List<int> AllPossibleServiceNumberListWithinHuaweiSwitch
1041:          {
1042:              get
1043:              {
1044:                  Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Vendor huawei;
1045:                  List<int> list;
1046:   
1047:                  huawei = (from v in Ia.Ngn.Cl.Model.Data.NetworkDesignDocument.VendorList where v == Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Vendor.Huawei select v).Single();
1048:   
1049:                  list = AllPossibleServiceNumberListWithinSwitchVendor(huawei);
1050:   
1051:                  return list;
1052:              }
1053:          }
1054:   
1055:          ////////////////////////////////////////////////////////////////////////////
1056:   
1057:          /// <summary>
1058:          ///
1059:          /// </summary>
1060:          private static List<int> AllPossibleServiceNumberListWithinSwitchVendor(Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Vendor vendor)
1061:          {
1062:              int n, length;
1063:              string s;
1064:              List<int> list;
1065:              List<int> domainListWithinSwitchVendor;
1066:   
1067:              domainListWithinSwitchVendor = Ia.Ngn.Cl.Model.Data.Service.DomainListWithinSwitchVendor(vendor);
1068:   
1069:              list = new List<int>(10000 * domainListWithinSwitchVendor.Count);
1070:   
1071:              foreach (int domain in domainListWithinSwitchVendor)
1072:              {
1073:                  s = domain.ToString();
1074:   
1075:                  length = s.Length;
1076:   
1077:                  if (length == 4)
1078:                  {
1079:                      for (int i = 0; i < 10000; i++)
1080:                      {
1081:                          n = domain * 10000 + i;
1082:   
1083:                          list.Add(n);
1084:                      }
1085:                  }
1086:                  else if (length == 5)
1087:                  {
1088:                      for (int p = 0; p < 1000; p++)
1089:                      {
1090:                          n = domain * 1000 + p;
1091:   
1092:                          list.Add(n);
1093:                      }
1094:                  }
1095:                  else
1096:                  {
1097:                      throw new Exception("length " + length + " is unknown");
1098:                  }
1099:              }
1100:   
1101:              return list;
1102:          }
1103:   
1104:          ////////////////////////////////////////////////////////////////////////////    
1105:          ////////////////////////////////////////////////////////////////////////////
1106:   
1107:          /// <summary>
1108:          ///
1109:          /// </summary>
1110:          public static List<int> AllPossibleServiceNumberWithinSite(string siteName)
1111:          {
1112:              int n, length;
1113:              string s;
1114:              List<int> list;
1115:              List<int> domainList;
1116:   
1117:              domainList = (from r in Ia.Ngn.Cl.Model.Data.NetworkDesignDocument.RouterList where r.Site.Name == siteName select r).SelectMany(r => r.DomainList).ToList();
1118:   
1119:              list = new List<int>(10000 * domainList.Count);
1120:   
1121:              foreach (int domain in domainList)
1122:              {
1123:                  s = domain.ToString();
1124:   
1125:                  length = s.Length;
1126:   
1127:                  if (length == 4)
1128:                  {
1129:                      for (int i = 0; i < 10000; i++)
1130:                      {
1131:                          n = domain * 10000 + i;
1132:   
1133:                          list.Add(n);
1134:                      }
1135:                  }
1136:                  else if (length == 5)
1137:                  {
1138:                      for (int p = 0; p < 1000; p++)
1139:                      {
1140:                          n = domain * 1000 + p;
1141:   
1142:                          list.Add(n);
1143:                      }
1144:                  }
1145:                  else
1146:                  {
1147:                      throw new Exception("length " + length + " is unknown");
1148:                  }
1149:              }
1150:   
1151:              list.Sort();
1152:   
1153:              return list.OrderBy(u => u).ToList(); // (u => u >= 25410000 && u <= 25440000).ToList();
1154:          }
1155:   
1156:          ////////////////////////////////////////////////////////////////////////////
1157:   
1158:          /// <summary>
1159:          ///
1160:          /// </summary>
1161:          public static List<int> AllPossiblePstnServiceNumbersWithinSite(string siteName)
1162:          {
1163:              int n, length;
1164:              string s;
1165:              List<int> list;
1166:              List<int> domainList;
1167:   
1168:              domainList = (from r in Ia.Ngn.Cl.Model.Data.NetworkDesignDocument.PstnList where r.Site.Name == siteName select r).SelectMany(r => r.DomainList).ToList();
1169:   
1170:              list = new List<int>(10000 * domainList.Count);
1171:   
1172:              foreach (int domain in domainList)
1173:              {
1174:                  s = domain.ToString();
1175:   
1176:                  length = s.Length;
1177:   
1178:                  if (length == 4)
1179:                  {
1180:                      for (int i = 0; i < 10000; i++)
1181:                      {
1182:                          n = domain * 10000 + i;
1183:   
1184:                          list.Add(n);
1185:                      }
1186:                  }
1187:                  else if (length == 5)
1188:                  {
1189:                      for (int p = 0; p < 1000; p++)
1190:                      {
1191:                          n = domain * 1000 + p;
1192:   
1193:                          list.Add(n);
1194:                      }
1195:                  }
1196:                  else
1197:                  {
1198:                      throw new Exception("length " + length + " is unknown");
1199:                  }
1200:              }
1201:   
1202:              list.Sort();
1203:   
1204:              return list.OrderBy(u => u).ToList(); // (u => u >= 25410000 && u <= 25440000).ToList();
1205:          }
1206:   
1207:          ////////////////////////////////////////////////////////////////////////////
1208:   
1209:          /// <summary>
1210:          ///
1211:          /// </summary>
1212:          public static List<int> AllPossiblePstnServiceNumbersWithinPstnSite(string pstnSiteName)
1213:          {
1214:              int n, length;
1215:              string s;
1216:              List<int> list;
1217:              List<int> domainList;
1218:   
1219:              domainList = (from p in Ia.Ngn.Cl.Model.Data.NetworkDesignDocument.PstnList where p.Name == pstnSiteName select p).SelectMany(r => r.DomainList).ToList();
1220:   
1221:              list = new List<int>(10000 * domainList.Count);
1222:   
1223:              foreach (int domain in domainList)
1224:              {
1225:                  s = domain.ToString();
1226:   
1227:                  length = s.Length;
1228:   
1229:                  if (length == 4)
1230:                  {
1231:                      for (int i = 0; i < 10000; i++)
1232:                      {
1233:                          n = domain * 10000 + i;
1234:   
1235:                          list.Add(n);
1236:                      }
1237:                  }
1238:                  else if (length == 5)
1239:                  {
1240:                      for (int p = 0; p < 1000; p++)
1241:                      {
1242:                          n = domain * 1000 + p;
1243:   
1244:                          list.Add(n);
1245:                      }
1246:                  }
1247:                  else
1248:                  {
1249:                      throw new Exception("length " + length + " is unknown");
1250:                  }
1251:              }
1252:   
1253:              list.Sort();
1254:   
1255:              return list.OrderBy(u => u).ToList(); // (u => u >= 25410000 && u <= 25440000).ToList();
1256:          }
1257:   
1258:          ////////////////////////////////////////////////////////////////////////////
1259:   
1260:          /// <summary>
1261:          ///
1262:          /// </summary>
1263:          public static List<string> SiteDomainList(string siteName)
1264:          {
1265:              List<int> list;
1266:              List<string> sList;
1267:   
1268:              list = (from r in Ia.Ngn.Cl.Model.Data.NetworkDesignDocument.RouterList where r.Site.Name == siteName select r).SelectMany(r => r.DomainList).ToList();
1269:   
1270:              list.Sort();
1271:   
1272:              sList = (from n in list select n.ToString()).ToList<string>();
1273:   
1274:              return sList;
1275:          }
1276:   
1277:          ////////////////////////////////////////////////////////////////////////////
1278:   
1279:          /// <summary>
1280:          ///
1281:          /// </summary>
1282:          public static List<string> SitePstnDomainList(string siteName)
1283:          {
1284:              List<int> list;
1285:              List<string> sList;
1286:   
1287:              list = (from r in Ia.Ngn.Cl.Model.Data.NetworkDesignDocument.PstnList where r.Site.Name == siteName select r).SelectMany(r => r.DomainList).ToList();
1288:   
1289:              list.Sort();
1290:   
1291:              sList = (from n in list select n.ToString()).ToList<string>();
1292:   
1293:              return sList;
1294:          }
1295:   
1296:          ////////////////////////////////////////////////////////////////////////////
1297:   
1298:          /// <summary>
1299:          ///
1300:          /// </summary>
1301:          public static bool ServiceListIsWithinSitePstnDomainList(string siteName, List<string> serviceList)
1302:          {
1303:              bool b;
1304:   
1305:              b = Ia.Ngn.Cl.Model.Data.Service.SitePstnDomainList(siteName).Any(u => serviceList.Any(v => v.StartsWith(u)));
1306:   
1307:              return b;
1308:          }
1309:   
1310:          ////////////////////////////////////////////////////////////////////////////
1311:   
1312:          /// <summary>
1313:          ///
1314:          /// </summary>
1315:          public static bool ServiceIsWithinPstnDomainList(string service)
1316:          {
1317:              bool b;
1318:   
1319:              b = Ia.Ngn.Cl.Model.Data.Service.PstnDomainList.Any(u => service.StartsWith(u.ToString()));
1320:   
1321:              return b;
1322:          }
1323:   
1324:          ////////////////////////////////////////////////////////////////////////////
1325:   
1326:          /// <summary>
1327:          ///
1328:          /// </summary>
1329:          public static bool ServiceListIsWithinPstnDomainList(List<string> serviceList)
1330:          {
1331:              bool b;
1332:   
1333:              b = Ia.Ngn.Cl.Model.Data.Service.PstnDomainList.Any(u => serviceList.Any(v => v.StartsWith(u.ToString())));
1334:   
1335:              return b;
1336:          }
1337:   
1338:          ////////////////////////////////////////////////////////////////////////////    
1339:          ////////////////////////////////////////////////////////////////////////////    
1340:   
1341:          /// <summary>
1342:          ///
1343:          /// </summary>
1344:          public static List<string> ActiveServiceRequestServiceNumbersWithinDomainList(string domain)
1345:          {
1346:              List<string> list;
1347:   
1348:              using (var db = new Ia.Ngn.Cl.Model.Ngn())
1349:              {
1350:                  list = (from srs in db.ServiceRequestServices
1351:                          where srs.ServiceType == 1 && srs.Service.StartsWith(domain) && srs.Provisioned == true
1352:                          select srs.Service).ToList();
1353:              }
1354:   
1355:              return list;
1356:          }
1357:   
1358:          ////////////////////////////////////////////////////////////////////////////    
1359:   
1360:          /// <summary>
1361:          ///
1362:          /// </summary>
1363:          public static List<string> ActiveServiceNumbersWithinDomainList(string domain)
1364:          {
1365:              int serviceType;
1366:              List<string> list;
1367:   
1368:              serviceType = Ia.Ngn.Cl.Model.Business.Service.ServiceType.NgnService;
1369:   
1370:              using (var db = new Ia.Ngn.Cl.Model.Ngn())
1371:              {
1372:                  list = (from s in db.Service2s
1373:                          where s.ServiceType == Ia.Ngn.Cl.Model.Business.Service.ServiceType.NgnService && s.ServiceType == serviceType && s.Service.StartsWith(domain)
1374:                          select s.Service).ToList();
1375:              }
1376:   
1377:              return list;
1378:          }
1379:   
1380:          ////////////////////////////////////////////////////////////////////////////
1381:   
1382:          /// <summary>
1383:          ///
1384:          /// </summary>
1385:          public static List<string> InactiveServiceRequestServiceNumbersWithinDomainList(string domain)
1386:          {
1387:              List<int> possibleServiceList;
1388:              List<string> serviceList, inactiveServiceList;
1389:   
1390:              serviceList = ActiveServiceRequestServiceNumbersWithinDomainList(domain);
1391:   
1392:              possibleServiceList = Ia.Ngn.Cl.Model.Data.Service.AllPossibleServiceNumberListWithinDomain(int.Parse(domain));
1393:   
1394:              inactiveServiceList = new List<string>(possibleServiceList.Count - serviceList.Count);
1395:   
1396:              // below: extract numbers within possible but not in serviceList
1397:              foreach (int i in possibleServiceList)
1398:              {
1399:                  if (!serviceList.Contains(i.ToString())) inactiveServiceList.Add(i.ToString());
1400:              }
1401:   
1402:              return inactiveServiceList;
1403:          }
1404:   
1405:          ////////////////////////////////////////////////////////////////////////////
1406:   
1407:          /// <summary>
1408:          ///
1409:          /// </summary>
1410:          public static List<string> InactiveServiceNumbersWithinDomainList(string domain)
1411:          {
1412:              List<int> possibleServiceList;
1413:              List<string> serviceList, inactiveServiceList;
1414:   
1415:              serviceList = ActiveServiceNumbersWithinDomainList(domain);
1416:   
1417:              possibleServiceList = Ia.Ngn.Cl.Model.Data.Service.AllPossibleServiceNumberListWithinDomain(int.Parse(domain));
1418:   
1419:              inactiveServiceList = new List<string>(possibleServiceList.Count - serviceList.Count);
1420:   
1421:              // below: extract numbers within possible but not in serviceList
1422:              foreach (int i in possibleServiceList)
1423:              {
1424:                  if (!serviceList.Contains(i.ToString())) inactiveServiceList.Add(i.ToString());
1425:              }
1426:   
1427:              return inactiveServiceList;
1428:          }
1429:   
1430:          ////////////////////////////////////////////////////////////////////////////
1431:   
1432:          /// <summary>
1433:          ///
1434:          /// </summary>
1435:          public static List<string> ServicePbxList
1436:          {
1437:              get
1438:              {
1439:                  List<string> list, nokiaPbxList, huaweiPbxList;
1440:   
1441:                  nokiaPbxList = Ia.Ngn.Cl.Model.Data.Nokia.SubParty.ServicePbxList();
1442:                  huaweiPbxList = new List<string>(); // Ia.Ngn.Cl.Model.Data.Huawei.???.ServicePbxList();
1443:   
1444:                  list = nokiaPbxList.Concat(huaweiPbxList).ToList();
1445:   
1446:                  return list;
1447:              }
1448:          }
1449:   
1450:          ////////////////////////////////////////////////////////////////////////////
1451:          ////////////////////////////////////////////////////////////////////////////
1452:   
1453:          /// <summary>
1454:          ///
1455:          /// </summary>
1456:          public static List<Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Olt> AllowedToBeProvisionedOltList
1457:          {
1458:              get
1459:              {
1460:                  return Ia.Ngn.Cl.Model.Data.NetworkDesignDocument.GreenFieldOltList.Union(AllowedToBeMigratedOltList).ToList();
1461:              }
1462:          }
1463:   
1464:          ////////////////////////////////////////////////////////////////////////////
1465:   
1466:          /// <summary>
1467:          ///
1468:          /// </summary>
1469:          public static List<int> AllowedToBeProvisionedOltIdList
1470:          {
1471:              get
1472:              {
1473:                  return Ia.Ngn.Cl.Model.Data.NetworkDesignDocument.GreenFieldOltIdList.Union(AllowedToBeMigratedOltIdList).ToList();
1474:              }
1475:          }
1476:   
1477:          ////////////////////////////////////////////////////////////////////////////
1478:   
1479:          /// <summary>
1480:          ///
1481:          /// </summary>
1482:          public static List<Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Olt> AllowedToBeProvisionedSipOltList
1483:          {
1484:              get
1485:              {
1486:                  return Ia.Ngn.Cl.Model.Data.NetworkDesignDocument.GreenFieldSipOltList.Union(AllowedToBeMigratedSipOltList).ToList();
1487:              }
1488:          }
1489:   
1490:          ////////////////////////////////////////////////////////////////////////////
1491:   
1492:          /// <summary>
1493:          ///
1494:          /// </summary>
1495:          public static List<int> AllowedToBeProvisionedSipOltIdList
1496:          {
1497:              get
1498:              {
1499:                  return Ia.Ngn.Cl.Model.Data.NetworkDesignDocument.GreenFieldSipOltIdList.Union(AllowedToBeMigratedSipOltIdList).ToList();
1500:              }
1501:          }
1502:   
1503:          ////////////////////////////////////////////////////////////////////////////
1504:          ////////////////////////////////////////////////////////////////////////////
1505:   
1506:          /// <summary>
1507:          ///
1508:          /// </summary>
1509:          public static List<Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Olt> AllowedToBeMigratedOltList
1510:          {
1511:              get
1512:              {
1513:                  return (from o in Ia.Ngn.Cl.Model.Data.NetworkDesignDocument.OltList where o.Symbol == "EGL" || o.PonGroupList.Any(pg => pg.Symbol == "EGL") select o).ToList();
1514:              }
1515:          }
1516:   
1517:          ////////////////////////////////////////////////////////////////////////////
1518:   
1519:          /// <summary>
1520:          ///
1521:          /// </summary>
1522:          public static List<int> AllowedToBeMigratedOltIdList
1523:          {
1524:              get
1525:              {
1526:                  return (from o in Ia.Ngn.Cl.Model.Data.NetworkDesignDocument.OltList where o.Symbol == "EGL" || o.PonGroupList.Any(pg => pg.Symbol == "EGL") select o.Id).ToList();
1527:              }
1528:          }
1529:   
1530:          ////////////////////////////////////////////////////////////////////////////
1531:   
1532:          /// <summary>
1533:          ///
1534:          /// </summary>
1535:          public static List<Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Olt> AllowedToBeMigratedSipOltList
1536:          {
1537:              get
1538:              {
1539:                  return (from o in Ia.Ngn.Cl.Model.Data.NetworkDesignDocument.OltList where o.Symbol == "EGL" || o.PonGroupList.Any(pg => pg.Symbol == "EGL") select o).ToList();
1540:              }
1541:          }
1542:   
1543:          ////////////////////////////////////////////////////////////////////////////
1544:   
1545:          /// <summary>
1546:          ///
1547:          /// </summary>
1548:          public static List<int> AllowedToBeMigratedSipOltIdList
1549:          {
1550:              get
1551:              {
1552:                  return (from o in Ia.Ngn.Cl.Model.Data.NetworkDesignDocument.OltList where o.Symbol == "EGL" || o.PonGroupList.Any(pg => pg.Symbol == "EGL") select o.Id).ToList();
1553:              }
1554:          }
1555:   
1556:          ////////////////////////////////////////////////////////////////////////////
1557:   
1558:          /// <summary>
1559:          ///
1560:          /// </summary>
1561:          public static Dictionary<string, Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Ont> AllowedToBeMigratedAccessIdToOntDictionary
1562:          {
1563:              get
1564:              {
1565:                  Dictionary<string, Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Ont> dictionary;
1566:   
1567:                  var list = (from o in Ia.Ngn.Cl.Model.Data.NetworkDesignDocument.OntList where o.Pon.PonGroup.Olt.Symbol == "EGL" || o.Pon.PonGroup.Symbol == "EGL" select o).ToList();
1568:   
1569:                  dictionary = list.ToDictionary(u => u.Access.Id, u => u);
1570:   
1571:                  return dictionary;
1572:              }
1573:          }
1574:   
1575:          ////////////////////////////////////////////////////////////////////////////
1576:          ////////////////////////////////////////////////////////////////////////////
1577:   
1578:          /// <summary>
1579:          ///
1580:          /// </summary>
1581:          public static Ia.Ngn.Cl.Model.Business.Service.ServiceType ServiceType(int typeId)
1582:          {
1583:              return (from s in Ia.Ngn.Cl.Model.Data.Service.ServiceTypeList where s.Id == typeId select s).SingleOrDefault();
1584:          }
1585:   
1586:          ////////////////////////////////////////////////////////////////////////////
1587:   
1588:          /// <summary>
1589:          ///
1590:          /// </summary>
1591:          public static string ServiceTypeNameFromId(int id)
1592:          {
1593:              return (from s in Ia.Ngn.Cl.Model.Data.Service.ServiceTypeList where s.Id == id select s.Name).SingleOrDefault();
1594:          }
1595:   
1596:          ////////////////////////////////////////////////////////////////////////////
1597:   
1598:          /// <summary>
1599:          ///
1600:          /// </summary>
1601:          public static List<Ia.Ngn.Cl.Model.Business.Service.ServiceType> ServiceTypeList
1602:          {
1603:              get
1604:              {
1605:                  if (serviceTypeList == null || serviceTypeList.Count == 0)
1606:                  {
1607:                      serviceTypeList = new List<Ia.Ngn.Cl.Model.Business.Service.ServiceType>();
1608:   
1609:                      serviceTypeList = new List<Ia.Ngn.Cl.Model.Business.Service.ServiceType>
1610:                      {
1611:                          // do not change "Ngn" and "Pstn" values, they will effect class ServiceType values
1612:                          new Ia.Ngn.Cl.Model.Business.Service.ServiceType(1, "Ngn", "Fiber (فايبر)", "fiber-blue"),
1613:                          new Ia.Ngn.Cl.Model.Business.Service.ServiceType(2, "Pstn", "Copper (نحاس)", "copper-brown")
1614:                      };
1615:   
1616:                      /*
1617:  
1618:                      /// 0:IMSSIPUE(IMSSIPUSER): The subscriber is an IMS SIP-UE subscriber.
1619:                      /// 1:POTS(POTSUSER): The subscriber is a SIP subscriber connected to the SIPIAD of the AGCF.
1620:                      /// 4:G/U(GUUSER): The subscriber is a G/U subscriber.
1621:                      /// 5:CDMA(CDMAUSER): The subscriber is a CDMA subscriber.
1622:                      /// 6:PSTN(PSTNUSER): The subscriber is a PSTN subscriber.
1623:  
1624:                      <type id="0" name="?"/>
1625:                      <type id="1" name="DN" Idlike="25212254:1:965"/>
1626:                      <type id="2" name="HSI" Idlike="SLA.82.13.1.2:2:965 SLA.PON.ONT.CARD.PORT"/>
1627:                      <type id="3" name="CDMA"/>
1628:                      <type id="4" name="G/U"/>
1629:                      <type id="5" name="POTS"/>
1630:                      <type id="6" name="PSTN"/>
1631:                       */
1632:                  }
1633:   
1634:                  return serviceTypeList.ToList();
1635:              }
1636:          }
1637:   
1638:          ////////////////////////////////////////////////////////////////////////////
1639:   
1640:          /// <summary>
1641:          /// 
1642:          /// How to embed and access resources by using Visual C# http://support.microsoft.com/kb/319292/en-us
1643:          /// 
1644:          /// 1. Change the "Build Action" property of your XML file from "Content" to "Embedded Resource".
1645:          /// 2. Add "using System.Reflection".
1646:          /// 3. See sample below.
1647:          /// 
1648:          /// </summary>
1649:   
1650:          private static XDocument XDocument
1651:          {
1652:              get
1653:              {
1654:                  if (xDocument == null)
1655:                  {
1656:                      Assembly _assembly;
1657:                      StreamReader streamReader;
1658:   
1659:                      _assembly = Assembly.GetExecutingAssembly();
1660:                      streamReader = new StreamReader(_assembly.GetManifestResourceStream("Ia.Ngn.Cl.model.data.service.xml"));
1661:   
1662:                      try
1663:                      {
1664:                          if (streamReader.Peek() != -1)
1665:                          {
1666:                              xDocument = System.Xml.Linq.XDocument.Load(streamReader);
1667:                          }
1668:                      }
1669:                      catch (Exception)
1670:                      {
1671:                      }
1672:                      finally
1673:                      {
1674:                      }
1675:                  }
1676:   
1677:                  return xDocument;
1678:              }
1679:          }
1680:   
1681:          ////////////////////////////////////////////////////////////////////////////    
1682:          ////////////////////////////////////////////////////////////////////////////
1683:      }
1684:   
1685:      ////////////////////////////////////////////////////////////////////////////
1686:      ////////////////////////////////////////////////////////////////////////////   
1687:  }