)>}]
شركة التطبيقات المتكاملة لتصميم وبرمجة البرمجيات الخاصة ش.ش.و.
Integrated Applications Programming Company
Home » Code Library » Default (Ia.Ftn.Cl.Models.Business.Huawei)

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

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