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