Esempio n. 1
0
    public logStatement(string statement)
    {
        IpAddress      = ipAddress.Create(Utils.GetIdentifier(ref statement));
        UserIdentifier = userIdentifier.Create(Utils.GetIdentifier(ref statement));
        User           = user.Create(Utils.GetIdentifier(ref statement));

        Utils.Trim(ref statement);
        if (statement[0] == '[')
        {
            statement = statement.Substring(1);
        }
        else
        {
            throw new LogParseException("Cannot read timestamp, expecting \'[\', but could not find");
        }
        Timestamp = timestamp.Create(Utils.GetIdentifier(ref statement, ']'));

        Utils.Trim(ref statement);
        if (statement[0] == '\"')
        {
            statement = statement.Substring(1);
        }
        else
        {
            throw new LogParseException("Cannot read url, expecting \'\"\', but could not find");
        }

        Url = url.Create(Utils.GetIdentifier(ref statement, '\"'));

        Response = Utils.GetNumber(ref statement, "Response");
        Size     = Utils.GetNumber(ref statement, "Size");
    }
Esempio n. 2
0
    public int Check(timestamp Timestamp, TimeSpan TimeWindow)
    {
        if (!Timestamp.Valid())
        {
            return(-1);
        }
        DateTime current = Timestamp.GetValue();

        while ((queue.Count > 1) && (TimeWindow > current.Subtract(queue.Peek())))
        {
            queue.Dequeue();
        }

        return(queue.Count);
    }
Esempio n. 3
0
    public void Update(url Url, timestamp Timestamp)
    {
        if (Url.Valid())
        {
            Registry.Increment(Url.GetSection());

            string outKey = KeyCache.Put(Url.GetSection());
            if (outKey != null)
            {
                Registry.Remove(outKey);
            }
        }

        if (Timestamp.Valid())
        {
            queue.Enqueue(Timestamp.GetValue());
        }
    }
Esempio n. 4
0
 /**
  * Return the relative date in relation to today. Returns something like "last hour" or "two month ago"
  *
  * @param int timestamp unix timestamp
  * @param boolean dateOnly
  * @return string human readable interpretation of the timestamp
  * @since 8.0.0
  * @suppress PhanDeprecatedFunction
  * @suppress PhanTypeMismatchArgument
  */
 public static function relative_modified_date(timestamp, dateOnly = false)
 {
     return(\ relative_modified_date(timestamp, null, dateOnly));
 }
 new ChatMessage(content : content, timestamp : DateTime.Now, visible : visible, sanitize : sanitize, sender : sender);
Esempio n. 6
0
        /// <summary>
        /// Read history info - interval, countdown etc
        /// </summary>
        /// <param name="interval">Current interval in minutes</param>
        /// <param name="countdown">Countdown to next measurement</param>
        /// <param name="timelast">Time/Date for last measurement</param>
        /// <param name="numrecords">number of valid records</param>
        /// <returns>address of last written record</returns>
        private int ws2300ReadHistoryDetails(out int interval, out int countdown, out timestamp timelast, out int numrecords)
        {
            byte[] data    = new byte[20];
            byte[] command = new byte[25];
            int    address = 0x6B2;
            int    bytes   = 10;

            timestamp loctimelast = new timestamp();

            if (ws2300ReadWithRetries(address, bytes, data, command) != bytes)
            {
                interval   = 0;
                countdown  = 0;
                timelast   = new timestamp();
                numrecords = 0;
                return(ERROR);
            }

            rainref = ws2300RainTotal();

            if (rainref < 0)
            {
                cumulus.LogMessage("WS2300: Unable to read current rain total");
                interval   = 0;
                countdown  = 0;
                timelast   = new timestamp();
                numrecords = 0;
                return(-1000);
            }
            else
            {
                cumulus.LogMessage("WS2300: current rain total from station = " + rainref);
                raincountref = ws2300RainHistoryRef();

                if (raincountref < 0)
                {
                    cumulus.LogMessage("WS2300: Unable to read current rain counter");
                    interval   = 0;
                    countdown  = 0;
                    timelast   = new timestamp();
                    numrecords = 0;
                    return(-1000);
                }
                else
                {
                    cumulus.LogMessage("WS2300: current rain counter from station = " + raincountref);

                    interval           = (data[1] & 0xF) * 256 + data[0] + 1;
                    countdown          = data[2] * 16 + (data[1] >> 4) + 1;
                    loctimelast.minute = ((data[3] >> 4) * 10) + (data[3] & 0xF);
                    loctimelast.hour   = ((data[4] >> 4) * 10) + (data[4] & 0xF);
                    loctimelast.day    = ((data[5] >> 4) * 10) + (data[5] & 0xF);
                    loctimelast.month  = ((data[6] >> 4) * 10) + (data[6] & 0xF);
                    loctimelast.year   = 2000 + ((data[7] >> 4) * 10) + (data[7] & 0xF);
                    numrecords         = data[9];

                    timelast = loctimelast;
                    return(data[8]);
                }
            }
        }
Esempio n. 7
0
 private DateTime ws2300TimestampToDateTime(timestamp ts)
 {
     return(new DateTime(ts.year, ts.month, ts.day, ts.hour, ts.minute, 0));
 }
Esempio n. 8
0
 var(timestamp, restOfLine) = lines[0];
 CallAndRestore(transactionProcessor, blockHeader, timestamp, transaction, treatBlockHeaderAsParentBlock, tracer);