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

Integrated Applications Programming Company

Skip Navigation LinksHome » Code Library » Event

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

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

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