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

Integrated Applications Programming Company

Skip Navigation LinksHome » Code Library » AgcfGatewayRecord

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

AGCF Gateway Records support class for Nokia's Next Generation Network (NGN) business model.

   1:  using System;
   2:  using System.Collections.Generic;
   3:  using System.Linq;
   4:   
   5:  namespace Ia.Ngn.Cl.Model.Business.Nokia
   6:  {
   7:      ////////////////////////////////////////////////////////////////////////////
   8:   
   9:      /// <summary publish="true">
  10:      /// AGCF Gateway Records support class for Nokia's Next Generation Network (NGN) business model.
  11:      /// </summary>
  12:      /// 
  13:      /// <remarks> 
  14:      /// Copyright � 2014-2017 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 AgcfGatewayRecord
  27:      {
  28:          public AgcfGatewayRecord() { }
  29:   
  30:          ////////////////////////////////////////////////////////////////////////////
  31:   
  32:          /// <summary>
  33:          ///
  34:          /// </summary>
  35:          public static void CreateRandomGatewayIdForAccessName(Ia.Ngn.Cl.Model.Client.Nokia.Ims nokiaIms, string accessName, out Ia.Cl.Model.Result result)
  36:          {
  37:              int gwId;
  38:              Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Ont nddOnt;
  39:   
  40:              result = new Ia.Cl.Model.Result();
  41:   
  42:              if (!string.IsNullOrEmpty(accessName))
  43:              {
  44:                  nddOnt = (from o in Ia.Ngn.Cl.Model.Data.NetworkDesignDocument.OntList where o.Access.Name == accessName select o).SingleOrDefault();
  45:   
  46:                  if (nddOnt != null)
  47:                  {
  48:                      gwId = Ia.Ngn.Cl.Model.Business.Nokia.AgcfGatewayRecord.RandomUnusedGwId();
  49:   
  50:                      Ia.Ngn.Cl.Model.Data.Nokia.Ims.CreateAgcfGatewayRecordForGwId(nokiaIms, gwId, nddOnt, out string createResult);
  51:   
  52:                      Ia.Ngn.Cl.Model.Data.Nokia.Ims.ReadUpdateAgcfGatewayRecordAndAgcfEndpointListAndSubPartyAndSubscriberAndServiceForGwId(nokiaIms, gwId, out string readResult);
  53:   
  54:                      result.AddSuccess("Access name: " + nddOnt.Access.Name + ", gwId: " + gwId + ", createResult: " + createResult + ", readResult: " + readResult);
  55:                  }
  56:                  else
  57:                  {
  58:                      result.AddError("NDD ONT is null, does not exist for access: " + accessName);
  59:                  }
  60:              }
  61:              else
  62:              {
  63:                  result.AddError("AccessName is null or empty");
  64:              }
  65:          }
  66:   
  67:          ////////////////////////////////////////////////////////////////////////////
  68:   
  69:          /// <summary>
  70:          ///
  71:          /// </summary>
  72:          public static void ReadGatewayId(Ia.Ngn.Cl.Model.Client.Nokia.Ims nokiaIms, string gatewayId, out string result)
  73:          {
  74:              int gwId;
  75:   
  76:              if (!string.IsNullOrEmpty(gatewayId))
  77:              {
  78:                  gatewayId = gatewayId.Trim();
  79:   
  80:                  if (int.TryParse(gatewayId, out int i))
  81:                  {
  82:                      gwId = i;
  83:   
  84:                      Ia.Ngn.Cl.Model.Data.Nokia.Ims.ReadUpdateAgcfGatewayRecordAndAgcfEndpointListAndSubPartyAndSubscriberAndServiceForGwId(nokiaIms, gwId, out result);
  85:                  }
  86:                  else
  87:                  {
  88:                      result = "error: input text is not in int format. ";
  89:                  }
  90:              }
  91:              else
  92:              {
  93:                  result = "error: input text is null or empty. ";
  94:              }
  95:          }
  96:   
  97:          ////////////////////////////////////////////////////////////////////////////
  98:   
  99:          /// <summary>
 100:          ///
 101:          /// </summary>
 102:          public static void DeleteGatewayId(Ia.Ngn.Cl.Model.Client.Nokia.Ims nokiaIms, string gatewayId, out string result)
 103:          {
 104:              int gwId;
 105:              Ia.Ngn.Cl.Model.Nokia.AgcfGatewayRecord agcfGatewayRecord;
 106:   
 107:              if (!string.IsNullOrEmpty(gatewayId))
 108:              {
 109:                  gatewayId = gatewayId.Trim();
 110:   
 111:                  if (int.TryParse(gatewayId, out int i))
 112:                  {
 113:                      gwId = i;
 114:   
 115:                      agcfGatewayRecord = Ia.Ngn.Cl.Model.Data.Nokia.AgcfGatewayRecord.ReadByGwId(gwId);
 116:   
 117:                      if (agcfGatewayRecord != null)
 118:                      {
 119:                          Ia.Ngn.Cl.Model.Data.Nokia.Ims.DeleteAgcfGatewayRecordForGwId(nokiaIms, agcfGatewayRecord, out string deleteResult);
 120:   
 121:                          Ia.Ngn.Cl.Model.Data.Nokia.Ims.ReadUpdateAgcfGatewayRecordAndAgcfEndpointListAndSubPartyAndSubscriberAndServiceForGwId(nokiaIms, agcfGatewayRecord.GwId, out string readResult);
 122:   
 123:                          result = "gwId: " + agcfGatewayRecord.GwId + ", deleteResult: " + deleteResult + ", readResult: " + readResult;
 124:                      }
 125:                      else result = "gwId: " + gwId + ", agcfGatewayRecord is null. ";
 126:                  }
 127:                  else result = "error: input text is not in int format. ";
 128:              }
 129:              else result = "error: input text is null or empty. ";
 130:          }
 131:   
 132:          ////////////////////////////////////////////////////////////////////////////
 133:   
 134:          /// <summary>
 135:          ///
 136:          /// </summary>
 137:          public static int RandomUnusedGwId()
 138:          {
 139:              int randomGwId;
 140:              Random r;
 141:              List<int> unusedGwIdList;
 142:   
 143:              r = new Random();
 144:              unusedGwIdList = Ia.Ngn.Cl.Model.Data.Nokia.AgcfGatewayRecord.ReadUnusedGwIdList();
 145:   
 146:              randomGwId = unusedGwIdList[r.Next(unusedGwIdList.Count)];
 147:   
 148:              return randomGwId;
 149:          }
 150:   
 151:          ////////////////////////////////////////////////////////////////////////////
 152:   
 153:          /// <summary>
 154:          ///
 155:          /// </summary>
 156:          public static Ia.Ngn.Cl.Model.Nokia.AgcfGatewayRecord ParseFromDictionary(Dictionary<string, string> parameterDictionary)
 157:          {
 158:              int i, gwId, tableId;
 159:              long l;
 160:              Ia.Ngn.Cl.Model.Nokia.AgcfGatewayRecord agcfGatewayRecord;
 161:   
 162:              agcfGatewayRecord = new Ia.Ngn.Cl.Model.Nokia.AgcfGatewayRecord();
 163:   
 164:              gwId = int.Parse(parameterDictionary["GwId"].ToString());
 165:              tableId = int.Parse(parameterDictionary["TableId"].ToString());
 166:   
 167:              agcfGatewayRecord.Id = Ia.Ngn.Cl.Model.Nokia.AgcfGatewayRecord.AgcfGatewayRecordId(tableId, gwId);
 168:   
 169:              agcfGatewayRecord.NgcfAgcfGatewayRecordAid = parameterDictionary["NgcfAgcfGatewayRecordAid"].ToString();
 170:              agcfGatewayRecord.GwId = gwId;
 171:              agcfGatewayRecord.TableId = tableId;
 172:   
 173:              agcfGatewayRecord.AgcfSipIaPort = parameterDictionary["AgcfSipIaPort"].ToString();
 174:              agcfGatewayRecord.ConnectionType = (parameterDictionary["ConnectionType"].ToString() == "UDP/IP") ? true : false;
 175:              agcfGatewayRecord.ContextAudits = (parameterDictionary["ContextAudits"].ToString() == "None") ? true : false;
 176:              agcfGatewayRecord.GwDigitMapId = int.TryParse(parameterDictionary["GwDigitMapId"].ToString(), out i) ? i : 0;
 177:              agcfGatewayRecord.EnableChannelStatusAudits = Convert.ToBoolean(parameterDictionary["EnableChannelStatusAudits"].ToString());
 178:              agcfGatewayRecord.GwUserId = parameterDictionary["GwUserId"].ToString();
 179:              agcfGatewayRecord.GwDomain = parameterDictionary["GwDomain"].ToString();
 180:              agcfGatewayRecord.GwName = parameterDictionary["GwName"].ToString();
 181:              agcfGatewayRecord.GwPrivId = parameterDictionary["GwPrivId"].ToString();
 182:              agcfGatewayRecord.IP1 = parameterDictionary["IP1"].ToString();
 183:              agcfGatewayRecord.IP2 = parameterDictionary["IP2"].ToString();
 184:              agcfGatewayRecord.LocalTermTypePrefix = parameterDictionary["LocalTermTypePrefix"].ToString();
 185:              agcfGatewayRecord.LocalTermTypeAnalogPrefix = parameterDictionary["LocalTermTypeAnalogPrefix"].ToString();
 186:              agcfGatewayRecord.IsLocalTermTypeTDMAnalog = Convert.ToBoolean(parameterDictionary["IsLocalTermTypeTDMAnalog"].ToString());
 187:              agcfGatewayRecord.NetTermTypePrefix = parameterDictionary["NetTermTypePrefix"].ToString();
 188:              agcfGatewayRecord.IsNetTermTypeRTPUDP = Convert.ToBoolean(parameterDictionary["IsNetTermTypeRTPUDP"].ToString());
 189:              agcfGatewayRecord.PhysicalTermIdScheme = parameterDictionary["PhysicalTermIdScheme"].ToString();
 190:              agcfGatewayRecord.SendCompactMessages = Convert.ToBoolean(parameterDictionary["SendCompactMessages"].ToString());
 191:              agcfGatewayRecord.SendEphemeralPrefix = Convert.ToBoolean(parameterDictionary["SendEphemeralPrefix"].ToString());
 192:              agcfGatewayRecord.UdpPort = int.TryParse(parameterDictionary["UdpPort"].ToString(), out i) ? i : 0;
 193:              agcfGatewayRecord.GwVariantId = int.TryParse(parameterDictionary["GwVariantId"].ToString(), out i) ? i : 0;
 194:              agcfGatewayRecord.AreaId = int.TryParse(parameterDictionary["AreaId"].ToString(), out i) ? i : 0;
 195:              agcfGatewayRecord.ComfortNoise = Convert.ToBoolean(parameterDictionary["ComfortNoise"].ToString());
 196:              agcfGatewayRecord.Dtmf = Convert.ToBoolean(parameterDictionary["Dtmf"].ToString());
 197:              agcfGatewayRecord.FaxEvents = Convert.ToBoolean(parameterDictionary["FaxEvents"].ToString());
 198:              agcfGatewayRecord.ModemEvents = Convert.ToBoolean(parameterDictionary["ModemEvents"].ToString());
 199:              agcfGatewayRecord.TextTelephonyEvents = Convert.ToBoolean(parameterDictionary["TextTelephonyEvents"].ToString());
 200:              agcfGatewayRecord.AllCodecDataStr = parameterDictionary["AllCodecDataStr"].ToString();
 201:              agcfGatewayRecord.AgwIuaIpAddress = parameterDictionary["AgwIuaIpAddress"].ToString();
 202:              agcfGatewayRecord.AgwIuaSctpPort = int.TryParse(parameterDictionary["AgwIuaSctpPort"].ToString(), out i) ? i : 0;
 203:              agcfGatewayRecord.AgcfLocalSctpPort = int.TryParse(parameterDictionary["AgcfLocalSctpPort"].ToString(), out i) ? i : 0;
 204:              agcfGatewayRecord.SctpProfile = int.TryParse(parameterDictionary["SctpProfile"].ToString(), out i) ? i : 0;
 205:              agcfGatewayRecord.IuaIIDMapScheme = parameterDictionary["IuaIIDMapScheme"].ToString();
 206:              agcfGatewayRecord.LocalTermTypeIsdnPrefix = parameterDictionary["LocalTermTypeIsdnPrefix"].ToString();
 207:              agcfGatewayRecord.AuditAllActiveIsdnCalls = Convert.ToBoolean(parameterDictionary["AuditAllActiveIsdnCalls"].ToString());
 208:              agcfGatewayRecord.MateSite = int.TryParse(parameterDictionary["MateSite"].ToString(), out i) ? i : 0;
 209:   
 210:              agcfGatewayRecord.IsPrimary = Convert.ToBoolean(parameterDictionary["IsPrimary"].ToString());
 211:              agcfGatewayRecord.MateExternalIPAddr = parameterDictionary["MateExternalIPAddr"].ToString();
 212:   
 213:              agcfGatewayRecord.MateExternalIPAddr = Ia.Ngn.Cl.Model.Business.Nokia.Ims.AssigneCorrectMateExternalIPAddrForIsPrimary(agcfGatewayRecord.IsPrimary, agcfGatewayRecord.MateExternalIPAddr);
 214:   
 215:   
 216:              agcfGatewayRecord.AddtionalDigitMapList = parameterDictionary["AddtionalDigitMapList"].ToString();
 217:              agcfGatewayRecord.AuthTimer = int.TryParse(parameterDictionary["AuthTimer"].ToString(), out i) ? i : 0;
 218:              agcfGatewayRecord.SharedBasNumber = long.TryParse(parameterDictionary["SharedBasNumber"].ToString(), out l) ? l : 0;
 219:              agcfGatewayRecord.SharedPriNumber = int.TryParse(parameterDictionary["SharedPriNumber"].ToString(), out i) ? i : 0;
 220:              agcfGatewayRecord.MgID = parameterDictionary["MgID"].ToString();
 221:              agcfGatewayRecord.EnnableMD5DigAuteh = Convert.ToBoolean(parameterDictionary["EnnableMD5DigAuteh"].ToString());
 222:              agcfGatewayRecord.ChannelAudits = int.TryParse(parameterDictionary["ChannelAudits"].ToString(), out i) ? i : 0;
 223:              agcfGatewayRecord.GroupId = int.TryParse(parameterDictionary["GroupId"].ToString(), out i) ? i : 0;
 224:              agcfGatewayRecord.AgcfGateWayType = int.TryParse(parameterDictionary["AgcfGateWayType"].ToString(), out i) ? i : 0;
 225:   
 226:              agcfGatewayRecord.Created = DateTime.UtcNow.AddHours(3);
 227:              agcfGatewayRecord.Updated = DateTime.UtcNow.AddHours(3);
 228:              agcfGatewayRecord.UserId = Guid.Empty;
 229:   
 230:              return agcfGatewayRecord;
 231:          }
 232:   
 233:          ////////////////////////////////////////////////////////////////////////////
 234:          ////////////////////////////////////////////////////////////////////////////
 235:      }
 236:   
 237:      ////////////////////////////////////////////////////////////////////////////
 238:      ////////////////////////////////////////////////////////////////////////////
 239:  }