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

Integrated Applications Programming Company

Skip Navigation LinksHome » Code Library » Provision

Public general use code classes and xml files that we've compiled and used over the years:

Provision support class for Next Generation Network (NGN) data model.

   1:  using System;
   2:  using System.Collections;
   3:  using System.Collections.Generic;
   4:  using System.Data;
   5:  using System.Linq;
   6:   
   7:  namespace Ia.Ngn.Cl.Model.Data
   8:  {
   9:      ////////////////////////////////////////////////////////////////////////////
  10:   
  11:      /// <summary publish="true">
  12:      /// Provision support class for Next Generation Network (NGN) data model.
  13:      /// </summary>
  14:      /// 
  15:      /// <remarks> 
  16:      /// Copyright © 2006-2019 Jasem Y. Al-Shamlan (info@ia.com.kw), Integrated Applications - Kuwait. All Rights Reserved.
  17:      ///
  18:      /// 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
  19:      /// the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
  20:      ///
  21:      /// This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
  22:      /// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
  23:      /// 
  24:      /// You should have received a copy of the GNU General Public License along with this library. If not, see http://www.gnu.org/licenses.
  25:      /// 
  26:      /// Copyright notice: This notice may not be removed or altered from any source distribution.
  27:      /// </remarks> 
  28:      public class Provision
  29:      {
  30:          private static int nddNokiaOntInNonSipOltWithAccessButNoAgcfGatewayRecordListIndex, nddHuaweiSwitchAndNokiaGponOntWithAccessButNoMgwRecordListIndex, allPossibleNddOntNotInAgcfGatewayRecordListIndex, allPossibleAgcfGatewayRecordFromWithinOltListIndex, agcfGatewayRecordWithNoNddOntAndNullOrEmptyAgcfEndpointListIndex, allPossibleAgcfGatewayRecordNoInOntListIndex;
  31:          private static List<Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Ont> allPossibleNddOntNotInAgcfGatewayRecordList, nddNokiaOntInNonSipOltWithAccessButNoAgcfGatewayRecordList, nddHuaweiSwitchAndNokiaGponOntWithAccessButNoMgwRecordList;
  32:          private static List<Ia.Ngn.Cl.Model.Nokia.AgcfGatewayRecord> allPossibleAgcfGatewayRecordFromWithinOltList, agcfGatewayRecordWithNoNddOntAndNullOrEmptyAgcfEndpointList, allPossibleAgcfGatewayRecordNoInOntList;
  33:   
  34:          ////////////////////////////////////////////////////////////////////////////
  35:   
  36:          /// <summary>
  37:          ///
  38:          /// </summary>
  39:          public Provision() { }
  40:   
  41:          ////////////////////////////////////////////////////////////////////////////
  42:   
  43:          /// <summary>
  44:          ///
  45:          /// </summary>
  46:          public static Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Ont NddNokiaSwitchOntInNonSipOltWithAccessButNoAgcfGatewayRecord(out string result)
  47:          {
  48:              Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Ont ont;
  49:   
  50:              if (nddNokiaOntInNonSipOltWithAccessButNoAgcfGatewayRecordList == null || nddNokiaOntInNonSipOltWithAccessButNoAgcfGatewayRecordListIndex == 0)
  51:              {
  52:                  nddNokiaOntInNonSipOltWithAccessButNoAgcfGatewayRecordList = Ia.Ngn.Cl.Model.Data.Nokia.Ims.NddNokiaSwitchOntInNonSipOltWithAccessButNoAgcfGatewayRecordList();//.Where(u=>u.Access.Name.Contains("SLA")).ToList();
  53:   
  54:                  nddNokiaOntInNonSipOltWithAccessButNoAgcfGatewayRecordListIndex = 0;
  55:              }
  56:   
  57:              if (nddNokiaOntInNonSipOltWithAccessButNoAgcfGatewayRecordList.Count > 0)
  58:              {
  59:                  ont = (Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Ont)nddNokiaOntInNonSipOltWithAccessButNoAgcfGatewayRecordList[nddNokiaOntInNonSipOltWithAccessButNoAgcfGatewayRecordListIndex];
  60:   
  61:                  nddNokiaOntInNonSipOltWithAccessButNoAgcfGatewayRecordListIndex = Ia.Cl.Model.Default.IncrementListIndexOrRestart(nddNokiaOntInNonSipOltWithAccessButNoAgcfGatewayRecordList, nddNokiaOntInNonSipOltWithAccessButNoAgcfGatewayRecordListIndex);
  62:              }
  63:              else ont = null;
  64:   
  65:              result = "(" + nddNokiaOntInNonSipOltWithAccessButNoAgcfGatewayRecordListIndex + "/" + nddNokiaOntInNonSipOltWithAccessButNoAgcfGatewayRecordList.Count + ") ";
  66:   
  67:              return ont;
  68:          }
  69:   
  70:          ////////////////////////////////////////////////////////////////////////////
  71:   
  72:          /// <summary>
  73:          ///
  74:          /// </summary>
  75:          public static Ia.Ngn.Cl.Model.Nokia.AgcfGatewayRecord AgcfGatewayRecordWithNoNddNokiaSwitchOntInNonSipOltAndNullOrEmptyAgcfEndpoint(out string result)
  76:          {
  77:              Ia.Ngn.Cl.Model.Nokia.AgcfGatewayRecord agcfGatewayRecord;
  78:   
  79:              if (agcfGatewayRecordWithNoNddOntAndNullOrEmptyAgcfEndpointList == null || agcfGatewayRecordWithNoNddOntAndNullOrEmptyAgcfEndpointListIndex == 0)
  80:              {
  81:                  agcfGatewayRecordWithNoNddOntAndNullOrEmptyAgcfEndpointList = Ia.Ngn.Cl.Model.Data.Nokia.Ims.AgcfGatewayRecordWithNoNddNokiaSwitchOntInNonSipOltAndNullOrEmptyAgcfEndpointList();
  82:   
  83:                  agcfGatewayRecordWithNoNddOntAndNullOrEmptyAgcfEndpointListIndex = 0;
  84:              }
  85:   
  86:              if (agcfGatewayRecordWithNoNddOntAndNullOrEmptyAgcfEndpointList.Count > 0)
  87:              {
  88:                  agcfGatewayRecord = (Ia.Ngn.Cl.Model.Nokia.AgcfGatewayRecord)agcfGatewayRecordWithNoNddOntAndNullOrEmptyAgcfEndpointList[agcfGatewayRecordWithNoNddOntAndNullOrEmptyAgcfEndpointListIndex];
  89:   
  90:                  agcfGatewayRecordWithNoNddOntAndNullOrEmptyAgcfEndpointListIndex = Ia.Cl.Model.Default.IncrementListIndexOrRestart(agcfGatewayRecordWithNoNddOntAndNullOrEmptyAgcfEndpointList, agcfGatewayRecordWithNoNddOntAndNullOrEmptyAgcfEndpointListIndex);
  91:              }
  92:              else agcfGatewayRecord = null;
  93:   
  94:              result = "(" + agcfGatewayRecordWithNoNddOntAndNullOrEmptyAgcfEndpointListIndex + "/" + agcfGatewayRecordWithNoNddOntAndNullOrEmptyAgcfEndpointList.Count + ") ";
  95:   
  96:              return agcfGatewayRecord;
  97:          }
  98:   
  99:          ////////////////////////////////////////////////////////////////////////////
 100:   
 101:          /// <summary>
 102:          ///
 103:          /// </summary>
 104:          public static Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Ont NddOntNotInAgcfGatewayRecordList(Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Olt olt, out string result)
 105:          {
 106:              Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Ont ont;
 107:   
 108:              if (allPossibleNddOntNotInAgcfGatewayRecordList == null || allPossibleNddOntNotInAgcfGatewayRecordListIndex == 0)
 109:              {
 110:                  allPossibleNddOntNotInAgcfGatewayRecordList = Ia.Ngn.Cl.Model.Data.Nokia.Ims.NddOntNotInAgcfGatewayRecordList(olt);
 111:   
 112:                  allPossibleNddOntNotInAgcfGatewayRecordListIndex = 0;
 113:              }
 114:   
 115:              if (allPossibleNddOntNotInAgcfGatewayRecordList.Count > 0)
 116:              {
 117:                  ont = (Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Ont)allPossibleNddOntNotInAgcfGatewayRecordList[allPossibleNddOntNotInAgcfGatewayRecordListIndex];
 118:   
 119:                  allPossibleNddOntNotInAgcfGatewayRecordListIndex = Ia.Cl.Model.Default.IncrementListIndexOrRestart(allPossibleNddOntNotInAgcfGatewayRecordList, allPossibleNddOntNotInAgcfGatewayRecordListIndex);
 120:              }
 121:              else ont = null;
 122:   
 123:              result = "(" + allPossibleNddOntNotInAgcfGatewayRecordListIndex + "/" + allPossibleNddOntNotInAgcfGatewayRecordList.Count + ") ";
 124:   
 125:              return ont;
 126:          }
 127:   
 128:          ////////////////////////////////////////////////////////////////////////////
 129:   
 130:          /// <summary>
 131:          ///
 132:          /// </summary>
 133:          public static Ia.Ngn.Cl.Model.Nokia.AgcfGatewayRecord AgcfGatewayRecordFromWithinOltList(Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Olt olt, out string result)
 134:          {
 135:              Ia.Ngn.Cl.Model.Nokia.AgcfGatewayRecord agcfGatewayRecord;
 136:   
 137:              if (allPossibleAgcfGatewayRecordFromWithinOltList == null || allPossibleAgcfGatewayRecordFromWithinOltListIndex == 0)
 138:              {
 139:                  allPossibleAgcfGatewayRecordFromWithinOltList = Ia.Ngn.Cl.Model.Data.Nokia.AgcfGatewayRecord.List(olt);
 140:   
 141:                  allPossibleAgcfGatewayRecordFromWithinOltListIndex = 0;
 142:              }
 143:   
 144:              if (allPossibleAgcfGatewayRecordFromWithinOltList.Count > 0)
 145:              {
 146:                  agcfGatewayRecord = (Ia.Ngn.Cl.Model.Nokia.AgcfGatewayRecord)allPossibleAgcfGatewayRecordFromWithinOltList[allPossibleAgcfGatewayRecordFromWithinOltListIndex];
 147:   
 148:                  allPossibleAgcfGatewayRecordFromWithinOltListIndex = Ia.Cl.Model.Default.IncrementListIndexOrRestart(allPossibleAgcfGatewayRecordFromWithinOltList, allPossibleAgcfGatewayRecordFromWithinOltListIndex);
 149:              }
 150:              else agcfGatewayRecord = null;
 151:   
 152:              result = "(" + allPossibleAgcfGatewayRecordFromWithinOltListIndex + "/" + allPossibleAgcfGatewayRecordFromWithinOltList.Count + ") ";
 153:   
 154:              return agcfGatewayRecord;
 155:          }
 156:   
 157:          ////////////////////////////////////////////////////////////////////////////
 158:   
 159:          /// <summary>
 160:          ///
 161:          /// </summary>
 162:          public static Ia.Ngn.Cl.Model.Nokia.AgcfGatewayRecord AgcfGatewayRecordNoInOntList(Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Olt olt)
 163:          {
 164:              Ia.Ngn.Cl.Model.Nokia.AgcfGatewayRecord agcfGatewayRecord;
 165:   
 166:              if (allPossibleAgcfGatewayRecordNoInOntList == null || allPossibleAgcfGatewayRecordNoInOntListIndex == 0)
 167:              {
 168:                  allPossibleAgcfGatewayRecordNoInOntList = Ia.Ngn.Cl.Model.Data.Nokia.Ims.AllPossibleAgcfGatewayRecordsNoInOntsList(olt);
 169:   
 170:                  allPossibleAgcfGatewayRecordNoInOntListIndex = 0;
 171:              }
 172:   
 173:              agcfGatewayRecord = (Ia.Ngn.Cl.Model.Nokia.AgcfGatewayRecord)allPossibleAgcfGatewayRecordNoInOntList[allPossibleAgcfGatewayRecordNoInOntListIndex];
 174:   
 175:              allPossibleAgcfGatewayRecordNoInOntListIndex = Ia.Cl.Model.Default.IncrementListIndexOrRestart(allPossibleAgcfGatewayRecordNoInOntList, allPossibleAgcfGatewayRecordNoInOntListIndex);
 176:   
 177:              return agcfGatewayRecord;
 178:          }
 179:   
 180:          ////////////////////////////////////////////////////////////////////////////
 181:          ////////////////////////////////////////////////////////////////////////////
 182:   
 183:          /// <summary>
 184:          ///
 185:          /// </summary>
 186:          public static Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Ont NddHuaweiSwitchAndNokiaGponOntWithAccessButNoMgwRecord(out string result)
 187:          {
 188:              Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Ont ont;
 189:   
 190:              if (nddHuaweiSwitchAndNokiaGponOntWithAccessButNoMgwRecordList == null || nddHuaweiSwitchAndNokiaGponOntWithAccessButNoMgwRecordListIndex == 0)
 191:              {
 192:                  nddHuaweiSwitchAndNokiaGponOntWithAccessButNoMgwRecordList = Ia.Ngn.Cl.Model.Data.Huawei.Ims.NddHuaweiSwitchAndNokiaGponOntWithAccessButNoMgwRecord();//.Where(u=>u.Access.Name.Contains("SLA")).ToList();
 193:   
 194:                  nddHuaweiSwitchAndNokiaGponOntWithAccessButNoMgwRecordListIndex = 0;
 195:              }
 196:   
 197:              if (nddHuaweiSwitchAndNokiaGponOntWithAccessButNoMgwRecordList.Count > 0)
 198:              {
 199:                  ont = (Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Ont)nddHuaweiSwitchAndNokiaGponOntWithAccessButNoMgwRecordList[nddHuaweiSwitchAndNokiaGponOntWithAccessButNoMgwRecordListIndex];
 200:   
 201:                  nddHuaweiSwitchAndNokiaGponOntWithAccessButNoMgwRecordListIndex = Ia.Cl.Model.Default.IncrementListIndexOrRestart(nddHuaweiSwitchAndNokiaGponOntWithAccessButNoMgwRecordList, nddHuaweiSwitchAndNokiaGponOntWithAccessButNoMgwRecordListIndex);
 202:              }
 203:              else ont = null;
 204:   
 205:              result = "(" + nddHuaweiSwitchAndNokiaGponOntWithAccessButNoMgwRecordListIndex + "/" + nddHuaweiSwitchAndNokiaGponOntWithAccessButNoMgwRecordList.Count + ") ";
 206:   
 207:              return ont;
 208:          }
 209:   
 210:          /*
 211:          ////////////////////////////////////////////////////////////////////////////
 212:  
 213:          /// <summary>
 214:          ///
 215:          /// </summary>
 216:          public static bool UpdateServiceRequestServiceServiceSuspensionWithNonNullAccess(out string result)
 217:          {
 218:              bool toTrue, toFalse;
 219:              StringBuilder sb;
 220:              List<string> srsCurrentList, toTrueList, toFalseList;
 221:  
 222:              toTrue = toFalse = false;
 223:  
 224:              srsCurrentList = Ia.Ngn.Cl.Model.Data.ServiceRequestService.ServiceSuspensionIsTrueStringNumberList;
 225:  
 226:              toTrueList = new List<string>(srsCurrentList.Count);
 227:              toFalseList = new List<string>(srsCurrentList.Count);
 228:  
 229:              sb = new StringBuilder(12 * (srsCurrentList.Count));
 230:  
 231:              // below: numbers that should be added to SRS barring
 232:              sb.Append("\r\nNumber(s) to be set in SRS as barred: ");
 233:  
 234:              toTrue = Ia.Ngn.Cl.Model.Data.ServiceRequestService.UpdateServiceSuspensionAndServiceSuspensionTypeIdToSpecifiedSuspensionStateForAServiceStringList(toTrueList, true, Guid.Empty);
 235:              sb.Append("\r\nNumber(s) set?: " + toTrue.ToString());
 236:  
 237:              // below: numbres that should be removed from SRS barring
 238:              sb.Append("\r\nNumber(s) to be reset in SRS as not barred: ");
 239:  
 240:              toFalse = Ia.Ngn.Cl.Model.Data.ServiceRequestService.UpdateServiceSuspensionAndServiceSuspensionTypeIdToSpecifiedSuspensionStateForAServiceStringList(toFalseList, false, Guid.Empty);
 241:              sb.Append("\r\nNumber(s) reset?: " + toTrue.ToString());
 242:  
 243:              result = sb.ToString();
 244:  
 245:              return toTrue || toFalse;
 246:          }
 247:          */
 248:   
 249:          ////////////////////////////////////////////////////////////////////////////
 250:   
 251:          /// <summary>
 252:          ///
 253:          /// </summary>
 254:          private static List<Ia.Ngn.Cl.Model.ServiceRequestService> ServiceRequestServiceWithAccessesWithNullAgcfEndpointList
 255:          {
 256:              get
 257:              {
 258:                  List<Ia.Ngn.Cl.Model.ServiceRequestService> serviceRequestServiceList;
 259:   
 260:                  using (var db = new Ia.Ngn.Cl.Model.Ngn())
 261:                  {
 262:                      serviceRequestServiceList = (from srs in db.ServiceRequestServices
 263:                                                   join e in db.AgcfEndpoints on Ia.Ngn.Cl.Model.Business.NumberFormatConverter.PrividUser(srs.Service) equals e.PrividUser
 264:                                                   into gj
 265:                                                   from u in gj.DefaultIfEmpty()
 266:                                                   where u == null && srs.Access != null
 267:                                                   select srs).ToList();
 268:                  }
 269:   
 270:                  return serviceRequestServiceList;
 271:              }
 272:          }
 273:   
 274:          ////////////////////////////////////////////////////////////////////////////
 275:   
 276:          /// <summary>
 277:          ///
 278:          /// </summary>
 279:          public static List<string> ServiceSuspensionMismatchBetweenServiceRequestServiceAndServiceServiceIdList()
 280:          {
 281:              string service;
 282:              List<string> serviceIdList;
 283:              List<string> /*serviceIdPbxList,*/ serviceIdExemptionList;
 284:   
 285:              using (var db = new Ia.Ngn.Cl.Model.Ngn())
 286:              {
 287:                  // below:
 288:                  /*
 289:                  var serviceIdList = (from s in db.Service2
 290:                                       join srs in db.ServiceRequestServices on s.Id equals srs.Id
 291:                                       where s.ServiceType == Ia.Ngn.Cl.Model.Business.Service.ServiceType.GponService &&
 292:  
 293:                                       // below: include only allowed domains that are allowed for provisioning
 294:                                       //Ia.Ngn.Cl.Model.Data.Service.ProvisioningEnabledFourDigitNumberDomainList.Any(u => srs.Service.StartsWith(u.ToString()))
 295:                                       //&& srs.Provisioned == true
 296:                                       //&&
 297:  
 298:                                       // below: exclude huawei from barring and service suspension operations
 299:                                       !Ia.Ngn.Cl.Model.Data.Service.HuaweiSwitchDomainList.Any(u => srs.Service.StartsWith(u.ToString())) &&
 300:                                       (
 301:                                       srs.CallBarring == false && srs.ServiceSuspension == false && s.ServiceSuspension == true
 302:                                       || srs.CallBarring == true && srs.ServiceSuspension == false && s.ServiceSuspension == false
 303:                                       || srs.CallBarring == false && srs.ServiceSuspension == true && s.ServiceSuspension == false
 304:                                       || srs.CallBarring == true && srs.ServiceSuspension == true && s.ServiceSuspension == false
 305:                                       )
 306:                                       select s.Id).ToList();
 307:                  */
 308:   
 309:                  var serviceId0List = (from s in db.Service2
 310:                                        join srs in db.ServiceRequestServices on s.Id equals srs.Id
 311:                                        where s.ServiceType == Ia.Ngn.Cl.Model.Business.Service.ServiceType.GponService &&
 312:                                        // below: exclude huawei from barring and service suspension operations
 313:                                        (
 314:                                        srs.CallBarring == false && srs.ServiceSuspension == false && s.ServiceSuspension == true
 315:                                        || srs.CallBarring == true && srs.ServiceSuspension == false && s.ServiceSuspension == false
 316:                                        || srs.CallBarring == false && srs.ServiceSuspension == true && s.ServiceSuspension == false
 317:                                        || srs.CallBarring == true && srs.ServiceSuspension == true && s.ServiceSuspension == false
 318:                                        )
 319:                                        select new { s.Id, Service = s.Service }).ToList();
 320:   
 321:                  serviceIdList = (from s in serviceId0List where !Ia.Ngn.Cl.Model.Data.Service.HuaweiSwitchDomainList.Any(u => s.Service.StartsWith(u.ToString())) select s.Id).ToList();
 322:              }
 323:   
 324:              // Testing
 325:              // exclude all Huawei and MSFT numbers
 326:              foreach (string serviceId in serviceIdList)
 327:              {
 328:                  service = Ia.Ngn.Cl.Model.Business.Service2.ServiceIdToService(serviceId);
 329:   
 330:                  if (Ia.Ngn.Cl.Model.Business.Service.NumberIsWithinAllowedHuaweiSwitchDomainList(service)) serviceIdList.Remove(service);
 331:                  else if ("2537".StartsWith(service) || "2538".StartsWith(service)) serviceIdList.Remove(service);
 332:              }
 333:   
 334:              // will exclude exempt numbers
 335:              serviceIdExemptionList = ServiceIdOfServiceExemptFromProvisionProcessingList();
 336:              foreach (string s in serviceIdExemptionList) serviceIdList.Remove(s);
 337:   
 338:              return serviceIdList;
 339:          }
 340:   
 341:          ////////////////////////////////////////////////////////////////////////////
 342:   
 343:          /// <summary>
 344:          ///
 345:          /// </summary>
 346:          private static Dictionary<string, string> ComplementaryServiceMismatchBetweenProvisionedServiceRequestServiceAndServiceServiceIdAccessIdList(DateTime backDateTime)
 347:          {
 348:              Dictionary<string, string> serviceIdAccessIdDictionary, serviceIdAccessIdWithNonNullAccessDictionary;
 349:   
 350:              var allowedOltToBeProvisionedIdList = Ia.Ngn.Cl.Model.Data.Service.AllowedToBeProvisionedOltIdList;
 351:   
 352:              using (var db = new Ia.Ngn.Cl.Model.Ngn())
 353:              {
 354:                  var servicePbxList = Ia.Ngn.Cl.Model.Data.Service.ServicePbxList;
 355:                  var huaweiSwitchDomainList = Ia.Ngn.Cl.Model.Data.Service.HuaweiSwitchDomainList.ConvertAll<string>(u => u.ToString());
 356:   
 357:                  // below: Service different from ServiceRequestService
 358:                  serviceIdAccessIdWithNonNullAccessDictionary = (from s in db.Service2
 359:                                                                  join srs in db.ServiceRequestServices on s.Id equals srs.Id
 360:                                                                  where s.ServiceType == Ia.Ngn.Cl.Model.Business.Service.ServiceType.GponService
 361:                                                                  && srs.Provisioned == true
 362:                                                                  && srs.LastRequestDateTime >= backDateTime
 363:                                                                  && s.Access != null && allowedOltToBeProvisionedIdList.Contains(s.Access.Olt)
 364:                                                                  //&& srs.Access != null && allowedOltToBeProvisionedIdList.Contains(s.Access.Olt)
 365:                                                                  &&
 366:                                                                  (
 367:                                                                      s.AbbriviatedCalling != srs.AbbriviatedCalling
 368:                                                                      || s.AlarmCall != srs.AlarmCall
 369:                                                                      || s.WakeupCall != srs.WakeupCall
 370:                                                                      || s.CallerId != srs.CallerId
 371:                                                                      || s.CallForwarding != srs.CallForwarding
 372:                                                                      || s.ConferenceCall != srs.ConferenceCall
 373:                                                                      || s.InternationalCallingUserControlled != srs.InternationalCallingUserControlled
 374:                                                                      || s.InternationalCalling != srs.InternationalCalling
 375:                                                                      || s.SpeedDial != srs.SpeedDial
 376:   
 377:                                                                      // below: exclude PBX numbers from the Call Waiting service requirement
 378:                                                                      || !servicePbxList.Contains(srs.Service) && s.CallWaiting != srs.CallWaiting
 379:   
 380:                                                                  /*
 381:                                                                  // below: exclude huawei from barring and service suspension operations
 382:                                                                  //|| !huaweiSwitchDomainList.Any(u => srs.Service.StartsWith(u.ToString()))
 383:                                                                  || !huaweiSwitchDomainList.Contains(srs.Service.Substring(0, 4)) && !huaweiSwitchDomainList.Contains(srs.Service.Substring(0, 5))
 384:                                                                  &&
 385:                                                                  (
 386:                                                                      srs.CallBarring == false && srs.ServiceSuspension == false && s.ServiceSuspension == true
 387:                                                                      || srs.CallBarring == true && srs.ServiceSuspension == false && s.ServiceSuspension == false
 388:                                                                      || srs.CallBarring == false && srs.ServiceSuspension == true && s.ServiceSuspension == false
 389:                                                                      || srs.CallBarring == true && srs.ServiceSuspension == true && s.ServiceSuspension == false
 390:                                                                  )
 391:                                                                  */
 392:   
 393:                                                                  // below: check for numbers in which srs.Access != s.Access when s.Access != null
 394:                                                                  //|| (s.Access != null && s.Access.Id != srs.Access.Id) // not appropriate to compare s.Access and srs.Access here
 395:                                                                  )
 396:                                                                  select new { s.Id, AccessId = s.Access.Id }).ToDictionary(n => n.Id, n => n.AccessId);
 397:                  //select new { Id = s.Id, AccessId = srs.Access.Id }).ToDictionary(n => n.Id, n => n.AccessId);
 398:   
 399:                  serviceIdAccessIdDictionary = serviceIdAccessIdWithNonNullAccessDictionary;
 400:              }
 401:   
 402:              return serviceIdAccessIdDictionary;
 403:          }
 404:   
 405:          ////////////////////////////////////////////////////////////////////////////
 406:   
 407:          /// <summary>
 408:          ///
 409:          /// </summary>
 410:          public static SortedList ProvisionedServiceRequestServiceAndServiceMismatchAccessServiceIdList()
 411:          {
 412:              SortedList serviceRequestServiceAndServiceMismatchAccessServiceIdList;
 413:              Dictionary<string, int> srsIdDictionary, sIdDictionary;
 414:   
 415:              using (var db = new Ia.Ngn.Cl.Model.Ngn())
 416:              {
 417:                  // below: ServiceRequestService dictionary
 418:                  srsIdDictionary = (from srs in db.ServiceRequestServices
 419:                                     join s in db.Service2 on srs.Id equals s.Id
 420:                                     where s.ServiceType == Ia.Ngn.Cl.Model.Business.Service.ServiceType.GponService && srs.Provisioned == true && srs.Access != null && s.Access != null && srs.Access.Id != s.Access.Id
 421:                                     select srs.Id).ToDictionary(n => n, n => 1);
 422:   
 423:                  // below: Service dictionary
 424:                  sIdDictionary = (from s in db.Service2
 425:                                   join srs in db.ServiceRequestServices on s.Id equals srs.Id
 426:                                   where s.ServiceType == Ia.Ngn.Cl.Model.Business.Service.ServiceType.GponService && srs.Provisioned == true && s.Access != null && srs.Access != null && s.Access.Id != srs.Access.Id
 427:                                   select s.Id).ToDictionary(n => n, n => 1);
 428:              }
 429:   
 430:              serviceRequestServiceAndServiceMismatchAccessServiceIdList = new SortedList(srsIdDictionary.Count + sIdDictionary.Count);
 431:   
 432:              foreach (KeyValuePair<string, int> kvp in srsIdDictionary)
 433:                  if (!serviceRequestServiceAndServiceMismatchAccessServiceIdList.ContainsKey(kvp.Key))
 434:                      serviceRequestServiceAndServiceMismatchAccessServiceIdList.Add(kvp.Key, 1);
 435:   
 436:              foreach (KeyValuePair<string, int> kvp in sIdDictionary)
 437:                  if (!serviceRequestServiceAndServiceMismatchAccessServiceIdList.ContainsKey(kvp.Key))
 438:                      serviceRequestServiceAndServiceMismatchAccessServiceIdList.Add(kvp.Key, 1);
 439:   
 440:              return serviceRequestServiceAndServiceMismatchAccessServiceIdList;
 441:          }
 442:   
 443:          ////////////////////////////////////////////////////////////////////////////
 444:   
 445:          /// <summary>
 446:          ///
 447:          /// </summary>
 448:          public static void ServiceToUpdateServiceIdAccessIdDictionary_ServiceToCreateServiceIdAccessIdDictionary_ServiceToDeleteServiceIdAccessIdDictionary(out Dictionary<string, string> serviceToUpdateServiceIdAccessIdDictionary, out Dictionary<string, string> serviceToCreateServiceIdAccessIdDictionary, out Dictionary<string, string> serviceToDeleteServiceIdAccessIdDictionary)
 449:          {
 450:              ServiceToUpdateServiceIdAccessIdDictionary_ServiceToCreateServiceIdAccessIdDictionary_ServiceToDeleteServiceIdAccessIdDictionary(0, out serviceToUpdateServiceIdAccessIdDictionary, out serviceToCreateServiceIdAccessIdDictionary, out serviceToDeleteServiceIdAccessIdDictionary);
 451:          }
 452:   
 453:          ////////////////////////////////////////////////////////////////////////////
 454:   
 455:          /// <summary>
 456:          ///
 457:          /// </summary>
 458:          public static void ServiceToUpdateServiceIdAccessIdDictionary_ServiceToCreateServiceIdAccessIdDictionary_ServiceToDeleteServiceIdAccessIdDictionary(int provisionWithinLastNDays, out Dictionary<string, string> serviceToUpdateServiceIdAccessIdDictionary, out Dictionary<string, string> serviceToCreateServiceIdAccessIdDictionary, out Dictionary<string, string> serviceToDeleteServiceIdAccessIdDictionary)
 459:          {
 460:              DateTime dateTime;
 461:              List<int> allowedOltToBeProvisionedIdList;
 462:              List<string> serviceIdExemptionList, serviceIdNullAccessList;
 463:              Dictionary<string, string> mismatchServiceIdAccessIdDictionary, serviceRequestServiceProvisionedServiceIdAccessIdDictionary, serviceRequestServiceRemovedServiceIdAccessIdDictionary, serviceIdAccessIdDictionary;
 464:   
 465:              dateTime = (provisionWithinLastNDays > 0) ? DateTime.UtcNow.AddHours(3).AddDays(-provisionWithinLastNDays) : Ia.Ngn.Cl.Model.Business.Administration.EarliestRequestDateTime;
 466:   
 467:              allowedOltToBeProvisionedIdList = Ia.Ngn.Cl.Model.Data.Service.AllowedToBeProvisionedOltIdList;
 468:   
 469:              using (var db = new Ia.Ngn.Cl.Model.Ngn())
 470:              {
 471:                  // below: ServiceRequestService dictionary
 472:                  serviceRequestServiceProvisionedServiceIdAccessIdDictionary = (from srs in db.ServiceRequestServices
 473:                                                                                 where srs.Provisioned == true && srs.LastRequestDateTime >= dateTime
 474:                                                                                 && srs.Access != null && allowedOltToBeProvisionedIdList.Contains(srs.Access.Olt)
 475:                                                                                 select new { srs.Id, AccessId = srs.Access.Id }).ToDictionary(n => n.Id, n => n.AccessId);
 476:   
 477:                  serviceRequestServiceRemovedServiceIdAccessIdDictionary = (from srs in db.ServiceRequestServices
 478:                                                                             where srs.Provisioned == false && srs.LastRequestDateTime >= dateTime
 479:                                                                             /*&& srs.Access != null && allowedOltToBeProvisionedIdList.Contains(srs.Access.Olt)*/
 480:                                                                             select new { srs.Id, AccessId = srs.Access.Id }).ToDictionary(n => n.Id, n => n.AccessId);
 481:   
 482:                  // below: Service dictionary with non-null access
 483:                  serviceIdAccessIdDictionary = (from s in db.Service2
 484:                                                 where s.ServiceType == Ia.Ngn.Cl.Model.Business.Service.ServiceType.GponService && s.Access != null && allowedOltToBeProvisionedIdList.Contains(s.Access.Olt)
 485:                                                 select new { s.Id, AccessId = s.Access.Id }).ToDictionary(n => n.Id, n => n.AccessId);
 486:   
 487:                  serviceIdNullAccessList = (from s in db.Service2
 488:                                             where s.ServiceType == Ia.Ngn.Cl.Model.Business.Service.ServiceType.GponService && s.Access == null
 489:                                             select s.Id).ToList();
 490:              }
 491:   
 492:              // services to provision (ServiceRequestService.Provisioned = true and not in Service list)
 493:              serviceToCreateServiceIdAccessIdDictionary = new Dictionary<string, string>(serviceRequestServiceProvisionedServiceIdAccessIdDictionary.Count);
 494:              foreach (KeyValuePair<string, string> kvp in serviceRequestServiceProvisionedServiceIdAccessIdDictionary)
 495:              {
 496:                  if (!serviceIdAccessIdDictionary.ContainsKey(kvp.Key))
 497:                  {
 498:                      if (!serviceIdNullAccessList.Contains(kvp.Key))
 499:                      {
 500:                          serviceToCreateServiceIdAccessIdDictionary.Add(kvp.Key, kvp.Value);
 501:                      }
 502:                  }
 503:              }
 504:   
 505:              // services to remove (Service has equivalent ServiceRequestService.Provisioned = false)
 506:              serviceToDeleteServiceIdAccessIdDictionary = new Dictionary<string, string>(serviceRequestServiceRemovedServiceIdAccessIdDictionary.Count);
 507:              foreach (KeyValuePair<string, string> kvp in serviceIdAccessIdDictionary)
 508:              {
 509:                  if (serviceRequestServiceRemovedServiceIdAccessIdDictionary.ContainsKey(kvp.Key))
 510:                  {
 511:                      serviceToDeleteServiceIdAccessIdDictionary.Add(kvp.Key, kvp.Value);
 512:                  }
 513:              }
 514:   
 515:   
 516:              mismatchServiceIdAccessIdDictionary = Ia.Ngn.Cl.Model.Data.Provision.ComplementaryServiceMismatchBetweenProvisionedServiceRequestServiceAndServiceServiceIdAccessIdList(dateTime);
 517:   
 518:              // services to update
 519:              serviceToUpdateServiceIdAccessIdDictionary = new Dictionary<string, string>(mismatchServiceIdAccessIdDictionary.Count);
 520:              foreach (KeyValuePair<string, string> kvp in mismatchServiceIdAccessIdDictionary)
 521:              {
 522:                  serviceToUpdateServiceIdAccessIdDictionary.Add(kvp.Key, kvp.Value);
 523:              }
 524:   
 525:              // 3. Update list (order is important behind create and delete lists)
 526:              foreach (KeyValuePair<string, string> kvp in mismatchServiceIdAccessIdDictionary)
 527:              {
 528:                  // I will exclude all numbers from complementary list that are in either serviceToProvision list or serviceToRemove list
 529:                  if (serviceToCreateServiceIdAccessIdDictionary.ContainsKey(kvp.Key) || serviceToDeleteServiceIdAccessIdDictionary.ContainsKey(kvp.Key))
 530:                  {
 531:                      serviceToUpdateServiceIdAccessIdDictionary.Remove(kvp.Key);
 532:                  }
 533:              }
 534:   
 535:              // will exclude exempt numbers
 536:              serviceIdExemptionList = ServiceIdOfServiceExemptFromProvisionProcessingList();
 537:              foreach (string s in serviceIdExemptionList)
 538:              {
 539:                  serviceToUpdateServiceIdAccessIdDictionary.Remove(s);
 540:                  serviceToCreateServiceIdAccessIdDictionary.Remove(s);
 541:                  serviceToDeleteServiceIdAccessIdDictionary.Remove(s);
 542:              }
 543:          }
 544:   
 545:          ////////////////////////////////////////////////////////////////////////////
 546:   
 547:          /// <summary>
 548:          /// List of exempt number ids
 549:          /// </summary>
 550:          public static List<string> ServiceIdOfServiceExemptFromProvisionProcessingList()
 551:          {
 552:              List<string> list;
 553:   
 554:              list = new List<string>();
 555:   
 556:              foreach (string u in Ia.Ngn.Cl.Model.Data.ServiceExemption.ServiceIdList()) list.Add(u);
 557:   
 558:              return list;
 559:          }
 560:   
 561:          ////////////////////////////////////////////////////////////////////////////
 562:   
 563:          /// <summary>
 564:          /// List of exempt services
 565:          /// </summary>
 566:          public static List<string> ServiceOfServiceExemptFromProvisionProcessingList()
 567:          {
 568:              List<string> list;
 569:   
 570:              list = new List<string>();
 571:   
 572:              foreach (string u in Ia.Ngn.Cl.Model.Data.ServiceExemption.ServiceList()) list.Add(u);
 573:   
 574:              return list;
 575:          }
 576:   
 577:          ////////////////////////////////////////////////////////////////////////////
 578:          ////////////////////////////////////////////////////////////////////////////    
 579:      }
 580:   
 581:      ////////////////////////////////////////////////////////////////////////////
 582:      ////////////////////////////////////////////////////////////////////////////   
 583:  }