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

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