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

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