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

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:                  serviceIdList = (from s in db.Service2s
 289:                                   join srs in db.ServiceRequestServices on s.Id equals srs.Id
 290:                                   where s.ServiceType == Ia.Ngn.Cl.Model.Business.Service.ServiceType.GponService &&
 291:   
 292:                                   // below: include only allowed domains that are allowed for provisioning
 293:                                   //Ia.Ngn.Cl.Model.Data.Service.ProvisioningEnabledFourDigitNumberDomainList.Any(u => srs.Service.StartsWith(u.ToString()))
 294:                                   //&& srs.Provisioned == true
 295:                                   //&&
 296:   
 297:                                   // below: exclude huawei from barring and service suspension operations
 298:                                   !Ia.Ngn.Cl.Model.Data.Service.HuaweiSwitchDomainList.Any(u => srs.Service.StartsWith(u.ToString())) &&
 299:                                   (
 300:                                   srs.CallBarring == false && srs.ServiceSuspension == false && s.ServiceSuspension == true
 301:                                   || srs.CallBarring == true && srs.ServiceSuspension == false && s.ServiceSuspension == false
 302:                                   || srs.CallBarring == false && srs.ServiceSuspension == true && s.ServiceSuspension == false
 303:                                   || srs.CallBarring == true && srs.ServiceSuspension == true && s.ServiceSuspension == false
 304:                                   )
 305:                                   select s.Id).ToList();
 306:              }
 307:   
 308:              // Testing
 309:              // exclude all Huawei and MSFT numbers
 310:              foreach (string serviceId in serviceIdList)
 311:              {
 312:                  service = Ia.Ngn.Cl.Model.Business.Service2.ServiceIdToService(serviceId);
 313:   
 314:                  if (Ia.Ngn.Cl.Model.Business.Service.NumberIsWithinAllowedHuaweiSwitchDomainList(service)) serviceIdList.Remove(service);
 315:                  else if ("2537".StartsWith(service) || "2538".StartsWith(service)) serviceIdList.Remove(service);
 316:              }
 317:   
 318:              // will exclude exempt numbers
 319:              serviceIdExemptionList = ServiceIdOfServiceExemptFromProvisionProcessingList();
 320:              foreach (string s in serviceIdExemptionList) serviceIdList.Remove(s);
 321:   
 322:              return serviceIdList;
 323:          }
 324:   
 325:          ////////////////////////////////////////////////////////////////////////////
 326:   
 327:          /// <summary>
 328:          ///
 329:          /// </summary>
 330:          private static Dictionary<string, string> ComplementaryServiceMismatchBetweenProvisionedServiceRequestServiceAndServiceServiceIdList(DateTime backDateTime)
 331:          {
 332:              List<string> servicePbxList;
 333:              List<int> allowedOltToBeProvisionedIdList;
 334:              Dictionary<string, string> serviceIdAccessIdDictionary, serviceIdAccessIdWithNonNullAccessDictionary;
 335:   
 336:              allowedOltToBeProvisionedIdList = Ia.Ngn.Cl.Model.Data.Service.AllowedToBeProvisionedOltIdList;
 337:   
 338:              using (var db = new Ia.Ngn.Cl.Model.Ngn())
 339:              {
 340:                  servicePbxList = Ia.Ngn.Cl.Model.Data.Service.ServicePbxList;
 341:   
 342:                  // below: Service different from ServiceRequestService
 343:                  serviceIdAccessIdWithNonNullAccessDictionary = (from s in db.Service2s
 344:                                                                  join srs in db.ServiceRequestServices on s.Id equals srs.Id
 345:                                                                  where s.ServiceType == Ia.Ngn.Cl.Model.Business.Service.ServiceType.GponService
 346:                                                                  && srs.Provisioned == true
 347:                                                                  && srs.LastRequestDateTime >= backDateTime
 348:                                                                  && srs.Access != null && allowedOltToBeProvisionedIdList.Contains(s.Access.Olt)
 349:                                                                  && (s.AbbriviatedCalling != srs.AbbriviatedCalling
 350:                                                                  || s.AlarmCall != srs.AlarmCall
 351:                                                                  || s.WakeupCall != srs.WakeupCall
 352:   
 353:                                                                  // below: exclude huawei from barring and service suspension operations
 354:                                                                  || !Ia.Ngn.Cl.Model.Data.Service.HuaweiSwitchDomainList.Any(u => srs.Service.StartsWith(u.ToString()))
 355:                                                                  &&
 356:                                                                  (
 357:                                                                  srs.CallBarring == false && srs.ServiceSuspension == false && s.ServiceSuspension == true
 358:                                                                  || srs.CallBarring == true && srs.ServiceSuspension == false && s.ServiceSuspension == false
 359:                                                                  || srs.CallBarring == false && srs.ServiceSuspension == true && s.ServiceSuspension == false
 360:                                                                  || srs.CallBarring == true && srs.ServiceSuspension == true && s.ServiceSuspension == false
 361:                                                                  )
 362:   
 363:                                                                  || s.CallerId != srs.CallerId
 364:                                                                  || s.CallForwarding != srs.CallForwarding
 365:   
 366:                                                                  // below: exclude PBX numbers from the Call Waiting service requirement
 367:                                                                  || !servicePbxList.Contains(srs.Service) && s.CallWaiting != srs.CallWaiting
 368:   
 369:                                                                  || s.ConferenceCall != srs.ConferenceCall
 370:                                                                  || s.InternationalCallingUserControlled != srs.InternationalCallingUserControlled
 371:   
 372:                                                                  // below: exclude huawei from international calling
 373:                                                                  || /*!Ia.Ngn.Cl.Model.Data.Service.HuaweiSwitchDomainList.Any(u => srs.Service.StartsWith(u.ToString())) &&*/ s.InternationalCalling != srs.InternationalCalling
 374:   
 375:                                                                  || s.SpeedDial != srs.SpeedDial
 376:   
 377:                                                                  // below: check for numbers in which srs.Access != s.Access when s.Access != null
 378:                                                                  || (s.Access != null && s.Access.Id != srs.Access.Id)
 379:                                                                  )
 380:                                                                  select new { Id = s.Id, AccessId = srs.Access.Id }).ToDictionary(n => n.Id, n => n.AccessId);
 381:   
 382:                  serviceIdAccessIdDictionary = serviceIdAccessIdWithNonNullAccessDictionary;
 383:              }
 384:   
 385:              return serviceIdAccessIdDictionary;
 386:          }
 387:   
 388:          ////////////////////////////////////////////////////////////////////////////
 389:   
 390:          /// <summary>
 391:          ///
 392:          /// </summary>
 393:          public static SortedList ProvisionedServiceRequestServiceAndServiceMismatchAccessServiceIdList()
 394:          {
 395:              SortedList serviceRequestServiceAndServiceMismatchAccessServiceIdList;
 396:              Dictionary<string, int> srsIdDictionary, sIdDictionary;
 397:   
 398:              using (var db = new Ia.Ngn.Cl.Model.Ngn())
 399:              {
 400:                  // below: ServiceRequestService dictionary
 401:                  srsIdDictionary = (from srs in db.ServiceRequestServices
 402:                                     join s in db.Service2s on srs.Id equals s.Id
 403:                                     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
 404:                                     select srs.Id).ToDictionary(n => n, n => 1);
 405:   
 406:                  // below: Service dictionary
 407:                  sIdDictionary = (from s in db.Service2s
 408:                                   join srs in db.ServiceRequestServices on s.Id equals srs.Id
 409:                                   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
 410:                                   select s.Id).ToDictionary(n => n, n => 1);
 411:              }
 412:   
 413:              serviceRequestServiceAndServiceMismatchAccessServiceIdList = new SortedList(srsIdDictionary.Count + sIdDictionary.Count);
 414:   
 415:              foreach (KeyValuePair<string, int> kvp in srsIdDictionary)
 416:                  if (!serviceRequestServiceAndServiceMismatchAccessServiceIdList.ContainsKey(kvp.Key))
 417:                      serviceRequestServiceAndServiceMismatchAccessServiceIdList.Add(kvp.Key, 1);
 418:   
 419:              foreach (KeyValuePair<string, int> kvp in sIdDictionary)
 420:                  if (!serviceRequestServiceAndServiceMismatchAccessServiceIdList.ContainsKey(kvp.Key))
 421:                      serviceRequestServiceAndServiceMismatchAccessServiceIdList.Add(kvp.Key, 1);
 422:   
 423:              return serviceRequestServiceAndServiceMismatchAccessServiceIdList;
 424:          }
 425:   
 426:          ////////////////////////////////////////////////////////////////////////////
 427:   
 428:          /// <summary>
 429:          ///
 430:          /// </summary>
 431:          public static void ServiceToUpdateServiceIdAccessIdDictionary_ServiceToCreateServiceIdAccessIdDictionary_ServiceToDeleteServiceIdAccessIdDictionary(out Dictionary<string, string> serviceToUpdateIdAccessIdDictionary, out Dictionary<string, string> serviceToCreateServiceIdAccessIdDictionary, out Dictionary<string, string> serviceToDeleteServiceIdAccessIdDictionary)
 432:          {
 433:              ServiceToUpdateServiceIdAccessIdDictionary_ServiceToCreateServiceIdAccessIdDictionary_ServiceToDeleteServiceIdAccessIdDictionary(0, out serviceToUpdateIdAccessIdDictionary, out serviceToCreateServiceIdAccessIdDictionary, out serviceToDeleteServiceIdAccessIdDictionary);
 434:          }
 435:   
 436:          ////////////////////////////////////////////////////////////////////////////
 437:   
 438:          /// <summary>
 439:          ///
 440:          /// </summary>
 441:          public static void ServiceToUpdateServiceIdAccessIdDictionary_ServiceToCreateServiceIdAccessIdDictionary_ServiceToDeleteServiceIdAccessIdDictionary(int provisionWithinLastNDays, out Dictionary<string, string> serviceToUpdateIdAccessIdDictionary, out Dictionary<string, string> serviceToCreateServiceIdAccessIdDictionary, out Dictionary<string, string> serviceToDeleteServiceIdAccessIdDictionary)
 442:          {
 443:              DateTime dateTime;
 444:              List<int> allowedOltToBeProvisionedIdList;
 445:              List<string> serviceIdExemptionList;
 446:              Dictionary<string, string> mismatchIdDictionary, serviceRequestServiceProvisionedIdDictionary, serviceRequestServiceRemovedIdDictionary, serviceIdDictionary;
 447:   
 448:              dateTime = (provisionWithinLastNDays > 0) ? DateTime.UtcNow.AddHours(3).AddDays(-provisionWithinLastNDays) : Ia.Ngn.Cl.Model.Business.Administration.EarliestRequestDateTime;
 449:   
 450:              allowedOltToBeProvisionedIdList = Ia.Ngn.Cl.Model.Data.Service.AllowedToBeProvisionedOltIdList;
 451:   
 452:              using (var db = new Ia.Ngn.Cl.Model.Ngn())
 453:              {
 454:                  // below: ServiceRequestService dictionary
 455:                  serviceRequestServiceProvisionedIdDictionary = (from srs in db.ServiceRequestServices
 456:                                                                  where srs.Provisioned == true && srs.LastRequestDateTime >= dateTime
 457:                                                                  && srs.Access != null && allowedOltToBeProvisionedIdList.Contains(srs.Access.Olt)
 458:                                                                  select new { srs.Id, AccessId = srs.Access.Id }).ToDictionary(n => n.Id, n => n.AccessId);
 459:   
 460:                  serviceRequestServiceRemovedIdDictionary = (from srs in db.ServiceRequestServices
 461:                                                              where srs.Provisioned == false && srs.LastRequestDateTime >= dateTime
 462:                                                              && srs.Access != null && allowedOltToBeProvisionedIdList.Contains(srs.Access.Olt)
 463:                                                              select new { srs.Id, AccessId = srs.Access.Id }).ToDictionary(n => n.Id, n => n.AccessId);
 464:   
 465:                  // below: Service dictionary
 466:                  serviceIdDictionary = (from s in db.Service2s
 467:                                         where s.ServiceType == Ia.Ngn.Cl.Model.Business.Service.ServiceType.GponService && s.Access != null && allowedOltToBeProvisionedIdList.Contains(s.Access.Olt)
 468:                                         select new { s.Id, AccessId = s.Access.Id }).ToDictionary(n => n.Id, n => n.AccessId);
 469:              }
 470:   
 471:              // services to provision (ServiceRequestService.Provisioned = true and not in Service list)
 472:              serviceToCreateServiceIdAccessIdDictionary = new Dictionary<string, string>(serviceRequestServiceProvisionedIdDictionary.Count);
 473:              foreach (KeyValuePair<string, string> kvp in serviceRequestServiceProvisionedIdDictionary)
 474:              {
 475:                  if (!serviceIdDictionary.ContainsKey(kvp.Key)) serviceToCreateServiceIdAccessIdDictionary.Add(kvp.Key, kvp.Value);
 476:              }
 477:   
 478:              // services to remove (Service has equivalent ServiceRequestService.Provisioned = false)
 479:              serviceToDeleteServiceIdAccessIdDictionary = new Dictionary<string, string>(serviceRequestServiceRemovedIdDictionary.Count);
 480:              foreach (KeyValuePair<string, string> kvp in serviceIdDictionary)
 481:              {
 482:                  if (serviceRequestServiceRemovedIdDictionary.ContainsKey(kvp.Key)) serviceToDeleteServiceIdAccessIdDictionary.Add(kvp.Key, kvp.Value);
 483:              }
 484:   
 485:   
 486:              mismatchIdDictionary = Ia.Ngn.Cl.Model.Data.Provision.ComplementaryServiceMismatchBetweenProvisionedServiceRequestServiceAndServiceServiceIdList(dateTime);
 487:   
 488:              // services to update
 489:              serviceToUpdateIdAccessIdDictionary = new Dictionary<string, string>(mismatchIdDictionary.Count);
 490:              foreach (KeyValuePair<string, string> kvp in mismatchIdDictionary)
 491:              {
 492:                  serviceToUpdateIdAccessIdDictionary.Add(kvp.Key, kvp.Value);
 493:              }
 494:   
 495:              // 3. Update list (order is important behind create and delete lists)
 496:              foreach (KeyValuePair<string, string> kvp in mismatchIdDictionary)
 497:              {
 498:                  // I will exclude all numbers from complementary list that are in either serviceToProvision list or serviceToRemove list
 499:                  if (serviceToCreateServiceIdAccessIdDictionary.ContainsKey(kvp.Key) || serviceToDeleteServiceIdAccessIdDictionary.ContainsKey(kvp.Key))
 500:                  {
 501:                      serviceToUpdateIdAccessIdDictionary.Remove(kvp.Key);
 502:                  }
 503:              }
 504:   
 505:   
 506:              // will exclude exempt numbers
 507:              serviceIdExemptionList = ServiceIdOfServiceExemptFromProvisionProcessingList();
 508:              foreach (string s in serviceIdExemptionList)
 509:              {
 510:                  serviceToUpdateIdAccessIdDictionary.Remove(s);
 511:                  serviceToCreateServiceIdAccessIdDictionary.Remove(s);
 512:                  serviceToDeleteServiceIdAccessIdDictionary.Remove(s);
 513:              }
 514:          }
 515:   
 516:          ////////////////////////////////////////////////////////////////////////////
 517:   
 518:          /// <summary>
 519:          /// List of exempt number ids
 520:          /// </summary>
 521:          public static List<string> ServiceIdOfServiceExemptFromProvisionProcessingList()
 522:          {
 523:              List<string> list;
 524:   
 525:              list = new List<string>();
 526:   
 527:              foreach (string u in Ia.Ngn.Cl.Model.Data.ServiceExemption.ServiceIdList()) list.Add(u);
 528:   
 529:              return list;
 530:          }
 531:   
 532:          ////////////////////////////////////////////////////////////////////////////
 533:   
 534:          /// <summary>
 535:          /// List of exempt services
 536:          /// </summary>
 537:          public static List<string> ServiceOfServiceExemptFromProvisionProcessingList()
 538:          {
 539:              List<string> list;
 540:   
 541:              list = new List<string>();
 542:   
 543:              foreach (string u in Ia.Ngn.Cl.Model.Data.ServiceExemption.ServiceList()) list.Add(u);
 544:   
 545:              return list;
 546:          }
 547:   
 548:          ////////////////////////////////////////////////////////////////////////////
 549:          ////////////////////////////////////////////////////////////////////////////    
 550:      }
 551:   
 552:      ////////////////////////////////////////////////////////////////////////////
 553:      ////////////////////////////////////////////////////////////////////////////   
 554:  }