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

Integrated Applications Programming Company

Skip Navigation LinksHome » Code Library » Default

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

Defaul general support class for Huawei's Optical Fiber Network (OFN) business model.

   1:  using System.Collections.Generic;
   2:  using System.Text.RegularExpressions;
   3:  using System.Text;
   4:  using System;
   5:  using System.IO;
   6:  using System.Linq;
   7:  using Ia.Cl.Model;
   8:  using Ia.Ngn.Cl.Model.Data.Huawei;
   9:  using static Ia.Ngn.Cl.Model.Business.Huawei.Dev;
  10:   
  11:  namespace Ia.Ngn.Cl.Model.Business.Huawei
  12:  {
  13:      ////////////////////////////////////////////////////////////////////////////
  14:   
  15:      /// <summary publish="true">
  16:      /// Defaul general support class for Huawei's Optical Fiber Network (OFN) business model.
  17:      /// </summary>
  18:      /// 
  19:      /// <remarks> 
  20:      /// Copyright © 2014-2018 Jasem Y. Al-Shamlan (info@ia.com.kw), Integrated Applications - Kuwait. All Rights Reserved.
  21:      ///
  22:      /// 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
  23:      /// the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
  24:      ///
  25:      /// This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
  26:      /// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
  27:      /// 
  28:      /// You should have received a copy of the GNU General Public License along with this library. If not, see http://www.gnu.org/licenses.
  29:      /// 
  30:      /// Copyright notice: This notice may not be removed or altered from any source distribution.
  31:      /// </remarks> 
  32:      public class Default
  33:      {
  34:          ////////////////////////////////////////////////////////////////////////////
  35:   
  36:          /// <summary>
  37:          ///
  38:          /// </summary>
  39:          public Default() { }
  40:   
  41:          ////////////////////////////////////////////////////////////////////////////
  42:   
  43:          /// <summary>
  44:          ///
  45:          /// </summary>
  46:          public class FnSnPnPort
  47:          {
  48:              /// <summary/>
  49:              public int Fn { get; set; }
  50:   
  51:              /// <summary/>
  52:              public int Sn { get; set; }
  53:   
  54:              /// <summary/>
  55:              public int Pn { get; set; }
  56:   
  57:              /// <summary/>
  58:              public int Port { get; set; }
  59:   
  60:              ////////////////////////////////////////////////////////////////////////////
  61:   
  62:              /// <summary>
  63:              ///
  64:              /// </summary>
  65:              public FnSnPnPort()
  66:              {
  67:                  this.Fn = 0;
  68:                  this.Sn = 0;
  69:                  this.Pn = 0;
  70:                  this.Port = Ia.Ngn.Cl.Model.Business.Default.PortUndefinedOrInvalidOrUnknown;
  71:              }
  72:   
  73:              ////////////////////////////////////////////////////////////////////////////
  74:   
  75:              /// <summary>
  76:              ///
  77:              /// </summary>
  78:              public FnSnPnPort(int fn, int sn, int pn, int port)
  79:              {
  80:                  this.Fn = fn;
  81:                  this.Sn = sn;
  82:                  this.Pn = pn;
  83:                  this.Port = port;
  84:              }
  85:   
  86:              ////////////////////////////////////////////////////////////////////////////
  87:          }
  88:   
  89:          ////////////////////////////////////////////////////////////////////////////
  90:          ////////////////////////////////////////////////////////////////////////////   
  91:   
  92:          /// <summary>
  93:          ///
  94:          /// </summary>
  95:          public static Ia.Cl.Model.Result InsertLic(Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Msan msan, string msanDevId, int cabinet, int frame, int card, int port, string service, Ia.Ngn.Cl.Model.Staff staff)
  96:          {
  97:              var result = new Ia.Cl.Model.Result();
  98:   
  99:              if (!string.IsNullOrEmpty(service))
 100:              {
 101:                  if (Ia.Ngn.Cl.Model.Business.Service.ServiceHasEightDigitsAndIsWithinAllowedDomainList(service))
 102:                  {
 103:                      var lic = Ia.Ngn.Cl.Model.Data.Huawei.Default.MsanDevLicByNddMsanAndCabinetAndFrameAndFnAndSnAndPn(msan, cabinet, frame, 0, card, port);
 104:   
 105:                      if (lic == null)
 106:                      {
 107:                          if (msan.DomainList.Any(u => service.StartsWith(u.ToString())))
 108:                          {
 109:                              var emsVoipPstnUserList = Ia.Ngn.Cl.Model.Data.Huawei.VoipPstnUser.ReadByMsanService(service);
 110:   
 111:                              if (emsVoipPstnUserList.Count == 0)
 112:                              {
 113:                                  emsVoipPstnUserList = Ia.Ngn.Cl.Model.Data.Huawei.VoipPstnUser.ReadByService(service);
 114:   
 115:                                  if (emsVoipPstnUserList.Count == 0)
 116:                                  {
 117:                                      var emsOntSipInfoList = Ia.Ngn.Cl.Model.Data.Huawei.OntSipInfo.ReadByService(service);
 118:   
 119:                                      if (emsOntSipInfoList.Count == 0)
 120:                                      {
 121:                                          Ia.Ngn.Cl.Model.Business.Maintenance.Task.ServiceMsanTask(Ia.Ngn.Cl.Model.Business.Msmq.Process.CreateReadNceMsanServiceMsanCabinetFrameFnSnPn, msanDevId, cabinet, frame, 0, card, port, service, staff, out result);
 122:                                      }
 123:                                      else result.AddError("The service number " + service + " already exists in the Fiber's EmsOntSipInfo table (الرقم موجود في قاعدة بيانات الشبكة الرقمية (الفايبر))");
 124:                                  }
 125:                                  else result.AddError("The service number " + service + " already exists in the Fiber's MDU EmsVoipPstnUser table (الرقم موجود في قاعدة بيانات الشبكة الرقمية (الفايبر))");
 126:                              }
 127:                              else result.AddError("The service number " + service + " already exists in MSAN's EmsVoipPstnUser table (الرقم موجود في قاعدة بيانات الأمسان)");
 128:                          }
 129:                          else result.AddError("The service number " + service + " does not belong to MSAN " + msan.NameSymbol + " (" + msan.Site.NameArabicName + ") allowed domain list (الرقم لا ينتمي لنطاق الأرقام المسموح بها في الأمسان)");
 130:                      }
 131:                      else result.AddError("LIC " + lic.ToMsanDevDevSnPnTextString() + " already exists in database (الربط موجود في قاعدة البيانات)");
 132:                  }
 133:                  else result.AddError(@"The service """ + service + @""" does not belong to the network (الرقم لا ينتمي للشبكة)");
 134:              }
 135:              else result.AddError("No input was entered for service (لم يتم إدخال رقم)");
 136:   
 137:              return result;
 138:          }
 139:   
 140:          ////////////////////////////////////////////////////////////////////////////   
 141:   
 142:          /// <summary>
 143:          ///
 144:          /// </summary>
 145:          public static Ia.Cl.Model.Result DeleteLic(Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Msan msan, string emsVoipPstnUserId, Ia.Ngn.Cl.Model.Staff staff, out Ia.Ngn.Cl.Model.Business.Huawei.Dev.MsanDev.Lic msanDevLic)
 146:          {
 147:              var result = new Ia.Cl.Model.Result();
 148:   
 149:              msanDevLic = Ia.Ngn.Cl.Model.Data.Huawei.Default.MsanDevLicByEmsVoipPstnUserId(emsVoipPstnUserId);
 150:   
 151:              if (msanDevLic != null)
 152:              {
 153:                  var service = msanDevLic.Service;
 154:   
 155:                  if (!string.IsNullOrEmpty(service))
 156:                  {
 157:                      if (Ia.Ngn.Cl.Model.Business.Service.ServiceHasEightDigitsAndIsWithinAllowedDomainList(service))
 158:                      {
 159:                          if (msan.DomainList.Any(u => service.StartsWith(u.ToString())))
 160:                          {
 161:                              Ia.Ngn.Cl.Model.Business.Maintenance.Task.ServiceMsanTask(Ia.Ngn.Cl.Model.Business.Msmq.Process.DeleteReadNceMsanService, service, staff, out result);
 162:                          }
 163:                          else result.AddError(@"The service """ + service + @""" does not belong to the network (الرقم لا ينتمي للشبكة).");
 164:                      }
 165:                      else result.AddError("No input was entered for service (لم يتم إدخال رقم).");
 166:                  }
 167:                  else result.AddError("The service number " + service + " does not belong to MSAN " + msan.NameSymbol + " (" + msan.Site.NameArabicName + ") allowed domain list (الرقم لا ينتمي لنطاق الأرقام المسموح بها في الأمسان).");
 168:              }
 169:              else result.AddError("LIC could not be deleted because it does not exist in database (لا يمكن مسح الربط لأنه غير موجود في قاعدة البيانات).");
 170:   
 171:              return result;
 172:          }
 173:   
 174:          ////////////////////////////////////////////////////////////////////////////   
 175:   
 176:          /// <summary>
 177:          ///
 178:          /// </summary>
 179:          public static Ia.Cl.Model.Result BulkInsertLic(string content, Ia.Ngn.Cl.Model.Staff staff, out StringBuilder stringBuilder)
 180:          {
 181:              string line;
 182:   
 183:              stringBuilder = new StringBuilder(10000);
 184:   
 185:              var result = new Ia.Cl.Model.Result();
 186:   
 187:              if (Ia.Ngn.Cl.Model.Business.Authority.StaffCanCreateBulkLicList(Ia.Ngn.Cl.Model.Business.Authority.PersistentStorageFunction.Create, staff))
 188:              {
 189:                  using (StringReader stringReader = new StringReader(content))
 190:                  {
 191:                      if (content.Length > 0)
 192:                      {
 193:                          while ((line = stringReader.ReadLine()) != null)
 194:                          {
 195:                              if (!string.IsNullOrEmpty(line)) // skip empty lines
 196:                              {
 197:                                  if (ParseLine(line, ref stringBuilder, out Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Msan msan, out int cabinet, out int frame, out int card, out int port, out string service))
 198:                                  {
 199:                                      var msanDevId = (from m in Ia.Ngn.Cl.Model.Data.Huawei.Default.MsanDevList
 200:                                                       where m.Msan.Site.Id == msan.Site.Id && m.Cabinet == cabinet && m.Frame == frame
 201:                                                       select m.Id).Single();
 202:   
 203:                                      var r0 = Ia.Ngn.Cl.Model.Business.Huawei.Default.InsertLic(msan, msanDevId, cabinet, frame, card, port, service, staff);
 204:   
 205:                                      if (r0.IsSuccessful)
 206:                                      {
 207:                                          result.AddSuccess(@"> [" + line.Trim() + @"]");
 208:                                          result.AddSuccess(r0.MessageWithoutCaption);
 209:   
 210:                                          stringBuilder.AppendLine(@"> [" + line.Trim() + @"]");
 211:                                          stringBuilder.AppendLine(@"Success: " + r0.MessageWithoutCaption);
 212:                                          stringBuilder.AppendLine(" ");
 213:                                      }
 214:                                      else
 215:                                      {
 216:                                          result.AddError(@"> [" + line.Trim() + @"]");
 217:                                          result.AddError(r0.MessageWithoutCaption);
 218:   
 219:                                          stringBuilder.AppendLine(@"> [" + line.Trim() + @"]");
 220:                                          stringBuilder.AppendLine(@"Error: " + r0.MessageWithoutCaption);
 221:                                          stringBuilder.AppendLine(" ");
 222:                                      }
 223:                                  }
 224:                                  else
 225:                                  {
 226:                                      result.AddError(@"> [" + line.Trim() + @"]");
 227:                                      result.AddError(@"Line format was incorrect and was not matched.");
 228:   
 229:                                      stringBuilder.AppendLine(@"> [" + line.Trim() + @"]");
 230:                                      stringBuilder.AppendLine(@"Error: Line format was incorrect and was not matched.");
 231:                                      stringBuilder.AppendLine(" ");
 232:                                  }
 233:                              }
 234:                          }
 235:                      }
 236:                      else result.AddError("Content is empty.");
 237:                  }
 238:              }
 239:              else result.AddError("You are not authorized to modify this value.");
 240:   
 241:              return result;
 242:          }
 243:   
 244:          /////////////////////////////////////////////////////////////////////////////////
 245:   
 246:          /// <summary>
 247:          ///
 248:          /// </summary>
 249:          private static bool ParseLine(string line, ref StringBuilder stringBuilder, out Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Msan msan, out int cabinet, out int frame, out int card, out int port, out string service)
 250:          {
 251:              bool matchSuccess;
 252:   
 253:              var match = Regex.Match(line, @"(\w{3}_MSAN_Cabinet (\d+)_Frame (\d+))\s+0\s+(\d+)\s+(\d+).+(\d{8})");
 254:              // SSB_MSAN_Cabinet 0_Frame 0    0    1    0    A1-0    1    0    23616315    A1-0-1-0
 255:              if (match.Success)
 256:              {
 257:                  var dev = match.Groups[1].Value;
 258:                  cabinet = int.Parse(match.Groups[2].Value);
 259:                  frame = int.Parse(match.Groups[3].Value);
 260:                  card = int.Parse(match.Groups[4].Value);
 261:                  port = int.Parse(match.Groups[5].Value);
 262:   
 263:                  service = match.Groups[6].Value;
 264:   
 265:                  msan = Ia.Ngn.Cl.Model.Business.Default.MsanFromHuaweiEmsDev(dev);
 266:   
 267:                  matchSuccess = true;
 268:              }
 269:              else
 270:              {
 271:                  msan = null;
 272:                  cabinet = frame = card = port = Ia.Ngn.Cl.Model.Business.Default.PortUndefinedOrInvalidOrUnknown;
 273:                  service = string.Empty;
 274:   
 275:                  matchSuccess = false;
 276:              }
 277:   
 278:              return matchSuccess;
 279:          }
 280:   
 281:          ////////////////////////////////////////////////////////////////////////////
 282:          ////////////////////////////////////////////////////////////////////////////   
 283:      }
 284:   
 285:      ////////////////////////////////////////////////////////////////////////////
 286:      ////////////////////////////////////////////////////////////////////////////   
 287:  }