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

Integrated Applications Programming Company

Skip Navigation LinksHome » Code Library » VoipPstnUser

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

Huawei's EMS VOIP PSTN User support class of Next Generation Network'a (NGN's) data model.

   1:  using System;
   2:  using System.Collections.Generic;
   3:  using System.Data;
   4:  using System.Data.Entity;
   5:  using System.Linq;
   6:  using System.Text;
   7:   
   8:  namespace Ia.Ngn.Cl.Model.Data.Huawei
   9:  {
  10:      ////////////////////////////////////////////////////////////////////////////
  11:   
  12:      /// <summary publish="true">
  13:      /// Huawei's EMS VOIP PSTN User support class of Next Generation Network'a (NGN's) data model.
  14:      /// </summary>
  15:      /// 
  16:      /// <remarks> 
  17:      /// Copyright © 2017-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 partial class VoipPstnUser
  30:      {
  31:          /// <summary/>
  32:          public VoipPstnUser() { }
  33:   
  34:          ////////////////////////////////////////////////////////////////////////////
  35:   
  36:          /// <summary>
  37:          /// Update a single EmsVoipPstnUser item
  38:          /// </summary>
  39:          public static bool Update(Ia.Ngn.Cl.Model.Business.Huawei.Ems.Response response, out Ia.Cl.Model.Result result)
  40:          {
  41:              bool isUpdated;
  42:              int did, queryFn, querySn, queryPn, readItemCount, existingItemCount, insertedItemCount, updatedItemCount, deletedItemCount, fn, sn, pn;
  43:              string id, queryCommand, queryDev, dn;
  44:              DataColumnCollection columns;
  45:              DataRow columnDataRow;
  46:              Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Ont nddOnt;
  47:              Ia.Ngn.Cl.Model.Huawei.EmsVoipPstnUser voipPstnUser, newVoipPstnUser;
  48:              Ia.Ngn.Cl.Model.Huawei.EmsOnt emsOnt;
  49:              List<string> itemIdList;
  50:              List<Ia.Ngn.Cl.Model.Huawei.EmsVoipPstnUser> voipPstnUserList;
  51:   
  52:              isUpdated = false;
  53:              readItemCount = existingItemCount = insertedItemCount = updatedItemCount = deletedItemCount = 0;
  54:   
  55:              result = new Ia.Cl.Model.Result(); // remove initially then add to test all return paths
  56:   
  57:              if (response.QueryDataTable != null)
  58:              {
  59:                  queryCommand = response.CommandFromCorrelationTagDictionaryByCtag;
  60:   
  61:                  //queryCommand = "LST-VOIPPSTNUSER::DEV=MDU-SAB-1615-002,FN=0,SN=3,PN=1:647947868992::;";
  62:   
  63:                  // LST-VOIPPSTNUSER::DEV=MDU-JBA-943-002,FN=0,SN=3,PN=10:1111::;
  64:                  queryDev = Ia.Cl.Model.Default.Match(queryCommand, @"DEV=(.+?),");
  65:                  queryFn = int.Parse(Ia.Cl.Model.Default.Match(queryCommand, @"FN=(\d+)"));
  66:                  querySn = int.Parse(Ia.Cl.Model.Default.Match(queryCommand, @"SN=(\d+)"));
  67:                  queryPn = int.Parse(Ia.Cl.Model.Default.Match(queryCommand, @"PN=(\d+)"));
  68:   
  69:                  columns = response.QueryDataTable.Columns;
  70:                  readItemCount = response.QueryDataTable.Rows.Count;
  71:   
  72:                  nddOnt = Ia.Ngn.Cl.Model.Business.Default.NddOntFromHuaweiEmsAccessNameFormat(queryDev);
  73:   
  74:                  if (nddOnt != null)
  75:                  {
  76:                      itemIdList = new List<string>(response.QueryDataTable.Rows.Count + 1);
  77:   
  78:                      using (var db = new Ia.Ngn.Cl.Model.Ngn())
  79:                      {
  80:                          emsOnt = (from eo in db.EmsOnts where eo.Id == nddOnt.Id select eo).SingleOrDefault();
  81:   
  82:                          if (emsOnt != null)
  83:                          {
  84:                              // this should always give a single value or non
  85:                              voipPstnUserList = (from eo in db.EmsVoipPstnUsers where eo.EmsOnt.Id == emsOnt.Id && eo.SN == querySn && eo.PN == queryPn select eo).ToList();
  86:   
  87:                              existingItemCount = voipPstnUserList.Count;
  88:   
  89:                              if (response.QueryDataTable.Rows.Count >= 1)
  90:                              {
  91:                                  columnDataRow = response.QueryDataTable.Rows[0];
  92:   
  93:                                  foreach (DataRow dataRow in response.QueryDataTable.Rows)
  94:                                  {
  95:                                      did = int.Parse(dataRow[columns.IndexOf("DID")].ToString());
  96:                                      fn = int.Parse(dataRow[columns.IndexOf("FN")].ToString());
  97:                                      sn = int.Parse(dataRow[columns.IndexOf("SN")].ToString());
  98:                                      pn = int.Parse(dataRow[columns.IndexOf("PN")].ToString());
  99:   
 100:                                      dn = columns.Contains("DN") ? dataRow[columns.IndexOf("DN")].ToString() : string.Empty;
 101:   
 102:                                      if (pn == queryPn && sn == querySn)
 103:                                      {
 104:                                          // we will check that the records is for a real 11 digit number, otherwise we will not send it to the database
 105:                                          if (Ia.Ngn.Cl.Model.Business.NumberFormatConverter.IsMatchToServiceWithCountryCode(dn))
 106:                                          {
 107:                                              id = Ia.Ngn.Cl.Model.Business.Huawei.VoipPstnUser.VoipPstnUserId(nddOnt.Id, sn, pn);
 108:   
 109:                                              voipPstnUser = (from eo in voipPstnUserList where eo.Id == id select eo).SingleOrDefault();
 110:   
 111:                                              newVoipPstnUser = new Ia.Ngn.Cl.Model.Huawei.EmsVoipPstnUser()
 112:                                              {
 113:                                                  Id = id,
 114:                                                  DID = did,
 115:                                                  FN = fn,
 116:                                                  SN = sn,
 117:                                                  PN = pn,
 118:                                                  DN = dn.ToString(),
 119:                                                  MGID = columns.Contains("MGID") ? int.Parse(dataRow[columns.IndexOf("MGID")].ToString()) : 0,
 120:                                                  MGNAME = columns.Contains("MGNAME") ? dataRow[columns.IndexOf("MGNAME")].ToString() : string.Empty,
 121:                                                  TID = columns.Contains("TID") ? Ia.Ngn.Cl.Model.Business.Huawei.VoipPstnUser.SpecialIntegerParameterHandling("TID", dataRow[columns.IndexOf("TID")].ToString()) : 0,
 122:                                                  LayeredConf = columns.Contains("LayeredConf") ? dataRow[columns.IndexOf("LayeredConf")].ToString() : string.Empty,
 123:                                                  HighLevelWidth = columns.Contains("HighLevelWidth") ? int.Parse(dataRow[columns.IndexOf("HighLevelWidth")].ToString()) : 0,
 124:                                                  LowerLevelWidth = columns.Contains("LowerLevelWidth") ? int.Parse(dataRow[columns.IndexOf("LowerLevelWidth")].ToString()) : 0,
 125:                                                  Voltage = columns.Contains("Voltage") ? dataRow[columns.IndexOf("Voltage")].ToString() : string.Empty,
 126:                                                  KCType = columns.Contains("KCType") ? dataRow[columns.IndexOf("KCType")].ToString() : string.Empty,
 127:                                                  VoiceGain = columns.Contains("VoiceGain") ? dataRow[columns.IndexOf("VoiceGain")].ToString() : string.Empty,
 128:                                                  LimitPulseDial = columns.Contains("LimitPulseDial") ? dataRow[columns.IndexOf("LimitPulseDial")].ToString() : string.Empty,
 129:                                                  RevPolarity = columns.Contains("RevPolarity") ? dataRow[columns.IndexOf("RevPolarity")].ToString() : string.Empty,
 130:                                                  RevPoleLevel = columns.Contains("RevPoleLevel") ? int.Parse(dataRow[columns.IndexOf("RevPoleLevel")].ToString()) : 0,
 131:                                                  RevPolePulse = columns.Contains("RevPolePulse") ? dataRow[columns.IndexOf("RevPolePulse")].ToString() : string.Empty,
 132:                                                  PSTAT = columns.Contains("PSTAT") ? dataRow[columns.IndexOf("PSTAT")].ToString() : string.Empty,
 133:                                                  ConfigStatus = columns.Contains("ConfigStatus") ? dataRow[columns.IndexOf("ConfigStatus")].ToString() : string.Empty,
 134:                                                  ServiceStatus = columns.Contains("ServiceStatus") ? dataRow[columns.IndexOf("ServiceStatus")].ToString() : string.Empty,
 135:                                                  ServiceType = columns.Contains("ServiceType") ? dataRow[columns.IndexOf("ServiceType")].ToString() : string.Empty,
 136:                                                  ALIAS = columns.Contains("ALIAS") ? dataRow[columns.IndexOf("ALIAS")].ToString() : string.Empty,
 137:                                                  UserType = columns.Contains("UserType") ? dataRow[columns.IndexOf("UserType")].ToString() : string.Empty,
 138:                                                  Impedance = columns.Contains("Impedance") ? dataRow[columns.IndexOf("Impedance")].ToString() : string.Empty,
 139:                                                  Current = columns.Contains("Current") ? dataRow[columns.IndexOf("Current")].ToString() : string.Empty,
 140:                                                  DCTime = columns.Contains("DCTime") ? int.Parse(dataRow[columns.IndexOf("DCTime")].ToString()) : 0,
 141:                                                  PITime = columns.Contains("PITime") ? Ia.Ngn.Cl.Model.Business.Huawei.VoipPstnUser.SpecialIntegerParameterHandling("PITime", dataRow[columns.IndexOf("PITime")].ToString()) : 0,
 142:                                                  FSKDelayInterval = columns.Contains("FSKDelayInterval") ? int.Parse(dataRow[columns.IndexOf("FSKDelayInterval")].ToString()) : 0,
 143:                                                  ActualVoiceGain = columns.Contains("ActualVoiceGain") ? dataRow[columns.IndexOf("ActualVoiceGain")].ToString() : string.Empty,
 144:                                                  CidTransWhen = columns.Contains("CidTransWhen") ? dataRow[columns.IndexOf("CidTransWhen")].ToString() : string.Empty,
 145:                                                  CidFormat = columns.Contains("CidFormat") ? dataRow[columns.IndexOf("CidFormat")].ToString() : string.Empty,
 146:                                                  OverloadPRI = columns.Contains("OverloadPRI") ? dataRow[columns.IndexOf("OverloadPRI")].ToString() : string.Empty,
 147:                                                  ImpedanceProfile = columns.Contains("ImpedanceProfile") ? dataRow[columns.IndexOf("ImpedanceProfile")].ToString() : string.Empty,
 148:                                                  SendVoiceGain = columns.Contains("SendVoiceGain") ? dataRow[columns.IndexOf("SendVoiceGain")].ToString() : string.Empty,
 149:                                                  RecvVoiceGain = columns.Contains("RecvVoiceGain") ? dataRow[columns.IndexOf("RecvVoiceGain")].ToString() : string.Empty,
 150:                                                  RevPolarityMode = columns.Contains("RevPolarityMode") ? dataRow[columns.IndexOf("RevPolarityMode")].ToString() : string.Empty,
 151:                                                  PortRunState = columns.Contains("PortRunState") ? dataRow[columns.IndexOf("PortRunState")].ToString() : string.Empty,
 152:                                                  PortTestState = columns.Contains("PortTestState") ? dataRow[columns.IndexOf("PortTestState")].ToString() : string.Empty,
 153:                                                  PortLineState = columns.Contains("PortLineState") ? dataRow[columns.IndexOf("PortLineState")].ToString() : string.Empty,
 154:                                                  PortLoopState = columns.Contains("PortLoopState") ? dataRow[columns.IndexOf("PortLoopState")].ToString() : string.Empty,
 155:                                                  ServiceRunState = columns.Contains("ServiceRunState") ? dataRow[columns.IndexOf("ServiceRunState")].ToString() : string.Empty,
 156:                                                  ServiceAdminState = columns.Contains("ServiceAdminState") ? dataRow[columns.IndexOf("ServiceAdminState")].ToString() : string.Empty,
 157:                                                  ActualSendVoiceGain = columns.Contains("ActualSendVoiceGain") ? dataRow[columns.IndexOf("ActualSendVoiceGain")].ToString() : string.Empty,
 158:                                                  ActualRecvVo = columns.Contains("ActualRecvVo") ? dataRow[columns.IndexOf("ActualRecvVo")].ToString() : string.Empty,
 159:                                                  AGCEnable = columns.Contains("AGCEnable") ? dataRow[columns.IndexOf("AGCEnable")].ToString() : string.Empty,
 160:                                                  AGCEnableLevel = columns.Contains("AGCEnableLevel") ? int.Parse(dataRow[columns.IndexOf("AGCEnableLevel")].ToString()) : 0,
 161:                                                  SNSEnable = columns.Contains("SNSEnable") ? dataRow[columns.IndexOf("SNSEnable")].ToString() : string.Empty,
 162:                                                  SNSEnableLevel = columns.Contains("SNSEnableLevel") ? int.Parse(dataRow[columns.IndexOf("SNSEnableLevel")].ToString()) : 0,
 163:                                                  NlpMode = columns.Contains("NlpMode") ? dataRow[columns.IndexOf("NlpMode")].ToString() : string.Empty,
 164:                                                  LineLockEnable = columns.Contains("LineLockEnable") ? dataRow[columns.IndexOf("LineLockEnable")].ToString() : string.Empty,
 165:                                                  DspInputGain = columns.Contains("DspInputGain") ? dataRow[columns.IndexOf("DspInputGain")].ToString() : string.Empty,
 166:                                                  DspOutputGain = columns.Contains("DspOutputGain") ? dataRow[columns.IndexOf("DspOutputGain")].ToString() : string.Empty,
 167:                                                  ClipReversePole = columns.Contains("ClipReversePole") ? dataRow[columns.IndexOf("ClipReversePole")].ToString() : string.Empty,
 168:                                                  DEFAULTCLI = columns.Contains("DEFAULTCLI") ? dataRow[columns.IndexOf("DEFAULTCLI")].ToString() : string.Empty,
 169:                                                  USERGROUPID = columns.Contains("USERGROUPID") ? int.Parse(dataRow[columns.IndexOf("USERGROUPID")].ToString()) : 0,
 170:                                                  ADJUSTFACTOR = columns.Contains("ADJUSTFACTOR") ? int.Parse(dataRow[columns.IndexOf("ADJUSTFACTOR")].ToString()) : 0,
 171:                                                  DSPPROFILE = columns.Contains("DSPPROFILE") ? dataRow[columns.IndexOf("DSPPROFILE")].ToString() : string.Empty,
 172:   
 173:                                                  EmsOnt = (from eo in db.EmsOnts where eo.Id == nddOnt.Id select eo).SingleOrDefault()
 174:                                              };
 175:   
 176:                                              if (voipPstnUser == null)
 177:                                              {
 178:                                                  newVoipPstnUser.Created = newVoipPstnUser.Updated = DateTime.UtcNow.AddHours(3);
 179:   
 180:                                                  db.EmsVoipPstnUsers.Add(newVoipPstnUser);
 181:   
 182:                                                  insertedItemCount++;
 183:                                              }
 184:                                              else // update
 185:                                              {
 186:                                                  // below: copy values from newVoipPstnUser to ontSipInfo
 187:   
 188:                                                  if (voipPstnUser.Update(newVoipPstnUser))
 189:                                                  {
 190:                                                      db.EmsVoipPstnUsers.Attach(voipPstnUser);
 191:                                                      db.Entry(voipPstnUser).State = System.Data.Entity.EntityState.Modified;
 192:   
 193:                                                      updatedItemCount++;
 194:                                                  }
 195:                                              }
 196:   
 197:                                              itemIdList.Add(id); // keep at the end
 198:                                          }
 199:                                          else
 200:                                          {
 201:   
 202:                                          }
 203:                                      }
 204:                                      else
 205:                                      {
 206:                                          result.AddError("pn != queryPn and/or sn != querySn for ont.Access.Name: " + nddOnt.Access.Name);
 207:                                      }
 208:                                  }
 209:   
 210:                                  // below: this function will remove values that were not present in the reading
 211:                                  if (voipPstnUserList.Count > 0)
 212:                                  {
 213:                                      foreach (Ia.Ngn.Cl.Model.Huawei.EmsVoipPstnUser o in voipPstnUserList)
 214:                                      {
 215:                                          if (!itemIdList.Contains(o.Id))
 216:                                          {
 217:                                              voipPstnUser = (from osi in db.EmsVoipPstnUsers where osi.Id == o.Id select osi).SingleOrDefault();
 218:   
 219:                                              db.EmsVoipPstnUsers.Remove(voipPstnUser);
 220:   
 221:                                              deletedItemCount++;
 222:                                          }
 223:                                      }
 224:                                  }
 225:                              }
 226:                              else //if (response.QueryDataTable.Rows.Count == 0)
 227:                              {
 228:                                  // note sometimes the response is ONT IS OFFLINE
 229:                                  // delete all ONT SIP INFO elements for this ONT
 230:   
 231:                                  /*
 232:                                  if (ontSipInfoList.Count > 0)
 233:                                  {
 234:                                      foreach (Ia.Ngn.Cl.Model.Huawei.EmsVoipPstnUser o in ontSipInfoList)
 235:                                      {
 236:                                          ontSipInfo = (from osi in db.EmsVoipPstnUsers where osi.Id == o.Id select osi).SingleOrDefault();
 237:  
 238:                                          db.EmsVoipPstnUsers.Remove(ontSipInfo);
 239:  
 240:                                          deletedItemCount++;
 241:                                      }
 242:                                  }
 243:                                  */
 244:                              }
 245:   
 246:                              db.SaveChanges();
 247:                          }
 248:                          else
 249:                          {
 250:                              result.AddWarning("EmsOnt is null for ont.Access.Name: " + nddOnt.Access.Name);
 251:                          }
 252:                      }
 253:   
 254:                      if (insertedItemCount != 0 || updatedItemCount != 0 || deletedItemCount != 0) isUpdated = true;
 255:                      else isUpdated = false;
 256:   
 257:                      result.AddSuccess("(" + readItemCount + "/" + existingItemCount + "/" + insertedItemCount + "," + updatedItemCount + "," + deletedItemCount + ")");
 258:                  }
 259:                  else
 260:                  {
 261:                      result.AddError("nddOnt is null");
 262:                  }
 263:              }
 264:              else
 265:              {
 266:                  result.AddWarning("response.QueryDataTable is null");
 267:              }
 268:   
 269:              return isUpdated;
 270:          }
 271:   
 272:          ////////////////////////////////////////////////////////////////////////////
 273:   
 274:          /// <summary>
 275:          ///
 276:          /// </summary>
 277:          public static List<Ia.Ngn.Cl.Model.Huawei.EmsVoipPstnUser> List()
 278:          {
 279:              List<Ia.Ngn.Cl.Model.Huawei.EmsVoipPstnUser> list;
 280:   
 281:              using (var db = new Ia.Ngn.Cl.Model.Ngn())
 282:              {
 283:                  list = (from vpu in db.EmsVoipPstnUsers select vpu).ToList();
 284:              }
 285:   
 286:              return list;
 287:          }
 288:   
 289:          ////////////////////////////////////////////////////////////////////////////
 290:   
 291:          /// <summary>
 292:          /// List of service number ids within EmsVoipPstnUsers within a SIP designated OLT
 293:          /// </summary>
 294:          public static List<string> ServiceIdWithinSipOltList()
 295:          {
 296:              int serviceType;
 297:              string service, serviceId;
 298:              List<int> sipOltIdList;
 299:              List<string> list, serviceIdList;
 300:   
 301:              serviceType = Ia.Ngn.Cl.Model.Business.Service.ServiceType.NgnService;
 302:              sipOltIdList = Ia.Ngn.Cl.Model.Data.NetworkDesignDocument.SipOltIdList;
 303:   
 304:              using (var db = new Ia.Ngn.Cl.Model.Ngn())
 305:              {
 306:                  list = (from vpu in db.EmsVoipPstnUsers where vpu.EmsOnt.Access != null && sipOltIdList.Contains(vpu.EmsOnt.Access.Olt) select vpu.DN).ToList();
 307:              }
 308:   
 309:              if (list != null && list.Count > 0)
 310:              {
 311:                  serviceIdList = new List<string>(list.Count);
 312:   
 313:                  foreach (string s in list)
 314:                  {
 315:                      service = Ia.Ngn.Cl.Model.Business.NumberFormatConverter.Service(s);
 316:   
 317:                      serviceId = Ia.Ngn.Cl.Model.Business.Service.ServiceToServiceId(service, serviceType);
 318:   
 319:                      serviceIdList.Add(serviceId);
 320:                  }
 321:              }
 322:              else
 323:              {
 324:                  serviceIdList = new List<string>();
 325:              }
 326:   
 327:              return serviceIdList;
 328:          }
 329:   
 330:          ////////////////////////////////////////////////////////////////////////////
 331:   
 332:          /// <summary>
 333:          /// List of service number ids within EmsVoipPstnUsers within a SIP allowed to be provisioned or migrated OLT
 334:          /// </summary>
 335:          public static List<string> ServiceIdWithinAllowedSipOltToBeProvisionedOrMigratedList()
 336:          {
 337:              int serviceType;
 338:              string service, serviceId;
 339:              List<int> sipOltIdList;
 340:              List<string> list, serviceIdList;
 341:   
 342:              serviceType = Ia.Ngn.Cl.Model.Business.Service.ServiceType.NgnService;
 343:              sipOltIdList = Ia.Ngn.Cl.Model.Data.Service.AllowedToBeProvisionedSipOltIdList.Union(Ia.Ngn.Cl.Model.Data.Service.AllowedToBeMigratedSipOltIdList).ToList();
 344:   
 345:              using (var db = new Ia.Ngn.Cl.Model.Ngn())
 346:              {
 347:                  list = (from vpu in db.EmsVoipPstnUsers where vpu.EmsOnt.Access != null && sipOltIdList.Contains(vpu.EmsOnt.Access.Olt) select vpu.DN).ToList();
 348:              }
 349:   
 350:              if (list != null && list.Count > 0)
 351:              {
 352:                  serviceIdList = new List<string>(list.Count);
 353:   
 354:                  foreach (string s in list)
 355:                  {
 356:                      service = Ia.Ngn.Cl.Model.Business.NumberFormatConverter.Service(s);
 357:   
 358:                      serviceId = Ia.Ngn.Cl.Model.Business.Service.ServiceToServiceId(service, serviceType);
 359:   
 360:                      serviceIdList.Add(serviceId);
 361:                  }
 362:              }
 363:              else
 364:              {
 365:                  serviceIdList = new List<string>();
 366:              }
 367:   
 368:              return serviceIdList;
 369:          }
 370:   
 371:          ////////////////////////////////////////////////////////////////////////////
 372:   
 373:          /// <summary>
 374:          ///
 375:          /// </summary>
 376:          public static Ia.Ngn.Cl.Model.Huawei.EmsVoipPstnUser Read(string id)
 377:          {
 378:              Ia.Ngn.Cl.Model.Huawei.EmsVoipPstnUser item;
 379:   
 380:              using (var db = new Ia.Ngn.Cl.Model.Ngn())
 381:              {
 382:                  item = (from vpu in db.EmsVoipPstnUsers where vpu.Id == id select vpu).Include(o => o.EmsOnt).SingleOrDefault();
 383:              }
 384:   
 385:              return item;
 386:          }
 387:   
 388:          ////////////////////////////////////////////////////////////////////////////
 389:   
 390:          /// <summary>
 391:          ///
 392:          /// </summary>
 393:          public static Ia.Ngn.Cl.Model.Huawei.EmsVoipPstnUser ReadByService(string service) //, Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Ont nddOnt)
 394:          {
 395:              string dn;
 396:              Ia.Ngn.Cl.Model.Huawei.EmsVoipPstnUser item;
 397:   
 398:              dn = Ia.Ngn.Cl.Model.Business.NumberFormatConverter.ServiceWithCountryCode(service);
 399:   
 400:              using (var db = new Ia.Ngn.Cl.Model.Ngn())
 401:              {
 402:                  item = (from vpu in db.EmsVoipPstnUsers where vpu.DN == dn select vpu).Include(o => o.EmsOnt).Include(o => o.EmsOnt.Access).SingleOrDefault();
 403:              }
 404:   
 405:              return item;
 406:          }
 407:   
 408:          ////////////////////////////////////////////////////////////////////////////
 409:   
 410:          /// <summary>
 411:          ///
 412:          /// </summary>
 413:          public static Dictionary<string, string> IdToOntIdDictionary
 414:          {
 415:              get
 416:              {
 417:                  Dictionary<string, string> dictionary;
 418:   
 419:                  using (var db = new Ia.Ngn.Cl.Model.Ngn())
 420:                  {
 421:                      dictionary = (from s in db.EmsVoipPstnUsers select new { s.Id, OntId = s.EmsOnt.Id }).ToDictionary(u => u.Id, u => u.OntId);
 422:                  }
 423:   
 424:                  return dictionary.ToDictionary(u => u.Key, u => u.Value);
 425:              }
 426:          }
 427:   
 428:          ////////////////////////////////////////////////////////////////////////////
 429:          ////////////////////////////////////////////////////////////////////////////
 430:   
 431:          /// <summary>
 432:          ///
 433:          /// </summary>
 434:          public static string ToSimpleTextString(Ia.Ngn.Cl.Model.Huawei.EmsVoipPstnUser emsVoipPstnUser)
 435:          {
 436:              StringBuilder sb;
 437:   
 438:              sb = new StringBuilder();
 439:   
 440:              //sb.AppendLine("Vendor: " + Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Vendor.Huawei.Name);
 441:              sb.AppendLine("DID: " + emsVoipPstnUser.DID);
 442:              sb.AppendLine("FN: " + emsVoipPstnUser.FN);
 443:              sb.AppendLine("SN: " + emsVoipPstnUser.SN);
 444:              sb.AppendLine("PN: " + emsVoipPstnUser.PN);
 445:              sb.AppendLine("MGID: " + emsVoipPstnUser.MGID);
 446:              sb.AppendLine("MGNAME: " + emsVoipPstnUser.MGNAME);
 447:              sb.AppendLine("TID: " + emsVoipPstnUser.TID);
 448:              sb.AppendLine("DN: " + emsVoipPstnUser.DN);
 449:              sb.AppendLine("LayeredConf: " + emsVoipPstnUser.LayeredConf);
 450:              sb.AppendLine("HighLevelWidth: " + emsVoipPstnUser.HighLevelWidth);
 451:              sb.AppendLine("LowerLevelWidth: " + emsVoipPstnUser.LowerLevelWidth);
 452:              sb.AppendLine("Voltage: " + emsVoipPstnUser.Voltage);
 453:              sb.AppendLine("KCType: " + emsVoipPstnUser.KCType);
 454:              sb.AppendLine("VoiceGain: " + emsVoipPstnUser.VoiceGain);
 455:              sb.AppendLine("LimitPulseDial: " + emsVoipPstnUser.LimitPulseDial);
 456:              sb.AppendLine("RevPolarity: " + emsVoipPstnUser.RevPolarity);
 457:              sb.AppendLine("RevPoleLevel: " + emsVoipPstnUser.RevPoleLevel);
 458:              sb.AppendLine("RevPolePulse: " + emsVoipPstnUser.RevPolePulse);
 459:              sb.AppendLine("PSTAT: " + emsVoipPstnUser.PSTAT);
 460:              sb.AppendLine("ConfigStatus: " + emsVoipPstnUser.ConfigStatus);
 461:              sb.AppendLine("ServiceStatus: " + emsVoipPstnUser.ServiceStatus);
 462:              sb.AppendLine("ServiceType: " + emsVoipPstnUser.ServiceType);
 463:              sb.AppendLine("ALIAS: " + emsVoipPstnUser.ALIAS);
 464:              sb.AppendLine("UserType: " + emsVoipPstnUser.UserType);
 465:              sb.AppendLine("Impedance: " + emsVoipPstnUser.Impedance);
 466:              sb.AppendLine("Current: " + emsVoipPstnUser.Current);
 467:              sb.AppendLine("DCTime: " + emsVoipPstnUser.DCTime);
 468:              sb.AppendLine("PITime: " + emsVoipPstnUser.PITime);
 469:              sb.AppendLine("FSKDelayInterval: " + emsVoipPstnUser.FSKDelayInterval);
 470:              sb.AppendLine("ActualVoiceGain: " + emsVoipPstnUser.ActualVoiceGain);
 471:              sb.AppendLine("CidTransWhen: " + emsVoipPstnUser.CidTransWhen);
 472:              sb.AppendLine("CidFormat: " + emsVoipPstnUser.CidFormat);
 473:              sb.AppendLine("OverloadPRI: " + emsVoipPstnUser.OverloadPRI);
 474:              sb.AppendLine("ImpedanceProfile: " + emsVoipPstnUser.ImpedanceProfile);
 475:              sb.AppendLine("SendVoiceGain: " + emsVoipPstnUser.SendVoiceGain);
 476:              sb.AppendLine("RecvVoiceGain: " + emsVoipPstnUser.RecvVoiceGain);
 477:              sb.AppendLine("RevPolarityMode: " + emsVoipPstnUser.RevPolarityMode);
 478:              sb.AppendLine("PortRunState: " + emsVoipPstnUser.PortRunState);
 479:              sb.AppendLine("PortTestState: " + emsVoipPstnUser.PortTestState);
 480:              sb.AppendLine("PortLineState: " + emsVoipPstnUser.PortLineState);
 481:              sb.AppendLine("PortLoopState: " + emsVoipPstnUser.PortLoopState);
 482:              sb.AppendLine("ServiceRunState: " + emsVoipPstnUser.ServiceRunState);
 483:              sb.AppendLine("ServiceAdminState: " + emsVoipPstnUser.ServiceAdminState);
 484:              sb.AppendLine("ActualSendVoiceGain: " + emsVoipPstnUser.ActualSendVoiceGain);
 485:              sb.AppendLine("ActualRecvVo: " + emsVoipPstnUser.ActualRecvVo);
 486:              sb.AppendLine("AGCEnable: " + emsVoipPstnUser.AGCEnable);
 487:              sb.AppendLine("AGCEnableLevel: " + emsVoipPstnUser.AGCEnableLevel);
 488:              sb.AppendLine("SNSEnable: " + emsVoipPstnUser.SNSEnable);
 489:              sb.AppendLine("SNSEnableLevel: " + emsVoipPstnUser.SNSEnableLevel);
 490:              sb.AppendLine("NlpMode: " + emsVoipPstnUser.NlpMode);
 491:              sb.AppendLine("LineLockEnable: " + emsVoipPstnUser.LineLockEnable);
 492:              sb.AppendLine("DspInputGain: " + emsVoipPstnUser.DspInputGain);
 493:              sb.AppendLine("DspOutputGain: " + emsVoipPstnUser.DspOutputGain);
 494:              sb.AppendLine("ClipReversePole: " + emsVoipPstnUser.ClipReversePole);
 495:              sb.AppendLine("DEFAULTCLI: " + emsVoipPstnUser.DEFAULTCLI);
 496:              sb.AppendLine("USERGROUPID: " + emsVoipPstnUser.USERGROUPID);
 497:              sb.AppendLine("ADJUSTFACTOR: " + emsVoipPstnUser.ADJUSTFACTOR);
 498:              sb.AppendLine("DSPPROFILE: " + emsVoipPstnUser.DSPPROFILE);
 499:   
 500:              return sb.ToString();
 501:          }
 502:   
 503:          ////////////////////////////////////////////////////////////////////////////
 504:          ////////////////////////////////////////////////////////////////////////////
 505:      }
 506:   
 507:      ////////////////////////////////////////////////////////////////////////////
 508:      ////////////////////////////////////////////////////////////////////////////
 509:  }