When developing web applications, interactive communication with the user is often necessary in the process of performing some actions. Web ERP-systems, in turn, impose on such communication rather specific requirements. After commissioning several variants of such systems, I found a method that seemed to me the most acceptable. Now I want to share my solution to the problem of interactive work with the user when performing actions on the server.var = (); (.()) { (“ , ?”); } (); 
public class HelloNewWorldOrder { // , Guid guid = new Guid("5FFD6DB4-1201-44BF-9DE0-DC199AC004D9"); public void KillAllHumans(Human[] humans) { foreach (var human in humans) { if (human.Name == Context.Current.User.Name) { // ExceptionHelper.Interactive(guid, " . ?"); } human.Kill(); } } } 
public static void Interactive(Guid id, string message) { // var key = RequestHelper.GetRequestId(); var exists = Query.All<InteractiveException>() .Any(r => r.RequestId == key && r.ExceptionId == id); if (exists) { return; } throw new InteractiveException(message, id, key); } /// <summary> /// /// </summary> [Icon(ExtIcon.Accept)] public class OrderCompleteAction : IAction<IFormContext<Order>> { /// <summary> /// 1 /// </summary> private Guid e1 = new Guid("84099696-2225-41F9-AF54-0BE66367CEAA"); /// <summary> /// 1 /// </summary> private Guid e2 = new Guid("26142EDB-3DC8-4B00-920F-FA33FC3ADF40"); /// <summary> /// /// </summary> /// <param name="context"> </param> public void Execute(IFormContext<Order> context) { Assert.That(context.Item, Is.Not.Null, " , !"); var cpus = context.Item.Items.Select(m => m.Linked) .OfType<Cpu>().Select(c => c.SocketType.SysName).ToHashSet(); var mbs = context.Item.Items.Select(m => m.Linked) .OfType<MotherBoard>().Select(c => c.SocketType.SysName).ToHashSet(); var coolers = context.Item.Items.Select(m => m.Linked) .OfType<Cooler>().SelectMany(c => c.Sockets.Select(m => m.Linked.SysName)).ToHashSet(); if (!cpus.IsSubsetOf(coolers)) { ExceptionHelper.Interactive(e1, " ."); } if (!cpus.IsSubsetOf(mbs)) { ExceptionHelper.Interactive(e2, " . ."); } context.Item.Status = Status.BuiltInStatuses.Work.ToEntity<Status>(); context.ShowMsgBox(" ."); } } Source: https://habr.com/ru/post/142897/
All Articles