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

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

ONT support class of Next Generation Network'a (NGN's) Nokia business model.

   1:  using System.Linq;
   2:  using System.Text.RegularExpressions;
   3:   
   4:  namespace Ia.Ngn.Cl.Model.Business.Nokia
   5:  {
   6:      ////////////////////////////////////////////////////////////////////////////
   7:   
   8:      /// <summary publish="true">
   9:      /// ONT support class of Next Generation Network'a (NGN's) Nokia business model.
  10:      /// </summary>
  11:      /// 
  12:      /// <remarks> 
  13:      /// Copyright © 2006-2018 Jasem Y. Al-Shamlan (info@ia.com.kw), Internet Applications - Kuwait. All Rights Reserved.
  14:      ///
  15:      /// 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
  16:      /// the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
  17:      ///
  18:      /// This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
  19:      /// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
  20:      /// 
  21:      /// You should have received a copy of the GNU General Public License along with this library. If not, see http://www.gnu.org/licenses.
  22:      /// 
  23:      /// Copyright notice: This notice may not be removed or altered from any source distribution.
  24:      /// </remarks> 
  25:      public partial class Ont
  26:      {
  27:          /// <summary/>
  28:          public enum FamilyType { Undefined = 0, Sfu = 1, Soho = 2, Mdu = 3 };
  29:   
  30:          /// <summary/>
  31:          public Ont() { }
  32:   
  33:          ////////////////////////////////////////////////////////////////////////////
  34:   
  35:          /// <summary>
  36:          ///
  37:          /// </summary>
  38:          public static string OntId(string ponId, int ontNumber)
  39:          {
  40:              string id;
  41:   
  42:              id = Ia.Ngn.Cl.Model.Business.Default.OntId(ponId, ontNumber);
  43:   
  44:              return id;
  45:          }
  46:   
  47:          ////////////////////////////////////////////////////////////////////////////
  48:   
  49:          /// <summary>
  50:          ///
  51:          /// </summary>
  52:          public static string OntId(string amsName, string cardPortOntSequence)
  53:          {
  54:              string id;
  55:              string ontPosition;
  56:   
  57:              ontPosition = Ia.Ngn.Cl.Model.Business.Nokia.Ams.OntPositionFromAmsNameAndCardPortOntSquence(amsName, cardPortOntSequence);
  58:   
  59:              id = (from o in Ia.Ngn.Cl.Model.Data.NetworkDesignDocument.OntList where o.Position == ontPosition select o.Id).SingleOrDefault();
  60:   
  61:              return id;
  62:          }
  63:   
  64:          ////////////////////////////////////////////////////////////////////////////
  65:   
  66:          /// <summary>
  67:          /// 
  68:          /// </summary>
  69:          public static Ia.Ngn.Cl.Model.Business.Nokia.Ont.FamilyType FamilyTypeFromString(string familyTypeString)
  70:          {
  71:              // this will convert string format of ONU type from both email submittals and from EMSONT EQUIPMENTID values from U2000
  72:   
  73:              Ia.Ngn.Cl.Model.Business.Nokia.Ont.FamilyType familyType;
  74:   
  75:              if (!string.IsNullOrEmpty(familyTypeString))
  76:              {
  77:                  switch (familyTypeString.ToUpper())
  78:                  {
  79:                      case "SFU": familyType = Ia.Ngn.Cl.Model.Business.Nokia.Ont.FamilyType.Sfu; break;
  80:                      case "SOHO": familyType = Ia.Ngn.Cl.Model.Business.Nokia.Ont.FamilyType.Soho; break;
  81:                      case "MDU": familyType = Ia.Ngn.Cl.Model.Business.Nokia.Ont.FamilyType.Mdu; break;
  82:   
  83:                      default: familyType = Ia.Ngn.Cl.Model.Business.Nokia.Ont.FamilyType.Undefined; break;
  84:                  }
  85:              }
  86:              else familyType = 0;
  87:   
  88:              return familyType; // Undefined
  89:          }
  90:   
  91:          ////////////////////////////////////////////////////////////////////////////
  92:   
  93:          /// <summary>
  94:          ///
  95:          /// </summary>
  96:          public static string OntPositionFromOntId(string ontId)
  97:          {
  98:              string rest, ontPosition, amsName;
  99:              int oltId, card, port, ont;
 100:   
 101:              oltId = int.Parse(ontId.Substring(0, 1 + 2 + 2 + 2 + 2)); // network id, site id, router id, odf id, olt id
 102:   
 103:              rest = Regex.Replace(ontId, "^" + oltId.ToString(), "");
 104:   
 105:              card = int.Parse(rest.Substring(4, 2));
 106:              port = int.Parse(rest.Substring(6, 2));
 107:              ont = int.Parse(rest.Substring(8, 2));
 108:   
 109:              amsName = Ia.Ngn.Cl.Model.Data.NetworkDesignDocument.AmsNameFromOltId(oltId);
 110:   
 111:              ontPosition = amsName + "-" + card + "-" + port + "-" + ont;
 112:   
 113:              return ontPosition;
 114:          }
 115:   
 116:          ////////////////////////////////////////////////////////////////////////////
 117:   
 118:          /// <summary>
 119:          ///
 120:          /// </summary>
 121:          public static bool IsValidSerialNumber(string serialNumber)
 122:          {
 123:              bool isValid;
 124:              string s;
 125:   
 126:              if (!string.IsNullOrEmpty(serialNumber))
 127:              {
 128:                  if (serialNumber.Length == 12) // ALCLA0A23C74
 129:                  {
 130:                      s = serialNumber.ToUpper();
 131:   
 132:                      if (s.Substring(0, 7) == "ALCLA0A")
 133:                      {
 134:                          s = s.Substring(4, 8);
 135:   
 136:                          isValid = Ia.Cl.Model.Default.IsHex(s);
 137:                      }
 138:                      else isValid = false;
 139:                  }
 140:                  else isValid = false;
 141:              }
 142:              else isValid = false;
 143:   
 144:              return isValid;
 145:          }
 146:   
 147:          ////////////////////////////////////////////////////////////////////////////
 148:          ////////////////////////////////////////////////////////////////////////////
 149:      }
 150:   
 151:      ////////////////////////////////////////////////////////////////////////////
 152:      ////////////////////////////////////////////////////////////////////////////
 153:  }