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

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:   
  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:                  Dictionary<string, string> serialToIdListDictionary, di;
 353:   
 354:                  /*
 355:      use Ia_Ngn
 356:      --select distinct System,Class, Aid, Detail from Events where Id > 18900000 and Cause = 'NEWONT'
 357:      --select *from Events where Id > 18000000 and Cause = 'NEWONT' order by Id
 358:      --select max(id) from Events
 359:      -- 1M events is about 3 weeks
 360:      --select * from Events where Id > (select max(id) - 1000000 from Events) and Cause = 'NEWONT' order by Id
 361:      select distinct System, Aid, Cause, Detail from Events where Id > (select max(id) - 1000000 from Events) and Cause = 'NEWONT'
 362:  
 363:       delete from Events where Id < 45564063
 364:  
 365:                  delete events using SQL before one month from today
 366:       */
 367:   
 368:                  serialList = new List<string>();
 369:                  ontIdList = new List<string>();
 370:                  uiList = new List<Ia.Ngn.Cl.Model.Ui.Event>();
 371:   
 372:                  di = Ia.Ngn.Cl.Model.Data.NetworkDesignDocument.OntAccessIdToOntAccessNameDictionary;
 373:   
 374:                  using (var db = new Ia.Ngn.Cl.Model.Ngn())
 375:                  {
 376:                      list = (from e in db.Events where e.Cause == "NEWONT" orderby e.Id descending select e).ToList();
 377:   
 378:                      if (list != null && list.Count > 0)
 379:                      {
 380:                          serialToIdListDictionary = Ia.Ngn.Cl.Model.Data.Nokia.Ont.SerialToIdListDictionary;
 381:   
 382:                          foreach (Ia.Ngn.Cl.Model.Event e in list.OrderByDescending(u => u.Id))
 383:                          {
 384:                              if (!string.IsNullOrEmpty(e.Detail))
 385:                              {
 386:                                  serial = Ia.Cl.Model.Default.Match(e.Detail, "(ALCL.{8})");
 387:   
 388:                                  if (!string.IsNullOrEmpty(serial))
 389:                                  {
 390:                                      if (!serialList.Contains(serial))
 391:                                      {
 392:                                          if (serialToIdListDictionary.ContainsKey(serial))
 393:                                          {
 394:                                              ontId = serialToIdListDictionary[serial];
 395:                                              ontSerial = serial;
 396:   
 397:                                              accessName = di[ontId];
 398:                                          }
 399:                                          else
 400:                                          {
 401:                                              ontId = ontSerial = accessName = string.Empty;
 402:                                          }
 403:   
 404:                                          eventOnt = new Ia.Ngn.Cl.Model.Ui.Event
 405:                                          {
 406:                                              Id = e.Id,
 407:                                              TypeId = e.TypeId,
 408:                                              System = e.System,
 409:                                              Class = e.Class,
 410:                                              Aid = e.Aid,
 411:                                              Cause = e.Cause,
 412:                                              Number = e.Number,
 413:                                              Detail = e.Detail,
 414:                                              Severity = e.Severity,
 415:                                              SeverityEffect = e.SeverityEffect,
 416:                                              EventTime = e.EventTime,
 417:                                              NodeTime = e.NodeTime,
 418:                                              Created = e.Created,
 419:                                              OntId = ontId,
 420:                                              Serial = ontSerial,
 421:                                              AccessName = accessName,
 422:                                          };
 423:   
 424:                                          uiList.Add(eventOnt);
 425:   
 426:                                          serialList.Add(serial);
 427:                                      }
 428:                                      else
 429:                                      {
 430:   
 431:                                      }
 432:                                  }
 433:                              }
 434:                          }
 435:                      }
 436:                      else
 437:                      {
 438:   
 439:                      }
 440:                  }
 441:   
 442:                  /*
 443:                      string s, sql;
 444:                      StringBuilder sb;
 445:                      Hashtable ht, a_ht;
 446:                      DataTable dt, a_dt;
 447:  
 448:                      sb = new StringBuilder(1000);
 449:                      ht = new Hashtable(1000);
 450:                      a_ht = new Hashtable(1000);
 451:  
 452:                      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, 
 453:                                       f.premises_old, f.premises_new, e.node_time, e.event_time, e.created
 454:              FROM            ia_event AS e LEFT OUTER JOIN
 455:                                       ia_field AS f ON e.detail LIKE '%' + f.ont_serial + '%'
 456:              WHERE        (e.cause = 'NEWONT') AND (e.id =
 457:                                           (SELECT        MAX(id) AS max_id
 458:                                             FROM            ia_event AS e2
 459:                                             WHERE        (cause = 'NEWONT') AND (system_id = e.system_id) AND (aid = e.aid) AND (detail = e.detail))) AND (e.severity <> 'CL')
 460:              ORDER BY e.created DESC";
 461:  
 462:                      dt = null; // main.Data.Select(sql);
 463:  
 464:                      if (dt != null && dt.Rows.Count > 1)
 465:                      {
 466:                          // below: now collect all valid ont_position entries and get the last event for them
 467:                          ///gh3
 468:                          sql = "";
 469:  
 470:                          foreach (DataRow r in dt.Rows)
 471:                          {
 472:                              if (r["ont"] != null && r["ont"].ToString().Length > 0)
 473:                              {
 474:                                  s = r["system_id"].ToString() + ":" + r["aid"].ToString().Replace("PON", "ONT") + "-" + r["ont"].ToString();
 475:                                  ht[s] = r["id"].ToString();
 476:                                  sb.Append("e.system_id='" + r["system_id"].ToString() + "' AND " + "e.aid='" + r["aid"].ToString().Replace("PON", "ONT") + "-" + r["ont"].ToString() + "' OR ");
 477:                              }
 478:                          }
 479:  
 480:                          sql = sb.ToString();
 481:  
 482:                          if (sql.Length > 0)
 483:                          {
 484:                              sql = sql.Remove(sql.Length - 4, 4);
 485:  
 486:                              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)))");
 487:  
 488:                              // below: now loop through table and collect cause + severity
 489:                              foreach (DataRow r in a_dt.Rows)
 490:                              {
 491:                                  s = r["system_id"].ToString() + ":" + r["aid"].ToString();
 492:                                  a_ht[ht[s].ToString()] = r["cause"].ToString() + ":" + r["severity"].ToString();
 493:                              }
 494:  
 495:                              // below: now loop through original table and insert last_event
 496:  
 497:                              foreach (DataRow r in dt.Rows)
 498:                              {
 499:                                  s = r["id"].ToString();
 500:                                  if (a_ht.ContainsKey(s)) r["last_event"] = a_ht[s].ToString();
 501:                              }
 502:  
 503:                              gv.DataSource = dt.DefaultView;
 504:                              gv.DataBind();
 505:                          }
 506:                      }
 507:                  }
 508:                       */
 509:   
 510:                  return uiList;
 511:              }
 512:          }
 513:   
 514:          ////////////////////////////////////////////////////////////////////////////
 515:   
 516:          /// <summary>
 517:          ///
 518:          /// </summary>
 519:          public static void DeleteAllEventsBeforeDateTime(DateTime dateTime)
 520:          {
 521:              // see comment on ofn/maitenance/log/event/ams.aspx
 522:   
 523:              using (var db = new Ia.Ngn.Cl.Model.Ngn())
 524:              {
 525:                  if (dateTime > DateTime.MinValue)
 526:                  {
 527:                      db.Database.ExecuteSqlCommand("delete Events where Created < '" + dateTime.ToString("yyyy-MM-dd") + "'");
 528:   
 529:                      /*
 530:  --select top 100 from events where Created 
 531:  
 532:  delete Events where Created < '2018-11-01'
 533:  
 534:  --delete Events where id < (select (max(id) - min(id))/2 + min(id) from Events) 
 535:  --select max(id), min(id),(max(id) - min(id)),(max(id) - min(id))/2 + min(id) from Events
 536:  */
 537:                  }
 538:              }
 539:          }
 540:   
 541:          ////////////////////////////////////////////////////////////////////////////
 542:   
 543:          /// <summary>
 544:          ///
 545:          /// </summary>
 546:          public static List<Severity> SeverityList
 547:          {
 548:              get
 549:              {
 550:                  List<Severity> severityList;
 551:   
 552:                  severityList = new List<Severity>();
 553:   
 554:                  severityList.Add(new Severity("CR", "Critical"));
 555:                  severityList.Add(new Severity("MJ", "Major"));
 556:                  severityList.Add(new Severity("MN", "Minor"));
 557:                  severityList.Add(new Severity("NR", "Normal/not reported"));
 558:                  severityList.Add(new Severity("NA", "Not alarmed"));
 559:                  severityList.Add(new Severity("ND", "Not yet determained"));
 560:                  severityList.Add(new Severity("WA", "Warning"));
 561:                  severityList.Add(new Severity("CL", "Clear"));
 562:   
 563:                  return severityList;
 564:              }
 565:          }
 566:   
 567:          ////////////////////////////////////////////////////////////////////////////
 568:   
 569:          /// <summary>
 570:          ///
 571:          /// </summary>
 572:          public static List<ServiceEffect> ServiceEffectList
 573:          {
 574:              get
 575:              {
 576:                  List<ServiceEffect> serviceEffectList;
 577:   
 578:                  serviceEffectList = new List<ServiceEffect>();
 579:   
 580:                  serviceEffectList.Add(new ServiceEffect("SA", "Service Affecting"));
 581:                  serviceEffectList.Add(new ServiceEffect("NSA", "Not Service Affecting"));
 582:                  serviceEffectList.Add(new ServiceEffect("NR", "Not Reported"));
 583:   
 584:                  return serviceEffectList;
 585:              }
 586:          }
 587:   
 588:          ////////////////////////////////////////////////////////////////////////////
 589:   
 590:          /// <summary>
 591:          ///
 592:          /// </summary>
 593:          public static List<string> ClassList
 594:          {
 595:              get
 596:              {
 597:                  List<string> list;
 598:   
 599:                  list = new List<string>();
 600:   
 601:                  list.Add("BRGPORT");
 602:                  list.Add("PON");
 603:                  list.Add("EQPT");
 604:                  list.Add("ONTPOTS");
 605:                  list.Add("ONTVOIP");
 606:                  list.Add("ONT");
 607:                  list.Add("ONTENET");
 608:                  list.Add("ONTCARD");
 609:                  list.Add("ONTHSI");
 610:                  list.Add("SECACCESS");
 611:   
 612:                  list.Sort();
 613:   
 614:                  return list;
 615:              }
 616:          }
 617:   
 618:          ////////////////////////////////////////////////////////////////////////////
 619:   
 620:          /// <summary>
 621:          ///
 622:          /// </summary>
 623:          public static List<string> CauseList
 624:          {
 625:              get
 626:              {
 627:                  List<string> list;
 628:   
 629:                  list = new List<string>();
 630:   
 631:                  list.Add("LIMSVCMIS");
 632:                  list.Add("MEM");
 633:                  list.Add("SECUMGTACCESS");
 634:                  list.Add("EQPT");
 635:                  list.Add("SWRESET");
 636:                  list.Add("SECUMGTACCESSTCA");
 637:                  list.Add("BDRESETCF");
 638:                  list.Add("VICONFIGNOTIFYFAIL");
 639:                  list.Add("TXFAIL");
 640:                  list.Add("PONLOS");
 641:                  list.Add("SWVER");
 642:                  list.Add("NEWONT");
 643:                  list.Add("VICONFIGHTTPFAIL");
 644:                  list.Add("LOAM");
 645:                  list.Add("SHUTDOWN");
 646:                  list.Add("BDMISSING");
 647:                  list.Add("BATTMISS");
 648:                  list.Add("LOA");
 649:                  list.Add("ACFAIL");
 650:                  list.Add("RTCPSTREAMLOSS");
 651:                  list.Add("POTSSVCMIS");
 652:                  list.Add("INACT");
 653:                  list.Add("SWDLIP");
 654:                  list.Add("PONMEA");
 655:                  list.Add("OMCICOMM");
 656:                  list.Add("SWVERCTLERR");
 657:                  list.Add("VNTWKERR");
 658:                  list.Add("BDRESET");
 659:                  list.Add("ONTMEA");
 660:                  list.Add("LOS");
 661:                  list.Add("VOIPCNFG");
 662:                  list.Add("SWACTFAIL");
 663:                  list.Add("VGATEWAYCOMM");
 664:                  list.Add("SD");
 665:                  list.Add("BDINIT");
 666:                  list.Add("INTRUDER");
 667:                  list.Add("FANALM");
 668:                  list.Add("DUPADDR");
 669:                  list.Add("SWDLFILE");
 670:                  list.Add("VCLIENTSVCMIS");
 671:                  list.Add("DG");
 672:                  list.Add("SF");
 673:                  list.Add("SUF");
 674:                  list.Add("BATTFAIL");
 675:                  list.Add("HITEMP");
 676:                  list.Add("LANSVCMIS");
 677:                  list.Add("VICONFIGSUBFAIL");
 678:                  list.Add("SWDLFAIL");
 679:                  list.Add("EXCEPTOVLD");
 680:                  list.Add("HSISVCMIS");
 681:                  list.Add("LOKS");
 682:                  list.Add("PONCOMMFAIL");
 683:                  list.Add("HITEMPSHUTOFF");
 684:                  list.Add("LIMMEA");
 685:                  list.Add("RDI");
 686:                  list.Add("ONTDISABLED");
 687:                  list.Add("BATTLOW");
 688:                  list.Add("DOW");
 689:   
 690:                  list.Sort();
 691:   
 692:                  return list;
 693:              }
 694:          }
 695:   
 696:          ////////////////////////////////////////////////////////////////////////////
 697:   
 698:          /// <summary>
 699:          ///
 700:          /// </summary>
 701:          public static List<Alarm> AlarmList
 702:          {
 703:              get
 704:              {
 705:                  Alarm alarm;
 706:                  List<Alarm> alarmList;
 707:   
 708:                  alarmList = new List<Alarm>();
 709:   
 710:                  foreach (XElement xe in XDocument.Element("event").Element("alarm").Elements("aid").Elements("alarmList").Elements("alarm"))
 711:                  {
 712:                      alarm = new Alarm();
 713:   
 714:                      alarm.Id = xe.Attribute("id").Value;
 715:                      alarm.Name = xe.Attribute("name").Value;
 716:                      alarm.Severity = (from s in SeverityList where s.Id == xe.Attribute("severity").Value select s).Single();
 717:                      alarm.ServiceEffect = (from s in ServiceEffectList where s.Id == xe.Attribute("serviceEffect").Value select s).Single();
 718:                      alarm.SaveMessage = bool.Parse(xe.Attribute("saveMessage").Value);
 719:                      alarm.Condition = xe.Element("condition").Value;
 720:                      alarm.Resolution = xe.Element("resolution").Value;
 721:   
 722:                      alarmList.Add(alarm);
 723:                  }
 724:   
 725:                  return alarmList;
 726:              }
 727:          }
 728:   
 729:          ////////////////////////////////////////////////////////////////////////////
 730:   
 731:          /// <summary>
 732:          ///
 733:          /// </summary>
 734:          public static string ToString(Ia.Ngn.Cl.Model.Event _event)
 735:          {
 736:              string s;
 737:              StringBuilder sb;
 738:   
 739:              sb = new StringBuilder();
 740:   
 741:              sb.AppendLine("Class: " + _event.Class);
 742:              sb.AppendLine("System: " + _event.System);
 743:              sb.AppendLine("Severity: " + _event.Severity);
 744:              sb.AppendLine("SeverityEffect: " + _event.SeverityEffect);
 745:              sb.AppendLine("Aid: " + _event.Aid);
 746:              sb.AppendLine("Cause: " + _event.Cause);
 747:              sb.AppendLine("Number: " + _event.Number);
 748:              sb.AppendLine("Detail: " + _event.Detail);
 749:              sb.AppendLine("EventTime: " + _event.EventTime);
 750:              sb.AppendLine("NodeTime: " + _event.NodeTime);
 751:              sb.AppendLine("Created: " + _event.Created);
 752:   
 753:              return sb.ToString();
 754:          }
 755:   
 756:          ////////////////////////////////////////////////////////////////////////////
 757:   
 758:          /// <summary>
 759:          ///
 760:          /// </summary>
 761:          public static string ToSimpleTextString(Ia.Ngn.Cl.Model.Event _event)
 762:          {
 763:              string s;
 764:              StringBuilder sb;
 765:   
 766:              sb = new StringBuilder();
 767:   
 768:              //sb.AppendLine("Class: " + _event.Class);
 769:              sb.AppendLine("System: " + _event.System);
 770:              sb.AppendLine("Severity: " + _event.Severity);
 771:              //sb.AppendLine("SeverityEffect: " + _event.SeverityEffect);
 772:              sb.AppendLine("Aid: " + _event.Aid);
 773:              sb.AppendLine("Cause: " + _event.Cause);
 774:              //sb.AppendLine("Number: " + _event.Number);
 775:              sb.AppendLine("Detail: " + _event.Detail);
 776:              sb.AppendLine("EventTime: " + _event.EventTime);
 777:              //sb.AppendLine("NodeTime: " + _event.NodeTime);
 778:              //sb.AppendLine("Created: " + _event.Created);
 779:   
 780:              return sb.ToString();
 781:          }
 782:   
 783:          ////////////////////////////////////////////////////////////////////////////
 784:   
 785:          /// <summary>
 786:          /// 
 787:          /// How to embed and access resources by using Visual C# http://support.microsoft.com/kb/319292/en-us
 788:          /// 
 789:          /// 1. Change the "Build Action" property of your XML file from "Content" to "Embedded Resource".
 790:          /// 2. Add "using System.Reflection".
 791:          /// 3. See sample below.
 792:          /// 
 793:          /// </summary>
 794:   
 795:          private static XDocument XDocument
 796:          {
 797:              get
 798:              {
 799:                  if (xDocument == null)
 800:                  {
 801:                      Assembly _assembly;
 802:                      StreamReader streamReader;
 803:   
 804:                      _assembly = Assembly.GetExecutingAssembly();
 805:                      streamReader = new StreamReader(_assembly.GetManifestResourceStream("Ia.Ngn.Cl.model.data.event.xml"));
 806:   
 807:                      try
 808:                      {
 809:                          if (streamReader.Peek() != -1)
 810:                          {
 811:                              xDocument = System.Xml.Linq.XDocument.Load(streamReader);
 812:                          }
 813:                      }
 814:                      catch (Exception)
 815:                      {
 816:                      }
 817:                      finally
 818:                      {
 819:                      }
 820:                  }
 821:   
 822:                  return xDocument;
 823:              }
 824:          }
 825:   
 826:          ////////////////////////////////////////////////////////////////////////////    
 827:          ////////////////////////////////////////////////////////////////////////////    
 828:      }
 829:   
 830:      ////////////////////////////////////////////////////////////////////////////
 831:      ////////////////////////////////////////////////////////////////////////////   
 832:  }