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

Integrated Applications Programming Company

Skip Navigation LinksHome » Code Library » Ems

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

Access Management System (AMS) support class for Huawei's Next Generation Network (NGN) data model.

   1:  using System.Collections.Generic;
   2:  using System.Data;
   3:  using System.Linq;
   4:   
   5:  namespace Ia.Ngn.Cl.Model.Data.Huawei
   6:  {
   7:      ////////////////////////////////////////////////////////////////////////////
   8:   
   9:      /// <summary publish="true">
  10:      /// Access Management System (AMS) support class for Huawei's Next Generation Network (NGN) data model.
  11:      /// </summary>
  12:   
  13:      /// <remarks> 
  14:      /// Copyright © 2016-2018 Jasem Y. Al-Shamlan (info@ia.com.kw), Integrated Applications - Kuwait. All Rights Reserved.
  15:      ///
  16:      /// 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
  17:      /// the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
  18:      ///
  19:      /// This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
  20:      /// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
  21:      /// 
  22:      /// You should have received a copy of the GNU General Public License along with this library. If not, see http://www.gnu.org/licenses.
  23:      /// 
  24:      /// Copyright notice: This notice may not be removed or altered from any source distribution.
  25:      /// </remarks> 
  26:      public partial class Ems
  27:      {
  28:          private static Dictionary<string, string> correlationTagDictionary = new Dictionary<string, string>(1000);
  29:   
  30:          public static Dictionary<string, string> CorrelationTagDictionary { get { return correlationTagDictionary; } set { correlationTagDictionary = value; } }
  31:   
  32:          ////////////////////////////////////////////////////////////////////////////
  33:   
  34:          /// <summary>
  35:          ///
  36:          /// </summary>
  37:          public Ems() { }
  38:   
  39:          ////////////////////////////////////////////////////////////////////////////
  40:   
  41:          /// <summary>
  42:          ///
  43:          /// </summary>
  44:          public static string BellcoreStateFromId(int stateId)
  45:          {
  46:              // see: ColoredBellcoreStateFromId()
  47:              string s;
  48:              Ia.Ngn.Cl.Model.Business.Huawei.Ems.BellcoreState bellcoreState;
  49:   
  50:              bellcoreState = (Ia.Ngn.Cl.Model.Business.Huawei.Ems.BellcoreState)stateId;
  51:   
  52:              /*
  53:               * IS-NR: (In-Service and Normal) The entity is fully operational and will perform as provisioned.
  54:               * OOS-AU: (Out-of-Service and Autonomous) The entity is not operational because of an autonomous event.
  55:               * OOS-AUMA: (Out-of-Service and Autonomous Management) The entity is not operational because of an autonomous event and has also been manually removed from service.
  56:               * OOS-MA: (Out-of-Service and Management) The entity has been manually removed from service.
  57:               */
  58:   
  59:              switch (bellcoreState)
  60:              {
  61:                  case Ia.Ngn.Cl.Model.Business.Huawei.Ems.BellcoreState.IsNr: s = "IS-NR"; break;
  62:                  case Ia.Ngn.Cl.Model.Business.Huawei.Ems.BellcoreState.OosAu: s = "OOS-AU"; break;
  63:                  case Ia.Ngn.Cl.Model.Business.Huawei.Ems.BellcoreState.OosAuma: s = "OOS-AUMA"; break;
  64:                  case Ia.Ngn.Cl.Model.Business.Huawei.Ems.BellcoreState.OosMa: s = "OOS-MA"; break;
  65:                  case Ia.Ngn.Cl.Model.Business.Huawei.Ems.BellcoreState.Unknown: s = "Unknown"; break;
  66:                  default: s = "Unknown"; break;
  67:              }
  68:   
  69:              return s;
  70:          }
  71:   
  72:          ////////////////////////////////////////////////////////////////////////////
  73:   
  74:          /// <summary>
  75:          ///
  76:          /// </summary>
  77:          public static string ColoredBellcoreStateFromId(int stateId)
  78:          {
  79:              // see: BellcoreStateFromId()
  80:              string s;
  81:              Ia.Ngn.Cl.Model.Business.Huawei.Ems.BellcoreState bellcoreState;
  82:   
  83:              bellcoreState = (Ia.Ngn.Cl.Model.Business.Huawei.Ems.BellcoreState)stateId;
  84:   
  85:              /*
  86:                  if (b) s = "<span style=\"color:Green\">Active</span>";
  87:                  else s = "<span style=\"color:DarkGoldenRod\">Idle</span>";             */
  88:              switch (bellcoreState)
  89:              {
  90:                  case Ia.Ngn.Cl.Model.Business.Huawei.Ems.BellcoreState.IsNr: s = "<span style=\"color:Green\">IS-NR</span>"; break;
  91:                  case Ia.Ngn.Cl.Model.Business.Huawei.Ems.BellcoreState.OosAu: s = "<span style=\"color:Red\">OOS-AU</span>"; break;
  92:                  case Ia.Ngn.Cl.Model.Business.Huawei.Ems.BellcoreState.OosAuma: s = "<span style=\"color:Red\">OOS-AUMA</span>"; break;
  93:                  case Ia.Ngn.Cl.Model.Business.Huawei.Ems.BellcoreState.OosMa: s = "<span style=\"color:Red\">OOS-MA</span>"; break;
  94:                  case Ia.Ngn.Cl.Model.Business.Huawei.Ems.BellcoreState.Unknown: s = "<span style=\"color:Red\">Unknown</span>"; break;
  95:                  default: s = "Unknown"; break;
  96:              }
  97:   
  98:              return s;
  99:          }
 100:   
 101:          ////////////////////////////////////////////////////////////////////////////
 102:   
 103:          /// <summary>
 104:          ///
 105:          /// </summary>
 106:          public static int NextVacantTelForOnt(Ia.Ngn.Cl.Model.Huawei.EmsOnt emsOnt)
 107:          {
 108:              int telPort;
 109:              List<int> list;
 110:   
 111:              list = Ia.Ngn.Cl.Model.Data.Huawei.Ems.UsedTelListForEmsOntId(emsOnt.Id);
 112:   
 113:              if (list.Count == 0) telPort = 1; // this means OntSipInfo does not exist for any number and the box is empty, and we should create number at 1
 114:              else
 115:              {
 116:                  list = Ia.Cl.Model.Default.ExcludedNumberListFromNumberListWithinRange(list, emsOnt.EquipmentType.TelPorts);
 117:   
 118:                  if (list.Count > 0) telPort = list[0];
 119:                  else telPort = Ia.Ngn.Cl.Model.Business.Default.PortUndefinedOrInvalidOrUnknown; // something went wrong
 120:              }
 121:   
 122:              return telPort;
 123:          }
 124:   
 125:          ////////////////////////////////////////////////////////////////////////////
 126:   
 127:          /// <summary>
 128:          ///
 129:          /// </summary>
 130:          public static List<int> VacantTelForOntList(Ia.Ngn.Cl.Model.Huawei.EmsOnt emsOnt)
 131:          {
 132:              List<int> usedlist, vacantList;
 133:   
 134:              usedlist = Ia.Ngn.Cl.Model.Data.Huawei.Ems.UsedTelListForEmsOntId(emsOnt.Id);
 135:   
 136:              vacantList = Ia.Cl.Model.Default.ExcludedNumberListFromNumberListWithinRange(usedlist, emsOnt.EquipmentType.TelPorts);
 137:   
 138:              return vacantList;
 139:          }
 140:   
 141:          ////////////////////////////////////////////////////////////////////////////
 142:   
 143:          /// <summary>
 144:          ///
 145:          /// </summary>
 146:          public static Ia.Ngn.Cl.Model.Business.Huawei.Default.FnSnPn NextVacantMduFnSnPnForOnt(Ia.Ngn.Cl.Model.Business.Huawei.Dev.MduDev mdu, Ia.Ngn.Cl.Model.Huawei.EmsOnt emsOnt)
 147:          {
 148:              Ia.Ngn.Cl.Model.Business.Huawei.Default.FnSnPn fnSnPn;
 149:              List<Ia.Ngn.Cl.Model.Business.Huawei.Default.FnSnPn> usedList, possibleList, list;
 150:   
 151:              usedList = Ia.Ngn.Cl.Model.Data.Huawei.Ems.UsedEmsVoipPstnUserFnSnPnListForEmsOntId(emsOnt.Id);
 152:   
 153:              if (usedList.Count == 0)
 154:              {
 155:                  fnSnPn = mdu.PossibleFnSnPnList[0]; // this means EmsVoipPstnUsers does not exist for any number and the box is empty, and we should create number at 0
 156:              }
 157:              else
 158:              {
 159:                  possibleList = mdu.PossibleFnSnPnList;
 160:   
 161:                  list = possibleList.Where(p => !usedList.Any(u => u.Fn == p.Fn && u.Sn == p.Sn && u.Pn == p.Pn)).ToList();
 162:   
 163:                  if (list.Count > 0) fnSnPn = list[0];
 164:                  else fnSnPn = null; // something went wrong
 165:              }
 166:   
 167:              return fnSnPn;
 168:          }
 169:   
 170:          ////////////////////////////////////////////////////////////////////////////
 171:   
 172:          /// <summary>
 173:          ///
 174:          /// </summary>
 175:          public static List<Ia.Ngn.Cl.Model.Business.Huawei.Default.FnSnPn> VacantMduFnSnPnForOntList(Ia.Ngn.Cl.Model.Business.Huawei.Dev.MduDev mdu, Ia.Ngn.Cl.Model.Huawei.EmsOnt emsOnt)
 176:          {
 177:              List<Ia.Ngn.Cl.Model.Business.Huawei.Default.FnSnPn> usedList, possibleList, vacantlist;
 178:   
 179:              usedList = Ia.Ngn.Cl.Model.Data.Huawei.Ems.UsedEmsVoipPstnUserFnSnPnListForEmsOntId(emsOnt.Id);
 180:   
 181:              possibleList = mdu.PossibleFnSnPnList;
 182:   
 183:              vacantlist = possibleList.Where(p => !usedList.Any(u => u.Fn == p.Fn && u.Sn == p.Sn && u.Pn == p.Pn)).ToList();
 184:   
 185:              return vacantlist;
 186:          }
 187:   
 188:          ////////////////////////////////////////////////////////////////////////////
 189:   
 190:          /// <summary>
 191:          ///
 192:          /// </summary>
 193:          private static List<int> UsedTelListForEmsOntId(string emsOntId)
 194:          {
 195:              List<int> list;
 196:   
 197:              using (var db = new Ia.Ngn.Cl.Model.Ngn())
 198:              {
 199:                  list = (from eosi in db.EmsOntSipInfoes where eosi.EmsOnt.Id == emsOntId orderby eosi.TEL ascending select eosi.TEL).ToList<int>();
 200:              }
 201:   
 202:              return list;
 203:          }
 204:   
 205:          ////////////////////////////////////////////////////////////////////////////
 206:   
 207:          /// <summary>
 208:          ///
 209:          /// </summary>
 210:          private static List<Ia.Ngn.Cl.Model.Business.Huawei.Default.FnSnPn> UsedEmsVoipPstnUserFnSnPnListForEmsOntId(string emsOntId)
 211:          {
 212:              List<Ia.Ngn.Cl.Model.Business.Huawei.Default.FnSnPn> list;
 213:   
 214:              using (var db = new Ia.Ngn.Cl.Model.Ngn())
 215:              {
 216:                  list = (from evpu in db.EmsVoipPstnUsers
 217:                          where evpu.EmsOnt.Id == emsOntId
 218:                          // below select will produce "Exception: System.NotSupportedException: Only parameterless constructors and initializers are supported in LINQ to Entities."
 219:                          // select new Ia.Ngn.Cl.Model.Business.Huawei.Default.FnSnPn(evpu.FN, evpu.SN, evpu.PN)).ToList<Ia.Ngn.Cl.Model.Business.Huawei.Default.FnSnPn>();
 220:                          select new Ia.Ngn.Cl.Model.Business.Huawei.Default.FnSnPn { Fn = evpu.FN, Sn = evpu.SN, Pn = evpu.PN }).ToList<Ia.Ngn.Cl.Model.Business.Huawei.Default.FnSnPn>();
 221:              }
 222:   
 223:              return list;
 224:          }
 225:   
 226:          ////////////////////////////////////////////////////////////////////////////
 227:          ////////////////////////////////////////////////////////////////////////////
 228:   
 229:          /// <summary>
 230:          ///
 231:          /// </summary>
 232:          public static void SendReadDevListByDt(Ia.Ngn.Cl.Model.Client.Huawei.Ems ems, string devType)
 233:          {
 234:              var command = Ia.Ngn.Cl.Model.Business.Huawei.Ems.ReadDevListByDtCommand(devType);
 235:   
 236:              ems.SendQueue.Enqueue(command);
 237:          }
 238:   
 239:          ////////////////////////////////////////////////////////////////////////////
 240:   
 241:          /// <summary>
 242:          ///
 243:          /// </summary>
 244:          public static void SendReadDevListByDev(Ia.Ngn.Cl.Model.Client.Huawei.Ems ems, string dev)
 245:          {
 246:              var command = Ia.Ngn.Cl.Model.Business.Huawei.Ems.ReadDevListByDevCommand(dev);
 247:   
 248:              ems.SendQueue.Enqueue(command);
 249:          }
 250:   
 251:          ////////////////////////////////////////////////////////////////////////////
 252:   
 253:          /// <summary>
 254:          ///
 255:          /// </summary>
 256:          public static void SendSaveDev(Ia.Ngn.Cl.Model.Client.Huawei.Ems ems, Ia.Ngn.Cl.Model.Business.Huawei.Dev.MduDev mduDev)
 257:          {
 258:              var command = Ia.Ngn.Cl.Model.Business.Huawei.Ems.SaveDevCommand(mduDev);
 259:   
 260:              ems.SendQueue.Enqueue(command);
 261:          }
 262:   
 263:          ////////////////////////////////////////////////////////////////////////////
 264:          ////////////////////////////////////////////////////////////////////////////
 265:   
 266:          /// <summary>
 267:          ///
 268:          /// </summary>
 269:          public static void SendReadBoardList(Ia.Ngn.Cl.Model.Client.Huawei.Ems ems, string dev)
 270:          {
 271:              var command = Ia.Ngn.Cl.Model.Business.Huawei.Ems.ReadBoardListCommand(dev);
 272:   
 273:              ems.SendQueue.Enqueue(command);
 274:          }
 275:   
 276:          ////////////////////////////////////////////////////////////////////////////
 277:   
 278:          /// <summary>
 279:          ///
 280:          /// </summary>
 281:          public static void SendReadOntList(Ia.Ngn.Cl.Model.Client.Huawei.Ems ems, int did)
 282:          {
 283:              var command = Ia.Ngn.Cl.Model.Business.Huawei.Ems.ReadOntListCommand(did);
 284:   
 285:              ems.SendQueue.Enqueue(command);
 286:          }
 287:   
 288:          ////////////////////////////////////////////////////////////////////////////
 289:   
 290:          /// <summary>
 291:          ///
 292:          /// </summary>
 293:          public static void SendReadOnt(Ia.Ngn.Cl.Model.Client.Huawei.Ems ems, Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Ont ont)
 294:          {
 295:              var command = Ia.Ngn.Cl.Model.Business.Huawei.Ems.ReadOntCommand(ont);
 296:   
 297:              ems.SendQueue.Enqueue(command);
 298:          }
 299:   
 300:          ////////////////////////////////////////////////////////////////////////////
 301:   
 302:          /// <summary>
 303:          ///
 304:          /// </summary>
 305:          public static void SendUpdateOntFromH248ToSip(Ia.Ngn.Cl.Model.Client.Huawei.Ems ems, Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Ont ont)
 306:          {
 307:              var command = Ia.Ngn.Cl.Model.Business.Huawei.Ems.UpdateOntFromH248ToSipCommand(ont);
 308:   
 309:              ems.SendQueue.Enqueue(command);
 310:          }
 311:   
 312:          ////////////////////////////////////////////////////////////////////////////
 313:          ////////////////////////////////////////////////////////////////////////////
 314:   
 315:          /// <summary>
 316:          ///
 317:          /// </summary>
 318:          public static void SendReadPortList(Ia.Ngn.Cl.Model.Client.Huawei.Ems ems, string dev, int fn, int sn)
 319:          {
 320:              var command = Ia.Ngn.Cl.Model.Business.Huawei.Ems.ReadPortListCommand(dev, fn, sn);
 321:   
 322:              ems.SendQueue.Enqueue(command);
 323:          }
 324:   
 325:          ////////////////////////////////////////////////////////////////////////////
 326:          ////////////////////////////////////////////////////////////////////////////
 327:   
 328:          /// <summary>
 329:          ///
 330:          /// </summary>
 331:          public static void SendCreateOntSipInfo(Ia.Ngn.Cl.Model.Client.Huawei.Ems ems, Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Ont nddOnt, string service, int telPort)
 332:          {
 333:              var command = Ia.Ngn.Cl.Model.Business.Huawei.Ems.CreateOrModifyOntSipInfoCommand(nddOnt, service, telPort);
 334:   
 335:              ems.SendQueue.Enqueue(command);
 336:          }
 337:   
 338:          ////////////////////////////////////////////////////////////////////////////
 339:   
 340:          /// <summary>
 341:          ///
 342:          /// </summary>
 343:          public static void SendReadOntSipInfo(Ia.Ngn.Cl.Model.Client.Huawei.Ems ems, Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Ont nddOnt)
 344:          {
 345:              var command = Ia.Ngn.Cl.Model.Business.Huawei.Ems.ReadOntSipInfoCommand(nddOnt);
 346:   
 347:              ems.SendQueue.Enqueue(command);
 348:          }
 349:   
 350:          ////////////////////////////////////////////////////////////////////////////
 351:   
 352:          /// <summary>
 353:          ///
 354:          /// </summary>
 355:          public static void SendVacateOntSipInfo(Ia.Ngn.Cl.Model.Client.Huawei.Ems ems, Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Ont nddOnt, string service, int telPort)
 356:          {
 357:              var command = Ia.Ngn.Cl.Model.Business.Huawei.Ems.VacateOntSipInfoCommand(nddOnt, service, telPort);
 358:   
 359:              ems.SendQueue.Enqueue(command);
 360:          }
 361:   
 362:          ////////////////////////////////////////////////////////////////////////////
 363:          ////////////////////////////////////////////////////////////////////////////
 364:   
 365:          /// <summary>
 366:          ///
 367:          /// </summary>
 368:          public static void SendResetOnt(Ia.Ngn.Cl.Model.Client.Huawei.Ems ems, Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Ont nddOnt)
 369:          {
 370:              var command = Ia.Ngn.Cl.Model.Business.Huawei.Ems.ResetOntCommand(nddOnt);
 371:   
 372:              ems.SendQueue.Enqueue(command);
 373:          }
 374:   
 375:          ////////////////////////////////////////////////////////////////////////////
 376:          ////////////////////////////////////////////////////////////////////////////
 377:   
 378:          /// <summary>
 379:          ///
 380:          /// </summary>
 381:          public static void SendCreateVoipPstnUser(Ia.Ngn.Cl.Model.Client.Huawei.Ems ems, Ia.Ngn.Cl.Model.Business.Huawei.Dev.MduDev mduDev, Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Ont nddOnt, string service, int sn, int port)
 382:          {
 383:              var command = Ia.Ngn.Cl.Model.Business.Huawei.Ems.CreateOrModifyVoipPstnUserCommand(mduDev, nddOnt, service, sn, port);
 384:   
 385:              ems.SendQueue.Enqueue(command);
 386:          }
 387:   
 388:          ////////////////////////////////////////////////////////////////////////////
 389:   
 390:          /// <summary>
 391:          ///
 392:          /// </summary>
 393:          public static void SendReadVoipPstnUser(Ia.Ngn.Cl.Model.Client.Huawei.Ems ems, Ia.Ngn.Cl.Model.Business.Huawei.Dev.MduDev mduDev, Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Ont nddOnt, int sn, int pn)
 394:          {
 395:              var command = Ia.Ngn.Cl.Model.Business.Huawei.Ems.ReadVoipPstnUserCommand(mduDev, nddOnt, sn, pn);
 396:   
 397:              ems.SendQueue.Enqueue(command);
 398:          }
 399:   
 400:          ////////////////////////////////////////////////////////////////////////////
 401:   
 402:          /// <summary>
 403:          ///
 404:          /// </summary>
 405:          public static void SendDeleteVoipPstnUser(Ia.Ngn.Cl.Model.Client.Huawei.Ems ems, Ia.Ngn.Cl.Model.Business.Huawei.Dev.MduDev mduDev, Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Ont nddOnt, string service, int sn, int telPort)
 406:          {
 407:              var command = Ia.Ngn.Cl.Model.Business.Huawei.Ems.DeleteVoipPstnUserCommand(mduDev, nddOnt, service, sn, telPort);
 408:   
 409:              ems.SendQueue.Enqueue(command);
 410:          }
 411:   
 412:          ////////////////////////////////////////////////////////////////////////////
 413:          ////////////////////////////////////////////////////////////////////////////
 414:   
 415:          /// <summary>
 416:          ///
 417:          /// </summary>
 418:          public static void SendCreateVoipPstnAccount(Ia.Ngn.Cl.Model.Client.Huawei.Ems ems, Ia.Ngn.Cl.Model.Business.Huawei.Dev.MduDev mduDev, Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Ont nddOnt, string service, int sn, int telPort)
 419:          {
 420:              var command = Ia.Ngn.Cl.Model.Business.Huawei.Ems.CreateOrModifyVoipPstnAccountCommand(mduDev, nddOnt, service, sn, telPort);
 421:   
 422:              ems.SendQueue.Enqueue(command);
 423:          }
 424:   
 425:          ////////////////////////////////////////////////////////////////////////////
 426:   
 427:          /// <summary>
 428:          ///
 429:          /// </summary>
 430:          public static void SendReadVoipPstnAccount(Ia.Ngn.Cl.Model.Client.Huawei.Ems ems, Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Ont nddOnt)
 431:          {
 432:              var command = Ia.Ngn.Cl.Model.Business.Huawei.Ems.ReadVoipPstnAccountCommand(nddOnt);
 433:   
 434:              ems.SendQueue.Enqueue(command);
 435:          }
 436:   
 437:          ////////////////////////////////////////////////////////////////////////////
 438:   
 439:          /// <summary>
 440:          ///
 441:          /// </summary>
 442:          public static void SendVacateVoipPstnAccount(Ia.Ngn.Cl.Model.Client.Huawei.Ems ems, Ia.Ngn.Cl.Model.Business.Huawei.Dev.MduDev mduDev, Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Ont nddOnt, string service, int sn, int telPort)
 443:          {
 444:              var command = Ia.Ngn.Cl.Model.Business.Huawei.Ems.VacateVoipPstnAccountCommand(mduDev, nddOnt, service, sn, telPort);
 445:   
 446:              ems.SendQueue.Enqueue(command);
 447:          }
 448:   
 449:          ////////////////////////////////////////////////////////////////////////////
 450:          ////////////////////////////////////////////////////////////////////////////   
 451:      }
 452:   
 453:      ////////////////////////////////////////////////////////////////////////////
 454:      ////////////////////////////////////////////////////////////////////////////   
 455:  }