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

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