|
@@ -103,6 +103,16 @@ namespace InABox.Core
|
|
|
/// <param name="model"></param>
|
|
|
public abstract void AfterPost(IDataModel<TPostable> model);
|
|
|
|
|
|
+ private static void SetFailed(IList<TPostable> entities)
|
|
|
+ {
|
|
|
+ foreach (var post in entities)
|
|
|
+ {
|
|
|
+ post.PostedStatus = PostedStatus.PostFailed;
|
|
|
+ post.PostedNote = "Post failed.";
|
|
|
+ }
|
|
|
+ new Client<TPostable>().Save(entities, "Post failed by user.");
|
|
|
+ }
|
|
|
+
|
|
|
public bool Process(IDataModel<TPostable> model)
|
|
|
{
|
|
|
if (!BeforePost(model))
|
|
@@ -144,26 +154,22 @@ namespace InABox.Core
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
- foreach (var post in entities)
|
|
|
- {
|
|
|
- post.PostedStatus = PostedStatus.PostFailed;
|
|
|
- post.PostedNote = "Post failed.";
|
|
|
- }
|
|
|
- new Client<TPostable>().Save(entities, "Post failed by user.");
|
|
|
+ SetFailed(entities);
|
|
|
}
|
|
|
return success;
|
|
|
}
|
|
|
+ catch (PostCancelledException)
|
|
|
+ {
|
|
|
+ var entities = data.ToObjects<TPostable>().ToList();
|
|
|
+ SetFailed(entities);
|
|
|
+ throw;
|
|
|
+ }
|
|
|
catch(Exception e)
|
|
|
{
|
|
|
Logger.Send(LogType.Error, "", $"Post Failed: {CoreUtils.FormatException(e)}");
|
|
|
|
|
|
var entities = data.ToObjects<TPostable>().ToList();
|
|
|
- foreach (var post in entities)
|
|
|
- {
|
|
|
- post.PostedStatus = PostedStatus.PostFailed;
|
|
|
- post.PostedNote = e.Message;
|
|
|
- }
|
|
|
- new Client<TPostable>().Save(entities, "Post failed by user.");
|
|
|
+ SetFailed(entities);
|
|
|
throw;
|
|
|
}
|
|
|
}
|