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

Integrated Applications Programming Company

Skip Navigation LinksHome » Code Library » Event

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

AMS Event support class for Next Generation Network (NGN) data model.

   1:  using System;
   2:  using System.Collections.Generic;
   3:  using System.Data;
   4:  using System.Data.Entity;
   5:  using System.IO;
   6:  using System.Linq;
   7:  using System.Reflection;
   8:  using System.Text;
   9:  using System.Web;
  10:  using System.Xml.Linq;
  11:   
  12:  namespace Ia.Ngn.Cl.Model.Data
  13:  {
  14:      ////////////////////////////////////////////////////////////////////////////
  15:   
  16:      /// <summary publish="true">
  17:      /// AMS Event support class for Next Generation Network (NGN) data model.
  18:      /// </summary>
  19:      /// 
  20:      /// <remarks> 
  21:      /// Copyright © 2006-2018 Jasem Y. Al-Shamlan (info@ia.com.kw), Integrated Applications - Kuwait. All Rights Reserved.
  22:      ///
  23:      /// 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
  24:      /// the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
  25:      ///
  26:      /// This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
  27:      /// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
  28:      /// 
  29:      /// You should have received a copy of the GNU General Public License along with this library. If not, see http://www.gnu.org/licenses.
  30:      /// 
  31:      /// Copyright notice: This notice may not be removed or altered from any source distribution.
  32:      /// </remarks> 
  33:      public partial class Event
  34:      {
  35:          private static long startEventId;
  36:          private static XDocument xDocument;
  37:          private static readonly object objectLock = new object();
  38:   
  39:          ////////////////////////////////////////////////////////////////////////////
  40:   
  41:          /// <summary>
  42:          ///
  43:          /// </summary>
  44:          public enum Priority
  45:          {
  46:              Urgent = 1, Important, Regular, Unspecified
  47:          }
  48:   
  49:          ////////////////////////////////////////////////////////////////////////////
  50:   
  51:          /// <summary>
  52:          ///
  53:          /// </summary>
  54:          public struct Severity
  55:          {
  56:              /// <summary/>
  57:              public Severity(string id, string name)
  58:              {
  59:                  this.Id = id;
  60:                  this.Name = name;
  61:              }
  62:   
  63:              /// <summary/>
  64:              public string Id { get; set; }
  65:              /// <summary/>
  66:              public string Name { get; set; }
  67:          }
  68:   
  69:          ////////////////////////////////////////////////////////////////////////////
  70:   
  71:          /// <summary>
  72:          ///
  73:          /// </summary>
  74:          public struct ServiceEffect
  75:          {
  76:              /// <summary/>
  77:              public ServiceEffect(string id, string name)
  78:              {
  79:                  this.Id = id;
  80:                  this.Name = name;
  81:              }
  82:   
  83:              /// <summary/>
  84:              public string Id { get; set; }
  85:              /// <summary/>
  86:              public string Name { get; set; }
  87:          }
  88:   
  89:          ////////////////////////////////////////////////////////////////////////////
  90:   
  91:          /// <summary>
  92:          ///
  93:          /// </summary>
  94:          public struct Alarm
  95:          {
  96:              public string Id { get; set; }
  97:              public string Name { get; set; }
  98:              public Severity Severity { get; set; }
  99:              public ServiceEffect ServiceEffect { get; set; }
 100:              public bool SaveMessage { get; set; }
 101:              public string Condition { get; set; }
 102:              public string Resolution { get; set; }
 103:          }
 104:   
 105:          ////////////////////////////////////////////////////////////////////////////
 106:   
 107:          /// <summary>
 108:          ///
 109:          /// </summary>
 110:          public Event() { }
 111:   
 112:          ////////////////////////////////////////////////////////////////////////////
 113:   
 114:          /// <summary>
 115:          /// This defines a starting point of event id for searching
 116:          /// </summary>
 117:          public static long StartEventId
 118:          {
 119:              get
 120:              {
 121:                  lock (objectLock)
 122:                  {
 123:                      if (startEventId == 0) startEventId = Ia.Ngn.Cl.Model.Data.Event._StartEventId;
 124:   
 125:                      return startEventId;
 126:                  }
 127:              }
 128:          }
 129:   
 130:          ////////////////////////////////////////////////////////////////////////////
 131:   
 132:          /// <summary>
 133:          /// This defines a starting point of event id for searching
 134:          /// </summary>
 135:          private static long _StartEventId
 136:          {
 137:              get
 138:              {
 139:                  if (HttpContext.Current != null && HttpContext.Current.Application["eventStartEventId"] != null)
 140:                  {
 141:                      startEventId = long.Parse(HttpContext.Current.Application["eventStartEventId"].ToString());
 142:                  }
 143:                  else
 144:                  {
 145:                      lock (objectLock)
 146:                      {
 147:                          startEventId = StartIdFromEventTime(DateTime.UtcNow.AddHours(3).AddDays(-30));
 148:   
 149:                          if (HttpContext.Current != null) HttpContext.Current.Application["eventStartEventId"] = startEventId.ToString();
 150:                      }
 151:                  }
 152:   
 153:                  return startEventId;
 154:              }
 155:          }
 156:   
 157:          ////////////////////////////////////////////////////////////////////////////
 158:   
 159:          /// <summary>
 160:          ///
 161:          /// </summary>
 162:          private static long StartIdFromEventTime(DateTime startEventTime)
 163:          {
 164:              long id;
 165:   
 166:              using (var db = new Ia.Ngn.Cl.Model.Ngn())
 167:              {
 168:                  id = (from e in db.Events where e.EventTime >= startEventTime select e.Id).Min();
 169:              }
 170:   
 171:              return id;
 172:          }
 173:   
 174:          ////////////////////////////////////////////////////////////////////////////
 175:   
 176:          /// <summary>
 177:          ///
 178:          /// </summary>
 179:          public static List<Ia.Ngn.Cl.Model.Event> ReadList()
 180:          {
 181:              List<Ia.Ngn.Cl.Model.Event> list;
 182:   
 183:              using (var db = new Ia.Ngn.Cl.Model.Ngn())
 184:              {
 185:                  list = (from e in db.Events select e).ToList();
 186:              }
 187:   
 188:              return list;
 189:          }
 190:   
 191:          ////////////////////////////////////////////////////////////////////////////
 192:   
 193:          /// <summary>
 194:          ///
 195:          /// </summary>
 196:          public static List<Ia.Ngn.Cl.Model.Ui.Event> ReadTakeNOrderByIdDescendingList(string classId, string severityId, string serviceEffectId, string causeId, int elementsToTake)
 197:          {
 198:              //long approximateNumberOfEventsInAMonth, fromEventId;
 199:              Ia.Ngn.Cl.Model.Ui.Event eventOnt;
 200:              List<Ia.Ngn.Cl.Model.Event> list;
 201:              List<Ia.Ngn.Cl.Model.Ui.Event> uiList;
 202:   
 203:              //approximateNumberOfEventsInAMonth = 1200000;
 204:              uiList = new List<Ia.Ngn.Cl.Model.Ui.Event>();
 205:   
 206:              //fromEventId = Ia.Ngn.Cl.Model.Data.Event.MaxEventId - approximateNumberOfEventsInAMonth;
 207:   
 208:              using (var db = new Ia.Ngn.Cl.Model.Ngn())
 209:              {
 210:                  // when classId is empty we will skip looking for it
 211:                  list = (from e in db.Events
 212:                          where /*e.Id > fromEventId &&*/ (classId == string.Empty || e.Class == classId)
 213:                          && (severityId == string.Empty || e.Severity == severityId)
 214:                          && (serviceEffectId == string.Empty || e.SeverityEffect == serviceEffectId)
 215:                          && (causeId == string.Empty || e.Cause == causeId)
 216:                          orderby e.Id descending
 217:                          select e).ToList();
 218:   
 219:                  if (list != null && list.Count > 0)
 220:                  {
 221:                      foreach (Ia.Ngn.Cl.Model.Event e in list.OrderByDescending(u => u.Id))
 222:                      {
 223:                          eventOnt = new Ia.Ngn.Cl.Model.Ui.Event
 224:                          {
 225:                              Id = e.Id,
 226:                              TypeId = e.TypeId,
 227:                              System = e.System,
 228:                              Class = e.Class,
 229:                              Aid = e.Aid,
 230:                              Cause = e.Cause,
 231:                              Number = e.Number,
 232:                              Detail = e.Detail,
 233:                              Severity = e.Severity,
 234:                              SeverityEffect = e.SeverityEffect,
 235:                              EventTime = e.EventTime,
 236:                              NodeTime = e.NodeTime,
 237:                              Created = e.Created,
 238:                          };
 239:   
 240:                          uiList.Add(eventOnt);
 241:                      }
 242:                  }
 243:                  else
 244:                  {
 245:   
 246:                  }
 247:              }
 248:   
 249:              return uiList;
 250:          }
 251:   
 252:          ////////////////////////////////////////////////////////////////////////////
 253:   
 254:          /// <summary>
 255:          ///
 256:          /// </summary>
 257:          public static List<Ia.Ngn.Cl.Model.Event> ReadTakeNOrderByEventTimeDescendingList(int elementsToTake)
 258:          {
 259:              List<Ia.Ngn.Cl.Model.Event> list;
 260:   
 261:              using (var db = new Ia.Ngn.Cl.Model.Ngn())
 262:              {
 263:                  list = (from e in db.Events orderby e.EventTime descending select e).Take(elementsToTake).ToList();
 264:              }
 265:   
 266:              return list;
 267:          }
 268:   
 269:          ////////////////////////////////////////////////////////////////////////////
 270:   
 271:          /// <summary>
 272:          ///
 273:          /// </summary>
 274:          public static List<Ia.Ngn.Cl.Model.Event> EventWithMjOrCrSeverityAndClassNotOntRelatedForLast24HoursList()
 275:          {
 276:              DateTime twentyFourHoursAgoDateTime;
 277:              List<Ia.Ngn.Cl.Model.Event> list;
 278:   
 279:              twentyFourHoursAgoDateTime = DateTime.UtcNow.AddHours(3).AddDays(-1);
 280:   
 281:              using (var db = new Ia.Ngn.Cl.Model.Ngn())
 282:              {
 283:                  list = (from e in db.Events
 284:                          where (e.Severity == "MJ" || e.Severity == "CR") && e.Class.Substring(0, 3) != "ONT" && e.Created >= twentyFourHoursAgoDateTime
 285:                          orderby e.Created descending
 286:                          select e).ToList();
 287:              }
 288:   
 289:              return list;
 290:          }
 291:   
 292:          ////////////////////////////////////////////////////////////////////////////
 293:   
 294:          /// <summary>
 295:          ///
 296:          /// </summary>
 297:          public static List<Ia.Ngn.Cl.Model.Event> EventWithClassOntAndCauseInactAndLastRecordSeverityNotClAndOntAccessNotNullInLast24HoursList
 298:          {
 299:              get
 300:              {
 301:                  DateTime twentyFourHoursAgoDateTime;
 302:                  List<Ia.Ngn.Cl.Model.Event> list;
 303:   
 304:                  /*
 305:  select e.* 
 306:  from Events e
 307:  inner join 
 308:  (
 309:   select Ont_Id, max(Created) as MaxDate 
 310:   from Events 
 311:   where Class = 'ONT' and Cause = 'INACT' and Created > '2020-01-14'
 312:   group by Ont_Id
 313:  ) e2 on e.Ont_Id = e2.Ont_Id and e.Created = e2.MaxDate
 314:   where e.Severity <> 'CL'
 315:                   */
 316:   
 317:                  twentyFourHoursAgoDateTime = DateTime.UtcNow.AddHours(3).AddDays(-1);
 318:   
 319:                  using (var db = new Ia.Ngn.Cl.Model.Ngn())
 320:                  {
 321:                      list = (from e in db.Events
 322:                              where e.Class == "ONT" && e.Cause == "INACT" && e.Ont != null && e.Ont.Access != null && e.Created >= twentyFourHoursAgoDateTime
 323:                              group e by e.Ont.Id into eg
 324:                              select eg.OrderByDescending(t => t.Created).FirstOrDefault()).Include(u => u.Ont).Include(u => u.Ont.Access).ToList();
 325:   
 326:                      list = (from e in list where e.Severity != "CL" select e).ToList();
 327:                  }
 328:   
 329:                  return list;
 330:              }
 331:          }
 332:   
 333:          ////////////////////////////////////////////////////////////////////////////
 334:   
 335:          /// <summary>
 336:          ///
 337:          /// </summary>
 338:          private static long MaxEventId
 339:          {
 340:              get
 341:              {
 342:                  long maxId;
 343:   
 344:                  using (var db = new Ia.Ngn.Cl.Model.Ngn())
 345:                  {
 346:                      maxId = db.Events.Max(u => u.Id);
 347:                  }
 348:   
 349:                  return maxId;
 350:              }
 351:          }
 352:   
 353:          ////////////////////////////////////////////////////////////////////////////
 354:          ////////////////////////////////////////////////////////////////////////////
 355:   
 356:          /// <summary>
 357:          ///
 358:          /// </summary>
 359:          public static List<Ia.Ngn.Cl.Model.Event> ReadNewOntList2()
 360:          {
 361:              List<Ia.Ngn.Cl.Model.Event> list;
 362:   
 363:              using (var db = new Ia.Ngn.Cl.Model.Ngn())
 364:              {
 365:                  list = (from e in db.Events where e.Cause == "NEWONT" select e).ToList();
 366:              }
 367:   
 368:              return list;
 369:          }
 370:   
 371:          ////////////////////////////////////////////////////////////////////////////
 372:   
 373:          /// <summary>
 374:          ///
 375:          /// </summary>
 376:          public static List<Ia.Ngn.Cl.Model.Ui.Event> ReadNewOntList
 377:          {
 378:              get
 379:              {
 380:                  string serial, ontSerial, ontId, accessName;
 381:                  Ia.Ngn.Cl.Model.Ui.Event eventOnt;
 382:                  List<string> serialList, ontIdList;
 383:                  List<Ia.Ngn.Cl.Model.Event> list;
 384:                  List<Ia.Ngn.Cl.Model.Ui.Event> uiList;
 385:                  Dictionary<string, string> serialToIdListDictionary, di;
 386:   
 387:                  /*
 388:      use Ia_Ngn
 389:      --select distinct System,Class, Aid, Detail from Events where Id > 18900000 and Cause = 'NEWONT'
 390:      --select *from Events where Id > 18000000 and Cause = 'NEWONT' order by Id
 391:      --select max(id) from Events
 392:      -- 1M events is about 3 weeks
 393:      --select * from Events where Id > (select max(id) - 1000000 from Events) and Cause = 'NEWONT' order by Id
 394:      select distinct System, Aid, Cause, Detail from Events where Id > (select max(id) - 1000000 from Events) and Cause = 'NEWONT'
 395:  
 396:       delete from Events where Id < 45564063
 397:  
 398:                  delete events using SQL before one month from today
 399:       */
 400:   
 401:                  serialList = new List<string>();
 402:                  ontIdList = new List<string>();
 403:                  uiList = new List<Ia.Ngn.Cl.Model.Ui.Event>();
 404:   
 405:                  di = Ia.Ngn.Cl.Model.Data.NetworkDesignDocument.OntAccessIdToOntAccessNameDictionary;
 406:   
 407:                  using (var db = new Ia.Ngn.Cl.Model.Ngn())
 408:                  {
 409:                      list = (from e in db.Events where e.Cause == "NEWONT" orderby e.Id descending select e).ToList();
 410:   
 411:                      if (list != null && list.Count > 0)
 412:                      {
 413:                          serialToIdListDictionary = Ia.Ngn.Cl.Model.Data.Nokia.Ont.SerialToIdListDictionary;
 414:   
 415:                          foreach (Ia.Ngn.Cl.Model.Event e in list.OrderByDescending(u => u.Id))
 416:                          {
 417:                              if (!string.IsNullOrEmpty(e.Detail))
 418:                              {
 419:                                  serial = Ia.Cl.Model.Default.Match(e.Detail, "(ALCL.{8})");
 420:   
 421:                                  if (!string.IsNullOrEmpty(serial))
 422:                                  {
 423:                                      if (!serialList.Contains(serial))
 424:                                      {
 425:                                          if (serialToIdListDictionary.ContainsKey(serial))
 426:                                          {
 427:                                              ontId = serialToIdListDictionary[serial];
 428:                                              ontSerial = serial;
 429:   
 430:                                              accessName = di[ontId];
 431:                                          }
 432:                                          else
 433:                                          {
 434:                                              ontId = ontSerial = accessName = string.Empty;
 435:                                          }
 436:   
 437:                                          eventOnt = new Ia.Ngn.Cl.Model.Ui.Event
 438:                                          {
 439:                                              Id = e.Id,
 440:                                              TypeId = e.TypeId,
 441:                                              System = e.System,
 442:                                              Class = e.Class,
 443:                                              Aid = e.Aid,
 444:                                              Cause = e.Cause,
 445:                                              Number = e.Number,
 446:                                              Detail = e.Detail,
 447:                                              Severity = e.Severity,
 448:                                              SeverityEffect = e.SeverityEffect,
 449:                                              EventTime = e.EventTime,
 450:                                              NodeTime = e.NodeTime,
 451:                                              Created = e.Created,
 452:                                              OntId = ontId,
 453:                                              Serial = ontSerial,
 454:                                              AccessName = accessName,
 455:                                          };
 456:   
 457:                                          uiList.Add(eventOnt);
 458:   
 459:                                          serialList.Add(serial);
 460:                                      }
 461:                                      else
 462:                                      {
 463:   
 464:                                      }
 465:                                  }
 466:                              }
 467:                          }
 468:                      }
 469:                      else
 470:                      {
 471:   
 472:                      }
 473:                  }
 474:   
 475:                  /*
 476:                      string s, sql;
 477:                      StringBuilder sb;
 478:                      Hashtable ht, a_ht;
 479:                      DataTable dt, a_dt;
 480:  
 481:                      sb = new StringBuilder(1000);
 482:                      ht = new Hashtable(1000);
 483:                      a_ht = new Hashtable(1000);
 484:  
 485:                      sql = @"SELECT e.id, '' AS last_event, f.area, f.pon, f.ont, f.olt, f.olt_card, f.olt_port, e.system_id, e.aid, f.ont_serial, e.detail, f.area AS f_area, f.block, f.street, 
 486:                                       f.premises_old, f.premises_new, e.node_time, e.event_time, e.created
 487:              FROM            ia_event AS e LEFT OUTER JOIN
 488:                                       ia_field AS f ON e.detail LIKE '%' + f.ont_serial + '%'
 489:              WHERE        (e.cause = 'NEWONT') AND (e.id =
 490:                                           (SELECT        MAX(id) AS max_id
 491:                                             FROM            ia_event AS e2
 492:                                             WHERE        (cause = 'NEWONT') AND (system_id = e.system_id) AND (aid = e.aid) AND (detail = e.detail))) AND (e.severity <> 'CL')
 493:              ORDER BY e.created DESC";
 494:  
 495:                      dt = null; // main.Data.Select(sql);
 496:  
 497:                      if (dt != null && dt.Rows.Count > 1)
 498:                      {
 499:                          // below: now collect all valid ont_position entries and get the last event for them
 500:                          ///gh3
 501:                          sql = string.Empty;
 502:  
 503:                          foreach (DataRow r in dt.Rows)
 504:                          {
 505:                              if (r["ont"] != null && r["ont"].ToString().Length > 0)
 506:                              {
 507:                                  s = r["system_id"].ToString() + ":" + r["aid"].ToString().Replace("PON", "ONT") + "-" + r["ont"].ToString();
 508:                                  ht[s] = r["id"].ToString();
 509:                                  sb.Append("e.system_id='" + r["system_id"].ToString() + "' AND " + "e.aid='" + r["aid"].ToString().Replace("PON", "ONT") + "-" + r["ont"].ToString() + "' OR ");
 510:                              }
 511:                          }
 512:  
 513:                          sql = sb.ToString();
 514:  
 515:                          if (sql.Length > 0)
 516:                          {
 517:                              sql = sql.Remove(sql.Length - 4, 4);
 518:  
 519:                              a_dt = null; // main.Data.Select(@"SELECT system_id, aid, cause, severity FROM ia_event AS e WHERE (" + sql + @") AND (id = (SELECT MAX(id) AS max_id FROM ia_event AS e2 WHERE (system_id = e.system_id) AND (aid = e.aid)))");
 520:  
 521:                              // below: now loop through table and collect cause + severity
 522:                              foreach (DataRow r in a_dt.Rows)
 523:                              {
 524:                                  s = r["system_id"].ToString() + ":" + r["aid"].ToString();
 525:                                  a_ht[ht[s].ToString()] = r["cause"].ToString() + ":" + r["severity"].ToString();
 526:                              }
 527:  
 528:                              // below: now loop through original table and insert last_event
 529:  
 530:                              foreach (DataRow r in dt.Rows)
 531:                              {
 532:                                  s = r["id"].ToString();
 533:                                  if (a_ht.ContainsKey(s)) r["last_event"] = a_ht[s].ToString();
 534:                              }
 535:  
 536:                              gv.DataSource = dt.DefaultView;
 537:                              gv.DataBind();
 538:                          }
 539:                      }
 540:                  }
 541:                       */
 542:   
 543:                  return uiList;
 544:              }
 545:          }
 546:   
 547:          ////////////////////////////////////////////////////////////////////////////
 548:   
 549:          /// <summary>
 550:          ///
 551:          /// </summary>
 552:          public static void DeleteAllEventsBeforeDateTime(DateTime dateTime)
 553:          {
 554:              // see comment on ofn/maitenance/log/event/ams.aspx
 555:   
 556:              using (var db = new Ia.Ngn.Cl.Model.Ngn())
 557:              {
 558:                  if (dateTime > DateTime.MinValue)
 559:                  {
 560:                      db.Database.ExecuteSqlCommand("delete Events where Created < '" + dateTime.ToString("yyyy-MM-dd") + "'");
 561:   
 562:                      /*
 563:  --select top 100 from events where Created 
 564:  
 565:  delete Events where Created < '2018-11-01'
 566:  
 567:  --delete Events where id < (select (max(id) - min(id))/2 + min(id) from Events) 
 568:  --select max(id), min(id),(max(id) - min(id)),(max(id) - min(id))/2 + min(id) from Events
 569:  */
 570:                  }
 571:              }
 572:          }
 573:   
 574:          ////////////////////////////////////////////////////////////////////////////
 575:   
 576:          /// <summary>
 577:          ///
 578:          /// </summary>
 579:          public static bool DeleteByAccessId(string accessId, out string result)
 580:          {
 581:              bool b;
 582:   
 583:              b = false;
 584:              result = string.Empty;
 585:   
 586:              using (var db = new Ia.Ngn.Cl.Model.Ngn())
 587:              {
 588:                  //--delete from Events where Ont_Id = (select id from Onts where Access_Id = '1040101010040004')
 589:   
 590:                  var v = (from e in db.Events
 591:                           join o in db.Onts on e.Ont.Id equals o.Id
 592:                           where o.Access.Id == accessId
 593:                           select e).FirstOrDefault();
 594:   
 595:                  if (v != null)
 596:                  {
 597:                      db.Events.Remove(v);
 598:                      db.SaveChanges();
 599:   
 600:                      b = true;
 601:                  }
 602:                  else b = false;
 603:              }
 604:   
 605:              return b;
 606:          }
 607:   
 608:          ////////////////////////////////////////////////////////////////////////////
 609:   
 610:          /// <summary>
 611:          ///
 612:          /// </summary>
 613:          public static List<Severity> SeverityList
 614:          {
 615:              get
 616:              {
 617:                  List<Severity> severityList;
 618:   
 619:                  severityList = new List<Severity>();
 620:   
 621:                  severityList.Add(new Severity("CR", "Critical"));
 622:                  severityList.Add(new Severity("MJ", "Major"));
 623:                  severityList.Add(new Severity("MN", "Minor"));
 624:                  severityList.Add(new Severity("NR", "Normal/not reported"));
 625:                  severityList.Add(new Severity("NA", "Not alarmed"));
 626:                  severityList.Add(new Severity("ND", "Not yet determained"));
 627:                  severityList.Add(new Severity("WA", "Warning"));
 628:                  severityList.Add(new Severity("CL", "Clear"));
 629:   
 630:                  return severityList;
 631:              }
 632:          }
 633:   
 634:          ////////////////////////////////////////////////////////////////////////////
 635:   
 636:          /// <summary>
 637:          ///
 638:          /// </summary>
 639:          public static List<ServiceEffect> ServiceEffectList
 640:          {
 641:              get
 642:              {
 643:                  List<ServiceEffect> serviceEffectList;
 644:   
 645:                  serviceEffectList = new List<ServiceEffect>();
 646:   
 647:                  serviceEffectList.Add(new ServiceEffect("SA", "Service Affecting"));
 648:                  serviceEffectList.Add(new ServiceEffect("NSA", "Not Service Affecting"));
 649:                  serviceEffectList.Add(new ServiceEffect("NR", "Not Reported"));
 650:   
 651:                  return serviceEffectList;
 652:              }
 653:          }
 654:   
 655:          ////////////////////////////////////////////////////////////////////////////
 656:   
 657:          /// <summary>
 658:          ///
 659:          /// </summary>
 660:          public static List<string> ClassList
 661:          {
 662:              get
 663:              {
 664:                  List<string> list;
 665:   
 666:                  list = new List<string>();
 667:   
 668:                  list.Add("BRGPORT");
 669:                  list.Add("PON");
 670:                  list.Add("EQPT");
 671:                  list.Add("ONTPOTS");
 672:                  list.Add("ONTVOIP");
 673:                  list.Add("ONT");
 674:                  list.Add("ONTENET");
 675:                  list.Add("ONTCARD");
 676:                  list.Add("ONTHSI");
 677:                  list.Add("SECACCESS");
 678:   
 679:                  list.Sort();
 680:   
 681:                  return list;
 682:              }
 683:          }
 684:   
 685:          ////////////////////////////////////////////////////////////////////////////
 686:   
 687:          /// <summary>
 688:          ///
 689:          /// </summary>
 690:          public static List<string> CauseList
 691:          {
 692:              get
 693:              {
 694:                  List<string> list;
 695:   
 696:                  list = new List<string>();
 697:   
 698:                  list.Add("LIMSVCMIS");
 699:                  list.Add("MEM");
 700:                  list.Add("SECUMGTACCESS");
 701:                  list.Add("EQPT");
 702:                  list.Add("SWRESET");
 703:                  list.Add("SECUMGTACCESSTCA");
 704:                  list.Add("BDRESETCF");
 705:                  list.Add("VICONFIGNOTIFYFAIL");
 706:                  list.Add("TXFAIL");
 707:                  list.Add("PONLOS");
 708:                  list.Add("SWVER");
 709:                  list.Add("NEWONT");
 710:                  list.Add("VICONFIGHTTPFAIL");
 711:                  list.Add("LOAM");
 712:                  list.Add("SHUTDOWN");
 713:                  list.Add("BDMISSING");
 714:                  list.Add("BATTMISS");
 715:                  list.Add("LOA");
 716:                  list.Add("ACFAIL");
 717:                  list.Add("RTCPSTREAMLOSS");
 718:                  list.Add("POTSSVCMIS");
 719:                  list.Add("INACT");
 720:                  list.Add("SWDLIP");
 721:                  list.Add("PONMEA");
 722:                  list.Add("OMCICOMM");
 723:                  list.Add("SWVERCTLERR");
 724:                  list.Add("VNTWKERR");
 725:                  list.Add("BDRESET");
 726:                  list.Add("ONTMEA");
 727:                  list.Add("LOS");
 728:                  list.Add("VOIPCNFG");
 729:                  list.Add("SWACTFAIL");
 730:                  list.Add("VGATEWAYCOMM");
 731:                  list.Add("SD");
 732:                  list.Add("BDINIT");
 733:                  list.Add("INTRUDER");
 734:                  list.Add("FANALM");
 735:                  list.Add("DUPADDR");
 736:                  list.Add("SWDLFILE");
 737:                  list.Add("VCLIENTSVCMIS");
 738:                  list.Add("DG");
 739:                  list.Add("SF");
 740:                  list.Add("SUF");
 741:                  list.Add("BATTFAIL");
 742:                  list.Add("HITEMP");
 743:                  list.Add("LANSVCMIS");
 744:                  list.Add("VICONFIGSUBFAIL");
 745:                  list.Add("SWDLFAIL");
 746:                  list.Add("EXCEPTOVLD");
 747:                  list.Add("HSISVCMIS");
 748:                  list.Add("LOKS");
 749:                  list.Add("PONCOMMFAIL");
 750:                  list.Add("HITEMPSHUTOFF");
 751:                  list.Add("LIMMEA");
 752:                  list.Add("RDI");
 753:                  list.Add("ONTDISABLED");
 754:                  list.Add("BATTLOW");
 755:                  list.Add("DOW");
 756:   
 757:                  list.Sort();
 758:   
 759:                  return list;
 760:              }
 761:          }
 762:   
 763:          ////////////////////////////////////////////////////////////////////////////
 764:   
 765:          /// <summary>
 766:          ///
 767:          /// </summary>
 768:          public static List<Alarm> AlarmList
 769:          {
 770:              get
 771:              {
 772:                  Alarm alarm;
 773:                  List<Alarm> alarmList;
 774:   
 775:                  alarmList = new List<Alarm>();
 776:   
 777:                  foreach (XElement xe in XDocument.Element("event").Element("alarm").Elements("aid").Elements("alarmList").Elements("alarm"))
 778:                  {
 779:                      alarm = new Alarm();
 780:   
 781:                      alarm.Id = xe.Attribute("id").Value;
 782:                      alarm.Name = xe.Attribute("name").Value;
 783:                      alarm.Severity = (from s in SeverityList where s.Id == xe.Attribute("severity").Value select s).Single();
 784:                      alarm.ServiceEffect = (from s in ServiceEffectList where s.Id == xe.Attribute("serviceEffect").Value select s).Single();
 785:                      alarm.SaveMessage = bool.Parse(xe.Attribute("saveMessage").Value);
 786:                      alarm.Condition = xe.Element("condition").Value;
 787:                      alarm.Resolution = xe.Element("resolution").Value;
 788:   
 789:                      alarmList.Add(alarm);
 790:                  }
 791:   
 792:                  return alarmList;
 793:              }
 794:          }
 795:   
 796:          ////////////////////////////////////////////////////////////////////////////
 797:   
 798:          /// <summary>
 799:          ///
 800:          /// </summary>
 801:          public static string ToString(Ia.Ngn.Cl.Model.Event _event)
 802:          {
 803:              StringBuilder sb;
 804:   
 805:              sb = new StringBuilder();
 806:   
 807:              sb.AppendLine("Class: " + _event.Class);
 808:              sb.AppendLine("System: " + _event.System);
 809:              sb.AppendLine("Severity: " + _event.Severity);
 810:              sb.AppendLine("SeverityEffect: " + _event.SeverityEffect);
 811:              sb.AppendLine("Aid: " + _event.Aid);
 812:              sb.AppendLine("Cause: " + _event.Cause);
 813:              sb.AppendLine("Number: " + _event.Number);
 814:              sb.AppendLine("Detail: " + _event.Detail);
 815:              sb.AppendLine("EventTime: " + _event.EventTime);
 816:              sb.AppendLine("NodeTime: " + _event.NodeTime);
 817:              sb.AppendLine("Created: " + _event.Created);
 818:   
 819:              return sb.ToString();
 820:          }
 821:   
 822:          ////////////////////////////////////////////////////////////////////////////
 823:   
 824:          /// <summary>
 825:          ///
 826:          /// </summary>
 827:          public static string ToSimpleTextString(Ia.Ngn.Cl.Model.Event _event)
 828:          {
 829:              StringBuilder sb;
 830:   
 831:              sb = new StringBuilder();
 832:   
 833:              //sb.AppendLine("Class: " + _event.Class);
 834:              sb.AppendLine("System: " + _event.System);
 835:              sb.AppendLine("Severity: " + _event.Severity);
 836:              //sb.AppendLine("SeverityEffect: " + _event.SeverityEffect);
 837:              sb.AppendLine("Aid: " + _event.Aid);
 838:              sb.AppendLine("Cause: " + _event.Cause);
 839:              //sb.AppendLine("Number: " + _event.Number);
 840:              sb.AppendLine("Detail: " + _event.Detail);
 841:              sb.AppendLine("EventTime: " + _event.EventTime);
 842:              //sb.AppendLine("NodeTime: " + _event.NodeTime);
 843:              //sb.AppendLine("Created: " + _event.Created);
 844:   
 845:              return sb.ToString();
 846:          }
 847:   
 848:          ////////////////////////////////////////////////////////////////////////////
 849:   
 850:          /// <summary>
 851:          /// 
 852:          /// How to embed and access resources by using Visual C# http://support.microsoft.com/kb/319292/en-us
 853:          /// 
 854:          /// 1. Change the "Build Action" property of your XML file from "Content" to "Embedded Resource".
 855:          /// 2. Add "using System.Reflection".
 856:          /// 3. See sample below.
 857:          /// 
 858:          /// </summary>
 859:   
 860:          private static XDocument XDocument
 861:          {
 862:              get
 863:              {
 864:                  if (xDocument == null)
 865:                  {
 866:                      Assembly _assembly;
 867:                      StreamReader streamReader;
 868:   
 869:                      _assembly = Assembly.GetExecutingAssembly();
 870:                      streamReader = new StreamReader(_assembly.GetManifestResourceStream("Ia.Ngn.Cl.model.data.event.xml"));
 871:   
 872:                      try
 873:                      {
 874:                          if (streamReader.Peek() != -1)
 875:                          {
 876:                              xDocument = System.Xml.Linq.XDocument.Load(streamReader);
 877:                          }
 878:                      }
 879:                      catch (Exception)
 880:                      {
 881:                      }
 882:                      finally
 883:                      {
 884:                      }
 885:                  }
 886:   
 887:                  return xDocument;
 888:              }
 889:          }
 890:   
 891:          ////////////////////////////////////////////////////////////////////////////    
 892:          ////////////////////////////////////////////////////////////////////////////    
 893:      }
 894:   
 895:      ////////////////////////////////////////////////////////////////////////////
 896:      ////////////////////////////////////////////////////////////////////////////   
 897:  }