Professional Applications Programmers/Consultants برمجة واستشارات تطبيقات الإنترنت
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:   
  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:                  if (startEventId == 0)
 122:                  {
 123:                      if (HttpContext.Current != null && HttpContext.Current.Application["eventStartEventId"] != null)
 124:                      {
 125:                          startEventId = long.Parse(HttpContext.Current.Application["eventStartEventId"].ToString());
 126:                      }
 127:                      else
 128:                      {
 129:                          startEventId = StartIdFromEventTime(DateTime.UtcNow.AddHours(3).AddDays(-30));
 130:   
 131:                          if (HttpContext.Current != null) HttpContext.Current.Application["eventStartEventId"] = startEventId.ToString();
 132:                      }
 133:                  }
 134:   
 135:                  return startEventId;
 136:              }
 137:          }
 138:   
 139:          ////////////////////////////////////////////////////////////////////////////
 140:   
 141:          /// <summary>
 142:          ///
 143:          /// </summary>
 144:          private static long StartIdFromEventTime(DateTime startEventTime)
 145:          {
 146:              long id;
 147:   
 148:              using (var db = new Ia.Ngn.Cl.Model.Ngn())
 149:              {
 150:                  id = (from e in db.Events where e.EventTime >= startEventTime select e.Id).Min();
 151:              }
 152:   
 153:              return id;
 154:          }
 155:   
 156:          ////////////////////////////////////////////////////////////////////////////
 157:   
 158:          /// <summary>
 159:          ///
 160:          /// </summary>
 161:          public static List<Ia.Ngn.Cl.Model.Event> ReadList()
 162:          {
 163:              List<Ia.Ngn.Cl.Model.Event> list;
 164:   
 165:              using (var db = new Ia.Ngn.Cl.Model.Ngn())
 166:              {
 167:                  list = (from e in db.Events select e).ToList();
 168:              }
 169:   
 170:              return list;
 171:          }
 172:   
 173:          ////////////////////////////////////////////////////////////////////////////
 174:   
 175:          /// <summary>
 176:          ///
 177:          /// </summary>
 178:          public static List<Ia.Ngn.Cl.Model.Ui.Event> ReadTakeNOrderByIdDescendingList(string classId, string severityId, string serviceEffectId, string causeId, int elementsToTake)
 179:          {
 180:              //long approximateNumberOfEventsInAMonth, fromEventId;
 181:              Ia.Ngn.Cl.Model.Ui.Event eventOnt;
 182:              List<Ia.Ngn.Cl.Model.Event> list;
 183:              List<Ia.Ngn.Cl.Model.Ui.Event> uiList;
 184:   
 185:              //approximateNumberOfEventsInAMonth = 1200000;
 186:              uiList = new List<Ia.Ngn.Cl.Model.Ui.Event>();
 187:   
 188:              //fromEventId = Ia.Ngn.Cl.Model.Data.Event.MaxEventId - approximateNumberOfEventsInAMonth;
 189:   
 190:              using (var db = new Ia.Ngn.Cl.Model.Ngn())
 191:              {
 192:                  // when classId is empty we will skip looking for it
 193:                  list = (from e in db.Events
 194:                          where /*e.Id > fromEventId &&*/ (classId == string.Empty || e.Class == classId)
 195:                          && (severityId == string.Empty || e.Severity == severityId)
 196:                          && (serviceEffectId == string.Empty || e.SeverityEffect == serviceEffectId)
 197:                          && (causeId == string.Empty || e.Cause == causeId)
 198:                          orderby e.Id descending
 199:                          select e).ToList();
 200:   
 201:                  if (list != null && list.Count > 0)
 202:                  {
 203:                      foreach (Ia.Ngn.Cl.Model.Event e in list.OrderByDescending(u => u.Id))
 204:                      {
 205:                          eventOnt = new Ia.Ngn.Cl.Model.Ui.Event
 206:                          {
 207:                              Id = e.Id,
 208:                              TypeId = e.TypeId,
 209:                              System = e.System,
 210:                              Class = e.Class,
 211:                              Aid = e.Aid,
 212:                              Cause = e.Cause,
 213:                              Number = e.Number,
 214:                              Detail = e.Detail,
 215:                              Severity = e.Severity,
 216:                              SeverityEffect = e.SeverityEffect,
 217:                              EventTime = e.EventTime,
 218:                              NodeTime = e.NodeTime,
 219:                              Created = e.Created,
 220:                          };
 221:   
 222:                          uiList.Add(eventOnt);
 223:                      }
 224:                  }
 225:                  else
 226:                  {
 227:   
 228:                  }
 229:              }
 230:   
 231:              return uiList;
 232:          }
 233:   
 234:          ////////////////////////////////////////////////////////////////////////////
 235:   
 236:          /// <summary>
 237:          ///
 238:          /// </summary>
 239:          public static List<Ia.Ngn.Cl.Model.Event> ReadTakeNOrderByEventTimeDescendingList(int elementsToTake)
 240:          {
 241:              List<Ia.Ngn.Cl.Model.Event> list;
 242:   
 243:              using (var db = new Ia.Ngn.Cl.Model.Ngn())
 244:              {
 245:                  list = (from e in db.Events orderby e.EventTime descending select e).Take(elementsToTake).ToList();
 246:              }
 247:   
 248:              return list;
 249:          }
 250:   
 251:          ////////////////////////////////////////////////////////////////////////////
 252:   
 253:          /// <summary>
 254:          ///
 255:          /// </summary>
 256:          public static List<Ia.Ngn.Cl.Model.Event> EventWithMjOrCrSeverityAndClassNotOntRelatedForLast24HoursList()
 257:          {
 258:              DateTime twentyFourHoursAgoDateTime;
 259:              List<Ia.Ngn.Cl.Model.Event> list;
 260:   
 261:              twentyFourHoursAgoDateTime = DateTime.UtcNow.AddHours(3).AddDays(-1);
 262:   
 263:              using (var db = new Ia.Ngn.Cl.Model.Ngn())
 264:              {
 265:                  list = (from e in db.Events
 266:                          where (e.Severity == "MJ" || e.Severity == "CR") && e.Class.Substring(0, 3) != "ONT" && e.Created >= twentyFourHoursAgoDateTime
 267:                          orderby e.Created descending
 268:                          select e).ToList();
 269:              }
 270:   
 271:              return list;
 272:          }
 273:   
 274:          ////////////////////////////////////////////////////////////////////////////
 275:   
 276:          /// <summary>
 277:          ///
 278:          /// </summary>
 279:          public static List<Ia.Ngn.Cl.Model.Event> EventWithClassOntAndCauseInactAndSeverityNotClInLast24HoursList
 280:          {
 281:              get
 282:              {
 283:                  DateTime twentyFourHoursAgoDateTime;
 284:                  List<Ia.Ngn.Cl.Model.Event> list;
 285:   
 286:                  twentyFourHoursAgoDateTime = DateTime.UtcNow.AddHours(3).AddDays(-1);
 287:   
 288:                  using (var db = new Ia.Ngn.Cl.Model.Ngn())
 289:                  {
 290:                      list = (from e in db.Events
 291:                              where e.Class == "ONT" && e.Cause == "INACT" && e.Severity != "CL" && e.Ont != null && e.Ont.Access != null && e.Created >= twentyFourHoursAgoDateTime
 292:                              orderby e.Id descending
 293:                              select e).Include(u => u.Ont).ToList();
 294:                  }
 295:   
 296:                  return list;
 297:              }
 298:          }
 299:   
 300:          ////////////////////////////////////////////////////////////////////////////
 301:   
 302:          /// <summary>
 303:          ///
 304:          /// </summary>
 305:          private static long MaxEventId
 306:          {
 307:              get
 308:              {
 309:                  long maxId;
 310:   
 311:                  using (var db = new Ia.Ngn.Cl.Model.Ngn())
 312:                  {
 313:                      maxId = db.Events.Max(u => u.Id);
 314:                  }
 315:   
 316:                  return maxId;
 317:              }
 318:          }
 319:   
 320:          ////////////////////////////////////////////////////////////////////////////
 321:          ////////////////////////////////////////////////////////////////////////////
 322:   
 323:          /// <summary>
 324:          ///
 325:          /// </summary>
 326:          public static List<Ia.Ngn.Cl.Model.Event> ReadNewOntList2()
 327:          {
 328:              List<Ia.Ngn.Cl.Model.Event> list;
 329:   
 330:              using (var db = new Ia.Ngn.Cl.Model.Ngn())
 331:              {
 332:                  list = (from e in db.Events where e.Cause == "NEWONT" select e).ToList();
 333:              }
 334:   
 335:              return list;
 336:          }
 337:   
 338:          ////////////////////////////////////////////////////////////////////////////
 339:   
 340:          /// <summary>
 341:          ///
 342:          /// </summary>
 343:          public static List<Ia.Ngn.Cl.Model.Ui.Event> ReadNewOntList
 344:          {
 345:              get
 346:              {
 347:                  string serial, ontSerial, ontId, accessName;
 348:                  Ia.Ngn.Cl.Model.Ui.Event eventOnt;
 349:                  List<string> serialList, ontIdList;
 350:                  List<Ia.Ngn.Cl.Model.Event> list;
 351:                  List<Ia.Ngn.Cl.Model.Ui.Event> uiList;
 352:                  Hashtable ht;
 353:                  Dictionary<string, string> serialToIdListDictionary;
 354:   
 355:                  /*
 356:      use Ia_Ngn
 357:      --select distinct System,Class, Aid, Detail from Events where Id > 18900000 and Cause = 'NEWONT'
 358:      --select *from Events where Id > 18000000 and Cause = 'NEWONT' order by Id
 359:      --select max(id) from Events
 360:      -- 1M events is about 3 weeks
 361:      --select * from Events where Id > (select max(id) - 1000000 from Events) and Cause = 'NEWONT' order by Id
 362:      select distinct System, Aid, Cause, Detail from Events where Id > (select max(id) - 1000000 from Events) and Cause = 'NEWONT'
 363:  
 364:       delete from Events where Id < 45564063
 365:  
 366:                  delete events using SQL before one month from today
 367:       */
 368:   
 369:                  serialList = new List<string>();
 370:                  ontIdList = new List<string>();
 371:                  uiList = new List<Ia.Ngn.Cl.Model.Ui.Event>();
 372:   
 373:                  ht = Ia.Ngn.Cl.Model.Data.NetworkDesignDocument.OntIdToAccessNameHashtable;
 374:   
 375:                  using (var db = new Ia.Ngn.Cl.Model.Ngn())
 376:                  {
 377:                      list = (from e in db.Events where e.Cause == "NEWONT" orderby e.Id descending select e).ToList();
 378:   
 379:                      if (list != null && list.Count > 0)
 380:                      {
 381:                          serialToIdListDictionary = Ia.Ngn.Cl.Model.Data.Nokia.Ont.SerialToIdListDictionary;
 382:   
 383:                          foreach (Ia.Ngn.Cl.Model.Event e in list.OrderByDescending(u => u.Id))
 384:                          {
 385:                              if (!string.IsNullOrEmpty(e.Detail))
 386:                              {
 387:                                  serial = Ia.Cl.Model.Default.Match(e.Detail, "(ALCL.{8})");
 388:   
 389:                                  if (!string.IsNullOrEmpty(serial))
 390:                                  {
 391:                                      if (!serialList.Contains(serial))
 392:                                      {
 393:                                          if (serialToIdListDictionary.ContainsKey(serial))
 394:                                          {
 395:                                              ontId = serialToIdListDictionary[serial];
 396:                                              ontSerial = serial;
 397:   
 398:                                              accessName = ht[ontId].ToString();
 399:                                          }
 400:                                          else
 401:                                          {
 402:                                              ontId = ontSerial = accessName = string.Empty;
 403:                                          }
 404:   
 405:                                          eventOnt = new Ia.Ngn.Cl.Model.Ui.Event
 406:                                          {
 407:                                              Id = e.Id,
 408:                                              TypeId = e.TypeId,
 409:                                              System = e.System,
 410:                                              Class = e.Class,
 411:                                              Aid = e.Aid,
 412:                                              Cause = e.Cause,
 413:                                              Number = e.Number,
 414:                                              Detail = e.Detail,
 415:                                              Severity = e.Severity,
 416:                                              SeverityEffect = e.SeverityEffect,
 417:                                              EventTime = e.EventTime,
 418:                                              NodeTime = e.NodeTime,
 419:                                              Created = e.Created,
 420:                                              OntId = ontId,
 421:                                              Serial = ontSerial,
 422:                                              AccessName = accessName,
 423:                                          };
 424:   
 425:                                          uiList.Add(eventOnt);
 426:   
 427:                                          serialList.Add(serial);
 428:                                      }
 429:                                      else
 430:                                      {
 431:   
 432:                                      }
 433:                                  }
 434:                              }
 435:                          }
 436:                      }
 437:                      else
 438:                      {
 439:   
 440:                      }
 441:                  }
 442:   
 443:                  /*
 444:                      string s, sql;
 445:                      StringBuilder sb;
 446:                      Hashtable ht, a_ht;
 447:                      DataTable dt, a_dt;
 448:  
 449:                      sb = new StringBuilder(1000);
 450:                      ht = new Hashtable(1000);
 451:                      a_ht = new Hashtable(1000);
 452:  
 453:                      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, 
 454:                                       f.premises_old, f.premises_new, e.node_time, e.event_time, e.created
 455:              FROM            ia_event AS e LEFT OUTER JOIN
 456:                                       ia_field AS f ON e.detail LIKE '%' + f.ont_serial + '%'
 457:              WHERE        (e.cause = 'NEWONT') AND (e.id =
 458:                                           (SELECT        MAX(id) AS max_id
 459:                                             FROM            ia_event AS e2
 460:                                             WHERE        (cause = 'NEWONT') AND (system_id = e.system_id) AND (aid = e.aid) AND (detail = e.detail))) AND (e.severity <> 'CL')
 461:              ORDER BY e.created DESC";
 462:  
 463:                      dt = null; // main.Data.Select(sql);
 464:  
 465:                      if (dt != null && dt.Rows.Count > 1)
 466:                      {
 467:                          // below: now collect all valid ont_position entries and get the last event for them
 468:                          ///gh3
 469:                          sql = "";
 470:  
 471:                          foreach (DataRow r in dt.Rows)
 472:                          {
 473:                              if (r["ont"] != null && r["ont"].ToString().Length > 0)
 474:                              {
 475:                                  s = r["system_id"].ToString() + ":" + r["aid"].ToString().Replace("PON", "ONT") + "-" + r["ont"].ToString();
 476:                                  ht[s] = r["id"].ToString();
 477:                                  sb.Append("e.system_id='" + r["system_id"].ToString() + "' AND " + "e.aid='" + r["aid"].ToString().Replace("PON", "ONT") + "-" + r["ont"].ToString() + "' OR ");
 478:                              }
 479:                          }
 480:  
 481:                          sql = sb.ToString();
 482:  
 483:                          if (sql.Length > 0)
 484:                          {
 485:                              sql = sql.Remove(sql.Length - 4, 4);
 486:  
 487:                              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)))");
 488:  
 489:                              // below: now loop through table and collect cause + severity
 490:                              foreach (DataRow r in a_dt.Rows)
 491:                              {
 492:                                  s = r["system_id"].ToString() + ":" + r["aid"].ToString();
 493:                                  a_ht[ht[s].ToString()] = r["cause"].ToString() + ":" + r["severity"].ToString();
 494:                              }
 495:  
 496:                              // below: now loop through original table and insert last_event
 497:  
 498:                              foreach (DataRow r in dt.Rows)
 499:                              {
 500:                                  s = r["id"].ToString();
 501:                                  if (a_ht.ContainsKey(s)) r["last_event"] = a_ht[s].ToString();
 502:                              }
 503:  
 504:                              gv.DataSource = dt.DefaultView;
 505:                              gv.DataBind();
 506:                          }
 507:                      }
 508:                  }
 509:                       */
 510:   
 511:                  return uiList;
 512:              }
 513:          }
 514:   
 515:          ////////////////////////////////////////////////////////////////////////////
 516:   
 517:          /// <summary>
 518:          ///
 519:          /// </summary>
 520:          public static void DeleteAllEventsBeforeDateTime(DateTime dateTime)
 521:          {
 522:              using (var db = new Ia.Ngn.Cl.Model.Ngn())
 523:              {
 524:                  if (dateTime > DateTime.MinValue)
 525:                  {
 526:                      db.Database.ExecuteSqlCommand("delete Events where Created < '" + dateTime.ToString("yyyy-MM-dd") + "'");
 527:                  }
 528:              }
 529:          }
 530:   
 531:          ////////////////////////////////////////////////////////////////////////////
 532:   
 533:          /// <summary>
 534:          ///
 535:          /// </summary>
 536:          public static List<Severity> SeverityList
 537:          {
 538:              get
 539:              {
 540:                  List<Severity> severityList;
 541:   
 542:                  severityList = new List<Severity>();
 543:   
 544:                  severityList.Add(new Severity("CR", "Critical"));
 545:                  severityList.Add(new Severity("MJ", "Major"));
 546:                  severityList.Add(new Severity("MN", "Minor"));
 547:                  severityList.Add(new Severity("NR", "Normal/not reported"));
 548:                  severityList.Add(new Severity("NA", "Not alarmed"));
 549:                  severityList.Add(new Severity("ND", "Not yet determained"));
 550:                  severityList.Add(new Severity("WA", "Warning"));
 551:                  severityList.Add(new Severity("CL", "Clear"));
 552:   
 553:                  return severityList;
 554:              }
 555:          }
 556:   
 557:          ////////////////////////////////////////////////////////////////////////////
 558:   
 559:          /// <summary>
 560:          ///
 561:          /// </summary>
 562:          public static List<ServiceEffect> ServiceEffectList
 563:          {
 564:              get
 565:              {
 566:                  List<ServiceEffect> serviceEffectList;
 567:   
 568:                  serviceEffectList = new List<ServiceEffect>();
 569:   
 570:                  serviceEffectList.Add(new ServiceEffect("SA", "Service Affecting"));
 571:                  serviceEffectList.Add(new ServiceEffect("NSA", "Not Service Affecting"));
 572:                  serviceEffectList.Add(new ServiceEffect("NR", "Not Reported"));
 573:   
 574:                  return serviceEffectList;
 575:              }
 576:          }
 577:   
 578:          ////////////////////////////////////////////////////////////////////////////
 579:   
 580:          /// <summary>
 581:          ///
 582:          /// </summary>
 583:          public static List<string> ClassList
 584:          {
 585:              get
 586:              {
 587:                  List<string> list;
 588:   
 589:                  list = new List<string>();
 590:   
 591:                  list.Add("BRGPORT");
 592:                  list.Add("PON");
 593:                  list.Add("EQPT");
 594:                  list.Add("ONTPOTS");
 595:                  list.Add("ONTVOIP");
 596:                  list.Add("ONT");
 597:                  list.Add("ONTENET");
 598:                  list.Add("ONTCARD");
 599:                  list.Add("ONTHSI");
 600:                  list.Add("SECACCESS");
 601:   
 602:                  list.Sort();
 603:   
 604:                  return list;
 605:              }
 606:          }
 607:   
 608:          ////////////////////////////////////////////////////////////////////////////
 609:   
 610:          /// <summary>
 611:          ///
 612:          /// </summary>
 613:          public static List<string> CauseList
 614:          {
 615:              get
 616:              {
 617:                  List<string> list;
 618:   
 619:                  list = new List<string>();
 620:   
 621:                  list.Add("LIMSVCMIS");
 622:                  list.Add("MEM");
 623:                  list.Add("SECUMGTACCESS");
 624:                  list.Add("EQPT");
 625:                  list.Add("SWRESET");
 626:                  list.Add("SECUMGTACCESSTCA");
 627:                  list.Add("BDRESETCF");
 628:                  list.Add("VICONFIGNOTIFYFAIL");
 629:                  list.Add("TXFAIL");
 630:                  list.Add("PONLOS");
 631:                  list.Add("SWVER");
 632:                  list.Add("NEWONT");
 633:                  list.Add("VICONFIGHTTPFAIL");
 634:                  list.Add("LOAM");
 635:                  list.Add("SHUTDOWN");
 636:                  list.Add("BDMISSING");
 637:                  list.Add("BATTMISS");
 638:                  list.Add("LOA");
 639:                  list.Add("ACFAIL");
 640:                  list.Add("RTCPSTREAMLOSS");
 641:                  list.Add("POTSSVCMIS");
 642:                  list.Add("INACT");
 643:                  list.Add("SWDLIP");
 644:                  list.Add("PONMEA");
 645:                  list.Add("OMCICOMM");
 646:                  list.Add("SWVERCTLERR");
 647:                  list.Add("VNTWKERR");
 648:                  list.Add("BDRESET");
 649:                  list.Add("ONTMEA");
 650:                  list.Add("LOS");
 651:                  list.Add("VOIPCNFG");
 652:                  list.Add("SWACTFAIL");
 653:                  list.Add("VGATEWAYCOMM");
 654:                  list.Add("SD");
 655:                  list.Add("BDINIT");
 656:                  list.Add("INTRUDER");
 657:                  list.Add("FANALM");
 658:                  list.Add("DUPADDR");
 659:                  list.Add("SWDLFILE");
 660:                  list.Add("VCLIENTSVCMIS");
 661:                  list.Add("DG");
 662:                  list.Add("SF");
 663:                  list.Add("SUF");
 664:                  list.Add("BATTFAIL");
 665:                  list.Add("HITEMP");
 666:                  list.Add("LANSVCMIS");
 667:                  list.Add("VICONFIGSUBFAIL");
 668:                  list.Add("SWDLFAIL");
 669:                  list.Add("EXCEPTOVLD");
 670:                  list.Add("HSISVCMIS");
 671:                  list.Add("LOKS");
 672:                  list.Add("PONCOMMFAIL");
 673:                  list.Add("HITEMPSHUTOFF");
 674:                  list.Add("LIMMEA");
 675:                  list.Add("RDI");
 676:                  list.Add("ONTDISABLED");
 677:                  list.Add("BATTLOW");
 678:                  list.Add("DOW");
 679:   
 680:                  list.Sort();
 681:   
 682:                  return list;
 683:              }
 684:          }
 685:   
 686:          ////////////////////////////////////////////////////////////////////////////
 687:   
 688:          /// <summary>
 689:          ///
 690:          /// </summary>
 691:          public static List<Alarm> AlarmList
 692:          {
 693:              get
 694:              {
 695:                  Alarm alarm;
 696:                  List<Alarm> alarmList;
 697:   
 698:                  alarmList = new List<Alarm>();
 699:   
 700:                  foreach (XElement xe in XDocument.Element("event").Element("alarm").Elements("aid").Elements("alarmList").Elements("alarm"))
 701:                  {
 702:                      alarm = new Alarm();
 703:   
 704:                      alarm.Id = xe.Attribute("id").Value;
 705:                      alarm.Name = xe.Attribute("name").Value;
 706:                      alarm.Severity = (from s in SeverityList where s.Id == xe.Attribute("severity").Value select s).Single();
 707:                      alarm.ServiceEffect = (from s in ServiceEffectList where s.Id == xe.Attribute("serviceEffect").Value select s).Single();
 708:                      alarm.SaveMessage = bool.Parse(xe.Attribute("saveMessage").Value);
 709:                      alarm.Condition = xe.Element("condition").Value;
 710:                      alarm.Resolution = xe.Element("resolution").Value;
 711:   
 712:                      alarmList.Add(alarm);
 713:                  }
 714:   
 715:                  return alarmList;
 716:              }
 717:          }
 718:   
 719:          ////////////////////////////////////////////////////////////////////////////
 720:   
 721:          /// <summary>
 722:          ///
 723:          /// </summary>
 724:          public static string ToString(Ia.Ngn.Cl.Model.Event _event)
 725:          {
 726:              string s;
 727:              StringBuilder sb;
 728:   
 729:              sb = new StringBuilder();
 730:   
 731:              sb.AppendLine("Class: " + _event.Class);
 732:              sb.AppendLine("System: " + _event.System);
 733:              sb.AppendLine("Severity: " + _event.Severity);
 734:              sb.AppendLine("SeverityEffect: " + _event.SeverityEffect);
 735:              sb.AppendLine("Aid: " + _event.Aid);
 736:              sb.AppendLine("Cause: " + _event.Cause);
 737:              sb.AppendLine("Number: " + _event.Number);
 738:              sb.AppendLine("Detail: " + _event.Detail);
 739:              sb.AppendLine("EventTime: " + _event.EventTime);
 740:              sb.AppendLine("NodeTime: " + _event.NodeTime);
 741:              sb.AppendLine("Created: " + _event.Created);
 742:   
 743:              return sb.ToString();
 744:          }
 745:   
 746:          ////////////////////////////////////////////////////////////////////////////
 747:   
 748:          /// <summary>
 749:          ///
 750:          /// </summary>
 751:          public static string ToSimpleTextString(Ia.Ngn.Cl.Model.Event _event)
 752:          {
 753:              string s;
 754:              StringBuilder sb;
 755:   
 756:              sb = new StringBuilder();
 757:   
 758:              //sb.AppendLine("Class: " + _event.Class);
 759:              sb.AppendLine("System: " + _event.System);
 760:              sb.AppendLine("Severity: " + _event.Severity);
 761:              //sb.AppendLine("SeverityEffect: " + _event.SeverityEffect);
 762:              sb.AppendLine("Aid: " + _event.Aid);
 763:              sb.AppendLine("Cause: " + _event.Cause);
 764:              //sb.AppendLine("Number: " + _event.Number);
 765:              sb.AppendLine("Detail: " + _event.Detail);
 766:              sb.AppendLine("EventTime: " + _event.EventTime);
 767:              //sb.AppendLine("NodeTime: " + _event.NodeTime);
 768:              //sb.AppendLine("Created: " + _event.Created);
 769:   
 770:              return sb.ToString();
 771:          }
 772:   
 773:          ////////////////////////////////////////////////////////////////////////////
 774:   
 775:          /// <summary>
 776:          /// 
 777:          /// How to embed and access resources by using Visual C# http://support.microsoft.com/kb/319292/en-us
 778:          /// 
 779:          /// 1. Change the "Build Action" property of your XML file from "Content" to "Embedded Resource".
 780:          /// 2. Add "using System.Reflection".
 781:          /// 3. See sample below.
 782:          /// 
 783:          /// </summary>
 784:   
 785:          private static XDocument XDocument
 786:          {
 787:              get
 788:              {
 789:                  if (xDocument == null)
 790:                  {
 791:                      Assembly _assembly;
 792:                      StreamReader streamReader;
 793:   
 794:                      _assembly = Assembly.GetExecutingAssembly();
 795:                      streamReader = new StreamReader(_assembly.GetManifestResourceStream("Ia.Ngn.Cl.model.data.event.xml"));
 796:   
 797:                      try
 798:                      {
 799:                          if (streamReader.Peek() != -1)
 800:                          {
 801:                              xDocument = System.Xml.Linq.XDocument.Load(streamReader);
 802:                          }
 803:                      }
 804:                      catch (Exception)
 805:                      {
 806:                      }
 807:                      finally
 808:                      {
 809:                      }
 810:                  }
 811:   
 812:                  return xDocument;
 813:              }
 814:          }
 815:   
 816:          ////////////////////////////////////////////////////////////////////////////    
 817:          ////////////////////////////////////////////////////////////////////////////    
 818:      }
 819:   
 820:      ////////////////////////////////////////////////////////////////////////////
 821:      ////////////////////////////////////////////////////////////////////////////   
 822:  }