Example #1
0
        public async Task <AffairEventDto> InsertTempArticle(string style, int affairId, List <RouteArticleCDto> articles, int depotId, string routeWorker)
        {
            string desc = null;

            foreach (var a in articles)
            {
                desc += a.DisplayText + ',';
            }

            var entity = new AffairEvent();

            entity.AffairId    = affairId;
            entity.EventTime   = DateTime.Now;
            entity.Name        = style;
            entity.Description = desc;
            if (depotId > 0)
            {
                entity.Issurer = WorkManager.GetDepot(depotId).Name + routeWorker;
            }
            else
            {
                entity.Issurer = routeWorker;
            }

            await _eventRepository.InsertAsync(entity);

            CurrentUnitOfWork.SaveChanges();
            return(ObjectMapper.Map <AffairEventDto>(entity));
        }
Example #2
0
        public async Task <AffairEventDto> InsertEvent(int affairId, string name, string desc, string issurer)
        {
            var entity = new AffairEvent();

            entity.AffairId    = affairId;
            entity.EventTime   = DateTime.Now;
            entity.Name        = "监控";
            entity.Description = desc;
            entity.Issurer     = issurer;

            await _eventRepository.InsertAsync(entity);

            CurrentUnitOfWork.SaveChanges();
            return(ObjectMapper.Map <AffairEventDto>(entity));
        }
Example #3
0
        public async Task Back(int id, bool finger)
        {
            int workerId = await GetCurrentUserWorkerIdAsync();

            workerId = WorkManager.GetCaptainOrAgentId(workerId);     // Agent

            var affair = _affairRepository.Get(id);

            affair.Status = "安排";
            await _affairRepository.UpdateAsync(affair);

            // for affairEvent
            var    worker = WorkManager.GetWorker(workerId);
            string issuer = string.Format("{0} {1}", worker.Cn, worker.Name);
            var    ae     = new AffairEvent()
            {
                AffairId = affair.Id, EventTime = DateTime.Now, Name = "回退任务", Description = finger?"指纹":"密码", Issurer = issuer
            };
            await _eventRepository.InsertAsync(ae);
        }
Example #4
0
        public async Task <(string, int)> Activate(List <int> ids, bool finger)
        {
            int workerId = await GetCurrentUserWorkerIdAsync();

            workerId = WorkManager.GetCaptainOrAgentId(workerId);     // Agent

            int count = 0;

            foreach (int id in ids)
            {
                Affair affair = _affairRepository.Get(id);
                if (affair.Status != "安排")
                {
                    continue;                                 // Skip
                }
                var reason = affair.CarryoutDate > DateTime.Now.Date ? null : CanActivateAffair(affair);
                if (reason != null)
                {
                    var wp = WorkManager.GetWorkplace(affair.WorkplaceId);
                    return($"{wp.Name}因({reason})不能激活", count);
                }
                affair.Status = "激活";
                await _affairRepository.UpdateAsync(affair);

                // for affairEvent
                var    worker = WorkManager.GetWorker(workerId);
                string issuer = string.Format("{0} {1}", worker.Cn, worker.Name);
                var    ae     = new AffairEvent()
                {
                    AffairId = affair.Id, EventTime = DateTime.Now, Name = "激活任务", Description = finger?"指纹":"密码", Issurer = issuer
                };
                await _eventRepository.InsertAsync(ae);

                count++;
            }
            return(null, count);
        }