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

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

Fixed Telecommunications Network's Operations Support System Management Intranet (FTN OSS) support class for Nokia's Fixed Telecommunications Network (FTN) business model.

    1: using System;
    2: using System.Collections.Generic;
    3: using System.Configuration;
    4: using System.Linq;
    5: using System.Text;
    6: using static Ia.Ftn.Cl.Models.Business.NetworkDesignDocument;
    7:  
    8: namespace Ia.Ftn.Cl.Models.Business.Nokia
    9: {
   10:     ////////////////////////////////////////////////////////////////////////////
   11:  
   12:     /// <summary publish="true">
   13:     /// Fixed Telecommunications Network's Operations Support System Management Intranet (FTN OSS) support class for Nokia's Fixed Telecommunications Network (FTN) business model.
   14:     /// </summary>
   15:     /// 
   16:     /// <value>
   17:     ///   <appSettings>
   18:     ///     <add key="sdcServerHost" value="https://*" />
   19:     ///     <add key="sdcServerPort" value="*" />
   20:     ///     <add key="sdcServerServiceUrl" value="*" />
   21:     ///     <add key="sdcServerUser" value="*" />
   22:     ///     <add key="sdcServerUserPassword" value="*" />
   23:     ///   </appSettings>
   24:     /// </value>
   25:     /// 
   26:     /// <remarks> 
   27:     /// Copyright © 2018-2022 Jasem Y. Al-Shamlan (info@ia.com.kw), Integrated Applications - Kuwait. All Rights Reserved.
   28:     /// </remarks> 
   29:     public class Sdc
   30:     {
   31:         private static List<string> ponNameList;
   32:  
   33:         private static List<Ia.Ftn.Cl.Models.Business.NetworkDesignDocument.Pon> ponList;
   34:  
   35:         /// <summary/>
   36:         public static string BaseAddress { get { return Ia.Cl.Models.ApplicationConfiguration.GetSetting("AppSettings:SdcServerHost") + ":" + Ia.Cl.Models.ApplicationConfiguration.GetSetting("AppSettings:SdcServerPort"); } }
   37:  
   38:         /// <summary/>
   39:         public static string ServiceUrl { get { return Ia.Cl.Models.ApplicationConfiguration.GetSetting("AppSettings:SdcServerServiceUrl"); } }
   40:  
   41:         /// <summary/>
   42:         public static string UserName { get { return Ia.Cl.Models.ApplicationConfiguration.GetSetting("AppSettings:SdcServerUser"); } }
   43:  
   44:         /// <summary/>
   45:         public static string Password { get { return Ia.Cl.Models.ApplicationConfiguration.GetSetting("AppSettings:SdcServerUserPassword"); } }
   46:  
   47:         /// <summary/>
   48:         public enum Transaction { Receive, Transmit }
   49:  
   50:         /// <summary/>
   51:         public static List<TimeSpan> ScaleList
   52:         {
   53:             get
   54:             {
   55:                 return new List<TimeSpan> { TimeSpan.FromHours(1), TimeSpan.FromDays(1), TimeSpan.FromDays(7), TimeSpan.FromDays(30), TimeSpan.FromDays(365) };
   56:             }
   57:         }
   58:  
   59:         ////////////////////////////////////////////////////////////////////////////
   60:  
   61:         /// <summary>
   62:         ///
   63:         /// </summary>
   64:         public Sdc()
   65:         {
   66:         }
   67:  
   68:         ////////////////////////////////////////////////////////////////////////////
   69:  
   70:         /// <summary>
   71:         /// 
   72:         /// </summary>
   73:         public class TransactionTimestampValue
   74:         {
   75:             /// <summary/>           
   76:             public Transaction Transaction { get; set; }
   77:  
   78:             /// <summary/>           
   79:             public DateTime Timestamp { get; set; }
   80:  
   81:             /// <summary/>           
   82:             public long Value { get; set; }
   83:  
   84:             ////////////////////////////////////////////////////////////////////////////
   85:  
   86:             /// <summary>
   87:             ///
   88:             /// </summary>
   89:             public TransactionTimestampValue(Transaction transaction, DateTime timestamp, long value)
   90:             {
   91:                 this.Transaction = transaction;
   92:  
   93:                 this.Timestamp = timestamp;
   94:  
   95:                 this.Value = value;
   96:             }
   97:  
   98:             ////////////////////////////////////////////////////////////////////////////
   99:  
  100:             /// <summary>
  101:             ///
  102:             /// </summary>
  103:             public override string ToString()
  104:             {
  105:                 return this.Transaction.ToString() + ": " + this.Timestamp + ": " + this.Value;
  106:             }
  107:  
  108:             ////////////////////////////////////////////////////////////////////////////
  109:         }
  110:  
  111:         ////////////////////////////////////////////////////////////////////////////
  112:  
  113:         /// <summary>
  114:         /// Response of Nokia SDC server
  115:         /// </summary>
  116:         public class Response
  117:         {
  118:             public string Author { get; set; }
  119:  
  120:             /// <summary/>
  121:             public string Version { get; set; }
  122:  
  123:             /// <summary/>
  124:             public string Tmf854Version { get; set; }
  125:  
  126:             /// <summary/>
  127:             public string ActivityName { get; set; }
  128:  
  129:             /// <summary/>
  130:             public string MessageName { get; set; }
  131:  
  132:             /// <summary/>
  133:             public string MessageType { get; set; }
  134:  
  135:             /// <summary/>
  136:             public string SenderUri { get; set; }
  137:  
  138:             /// <summary/>
  139:             public string DestinationUri { get; set; }
  140:  
  141:             /// <summary/>
  142:             public string CommunicationPattern { get; set; }
  143:  
  144:             /// <summary/>
  145:             public string CommunicationStyle { get; set; }
  146:  
  147:             /// <summary/>
  148:             public string ActivityStatus { get; set; }
  149:  
  150:             /// <summary/>
  151:             public DateTime Timestamp { get; set; }
  152:  
  153:             /// <summary/>
  154:             public string BodyText { get; set; }
  155:  
  156:             /// <summary/>
  157:             public Dictionary<string, string> ParameterDictionary;
  158:  
  159:             /// <summary/>
  160:             public bool IsSuccessfull { get { return ReturnCode == Ia.Ftn.Cl.Models.Client.Nokia.Sdc.ResultCode.Successful; } }
  161:  
  162:             /// <summary/>
  163:             public Ia.Ftn.Cl.Models.Client.Nokia.Sdc.ResultCode ReturnCode { get; set; }
  164:  
  165:             /// <summary/>
  166:             public Response() { }
  167:         }
  168:  
  169:         ////////////////////////////////////////////////////////////////////////////
  170:  
  171:         /// <summary>
  172:         ///
  173:         /// </summary>
  174:         public static void EnableSdcPerformanceMonitoringDataOfAllPons(Ia.Ftn.Cl.Models.Client.Nokia.Sdc sdc, out Ia.Cl.Models.Result result)
  175:         {
  176:             StringBuilder sb;
  177:  
  178:             result = new Ia.Cl.Models.Result();
  179:  
  180:             if (ponList == null) ponList = (from p in Ia.Ftn.Cl.Models.Data.NetworkDesignDocument.PonList
  181:                                             where p.PonGroup.Olt.Odf.Vendor == Ia.Ftn.Cl.Models.Business.NetworkDesignDocument.Vendor.Nokia
  182:                                             select p).ToList();
  183:  
  184:             sb = new StringBuilder();
  185:  
  186:             foreach (var pon in ponList)
  187:             {
  188:                 Ia.Ftn.Cl.Models.Business.Nokia.Sdc.EnableSdcPerformanceMonitoringDataForPon(sdc, pon, out result);
  189:  
  190:                 result.AddResult(result);
  191:  
  192:                 sb.AppendLine(result.Message);
  193:             }
  194:         }
  195:  
  196:         ////////////////////////////////////////////////////////////////////////////
  197:  
  198:         /// <summary>
  199:         ///
  200:         /// </summary>
  201:         public static void EnableSdcPerformanceMonitoringDataForPon(Ia.Ftn.Cl.Models.Client.Nokia.Sdc sdc, Ia.Ftn.Cl.Models.Business.NetworkDesignDocument.Pon pon, out Ia.Cl.Models.Result result)
  202:         {
  203:             string s;
  204:  
  205:             result = new Ia.Cl.Models.Result();
  206:  
  207:             sdc.EnablePerformanceMonitoringDataOverPon(pon, out Cl.Models.Business.Nokia.Sdc.Response response);
  208:  
  209:             s = response.Timestamp + ": " + response.ActivityName + ": " + response.ActivityStatus;
  210:             s += "\r\n";
  211:  
  212:             if (response != null && response.ParameterDictionary != null)
  213:             {
  214:                 if (response.ParameterDictionary.Count > 0)
  215:                 {
  216:                     foreach (KeyValuePair<string, string> kvp in response.ParameterDictionary)
  217:                     {
  218:                         s += kvp.Key + ": " + kvp.Value + "\r\n";
  219:                     }
  220:                 }
  221:             }
  222:  
  223:             if (response.IsSuccessfull) result.AddSuccess(s);
  224:             else result.AddError(s);
  225:         }
  226:  
  227:         ////////////////////////////////////////////////////////////////////////////
  228:  
  229:         /// <summary>
  230:         ///
  231:         /// </summary>
  232:         public static Ia.Cl.Models.Result ReadPerformanceMonitoringDataOfEnabledPon(Ia.Ftn.Cl.Models.Client.Nokia.Sdc sdc, Ia.Ftn.Cl.Models.Business.NetworkDesignDocument.Pon pon)
  233:         {
  234:             var result = new Ia.Cl.Models.Result();
  235:  
  236:             var response = sdc.GetPerformanceMonitoringDataOverPon(pon);
  237:  
  238:             var text = string.Empty;
  239:  
  240:             if (response.IsSuccessfull)
  241:             {
  242:                 // Tx
  243:                 if (response.ParameterDictionary.ContainsKey("pmParameterName0"))
  244:                 {
  245:                     var gponOltSidePonUtilTxPmIntervalTotalBytesPmParameterName = response.ParameterDictionary["pmParameterName0"];
  246:  
  247:                     if (response.ParameterDictionary.ContainsKey("pmParameterValue0"))
  248:                     {
  249:                         var gponOltSidePonUtilTxPmIntervalTotalBytesPmParameterValue = response.ParameterDictionary["pmParameterValue0"];
  250:  
  251:                         if (gponOltSidePonUtilTxPmIntervalTotalBytesPmParameterValue.Length > 0)
  252:                         {
  253:                             var list = gponOltSidePonUtilTxPmIntervalTotalBytesPmParameterValue.Split(',');
  254:  
  255:                             if (list.Length > 0)
  256:                             {
  257:                                 var valueList = new List<long>();
  258:  
  259:                                 foreach (var s in list)
  260:                                 {
  261:                                     if (long.TryParse(s, out long l)) valueList.Add(l);
  262:                                     else text += pon.Name + ": transmit: " + response.Timestamp + ": Error: can't parse s: " + s;
  263:                                 }
  264:  
  265:                                 Ia.Ftn.Cl.Models.Data.Nokia.Sdc.SaveTransactionTimestampValueListOfPon(pon, Ia.Ftn.Cl.Models.Business.Nokia.Sdc.Transaction.Transmit, response.Timestamp, valueList);
  266:  
  267:                                 text += pon.Name + ": transmit: " + response.Timestamp + ": " + string.Join(",", valueList);
  268:                             }
  269:                             else
  270:                             {
  271:                                 text += pon.Name + ": transmit: " + response.Timestamp + ": Error: list is empty";
  272:                             }
  273:                         }
  274:                         else
  275:                         {
  276:                             text += pon.Name + ": transmit: " + response.Timestamp + ": Error: gponOltSidePonUtilTxPmIntervalTotalBytesPmParameterValue is empty";
  277:                         }
  278:  
  279:                         result.AddSuccess(text);
  280:                     }
  281:                     else
  282:                     {
  283:                         text += pon.Name + ": transmit: " + response.Timestamp + ": Error: response.ParameterDictionary does not contain key pmParameterValue0";
  284:  
  285:                         result.AddError(text);
  286:                     }
  287:                 }
  288:                 else
  289:                 {
  290:                     text += pon.Name + ": transmit: " + response.Timestamp + ": Error: response.ParameterDictionary does not contain key pmParameterName0";
  291:  
  292:                     result.AddError(text);
  293:                 }
  294:  
  295:  
  296:                 text = string.Empty;
  297:  
  298:                 // Rx
  299:                 if (response.ParameterDictionary.ContainsKey("pmParameterName1"))
  300:                 {
  301:                     var gponOltSidePonUtilRxPmIntervalTotalBytesPmParameterName = response.ParameterDictionary["pmParameterName1"];
  302:  
  303:                     if (response.ParameterDictionary.ContainsKey("pmParameterValue1"))
  304:                     {
  305:                         var gponOltSidePonUtilRxPmIntervalTotalBytesPmParameterValue = response.ParameterDictionary["pmParameterValue1"];
  306:  
  307:                         if (gponOltSidePonUtilRxPmIntervalTotalBytesPmParameterValue.Length > 0)
  308:                         {
  309:                             var list = gponOltSidePonUtilRxPmIntervalTotalBytesPmParameterValue.Split(',');
  310:  
  311:                             if (list.Length > 0)
  312:                             {
  313:                                 var valueList = new List<long>();
  314:  
  315:                                 foreach (var s in list)
  316:                                 {
  317:                                     if (long.TryParse(s, out long l)) valueList.Add(l);
  318:                                     else text += pon.Name + ": receive: " + response.Timestamp + ": Error: can't parse s: " + s;
  319:                                 }
  320:  
  321:                                 Ia.Ftn.Cl.Models.Data.Nokia.Sdc.SaveTransactionTimestampValueListOfPon(pon, Ia.Ftn.Cl.Models.Business.Nokia.Sdc.Transaction.Receive, response.Timestamp, valueList);
  322:  
  323:                                 text += pon.Name + ": receive: " + response.Timestamp + ": " + string.Join(",", valueList);
  324:                             }
  325:                             else
  326:                             {
  327:                                 text += pon.Name + ": receive: " + response.Timestamp + ": Error: list is empty";
  328:                             }
  329:                         }
  330:                         else
  331:                         {
  332:                             text += pon.Name + ": receive: " + response.Timestamp + ": Error: gponOltSidePonUtilRxPmIntervalTotalBytesPmParameterValue is empty";
  333:                         }
  334:  
  335:                         result.AddSuccess(text);
  336:                     }
  337:                     else
  338:                     {
  339:                         text += pon.Name + ": receive: " + response.Timestamp + ": Error: response.ParameterDictionary does not contain key pmParameterValue1";
  340:  
  341:                         result.AddError(text);
  342:                     }
  343:                 }
  344:                 else
  345:                 {
  346:                     text += pon.Name + ": receive: " + response.Timestamp + ": Error: response.ParameterDictionary does not contain key pmParameterName1";
  347:  
  348:                     result.AddError(text);
  349:                 }
  350:             }
  351:             else result.AddError(text);
  352:  
  353:             return result;
  354:         }
  355:  
  356:         ////////////////////////////////////////////////////////////////////////////
  357:  
  358:         /// <summary>
  359:         ///
  360:         /// </summary>
  361:         public static List<Ia.Ftn.Cl.Models.Business.Nokia.Sdc.TransactionTimestampValue> AdjustTransactionTimestampHourlyValueList(Ia.Ftn.Cl.Models.Business.Nokia.Sdc.Transaction transaction, List<Ia.Ftn.Cl.Models.Business.Nokia.Sdc.TransactionTimestampValue> timestampValueList)
  362:         {
  363:             long l;
  364:             List<Ia.Ftn.Cl.Models.Business.Nokia.Sdc.TransactionTimestampValue> adjustedTimestampValueList;
  365:  
  366:             adjustedTimestampValueList = new List<Ia.Ftn.Cl.Models.Business.Nokia.Sdc.TransactionTimestampValue>();
  367:  
  368:             //previous = 0;
  369:  
  370:             foreach (var timestampValue in timestampValueList)
  371:             {
  372:                 if (timestampValue.Transaction == transaction)
  373:                 {
  374:                     l = ConvertHourlyByteCountToMegaBitsPerSecond(timestampValue.Value);
  375:  
  376:                     adjustedTimestampValueList.Add(new Ia.Ftn.Cl.Models.Business.Nokia.Sdc.TransactionTimestampValue(transaction, timestampValue.Timestamp, l));
  377:                 }
  378:             }
  379:  
  380:             return adjustedTimestampValueList;
  381:         }
  382:  
  383:         ////////////////////////////////////////////////////////////////////////////
  384:  
  385:         /// <summary>
  386:         ///
  387:         /// </summary>
  388:         public static long ConvertHourlyByteCountToMegaBitsPerSecond(long l)
  389:         {
  390:             // from Nokia support:.. these are byte counters and five minute interval means that you will have to divide the value with 300 to get bytes per second.
  391:             // ... one byte is eight bits, thus, 10 MB/s = 80 Mb/s.
  392:             // I say: to get the hourly *rate* in Mb/s I will need to divide by 3600 (seconds in an hour)
  393:  
  394:             return l / 3600 * 8 / 1000000;
  395:         }
  396:  
  397:         ////////////////////////////////////////////////////////////////////////////
  398:  
  399:         /// <summary>
  400:         ///
  401:         /// </summary>
  402:         public static void ReadPerformanceMonitoringDataOfEnabledPon(Ia.Ftn.Cl.Models.Client.Nokia.Sdc sdc, out Ia.Cl.Models.Result result)
  403:         {
  404:             if (ponList == null)
  405:             {
  406:                 ponList = (from p in Ia.Ftn.Cl.Models.Data.NetworkDesignDocument.PonList
  407:                            where p.PonGroup.Olt.Odf.Vendor == Ia.Ftn.Cl.Models.Business.NetworkDesignDocument.Vendor.Nokia
  408:                            select p).ToList();
  409:             }
  410:  
  411:             var pon = ponList.Next();
  412:  
  413:             result = Ia.Ftn.Cl.Models.Business.Nokia.Sdc.ReadPerformanceMonitoringDataOfEnabledPon(sdc, pon);
  414:         }
  415:  
  416:         /*
  417:         ////////////////////////////////////////////////////////////////////////////
  418: 
  419:         /// <summary>
  420:         ///
  421:         /// </summary>
  422:         public static List<Ia.Ftn.Cl.Model.Business.Nokia.Sdc.PonNameTimestampValue> AdjusteStatisticDistributionAndCountAndAverageAccordingToTimeScaleToStatisticsListToMakeMoreResonableStorageList(List<Ia.Ftn.Cl.Model.Business.Nokia.Sdc.PonNameTimestampValue> statisticList)
  423:         {
  424:             //int i, numberOfSamplesPerTimeScale;
  425:             //TimeSpan timeSpan;
  426:             //DateTime startTime, endTime;
  427:             List<Ia.Ftn.Cl.Model.Business.Nokia.Sdc.PonNameTimestampValue> oldList, adjustedStatisticsList;
  428: 
  429:             /*
  430:             Dictionary<TimeSpan, List<Ia.Ftn.Cl.Model.Business.Nokia.Sdc.Statistic>> timeSpanToStatisticListDictionary;
  431:             Dictionary<TimeSpan, List<Ia.Ftn.Cl.Model.Business.Nokia.Sdc.Statistic>> timeScaleToStatisticsListDictionary;
  432: 
  433:             numberOfSamplesPerTimeScale = 100;
  434: 
  435:             timeScaleToStatisticsListDictionary = new Dictionary<TimeSpan, List<Ia.Ftn.Cl.Model.Business.Nokia.Sdc.Statistic>>();
  436: 
  437:             timeSpanToStatisticListDictionary = new Dictionary<TimeSpan, List<Ia.Ftn.Cl.Model.Business.Nokia.Sdc.Statistic>>();
  438:             */
  439:         //adjustedStatisticsList = new List<Ia.Ftn.Cl.Model.Business.Nokia.Sdc.PonNameTimestampValue>();
  440:  
  441:         /*
  442:         oldList = new List<Ia.Ftn.Cl.Model.Business.Nokia.Sdc.Statistic>();
  443: 
  444:         foreach (var scale in Ia.Ftn.Cl.Model.Business.Nokia.Sdc.ScaleList.OrderBy(u => u.TotalSeconds))
  445:         {
  446:             timeScaleToStatisticsListDictionary[scale] = FilterAccordingToScaleTimeSpan(scale, statisticList).Except(oldList).ToList();
  447: 
  448:             oldList.AddRange(timeScaleToStatisticsListDictionary[scale]);
  449:         }
  450: 
  451: 
  452:         foreach (var timeScaleToStatisticsList in timeScaleToStatisticsListDictionary.OrderBy(u => u.Key.TotalSeconds))
  453:         {
  454:             timeSpan = new TimeSpan(timeScaleToStatisticsList.Key.Ticks / numberOfSamplesPerTimeScale);
  455: 
  456:             startTime = DateTime.UtcNow.AddHours(3) - timeScaleToStatisticsList.Key;
  457:             endTime = startTime + timeSpan;
  458: 
  459:             foreach (var statistic in timeScaleToStatisticsList.Value)
  460:             {
  461:                 for (i = 0; i < numberOfSamplesPerTimeScale; i++)
  462:                 {
  463:                     if (statistic.Timestamp >= startTime && statistic.Timestamp < endTime)
  464:                     {
  465:                         if (timeSpanToStatisticListDictionary.ContainsKey(timeSpan))
  466:                         {
  467:                             timeSpanToStatisticListDictionary[timeSpan].Add(statistic);
  468:                         }
  469:                         else
  470:                         {
  471:                             timeSpanToStatisticListDictionary[timeSpan] = new List<Ia.Ftn.Cl.Model.Business.Nokia.Sdc.Statistic>();
  472: 
  473:                             timeSpanToStatisticListDictionary[timeSpan].Add(statistic);
  474:                         }
  475: 
  476:                         break;
  477:                     }
  478: 
  479:                     startTime = endTime;
  480:                     endTime = startTime + timeSpan;
  481:                 }
  482:             }
  483: 
  484:             statisticList = new List<Ia.Ftn.Cl.Model.Business.Nokia.Sdc.Statistic>();
  485: 
  486:             foreach (KeyValuePair<TimeSpan, List<Ia.Ftn.Cl.Model.Business.Nokia.Sdc.Statistic>> timeSpanToStatisticList in timeSpanToStatisticListDictionary)
  487:             {
  488:                 if (timeScaleToStatisticsList.Value.Count > 0)
  489:                 {
  490:                     statisticList.Add(new Ia.Ftn.Cl.Model.Business.Nokia.Sdc.Statistic(timeScaleToStatisticsList.Value[0].Pon, startTime, (long)timeSpanToStatisticList.Value.Average(u => u.Count)));
  491:                 }
  492:             }
  493: 
  494:             adjustedStatisticsList.AddRange(statisticList);
  495:         }
  496:         * /
  497: 
  498:         foreach (var v in statisticList)
  499:         {
  500:             if (v.Timestamp >= DateTime.UtcNow.AddHours(3).AddDays(-7))
  501:             {
  502:                 adjustedStatisticsList.Add(v);
  503:             }
  504:         }
  505: 
  506:         return adjustedStatisticsList.OrderBy(u => u.Timestamp.Ticks).ToList();
  507:     }
  508:         */
  509:  
  510:         ////////////////////////////////////////////////////////////////////////////
  511:  
  512:         /// <summary>
  513:         ///
  514:         /// </summary>
  515:         public static List<Ia.Ftn.Cl.Models.Business.Nokia.Sdc.TransactionTimestampValue> FilterAndKeepDataFromNDays(List<Ia.Ftn.Cl.Models.Business.Nokia.Sdc.TransactionTimestampValue> timestampValuelist)
  516:         {
  517:             var dataToKeepFromPastNDays = 30;
  518:             var now = DateTime.UtcNow.AddHours(3);
  519:             var list = new List<Ia.Ftn.Cl.Models.Business.Nokia.Sdc.TransactionTimestampValue>(timestampValuelist.Count);
  520:  
  521:             foreach (var timestampValue in timestampValuelist)
  522:             {
  523:                 if (now.AddDays(-dataToKeepFromPastNDays) < timestampValue.Timestamp) list.Add(timestampValue);
  524:             }
  525:  
  526:             return list;
  527:         }
  528:  
  529:         ////////////////////////////////////////////////////////////////////////////
  530:         ////////////////////////////////////////////////////////////////////////////
  531:     }
  532:  
  533:     ////////////////////////////////////////////////////////////////////////////
  534:     ////////////////////////////////////////////////////////////////////////////
  535: }