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

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), Internet 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 static int NextVacantTelForOnt(Ia.Ngn.Cl.Model.Huawei.EmsOnt emsOnt)
  38:          {
  39:              int telPort;
  40:              List<int> list;
  41:   
  42:              list = Ia.Ngn.Cl.Model.Data.Huawei.Ems.UsedTelListForEmsOntId(emsOnt.Id);
  43:   
  44:              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
  45:              else
  46:              {
  47:                  list = Ia.Cl.Model.Default.ExcludedNumberListFromNumberListWithinRange(list, Ia.Ngn.Cl.Model.Business.Huawei.Ems.PossibleNumberOfTdForOntEquipmentType(emsOnt.EquipmentType));
  48:   
  49:                  if (list.Count > 0) telPort = list[0];
  50:                  else telPort = Ia.Ngn.Cl.Model.Business.Default.PortUndefinedOrInvalidOrUnknown; // something went wrong
  51:              }
  52:   
  53:              return telPort;
  54:          }
  55:   
  56:          ////////////////////////////////////////////////////////////////////////////
  57:   
  58:          /// <summary>
  59:          ///
  60:          /// </summary>
  61:          public static List<int> VacantTelForOntList(Ia.Ngn.Cl.Model.Huawei.EmsOnt emsOnt)
  62:          {
  63:              List<int> usedlist, vacantList;
  64:   
  65:              usedlist = Ia.Ngn.Cl.Model.Data.Huawei.Ems.UsedTelListForEmsOntId(emsOnt.Id);
  66:   
  67:              vacantList = Ia.Cl.Model.Default.ExcludedNumberListFromNumberListWithinRange(usedlist, Ia.Ngn.Cl.Model.Business.Huawei.Ems.PossibleNumberOfTdForOntEquipmentType(emsOnt.EquipmentType));
  68:   
  69:              return vacantList;
  70:          }
  71:   
  72:          ////////////////////////////////////////////////////////////////////////////
  73:   
  74:          /// <summary>
  75:          ///
  76:          /// </summary>
  77:          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)
  78:          {
  79:              Ia.Ngn.Cl.Model.Business.Huawei.Default.FnSnPn fnSnPn;
  80:              List<Ia.Ngn.Cl.Model.Business.Huawei.Default.FnSnPn> usedList, possibleList, list;
  81:   
  82:              usedList = Ia.Ngn.Cl.Model.Data.Huawei.Ems.UsedEmsVoipPstnUserFnSnPnListForEmsOntId(emsOnt.Id);
  83:   
  84:              if (usedList.Count == 0)
  85:              {
  86:                  fnSnPn = new Ia.Ngn.Cl.Model.Business.Huawei.Default.FnSnPn(); // this means EmsVoipPstnUsers does not exist for any number and the box is empty, and we should create number at 0
  87:              }
  88:              else
  89:              {
  90:                  possibleList = mdu.PossibleFnSnPnList;
  91:   
  92:                  list = possibleList.Where(p => !usedList.Any(u => u.Fn == p.Fn && u.Sn == p.Sn && u.Pn == p.Pn)).ToList();
  93:   
  94:                  if (list.Count > 0) fnSnPn = list[0];
  95:                  else fnSnPn = null; // something went wrong
  96:              }
  97:   
  98:              return fnSnPn;
  99:          }
 100:   
 101:          ////////////////////////////////////////////////////////////////////////////
 102:   
 103:          /// <summary>
 104:          ///
 105:          /// </summary>
 106:          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)
 107:          {
 108:              List<Ia.Ngn.Cl.Model.Business.Huawei.Default.FnSnPn> usedList, possibleList, vacantlist;
 109:   
 110:              usedList = Ia.Ngn.Cl.Model.Data.Huawei.Ems.UsedEmsVoipPstnUserFnSnPnListForEmsOntId(emsOnt.Id);
 111:   
 112:              possibleList = mdu.PossibleFnSnPnList;
 113:   
 114:              vacantlist = possibleList.Where(p => !usedList.Any(u => u.Fn == p.Fn && u.Sn == p.Sn && u.Pn == p.Pn)).ToList();
 115:   
 116:              return vacantlist;
 117:          }
 118:   
 119:          ////////////////////////////////////////////////////////////////////////////
 120:   
 121:          /// <summary>
 122:          ///
 123:          /// </summary>
 124:          private static List<int> UsedTelListForEmsOntId(string emsOntId)
 125:          {
 126:              List<int> list;
 127:   
 128:              using (var db = new Ia.Ngn.Cl.Model.Ngn())
 129:              {
 130:                  list = (from eosi in db.EmsOntSipInfos where eosi.EmsOnt.Id == emsOntId orderby eosi.TEL ascending select eosi.TEL).ToList<int>();
 131:              }
 132:   
 133:              return list;
 134:          }
 135:   
 136:          ////////////////////////////////////////////////////////////////////////////
 137:   
 138:          /// <summary>
 139:          ///
 140:          /// </summary>
 141:          private static List<Ia.Ngn.Cl.Model.Business.Huawei.Default.FnSnPn> UsedEmsVoipPstnUserFnSnPnListForEmsOntId(string emsOntId)
 142:          {
 143:              List<Ia.Ngn.Cl.Model.Business.Huawei.Default.FnSnPn> list;
 144:   
 145:              using (var db = new Ia.Ngn.Cl.Model.Ngn())
 146:              {
 147:                  list = (from evpu in db.EmsVoipPstnUsers
 148:                          where evpu.EmsOnt.Id == emsOntId
 149:                          // below select will produce "Exception: System.NotSupportedException: Only parameterless constructors and initializers are supported in LINQ to Entities."
 150:                          // 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>();
 151:                          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>();
 152:              }
 153:   
 154:              return list;
 155:          }
 156:   
 157:          ////////////////////////////////////////////////////////////////////////////
 158:          ////////////////////////////////////////////////////////////////////////////
 159:   
 160:          /// <summary>
 161:          ///
 162:          /// </summary>
 163:          public static void SendReadDevListByDt(Ia.Ngn.Cl.Model.Client.Huawei.Ems ems, string devType)
 164:          {
 165:              string command;
 166:   
 167:              command = Ia.Ngn.Cl.Model.Business.Huawei.Ems.ReadDevListByDtCommand(devType);
 168:   
 169:              ems.SendQueue.Enqueue(command);
 170:          }
 171:   
 172:          ////////////////////////////////////////////////////////////////////////////
 173:   
 174:          /// <summary>
 175:          ///
 176:          /// </summary>
 177:          public static void SendReadDevListByDev(Ia.Ngn.Cl.Model.Client.Huawei.Ems ems, string dev)
 178:          {
 179:              string command;
 180:   
 181:              command = Ia.Ngn.Cl.Model.Business.Huawei.Ems.ReadDevListByDevCommand(dev);
 182:   
 183:              ems.SendQueue.Enqueue(command);
 184:          }
 185:   
 186:          ////////////////////////////////////////////////////////////////////////////
 187:          ////////////////////////////////////////////////////////////////////////////
 188:   
 189:          /// <summary>
 190:          ///
 191:          /// </summary>
 192:          public static void SendReadBoardList(Ia.Ngn.Cl.Model.Client.Huawei.Ems ems, string dev)
 193:          {
 194:              string command;
 195:   
 196:              command = Ia.Ngn.Cl.Model.Business.Huawei.Ems.ReadBoardListCommand(dev);
 197:   
 198:              ems.SendQueue.Enqueue(command);
 199:          }
 200:   
 201:          ////////////////////////////////////////////////////////////////////////////
 202:   
 203:          /// <summary>
 204:          ///
 205:          /// </summary>
 206:          public static void SendReadOntList(Ia.Ngn.Cl.Model.Client.Huawei.Ems ems, int did)
 207:          {
 208:              string command;
 209:   
 210:              command = Ia.Ngn.Cl.Model.Business.Huawei.Ems.ReadOntListCommand(did);
 211:   
 212:              ems.SendQueue.Enqueue(command);
 213:          }
 214:   
 215:          ////////////////////////////////////////////////////////////////////////////
 216:   
 217:          /// <summary>
 218:          ///
 219:          /// </summary>
 220:          public static void SendReadOnt(Ia.Ngn.Cl.Model.Client.Huawei.Ems ems, Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Ont ont)
 221:          {
 222:              string command;
 223:   
 224:              command = Ia.Ngn.Cl.Model.Business.Huawei.Ems.ReadOntCommand(ont);
 225:   
 226:              ems.SendQueue.Enqueue(command);
 227:          }
 228:   
 229:          ////////////////////////////////////////////////////////////////////////////
 230:   
 231:          /// <summary>
 232:          ///
 233:          /// </summary>
 234:          public static void SendUpdateOntFromH248ToSip(Ia.Ngn.Cl.Model.Client.Huawei.Ems ems, Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Ont ont)
 235:          {
 236:              string command;
 237:   
 238:              command = Ia.Ngn.Cl.Model.Business.Huawei.Ems.UpdateOntFromH248ToSipCommand(ont);
 239:   
 240:              ems.SendQueue.Enqueue(command);
 241:          }
 242:   
 243:          ////////////////////////////////////////////////////////////////////////////
 244:          ////////////////////////////////////////////////////////////////////////////
 245:   
 246:          /// <summary>
 247:          ///
 248:          /// </summary>
 249:          public static void SendReadPortList(Ia.Ngn.Cl.Model.Client.Huawei.Ems ems, string dev, int fn, int sn)
 250:          {
 251:              string command;
 252:   
 253:              command = Ia.Ngn.Cl.Model.Business.Huawei.Ems.ReadPortListCommand(dev, fn, sn);
 254:   
 255:              ems.SendQueue.Enqueue(command);
 256:          }
 257:   
 258:          ////////////////////////////////////////////////////////////////////////////
 259:          ////////////////////////////////////////////////////////////////////////////
 260:   
 261:          /// <summary>
 262:          ///
 263:          /// </summary>
 264:          public static void SendCreateOntSipInfo(Ia.Ngn.Cl.Model.Client.Huawei.Ems ems, Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Ont nddOnt, string service, int telPort)
 265:          {
 266:              string command;
 267:   
 268:              command = Ia.Ngn.Cl.Model.Business.Huawei.Ems.CreateOrModifyOntSipInfoCommand(nddOnt, service, telPort);
 269:   
 270:              ems.SendQueue.Enqueue(command);
 271:          }
 272:   
 273:          ////////////////////////////////////////////////////////////////////////////
 274:   
 275:          /// <summary>
 276:          ///
 277:          /// </summary>
 278:          public static void SendReadOntSipInfo(Ia.Ngn.Cl.Model.Client.Huawei.Ems ems, Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Ont nddOnt)
 279:          {
 280:              string command;
 281:   
 282:              command = Ia.Ngn.Cl.Model.Business.Huawei.Ems.ReadOntSipInfoCommand(nddOnt);
 283:   
 284:              ems.SendQueue.Enqueue(command);
 285:          }
 286:   
 287:          ////////////////////////////////////////////////////////////////////////////
 288:   
 289:          /// <summary>
 290:          ///
 291:          /// </summary>
 292:          public static void SendVacateOntSipInfo(Ia.Ngn.Cl.Model.Client.Huawei.Ems ems, Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Ont nddOnt, string service, int telPort)
 293:          {
 294:              string command;
 295:   
 296:              command = Ia.Ngn.Cl.Model.Business.Huawei.Ems.VacateOntSipInfoCommand(nddOnt, service, telPort);
 297:   
 298:              ems.SendQueue.Enqueue(command);
 299:          }
 300:   
 301:          ////////////////////////////////////////////////////////////////////////////
 302:          ////////////////////////////////////////////////////////////////////////////
 303:   
 304:          /// <summary>
 305:          ///
 306:          /// </summary>
 307:          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)
 308:          {
 309:              string command;
 310:   
 311:              command = Ia.Ngn.Cl.Model.Business.Huawei.Ems.CreateOrModifyVoipPstnUserCommand(mduDev, nddOnt, service, sn, port);
 312:   
 313:              ems.SendQueue.Enqueue(command);
 314:          }
 315:   
 316:          ////////////////////////////////////////////////////////////////////////////
 317:   
 318:          /// <summary>
 319:          ///
 320:          /// </summary>
 321:          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 telPort)
 322:          {
 323:              string command;
 324:   
 325:              command = Ia.Ngn.Cl.Model.Business.Huawei.Ems.ReadVoipPstnUserCommand(mduDev, nddOnt, sn, telPort);
 326:   
 327:              ems.SendQueue.Enqueue(command);
 328:          }
 329:   
 330:          ////////////////////////////////////////////////////////////////////////////
 331:   
 332:          /// <summary>
 333:          ///
 334:          /// </summary>
 335:          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)
 336:          {
 337:              string command;
 338:   
 339:              command = Ia.Ngn.Cl.Model.Business.Huawei.Ems.DeleteVoipPstnUserCommand(mduDev, nddOnt, service, sn, telPort);
 340:   
 341:              ems.SendQueue.Enqueue(command);
 342:          }
 343:   
 344:          ////////////////////////////////////////////////////////////////////////////
 345:          ////////////////////////////////////////////////////////////////////////////
 346:   
 347:          /// <summary>
 348:          ///
 349:          /// </summary>
 350:          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)
 351:          {
 352:              string command;
 353:   
 354:              command = Ia.Ngn.Cl.Model.Business.Huawei.Ems.CreateOrModifyVoipPstnAccountCommand(mduDev, nddOnt, service, sn, telPort);
 355:   
 356:              ems.SendQueue.Enqueue(command);
 357:          }
 358:   
 359:          ////////////////////////////////////////////////////////////////////////////
 360:   
 361:          /// <summary>
 362:          ///
 363:          /// </summary>
 364:          public static void SendReadVoipPstnAccount(Ia.Ngn.Cl.Model.Client.Huawei.Ems ems, Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Ont nddOnt)
 365:          {
 366:              string command;
 367:   
 368:              command = Ia.Ngn.Cl.Model.Business.Huawei.Ems.ReadVoipPstnAccountCommand(nddOnt);
 369:   
 370:              ems.SendQueue.Enqueue(command);
 371:          }
 372:   
 373:          ////////////////////////////////////////////////////////////////////////////
 374:   
 375:          /// <summary>
 376:          ///
 377:          /// </summary>
 378:          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)
 379:          {
 380:              string command;
 381:   
 382:              command = Ia.Ngn.Cl.Model.Business.Huawei.Ems.VacateVoipPstnAccountCommand(mduDev, nddOnt, service, sn, telPort);
 383:   
 384:              ems.SendQueue.Enqueue(command);
 385:          }
 386:   
 387:          ////////////////////////////////////////////////////////////////////////////
 388:          ////////////////////////////////////////////////////////////////////////////   
 389:      }
 390:   
 391:      ////////////////////////////////////////////////////////////////////////////
 392:      ////////////////////////////////////////////////////////////////////////////   
 393:  }