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