コード例 #1
0
        private static void ForceCreateRecord(string typeKey)
        {
            var record = new ExecuteRecord
            {
                TypeKey         = typeKey,
                LastExecuteTime = DateTime.Now
            };

            WriteRecordInteranl(record);
        }
コード例 #2
0
        private static void WriteRecord(ExecuteDetail detail)
        {
            var record = new ExecuteRecord
            {
                TypeKey         = detail.TypeKey,
                LastExecuteTime = detail.End
            };

            WriteRecordInteranl(record);
        }
コード例 #3
0
 private static void WriteRecordInteranl(ExecuteRecord record)
 {
     try
     {
         var fileName = GetRecordFileName(record.TypeKey);
         File.WriteAllText(fileName, SerializationUtils.XmlSerialize(record));
     }
     catch (Exception ex)
     {
         ExceptionLog(string.Format("WriteRecord {0}", record.TypeKey), ex);
     }
 }
コード例 #4
0
        /// <summary>
        /// </summary>
        /// <param name="typeKey"></param>
        /// <param name="record"></param>
        internal static bool TryReadRecord(string typeKey, out ExecuteRecord record)
        {
            record = null;
            var fileName = GetRecordFileName(typeKey);

            try
            {
                if (File.Exists(fileName))
                {
                    record = SerializationUtils.XmlDeserializeFromFile <ExecuteRecord>(fileName);
                    return(true);
                }
            }
            catch (Exception ex)
            {
                ExceptionLog(string.Format("TryReadRecord PluginExecuteRecord {0}", typeKey), ex);
            }
            //如果没有找到执行记录
            //则将创建执行记录设置为当前时间
            ForceCreateRecord(typeKey);
            return(false);
        }