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

Integrated Applications Programming Company

Skip Navigation LinksHome » Code Library » ServiceRequest

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

Service Request support class of Next Generation Network'a (NGN's) business model.

   1:  using System;
   2:  using System.Collections.Generic;
   3:  using System.Linq;
   4:  using System.Text.RegularExpressions;
   5:  using System.Data;
   6:  using System.Globalization;
   7:   
   8:  namespace Ia.Ngn.Cl.Model.Business
   9:  {
  10:      ////////////////////////////////////////////////////////////////////////////
  11:   
  12:      /// <summary publish="true">
  13:      /// Service Request support class of Next Generation Network'a (NGN's) business model.
  14:      /// </summary>
  15:      /// 
  16:      /// <remarks> 
  17:      /// Copyright © 2006-2019 Jasem Y. Al-Shamlan (info@ia.com.kw), Internet Applications - Kuwait. All Rights Reserved.
  18:      ///
  19:      /// 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
  20:      /// the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
  21:      ///
  22:      /// This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
  23:      /// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
  24:      /// 
  25:      /// You should have received a copy of the GNU General Public License along with this library. If not, see http://www.gnu.org/licenses.
  26:      /// 
  27:      /// Copyright notice: This notice may not be removed or altered from any source distribution.
  28:      /// </remarks> 
  29:      public partial class ServiceRequest
  30:      {
  31:          /// <summary/>
  32:          public ServiceRequest() { }
  33:   
  34:          private static int sequentialProvisioningWorkflowQueueOriginalCount;
  35:          private static Dictionary<string, DateTime> provisioningWorkflowServiceIdDateTimeDictionary = new Dictionary<string, DateTime>();
  36:          private static Queue<ProvisioningWorkflow<Ia.Ngn.Cl.Model.ServiceRequestOntDetail>> sequentialProvisioningWorkflowQueue = new Queue<ProvisioningWorkflow<Ia.Ngn.Cl.Model.ServiceRequestOntDetail>>();
  37:   
  38:          public const string ServiceRequestCustomerIdInputTypeString = "serviceRequestCustomerId";
  39:   
  40:          /// <summary/>
  41:          public enum Procedure { Create, Read, Update, Delete, None };
  42:   
  43:          /// <summary/>
  44:          public struct ProvisioningWorkflow<T>
  45:          {
  46:              /// <summary/>
  47:              public T Item { get; set; }
  48:   
  49:              /// <summary/>
  50:              public Procedure Procedure { get; set; }
  51:   
  52:              /// <summary/>
  53:              public DateTime DateTime { get; set; }
  54:          }
  55:   
  56:          ////////////////////////////////////////////////////////////////////////////    
  57:   
  58:          /// <summary>
  59:          ///
  60:          /// </summary>
  61:          public struct NumberSerial
  62:          {
  63:              public long Id
  64:              {
  65:                  get { return (long)Number * 100 + Serial; }
  66:              }
  67:              public int Number { get; set; }
  68:              public int Serial { get; set; }
  69:          }
  70:   
  71:          ////////////////////////////////////////////////////////////////////////////    
  72:          ////////////////////////////////////////////////////////////////////////////    
  73:   
  74:          /// <summary>
  75:          ///
  76:          /// </summary>
  77:          public static string OracleSqlCommandForServiceRequestIdRange(Tuple<int, int> startEndRange)
  78:          {
  79:              return OracleSqlCommandForServiceRequestIdRange(startEndRange.Item1, startEndRange.Item2);
  80:          }
  81:   
  82:          ////////////////////////////////////////////////////////////////////////////    
  83:   
  84:          /// <summary>
  85:          ///
  86:          /// </summary>
  87:          public static string OracleSqlCommandForServiceRequestIdRange(int start, int end)
  88:          {
  89:              string sql;
  90:   
  91:              // select * from SRV_REQ_FIPER where SRV_REQ_ID >= 110000 and SRV_REQ_ID <= 110200 order by SRV_REQ_ID asc
  92:              sql = @"select * from SRV_REQ_FIPER where SRV_REQ_ID >= " + start + " and SRV_REQ_ID <= " + end + " order by SRV_REQ_ID asc";
  93:   
  94:              return sql;
  95:          }
  96:   
  97:          ////////////////////////////////////////////////////////////////////////////    
  98:   
  99:          /// <summary>
 100:          ///
 101:          /// </summary>
 102:          public static string OracleSqlCommandForServiceRequest(string service)
 103:          {
 104:              string sql;
 105:   
 106:              if (!string.IsNullOrEmpty(service))
 107:              {
 108:                  // select * from SRV_REQ_FIPER where SRV_NO = 23632222 order by SRV_REQ_ID asc
 109:                  sql = @"select * from SRV_REQ_FIPER where SRV_NO = " + service + " order by SRV_REQ_ID asc";
 110:              }
 111:              else sql = string.Empty;
 112:   
 113:              return sql;
 114:          }
 115:   
 116:          ////////////////////////////////////////////////////////////////////////////    
 117:   
 118:          /// <summary>
 119:          ///
 120:          /// </summary>
 121:          private static string OracleSqlCommandForGivenDateTime(DateTime dateTime)
 122:          {
 123:              string sql;
 124:   
 125:              //sql = @"select * from SRV_REQ_FIPER LEFT OUTER JOIN SRV_REQ_FIPER_TECH ON SRV_REQ_FIPER_TECH.SRV_REQ_ID = SRV_REQ_FIPER.SRV_REQ_ID where REQ_DATE >= '" + dateTime.ToString("dd/MM/yyyy", CultureInfo.InvariantCulture) + "' and REQ_DATE < '" + dateTime.AddDays(1).ToString("dd/MM/yyyy", CultureInfo.InvariantCulture) + "' order by REQ_DATE asc, SRV_REQ_ID asc";
 126:              sql = @"select * from SRV_REQ_FIPER where REQ_DATE >= '" + dateTime.ToString("dd/MM/yyyy", CultureInfo.InvariantCulture) + "' and REQ_DATE < '" + dateTime.AddDays(1).ToString("dd/MM/yyyy", CultureInfo.InvariantCulture) + "' order by SRV_REQ_ID asc";
 127:   
 128:              return sql;
 129:          }
 130:   
 131:          ////////////////////////////////////////////////////////////////////////////    
 132:   
 133:          /// <summary>
 134:          ///
 135:          /// </summary>
 136:          private static string OracleSqlCommandForSingleRandomDateTimeWithinTheLastNDays(int rangeOfPastDays, out DateTime selectedDate)
 137:          {
 138:              // below:
 139:              int i;
 140:              string sql;
 141:   
 142:              i = Ia.Cl.Model.Default.Random(rangeOfPastDays);
 143:   
 144:              selectedDate = DateTime.UtcNow.AddDays(-i);
 145:   
 146:              sql = OracleSqlCommandForGivenDateTime(selectedDate);
 147:   
 148:              return sql;
 149:          }
 150:   
 151:          ////////////////////////////////////////////////////////////////////////////    
 152:   
 153:          /// <summary>
 154:          ///
 155:          /// </summary>
 156:          private static string OracleSqlCommandForSingleDateTimeUsingDayIndexBetweenNowAndEarliestDate(ref int index, out DateTime selectedDate)
 157:          {
 158:              // below: select a date between now and the earliest date using an variable index value
 159:              string sql;
 160:              DateTime now;
 161:   
 162:              now = DateTime.UtcNow.AddHours(3);
 163:   
 164:              // below: check that inIndex is an index of a day between earliest day and now, and reset it to 0 if it is bigger than now
 165:              if (DateTime.Compare(Ia.Ngn.Cl.Model.Business.Administration.EarliestServiceRequestDate.AddDays(index), now) < 0)
 166:              {
 167:                  // below: within range
 168:              }
 169:              else index = 0;
 170:   
 171:              selectedDate = Ia.Ngn.Cl.Model.Business.Administration.EarliestServiceRequestDate.AddDays(index++);
 172:   
 173:              sql = OracleSqlCommandForGivenDateTime(selectedDate);
 174:   
 175:              return sql;
 176:          }
 177:   
 178:          ////////////////////////////////////////////////////////////////////////////
 179:          ////////////////////////////////////////////////////////////////////////////
 180:   
 181:          /// <summary>
 182:          ///
 183:          /// </summary>
 184:          public static ProvisioningWorkflow<Ia.Ngn.Cl.Model.ServiceRequestOntDetail> SequentialProvisioningWorkflowOfOfServiceRequestOntDetailSyncWithCustomerDepartmentDatabaseListItem(out int sequentialProvisioningWorkflowQueueCount, out string progressCounterString)
 185:          {
 186:              ProvisioningWorkflow<Ia.Ngn.Cl.Model.ServiceRequestOntDetail> pw;
 187:              List<ProvisioningWorkflow<Ia.Ngn.Cl.Model.ServiceRequestOntDetail>> list;
 188:   
 189:              if (sequentialProvisioningWorkflowQueue.Count == 0)
 190:              {
 191:                  list = Ia.Ngn.Cl.Model.Business.ServiceRequest.ProvisioningWorkflowOfServiceRequestOntDetailSyncWithCustomerDepartmentDatabaseList;
 192:   
 193:                  sequentialProvisioningWorkflowQueue = new Queue<ProvisioningWorkflow<Ia.Ngn.Cl.Model.ServiceRequestOntDetail>>(list);
 194:   
 195:                  sequentialProvisioningWorkflowQueueOriginalCount = sequentialProvisioningWorkflowQueue.Count;
 196:              }
 197:   
 198:              if (sequentialProvisioningWorkflowQueue.Count > 0) pw = sequentialProvisioningWorkflowQueue.Dequeue();
 199:              else pw = new ProvisioningWorkflow<Ia.Ngn.Cl.Model.ServiceRequestOntDetail> { Item = null, Procedure = Procedure.None };
 200:   
 201:              progressCounterString = "(" + sequentialProvisioningWorkflowQueue.Count + "/" + sequentialProvisioningWorkflowQueueOriginalCount + ")";
 202:   
 203:              sequentialProvisioningWorkflowQueueCount = sequentialProvisioningWorkflowQueue.Count;
 204:   
 205:              return pw;
 206:          }
 207:   
 208:          ////////////////////////////////////////////////////////////////////////////
 209:   
 210:          /// <summary>
 211:          ///
 212:          /// </summary>
 213:          public static List<ProvisioningWorkflow<Ia.Ngn.Cl.Model.ServiceRequestOntDetail>> ProvisioningWorkflowOfServiceRequestOntDetailSyncWithCustomerDepartmentDatabaseList
 214:          {
 215:              get
 216:              {
 217:                  DateTime dateTime;
 218:                  ProvisioningWorkflow<Ia.Ngn.Cl.Model.ServiceRequestOntDetail> provisioningWorkflow;
 219:                  List<ProvisioningWorkflow<Ia.Ngn.Cl.Model.ServiceRequestOntDetail>> provisioningWorkflowList;
 220:   
 221:                  dateTime = DateTime.UtcNow.AddHours(3);
 222:   
 223:                  provisioningWorkflowList = new List<ProvisioningWorkflow<Ia.Ngn.Cl.Model.ServiceRequestOntDetail>>();
 224:   
 225:                  Ia.Ngn.Cl.Model.Data.ServiceRequestOntDetail.ServiceRequestOntDetailCreateAndDeleteList(out List<Model.ServiceRequestOntDetail> serviceRequestOntDetailCreateList, out List<Model.ServiceRequestOntDetail> serviceRequestOntDetailDeleteList);
 226:   
 227:                  foreach (Ia.Ngn.Cl.Model.ServiceRequestOntDetail srod in serviceRequestOntDetailCreateList)
 228:                  {
 229:                      provisioningWorkflow = new ProvisioningWorkflow<Ia.Ngn.Cl.Model.ServiceRequestOntDetail> { Item = srod, Procedure = Procedure.Create, DateTime = dateTime };
 230:                      provisioningWorkflowList.Add(provisioningWorkflow);
 231:   
 232:                      provisioningWorkflow = new ProvisioningWorkflow<Ia.Ngn.Cl.Model.ServiceRequestOntDetail> { Item = srod, Procedure = Procedure.Read, DateTime = dateTime };
 233:                      provisioningWorkflowList.Add(provisioningWorkflow);
 234:                  }
 235:   
 236:                  foreach (Ia.Ngn.Cl.Model.ServiceRequestOntDetail srod in serviceRequestOntDetailDeleteList)
 237:                  {
 238:                      provisioningWorkflow = new ProvisioningWorkflow<Ia.Ngn.Cl.Model.ServiceRequestOntDetail> { Item = srod, Procedure = Procedure.Delete, DateTime = dateTime };
 239:                      provisioningWorkflowList.Add(provisioningWorkflow);
 240:   
 241:                      provisioningWorkflow = new ProvisioningWorkflow<Ia.Ngn.Cl.Model.ServiceRequestOntDetail> { Item = srod, Procedure = Procedure.Read, DateTime = dateTime };
 242:                      provisioningWorkflowList.Add(provisioningWorkflow);
 243:                  }
 244:   
 245:                  return provisioningWorkflowList;
 246:              }
 247:          }
 248:   
 249:          ////////////////////////////////////////////////////////////////////////////
 250:          ////////////////////////////////////////////////////////////////////////////
 251:   
 252:          /// <summary>
 253:          ///
 254:          /// </summary>
 255:          public static Ia.Ngn.Cl.Model.Business.ServiceAddress StatisticalServiceAddress(string service, string customerAddress, out string level)
 256:          {
 257:              string provinceArea;
 258:              Match match;
 259:              Ia.Ngn.Cl.Model.Business.ServiceAddress serviceAddress;
 260:   
 261:              serviceAddress = new ServiceAddress
 262:              {
 263:                  Service = service
 264:              };
 265:   
 266:              if (customerAddress != null)
 267:              {
 268:                  customerAddress = Ia.Ngn.Cl.Model.Business.Default.CorrectCustomerAddress(customerAddress);
 269:   
 270:                  // below: special handeling needed here
 271:                  customerAddress = Ia.Ngn.Cl.Model.Business.Default.CorrectCustomerAddressMissingProvinceArea(service, customerAddress);
 272:   
 273:                  // ',قطعة 4 قسيمة 538,'
 274:                  // below:
 275:                  // (.+),قطعة
 276:                  // ? entries
 277:                  match = Regex.Match(customerAddress, @"^(.+),قطعة", RegexOptions.Singleline);
 278:   
 279:                  if (match.Success)
 280:                  {
 281:                      level = "1";
 282:   
 283:                      provinceArea = match.Groups[1].Value;
 284:                      serviceAddress.AreaId = (from a in Ia.Ngn.Cl.Model.Data.Service.KuwaitNgnAreaList where provinceArea == a.ServiceRequestAddressProvinceAreaName select a.Id).SingleOrDefault();
 285:                  }
 286:                  else
 287:                  {
 288:                      serviceAddress.AreaId = 0;
 289:                  }
 290:   
 291:                  // below:
 292:                  // الجهراء الجهراء المدينة,قطعة 79 شارع 5 جادة 5 قسيمة 17, منزل 17
 293:                  match = Regex.Match(customerAddress, @"^(.+),قطعة (.+) شارع (.+) جادة (.+) قسيمة (.+), منزل (.+)$", RegexOptions.Singleline);
 294:   
 295:                  if (match.Success)
 296:                  {
 297:                      level = "1-";
 298:   
 299:                      serviceAddress.Block = Ia.Ngn.Cl.Model.Business.Access.NormalizeBlockEntry(match.Groups[2].Value);
 300:                      serviceAddress.Street = match.Groups[3].Value;
 301:                      serviceAddress.Boulevard = match.Groups[4].Value;
 302:                      serviceAddress.PremisesOld = match.Groups[5].Value;
 303:                      serviceAddress.PremisesNew = match.Groups[6].Value;
 304:                  }
 305:                  else
 306:                  {
 307:                      level = "2";
 308:   
 309:                      // below:
 310:                      // الجهراء الجهراء المدينة,قطعة 79 شارع 5 قسيمة 17, منزل 17
 311:                      match = Regex.Match(customerAddress, @"^(.+),قطعة (.+) شارع (.+) قسيمة (.+), منزل (.+)$", RegexOptions.Singleline);
 312:   
 313:                      if (match.Success)
 314:                      {
 315:                          level = "2-";
 316:   
 317:                          serviceAddress.Block = Ia.Ngn.Cl.Model.Business.Access.NormalizeBlockEntry(match.Groups[2].Value);
 318:                          serviceAddress.Street = match.Groups[3].Value;
 319:                          serviceAddress.Boulevard = null;
 320:                          serviceAddress.PremisesOld = match.Groups[4].Value;
 321:                          serviceAddress.PremisesNew = match.Groups[5].Value;
 322:                      }
 323:                      else
 324:                      {
 325:                          level = "3";
 326:   
 327:                          // below:
 328:                          // الجهراء الجهراء المدينة,قطعة 79 شارع 5, منزل 17
 329:                          match = Regex.Match(customerAddress, @"^(.+),قطعة (.+) شارع (.+), منزل (.+)$", RegexOptions.Singleline);
 330:   
 331:                          if (match.Success)
 332:                          {
 333:                              level = "3-";
 334:   
 335:                              serviceAddress.Block = Ia.Ngn.Cl.Model.Business.Access.NormalizeBlockEntry(match.Groups[2].Value);
 336:                              serviceAddress.Street = match.Groups[3].Value;
 337:                              serviceAddress.Boulevard = null;
 338:                              serviceAddress.PremisesOld = null;
 339:                              serviceAddress.PremisesNew = match.Groups[4].Value;
 340:                          }
 341:                          else
 342:                          {
 343:                              level = "4";
 344:   
 345:                              // below:
 346:                              // الجهراء الجهراء المدينة,قطعة 79 شارع 5 قسيمة 17
 347:                              match = Regex.Match(customerAddress, @"^(.+),قطعة (.+) شارع (.+) قسيمة (.+),$", RegexOptions.Singleline);
 348:   
 349:                              if (match.Success)
 350:                              {
 351:                                  level = "4-";
 352:   
 353:                                  serviceAddress.Block = Ia.Ngn.Cl.Model.Business.Access.NormalizeBlockEntry(match.Groups[2].Value);
 354:                                  serviceAddress.Street = match.Groups[3].Value;
 355:                                  serviceAddress.Boulevard = null;
 356:                                  serviceAddress.PremisesOld = match.Groups[4].Value;
 357:                                  serviceAddress.PremisesNew = null;
 358:                              }
 359:                              else
 360:                              {
 361:                                  level = "5";
 362:   
 363:                                  // below:
 364:                                  // الجهراء الجهراء المدينة,قطعة 79 شارع 5 جادة 5
 365:                                  match = Regex.Match(customerAddress, @"^(.+),قطعة (.+) شارع (.+) جادة (.+),$", RegexOptions.Singleline);
 366:   
 367:                                  if (match.Success)
 368:                                  {
 369:                                      level = "5-";
 370:   
 371:                                      serviceAddress.Block = Ia.Ngn.Cl.Model.Business.Access.NormalizeBlockEntry(match.Groups[2].Value);
 372:                                      serviceAddress.Street = match.Groups[3].Value;
 373:                                      serviceAddress.Boulevard = match.Groups[4].Value;
 374:                                      serviceAddress.PremisesOld = null;
 375:                                      serviceAddress.PremisesNew = null;
 376:                                  }
 377:                                  else
 378:                                  {
 379:                                      level = "6";
 380:   
 381:                                      // below:
 382:                                      // الجهراء الجهراء المدينة,قطعة 79 قسيمة 17, منزل 17
 383:                                      match = Regex.Match(customerAddress, @"^(.+),قطعة (.+) قسيمة (.+), منزل (.+)$", RegexOptions.Singleline);
 384:   
 385:                                      if (match.Success)
 386:                                      {
 387:                                          level = "6-";
 388:   
 389:                                          serviceAddress.Block = Ia.Ngn.Cl.Model.Business.Access.NormalizeBlockEntry(match.Groups[2].Value);
 390:                                          serviceAddress.Street = null;
 391:                                          serviceAddress.Boulevard = null;
 392:                                          serviceAddress.PremisesOld = match.Groups[3].Value;
 393:                                          serviceAddress.PremisesNew = match.Groups[4].Value;
 394:                                      }
 395:                                      else
 396:                                      {
 397:                                          level = "7";
 398:   
 399:                                          // below:
 400:                                          // الجهراء الجهراء المدينة,قطعة 79 قسيمة 17
 401:                                          match = Regex.Match(customerAddress, @"^(.+),قطعة (.+) قسيمة (.+),$", RegexOptions.Singleline);
 402:   
 403:                                          if (match.Success)
 404:                                          {
 405:                                              level = "7-";
 406:   
 407:                                              serviceAddress.Block = Ia.Ngn.Cl.Model.Business.Access.NormalizeBlockEntry(match.Groups[2].Value);
 408:                                              serviceAddress.Street = null;
 409:                                              serviceAddress.Boulevard = null;
 410:                                              serviceAddress.PremisesOld = match.Groups[3].Value;
 411:                                              serviceAddress.PremisesNew = null;
 412:                                          }
 413:                                          else
 414:                                          {
 415:                                              level = "8";
 416:   
 417:                                              // below:
 418:                                              // الجهراء الجهراء المدينة,قطعة 79, منزل 17
 419:                                              match = Regex.Match(customerAddress, @"^(.+),قطعة (.+), منزل (.+)$", RegexOptions.Singleline);
 420:   
 421:                                              if (match.Success)
 422:                                              {
 423:                                                  level = "8-";
 424:   
 425:                                                  serviceAddress.Block = Ia.Ngn.Cl.Model.Business.Access.NormalizeBlockEntry(match.Groups[2].Value);
 426:                                                  serviceAddress.Street = null;
 427:                                                  serviceAddress.Boulevard = null;
 428:                                                  serviceAddress.PremisesOld = null;
 429:                                                  serviceAddress.PremisesNew = match.Groups[3].Value;
 430:                                              }
 431:                                              else
 432:                                              {
 433:                                                  level = "9";
 434:   
 435:                                                  // below:
 436:                                                  // الجهراء الجهراء المدينة,قطعة 79 شارع 5
 437:                                                  match = Regex.Match(customerAddress, @"^(.+),قطعة (.+) شارع (.+)$", RegexOptions.Singleline);
 438:   
 439:                                                  if (match.Success)
 440:                                                  {
 441:                                                      level = "9-";
 442:   
 443:                                                      serviceAddress.Block = Ia.Ngn.Cl.Model.Business.Access.NormalizeBlockEntry(match.Groups[2].Value);
 444:                                                      serviceAddress.Street = match.Groups[3].Value;
 445:                                                      serviceAddress.Boulevard = null;
 446:                                                      serviceAddress.PremisesOld = null;
 447:                                                      serviceAddress.PremisesNew = null;
 448:                                                  }
 449:                                                  else
 450:                                                  {
 451:                                                      level = "10";
 452:   
 453:                                                      // below:
 454:                                                      // الجهراء الجهراء المدينة,قطعة 79
 455:                                                      match = Regex.Match(customerAddress, @"^(.+),قطعة (.+),$", RegexOptions.Singleline);
 456:   
 457:                                                      if (match.Success)
 458:                                                      {
 459:                                                          level = "10-";
 460:   
 461:                                                          serviceAddress.Block = Ia.Ngn.Cl.Model.Business.Access.NormalizeBlockEntry(match.Groups[2].Value);
 462:                                                          serviceAddress.Street = null;
 463:                                                          serviceAddress.Boulevard = null;
 464:                                                          serviceAddress.PremisesOld = null;
 465:                                                          serviceAddress.PremisesNew = null;
 466:                                                      }
 467:                                                      else
 468:                                                      {
 469:                                                          level = "11";
 470:                                                      }
 471:                                                  }
 472:                                              }
 473:                                          }
 474:                                      }
 475:                                  }
 476:                              }
 477:                          }
 478:                      }
 479:                  }
 480:   
 481:                  // below: we will try to store integers in integer format
 482:   
 483:                  //serviceAddress.Block this is already in int format
 484:                  serviceAddress.Street = int.TryParse(serviceAddress.Street, out int i) ? i.ToString() : serviceAddress.Street;
 485:                  serviceAddress.Boulevard = int.TryParse(serviceAddress.Boulevard, out i) ? i.ToString() : serviceAddress.Boulevard;
 486:                  serviceAddress.PremisesOld = int.TryParse(serviceAddress.PremisesOld, out i) ? i.ToString() : serviceAddress.PremisesOld;
 487:                  serviceAddress.PremisesNew = int.TryParse(serviceAddress.PremisesNew, out i) ? i.ToString() : serviceAddress.PremisesNew;
 488:              }
 489:              else
 490:              {
 491:                  level = "0";
 492:   
 493:                  serviceAddress.AreaId = 0;
 494:              }
 495:   
 496:              return serviceAddress;
 497:          }
 498:   
 499:          ////////////////////////////////////////////////////////////////////////////    
 500:      }
 501:   
 502:      ////////////////////////////////////////////////////////////////////////////    
 503:      ////////////////////////////////////////////////////////////////////////////
 504:   
 505:      /// <summary>
 506:      ///
 507:      /// </summary>
 508:      public static class ServiceRequestExtension
 509:      {
 510:          ////////////////////////////////////////////////////////////////////////////
 511:   
 512:          /// <summary>
 513:          /// Extension method: Collect number list
 514:          /// </summary>
 515:          public static List<int> NumberList(this List<Ia.Ngn.Cl.Model.ServiceRequest> serviceRequestList)
 516:          {
 517:              List<int> numberList;
 518:   
 519:              numberList = (from n in serviceRequestList select n.Number).Distinct().ToList<int>();
 520:   
 521:              return numberList;
 522:          }
 523:   
 524:          ////////////////////////////////////////////////////////////////////////////
 525:   
 526:          /// <summary>
 527:          /// Extension method: Collect distinct number-serials into NumberSerial list
 528:          /// </summary>
 529:          public static List<Ia.Ngn.Cl.Model.Business.ServiceRequest.NumberSerial> DistinctNumberSerialList(this List<Ia.Ngn.Cl.Model.ServiceRequest> sourceList)
 530:          {
 531:              List<Ia.Ngn.Cl.Model.Business.ServiceRequest.NumberSerial> numberSerialList;
 532:   
 533:              numberSerialList = (from n in sourceList select new Ia.Ngn.Cl.Model.Business.ServiceRequest.NumberSerial { Number = n.Number, Serial = n.Serial }).Distinct().ToList();
 534:   
 535:              return numberSerialList;
 536:          }
 537:   
 538:          ////////////////////////////////////////////////////////////////////////////
 539:          ////////////////////////////////////////////////////////////////////////////
 540:      }
 541:   
 542:      ////////////////////////////////////////////////////////////////////////////
 543:      ////////////////////////////////////////////////////////////////////////////
 544:  }