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

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

Access Management System (AMS) support class for Nokia data model.

   1:  using System;
   2:  using System.Web;
   3:  using System.Xml;
   4:  using System.Xml.Linq;
   5:  using System.IO;
   6:  using System.Configuration;
   7:  using System.Text;
   8:  using System.Text.RegularExpressions;
   9:  using System.Data;
  10:  using System.Data.SqlClient;
  11:  using System.Web.UI;
  12:  using System.Web.UI.WebControls;
  13:  using System.Collections;
  14:  using System.Collections.Generic;
  15:  using System.Reflection;
  16:  using System.Linq;
  17:   
  18:  namespace Ia.Ngn.Cl.Model.Data.Nokia
  19:  {
  20:      ////////////////////////////////////////////////////////////////////////////
  21:   
  22:      /// <summary publish="true">
  23:      /// Access Management System (AMS) support class for Nokia data model.
  24:      /// </summary>
  25:      /// 
  26:      /// <remarks> 
  27:      /// Copyright © 2006-2017 Jasem Y. Al-Shamlan (info@ia.com.kw), Internet Applications - Kuwait. All Rights Reserved.
  28:      ///
  29:      /// 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
  30:      /// the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
  31:      ///
  32:      /// This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
  33:      /// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
  34:      /// 
  35:      /// You should have received a copy of the GNU General Public License along with this library. If not, see http://www.gnu.org/licenses.
  36:      /// 
  37:      /// Copyright notice: This notice may not be removed or altered from any source distribution.
  38:      /// </remarks> 
  39:      public partial class Ams
  40:      {
  41:          private static Dictionary<string, string> correlationTagDictionary = new Dictionary<string, string>(1000);
  42:   
  43:          public static Dictionary<string, string> CorrelationTagDictionary { get { return correlationTagDictionary; } set { correlationTagDictionary = value; } }
  44:   
  45:          ////////////////////////////////////////////////////////////////////////////
  46:   
  47:          /// <summary>
  48:          ///
  49:          /// </summary>
  50:          public Ams() { }
  51:   
  52:          ////////////////////////////////////////////////////////////////////////////
  53:   
  54:          /// <summary>
  55:          ///
  56:          /// </summary>
  57:          public static string BellcoreStateFromId(int stateId)
  58:          {
  59:              string s;
  60:              Ia.Ngn.Cl.Model.Business.Nokia.Ams.BellcoreState bellcoreState;
  61:   
  62:              bellcoreState = (Ia.Ngn.Cl.Model.Business.Nokia.Ams.BellcoreState)stateId;
  63:   
  64:              switch (bellcoreState)
  65:              {
  66:                  case Ia.Ngn.Cl.Model.Business.Nokia.Ams.BellcoreState.IsNr: s = "IS-NR"; break;
  67:                  case Ia.Ngn.Cl.Model.Business.Nokia.Ams.BellcoreState.OosAu: s = "OOS-AU"; break;
  68:                  case Ia.Ngn.Cl.Model.Business.Nokia.Ams.BellcoreState.OosAuma: s = "OOS-AUMA"; break;
  69:                  case Ia.Ngn.Cl.Model.Business.Nokia.Ams.BellcoreState.OosMa: s = "OOS-MA"; break;
  70:                  case Ia.Ngn.Cl.Model.Business.Nokia.Ams.BellcoreState.Undefined: s = "Undefined"; break;
  71:                  default: s = "Undefined"; break;
  72:              }
  73:   
  74:              return s;
  75:          }
  76:   
  77:          ////////////////////////////////////////////////////////////////////////////
  78:   
  79:          /// <summary>
  80:          ///
  81:          /// </summary>
  82:          public static string PlannedSoftware
  83:          {
  84:              get
  85:              {
  86:                  return "3FE50853AFXA35";
  87:              }
  88:          }
  89:   
  90:          ////////////////////////////////////////////////////////////////////////////
  91:   
  92:          /// <summary>
  93:          ///
  94:          /// </summary>
  95:          public static void ReadAccessOntHsiVoipPotsDetailsFromSerialTake10Onts(string serial, out List<Ia.Ngn.Cl.Model.Access> accessList, out List<Ia.Ngn.Cl.Model.Ont> ontList, out List<Ia.Ngn.Cl.Model.OntServiceHsi> ontServiceHsiList, out List<Ia.Ngn.Cl.Model.OntServiceVoip> ontServiceVoipList, out List<Ia.Ngn.Cl.Model.OntOntPots> ontOntPotsList)
  96:          {
  97:              using (var db = new Ia.Ngn.Cl.Model.Ngn())
  98:              {
  99:                  accessList = (from o in db.Onts where o.Serial == serial && o.Access != null select o.Access).Take(10).ToList();
 100:   
 101:                  ontList = (from o in db.Onts where o.Serial == serial select o).Take(10).ToList();
 102:   
 103:                  ontServiceHsiList = ontList.SelectMany(t => t.OntServiceHsis).ToList();
 104:                  ontServiceVoipList = ontList.SelectMany(t => t.OntServiceVoips).ToList();
 105:                  ontOntPotsList = ontList.SelectMany(t => t.OntOntPotses).ToList();
 106:              }
 107:          }
 108:   
 109:          ////////////////////////////////////////////////////////////////////////////
 110:   
 111:          /// <summary>
 112:          ///
 113:          /// </summary>
 114:          public static int NextVacantFlatTermIdForOnt(int familyTypeId, Ia.Ngn.Cl.Model.Ont ont)
 115:          {
 116:              int ft, gwId;
 117:              List<int> list;
 118:   
 119:              if (ont.OntServiceVoips != null && ont.OntServiceVoips.Count > 0)
 120:              {
 121:                  gwId = Ia.Ngn.Cl.Model.Data.Nokia.AgcfGatewayRecord.GwIdFromIp(ont.OntServiceVoips.First().Ip);
 122:   
 123:                  list = Ia.Ngn.Cl.Model.Data.Nokia.AgcfEndpoint.UsedFlatTermIdListForGatewayId(gwId);
 124:   
 125:                  if (list.Count == 0) ft = 1; // this means agcfEndpoint does not exist for any number and the box is empty, and we should create agcfEndpoint at 1
 126:                  else
 127:                  {
 128:                      list = Ia.Cl.Model.Default.ExcludedNumberListFromNumberListWithinRange(list, Ia.Ngn.Cl.Model.Business.Nokia.Ams.PossibleNumberOfTdForOntFamilyType((Ia.Ngn.Cl.Model.Business.Nokia.Ont.FamilyType)familyTypeId));
 129:   
 130:                      if (list.Count > 0) ft = list[0];
 131:                      else ft = 0; // something went wrong
 132:                  }
 133:              }
 134:              else
 135:              {
 136:                  ft = 0; // something went wrong
 137:              }
 138:   
 139:              return ft;
 140:          }
 141:   
 142:          ////////////////////////////////////////////////////////////////////////////
 143:   
 144:          /// <summary>
 145:          ///
 146:          /// </summary>
 147:          public static Ia.Ngn.Cl.Model.Ont OntFromGwId(int gwId)
 148:          {
 149:              string ip;
 150:              Ia.Ngn.Cl.Model.Ont ont;
 151:   
 152:              using (var db = new Ia.Ngn.Cl.Model.Ngn())
 153:              {
 154:                  ip = Ia.Ngn.Cl.Model.Data.Nokia.AgcfGatewayRecord.IpFromGatewayId(gwId);
 155:   
 156:                  ont = (from o in db.Onts where o.OntServiceVoips.First().Ip == ip select o).SingleOrDefault();
 157:              }
 158:   
 159:              return ont;
 160:          }
 161:   
 162:          ////////////////////////////////////////////////////////////////////////////
 163:   
 164:          /// <summary>
 165:          ///
 166:          /// </summary>
 167:          public static List<string> UsedHsiCardPortServiceConfigurationListForOntId(string ontId)
 168:          {
 169:              List<string> list;
 170:   
 171:              using (var db = new Ia.Ngn.Cl.Model.Ngn())
 172:              {
 173:                  list = (from osh in db.OntServiceHsis where osh.Ont.Id == ontId select osh.Card + "-" + osh.Port + "-" + osh.Service).ToList();
 174:              }
 175:   
 176:              return list.Distinct().ToList();
 177:          }
 178:   
 179:          ////////////////////////////////////////////////////////////////////////////
 180:   
 181:          /// <summary>
 182:          ///
 183:          /// </summary>
 184:          public static List<string> AvailableHsiCardPortServiceConfigurationListForOnt(Ia.Ngn.Cl.Model.Ont ont)
 185:          {
 186:              List<string> list, possibleList, usedList;
 187:   
 188:              list = new List<string>();
 189:   
 190:              usedList = Ia.Ngn.Cl.Model.Data.Nokia.Ams.UsedHsiCardPortServiceConfigurationListForOntId(ont.Id);
 191:   
 192:              possibleList = Ia.Ngn.Cl.Model.Business.Nokia.Ams.PossibleHsiCardPortServiceConfigurationForOntFamilyTypeArrayList((Ia.Ngn.Cl.Model.Business.Nokia.Ont.FamilyType)ont.FamilyTypeId);
 193:   
 194:              if (possibleList.Count > 0)
 195:              {
 196:                  if (usedList.Count > 0)
 197:                  {
 198:                      foreach (string s in possibleList)
 199:                      {
 200:                          if (!usedList.Contains(s))
 201:                          {
 202:                              list.Add(s);
 203:                          }
 204:                      }
 205:                  }
 206:                  else
 207:                  {
 208:                      list = possibleList.ToList();
 209:                  }
 210:              }
 211:              else
 212:              {
 213:              }
 214:   
 215:              return list.Distinct().ToList();
 216:          }
 217:   
 218:          ////////////////////////////////////////////////////////////////////////////
 219:          ////////////////////////////////////////////////////////////////////////////
 220:      }
 221:   
 222:      ////////////////////////////////////////////////////////////////////////////
 223:      ////////////////////////////////////////////////////////////////////////////
 224:  }