public SystemEventLog UpdateSystemEventLog(SystemEventLog entity)
 {
     return _iSystemEventLogRepository.UpdateSystemEventLog(entity);
 }
 public bool InsertSystemEventLog(string title, string description, Core.Enums.EventCodes code)
 {
     SystemEventLog evlog = new SystemEventLog();
      evlog.DateOccured = DateTime.UtcNow;
      evlog.Description = description;
      evlog.EventCode = (int)code;
      if (!string.IsNullOrEmpty(ConfigurationManager.AppSettings["SystemProcess"]))
      {
          var servicename = ConfigurationManager.AppSettings["SystemProcess"];
          evlog.Title = title + "- " + servicename;
      }
      else
      {
          evlog.Title = title;
      }
      var result = _iSystemEventLogRepository.InsertSystemEventLog(evlog);
      if (result != null && result.EventLogId > 0)
          return true;
      else return false;
 }
        public DataTransfer<PutOutput> Update(PutInput Input)
        {
            DataTransfer<PutOutput> transer = new DataTransfer<PutOutput>();

            SystemEventLog systemeventloginput = new SystemEventLog();
            SystemEventLog systemeventlogoutput = new SystemEventLog();
            PutOutput output = new PutOutput();
            systemeventloginput.CopyFrom(Input);
            SystemEventLog systemeventlog = _iSystemEventLogRepository.GetSystemEventLog(systemeventloginput.EventLogId);
            if (systemeventlog != null)
            {
                systemeventlogoutput = _iSystemEventLogRepository.UpdateSystemEventLog(systemeventloginput);
                if (systemeventlogoutput != null)
                {
                    output.CopyFrom(systemeventlogoutput);
                    transer.IsSuccess = true;
                    transer.Data = output;
                }
                else
                {
                    transer.IsSuccess = false;
                    transer.Errors = new string[1];
                    transer.Errors[0] = "Error: Could not update.";
                }
            }
            else
            {
                transer.IsSuccess = false;
                transer.Errors = new string[1];
                transer.Errors[0] = "Error: Record not found.";
            }

            return transer;
        }
Ejemplo n.º 4
0
 public SystemEventLog UpdateSystemEventLog(SystemEventLog entity)
 {
     return(_iSystemEventLogRepository.UpdateSystemEventLog(entity));
 }
 public SystemEventLog InsertSystemEventLog(SystemEventLog entity)
 {
     return _iSystemEventLogRepository.InsertSystemEventLog(entity);
 }
