Professional Applications Programmers/Consultants برمجة واستشارات تطبيقات الإنترنت
Skip Navigation LinksHome » Code Library » Find

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

Find subscriber and network information support class for the Next Generation Network business model

   1:  using System;
   2:  using System.Text.RegularExpressions;
   3:  using System.Data;
   4:  using System.Data.Entity;
   5:  using System.Collections.Generic;
   6:  using System.Linq;
   7:   
   8:  namespace Ia.Ngn.Cl.Model.Business.Maintenance
   9:  {
  10:      ////////////////////////////////////////////////////////////////////////////
  11:   
  12:      /// <summary publish="true">
  13:      /// Find subscriber and network information support class for the Next Generation Network business model
  14:      /// </summary>
  15:      /// 
  16:      /// <remarks> 
  17:      /// Copyright © 2006-2018 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 class Find
  30:      {
  31:          ////////////////////////////////////////////////////////////////////////////
  32:   
  33:          /// <summary>
  34:          ///
  35:          /// </summary>
  36:          public Find() { }
  37:   
  38:          ////////////////////////////////////////////////////////////////////////////
  39:   
  40:          /// <summary>
  41:          ///
  42:          /// </summary>
  43:          public static void Search(string rowInput, string inputType,
  44:              out List<Ia.Ngn.Cl.Model.Ui.Service2> serviceList,
  45:              out List<Ia.Ngn.Cl.Model.Ui.Nokia.AgcfGatewayRecord> agcfGatewayRecordList,
  46:              out List<Ia.Ngn.Cl.Model.Ui.Nokia.AgcfEndpoint> agcfEndpointList,
  47:              out List<Ia.Ngn.Cl.Model.Ui.Nokia.SubParty> subPartyList,
  48:              out List<Ia.Ngn.Cl.Model.Ui.Nokia.Subscriber> subscriberList,
  49:              out List<Ia.Ngn.Cl.Model.Ui.Huawei.HuSbr> huSbrList,
  50:              out List<Ia.Ngn.Cl.Model.Huawei.Owsbr> owsbrList,
  51:              out List<Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Ont> nddOntList,
  52:              out List<Ia.Ngn.Cl.Model.Ont> ontList,
  53:              out List<Ia.Ngn.Cl.Model.OntServiceVoip> ontServiceVoipList,
  54:              out List<Ia.Ngn.Cl.Model.OntOntPots> ontOntPotsList,
  55:              out List<Ia.Ngn.Cl.Model.Ui.Huawei.EmsOnt> emsOntList,
  56:              out List<Ia.Ngn.Cl.Model.Huawei.EmsOntSipInfo> emsOntSipInfoList,
  57:              out List<Ia.Ngn.Cl.Model.Huawei.EmsVoipPstnUser> emsVoipPstnUserList,
  58:              out List<Ia.Ngn.Cl.Model.Event> eventList,
  59:              out List<Ia.Ngn.Cl.Model.Access> accessList,
  60:              out List<Ia.Ngn.Cl.Model.Ui.ServiceRequestService> serviceRequestServiceList,
  61:              out List<Ia.Ngn.Cl.Model.ServiceInitialState> serviceInitialStateList,
  62:              out List<Ia.Ngn.Cl.Model.ServiceRequest> serviceRequestList,
  63:              out List<Ia.Ngn.Cl.Model.ServiceRequestType> serviceRequestTypeList,
  64:              out List<Ia.Ngn.Cl.Model.ServiceRequestOnt> serviceRequestOntList,
  65:              out List<Ia.Ngn.Cl.Model.ServiceRequestOntDetail> serviceRequestOntDetailList,
  66:              out List<Ia.Ngn.Cl.Model.Report> reportList,
  67:              out List<Ia.Ngn.Cl.Model.ReportHistory> reportHistoryList,
  68:              out Ia.Cl.Model.Result result)
  69:          {
  70:              Ia.Ngn.Cl.Model.Business.Maintenance.Find.Search(null, rowInput, inputType, out serviceList, out agcfGatewayRecordList, out agcfEndpointList, out subPartyList, out subscriberList, out huSbrList, out owsbrList, out nddOntList, out ontList, out ontServiceVoipList, out ontOntPotsList, out emsOntList, out emsOntSipInfoList, out emsVoipPstnUserList, out eventList, out accessList, out serviceRequestServiceList, out serviceInitialStateList, out serviceRequestList, out serviceRequestTypeList, out serviceRequestOntList, out serviceRequestOntDetailList, out reportList, out reportHistoryList, out result);
  71:          }
  72:   
  73:          ////////////////////////////////////////////////////////////////////////////
  74:   
  75:          /// <summary>
  76:          ///
  77:          /// </summary>
  78:          public static void Search(Ia.Ngn.Cl.Model.Staff staff, string rowInput, string inputType,
  79:              out List<Ia.Ngn.Cl.Model.Ui.Service2> serviceList,
  80:              out List<Ia.Ngn.Cl.Model.Ui.Nokia.AgcfGatewayRecord> agcfGatewayRecordList,
  81:              out List<Ia.Ngn.Cl.Model.Ui.Nokia.AgcfEndpoint> agcfEndpointList,
  82:              out List<Ia.Ngn.Cl.Model.Ui.Nokia.SubParty> subPartyList,
  83:              out List<Ia.Ngn.Cl.Model.Ui.Nokia.Subscriber> subscriberList,
  84:              out List<Ia.Ngn.Cl.Model.Ui.Huawei.HuSbr> huSbrList,
  85:              out List<Ia.Ngn.Cl.Model.Huawei.Owsbr> owsbrList,
  86:              out List<Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Ont> nddOntList,
  87:              out List<Ia.Ngn.Cl.Model.Ont> ontList,
  88:              out List<Ia.Ngn.Cl.Model.OntServiceVoip> ontServiceVoipList,
  89:              out List<Ia.Ngn.Cl.Model.OntOntPots> ontOntPotsList,
  90:              out List<Ia.Ngn.Cl.Model.Ui.Huawei.EmsOnt> emsOntList,
  91:              out List<Ia.Ngn.Cl.Model.Huawei.EmsOntSipInfo> emsOntSipInfoList,
  92:              out List<Ia.Ngn.Cl.Model.Huawei.EmsVoipPstnUser> emsVoipPstnUserList,
  93:              out List<Ia.Ngn.Cl.Model.Event> eventList,
  94:              out List<Ia.Ngn.Cl.Model.Access> accessList,
  95:              out List<Ia.Ngn.Cl.Model.Ui.ServiceRequestService> serviceRequestServiceList,
  96:              out List<Ia.Ngn.Cl.Model.ServiceInitialState> serviceInitialStateList,
  97:              out List<Ia.Ngn.Cl.Model.ServiceRequest> serviceRequestList,
  98:              out List<Ia.Ngn.Cl.Model.ServiceRequestType> serviceRequestTypeList,
  99:              out List<Ia.Ngn.Cl.Model.ServiceRequestOnt> serviceRequestOntList,
 100:              out List<Ia.Ngn.Cl.Model.ServiceRequestOntDetail> serviceRequestOntDetailList,
 101:              out List<Ia.Ngn.Cl.Model.Report> reportList,
 102:              out List<Ia.Ngn.Cl.Model.ReportHistory> reportHistoryList,
 103:              out Ia.Cl.Model.Result result)
 104:          {
 105:              bool inputIsValid;
 106:              string input;
 107:   
 108:              inputIsValid = false;
 109:              result = null;
 110:   
 111:              serviceList = null;
 112:              agcfGatewayRecordList = null;
 113:              agcfEndpointList = null;
 114:              subPartyList = null;
 115:              subscriberList = null;
 116:              huSbrList = null;
 117:              owsbrList = null;
 118:              nddOntList = null;
 119:              ontList = null;
 120:              ontServiceVoipList = null;
 121:              ontOntPotsList = null;
 122:              emsOntList = null;
 123:              emsOntSipInfoList = null;
 124:              emsVoipPstnUserList = null;
 125:              eventList = null;
 126:              accessList = null;
 127:              serviceRequestServiceList = null;
 128:              serviceInitialStateList = null;
 129:              serviceRequestList = null;
 130:              serviceRequestTypeList = null;
 131:              serviceRequestOntList = null;
 132:              serviceRequestOntDetailList = null;
 133:              reportList = null;
 134:              reportHistoryList = null;
 135:   
 136:              result = new Ia.Cl.Model.Result();
 137:   
 138:              if (!string.IsNullOrEmpty(rowInput))
 139:              {
 140:                  rowInput = rowInput.Trim();
 141:                  input = rowInput.ToLower();
 142:   
 143:                  if (input.Length > 0)
 144:                  {
 145:                      inputIsValid = true;
 146:   
 147:                      if (Regex.IsMatch(input, @"^\d{8}$") || Regex.IsMatch(input, @"^" + Ia.Ngn.Cl.Model.Business.Service.CountryCode + @"\d{8}$") || Regex.IsMatch(input, @"^sip:\+" + Ia.Ngn.Cl.Model.Business.Service.CountryCode + @"\d{8}@ims.moc.kw$"))
 148:                      {
 149:                          Ia.Ngn.Cl.Model.Business.Maintenance.Find.Number(staff, rowInput, out serviceList, out agcfGatewayRecordList, out agcfEndpointList, out subPartyList, out subscriberList, out huSbrList, out owsbrList, out nddOntList, out ontList, out ontServiceVoipList, out ontOntPotsList, out emsOntList, out emsOntSipInfoList, out emsVoipPstnUserList, out eventList, out accessList, out serviceRequestServiceList, out serviceInitialStateList, out serviceRequestList, out serviceRequestTypeList, out serviceRequestOntList, out serviceRequestOntDetailList, out reportList, out reportHistoryList, out result);
 150:                      }
 151:                      else if (Regex.IsMatch(input, @"^[a-zA-Z]{3}\s+\d{1,4}\s+\d{1,3}$") || Regex.IsMatch(input, @"^[a-zA-Z]{3}\.\d{1,4}\.\d{1,3}$") || Regex.IsMatch(input, @"^[a-zA-Z]{3}\/\d{1,4}\/\d{1,3}$") || Regex.IsMatch(input, @"^[a-zA-Z]{3}-\d{1,4}-\d{1,3}$"))
 152:                      {
 153:                          Ia.Ngn.Cl.Model.Business.Maintenance.Find.OntName(staff, rowInput, out serviceList, out agcfGatewayRecordList, out agcfEndpointList, out subPartyList, out subscriberList, out huSbrList, out owsbrList, out nddOntList, out ontList, out ontServiceVoipList, out ontOntPotsList, out emsOntList, out emsOntSipInfoList, out emsVoipPstnUserList, out eventList, out accessList, out serviceRequestServiceList, out serviceInitialStateList, out serviceRequestList, out serviceRequestTypeList, out serviceRequestOntList, out serviceRequestOntDetailList, out reportList, out reportHistoryList, out result);
 154:                      }
 155:                      else if (Ia.Ngn.Cl.Model.Business.Huawei.Ont.IsValidSerialNumber(input) || Ia.Ngn.Cl.Model.Business.Nokia.Ont.IsValidSerialNumber(input)) // Huawei or Nokia ONT serial
 156:                      {
 157:                          Ia.Ngn.Cl.Model.Business.Maintenance.Find.Serial(rowInput, out serviceList, out agcfGatewayRecordList, out agcfEndpointList, out subPartyList, out subscriberList, out huSbrList, out owsbrList, out nddOntList, out ontList, out ontServiceVoipList, out ontOntPotsList, out emsOntList, out emsOntSipInfoList, out emsVoipPstnUserList, out eventList, out accessList, out serviceRequestServiceList, out serviceInitialStateList, out serviceRequestList, out serviceRequestTypeList, out serviceRequestOntList, out serviceRequestOntDetailList, out reportList, out reportHistoryList, out result);
 158:                      }
 159:                      else if (Regex.IsMatch(input, @"^\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}$"))
 160:                      {
 161:                          Ia.Ngn.Cl.Model.Business.Maintenance.Find.Ip(rowInput, out serviceList, out agcfGatewayRecordList, out agcfEndpointList, out subPartyList, out subscriberList, out huSbrList, out owsbrList, out nddOntList, out ontList, out ontServiceVoipList, out ontOntPotsList, out emsOntList, out emsOntSipInfoList, out emsVoipPstnUserList, out eventList, out accessList, out serviceRequestServiceList, out serviceInitialStateList, out serviceRequestList, out serviceRequestTypeList, out serviceRequestOntList, out serviceRequestOntDetailList, out reportList, out reportHistoryList, out result);
 162:                      }
 163:                      else if (Regex.IsMatch(input, @"^[a-zA-Z]{3}\s+\d{1,4}$") || Regex.IsMatch(input, @"^[a-zA-Z]{3}\.\d{1,4}$") || Regex.IsMatch(input, @"^[a-zA-Z]{3}\/\d{1,4}$") || Regex.IsMatch(input, @"^[a-zA-Z]{3}-\d{1,4}$"))
 164:                      {
 165:                          Ia.Ngn.Cl.Model.Business.Maintenance.Find.PonName(rowInput, out serviceList, out agcfGatewayRecordList, out agcfEndpointList, out subPartyList, out subscriberList, out huSbrList, out owsbrList, out nddOntList, out ontList, out ontServiceVoipList, out ontOntPotsList, out emsOntList, out emsOntSipInfoList, out emsVoipPstnUserList, out eventList, out accessList, out serviceRequestServiceList, out serviceInitialStateList, out serviceRequestList, out serviceRequestTypeList, out serviceRequestOntList, out serviceRequestOntDetailList, out reportList, out reportHistoryList, out result);
 166:                      }
 167:                      else if (Regex.IsMatch(input, @"^[\w\d\-]+\-\d{1,2}\-\d{1,2}\-\d{1,2}$"))
 168:                      {
 169:                          Ia.Ngn.Cl.Model.Business.Maintenance.Find.OntPosition(rowInput, out serviceList, out agcfGatewayRecordList, out agcfEndpointList, out subPartyList, out subscriberList, out huSbrList, out owsbrList, out nddOntList, out ontList, out ontServiceVoipList, out ontOntPotsList, out emsOntList, out emsOntSipInfoList, out emsVoipPstnUserList, out eventList, out accessList, out serviceRequestServiceList, out serviceInitialStateList, out serviceRequestList, out serviceRequestTypeList, out serviceRequestOntList, out serviceRequestOntDetailList, out reportList, out reportHistoryList, out result);
 170:                      }
 171:                      else if (Regex.IsMatch(input, @"^[a-zA-Z]{3},\d{1,3}$"))
 172:                      {
 173:                          Ia.Ngn.Cl.Model.Business.Maintenance.Find.AreaBlock(rowInput, out accessList, out result);
 174:                      }
 175:                      else if (Regex.IsMatch(input, @"^[a-zA-Z]{3},\d{1,3},\d{0,3},\d{0,3},\d{0,3}$"))
 176:                      {
 177:                          Ia.Ngn.Cl.Model.Business.Maintenance.Find.Address(rowInput/*, out serviceList, out agcfGatewayRecordList, out agcfEndpointList, out subPartyList, out subscriberList, out huSbrList, out owsbrList, out nddOntList, out ontList, out ontServiceVoipList, out ontOntPotsList, out emsOntList, out emsOntSipInfoList, out emsVoipPstnUserList, out eventList*/, out accessList/*, out serviceRequestServiceList, out serviceInitialStateList, out serviceRequestList, out serviceRequestTypeList, out serviceRequestOntList, out serviceRequestOntDetailList, out reportList, out reportHistoryList*/, out result);
 178:                      }
 179:                      else if (Regex.IsMatch(input, @"^\d{1,7}$"))
 180:                      {
 181:                          if (!string.IsNullOrEmpty(inputType) && inputType == Ia.Ngn.Cl.Model.Business.ServiceRequest.ServiceRequestCustomerIdInputTypeString)
 182:                          {
 183:                              // max value of ServiceRequest CustomerId is a 7 digit number
 184:   
 185:                              Ia.Ngn.Cl.Model.Business.Maintenance.Find.CustomerId(rowInput, out serviceRequestList, out result);
 186:                          }
 187:                          else Ia.Ngn.Cl.Model.Business.Maintenance.Find.GatewayId(rowInput, out serviceList, out agcfGatewayRecordList, out agcfEndpointList, out subPartyList, out subscriberList, out huSbrList, out owsbrList, out nddOntList, out ontList, out ontServiceVoipList, out ontOntPotsList, out emsOntList, out emsOntSipInfoList, out emsVoipPstnUserList, out eventList, out accessList, out serviceRequestServiceList, out serviceInitialStateList, out serviceRequestList, out serviceRequestTypeList, out serviceRequestOntList, out serviceRequestOntDetailList, out reportList, out reportHistoryList, out result);
 188:                      }
 189:                      else if (Regex.IsMatch(input, @"^[\p{L}|\s]+$")) // "\p{L}" matches unicode characters
 190:                      {
 191:                          Ia.Ngn.Cl.Model.Business.Maintenance.Find.CustomerName(rowInput, out serviceRequestList, out result);
 192:                      }
 193:                      else inputIsValid = false;
 194:   
 195:                      if (inputIsValid)
 196:                      {
 197:                          if (
 198:                          (serviceList == null || serviceList != null && serviceList.Count == 0) &&
 199:                          (agcfGatewayRecordList == null || agcfGatewayRecordList != null && agcfGatewayRecordList.Count == 0) &&
 200:                          (agcfEndpointList == null || agcfEndpointList != null && agcfEndpointList.Count == 0) &&
 201:                          (subPartyList == null || subPartyList != null && subPartyList.Count == 0) &&
 202:                          (subscriberList == null || subscriberList != null && subscriberList.Count == 0) &&
 203:                          (huSbrList == null || huSbrList != null && huSbrList.Count == 0) &&
 204:                          (owsbrList == null || owsbrList != null && owsbrList.Count == 0) &&
 205:                          (nddOntList == null || nddOntList != null && nddOntList.Count == 0) &&
 206:                          (ontList == null || ontList != null && ontList.Count == 0) &&
 207:                          (ontServiceVoipList == null || ontServiceVoipList != null && ontServiceVoipList.Count == 0) &&
 208:                          (ontOntPotsList == null || ontOntPotsList != null && ontOntPotsList.Count == 0) &&
 209:                          (emsOntList == null || emsOntList != null && emsOntList.Count == 0) &&
 210:                          (emsOntSipInfoList == null || emsOntSipInfoList != null && emsOntSipInfoList.Count == 0) &&
 211:                          (emsVoipPstnUserList == null || emsVoipPstnUserList != null && emsVoipPstnUserList.Count == 0) &&
 212:                          (eventList == null || eventList != null && eventList.Count == 0) &&
 213:                          (accessList == null || accessList != null && accessList.Count == 0) &&
 214:                          (serviceRequestServiceList == null || serviceRequestServiceList != null && serviceRequestServiceList.Count == 0) &&
 215:                          (serviceInitialStateList == null || serviceInitialStateList != null && serviceInitialStateList.Count == 0) &&
 216:                          (serviceRequestList == null || serviceRequestList != null && serviceRequestList.Count == 0) &&
 217:                          (serviceRequestTypeList == null || serviceRequestTypeList != null && serviceRequestTypeList.Count == 0) &&
 218:                          (serviceRequestOntList == null || serviceRequestOntList != null && serviceRequestOntList.Count == 0) &&
 219:                          (serviceRequestOntDetailList == null || serviceRequestOntDetailList != null && serviceRequestOntDetailList.Count == 0) &&
 220:                          (reportList == null || reportList != null && reportList.Count == 0) &&
 221:                          (reportHistoryList == null || reportHistoryList != null && reportHistoryList.Count == 0))
 222:                          {
 223:                              if (result.IsSuccessful)
 224:                              {
 225:                                  result.AddWarning("No data records were found for \"" + rowInput + "\" (لا توجد معلومات عن القيمة المعطاة). ");
 226:                              }
 227:                              else { };// result.AddError(result.Error);
 228:                          }
 229:                          else
 230:                          {
 231:                              /*
 232:                              if (result.IsSuccessful)
 233:                              {
 234:                                  if (!string.IsNullOrEmpty(result.Message)) result.AddSuccess(result.Message);
 235:                              }
 236:                              //else result.AddError(result.Error);
 237:                              */
 238:                          }
 239:                      }
 240:                      else result.AddError("Input format is unknown (قيمة غير مفهومة). ");
 241:                  }
 242:                  else result.AddError("No input was entered (لم يتم إدخال أي شيء). ");
 243:              }
 244:              else result.AddError("Input is null or empty (لم يتم إدخال أي شيء). ");
 245:          }
 246:   
 247:          ////////////////////////////////////////////////////////////////////////////
 248:   
 249:          /// <summary>
 250:          ///
 251:          /// </summary>
 252:          public static void BulkSearch(string rowInput, out List<Ia.Ngn.Cl.Model.Business.ServiceAccessName> serviceAccessNameList, out Ia.Cl.Model.Result result)
 253:          {
 254:              bool inputIsValid;
 255:              string input;
 256:   
 257:              inputIsValid = false;
 258:              result = null;
 259:   
 260:              serviceAccessNameList = null;
 261:   
 262:              result = new Ia.Cl.Model.Result();
 263:   
 264:              if (!string.IsNullOrEmpty(rowInput))
 265:              {
 266:                  rowInput = rowInput.Trim();
 267:                  input = rowInput.ToLower();
 268:   
 269:                  if (input.Length > 0)
 270:                  {
 271:                      inputIsValid = true;
 272:   
 273:                      Ia.Ngn.Cl.Model.Business.Maintenance.Find.NumberStringListToAccessNameList(rowInput, out serviceAccessNameList, out result);
 274:   
 275:                      if (inputIsValid)
 276:                      {
 277:                          if (serviceAccessNameList == null || serviceAccessNameList != null && serviceAccessNameList.Count == 0)
 278:                          {
 279:                              if (result.IsSuccessful)
 280:                              {
 281:                                  result.AddWarning("No data records were found for \"" + rowInput + "\" (لا توجد معلومات عن القيمة أو القيم المعطاة). ");
 282:                              }
 283:                              else { };// result.AddError(result.Error);
 284:                          }
 285:                          else
 286:                          {
 287:                              if (result.IsSuccessful)
 288:                              {
 289:                                  if (!string.IsNullOrEmpty(result.Message)) result.AddSuccess(result.Message);
 290:                              }
 291:                              //else result.AddError(result.Error);
 292:                          }
 293:                      }
 294:                      else result.AddError("Input format is unknown (قيمة غير مفهومة). ");
 295:                  }
 296:                  else result.AddError("No input was entered (لم يتم إدخال أي شيء). ");
 297:              }
 298:              else result.AddError("Input is null or empty (لم يتم إدخال أي شيء). ");
 299:          }
 300:   
 301:          ////////////////////////////////////////////////////////////////////////////
 302:   
 303:          /// <summary>
 304:          ///
 305:          /// </summary>
 306:          public static void NumberStringListToAccessNameList(string rowInput, out List<Ia.Ngn.Cl.Model.Business.ServiceAccessName> serviceAccessNameList, out Ia.Cl.Model.Result result)
 307:          {
 308:              string input, serviceId;
 309:              int number;
 310:              string numberString;
 311:              Dictionary<string, string> serviceToAccessNameDictionary;
 312:              MatchCollection matchCollection;
 313:              Ia.Ngn.Cl.Model.Business.ServiceAccessName serviceAccessName;
 314:   
 315:              result = new Ia.Cl.Model.Result();
 316:   
 317:              serviceAccessNameList = new List<Ia.Ngn.Cl.Model.Business.ServiceAccessName>();
 318:   
 319:              input = rowInput.ToLower();
 320:   
 321:              serviceToAccessNameDictionary = Ia.Ngn.Cl.Model.Data.Service2.ServiceIdToAccessNameDictionary;
 322:   
 323:              matchCollection = Regex.Matches(input, @"\d{8}");
 324:   
 325:              if (matchCollection.Count > 0)
 326:              {
 327:                  foreach (Match match in matchCollection)
 328:                  {
 329:                      numberString = match.Value;
 330:   
 331:                      number = int.Parse(numberString);
 332:   
 333:                      if (Ia.Ngn.Cl.Model.Business.Service.NumberIsWithinAllowedDomainList(number))
 334:                      {
 335:                          serviceAccessName = new Ia.Ngn.Cl.Model.Business.ServiceAccessName();
 336:   
 337:                          serviceId = numberString + ":1:965";
 338:   
 339:                          serviceAccessName.Service = number.ToString();
 340:   
 341:                          if (serviceToAccessNameDictionary.ContainsKey(serviceId))
 342:                          {
 343:                              serviceAccessName.AccessName = serviceToAccessNameDictionary[serviceId];
 344:                          }
 345:   
 346:                          serviceAccessNameList.Add(serviceAccessName);
 347:   
 348:                          foreach (var v in serviceAccessNameList) Ia.Ngn.Cl.Model.Data.Msmq.ServiceQueue.Enqueue(v.Service);
 349:                      }
 350:                      else
 351:                      {
 352:                          result.AddWarning("The number \"" + numberString + "\" does not belong to the network (الرقم لا ينتمي للشبكة). ");
 353:                      }
 354:                  }
 355:              }
 356:              else
 357:              {
 358:                  result.AddError("No input was entered (لم يتم إدخال أي شيء). ");
 359:              }
 360:          }
 361:   
 362:          ////////////////////////////////////////////////////////////////////////////
 363:          ////////////////////////////////////////////////////////////////////////////
 364:   
 365:          /// <summary>
 366:          ///
 367:          /// </summary>
 368:          public static void OntName(Ia.Ngn.Cl.Model.Staff staff, string rowInput,
 369:              out List<Ia.Ngn.Cl.Model.Ui.Service2> service2List,
 370:              out List<Ia.Ngn.Cl.Model.Ui.Nokia.AgcfGatewayRecord> agcfGatewayRecordList,
 371:              out List<Ia.Ngn.Cl.Model.Ui.Nokia.AgcfEndpoint> agcfEndpointList,
 372:              out List<Ia.Ngn.Cl.Model.Ui.Nokia.SubParty> subPartyList,
 373:              out List<Ia.Ngn.Cl.Model.Ui.Nokia.Subscriber> subscriberList,
 374:              out List<Ia.Ngn.Cl.Model.Ui.Huawei.HuSbr> huSbrList,
 375:              out List<Ia.Ngn.Cl.Model.Huawei.Owsbr> owsbrList,
 376:              out List<Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Ont> nddOntList,
 377:              out List<Ia.Ngn.Cl.Model.Ont> ontList,
 378:              out List<Ia.Ngn.Cl.Model.OntServiceVoip> ontServiceVoipList,
 379:              out List<Ia.Ngn.Cl.Model.OntOntPots> ontOntPotsList,
 380:              out List<Ia.Ngn.Cl.Model.Ui.Huawei.EmsOnt> emsOntList,
 381:              out List<Ia.Ngn.Cl.Model.Huawei.EmsOntSipInfo> emsOntSipInfoList,
 382:              out List<Ia.Ngn.Cl.Model.Huawei.EmsVoipPstnUser> emsVoipPstnUserList,
 383:              out List<Ia.Ngn.Cl.Model.Event> eventList,
 384:              out List<Ia.Ngn.Cl.Model.Access> accessList,
 385:              out List<Ia.Ngn.Cl.Model.Ui.ServiceRequestService> serviceRequestServiceList,
 386:              out List<Ia.Ngn.Cl.Model.ServiceInitialState> serviceInitialStateList,
 387:              out List<Ia.Ngn.Cl.Model.ServiceRequest> serviceRequestList,
 388:              out List<Ia.Ngn.Cl.Model.ServiceRequestType> serviceRequestTypeList,
 389:              out List<Ia.Ngn.Cl.Model.ServiceRequestOnt> serviceRequestOntList,
 390:              out List<Ia.Ngn.Cl.Model.ServiceRequestOntDetail> serviceRequestOntDetailList,
 391:              out List<Ia.Ngn.Cl.Model.Report> reportList,
 392:              out List<Ia.Ngn.Cl.Model.ReportHistory> reportHistoryList,
 393:              out Ia.Cl.Model.Result result)
 394:          {
 395:              int oltId, ponNumber, ontInternalNumber;
 396:              string input, accessName;
 397:              Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Vendor accessVendor, switchVendor;
 398:              Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Ont nddOnt;
 399:              List<string> accessIdList, nddOntIdList, ipList;
 400:   
 401:              ipList = new List<string>();
 402:              nddOntIdList = new List<string>();
 403:              accessIdList = new List<string>();
 404:   
 405:              result = new Ia.Cl.Model.Result();
 406:   
 407:              service2List = null;
 408:              agcfGatewayRecordList = null;
 409:              agcfEndpointList = null;
 410:              subPartyList = null;
 411:              subscriberList = null;
 412:              huSbrList = null;
 413:              owsbrList = null;
 414:              nddOntList = null;
 415:              ontList = null;
 416:              ontServiceVoipList = null;
 417:              ontOntPotsList = null;
 418:              emsOntList = null;
 419:              emsOntSipInfoList = null;
 420:              emsVoipPstnUserList = null;
 421:              eventList = null;
 422:              accessList = null;
 423:              serviceRequestServiceList = null;
 424:              serviceInitialStateList = null;
 425:              serviceRequestList = null;
 426:              serviceRequestTypeList = null;
 427:              serviceRequestOntList = null;
 428:              serviceRequestOntDetailList = null;
 429:              reportList = null;
 430:              reportHistoryList = null;
 431:   
 432:              input = rowInput.ToLower();
 433:   
 434:              accessName = Ia.Ngn.Cl.Model.Business.Default.ExtractAccessNameWithValidSymbolAndLegalFormatForPonAndOntFromValue(input);
 435:   
 436:              nddOnt = Ia.Ngn.Cl.Model.Data.NetworkDesignDocument.OntByAccessName(accessName);
 437:   
 438:              if (nddOnt != null)
 439:              {
 440:                  if (Ia.Ngn.Cl.Model.Business.Authority.AccessNameIsWithinStaffSiteAreaSymbolList(staff, accessName))
 441:                  {
 442:                      accessVendor = nddOnt.Pon.PonGroup.Olt.Odf.Vendor;
 443:                      switchVendor = nddOnt.Pon.PonGroup.Olt.Odf.Router.Vendor;
 444:   
 445:                      oltId = nddOnt.Pon.PonGroup.Olt.Id;
 446:                      ponNumber = nddOnt.Pon.Number;
 447:                      ontInternalNumber = nddOnt.InternalNumber;
 448:   
 449:                      try
 450:                      {
 451:                          ipList.Add(nddOnt.Ip);
 452:   
 453:                          accessIdList.Add(nddOnt.Access.Id);
 454:   
 455:                          nddOntIdList.Add(nddOnt.Id);
 456:   
 457:                          OntNameAndPonNameAndPosition(switchVendor, accessVendor, nddOntIdList, accessIdList, ipList, out service2List, out agcfGatewayRecordList, out agcfEndpointList, out subPartyList, out subscriberList, out huSbrList, out owsbrList, out nddOntList, out ontList, out ontServiceVoipList, out ontOntPotsList, out emsOntList, out emsOntSipInfoList, out emsVoipPstnUserList, out eventList, out accessList, out serviceRequestServiceList, out serviceInitialStateList, out serviceRequestList, out serviceRequestTypeList, out serviceRequestOntList, out serviceRequestOntDetailList, out reportList, out reportHistoryList);
 458:                      }
 459:                      catch (Exception ex)
 460:                      {
 461:                          result.AddError("Exception: Retrieval error of data for \"" + rowInput + "\": " + ex.ToString());
 462:                      }
 463:                  }
 464:                  else
 465:                  {
 466:                      result.AddError("Access " + accessName + " is not in staff site access list (رقم الصندوق لا ينتمي لمقسم المستخدم). ");
 467:                  }
 468:              }
 469:              else
 470:              {
 471:                  result.AddError("The ONT \"" + rowInput + "\" does not belong to the network (الصندوق لا ينتمي للشبكة). ");
 472:              }
 473:          }
 474:   
 475:          ////////////////////////////////////////////////////////////////////////////
 476:   
 477:          /// <summary>
 478:          ///
 479:          /// </summary>
 480:          public static void PonName(string rowInput,
 481:              out List<Ia.Ngn.Cl.Model.Ui.Service2> service2List,
 482:              out List<Ia.Ngn.Cl.Model.Ui.Nokia.AgcfGatewayRecord> agcfGatewayRecordList,
 483:              out List<Ia.Ngn.Cl.Model.Ui.Nokia.AgcfEndpoint> agcfEndpointList,
 484:              out List<Ia.Ngn.Cl.Model.Ui.Nokia.SubParty> subPartyList,
 485:              out List<Ia.Ngn.Cl.Model.Ui.Nokia.Subscriber> subscriberList,
 486:              out List<Ia.Ngn.Cl.Model.Ui.Huawei.HuSbr> huSbrList,
 487:              out List<Ia.Ngn.Cl.Model.Huawei.Owsbr> owsbrList,
 488:              out List<Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Ont> nddOntList,
 489:              out List<Ia.Ngn.Cl.Model.Ont> ontList,
 490:              out List<Ia.Ngn.Cl.Model.OntServiceVoip> ontServiceVoipList,
 491:              out List<Ia.Ngn.Cl.Model.OntOntPots> ontOntPotsList,
 492:              out List<Ia.Ngn.Cl.Model.Ui.Huawei.EmsOnt> emsOntList,
 493:              out List<Ia.Ngn.Cl.Model.Huawei.EmsOntSipInfo> emsOntSipInfoList,
 494:              out List<Ia.Ngn.Cl.Model.Huawei.EmsVoipPstnUser> emsVoipPstnUserList,
 495:              out List<Ia.Ngn.Cl.Model.Event> eventList,
 496:              out List<Ia.Ngn.Cl.Model.Access> accessList,
 497:              out List<Ia.Ngn.Cl.Model.Ui.ServiceRequestService> serviceRequestServiceList,
 498:              out List<Ia.Ngn.Cl.Model.ServiceInitialState> serviceInitialStateList,
 499:              out List<Ia.Ngn.Cl.Model.ServiceRequest> serviceRequestList,
 500:              out List<Ia.Ngn.Cl.Model.ServiceRequestType> serviceRequestTypeList,
 501:              out List<Ia.Ngn.Cl.Model.ServiceRequestOnt> serviceRequestOntList,
 502:              out List<Ia.Ngn.Cl.Model.ServiceRequestOntDetail> serviceRequestOntDetailList,
 503:              out List<Ia.Ngn.Cl.Model.Report> reportList,
 504:              out List<Ia.Ngn.Cl.Model.ReportHistory> reportHistoryList,
 505:              out Ia.Cl.Model.Result result)
 506:          {
 507:              int oltId, ponNumber;
 508:              string input, ponName;
 509:              Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Vendor accessVendor, switchVendor;
 510:              Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Pon nddPon;
 511:              List<string> accessIdList, nddOntIdList, ipList;
 512:   
 513:              result = new Ia.Cl.Model.Result();
 514:   
 515:              service2List = null;
 516:              agcfGatewayRecordList = null;
 517:              agcfEndpointList = null;
 518:              subPartyList = null;
 519:              subscriberList = null;
 520:              huSbrList = null;
 521:              owsbrList = null;
 522:              nddOntList = null;
 523:              ontList = null;
 524:              ontServiceVoipList = null;
 525:              ontOntPotsList = null;
 526:              emsOntList = null;
 527:              emsOntSipInfoList = null;
 528:              emsVoipPstnUserList = null;
 529:              eventList = null;
 530:              accessList = null;
 531:              serviceRequestServiceList = null;
 532:              serviceInitialStateList = null;
 533:              serviceRequestList = null;
 534:              serviceRequestTypeList = null;
 535:              serviceRequestOntList = null;
 536:              serviceRequestOntDetailList = null;
 537:              reportList = null;
 538:              reportHistoryList = null;
 539:   
 540:              input = rowInput.ToLower();
 541:   
 542:              ponName = Ia.Ngn.Cl.Model.Business.Default.ExtractPonNameWithValidSymbolAndLegalFormatForPonAndOntFromValue(input);
 543:   
 544:              nddPon = (from p in Ia.Ngn.Cl.Model.Data.NetworkDesignDocument.PonList where p.Name == ponName select p).SingleOrDefault();
 545:   
 546:              if (nddPon != null)
 547:              {
 548:                  accessVendor = nddPon.PonGroup.Olt.Odf.Vendor;
 549:                  switchVendor = nddPon.PonGroup.Olt.Odf.Router.Vendor;
 550:   
 551:                  oltId = nddPon.PonGroup.Olt.Id;
 552:                  ponNumber = nddPon.Number;
 553:   
 554:                  try
 555:                  {
 556:                      ipList = new List<string>(); // pass empty
 557:   
 558:                      accessIdList = Ia.Ngn.Cl.Model.Data.Maintenance.Find.AccessIdList(oltId, ponNumber);
 559:   
 560:                      nddOntIdList = Ia.Ngn.Cl.Model.Data.Maintenance.Find.NddOntIdList(oltId, ponNumber);
 561:   
 562:                      OntNameAndPonNameAndPosition(switchVendor, accessVendor, nddOntIdList, accessIdList, ipList, out service2List, out agcfGatewayRecordList, out agcfEndpointList, out subPartyList, out subscriberList, out huSbrList, out owsbrList, out nddOntList, out ontList, out ontServiceVoipList, out ontOntPotsList, out emsOntList, out emsOntSipInfoList, out emsVoipPstnUserList, out eventList, out accessList, out serviceRequestServiceList, out serviceInitialStateList, out serviceRequestList, out serviceRequestTypeList, out serviceRequestOntList, out serviceRequestOntDetailList, out reportList, out reportHistoryList);
 563:                  }
 564:                  catch (Exception ex)
 565:                  {
 566:                      result.AddError("Exception: Retrieval error of data for \"" + rowInput + "\": " + ex.ToString());
 567:                  }
 568:              }
 569:              else
 570:              {
 571:                  result.AddError("The PON \"" + rowInput + "\" had a null values. ");
 572:              }
 573:          }
 574:   
 575:          ////////////////////////////////////////////////////////////////////////////
 576:   
 577:          /// <summary>
 578:          ///
 579:          /// </summary>
 580:          public static void OntPosition(string rowInput,
 581:              out List<Ia.Ngn.Cl.Model.Ui.Service2> service2List,
 582:              out List<Ia.Ngn.Cl.Model.Ui.Nokia.AgcfGatewayRecord> agcfGatewayRecordList,
 583:              out List<Ia.Ngn.Cl.Model.Ui.Nokia.AgcfEndpoint> agcfEndpointList,
 584:              out List<Ia.Ngn.Cl.Model.Ui.Nokia.SubParty> subPartyList,
 585:              out List<Ia.Ngn.Cl.Model.Ui.Nokia.Subscriber> subscriberList,
 586:              out List<Ia.Ngn.Cl.Model.Ui.Huawei.HuSbr> huSbrList,
 587:              out List<Ia.Ngn.Cl.Model.Huawei.Owsbr> owsbrList,
 588:              out List<Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Ont> nddOntList,
 589:              out List<Ia.Ngn.Cl.Model.Ont> ontList,
 590:              out List<Ia.Ngn.Cl.Model.OntServiceVoip> ontServiceVoipList,
 591:              out List<Ia.Ngn.Cl.Model.OntOntPots> ontOntPotsList,
 592:              out List<Ia.Ngn.Cl.Model.Ui.Huawei.EmsOnt> emsOntList,
 593:              out List<Ia.Ngn.Cl.Model.Huawei.EmsOntSipInfo> emsOntSipInfoList,
 594:              out List<Ia.Ngn.Cl.Model.Huawei.EmsVoipPstnUser> emsVoipPstnUserList,
 595:              out List<Ia.Ngn.Cl.Model.Event> eventList,
 596:              out List<Ia.Ngn.Cl.Model.Access> accessList,
 597:              out List<Ia.Ngn.Cl.Model.Ui.ServiceRequestService> serviceRequestServiceList,
 598:              out List<Ia.Ngn.Cl.Model.ServiceInitialState> serviceInitialStateList,
 599:              out List<Ia.Ngn.Cl.Model.ServiceRequest> serviceRequestList,
 600:              out List<Ia.Ngn.Cl.Model.ServiceRequestType> serviceRequestTypeList,
 601:              out List<Ia.Ngn.Cl.Model.ServiceRequestOnt> serviceRequestOntList,
 602:              out List<Ia.Ngn.Cl.Model.ServiceRequestOntDetail> serviceRequestOntDetailList,
 603:              out List<Ia.Ngn.Cl.Model.Report> reportList,
 604:              out List<Ia.Ngn.Cl.Model.ReportHistory> reportHistoryList,
 605:              out Ia.Cl.Model.Result result)
 606:          {
 607:              int oltId, ponNumber, ontInternalNumber;
 608:              string input, accessName;
 609:              Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Vendor accessVendor, switchVendor;
 610:              Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Ont nddOnt;
 611:              List<string> accessIdList, nddOntIdList, ipList;
 612:   
 613:              ipList = new List<string>();
 614:   
 615:              result = new Ia.Cl.Model.Result();
 616:   
 617:              service2List = null;
 618:              agcfGatewayRecordList = null;
 619:              agcfEndpointList = null;
 620:              subPartyList = null;
 621:              subscriberList = null;
 622:              huSbrList = null;
 623:              owsbrList = null;
 624:              nddOntList = null;
 625:              ontList = null;
 626:              ontServiceVoipList = null;
 627:              ontOntPotsList = null;
 628:              emsOntList = null;
 629:              emsOntSipInfoList = null;
 630:              emsVoipPstnUserList = null;
 631:              eventList = null;
 632:              accessList = null;
 633:              serviceRequestServiceList = null;
 634:              serviceInitialStateList = null;
 635:              serviceRequestList = null;
 636:              serviceRequestTypeList = null;
 637:              serviceRequestOntList = null;
 638:              serviceRequestOntDetailList = null;
 639:              reportList = null;
 640:              reportHistoryList = null;
 641:   
 642:              input = rowInput.ToUpper();
 643:   
 644:              nddOnt = (from nddo in Ia.Ngn.Cl.Model.Data.NetworkDesignDocument.OntList where nddo.Position == input select nddo).SingleOrDefault();
 645:   
 646:              if (nddOnt != null)
 647:              {
 648:                  accessName = nddOnt.Access.Name;
 649:   
 650:                  accessVendor = nddOnt.Pon.PonGroup.Olt.Odf.Vendor;
 651:                  switchVendor = nddOnt.Pon.PonGroup.Olt.Odf.Router.Vendor;
 652:   
 653:                  oltId = nddOnt.Pon.PonGroup.Olt.Id;
 654:                  ponNumber = nddOnt.Pon.Number;
 655:                  ontInternalNumber = nddOnt.InternalNumber;
 656:   
 657:                  try
 658:                  {
 659:                      ipList.Add(nddOnt.Ip);
 660:   
 661:                      accessIdList = Ia.Ngn.Cl.Model.Data.Maintenance.Find.AccessIdList(oltId, ponNumber, ontInternalNumber);
 662:   
 663:                      nddOntIdList = Ia.Ngn.Cl.Model.Data.Maintenance.Find.NddOntIdList(oltId, ponNumber, ontInternalNumber);
 664:   
 665:                      OntNameAndPonNameAndPosition(switchVendor, accessVendor, nddOntIdList, accessIdList, ipList, out service2List, out agcfGatewayRecordList, out agcfEndpointList, out subPartyList, out subscriberList, out huSbrList, out owsbrList, out nddOntList, out ontList, out ontServiceVoipList, out ontOntPotsList, out emsOntList, out emsOntSipInfoList, out emsVoipPstnUserList, out eventList, out accessList, out serviceRequestServiceList, out serviceInitialStateList, out serviceRequestList, out serviceRequestTypeList, out serviceRequestOntList, out serviceRequestOntDetailList, out reportList, out reportHistoryList);
 666:                  }
 667:                  catch (Exception ex)
 668:                  {
 669:                      result.AddError("Exception: Retrieval error of data for \"" + rowInput + "\": " + ex.ToString());
 670:                  }
 671:              }
 672:              else
 673:              {
 674:                  result.AddError("The ONT position \"" + rowInput + "\" was not found in the network. ");
 675:              }
 676:          }
 677:   
 678:          ////////////////////////////////////////////////////////////////////////////
 679:   
 680:          /// <summary>
 681:          ///
 682:          /// </summary>
 683:          public static void OntNameAndPonNameAndPosition(Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Vendor switchVendor,
 684:              Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Vendor accessVendor,
 685:              List<string> nddOntIdList,
 686:              List<string> accessIdList,
 687:              List<string> ipList,
 688:              out List<Ia.Ngn.Cl.Model.Ui.Service2> service2List,
 689:              out List<Ia.Ngn.Cl.Model.Ui.Nokia.AgcfGatewayRecord> agcfGatewayRecordList,
 690:              out List<Ia.Ngn.Cl.Model.Ui.Nokia.AgcfEndpoint> agcfEndpointList,
 691:              out List<Ia.Ngn.Cl.Model.Ui.Nokia.SubParty> subPartyList,
 692:              out List<Ia.Ngn.Cl.Model.Ui.Nokia.Subscriber> subscriberList,
 693:              out List<Ia.Ngn.Cl.Model.Ui.Huawei.HuSbr> huSbrList,
 694:              out List<Ia.Ngn.Cl.Model.Huawei.Owsbr> owsbrList,
 695:              out List<Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Ont> nddOntList,
 696:              out List<Ia.Ngn.Cl.Model.Ont> ontList,
 697:              out List<Ia.Ngn.Cl.Model.OntServiceVoip> ontServiceVoipList,
 698:              out List<Ia.Ngn.Cl.Model.OntOntPots> ontOntPotsList,
 699:              out List<Ia.Ngn.Cl.Model.Ui.Huawei.EmsOnt> emsOntList,
 700:              out List<Ia.Ngn.Cl.Model.Huawei.EmsOntSipInfo> emsOntSipInfoList,
 701:              out List<Ia.Ngn.Cl.Model.Huawei.EmsVoipPstnUser> emsVoipPstnUserList,
 702:              out List<Ia.Ngn.Cl.Model.Event> eventList,
 703:              out List<Ia.Ngn.Cl.Model.Access> accessList,
 704:              out List<Ia.Ngn.Cl.Model.Ui.ServiceRequestService> serviceRequestServiceList,
 705:              out List<Ia.Ngn.Cl.Model.ServiceInitialState> serviceInitialStateList,
 706:              out List<Ia.Ngn.Cl.Model.ServiceRequest> serviceRequestList,
 707:              out List<Ia.Ngn.Cl.Model.ServiceRequestType> serviceRequestTypeList,
 708:              out List<Ia.Ngn.Cl.Model.ServiceRequestOnt> serviceRequestOntList,
 709:              out List<Ia.Ngn.Cl.Model.ServiceRequestOntDetail> serviceRequestOntDetailList,
 710:              out List<Ia.Ngn.Cl.Model.Report> reportList,
 711:              out List<Ia.Ngn.Cl.Model.ReportHistory> reportHistoryList)
 712:          {
 713:              List<int> serviceRequestIdList, serviceRequestTypeIdList, agcfGatewayRecordIdList, reportIdList, numberList;
 714:              List<long> serviceLongList, eventIdList;
 715:              List<string> sbrImpuList, owsbrImpuList, partyIdList, prividUserList, serviceList, serviceRequestServiceIdList, serviceInitialStateIdList, serviceRequestOntIdList, service2IdList, impuSipDomainList, ontIdList, ontOntPotsIdList, ontServiceVoipIdList, emsOntIdList, agcfEndpointIdList, subPartyIdList, subscriberIdList, ontServiceVoipIpList, emsOntIpList;
 716:   
 717:              serviceLongList = new List<long>();
 718:              numberList = new List<int>();
 719:              serviceList = new List<string>();
 720:              partyIdList = new List<string>();
 721:              prividUserList = new List<string>();
 722:              impuSipDomainList = new List<string>();
 723:   
 724:              agcfGatewayRecordIdList = new List<int>();
 725:              agcfEndpointIdList = new List<string>();
 726:              subPartyIdList = new List<string>();
 727:              subscriberIdList = new List<string>();
 728:   
 729:              sbrImpuList = new List<string>();
 730:              owsbrImpuList = new List<string>();
 731:   
 732:              ontIdList = new List<string>();
 733:              ontOntPotsIdList = new List<string>();
 734:              ontServiceVoipIdList = new List<string>();
 735:   
 736:              eventIdList = new List<long>();
 737:   
 738:              emsOntIdList = new List<string>();
 739:   
 740:              service2List = null;
 741:              agcfGatewayRecordList = null;
 742:              agcfEndpointList = null;
 743:              subPartyList = null;
 744:              subscriberList = null;
 745:              huSbrList = null;
 746:              owsbrList = null;
 747:              nddOntList = null;
 748:              ontList = null;
 749:              ontServiceVoipList = null;
 750:              ontOntPotsList = null;
 751:              emsOntList = null;
 752:              emsOntSipInfoList = null;
 753:              emsVoipPstnUserList = null;
 754:              eventList = null;
 755:              accessList = null;
 756:              serviceRequestServiceList = null;
 757:              serviceInitialStateList = null;
 758:              serviceRequestList = null;
 759:              serviceRequestTypeList = null;
 760:              serviceRequestOntList = null;
 761:              serviceRequestOntDetailList = null;
 762:              reportList = null;
 763:              reportHistoryList = null;
 764:   
 765:              using (var db = new Ia.Ngn.Cl.Model.Ngn())
 766:              {
 767:                  nddOntIdList.AddRange(Ia.Ngn.Cl.Model.Data.Maintenance.Find.NddOntIdListFromAccessIdList(accessIdList));
 768:                  nddOntIdList = nddOntIdList.Distinct().ToList();
 769:   
 770:                  service2IdList = Ia.Ngn.Cl.Model.Data.Maintenance.Find.ServiceIdListFromAccessIdList(accessIdList);
 771:   
 772:                  Ia.Ngn.Cl.Model.Data.Maintenance.Find.CollectServiceListFromServiceRequestServiceIdOrService2IdList(service2IdList, ref serviceList);
 773:                  Ia.Ngn.Cl.Model.Data.Maintenance.Find.SynchronizeNumberFormatLists(ref partyIdList, ref prividUserList, ref serviceList, ref numberList, ref serviceLongList, ref impuSipDomainList);
 774:   
 775:                  if (accessVendor == Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Vendor.Nokia)
 776:                  {
 777:                      ontIdList = Ia.Ngn.Cl.Model.Data.Maintenance.Find.OntIdListFromNddOntIdList(nddOntIdList);
 778:   
 779:                      ontOntPotsIdList = Ia.Ngn.Cl.Model.Data.Maintenance.Find.OntOntPotsIdListFromOntIdList(ontIdList);
 780:   
 781:                      ontServiceVoipIdList = Ia.Ngn.Cl.Model.Data.Maintenance.Find.OntServiceVoipsIdListFromOntIdList(ontIdList);
 782:   
 783:                      ontServiceVoipIpList = Ia.Ngn.Cl.Model.Data.Maintenance.Find.OntServiceVoipIpList(ontServiceVoipIdList);
 784:   
 785:                      ipList.AddRange(ontServiceVoipIpList);
 786:   
 787:                      //eventIdList = Ia.Ngn.Cl.Model.Data.Maintenance.Find.EventIdListFromOntIdList(ontIdList);
 788:                  }
 789:                  else if (accessVendor == Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Vendor.Huawei)
 790:                  {
 791:                      emsOntIdList = Ia.Ngn.Cl.Model.Data.Maintenance.Find.EmsOntIdListFromNddOntIdList(nddOntIdList);
 792:   
 793:                      ipList.AddRange(Ia.Ngn.Cl.Model.Data.Maintenance.Find.EmsOntIpListFromNddOntIdList(nddOntIdList));
 794:                  }
 795:                  else throw new Exception("OntAndPonName(): Vendor is unknown. ");
 796:   
 797:                  if (switchVendor == Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Vendor.Nokia)
 798:                  {
 799:                      subscriberIdList = Ia.Ngn.Cl.Model.Data.Maintenance.Find.SubscriberIdListFromPartyIdList(partyIdList);
 800:   
 801:                      subPartyIdList = Ia.Ngn.Cl.Model.Data.Maintenance.Find.SubscriberIdListFromPartyIdList(partyIdList);
 802:   
 803:                      agcfEndpointIdList = Ia.Ngn.Cl.Model.Data.Maintenance.Find.AgcfEndpointIdListFromPrividUserList(prividUserList);
 804:   
 805:                      agcfGatewayRecordIdList = Ia.Ngn.Cl.Model.Data.Maintenance.Find.AgcfGatewayRecordIdListFromAgcfEndpointIdList(agcfEndpointIdList);
 806:                      agcfGatewayRecordIdList.AddRange(Ia.Ngn.Cl.Model.Data.Maintenance.Find.AgcfGatewayRecordIdListFromIpList(ipList));
 807:                      agcfGatewayRecordIdList.AddRange(Ia.Ngn.Cl.Model.Data.Maintenance.Find.AgcfGatewayRecordIdListFromNddOntIdList(nddOntIdList));
 808:                      agcfGatewayRecordIdList = agcfGatewayRecordIdList.Distinct().ToList();
 809:                  }
 810:   
 811:                  serviceRequestServiceIdList = Ia.Ngn.Cl.Model.Data.Maintenance.Find.ServiceRequestServiceIdListFromAccessIdList(accessIdList);
 812:   
 813:                  Ia.Ngn.Cl.Model.Data.Maintenance.Find.CollectServiceListFromServiceRequestServiceIdOrService2IdList(serviceRequestServiceIdList, ref serviceList);
 814:                  Ia.Ngn.Cl.Model.Data.Maintenance.Find.SynchronizeNumberFormatLists(ref partyIdList, ref prividUserList, ref serviceList, ref numberList, ref serviceLongList, ref impuSipDomainList);
 815:   
 816:                  serviceInitialStateIdList = Ia.Ngn.Cl.Model.Data.Maintenance.Find.ServiceInitialStateIdListFromServiceList(serviceList);
 817:                  serviceInitialStateIdList.AddRange(Ia.Ngn.Cl.Model.Data.Maintenance.Find.ServiceInitialStateIdListFromAccessIdList(accessIdList));
 818:                  serviceInitialStateIdList = serviceInitialStateIdList.Distinct().ToList();
 819:   
 820:                  reportIdList = Ia.Ngn.Cl.Model.Data.Maintenance.Find.ReportIdListFromServiceList(serviceList);
 821:   
 822:                  service2IdList.AddRange(Ia.Ngn.Cl.Model.Data.Maintenance.Find.ServiceIdListFromServiceList(serviceList));
 823:                  service2IdList = service2IdList.Distinct().ToList();
 824:   
 825:                  serviceRequestIdList = Ia.Ngn.Cl.Model.Data.Maintenance.Find.ServiceRequestIdListFromServiceList(serviceList);
 826:                  serviceRequestTypeIdList = Ia.Ngn.Cl.Model.Data.Maintenance.Find.ServiceRequestTypeIdListFromServiceRequestIdList(serviceRequestIdList);
 827:                  serviceRequestOntIdList = Ia.Ngn.Cl.Model.Data.Maintenance.Find.ServiceRequestOntIdListFromAccessIdList(accessIdList);
 828:   
 829:                  if (switchVendor == Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Vendor.Huawei)
 830:                  {
 831:                      sbrImpuList = Ia.Ngn.Cl.Model.Data.Maintenance.Find.SbrImpuListFromImpuSipDomainList(impuSipDomainList);
 832:   
 833:                      owsbrImpuList = Ia.Ngn.Cl.Model.Data.Maintenance.Find.OwSbrImpuListFromImpuSipDomainList(impuSipDomainList);
 834:                  }
 835:   
 836:                  /////////////////////////////////
 837:   
 838:                  if (switchVendor == Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Vendor.Nokia)
 839:                  {
 840:                      agcfGatewayRecordList = Ia.Ngn.Cl.Model.Data.Maintenance.Find.AgcfGatewayRecordList(agcfGatewayRecordIdList);
 841:                      agcfEndpointList = Ia.Ngn.Cl.Model.Data.Maintenance.Find.AgcfEndpointList(agcfEndpointIdList);
 842:                      subPartyList = Ia.Ngn.Cl.Model.Data.Maintenance.Find.SubPartyList(subPartyIdList);
 843:                      subscriberList = Ia.Ngn.Cl.Model.Data.Maintenance.Find.SubscriberList(subscriberIdList);
 844:                  }
 845:                  else if (switchVendor == Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Vendor.Huawei)
 846:                  {
 847:                      huSbrList = Ia.Ngn.Cl.Model.Data.Maintenance.Find.HuSbrList(sbrImpuList);
 848:                      owsbrList = Ia.Ngn.Cl.Model.Data.Maintenance.Find.OwsbrList(owsbrImpuList);
 849:                  }
 850:                  else throw new Exception("OntAndPonName(): Vendor is unknown. ");
 851:   
 852:                  if (accessVendor == Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Vendor.Nokia)
 853:                  {
 854:                      ontList = Ia.Ngn.Cl.Model.Data.Maintenance.Find.OntList(ontIdList);
 855:                      ontOntPotsList = Ia.Ngn.Cl.Model.Data.Maintenance.Find.OntOntPotsListFromOntOntPotsIdList(ontOntPotsIdList);
 856:                      ontServiceVoipList = Ia.Ngn.Cl.Model.Data.Maintenance.Find.OntServiceVoipList(ontServiceVoipIdList);
 857:                      //eventList = Ia.Ngn.Cl.Model.Data.Maintenance.Find.EventList(eventIdList);
 858:                  }
 859:                  else if (accessVendor == Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Vendor.Huawei)
 860:                  {
 861:                      emsOntList = Ia.Ngn.Cl.Model.Data.Maintenance.Find.EmsOntList(emsOntIdList);
 862:                      emsOntSipInfoList = Ia.Ngn.Cl.Model.Data.Maintenance.Find.EmsOntSipInfoListFromEmsOntIdList(emsOntIdList);
 863:                      emsVoipPstnUserList = Ia.Ngn.Cl.Model.Data.Maintenance.Find.EmsVoipPstnUserListFromEmsOntIdList(emsOntIdList);
 864:                  }
 865:                  else throw new Exception("OntAndPonName(): Vendor is unknown. ");
 866:   
 867:                  service2List = Ia.Ngn.Cl.Model.Data.Maintenance.Find.ServiceList(service2IdList);
 868:   
 869:                  nddOntList = Ia.Ngn.Cl.Model.Data.Maintenance.Find.NddOntList(nddOntIdList);
 870:                  accessList = Ia.Ngn.Cl.Model.Data.Maintenance.Find.AccessList(accessIdList);
 871:   
 872:                  serviceRequestServiceList = Ia.Ngn.Cl.Model.Data.Maintenance.Find.ServiceRequestServiceList(serviceRequestServiceIdList);
 873:                  serviceInitialStateList = Ia.Ngn.Cl.Model.Data.Maintenance.Find.ServiceInitialStateList(serviceInitialStateIdList);
 874:   
 875:                  serviceRequestList = Ia.Ngn.Cl.Model.Data.Maintenance.Find.ServiceRequestList(serviceRequestIdList);
 876:                  serviceRequestTypeList = Ia.Ngn.Cl.Model.Data.Maintenance.Find.ServiceRequestTypeList(serviceRequestTypeIdList);
 877:                  serviceRequestOntList = Ia.Ngn.Cl.Model.Data.Maintenance.Find.ServiceRequestOntList(serviceRequestOntIdList);
 878:                  serviceRequestOntDetailList = Ia.Ngn.Cl.Model.Data.Maintenance.Find.ServiceRequestOntDetailList(serviceRequestOntIdList);
 879:   
 880:                  reportList = Ia.Ngn.Cl.Model.Data.Maintenance.Find.ReportList(reportIdList);
 881:   
 882:                  foreach (var v in serviceList) Ia.Ngn.Cl.Model.Data.Msmq.ServiceQueue.Enqueue(v);
 883:                  foreach (var v in nddOntList) Ia.Ngn.Cl.Model.Data.Msmq.AccessNameQueue.Enqueue(v.Access.Name);
 884:              }
 885:          }
 886:   
 887:          ////////////////////////////////////////////////////////////////////////////
 888:   
 889:          /// <summary>
 890:          ///
 891:          /// </summary>
 892:          public static void Number(Ia.Ngn.Cl.Model.Staff staff, string rowInput,
 893:              out List<Ia.Ngn.Cl.Model.Ui.Service2> service2List,
 894:              out List<Ia.Ngn.Cl.Model.Ui.Nokia.AgcfGatewayRecord> agcfGatewayRecordList,
 895:              out List<Ia.Ngn.Cl.Model.Ui.Nokia.AgcfEndpoint> agcfEndpointList,
 896:              out List<Ia.Ngn.Cl.Model.Ui.Nokia.SubParty> subPartyList,
 897:              out List<Ia.Ngn.Cl.Model.Ui.Nokia.Subscriber> subscriberList,
 898:              out List<Ia.Ngn.Cl.Model.Ui.Huawei.HuSbr> huSbrList,
 899:              out List<Ia.Ngn.Cl.Model.Huawei.Owsbr> owsbrList,
 900:              out List<Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Ont> nddOntList,
 901:              out List<Ia.Ngn.Cl.Model.Ont> ontList,
 902:              out List<Ia.Ngn.Cl.Model.OntServiceVoip> ontServiceVoipList,
 903:              out List<Ia.Ngn.Cl.Model.OntOntPots> ontOntPotsList,
 904:              out List<Ia.Ngn.Cl.Model.Ui.Huawei.EmsOnt> emsOntList,
 905:              out List<Ia.Ngn.Cl.Model.Huawei.EmsOntSipInfo> emsOntSipInfoList,
 906:              out List<Ia.Ngn.Cl.Model.Huawei.EmsVoipPstnUser> emsVoipPstnUserList,
 907:              out List<Ia.Ngn.Cl.Model.Event> eventList,
 908:              out List<Ia.Ngn.Cl.Model.Access> accessList,
 909:              out List<Ia.Ngn.Cl.Model.Ui.ServiceRequestService> serviceRequestServiceList,
 910:              out List<Ia.Ngn.Cl.Model.ServiceInitialState> serviceInitialStateList,
 911:              out List<Ia.Ngn.Cl.Model.ServiceRequest> serviceRequestList,
 912:              out List<Ia.Ngn.Cl.Model.ServiceRequestType> serviceRequestTypeList,
 913:              out List<Ia.Ngn.Cl.Model.ServiceRequestOnt> serviceRequestOntList,
 914:              out List<Ia.Ngn.Cl.Model.ServiceRequestOntDetail> serviceRequestOntDetailList,
 915:              out List<Ia.Ngn.Cl.Model.Report> reportList,
 916:              out List<Ia.Ngn.Cl.Model.ReportHistory> reportHistoryList,
 917:              out Ia.Cl.Model.Result result)
 918:          {
 919:              string input, service;
 920:              List<int> serviceRequestIdList, serviceRequestTypeIdList, agcfGatewayRecordIdList, reportIdList, numberList;
 921:              List<long> serviceLongList, eventIdList;
 922:              List<string> accessIdList, nddOntIdList, ipList, sbrImpuList, owsbrImpuList, partyIdList, prividUserList, serviceList, serviceRequestServiceIdList, serviceInitialStateIdList, serviceRequestOntIdList, service2IdList, impuSipDomainList, ontIdList, ontOntPotsIdList, ontServiceVoipIdList, emsOntIdList, agcfEndpointIdList, subPartyIdList, subscriberIdList, ontServiceVoipIpList, emsOntIpList;
 923:              Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Vendor accessVendor, switchVendor;
 924:   
 925:              serviceLongList = new List<long>();
 926:              numberList = new List<int>();
 927:              serviceList = new List<string>();
 928:              partyIdList = new List<string>();
 929:              prividUserList = new List<string>();
 930:              impuSipDomainList = new List<string>();
 931:              serviceRequestIdList = new List<int>();
 932:              accessIdList = new List<string>();
 933:              nddOntIdList = new List<string>();
 934:              ontIdList = new List<string>();
 935:              agcfGatewayRecordIdList = new List<int>();
 936:              ipList = new List<string>();
 937:              agcfEndpointIdList = new List<string>();
 938:              subPartyIdList = new List<string>();
 939:              subscriberIdList = new List<string>();
 940:              sbrImpuList = new List<string>();
 941:              owsbrImpuList = new List<string>();
 942:              ontOntPotsIdList = new List<string>();
 943:              ontServiceVoipIdList = new List<string>();
 944:              eventIdList = new List<long>();
 945:              emsOntIdList = new List<string>();
 946:              ipList = new List<string>();
 947:   
 948:              result = new Ia.Cl.Model.Result();
 949:   
 950:              service2List = null;
 951:              agcfGatewayRecordList = null;
 952:              agcfEndpointList = null;
 953:              subPartyList = null;
 954:              subscriberList = null;
 955:              huSbrList = null;
 956:              owsbrList = null;
 957:              nddOntList = null;
 958:              ontList = null;
 959:              ontServiceVoipList = null;
 960:              ontOntPotsList = null;
 961:              emsOntList = null;
 962:              emsOntSipInfoList = null;
 963:              emsVoipPstnUserList = null;
 964:              eventList = null;
 965:              accessList = null;
 966:              serviceRequestServiceList = null;
 967:              serviceInitialStateList = null;
 968:              serviceRequestList = null;
 969:              serviceRequestTypeList = null;
 970:              serviceRequestOntList = null;
 971:              serviceRequestOntDetailList = null;
 972:              reportList = null;
 973:              reportHistoryList = null;
 974:   
 975:              input = rowInput.ToLower();
 976:   
 977:              service = Ia.Ngn.Cl.Model.Business.NumberFormatConverter.Service(input);
 978:   
 979:              if (Ia.Ngn.Cl.Model.Business.Service.NumberIsWithinAllowedDomainList(service))
 980:              {
 981:                  if (Ia.Ngn.Cl.Model.Business.Authority.NumberIsWithinStaffSiteDomainList(staff, service))
 982:                  {
 983:                      serviceList.Add(service);
 984:   
 985:                      switchVendor = Ia.Ngn.Cl.Model.Business.Service.SwitchVendor(service);
 986:   
 987:                      try
 988:                      {
 989:                          using (var db = new Ia.Ngn.Cl.Model.Ngn())
 990:                          {
 991:                              Ia.Ngn.Cl.Model.Data.Maintenance.Find.SynchronizeNumberFormatLists(ref partyIdList, ref prividUserList, ref serviceList, ref numberList, ref serviceLongList, ref impuSipDomainList);
 992:   
 993:                              service2IdList = Ia.Ngn.Cl.Model.Data.Maintenance.Find.ServiceIdListFromServiceList(serviceList);
 994:   
 995:                              if (switchVendor == Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Vendor.Nokia)
 996:                              {
 997:                                  subscriberIdList = Ia.Ngn.Cl.Model.Data.Maintenance.Find.SubscriberIdListFromPartyIdList(partyIdList);
 998:   
 999:                                  subPartyIdList = Ia.Ngn.Cl.Model.Data.Maintenance.Find.SubscriberIdListFromPartyIdList(partyIdList);
1000:   
1001:                                  agcfEndpointIdList = Ia.Ngn.Cl.Model.Data.Maintenance.Find.AgcfEndpointIdListFromPrividUserList(prividUserList);
1002:   
1003:                                  agcfGatewayRecordIdList = Ia.Ngn.Cl.Model.Data.Maintenance.Find.AgcfGatewayRecordIdListFromAgcfEndpointIdList(agcfEndpointIdList);
1004:                              }
1005:                              else if (switchVendor == Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Vendor.Huawei)
1006:                              {
1007:                                  sbrImpuList = Ia.Ngn.Cl.Model.Data.Maintenance.Find.SbrImpuListFromImpuSipDomainList(impuSipDomainList);
1008:   
1009:                                  owsbrImpuList = Ia.Ngn.Cl.Model.Data.Maintenance.Find.OwSbrImpuListFromImpuSipDomainList(impuSipDomainList);
1010:                              }
1011:                              else throw new Exception("Number(): Vendor is unknown. ");
1012:   
1013:                              serviceRequestServiceIdList = Ia.Ngn.Cl.Model.Data.Maintenance.Find.ServiceRequestServiceIdListFromServiceList(serviceList);
1014:   
1015:                              accessIdList = Ia.Ngn.Cl.Model.Data.Maintenance.Find.AccessIdListFromServiceList(serviceList);
1016:                              accessIdList.AddRange(Ia.Ngn.Cl.Model.Data.Maintenance.Find.AccessIdListFromServiceRequestServiceIdList(serviceRequestServiceIdList));
1017:                              accessIdList = accessIdList.Distinct().ToList();
1018:   
1019:                              Ia.Ngn.Cl.Model.Data.Maintenance.Find.CollectServiceListFromServiceRequestServiceIdOrService2IdList(service2IdList, ref serviceList);
1020:                              Ia.Ngn.Cl.Model.Data.Maintenance.Find.SynchronizeNumberFormatLists(ref partyIdList, ref prividUserList, ref serviceList, ref numberList, ref serviceLongList, ref impuSipDomainList);
1021:   
1022:                              serviceInitialStateIdList = Ia.Ngn.Cl.Model.Data.Maintenance.Find.ServiceInitialStateIdListFromServiceList(serviceList);
1023:                              serviceInitialStateIdList.AddRange(Ia.Ngn.Cl.Model.Data.Maintenance.Find.ServiceInitialStateIdListFromAccessIdList(accessIdList));
1024:                              serviceInitialStateIdList = serviceInitialStateIdList.Distinct().ToList();
1025:   
1026:                              reportIdList = Ia.Ngn.Cl.Model.Data.Maintenance.Find.ReportIdListFromServiceList(serviceList);
1027:   
1028:                              serviceRequestIdList = Ia.Ngn.Cl.Model.Data.Maintenance.Find.ServiceRequestIdListFromServiceList(serviceList);
1029:                              serviceRequestTypeIdList = Ia.Ngn.Cl.Model.Data.Maintenance.Find.ServiceRequestTypeIdListFromServiceRequestIdList(serviceRequestIdList);
1030:                              serviceRequestOntIdList = Ia.Ngn.Cl.Model.Data.Maintenance.Find.ServiceRequestOntIdListFromAccessIdList(accessIdList);
1031:   
1032:                              nddOntIdList.AddRange(Ia.Ngn.Cl.Model.Data.Maintenance.Find.NddOntIdListFromAccessIdList(accessIdList));
1033:                              nddOntIdList = nddOntIdList.Distinct().ToList();
1034:   
1035:                              if (nddOntIdList.Count > 0) accessVendor = Ia.Ngn.Cl.Model.Data.NetworkDesignDocument.AccessVendorByOntId(nddOntIdList[0]);
1036:                              else accessVendor = Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Vendor.Undefined;
1037:   
1038:                              if (accessVendor == Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Vendor.Nokia)
1039:                              {
1040:                                  ontIdList = Ia.Ngn.Cl.Model.Data.Maintenance.Find.OntIdListFromNddOntIdList(nddOntIdList);
1041:   
1042:                                  ontOntPotsIdList = Ia.Ngn.Cl.Model.Data.Maintenance.Find.OntOntPotsIdListFromOntIdList(ontIdList);
1043:   
1044:                                  ontServiceVoipIdList = Ia.Ngn.Cl.Model.Data.Maintenance.Find.OntServiceVoipsIdListFromOntIdList(ontIdList);
1045:   
1046:                                  ontServiceVoipIpList = Ia.Ngn.Cl.Model.Data.Maintenance.Find.OntServiceVoipIpList(ontServiceVoipIdList);
1047:   
1048:                                  ipList.AddRange(ontServiceVoipIpList);
1049:   
1050:                                  //eventIdList = Ia.Ngn.Cl.Model.Data.Maintenance.Find.EventIdListFromOntIdList(ontIdList);
1051:                              }
1052:                              else if (accessVendor == Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Vendor.Huawei)
1053:                              {
1054:                                  emsOntIdList = Ia.Ngn.Cl.Model.Data.Maintenance.Find.EmsOntIdListFromNddOntIdList(nddOntIdList);
1055:   
1056:                                  ipList.AddRange(Ia.Ngn.Cl.Model.Data.Maintenance.Find.EmsOntIpListFromNddOntIdList(nddOntIdList));
1057:                              }
1058:   
1059:                              /////////////////////////////////
1060:   
1061:                              if (switchVendor == Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Vendor.Nokia)
1062:                              {
1063:                                  agcfGatewayRecordList = Ia.Ngn.Cl.Model.Data.Maintenance.Find.AgcfGatewayRecordList(agcfGatewayRecordIdList);
1064:                                  agcfEndpointList = Ia.Ngn.Cl.Model.Data.Maintenance.Find.AgcfEndpointList(agcfEndpointIdList);
1065:                                  subPartyList = Ia.Ngn.Cl.Model.Data.Maintenance.Find.SubPartyList(subPartyIdList);
1066:                                  subscriberList = Ia.Ngn.Cl.Model.Data.Maintenance.Find.SubscriberList(subscriberIdList);
1067:                              }
1068:                              else if (switchVendor == Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Vendor.Huawei)
1069:                              {
1070:                                  huSbrList = Ia.Ngn.Cl.Model.Data.Maintenance.Find.HuSbrList(sbrImpuList);
1071:                                  owsbrList = Ia.Ngn.Cl.Model.Data.Maintenance.Find.OwsbrList(owsbrImpuList);
1072:                              }
1073:                              else throw new Exception("OntAndPonName(): Vendor is unknown. ");
1074:   
1075:                              if (accessVendor == Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Vendor.Nokia)
1076:                              {
1077:                                  ontList = Ia.Ngn.Cl.Model.Data.Maintenance.Find.OntList(ontIdList);
1078:                                  ontOntPotsList = Ia.Ngn.Cl.Model.Data.Maintenance.Find.OntOntPotsListFromOntOntPotsIdList(ontOntPotsIdList);
1079:                                  ontServiceVoipList = Ia.Ngn.Cl.Model.Data.Maintenance.Find.OntServiceVoipList(ontServiceVoipIdList);
1080:                                  //eventList = Ia.Ngn.Cl.Model.Data.Maintenance.Find.EventList(eventIdList);
1081:                              }
1082:                              else if (accessVendor == Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Vendor.Huawei)
1083:                              {
1084:                                  emsOntList = Ia.Ngn.Cl.Model.Data.Maintenance.Find.EmsOntList(emsOntIdList);
1085:                                  emsOntSipInfoList = Ia.Ngn.Cl.Model.Data.Maintenance.Find.EmsOntSipInfoListFromEmsOntIdList(emsOntIdList);
1086:                                  emsVoipPstnUserList = Ia.Ngn.Cl.Model.Data.Maintenance.Find.EmsVoipPstnUserListFromEmsOntIdList(emsOntIdList);
1087:                              }
1088:                              //else throw new Exception("OntAndPonName(): Vendor is unknown. ");
1089:   
1090:                              service2List = Ia.Ngn.Cl.Model.Data.Maintenance.Find.ServiceList(service2IdList);
1091:   
1092:                              nddOntList = Ia.Ngn.Cl.Model.Data.Maintenance.Find.NddOntList(nddOntIdList);
1093:                              accessList = Ia.Ngn.Cl.Model.Data.Maintenance.Find.AccessList(accessIdList);
1094:   
1095:                              serviceRequestServiceList = Ia.Ngn.Cl.Model.Data.Maintenance.Find.ServiceRequestServiceList(serviceRequestServiceIdList);
1096:                              serviceInitialStateList = Ia.Ngn.Cl.Model.Data.Maintenance.Find.ServiceInitialStateList(serviceInitialStateIdList);
1097:   
1098:                              serviceRequestList = Ia.Ngn.Cl.Model.Data.Maintenance.Find.ServiceRequestList(serviceRequestIdList);
1099:                              serviceRequestTypeList = Ia.Ngn.Cl.Model.Data.Maintenance.Find.ServiceRequestTypeList(serviceRequestTypeIdList);
1100:                              serviceRequestOntList = Ia.Ngn.Cl.Model.Data.Maintenance.Find.ServiceRequestOntList(serviceRequestOntIdList);
1101:                              serviceRequestOntDetailList = Ia.Ngn.Cl.Model.Data.Maintenance.Find.ServiceRequestOntDetailList(serviceRequestOntIdList);
1102:   
1103:                              reportList = Ia.Ngn.Cl.Model.Data.Maintenance.Find.ReportList(reportIdList);
1104:   
1105:                              foreach (var v in serviceList) Ia.Ngn.Cl.Model.Data.Msmq.ServiceQueue.Enqueue(v);
1106:                              foreach (var v in nddOntList) Ia.Ngn.Cl.Model.Data.Msmq.AccessNameQueue.Enqueue(v.Access.Name);
1107:                          }
1108:                      }
1109:                      catch (Exception ex)
1110:                      {
1111:                          result.AddError("Exception: Retrieval error of data for \"" + rowInput + "\": " + ex.ToString());
1112:                      }
1113:                  }
1114:                  else
1115:                  {
1116:                      result.AddError("Number " + service + " is not in staff site domain (الرقم لا ينتمي لنطاقات المستخدم). ");
1117:                  }
1118:              }
1119:              else
1120:              {
1121:                  result.AddError("The number \"" + rowInput + "\" does not belong to the network (الرقم لا ينتمي للشبكة). ");
1122:              }
1123:          }
1124:   
1125:          ////////////////////////////////////////////////////////////////////////////
1126:          ////////////////////////////////////////////////////////////////////////////
1127:   
1128:          /// <summary>
1129:          ///
1130:          /// </summary>
1131:          public static void Serial(string rowInput,
1132:              out List<Ia.Ngn.Cl.Model.Ui.Service2> service2List,
1133:              out List<Ia.Ngn.Cl.Model.Ui.Nokia.AgcfGatewayRecord> agcfGatewayRecordList,
1134:              out List<Ia.Ngn.Cl.Model.Ui.Nokia.AgcfEndpoint> agcfEndpointList,
1135:              out List<Ia.Ngn.Cl.Model.Ui.Nokia.SubParty> subPartyList,
1136:              out List<Ia.Ngn.Cl.Model.Ui.Nokia.Subscriber> subscriberList,
1137:              out List<Ia.Ngn.Cl.Model.Ui.Huawei.HuSbr> huSbrList,
1138:              out List<Ia.Ngn.Cl.Model.Huawei.Owsbr> owsbrList,
1139:              out List<Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Ont> nddOntList,
1140:              out List<Ia.Ngn.Cl.Model.Ont> ontList,
1141:              out List<Ia.Ngn.Cl.Model.OntServiceVoip> ontServiceVoipList,
1142:              out List<Ia.Ngn.Cl.Model.OntOntPots> ontOntPotsList,
1143:              out List<Ia.Ngn.Cl.Model.Ui.Huawei.EmsOnt> emsOntList,
1144:              out List<Ia.Ngn.Cl.Model.Huawei.EmsOntSipInfo> emsOntSipInfoList,
1145:              out List<Ia.Ngn.Cl.Model.Huawei.EmsVoipPstnUser> emsVoipPstnUserList,
1146:              out List<Ia.Ngn.Cl.Model.Event> eventList,
1147:              out List<Ia.Ngn.Cl.Model.Access> accessList,
1148:              out List<Ia.Ngn.Cl.Model.Ui.ServiceRequestService> serviceRequestServiceList,
1149:              out List<Ia.Ngn.Cl.Model.ServiceInitialState> serviceInitialStateList,
1150:              out List<Ia.Ngn.Cl.Model.ServiceRequest> serviceRequestList,
1151:              out List<Ia.Ngn.Cl.Model.ServiceRequestType> serviceRequestTypeList,
1152:              out List<Ia.Ngn.Cl.Model.ServiceRequestOnt> serviceRequestOntList,
1153:              out List<Ia.Ngn.Cl.Model.ServiceRequestOntDetail> serviceRequestOntDetailList,
1154:              out List<Ia.Ngn.Cl.Model.Report> reportList,
1155:              out List<Ia.Ngn.Cl.Model.ReportHistory> reportHistoryList,
1156:              out Ia.Cl.Model.Result result)
1157:          {
1158:              string input;
1159:              int number;
1160:              long numberWithCountryCode;
1161:              string numberString, partyId;
1162:              Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Vendor accessVendor, switchVendor;
1163:              List<int> agcfGatewayRecordIdList, numberList;
1164:              List<long> serviceLongList;
1165:              List<string> serviceList, service2IdList, impuSipDomainList, accessIdList, ontIdList, partyIdList, prividUserList, serviceRequestServiceIdList;
1166:   
1167:              service2IdList = new List<string>();
1168:              accessIdList = new List<string>();
1169:              ontIdList = new List<string>();
1170:              agcfGatewayRecordIdList = new List<int>();
1171:              numberList = new List<int>();
1172:              serviceLongList = new List<long>();
1173:              impuSipDomainList = new List<string>();
1174:              serviceList = new List<string>();
1175:              partyIdList = new List<string>();
1176:              prividUserList = new List<string>();
1177:   
1178:              result = new Ia.Cl.Model.Result();
1179:   
1180:              service2List = null;
1181:   
1182:              agcfGatewayRecordList = null;
1183:              agcfEndpointList = null;
1184:              subPartyList = null;
1185:              subscriberList = null;
1186:   
1187:              huSbrList = null;
1188:              owsbrList = null;
1189:   
1190:              nddOntList = null;
1191:              ontList = null;
1192:              ontServiceVoipList = null;
1193:              ontOntPotsList = null;
1194:              emsOntList = null;
1195:              emsOntSipInfoList = null;
1196:              emsVoipPstnUserList = null;
1197:              eventList = null;
1198:              accessList = null;
1199:              serviceRequestServiceList = null;
1200:              serviceInitialStateList = null;
1201:              serviceRequestList = null;
1202:              serviceRequestTypeList = null;
1203:              serviceRequestOntList = null;
1204:              serviceRequestOntDetailList = null;
1205:              reportList = null;
1206:              reportHistoryList = null;
1207:   
1208:              input = rowInput.ToLower();
1209:   
1210:              if (Ia.Ngn.Cl.Model.Business.Nokia.Ont.IsValidSerialNumber(input))
1211:              {
1212:                  accessVendor = Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Vendor.Nokia;
1213:              }
1214:              else if (Ia.Ngn.Cl.Model.Business.Huawei.Ont.IsValidSerialNumber(input))
1215:              {
1216:                  accessVendor = Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Vendor.Huawei;
1217:              }
1218:              else
1219:              {
1220:                  accessVendor = Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Vendor.Undefined;
1221:              }
1222:   
1223:              try
1224:              {
1225:                  using (var db = new Ia.Ngn.Cl.Model.Ngn())
1226:                  {
1227:                      if (accessVendor != Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Vendor.Undefined)
1228:                      {
1229:                          if (accessVendor == Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Vendor.Nokia)
1230:                          {
1231:                              ontList = (from o in db.Onts where o.Serial == input select o).ToList();
1232:                              foreach (var v in ontList) ontIdList.Add(v.Id);
1233:                              ontIdList = ontIdList.Distinct().ToList();
1234:   
1235:                              ontOntPotsList = (from op in db.OntOntPotses join oid in ontIdList on op.Ont.Id equals oid select op).ToList();
1236:                              ontServiceVoipList = (from ov in db.OntServiceVoips join oid in ontIdList on ov.Ont.Id equals oid select ov).ToList();
1237:                          }
1238:                          else if (accessVendor == Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Vendor.Huawei)
1239:                          {
1240:                              ontList = (from o in db.Onts where o.Serial == input select o).ToList();
1241:                              foreach (var v in ontList) ontIdList.Add(v.Id);
1242:                              ontIdList = ontIdList.Distinct().ToList();
1243:                          }
1244:   
1245:                          foreach (var v in ontList) if (v.Access != null) accessIdList.Add(v.Access.Id);
1246:                          accessIdList = accessIdList.Distinct().ToList();
1247:   
1248:   
1249:                          nddOntList = (from nddo in Ia.Ngn.Cl.Model.Data.NetworkDesignDocument.OntList
1250:                                        join aid in accessIdList on nddo.Access.Id equals aid
1251:                                        select nddo)
1252:                                        .Union(
1253:                                        from nddo in Ia.Ngn.Cl.Model.Data.NetworkDesignDocument.OntList
1254:                                        join oid in ontIdList on nddo.Id equals oid
1255:                                        select nddo
1256:                                        ).ToList();
1257:                          foreach (var v in nddOntList)
1258:                          {
1259:                              ontIdList.Add(v.Id);
1260:   
1261:                              //eventSystemList.Add(v.Pon.PonGroup.Olt.AmsName);
1262:                              //eventAidOntList.Add("ONT-1-1-" + v.Card + "-" + v.Port + "-" + v.Number);
1263:                              //eventAidOntVoipList.Add("ONTVOIP-1-1-" + v.Card + "-" + v.Port + "-1");
1264:   
1265:                              //foreach (var w in ontOntPotsList) eventAidOntPotsList.Add("ONTPOTS-1-1-" + v.Card + "-" + v.Port + "-" + w.Card + "-" + w.Port);
1266:                          }
1267:                          ontIdList = ontIdList.Distinct().ToList();
1268:                          //eventSystemList = eventSystemList.Distinct().ToList();
1269:                          //eventAidOntList = eventAidOntList.Distinct().ToList();
1270:                          //eventAidOntVoipList = eventAidOntVoipList.Distinct().ToList();
1271:   
1272:                          /*
1273:                          eventList = (from e in db.Events join es in eventSystemList on e.System equals es join eao in eventAidOntList on e.Aid equals eao select e)
1274:                                      .Union(from e in db.Events join es in eventSystemList on e.System equals es join eao in eventAidOntList on e.Aid equals eao join eaov in eventAidOntVoipList on e.Aid equals eaov select e)
1275:                                      .Union(from e in db.Events join es in eventSystemList on e.System equals es join eao in eventAidOntList on e.Aid equals eao join eaop in eventAidOntPotsList on e.Aid equals eaop select e)
1276:                                      .ToList();
1277:                                      */
1278:   
1279:                          accessList = (from a in db.Accesses join aid in accessIdList on a.Id equals aid select a).ToList();
1280:   
1281:                          serviceRequestServiceList = (from srs in db.ServiceRequestServices
1282:                                                       join aid in accessIdList on srs.Access.Id equals aid
1283:                                                       select new Ia.Ngn.Cl.Model.Ui.ServiceRequestService()
1284:                                                       {
1285:                                                           Id = srs.Id,
1286:                                                           AbbriviatedCalling = srs.AbbriviatedCalling,
1287:                                                           Access = srs.Access,
1288:                                                           AlarmCall = srs.AlarmCall,
1289:                                                           CallBarring = srs.CallBarring,
1290:                                                           CallerId = srs.CallerId,
1291:                                                           CallForwarding = srs.CallForwarding,
1292:                                                           CallWaiting = srs.CallWaiting,
1293:                                                           ConferenceCall = srs.ConferenceCall,
1294:                                                           Created = srs.Created,
1295:                                                           InternationalCalling = srs.InternationalCalling,
1296:                                                           InternationalCallingUserControlled = srs.InternationalCallingUserControlled,
1297:                                                           LastRequestDateTime = srs.LastRequestDateTime,
1298:                                                           Provisioned = srs.Provisioned,
1299:                                                           Service = srs.Service,
1300:                                                           ServiceType = srs.ServiceType,
1301:                                                           ServiceSuspension = srs.ServiceSuspension,
1302:                                                           Type = srs.Type,
1303:                                                           Updated = srs.Updated
1304:                                                       }).ToList();
1305:   
1306:                          serviceInitialStateList = (from sis in db.ServiceInitialStates
1307:                                                     join aid in accessIdList on sis.Access.Id equals aid
1308:                                                     select sis).ToList();
1309:   
1310:                          serviceRequestServiceIdList = (from srs in serviceRequestServiceList select srs.Id).ToList();
1311:   
1312:                          Ia.Ngn.Cl.Model.Data.Maintenance.Find.CollectServiceListFromServiceRequestServiceIdOrService2IdList(service2IdList, ref serviceList);
1313:                          Ia.Ngn.Cl.Model.Data.Maintenance.Find.SynchronizeNumberFormatLists(ref partyIdList, ref prividUserList, ref serviceList, ref numberList, ref serviceLongList, ref impuSipDomainList);
1314:   
1315:                          service2List = (from s in db.Service2s
1316:                                          join ns in serviceList on s.Service equals ns
1317:                                          select new Ia.Ngn.Cl.Model.Ui.Service2()
1318:                                          {
1319:                                              AbbriviatedCalling = s.AbbriviatedCalling,
1320:                                              AlarmCall = s.AlarmCall,
1321:                                              CallBarring = s.CallBarring,
1322:                                              CallerId = s.CallerId,
1323:                                              CallForwarding = s.CallForwarding,
1324:                                              CallWaiting = s.CallWaiting,
1325:                                              ConferenceCall = s.ConferenceCall,
1326:                                              Created = s.Created,
1327:                                              InternationalCalling = s.InternationalCalling,
1328:                                              InternationalCallingUserControlled = s.InternationalCallingUserControlled,
1329:                                              LineCard = s.LineCard,
1330:                                              Pin = s.Pin,
1331:                                              Service = s.Service,
1332:                                              ServiceType = s.ServiceType,
1333:                                              ServiceSuspension = s.ServiceSuspension,
1334:                                              ServiceTypeName = s.ServiceType.ToString(),
1335:                                              Updated = s.Updated,
1336:                                              AccessId = s.Access.Id
1337:                                          }).ToList();
1338:   
1339:                          agcfGatewayRecordList = (from gr in db.AgcfGatewayRecords
1340:                                                   join e in db.AgcfEndpoints on gr equals e.AgcfGatewayRecord
1341:                                                   join sp in db.SubParties on e equals sp.AgcfEndpoint
1342:                                                   join p in partyIdList on sp.PartyId equals p
1343:                                                   select new Ia.Ngn.Cl.Model.Ui.Nokia.AgcfGatewayRecord()
1344:                                                   {
1345:                                                       Id = gr.Id,
1346:                                                       GwId = gr.GwId,
1347:                                                       GwUserId = gr.GwUserId,
1348:                                                       GwDomain = gr.GwDomain,
1349:                                                       GwName = gr.GwName,
1350:                                                       IP1 = gr.IP1,
1351:                                                       IP2 = gr.IP2,
1352:                                                       MateExternalIPAddr = gr.MateExternalIPAddr,
1353:                                                       IsPrimary = gr.IsPrimary,
1354:                                                       Created = gr.Created,
1355:                                                       Updated = gr.Updated
1356:                                                   }).ToList();
1357:                          foreach (var v in agcfGatewayRecordList) agcfGatewayRecordIdList.Add(v.Id);
1358:                          agcfGatewayRecordIdList = agcfGatewayRecordIdList.Distinct().ToList();
1359:   
1360:                          agcfEndpointList = (from e in db.AgcfEndpoints
1361:                                              join grid in agcfGatewayRecordIdList on e.AgcfGatewayRecord.Id equals grid
1362:                                              select new Ia.Ngn.Cl.Model.Ui.Nokia.AgcfEndpoint()
1363:                                              {
1364:                                                  Id = e.Id,
1365:                                                  PrividUser = e.PrividUser,
1366:                                                  GwId = e.GwId,
1367:                                                  Dn = e.Dn,
1368:                                                  FlatTermID = e.FlatTermID,
1369:                                                  CallHoldLc = e.CallHoldLc,
1370:                                                  CallWaitingLc = e.CallWaitingLc,
1371:                                                  CallToggleLc = e.CallToggleLc,
1372:                                                  ThreeWayCallLc = e.ThreeWayCallLc,
1373:                                                  McidLc = e.McidLc,
1374:                                                  Password = e.Password,
1375:                                                  CallTransferLc = e.CallTransferLc,
1376:                                                  Created = e.Created,
1377:                                                  Updated = e.Updated
1378:                                              }).ToList();
1379:   
1380:                          subscriberList = (from s in db.Subscribers
1381:                                            join p in partyIdList on s.PartyId equals p
1382:                                            select s).AsEnumerable().Select(s => new Ia.Ngn.Cl.Model.Ui.Nokia.Subscriber()
1383:                                            {
1384:                                                Id = s.Id,
1385:                                                AlternateOtasRealm = s.AlternateOtasRealm,
1386:                                                PartyId = s.PartyId,
1387:                                                AbbriviatedCalling = Ia.Ngn.Cl.Model.Business.Nokia.Subscriber.OneDigitSpeedDialIsAssigned(s._OneDigitSpeedDial),
1388:                                                AlarmCall = Ia.Ngn.Cl.Model.Business.Nokia.Subscriber.ReminderCallIsAssigned(s._ReminderCall),
1389:                                                CallerId = Ia.Ngn.Cl.Model.Business.Nokia.Subscriber.CallingLineIdIsAssigned(s._CallingLineId),
1390:                                                CallForwarding = Ia.Ngn.Cl.Model.Business.Nokia.Subscriber.CallForwardingIsAssigned(s._CallForwardingVari),
1391:                                                CallWaiting = Ia.Ngn.Cl.Model.Business.Nokia.Subscriber.CallWaitingIsAssigned(s._CallWaiting, false),
1392:                                                ConferenceCall = Ia.Ngn.Cl.Model.Business.Nokia.Subscriber.ConferenceCallIsAssigned(s._ConferenceCalling),
1393:                                                InternationalCalling = Ia.Ngn.Cl.Model.Business.Nokia.Subscriber.InternationalCallingIsAssigned(s._CallBarring),
1394:                                                InternationalCallingUserControlled = Ia.Ngn.Cl.Model.Business.Nokia.Subscriber.InternationalCallingUserControlledIsAssigned(s._OutgoingCallBarring),
1395:                                                //ServiceSuspention = Ia.Ngn.Cl.Model.Business.Nokia.Subscriber.ServiceSuspentionIsAssigned(s._ServiceSuspention),
1396:                                                Created = s.Created,
1397:                                                Updated = s.Updated,
1398:                                            }).ToList();
1399:   
1400:                          subPartyList = (from sp in db.SubParties
1401:                                          join p in partyIdList on sp.PartyId equals p
1402:                                          select new Ia.Ngn.Cl.Model.Ui.Nokia.SubParty()
1403:                                          {
1404:                                              Id = sp.Id,
1405:                                              PartyId = sp.PartyId,
1406:                                              PrimaryPUIDCPEProfileNumber = sp.PrimaryPUIDCPEProfileNumber,
1407:                                              DisplayName = sp.DisplayName,
1408:                                              Category = sp.Category,
1409:                                              AssocOtasRealm = sp.AssocOtasRealm,
1410:                                              ServiceSuspension = sp.ServiceSuspension,
1411:                                              Created = sp.Created,
1412:                                              Updated = sp.Updated
1413:                                          }).ToList();
1414:   
1415:                          huSbrList = (from h in db.HuSbrs
1416:                                       join i in impuSipDomainList on h.IMPU equals i
1417:                                       select new Ia.Ngn.Cl.Model.Ui.Huawei.HuSbr()
1418:                                       {
1419:                                           COP = h.COP,
1420:                                           CSC = h.CSC,
1421:                                           Id = h.Id,
1422:                                           IMPU = h.IMPU,
1423:                                           ITT = h.ITT,
1424:                                           LP = h.LP,
1425:                                           NS3PTY = h.NS3PTY,
1426:                                           NSABRC = h.NSABRC,
1427:                                           NSCBA = h.NSCBA,
1428:                                           NSCFU = h.NSCFU,
1429:                                           NSCLIP = h.NSCLIP,
1430:                                           NSCW = h.NSCW,
1431:                                           NSFAX = h.NSFAX,
1432:                                           NSHOLD = h.NSHOLD,
1433:                                           NSNPTY = h.NSNPTY,
1434:                                           NSWAKE_UP = h.NSWAKE_UP,
1435:                                           Created = h.Created,
1436:                                           Updated = h.Updated
1437:                                       }).ToList();
1438:   
1439:                          owsbrList = (from o in db.Owsbrs join i in impuSipDomainList on o.IMPU equals i select o).ToList();
1440:   
1441:                          serviceRequestList = (from sr in db.ServiceRequests join n in numberList on sr.Number equals n select sr).ToList();
1442:                          serviceRequestTypeList = (from srt in db.ServiceRequestTypes join sr in db.ServiceRequests on srt.ServiceRequest equals sr join n in numberList on sr.Number equals n select srt).ToList();
1443:   
1444:                          reportList = (from r in db.Reports join sl in service2IdList on r.Service equals sl select r).Include(x => x.ReportHistories).ToList();
1445:                      }
1446:                      else
1447:                      {
1448:                          throw new Exception("ONT serial vendor undefined. ");
1449:                      }
1450:                  }
1451:              }
1452:              catch (Exception ex)
1453:              {
1454:                  result.AddError("Exception: Retrieval error of data for \"" + rowInput + "\": " + ex.ToString());
1455:              }
1456:          }
1457:   
1458:          ////////////////////////////////////////////////////////////////////////////
1459:   
1460:          /// <summary>
1461:          ///
1462:          /// </summary>
1463:          public static void Ip(string rowInput,
1464:              out List<Ia.Ngn.Cl.Model.Ui.Service2> service2List,
1465:              out List<Ia.Ngn.Cl.Model.Ui.Nokia.AgcfGatewayRecord> agcfGatewayRecordList,
1466:              out List<Ia.Ngn.Cl.Model.Ui.Nokia.AgcfEndpoint> agcfEndpointList,
1467:              out List<Ia.Ngn.Cl.Model.Ui.Nokia.SubParty> subPartyList,
1468:              out List<Ia.Ngn.Cl.Model.Ui.Nokia.Subscriber> subscriberList,
1469:              out List<Ia.Ngn.Cl.Model.Ui.Huawei.HuSbr> huSbrList,
1470:              out List<Ia.Ngn.Cl.Model.Huawei.Owsbr> owsbrList,
1471:              out List<Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Ont> nddOntList,
1472:              out List<Ia.Ngn.Cl.Model.Ont> ontList,
1473:              out List<Ia.Ngn.Cl.Model.OntServiceVoip> ontServiceVoipList,
1474:              out List<Ia.Ngn.Cl.Model.OntOntPots> ontOntPotsList,
1475:              out List<Ia.Ngn.Cl.Model.Ui.Huawei.EmsOnt> emsOntList,
1476:              out List<Ia.Ngn.Cl.Model.Huawei.EmsOntSipInfo> emsOntSipInfoList,
1477:              out List<Ia.Ngn.Cl.Model.Huawei.EmsVoipPstnUser> emsVoipPstnUserList,
1478:              out List<Ia.Ngn.Cl.Model.Event> eventList,
1479:              out List<Ia.Ngn.Cl.Model.Access> accessList,
1480:              out List<Ia.Ngn.Cl.Model.Ui.ServiceRequestService> serviceRequestServiceList,
1481:              out List<Ia.Ngn.Cl.Model.ServiceInitialState> serviceInitialStateList,
1482:              out List<Ia.Ngn.Cl.Model.ServiceRequest> serviceRequestList,
1483:              out List<Ia.Ngn.Cl.Model.ServiceRequestType> serviceRequestTypeList,
1484:              out List<Ia.Ngn.Cl.Model.ServiceRequestOnt> serviceRequestOntList,
1485:              out List<Ia.Ngn.Cl.Model.ServiceRequestOntDetail> serviceRequestOntDetailList,
1486:              out List<Ia.Ngn.Cl.Model.Report> reportList,
1487:              out List<Ia.Ngn.Cl.Model.ReportHistory> reportHistoryList,
1488:              out Ia.Cl.Model.Result result)
1489:          {
1490:              string input;
1491:              int number;
1492:              long numberWithCountryCode;
1493:              string numberString, partyId;
1494:              Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Vendor accessVendor, switchVendor;
1495:              List<int> agcfGatewayRecordIdList, numberList;
1496:              List<long> serviceLongList;
1497:              List<string> serviceList, service2IdList, impuSipDomainList, accessIdList, ontIdList, partyIdList, agcfEndpointIdList;
1498:   
1499:              service2IdList = new List<string>();
1500:              accessIdList = new List<string>();
1501:              ontIdList = new List<string>();
1502:              agcfGatewayRecordIdList = new List<int>();
1503:              numberList = new List<int>();
1504:              serviceLongList = new List<long>();
1505:              impuSipDomainList = new List<string>();
1506:              serviceList = new List<string>();
1507:              partyIdList = new List<string>();
1508:              serviceList = new List<string>();
1509:   
1510:              result = new Ia.Cl.Model.Result();
1511:   
1512:              service2List = null;
1513:   
1514:              agcfGatewayRecordList = null;
1515:              agcfEndpointList = null;
1516:              subPartyList = null;
1517:              subscriberList = null;
1518:   
1519:              huSbrList = null;
1520:              owsbrList = null;
1521:   
1522:              nddOntList = null;
1523:              ontList = null;
1524:              ontServiceVoipList = null;
1525:              ontOntPotsList = null;
1526:              emsOntList = null;
1527:              emsOntSipInfoList = null;
1528:              emsVoipPstnUserList = null;
1529:              eventList = null;
1530:              accessList = null;
1531:              serviceRequestServiceList = null;
1532:              serviceInitialStateList = null;
1533:              serviceRequestList = null;
1534:              serviceRequestTypeList = null;
1535:              serviceRequestOntList = null;
1536:              serviceRequestOntDetailList = null;
1537:              reportList = null;
1538:              reportHistoryList = null;
1539:   
1540:              input = rowInput.ToLower();
1541:   
1542:              try
1543:              {
1544:                  using (var db = new Ia.Ngn.Cl.Model.Ngn())
1545:                  {
1546:                      ontServiceVoipList = (from ov in db.OntServiceVoips where ov.Ip == input select ov).ToList();
1547:                      foreach (var v in ontServiceVoipList) ontIdList.Add(v.Ont.Id);
1548:                      ontIdList = ontIdList.Distinct().ToList();
1549:   
1550:                      agcfGatewayRecordList = (from gr in db.AgcfGatewayRecords
1551:                                               where gr.IP1 == input || gr.IP2 == input
1552:                                               select new Ia.Ngn.Cl.Model.Ui.Nokia.AgcfGatewayRecord()
1553:                                               {
1554:                                                   Id = gr.Id,
1555:                                                   GwId = gr.GwId,
1556:                                                   GwUserId = gr.GwUserId,
1557:                                                   GwDomain = gr.GwDomain,
1558:                                                   GwName = gr.GwName,
1559:                                                   IP1 = gr.IP1,
1560:                                                   IP2 = gr.IP2,
1561:                                                   MateExternalIPAddr = gr.MateExternalIPAddr,
1562:                                                   IsPrimary = gr.IsPrimary,
1563:                                                   Created = gr.Created,
1564:                                                   Updated = gr.Updated
1565:                                               }).ToList();
1566:                      foreach (var v in agcfGatewayRecordList) agcfGatewayRecordIdList.Add(v.Id);
1567:                      agcfGatewayRecordIdList = agcfGatewayRecordIdList.Distinct().ToList();
1568:   
1569:                      agcfEndpointList = (from e in db.AgcfEndpoints
1570:                                          join grid in agcfGatewayRecordIdList on e.AgcfGatewayRecord.Id equals grid
1571:                                          select new Ia.Ngn.Cl.Model.Ui.Nokia.AgcfEndpoint()
1572:                                          {
1573:                                              Id = e.Id,
1574:                                              PrividUser = e.PrividUser,
1575:                                              GwId = e.GwId,
1576:                                              Dn = e.Dn,
1577:                                              FlatTermID = e.FlatTermID,
1578:                                              CallHoldLc = e.CallHoldLc,
1579:                                              CallWaitingLc = e.CallWaitingLc,
1580:                                              CallToggleLc = e.CallToggleLc,
1581:                                              ThreeWayCallLc = e.ThreeWayCallLc,
1582:                                              McidLc = e.McidLc,
1583:                                              Password = e.Password,
1584:                                              CallTransferLc = e.CallTransferLc,
1585:                                              Created = e.Created,
1586:                                              Updated = e.Updated
1587:                                          }).ToList();
1588:   
1589:                      // agcfEndpointIdList = (from ep in agcfEndpointList select ep.Id).ToList();
1590:   
1591:                      Ia.Ngn.Cl.Model.Data.Maintenance.Find.CollectNumbersFromAgcfEndpointList(agcfEndpointList, ref serviceList, ref numberList, ref serviceLongList, ref impuSipDomainList, ref partyIdList);
1592:   
1593:                      service2List = (from s in db.Service2s
1594:                                      join ns in serviceList on s.Service equals ns
1595:                                      select new Ia.Ngn.Cl.Model.Ui.Service2()
1596:                                      {
1597:                                          AbbriviatedCalling = s.AbbriviatedCalling,
1598:                                          AlarmCall = s.AlarmCall,
1599:                                          CallBarring = s.CallBarring,
1600:                                          CallerId = s.CallerId,
1601:                                          CallForwarding = s.CallForwarding,
1602:                                          CallWaiting = s.CallWaiting,
1603:                                          ConferenceCall = s.ConferenceCall,
1604:                                          Created = s.Created,
1605:                                          InternationalCalling = s.InternationalCalling,
1606:                                          InternationalCallingUserControlled = s.InternationalCallingUserControlled,
1607:                                          LineCard = s.LineCard,
1608:                                          Pin = s.Pin,
1609:                                          Service = s.Service,
1610:                                          ServiceType = s.ServiceType,
1611:                                          ServiceSuspension = s.ServiceSuspension,
1612:                                          ServiceTypeName = s.ServiceType.ToString(),
1613:                                          Updated = s.Updated,
1614:                                          AccessId = s.Access.Id
1615:                                      }).ToList();
1616:   
1617:                      serviceRequestServiceList = (from srs in db.ServiceRequestServices
1618:                                                   join aid in accessIdList on srs.Access.Id equals aid
1619:                                                   select new Ia.Ngn.Cl.Model.Ui.ServiceRequestService()
1620:                                                   {
1621:                                                       Id = srs.Id,
1622:                                                       AbbriviatedCalling = srs.AbbriviatedCalling,
1623:                                                       Access = srs.Access,
1624:                                                       AlarmCall = srs.AlarmCall,
1625:                                                       CallBarring = srs.CallBarring,
1626:                                                       CallerId = srs.CallerId,
1627:                                                       CallForwarding = srs.CallForwarding,
1628:                                                       CallWaiting = srs.CallWaiting,
1629:                                                       ConferenceCall = srs.ConferenceCall,
1630:                                                       Created = srs.Created,
1631:                                                       InternationalCalling = srs.InternationalCalling,
1632:                                                       InternationalCallingUserControlled = srs.InternationalCallingUserControlled,
1633:                                                       LastRequestDateTime = srs.LastRequestDateTime,
1634:                                                       Provisioned = srs.Provisioned,
1635:                                                       Service = srs.Service,
1636:                                                       ServiceType = srs.ServiceType,
1637:                                                       ServiceSuspension = srs.ServiceSuspension,
1638:                                                       Type = srs.Type,
1639:                                                       Updated = srs.Updated
1640:                                                   }).ToList();
1641:   
1642:                      serviceInitialStateList = (from sis in db.ServiceInitialStates join aid in accessIdList on sis.Access.Id equals aid select sis).ToList();
1643:   
1644:                      subscriberList = (from s in db.Subscribers
1645:                                        join p in partyIdList on s.PartyId equals p
1646:                                        select s).AsEnumerable().Select(s => new Ia.Ngn.Cl.Model.Ui.Nokia.Subscriber()
1647:                                        {
1648:                                            Id = s.Id,
1649:                                            AlternateOtasRealm = s.AlternateOtasRealm,
1650:                                            PartyId = s.PartyId,
1651:                                            AbbriviatedCalling = Ia.Ngn.Cl.Model.Business.Nokia.Subscriber.OneDigitSpeedDialIsAssigned(s._OneDigitSpeedDial),
1652:                                            AlarmCall = Ia.Ngn.Cl.Model.Business.Nokia.Subscriber.ReminderCallIsAssigned(s._ReminderCall),
1653:                                            CallerId = Ia.Ngn.Cl.Model.Business.Nokia.Subscriber.CallingLineIdIsAssigned(s._CallingLineId),
1654:                                            CallForwarding = Ia.Ngn.Cl.Model.Business.Nokia.Subscriber.CallForwardingIsAssigned(s._CallForwardingVari),
1655:                                            CallWaiting = Ia.Ngn.Cl.Model.Business.Nokia.Subscriber.CallWaitingIsAssigned(s._CallWaiting, false),
1656:                                            ConferenceCall = Ia.Ngn.Cl.Model.Business.Nokia.Subscriber.ConferenceCallIsAssigned(s._ConferenceCalling),
1657:                                            InternationalCalling = Ia.Ngn.Cl.Model.Business.Nokia.Subscriber.InternationalCallingIsAssigned(s._CallBarring),
1658:                                            InternationalCallingUserControlled = Ia.Ngn.Cl.Model.Business.Nokia.Subscriber.InternationalCallingUserControlledIsAssigned(s._OutgoingCallBarring),
1659:                                            //ServiceSuspention = Ia.Ngn.Cl.Model.Business.Nokia.Subscriber.ServiceSuspentionIsAssigned(s._ServiceSuspention),
1660:                                            Created = s.Created,
1661:                                            Updated = s.Updated,
1662:                                        }).ToList();
1663:   
1664:                      subPartyList = (from sp in db.SubParties
1665:                                      join p in partyIdList on sp.PartyId equals p
1666:                                      select new Ia.Ngn.Cl.Model.Ui.Nokia.SubParty()
1667:                                      {
1668:                                          Id = sp.Id,
1669:                                          PartyId = sp.PartyId,
1670:                                          PrimaryPUIDCPEProfileNumber = sp.PrimaryPUIDCPEProfileNumber,
1671:                                          DisplayName = sp.DisplayName,
1672:                                          Category = sp.Category,
1673:                                          AssocOtasRealm = sp.AssocOtasRealm,
1674:                                          ServiceSuspension = sp.ServiceSuspension,
1675:                                          Created = sp.Created,
1676:                                          Updated = sp.Updated
1677:                                      }).ToList();
1678:   
1679:   
1680:                      huSbrList = (from h in db.HuSbrs
1681:                                   join i in impuSipDomainList on h.IMPU equals i
1682:                                   select new Ia.Ngn.Cl.Model.Ui.Huawei.HuSbr()
1683:                                   {
1684:                                       COP = h.COP,
1685:                                       CSC = h.CSC,
1686:                                       Id = h.Id,
1687:                                       IMPU = h.IMPU,
1688:                                       ITT = h.ITT,
1689:                                       LP = h.LP,
1690:                                       NS3PTY = h.NS3PTY,
1691:                                       NSABRC = h.NSABRC,
1692:                                       NSCBA = h.NSCBA,
1693:                                       NSCFU = h.NSCFU,
1694:                                       NSCLIP = h.NSCLIP,
1695:                                       NSCW = h.NSCW,
1696:                                       NSFAX = h.NSFAX,
1697:                                       NSHOLD = h.NSHOLD,
1698:                                       NSNPTY = h.NSNPTY,
1699:                                       NSWAKE_UP = h.NSWAKE_UP,
1700:                                       Created = h.Created,
1701:                                       Updated = h.Updated
1702:                                   }).ToList();
1703:   
1704:                      owsbrList = (from o in db.Owsbrs join i in impuSipDomainList on o.IMPU equals i select o).ToList();
1705:   
1706:                      serviceRequestList = (from sr in db.ServiceRequests join n in numberList on sr.Number equals n select sr).ToList();
1707:                      serviceRequestTypeList = (from srt in db.ServiceRequestTypes join sr in db.ServiceRequests on srt.ServiceRequest equals sr join n in numberList on sr.Number equals n select srt).ToList();
1708:   
1709:                      reportList = (from r in db.Reports join sl in service2IdList on r.Service equals sl select r).Include(x => x.ReportHistories).ToList();
1710:   
1711:   
1712:                      nddOntList = (from nddo in Ia.Ngn.Cl.Model.Data.NetworkDesignDocument.OntList where nddo.Ip == input select nddo).ToList();
1713:                      foreach (var v in nddOntList) ontIdList.Add(v.Id);
1714:                      ontIdList = ontIdList.Distinct().ToList();
1715:   
1716:                      ontList = (from o in db.Onts join oid in ontIdList on o.Id equals oid select o).ToList();
1717:                      foreach (var v in ontList) ontIdList.Add(v.Id);
1718:                      ontIdList = ontIdList.Distinct().ToList();
1719:   
1720:                      foreach (var v in ontList) if (v.Access != null) accessIdList.Add(v.Access.Id);
1721:                      accessIdList = accessIdList.Distinct().ToList();
1722:   
1723:                      ontOntPotsList = (from op in db.OntOntPotses join oid in ontIdList on op.Ont.Id equals oid select op).ToList();
1724:                      ontServiceVoipList = (from ov in db.OntServiceVoips join oid in ontIdList on ov.Ont.Id equals oid select ov).ToList();
1725:   
1726:                      foreach (var v in nddOntList)
1727:                      {
1728:                          //eventSystemList.Add(v.Pon.PonGroup.Olt.AmsName);
1729:                          //eventAidOntList.Add("ONT-1-1-" + v.Card + "-" + v.Port + "-" + v.Number);
1730:                          //eventAidOntVoipList.Add("ONTVOIP-1-1-" + v.Card + "-" + v.Port + "-1");
1731:   
1732:                          //foreach (var w in ontOntPotsList) eventAidOntPotsList.Add("ONTPOTS-1-1-" + v.Card + "-" + v.Port + "-" + w.Card + "-" + w.Port);
1733:                      }
1734:   
1735:                      //eventSystemList = eventSystemList.Distinct().ToList();
1736:                      //eventAidOntList = eventAidOntList.Distinct().ToList();
1737:                      //eventAidOntVoipList = eventAidOntVoipList.Distinct().ToList();
1738:   
1739:                      /*
1740:                      eventList = (from e in db.Events join es in eventSystemList on e.System equals es join eao in eventAidOntList on e.Aid equals eao select e)
1741:                                  .Union(from e in db.Events join es in eventSystemList on e.System equals es join eao in eventAidOntList on e.Aid equals eao join eaov in eventAidOntVoipList on e.Aid equals eaov select e)
1742:                                  .Union(from e in db.Events join es in eventSystemList on e.System equals es join eao in eventAidOntList on e.Aid equals eao join eaop in eventAidOntPotsList on e.Aid equals eaop select e)
1743:                                  .ToList();
1744:                                  */
1745:   
1746:                      accessList = (from a in db.Accesses join aid in accessIdList on a.Id equals aid select a).ToList();
1747:                  }
1748:              }
1749:              catch (Exception ex)
1750:              {
1751:                  result.AddError("Exception: Retrieval error of data for \"" + rowInput + "\": " + ex.ToString());
1752:              }
1753:          }
1754:   
1755:          ////////////////////////////////////////////////////////////////////////////
1756:   
1757:          /// <summary>
1758:          ///
1759:          /// </summary>
1760:          public static void GatewayId(string rowInput,
1761:              out List<Ia.Ngn.Cl.Model.Ui.Service2> service2List,
1762:              out List<Ia.Ngn.Cl.Model.Ui.Nokia.AgcfGatewayRecord> agcfGatewayRecordList,
1763:              out List<Ia.Ngn.Cl.Model.Ui.Nokia.AgcfEndpoint> agcfEndpointList,
1764:              out List<Ia.Ngn.Cl.Model.Ui.Nokia.SubParty> subPartyList,
1765:              out List<Ia.Ngn.Cl.Model.Ui.Nokia.Subscriber> subscriberList,
1766:              out List<Ia.Ngn.Cl.Model.Ui.Huawei.HuSbr> huSbrList,
1767:              out List<Ia.Ngn.Cl.Model.Huawei.Owsbr> owsbrList,
1768:              out List<Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Ont> nddOntList,
1769:              out List<Ia.Ngn.Cl.Model.Ont> ontList,
1770:              out List<Ia.Ngn.Cl.Model.OntServiceVoip> ontServiceVoipList,
1771:              out List<Ia.Ngn.Cl.Model.OntOntPots> ontOntPotsList,
1772:              out List<Ia.Ngn.Cl.Model.Ui.Huawei.EmsOnt> emsOntList,
1773:              out List<Ia.Ngn.Cl.Model.Huawei.EmsOntSipInfo> emsOntSipInfoList,
1774:              out List<Ia.Ngn.Cl.Model.Huawei.EmsVoipPstnUser> emsVoipPstnUserList,
1775:              out List<Ia.Ngn.Cl.Model.Event> eventList,
1776:              out List<Ia.Ngn.Cl.Model.Access> accessList,
1777:              out List<Ia.Ngn.Cl.Model.Ui.ServiceRequestService> serviceRequestServiceList,
1778:              out List<Ia.Ngn.Cl.Model.ServiceInitialState> serviceInitialStateList,
1779:              out List<Ia.Ngn.Cl.Model.ServiceRequest> serviceRequestList,
1780:              out List<Ia.Ngn.Cl.Model.ServiceRequestType> serviceRequestTypeList,
1781:              out List<Ia.Ngn.Cl.Model.ServiceRequestOnt> serviceRequestOntList,
1782:              out List<Ia.Ngn.Cl.Model.ServiceRequestOntDetail> serviceRequestOntDetailList,
1783:              out List<Ia.Ngn.Cl.Model.Report> reportList,
1784:              out List<Ia.Ngn.Cl.Model.ReportHistory> reportHistoryList,
1785:              out Ia.Cl.Model.Result result)
1786:          {
1787:              string input;
1788:              int number, gatewayId;
1789:              Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Vendor accessVendor, switchVendor;
1790:              List<int> serviceRequestIdList, agcfGatewayRecordIdList, reportIdList, numberList;
1791:              List<long> serviceLongList;
1792:              List<string> serviceList, serviceRequestServiceIdList, impuSipDomainList, accessIdList, ontIdList, agcfEndpointIdList, subPartyIdList, subscriberIdList, partyIdList, prividUserList, ipList;
1793:   
1794:              serviceRequestIdList = new List<int>();
1795:              serviceRequestServiceIdList = new List<string>();
1796:              accessIdList = new List<string>();
1797:              ontIdList = new List<string>();
1798:              agcfEndpointIdList = new List<string>();
1799:              subscriberIdList = new List<string>();
1800:              agcfGatewayRecordIdList = new List<int>();
1801:              reportIdList = new List<int>();
1802:              ipList = new List<string>();
1803:              numberList = new List<int>();
1804:              impuSipDomainList = new List<string>();
1805:              serviceList = new List<string>();
1806:              partyIdList = new List<string>();
1807:              prividUserList = new List<string>();
1808:              subPartyIdList = new List<string>();
1809:   
1810:              serviceLongList = new List<long>();
1811:   
1812:              result = new Ia.Cl.Model.Result();
1813:   
1814:              service2List = null;
1815:   
1816:              agcfGatewayRecordList = null;
1817:              agcfEndpointList = null;
1818:              subPartyList = null;
1819:              subscriberList = null;
1820:   
1821:              huSbrList = null;
1822:              owsbrList = null;
1823:   
1824:              nddOntList = null;
1825:              ontList = null;
1826:              ontServiceVoipList = null;
1827:              ontOntPotsList = null;
1828:              emsOntList = null;
1829:              emsOntSipInfoList = null;
1830:              emsVoipPstnUserList = null;
1831:              eventList = null;
1832:              accessList = null;
1833:              serviceRequestServiceList = null;
1834:              serviceInitialStateList = null;
1835:              serviceRequestList = null;
1836:              serviceRequestTypeList = null;
1837:              serviceRequestOntList = null;
1838:              serviceRequestOntDetailList = null;
1839:              reportList = null;
1840:              reportHistoryList = null;
1841:   
1842:              input = rowInput.ToLower();
1843:   
1844:              gatewayId = int.Parse(input);
1845:   
1846:              if (gatewayId >= Ia.Ngn.Cl.Model.Business.Nokia.Ims.FirstGatewayId && gatewayId <= Ia.Ngn.Cl.Model.Business.Nokia.Ims.LastGatewayId)
1847:              {
1848:                  Ia.Ngn.Cl.Model.Data.Msmq.GatewayIdQueue.Enqueue(gatewayId);
1849:   
1850:                  try
1851:                  {
1852:                      using (var db = new Ia.Ngn.Cl.Model.Ngn())
1853:                      {
1854:                          agcfEndpointList = (from e in db.AgcfEndpoints
1855:                                              where e.GwId == gatewayId
1856:                                              select new Ia.Ngn.Cl.Model.Ui.Nokia.AgcfEndpoint()
1857:                                              {
1858:                                                  Id = e.Id,
1859:                                                  PrividUser = e.PrividUser,
1860:                                                  GwId = e.GwId,
1861:                                                  Dn = e.Dn,
1862:                                                  FlatTermID = e.FlatTermID,
1863:                                                  CallHoldLc = e.CallHoldLc,
1864:                                                  CallWaitingLc = e.CallWaitingLc,
1865:                                                  CallToggleLc = e.CallToggleLc,
1866:                                                  ThreeWayCallLc = e.ThreeWayCallLc,
1867:                                                  McidLc = e.McidLc,
1868:                                                  Password = e.Password,
1869:                                                  CallTransferLc = e.CallTransferLc,
1870:                                                  Created = e.Created,
1871:                                                  Updated = e.Updated
1872:                                              }).ToList();
1873:   
1874:                          foreach (var v in agcfEndpointList) agcfEndpointIdList.Add(v.Id);
1875:                          agcfEndpointIdList = agcfEndpointIdList.Distinct().ToList();
1876:   
1877:                          agcfGatewayRecordList = (from gr in db.AgcfGatewayRecords
1878:                                                   where gr.GwId == gatewayId
1879:                                                   select new Ia.Ngn.Cl.Model.Ui.Nokia.AgcfGatewayRecord()
1880:                                                   {
1881:                                                       Id = gr.Id,
1882:                                                       GwId = gr.GwId,
1883:                                                       GwUserId = gr.GwUserId,
1884:                                                       GwDomain = gr.GwDomain,
1885:                                                       GwName = gr.GwName,
1886:                                                       IP1 = gr.IP1,
1887:                                                       IP2 = gr.IP2,
1888:                                                       MateExternalIPAddr = gr.MateExternalIPAddr,
1889:                                                       IsPrimary = gr.IsPrimary,
1890:                                                       Created = gr.Created,
1891:                                                       Updated = gr.Updated
1892:                                                   }).ToList();
1893:   
1894:                          foreach (var v in agcfGatewayRecordList)
1895:                          {
1896:                              agcfGatewayRecordIdList.Add(v.Id);
1897:                              ipList.Add(v.IP1);
1898:                          }
1899:                          agcfGatewayRecordIdList = agcfGatewayRecordIdList.Distinct().ToList();
1900:                          ipList = ipList.Distinct().ToList();
1901:   
1902:                          subPartyList = (from sp in db.SubParties
1903:                                          join eid in agcfEndpointIdList on sp.AgcfEndpoint.Id equals eid
1904:                                          select new Ia.Ngn.Cl.Model.Ui.Nokia.SubParty()
1905:                                          {
1906:                                              Id = sp.Id,
1907:                                              PartyId = sp.PartyId,
1908:                                              PrimaryPUIDCPEProfileNumber = sp.PrimaryPUIDCPEProfileNumber,
1909:                                              DisplayName = sp.DisplayName,
1910:                                              Category = sp.Category,
1911:                                              AssocOtasRealm = sp.AssocOtasRealm,
1912:                                              ServiceSuspension = sp.ServiceSuspension,
1913:                                              Created = sp.Created,
1914:                                              Updated = sp.Updated
1915:                                          }).ToList();
1916:   
1917:                          foreach (var v in subPartyList) subPartyIdList.Add(v.Id);
1918:                          subPartyIdList = subPartyIdList.Distinct().ToList();
1919:   
1920:                          subscriberList = (from s in db.Subscribers
1921:                                            join sid in subPartyIdList on s.SubParty.Id equals sid
1922:                                            select s).AsEnumerable().Select(s => new Ia.Ngn.Cl.Model.Ui.Nokia.Subscriber()
1923:                                            {
1924:                                                Id = s.Id,
1925:                                                AlternateOtasRealm = s.AlternateOtasRealm,
1926:                                                PartyId = s.PartyId,
1927:                                                AbbriviatedCalling = Ia.Ngn.Cl.Model.Business.Nokia.Subscriber.OneDigitSpeedDialIsAssigned(s._OneDigitSpeedDial),
1928:                                                AlarmCall = Ia.Ngn.Cl.Model.Business.Nokia.Subscriber.ReminderCallIsAssigned(s._ReminderCall),
1929:                                                CallerId = Ia.Ngn.Cl.Model.Business.Nokia.Subscriber.CallingLineIdIsAssigned(s._CallingLineId),
1930:                                                CallForwarding = Ia.Ngn.Cl.Model.Business.Nokia.Subscriber.CallForwardingIsAssigned(s._CallForwardingVari),
1931:                                                CallWaiting = Ia.Ngn.Cl.Model.Business.Nokia.Subscriber.CallWaitingIsAssigned(s._CallWaiting, false),
1932:                                                ConferenceCall = Ia.Ngn.Cl.Model.Business.Nokia.Subscriber.ConferenceCallIsAssigned(s._ConferenceCalling),
1933:                                                InternationalCalling = Ia.Ngn.Cl.Model.Business.Nokia.Subscriber.InternationalCallingIsAssigned(s._CallBarring),
1934:                                                InternationalCallingUserControlled = Ia.Ngn.Cl.Model.Business.Nokia.Subscriber.InternationalCallingUserControlledIsAssigned(s._OutgoingCallBarring),
1935:                                                //ServiceSuspention = Ia.Ngn.Cl.Model.Business.Nokia.Subscriber.ServiceSuspentionIsAssigned(s._ServiceSuspention),
1936:                                                Created = s.Created,
1937:                                                Updated = s.Updated,
1938:                                            }).ToList();
1939:   
1940:                          Ia.Ngn.Cl.Model.Data.Maintenance.Find.CollectNumbersFromSubscriberList(subscriberList, ref serviceList, ref numberList, ref serviceLongList, ref impuSipDomainList, ref partyIdList);
1941:   
1942:                          subPartyList = (from sp in db.SubParties
1943:                                          join e in agcfEndpointIdList on sp.AgcfEndpoint.Id equals e
1944:                                          join p in partyIdList on sp.PartyId equals p
1945:                                          where sp.AgcfEndpoint != null
1946:                                          select new Ia.Ngn.Cl.Model.Ui.Nokia.SubParty()
1947:                                          {
1948:                                              Id = sp.Id,
1949:                                              PartyId = sp.PartyId,
1950:                                              PrimaryPUIDCPEProfileNumber = sp.PrimaryPUIDCPEProfileNumber,
1951:                                              DisplayName = sp.DisplayName,
1952:                                              Category = sp.Category,
1953:                                              AssocOtasRealm = sp.AssocOtasRealm,
1954:                                              ServiceSuspension = sp.ServiceSuspension,
1955:                                              Created = sp.Created,
1956:                                              Updated = sp.Updated
1957:                                          }).ToList();
1958:   
1959:                          foreach (var v in subPartyList) subPartyIdList.Add(v.Id);
1960:                          subPartyIdList = subPartyIdList.Distinct().ToList();
1961:   
1962:                          // below: db.Subscribers contains XML fields which can not be evaluated in a Union() function.
1963:                          subscriberList = (from s in db.Subscribers
1964:                                            join pid in partyIdList on s.PartyId equals pid
1965:                                            select s).AsEnumerable().Select(s => new Ia.Ngn.Cl.Model.Ui.Nokia.Subscriber()
1966:                                            {
1967:                                                Id = s.Id,
1968:                                                AlternateOtasRealm = s.AlternateOtasRealm,
1969:                                                PartyId = s.PartyId,
1970:                                                AbbriviatedCalling = Ia.Ngn.Cl.Model.Business.Nokia.Subscriber.OneDigitSpeedDialIsAssigned(s._OneDigitSpeedDial),
1971:                                                AlarmCall = Ia.Ngn.Cl.Model.Business.Nokia.Subscriber.ReminderCallIsAssigned(s._ReminderCall),
1972:                                                CallerId = Ia.Ngn.Cl.Model.Business.Nokia.Subscriber.CallingLineIdIsAssigned(s._CallingLineId),
1973:                                                CallForwarding = Ia.Ngn.Cl.Model.Business.Nokia.Subscriber.CallForwardingIsAssigned(s._CallForwardingVari),
1974:                                                CallWaiting = Ia.Ngn.Cl.Model.Business.Nokia.Subscriber.CallWaitingIsAssigned(s._CallWaiting, false),
1975:                                                ConferenceCall = Ia.Ngn.Cl.Model.Business.Nokia.Subscriber.ConferenceCallIsAssigned(s._ConferenceCalling),
1976:                                                InternationalCalling = Ia.Ngn.Cl.Model.Business.Nokia.Subscriber.InternationalCallingIsAssigned(s._CallBarring),
1977:                                                InternationalCallingUserControlled = Ia.Ngn.Cl.Model.Business.Nokia.Subscriber.InternationalCallingUserControlledIsAssigned(s._OutgoingCallBarring),
1978:                                                //ServiceSuspention = Ia.Ngn.Cl.Model.Business.Nokia.Subscriber.ServiceSuspentionIsAssigned(s._ServiceSuspention),
1979:                                                Created = s.Created,
1980:                                                Updated = s.Updated,
1981:                                            }).ToList();
1982:   
1983:                          foreach (var v in subscriberList) subscriberIdList.Add(v.Id);
1984:                          subscriberIdList = subscriberIdList.Distinct().ToList();
1985:                          subscriberList = (from s in db.Subscribers
1986:                                            join spid in subPartyIdList on s.SubParty.Id equals spid
1987:                                            select s).AsEnumerable().Select(s => new Ia.Ngn.Cl.Model.Ui.Nokia.Subscriber()
1988:                                            {
1989:                                                Id = s.Id,
1990:                                                AlternateOtasRealm = s.AlternateOtasRealm,
1991:                                                PartyId = s.PartyId,
1992:                                                AbbriviatedCalling = Ia.Ngn.Cl.Model.Business.Nokia.Subscriber.OneDigitSpeedDialIsAssigned(s._OneDigitSpeedDial),
1993:                                                AlarmCall = Ia.Ngn.Cl.Model.Business.Nokia.Subscriber.ReminderCallIsAssigned(s._ReminderCall),
1994:                                                CallerId = Ia.Ngn.Cl.Model.Business.Nokia.Subscriber.CallingLineIdIsAssigned(s._CallingLineId),
1995:                                                CallForwarding = Ia.Ngn.Cl.Model.Business.Nokia.Subscriber.CallForwardingIsAssigned(s._CallForwardingVari),
1996:                                                CallWaiting = Ia.Ngn.Cl.Model.Business.Nokia.Subscriber.CallWaitingIsAssigned(s._CallWaiting, false),
1997:                                                ConferenceCall = Ia.Ngn.Cl.Model.Business.Nokia.Subscriber.ConferenceCallIsAssigned(s._ConferenceCalling),
1998:                                                InternationalCalling = Ia.Ngn.Cl.Model.Business.Nokia.Subscriber.InternationalCallingIsAssigned(s._CallBarring),
1999:                                                InternationalCallingUserControlled = Ia.Ngn.Cl.Model.Business.Nokia.Subscriber.InternationalCallingUserControlledIsAssigned(s._OutgoingCallBarring),
2000:                                                //ServiceSuspention = Ia.Ngn.Cl.Model.Business.Nokia.Subscriber.ServiceSuspentionIsAssigned(s._ServiceSuspention),
2001:                                                Created = s.Created,
2002:                                                Updated = s.Updated,
2003:                                            }).ToList();
2004:   
2005:                          foreach (var v in subscriberList) subscriberIdList.Add(v.Id);
2006:                          subscriberIdList = subscriberIdList.Distinct().ToList();
2007:                          subscriberList = (from s in db.Subscribers
2008:                                            join sid in subscriberIdList on s.Id equals sid
2009:                                            select s).AsEnumerable().Select(s => new Ia.Ngn.Cl.Model.Ui.Nokia.Subscriber()
2010:                                            {
2011:                                                Id = s.Id,
2012:                                                AlternateOtasRealm = s.AlternateOtasRealm,
2013:                                                PartyId = s.PartyId,
2014:                                                AbbriviatedCalling = Ia.Ngn.Cl.Model.Business.Nokia.Subscriber.OneDigitSpeedDialIsAssigned(s._OneDigitSpeedDial),
2015:                                                AlarmCall = Ia.Ngn.Cl.Model.Business.Nokia.Subscriber.ReminderCallIsAssigned(s._ReminderCall),
2016:                                                CallerId = Ia.Ngn.Cl.Model.Business.Nokia.Subscriber.CallingLineIdIsAssigned(s._CallingLineId),
2017:                                                CallForwarding = Ia.Ngn.Cl.Model.Business.Nokia.Subscriber.CallForwardingIsAssigned(s._CallForwardingVari),
2018:                                                CallWaiting = Ia.Ngn.Cl.Model.Business.Nokia.Subscriber.CallWaitingIsAssigned(s._CallWaiting, false),
2019:                                                ConferenceCall = Ia.Ngn.Cl.Model.Business.Nokia.Subscriber.ConferenceCallIsAssigned(s._ConferenceCalling),
2020:                                                InternationalCalling = Ia.Ngn.Cl.Model.Business.Nokia.Subscriber.InternationalCallingIsAssigned(s._CallBarring),
2021:                                                InternationalCallingUserControlled = Ia.Ngn.Cl.Model.Business.Nokia.Subscriber.InternationalCallingUserControlledIsAssigned(s._OutgoingCallBarring),
2022:                                                //ServiceSuspention = Ia.Ngn.Cl.Model.Business.Nokia.Subscriber.ServiceSuspentionIsAssigned(s._ServiceSuspention),
2023:                                                Created = s.Created,
2024:                                                Updated = s.Updated,
2025:                                            }).ToList();
2026:   
2027:   
2028:                          Ia.Ngn.Cl.Model.Data.Maintenance.Find.SynchronizeNumberFormatLists(ref partyIdList, ref prividUserList, ref serviceList, ref numberList, ref serviceLongList, ref impuSipDomainList);
2029:   
2030:                          serviceRequestServiceList = (from srs in db.ServiceRequestServices
2031:                                                       join ns in serviceList on srs.Service equals ns
2032:                                                       select new Ia.Ngn.Cl.Model.Ui.ServiceRequestService()
2033:                                                       {
2034:                                                           Id = srs.Id,
2035:                                                           AbbriviatedCalling = srs.AbbriviatedCalling,
2036:                                                           Access = srs.Access,
2037:                                                           AlarmCall = srs.AlarmCall,
2038:                                                           CallBarring = srs.CallBarring,
2039:                                                           CallerId = srs.CallerId,
2040:                                                           CallForwarding = srs.CallForwarding,
2041:                                                           CallWaiting = srs.CallWaiting,
2042:                                                           ConferenceCall = srs.ConferenceCall,
2043:                                                           Created = srs.Created,
2044:                                                           InternationalCalling = srs.InternationalCalling,
2045:                                                           InternationalCallingUserControlled = srs.InternationalCallingUserControlled,
2046:                                                           LastRequestDateTime = srs.LastRequestDateTime,
2047:                                                           Provisioned = srs.Provisioned,
2048:                                                           Service = srs.Service,
2049:                                                           ServiceType = srs.ServiceType,
2050:                                                           ServiceSuspension = srs.ServiceSuspension,
2051:                                                           Type = srs.Type,
2052:                                                           Updated = srs.Updated
2053:                                                       }).ToList();
2054:                          foreach (var v in serviceRequestServiceList) serviceRequestServiceIdList.Add(v.Id);
2055:                          serviceRequestServiceIdList = serviceRequestServiceIdList.Distinct().ToList();
2056:   
2057:                          serviceInitialStateList = (from sis in db.ServiceInitialStates join ns in serviceList on sis.Service equals ns select sis).ToList();
2058:   
2059:                          service2List = (from s in db.Service2s
2060:                                          join ns in serviceList on s.Service equals ns
2061:                                          select new Ia.Ngn.Cl.Model.Ui.Service2()
2062:                                          {
2063:                                              AbbriviatedCalling = s.AbbriviatedCalling,
2064:                                              AlarmCall = s.AlarmCall,
2065:                                              CallBarring = s.CallBarring,
2066:                                              CallerId = s.CallerId,
2067:                                              CallForwarding = s.CallForwarding,
2068:                                              CallWaiting = s.CallWaiting,
2069:                                              ConferenceCall = s.ConferenceCall,
2070:                                              Created = s.Created,
2071:                                              InternationalCalling = s.InternationalCalling,
2072:                                              InternationalCallingUserControlled = s.InternationalCallingUserControlled,
2073:                                              LineCard = s.LineCard,
2074:                                              Pin = s.Pin,
2075:                                              Service = s.Service,
2076:                                              ServiceType = s.ServiceType,
2077:                                              ServiceSuspension = s.ServiceSuspension,
2078:                                              ServiceTypeName = s.ServiceType.ToString(),
2079:                                              Updated = s.Updated,
2080:                                              AccessId = s.Access.Id
2081:                                          }).ToList();
2082:   
2083:                          huSbrList = (from h in db.HuSbrs
2084:                                       join i in impuSipDomainList on h.IMPU equals i
2085:                                       select new Ia.Ngn.Cl.Model.Ui.Huawei.HuSbr()
2086:                                       {
2087:                                           COP = h.COP,
2088:                                           CSC = h.CSC,
2089:                                           Id = h.Id,
2090:                                           IMPU = h.IMPU,
2091:                                           ITT = h.ITT,
2092:                                           LP = h.LP,
2093:                                           NS3PTY = h.NS3PTY,
2094:                                           NSABRC = h.NSABRC,
2095:                                           NSCBA = h.NSCBA,
2096:                                           NSCFU = h.NSCFU,
2097:                                           NSCLIP = h.NSCLIP,
2098:                                           NSCW = h.NSCW,
2099:                                           NSFAX = h.NSFAX,
2100:                                           NSHOLD = h.NSHOLD,
2101:                                           NSNPTY = h.NSNPTY,
2102:                                           NSWAKE_UP = h.NSWAKE_UP,
2103:                                           Created = h.Created,
2104:                                           Updated = h.Updated
2105:                                       }).ToList();
2106:   
2107:                          owsbrList = (from o in db.Owsbrs join i in impuSipDomainList on o.IMPU equals i select o).ToList();
2108:   
2109:                          serviceRequestList = (from sr in db.ServiceRequests join n in numberList on sr.Number equals n select sr).ToList();
2110:                          serviceRequestList = serviceRequestList.Union(from sr in db.ServiceRequests join srsid in serviceRequestServiceIdList on sr.ServiceRequestService.Id equals srsid where sr.ServiceRequestService != null select sr).ToList();
2111:                          foreach (var v in serviceRequestList) serviceRequestIdList.Add(v.Id);
2112:                          serviceRequestIdList = serviceRequestIdList.Distinct().ToList();
2113:   
2114:                          serviceRequestTypeList = (from srt in db.ServiceRequestTypes join srid in serviceRequestIdList on srt.ServiceRequest.Id equals srid where srt.ServiceRequest != null select srt).ToList();
2115:   
2116:                          reportList = ((from r in db.Reports join n in serviceList on r.Service equals n select r).Include(x => x.ReportHistories)).ToList();
2117:                          foreach (var v in reportList) reportIdList.Add(v.Id);
2118:                          reportIdList = reportIdList.Distinct().ToList();
2119:   
2120:                          nddOntList = (from nddo in Ia.Ngn.Cl.Model.Data.NetworkDesignDocument.OntList join ip in ipList on nddo.Ip equals ip select nddo).ToList();
2121:                          foreach (var v in nddOntList)
2122:                          {
2123:                              ontIdList.Add(v.Id);
2124:   
2125:                              //eventSystemList.Add(v.Pon.PonGroup.Olt.AmsName);
2126:                              //eventAidOntList.Add("ONT-1-1-" + v.Card + "-" + v.Port + "-" + v.Number);
2127:                              //eventAidOntVoipList.Add("ONTVOIP-1-1-" + v.Card + "-" + v.Port + "-1");
2128:                          }
2129:                          ontIdList = ontIdList.Distinct().ToList();
2130:                          //eventSystemList = eventSystemList.Distinct().ToList();
2131:                          //eventAidOntList = eventAidOntList.Distinct().ToList();
2132:                          //eventAidOntVoipList = eventAidOntVoipList.Distinct().ToList();
2133:   
2134:                          ontList = (from o in db.Onts join oid in ontIdList on o.Id equals oid select o).ToList();
2135:                          foreach (var v in ontList) ontIdList.Add(v.Id);
2136:                          ontIdList = ontIdList.Distinct().ToList();
2137:   
2138:                          foreach (var v in ontList) if (v.Access != null) accessIdList.Add(v.Access.Id);
2139:                          accessIdList = accessIdList.Distinct().ToList();
2140:   
2141:                          ontOntPotsList = (from op in db.OntOntPotses join oid in ontIdList on op.Ont.Id equals oid select op).ToList();
2142:                          ontServiceVoipList = (from ov in db.OntServiceVoips join oid in ontIdList on ov.Ont.Id equals oid select ov).ToList();
2143:   
2144:                          accessList = (from a in db.Accesses join aid in accessIdList on a.Id equals aid select a).ToList();
2145:                          foreach (var v in nddOntList)
2146:                          {
2147:                              ontIdList.Add(v.Id);
2148:   
2149:                              //eventSystemList.Add(v.Pon.PonGroup.Olt.AmsName);
2150:                              //eventAidOntList.Add("ONT-1-1-" + v.Card + "-" + v.Port + "-" + v.Number);
2151:                              //eventAidOntVoipList.Add("ONTVOIP-1-1-" + v.Card + "-" + v.Port + "-1");
2152:   
2153:                              //foreach (var w in ontOntPotsList) eventAidOntPotsList.Add("ONTPOTS-1-1-" + v.Card + "-" + v.Port + "-" + w.Card + "-" + w.Port);
2154:                          }
2155:                          ontIdList = ontIdList.Distinct().ToList();
2156:                          //eventSystemList = eventSystemList.Distinct().ToList();
2157:                          //eventAidOntList = eventAidOntList.Distinct().ToList();
2158:                          //eventAidOntVoipList = eventAidOntVoipList.Distinct().ToList();
2159:   
2160:                          /*
2161:                          eventList = (from e in db.Events join es in eventSystemList on e.System equals es join eao in eventAidOntList on e.Aid equals eao select e)
2162:                                      .Union(from e in db.Events join es in eventSystemList on e.System equals es join eao in eventAidOntList on e.Aid equals eao join eaov in eventAidOntVoipList on e.Aid equals eaov select e)
2163:                                      .Union(from e in db.Events join es in eventSystemList on e.System equals es join eao in eventAidOntList on e.Aid equals eao join eaop in eventAidOntPotsList on e.Aid equals eaop select e)
2164:                                      .ToList();
2165:                                      */
2166:                      }
2167:                  }
2168:                  catch (Exception ex)
2169:                  {
2170:                      result.AddError("Exception: Retrieval error of data for \"" + rowInput + "\": " + ex.ToString());
2171:                  }
2172:              }
2173:              else
2174:              {
2175:                  result.AddError("The gatewayId \"" + rowInput + "\" is not within the allowed gatewayId range (الرقم لا ينتمي للمجال). ");
2176:              }
2177:          }
2178:   
2179:          ////////////////////////////////////////////////////////////////////////////
2180:   
2181:          /// <summary>
2182:          ///
2183:          /// </summary>
2184:          public static void AreaBlock(string rowInput, out List<Ia.Ngn.Cl.Model.Access> accessList, out Ia.Cl.Model.Result result)
2185:          {
2186:              string input;
2187:   
2188:              result = new Ia.Cl.Model.Result();
2189:              accessList = null;
2190:   
2191:              input = rowInput.ToLower();
2192:   
2193:              try
2194:              {
2195:                  // note that this returns 0 int values for missing fields
2196:                  ExtractAreaBlockFromSearchAreaBlockTerm(input, out Ia.Ngn.Cl.Model.Business.Service.KuwaitNgnArea kuwaitNgnArea, out string block);
2197:   
2198:                  if (kuwaitNgnArea != null)
2199:                  {
2200:                      using (var db = new Ia.Ngn.Cl.Model.Ngn())
2201:                      {
2202:                          accessList = Ia.Ngn.Cl.Model.Data.Maintenance.Find.AccessListFromAreaAndBlock(kuwaitNgnArea.Id, block);
2203:                      }
2204:                  }
2205:                  else
2206:                  {
2207:                      result.AddError("The area of \"" + rowInput + "\" is unrecognized. ");
2208:                  }
2209:              }
2210:              catch (Exception ex)
2211:              {
2212:                  result.AddError("Exception: Retrieval error of data for \"" + rowInput + "\": " + ex.ToString());
2213:              }
2214:          }
2215:   
2216:          ////////////////////////////////////////////////////////////////////////////
2217:   
2218:          /// <summary>
2219:          ///
2220:          /// </summary>
2221:          public static void Address(string rowInput, out List<Ia.Ngn.Cl.Model.Access> accessList, out Ia.Cl.Model.Result result)
2222:          {
2223:              string input;
2224:   
2225:              result = new Ia.Cl.Model.Result();
2226:              accessList = null;
2227:   
2228:              input = rowInput.ToLower();
2229:   
2230:              try
2231:              {
2232:                  // note that this returns 0 int values for missing fields
2233:                  ExtractAddressFromSearchAddressTerm(input, out Ia.Ngn.Cl.Model.Business.Service.KuwaitNgnArea kuwaitNgnArea, out string block, out int street, out int premisesOld, out int premisesNew);
2234:   
2235:                  if (kuwaitNgnArea != null)
2236:                  {
2237:                      accessList = Ia.Ngn.Cl.Model.Data.Maintenance.Find.AccessListFromAddress(kuwaitNgnArea.Id, block, street, premisesOld, premisesNew);
2238:                  }
2239:                  else
2240:                  {
2241:                      result.AddError("The area of \"" + rowInput + "\" is unrecognized. ");
2242:                  }
2243:              }
2244:              catch (Exception ex)
2245:              {
2246:                  result.AddError("Exception: Retrieval error of data for \"" + rowInput + "\": " + ex.ToString());
2247:              }
2248:          }
2249:   
2250:          ////////////////////////////////////////////////////////////////////////////
2251:   
2252:          /// <summary>
2253:          ///
2254:          /// </summary>
2255:          public static void CustomerName(string rowInput, out List<Ia.Ngn.Cl.Model.ServiceRequest> serviceRequestList, out Ia.Cl.Model.Result result)
2256:          {
2257:              string input;
2258:              int maxNumberOfResults = 1000;
2259:              string customerName;
2260:   
2261:              result = new Ia.Cl.Model.Result();
2262:              serviceRequestList = null;
2263:   
2264:              input = rowInput.ToLower();
2265:   
2266:              try
2267:              {
2268:                  using (var db = new Ia.Ngn.Cl.Model.Ngn())
2269:                  {
2270:                      customerName = Ia.Ngn.Cl.Model.Business.Default.CorrectCustomerName(input);
2271:   
2272:                      if (!string.IsNullOrEmpty(customerName))
2273:                      {
2274:                          serviceRequestList = Ia.Ngn.Cl.Model.Data.Maintenance.Find.ServiceRequestListForCustomerName(customerName, maxNumberOfResults);
2275:   
2276:                          if (serviceRequestList.Count >= maxNumberOfResults) result.AddSuccess("The search returned " + maxNumberOfResults + " or more results. The output is limited to " + maxNumberOfResults + ". ");
2277:                      }
2278:                      else
2279:                      {
2280:                          serviceRequestList = null;
2281:                      }
2282:                  }
2283:              }
2284:              catch (Exception ex)
2285:              {
2286:                  result.AddError("Exception: Retrieval error of data for \"" + rowInput + "\": " + ex.ToString());
2287:              }
2288:          }
2289:   
2290:          ////////////////////////////////////////////////////////////////////////////
2291:   
2292:          /// <summary>
2293:          ///
2294:          /// </summary>
2295:          public static void CustomerId(string rowInput, out List<Ia.Ngn.Cl.Model.ServiceRequest> serviceRequestList, out Ia.Cl.Model.Result result)
2296:          {
2297:              string input;
2298:              int customerId, maxNumberOfResults = 1000;
2299:   
2300:              result = new Ia.Cl.Model.Result();
2301:              serviceRequestList = null;
2302:   
2303:              input = rowInput.ToLower();
2304:   
2305:              try
2306:              {
2307:                  using (var db = new Ia.Ngn.Cl.Model.Ngn())
2308:                  {
2309:                      customerId = int.Parse(input);
2310:   
2311:                      serviceRequestList = Ia.Ngn.Cl.Model.Data.Maintenance.Find.ServiceRequestListForCustomerId(customerId, maxNumberOfResults);
2312:   
2313:                      if (serviceRequestList.Count >= maxNumberOfResults) result.AddSuccess("The search returned " + maxNumberOfResults + " or more results. The output is limited to " + maxNumberOfResults + ". ");
2314:                  }
2315:              }
2316:              catch (Exception ex)
2317:              {
2318:                  result.AddError("Exception: Retrieval error of data for \"" + rowInput + "\": " + ex.ToString());
2319:              }
2320:          }
2321:   
2322:          ////////////////////////////////////////////////////////////////////////////
2323:   
2324:          /// <summary>
2325:          /// Extract area,block from search term like "SLA,2" {kuwaitAreaSymbol,block}
2326:          /// </summary>
2327:          private static void ExtractAreaBlockFromSearchAreaBlockTerm(string addressTerm, out Ia.Ngn.Cl.Model.Business.Service.KuwaitNgnArea kuwaitNgnArea, out string block)
2328:          {
2329:              int i;
2330:              string kuwaitNgnAreaSymbol;
2331:              Match match;
2332:   
2333:              // "SLA,2"
2334:              match = Regex.Match(addressTerm, @"^([a-zA-Z]{3}),(\d{1,3})$");
2335:   
2336:              kuwaitNgnAreaSymbol = match.Groups[1].Value;
2337:              block = match.Groups[2].Value;
2338:   
2339:              kuwaitNgnArea = (from kna in Ia.Ngn.Cl.Model.Data.Service.KuwaitNgnAreaList where kna.Symbol == kuwaitNgnAreaSymbol.ToUpper() select kna).FirstOrDefault();
2340:          }
2341:   
2342:          ////////////////////////////////////////////////////////////////////////////
2343:   
2344:          /// <summary>
2345:          /// Extract address from search term like "SLA,2,202,339,36" {kuwaitAreaSymbol,block,street,old premises,new premises}
2346:          /// </summary>
2347:          private static void ExtractAddressFromSearchAddressTerm(string addressTerm, out Ia.Ngn.Cl.Model.Business.Service.KuwaitNgnArea kuwaitNgnArea, out string block, out int street, out int premisesOld, out int premisesNew)
2348:          {
2349:              int i;
2350:              string kuwaitNgnAreaSymbol;
2351:              Match match;
2352:   
2353:              // "SLA,2,202,339,36"
2354:              match = Regex.Match(addressTerm, @"^([a-zA-Z]{3}),(\d{1,3}),(\d{0,3}),(\d{0,3}),(\d{0,3})$");
2355:   
2356:              kuwaitNgnAreaSymbol = match.Groups[1].Value;
2357:              block = match.Groups[2].Value;
2358:              street = int.TryParse(match.Groups[3].Value, out i) ? i : 0;
2359:              premisesOld = int.TryParse(match.Groups[4].Value, out i) ? i : 0;
2360:              premisesNew = int.TryParse(match.Groups[5].Value, out i) ? i : 0;
2361:   
2362:              kuwaitNgnArea = (from kna in Ia.Ngn.Cl.Model.Data.Service.KuwaitNgnAreaList where kna.Symbol == kuwaitNgnAreaSymbol.ToUpper() select kna).FirstOrDefault();
2363:          }
2364:   
2365:          ////////////////////////////////////////////////////////////////////////////
2366:          ////////////////////////////////////////////////////////////////////////////   
2367:      }
2368:   
2369:      ////////////////////////////////////////////////////////////////////////////
2370:      ////////////////////////////////////////////////////////////////////////////   
2371:  }