Beispiel #1
0
        public void SerializeInfo()
        {
            Utility.StatusItem _StatusItem = Utility.StatusItem.None;
            this.Serialized_Data = Utility.ConvertObjToRedisValue(this.Data, out _StatusItem);
            this.StatusItem      = _StatusItem;

            this.UpdateSerialized_TTL();    //Update TTL and generate new ttl string.
        }
Beispiel #2
0
        /// <summary>
        /// Convert to string DateTime and TimeStamp.
        /// Calculate new DateTime relative to TimeStamp
        /// </summary>
        /// <param name="ttlSLI"></param>
        /// <param name="ttlABS"></param>
        /// <param name="forceUpdateDtABS"></param>
        /// <returns></returns>
        internal static string TTLSerialize(TimeSpan ttlSLI, TimeSpan ttlABS, DateTime forceUpdateDtABS, Utility.StatusItem statusItem)
        {
            DateTime dtResult  = DateTime.Now.ToUniversalTime().Add(ttlSLI);  //Convert to UTC and add TimeStamp to Sliding Datetime
            string   str_dtSLI = dtResult.ToString("yyMMddTHHmmss");          //Convert to String. For Datetime Format is: yyMMddTHHmmss
            string   str_tsSLI = ttlSLI.TotalSeconds.ToString();              //Convert to String. Fot TimeStamp Format is: hhmmss

            if (ttlSLI == Utility.NO_EXPIRATION)
            {
                str_dtSLI = _No_TTL;
                str_tsSLI = _No_TTL;
            }

            dtResult = DateTime.Now.ToUniversalTime().Add(ttlABS);            //Convert to UTC and add TimeStamp to Absolute Datetime
            string str_dtABS = dtResult.ToString("yyMMddTHHmmss");            //Convert to String. For Datetime Format is: yyMMddTHHmmss
            string str_tsABS = ttlABS.TotalSeconds.ToString();                //Convert to String. Fot TimeStamp Format is: hhmmss

            if (ttlABS == Utility.NO_EXPIRATION)
            {
                str_dtABS = _No_TTL;
                str_tsABS = _No_TTL;
            }

            if (forceUpdateDtABS != DateTime.MaxValue)                          //This check is necessary if update Sliding TTL (call from "Get Function"). Reset Absolute Datetime.
            {
                str_dtABS = forceUpdateDtABS.ToString("yyMMddTHHmmss");
            }

            string strResult = str_dtSLI + "|" + str_tsSLI + "|" + str_dtABS + "|" + str_tsABS + "|" + Convert.ToInt32(statusItem);     //Concatenate string: Sliding DateTime + Sliding TTL + Absolute DateTime + Absolute TTL

            return(strResult);
        }