using Aitex.Core.RT.DataCenter; using Aitex.Core.RT.OperationCenter; using Aitex.Core.Util; using DocumentFormat.OpenXml.Vml.Office; using MECF.Framework.Common.OperationCenter; using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading; using System.Threading.Tasks; public class RecipeLockManager : Singleton { private bool _isLocked; private bool IsLocked { get { return _isLocked; } set { locktimer?.Dispose(); _isLocked = value; if (!value) return; locktimer = new Timer(LockCallBack, null, 12000, 10000); } } private Timer locktimer; private bool _isInit = false; void LockCallBack(object state) { this.IsLocked = false; } public void Initialize() { if (this._isInit) return; try { DATA.Subscribe("RecipeEditLock", () => this.IsLocked, SubscriptionAttribute.FLAG.IgnoreSaveDB); OP.Subscribe($"RecipeEditLock", LockCallBack); this._isInit = true; } catch { } } private bool LockCallBack(out string reason, int time, object[] param) { reason = string.Empty; if (param.Length >= 1 && param[0] is bool isLocked) this.IsLocked = isLocked; return true; } }