Ejemplo n.º 6
0
        /// <summary>
        /// Recursively retrieves System Event Log entries.
        /// </summary>
        public virtual SystemEventLog GetSel()
        {
            // return value. create string collection to hold system event strings.
            SystemEventLog messageCollection = new SystemEventLog(0x00);

            // Default Record Off Set
            byte offSet = 0x00;

            // limit number of records to retrive
            ushort RecordCount = 0;

            // limit number of records to retrive
            ushort RecordLimit = 350;

            // system event log entry point
            ushort recordId = 0;

            // system event log record reserve (used for partial retrieve)
            ushort reserveId = 0;

            // signal last system event record (aborts event log Loop)
            ushort lastRecordId = 65535;

            // system event log record Id and raw payload collection
            IpmiSelCollection responseCollection = new IpmiSelCollection();

            // retrieve all records while connected by recursively calling the Sel entry command
            while (recordId != lastRecordId || RecordCount >= RecordLimit)
            {
                // get the SEL record
                SelEntryResponse response = (SelEntryResponse)this.IpmiSendReceive(
                    new SelEntryRequest(reserveId, recordId, offSet), typeof(SelEntryResponse));

                // reset the main class error code.
                messageCollection.CompletionCode = response.CompletionCode;

                if (response.CompletionCode == 0x00)
                {
                    // add the record to the collection
                    responseCollection.Add(response);

                    // update the record Id (signals loop exit)
                    recordId = BitConverter.ToUInt16(response.NextRecordId, 0);
                }
                else
                {
                    // add the errored record to the collection
                    responseCollection.Add(response);
                    // break the loop on error.
                    break;
                }

                RecordCount++;
            }

            // check for valid sel event messages before processing
            if (responseCollection.Count > 0)
            {
                foreach (SelEntryResponse response in responseCollection)
                {
                    SystemEventLogMessage message = new SystemEventLogMessage(response.CompletionCode);

                    // if the response was not an error cast it.
                    if (response.CompletionCode == 0x00)
                    {
                        // bytes 0-2 = Record Id
                        ushort recordNo = BitConverter.ToUInt16(response.SelEntry, 0);

                        // sel record type
                        byte recordType = response.SelEntry[2];

                        // byte array for message data
                        byte[] messageData = new byte[13];

                        // copy message data in message data array
                        Buffer.BlockCopy(response.SelEntry, 3, messageData, 0, (response.SelEntry.Length - 3));

                        // IPMI SPEC: 31.6.1  SEL Record Type Ranges
                        if (recordType >= 0x00 && recordType <= 0xBF)
                        {
                            // Standard Range. 0x02 "System Event". (Spec declares 0x02.  TODO: Monitor the range here)
                            message.EventFormat = EventMessageFormat.SystemEvent;

                            // Format Standard SEL record
                            SelSupport.StandardSelFormat(ref message, messageData);

                            message.EventMessage = ExtractSystemEventRecordMessage(message.RawSensorType,
                                                                                   message.EventTypeCode, message.RawPayload);
                        }
                        else if ((recordType >= 0xC0) && (recordType <= 0xDF))
                        {
                            // Time Stamped OEM. (override type to reduce string repetition in resource file)
                            message.EventFormat = EventMessageFormat.OemTimeStamped;

                            // Format "TimeStamped OEM" SEL record
                            SelSupport.TimeStampedOEMSelFormat(ref message, messageData);

                            message.EventMessage = ExtractOemTimestampedEventMessage(message.RawPayload);
                        }
                        else if ((recordType >= 0xE0) && (recordType <= 0xFF))
                        {
                            // Non TimeStamped OEM. (override type to reduce string repetition in resource file)
                            message.EventFormat = EventMessageFormat.OemNonTimeStamped;

                            // Format "Non TimeStamped OEM" SEL record
                            SelSupport.NonTimestampedOemSelFormat(ref message, messageData);

                            message.EventMessage = ExtractOemNonTimestampedEventMessage(message.RawPayload);
                        }

                        // add message to the collection
                        messageCollection.EventLog.Add(message);
                    }
                }
            }

            return(messageCollection);
        }
 public virtual SystemEventLog DeleteSystemEventLog(SystemEventLog entity)
 {
     this.DeleteSystemEventLog(entity.EventLogId);
     return entity;
 }
 public virtual SystemEventLog UpdateSystemEventLog(SystemEventLog entity)
 {
     if (entity.IsTransient()) return entity;
     SystemEventLog other = GetSystemEventLog(entity.EventLogId);
     if (entity.Equals(other)) return entity;
     string sql=@"Update SystemEventLog set  [EventCode]=@EventCode
                     , [Title]=@Title
                     , [Description]=@Description
                     , [DateOccured]=@DateOccured
                     , [ElmahErrorID]=@ElmahErrorID
                     , [Source]=@Source
                      where EventLogID=@EventLogID";
     SqlParameter[] parameterArray=new SqlParameter[]{
              new SqlParameter("@EventCode",entity.EventCode ?? (object)DBNull.Value)
             , new SqlParameter("@Title",entity.Title ?? (object)DBNull.Value)
             , new SqlParameter("@Description",entity.Description ?? (object)DBNull.Value)
             , new SqlParameter("@DateOccured",entity.DateOccured)
             , new SqlParameter("@ElmahErrorID",entity.ElmahErrorId ?? (object)DBNull.Value)
             , new SqlParameter("@Source",entity.Source ?? (object)DBNull.Value)
             , new SqlParameter("@EventLogID",entity.EventLogId)};
     SqlHelper.ExecuteNonQuery(this.ConnectionString,CommandType.Text,sql,parameterArray);
     return GetSystemEventLog(entity.EventLogId);
 }
 public virtual SystemEventLog SystemEventLogFromDataRow(DataRow dr)
 {
     if(dr==null) return null;
     SystemEventLog entity=new SystemEventLog();
     if (dr.Table.Columns.Contains("EventLogID"))
     {
     entity.EventLogId = (System.Int32)dr["EventLogID"];
     }
     if (dr.Table.Columns.Contains("EventCode"))
     {
     entity.EventCode = dr["EventCode"]==DBNull.Value?(System.Int32?)null:(System.Int32?)dr["EventCode"];
     }
     if (dr.Table.Columns.Contains("Title"))
     {
     entity.Title = dr["Title"].ToString();
     }
     if (dr.Table.Columns.Contains("Description"))
     {
     entity.Description = dr["Description"].ToString();
     }
     if (dr.Table.Columns.Contains("DateOccured"))
     {
     entity.DateOccured = (System.DateTime)dr["DateOccured"];
     }
     if (dr.Table.Columns.Contains("ElmahErrorID"))
     {
     entity.ElmahErrorId = dr["ElmahErrorID"]==DBNull.Value?(System.Guid?)null:(System.Guid?)dr["ElmahErrorID"];
     }
     if (dr.Table.Columns.Contains("Source"))
     {
     entity.Source = dr["Source"].ToString();
     }
     return entity;
 }
 public virtual SystemEventLog InsertSystemEventLog(SystemEventLog entity)
 {
     SystemEventLog other=new SystemEventLog();
     other = entity;
     if(entity.IsTransient())
     {
         string sql=@"Insert into SystemEventLog ( [EventCode]
         ,[Title]
         ,[Description]
         ,[DateOccured]
         ,[ElmahErrorID]
         ,[Source] )
         Values
         ( @EventCode
         , @Title
         , @Description
         , @DateOccured
         , @ElmahErrorID
         , @Source );
         Select scope_identity()";
         SqlParameter[] parameterArray=new SqlParameter[]{
              new SqlParameter("@EventCode",entity.EventCode ?? (object)DBNull.Value)
             , new SqlParameter("@Title",entity.Title ?? (object)DBNull.Value)
             , new SqlParameter("@Description",entity.Description ?? (object)DBNull.Value)
             , new SqlParameter("@DateOccured",entity.DateOccured)
             , new SqlParameter("@ElmahErrorID",entity.ElmahErrorId ?? (object)DBNull.Value)
             , new SqlParameter("@Source",entity.Source ?? (object)DBNull.Value)};
         var identity=SqlHelper.ExecuteScalar(this.ConnectionString,CommandType.Text,sql,parameterArray);
         if(identity==DBNull.Value) throw new DataException("Identity column was null as a result of the insert operation.");
         return GetSystemEventLog(Convert.ToInt32(identity));
     }
     return entity;
 }