| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566 |
- 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<RecipeLockManager>
- {
- 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;
- }
- }
|