コード例 #1
0
        private void OnStatusChanged(object sender, StatusEventArgs args)
        {
            Debugger.WriteLine($"Changed status for property {EnumHelper.GetName(args.Tag)}");
            Debugger.WriteLine(
                $"Called maid: {args.CallerMaid.Param.status.first_name} {args.CallerMaid.Param.status.last_name}");

            if (!IsMaidLoaded(args.CallerMaid))
            {
                Debugger.WriteLine(LogLevel.Error, "Maid not in the list! Aborting!");
                return;
            }

            MaidInfo maid = GetMaidInfo(args.CallerMaid);

            if (maid.IsLocked(args.Tag))
            {
                Debugger.WriteLine(LogLevel.Info, "Value locked! Aborting changes...");
                args.BlockAssignment = true;
                return;
            }

            if (SelectedMaid != null && SelectedMaid.Maid != maid.Maid)
            {
                Debugger.WriteLine(LogLevel.Warning, "Selected maids are different!");
                return;
            }

            if (!valueUpdateQueue[currentQueue].ContainsKey(args.Tag))
            {
                Debugger.WriteLine(LogLevel.Info, "Adding to update queue");
                valueUpdateQueue[currentQueue].Add(args.Tag, () => maid.UpdateField(args.Tag));
            }
            else
            {
                Debugger.WriteLine(
                    LogLevel.Warning,
                    $"Already in update queue {currentQueue}! Queue length: {valueUpdateQueue[currentQueue].Count}");
            }
        }