public static void RemovePlan(ZeroPlan plan) { if (Plans.TryGetValue(plan.plan_id, out var old)) { Plans.Remove(plan.plan_id); plan.plan_state = plan_message_state.remove; WebSocketNotify.Publish("plan_notify", "remove", JsonConvert.SerializeObject(plan)); } }
public static void SyncPlan(ZeroPlan plan) { if (Plans.ContainsKey(plan.plan_id)) { Plans[plan.plan_id] = plan; } else { Plans.Add(plan.plan_id, plan); } WebSocketNotify.Publish("plan_notify", "add", JsonConvert.SerializeObject(plan)); }
public static void UpdatePlan(ZeroPlan plan) { if (Plans.TryGetValue(plan.plan_id, out var old)) { old.exec_time = plan.exec_time; old.exec_state = plan.exec_state; old.plan_state = plan.plan_state; old.plan_time = plan.plan_time; old.real_repet = plan.real_repet; old.skip_set = plan.skip_set; old.skip_num = plan.skip_num; WebSocketNotify.Publish("plan_notify", "update", JsonConvert.SerializeObject(plan)); } }
public static void OnPlanEvent(ZeroNetEventType eventType, ZeroPlan plan) { switch (eventType) { case ZeroNetEventType.PlanAdd: SyncPlan(plan); break; case ZeroNetEventType.PlanRemove: RemovePlan(plan); break; default: UpdatePlan(plan); break; } }