Beispiel #1
0
 /// <summary>
 /// 开始执行事件
 /// </summary>
 public void Run()
 {
     if (AffairEvent != null)
     {
         AffairEvent.Invoke();
     }
 }
Beispiel #2
0
        public (bool, string) AskOpenDoor(int depotId, int affairId, int doorId, int[] workers, int taskId, bool waiting = false)
        {
            // judge workplace is vault
            var wp = _workplaceCache[doorId];

            if (string.IsNullOrEmpty(wp.AskOpenStyle))
            {
                return(false, "不需要申请开门");
            }
            if (wp.AskOpenStyle == "线路")
            {
                return(false, "已设置为线路任务方式开门");
            }
            var isVault = wp.Name.Contains("金库");

            var affair = _affairCache.GetAffair(DateTime.Now.Date, depotId, affairId);

            // scan affair workers
            foreach (AffairWorkerCacheItem aw in affair.Workers)
            {
                if (aw.CheckoutTime.HasValue)
                {
                    continue;
                }
                // judge this worker VaultDuty.
                var duties = _workRoleCache[aw.WorkRoleId].Duties;
                var VD     = !string.IsNullOrEmpty(duties) && duties.Contains("金库");

                if (isVault && VD && !workers.Contains(aw.WorkerId))
                {
                    return(false, "金库门需要全部相关人员确认");
                }
                if (isVault && !VD && workers.Contains(aw.WorkerId))
                {
                    return(false, "申请中有非金库职责人员");
                }

                // if checkin
                if (workers.Contains(aw.WorkerId) && NeedCheckin(aw.CheckinTime))
                {
                    return(false, "需要先验入");
                }

                if (workers.Contains(aw.WorkerId))
                {
                    SetLastAskDoorTime(affair, aw);
                }
            }

            if (isVault)
            {
                string remark = null;
                if (taskId != 0)
                {
                    AffairEvent e = new AffairEvent();
                    e.AffairId  = affairId;
                    e.Name      = "金库子任务开门";
                    e.EventTime = DateTime.Now;
                    e.Issurer   = GetWorkerString(workers);
                    var task = _affairTaskRepository.Get(taskId);
                    e.Description = task.Content;
                    _affairEventRepository.Insert(e);
                    remark = $"金库子任务({task.Content})";
                }
                SetAskDoorRecord(doorId, affairId, workers, waiting, remark);
                if (!waiting)
                {
                    return(true, "你的金库开门申请已发往监控中心");
                }
            }
            else
            {
                SetAskDoorRecord(doorId, affairId, workers, waiting);
                if (!waiting)
                {
                    return(true, "你的申请已发往监控中心");
                }
            }

            return(true, "请去门口用手机触发申请");
        }