public static bool GetSetFailTimes(EnsureObject item) { int failedtimes = 0; if (FailTimes.ContainsKey(item.Id)) { failedtimes = FailTimes[item.Id]; } failedtimes += 1; if (failedtimes > 10) { // save for backup. string folder = Kooboo.Data.AppSettings.RootPath; folder = System.IO.Path.Combine(folder, "AppData"); folder = System.IO.Path.Combine(folder, "EnsureLog"); string filename = System.IO.Path.Combine(folder, Guid.NewGuid().ToString() + ".txt"); Lib.Helper.IOHelper.EnsureFileDirectoryExists(filename); System.IO.File.WriteAllText(filename, Lib.Helper.JsonHelper.Serialize(item)); return(true); } else { FailTimes[item.Id] = failedtimes; } return(false); }
public static void Add(IQueueTask item) { EnsureObject obj = new EnsureObject(); obj.ModelType = item.GetType().FullName; obj.Json = Lib.Helper.JsonHelper.Serialize(item); GlobalDb.Ensurance.AddOrUpdate(obj); // add log string log = obj.ModelType + ":\r\n"; log += obj.Json; LoggingIn.Write(log); }