public IActionResult AddHistory(HistoryDto historyDto)
        {
            var history = _mapper.Map <History>(historyDto);

            _historyService.Add(history);
            return(Ok());
        }
示例#2
0
        public void Record(HistoryDto model)
        {
            // 紀錄取得點數
            var record = new History()
            {
                HistoryId    = Guid.Parse(model.HistoryId),
                UserId       = Guid.Parse(model.UserId),
                DateTime     = DateTime.Parse(model.Time),
                CategoryId   = model.CategoryId,
                PointChanged = model.PointsChange
            };

            _history.Create(record);

            // 增加點數
            var user      = _users.GetAll2().FirstOrDefault(x => x.UserId.ToString() == model.UserId);
            var getpoints = _category.GetAll2().FirstOrDefault(x => x.CategoryId == model.CategoryId).Points;

            user.Points = user.Points + getpoints;
            _users.Update(user);

            try
            {
                _history.SaveContext();
                _users.SaveContext();
            }
            catch (Exception ex)
            {
                Debug.WriteLine(ex);
            }
        }
示例#3
0
 private void AssertHistory(History expected, HistoryDto actual)
 {
     Assert.AreEqual(expected.Id, actual.Id);
     Assert.AreEqual(expected.Description, actual.Description);
     Assert.AreEqual(expected.EventType, actual.EventType);
     Assert.AreEqual(expected.CreatedById, actual.CreatedBy.Id);
     Assert.AreEqual(expected.CreatedAtUtc, actual.CreatedAtUtc);
 }
        public IActionResult UpdateHistory(HistoryDto historyDto, [FromRoute] int id)
        {
            var history = _mapper.Map <History>(historyDto);

            history.Id = id;
            _historyService.Update(history);
            return(Ok());
        }
        public static HistoryModel ToHistoryModel(this IMapper mapper, HistoryDto historyDto)
        {
            var historyModel = mapper.Map <HistoryDto, HistoryModel>(historyDto);

            historyModel.ResultKindAwayTeam = GetAwayTeamResultByScore(historyModel.GoalsHomeTeam, historyModel.GoalsAwayTeam);
            historyModel.ResultKindHomeTeam = GetHomeTeamResultByScore(historyModel.GoalsHomeTeam, historyModel.GoalsAwayTeam);

            return(historyModel);
        }
        public IActionResult Index(string account)
        {
            HistoryDto history           = new HistoryDto(account);
            var        historyExtranctor = this.ServiceProvider.GetService <IHistoryExtractor>();
            NodeData   nodeData          = this.Settings.Value;

            foreach (var nodeAddress in nodeData.Url)
            {
                List <Transaction> transactions = new List <Transaction>();
                bool success = false;

                NodeInfo nodeInfo = new NodeInfo()
                {
                    UrlAddress       = nodeAddress + nodeData.Endpoints.GetBlocks,
                    MaxBlocksInQuery = nodeData.MaxBlocksInQuery,
                    StartingPage     = nodeData.StartingPage
                };

                (transactions, success) = historyExtranctor.GetTransactions(account, nodeInfo.UrlAddress, nodeInfo.StartingPage, nodeInfo.MaxBlocksInQuery);

                if (success)
                {
                    foreach (var tran in transactions)
                    {
                        if (!history.Transactions.Contains(tran))
                        {
                            history.Transactions.Add(tran);
                        }
                    }
                }

                nodeInfo.UrlAddress = nodeAddress + nodeData.Endpoints.GetPendingTransactions;

                (transactions, success) = historyExtranctor.GetPendingTransactions(account, nodeInfo.UrlAddress);

                if (success)
                {
                    foreach (var tran in transactions)
                    {
                        if (!history.Transactions.Contains(tran))
                        {
                            history.Transactions.Add(tran);
                        }
                    }
                }
            }

            if (history.Transactions.Count == 0)
            {
                history.Description = "The wallet doesn't have any transactions yet!";
            }

            return(View(history));
        }
        protected async Task CreateHistoryAsync(TOut element)
        {
            var history = new HistoryDto
            {
                EntityName      = typeof(TIn).Name,
                EntityId        = element.Id.ToString(),
                IsEntityDeleted = false,
                CreatedAt       = DateTime.UtcNow,
                Differences     = GetCreatedDifferenceValueList(element)
            };

            await historyService.CreateAsync(history);
        }
示例#8
0
        public IActionResult Get(Guid entityId)
        {
            try
            {
                HistoryDto dto = _historyService.Get(entityId);

                return(Json(dto));
            }
            catch (Exception e)
            {
                Log.Error(e, $"Failed to Get history enties {entityId}");
                return(StatusCode(500));
            }
        }
        public async Task DeleteAsync(TId id)
        {
            var history = new HistoryDto
            {
                EntityName      = typeof(TIn).Name,
                EntityId        = id.ToString(),
                IsEntityDeleted = true,
                CreatedAt       = DateTime.UtcNow
            };

            await fullCrudService.DeleteAsync(id);

            await historyService.CreateAsync(history);
        }
示例#10
0
        public virtual async Task <HistoryDto> CreateHistoryAsync(HistoryDto historyDto)
        {
            HttpResponseMessage response = await _proxyService.PostJsonAsync("/api/histories", new
            {
                processType = historyDto.ProcessType,
                comment     = historyDto.Comment,
                historyId   = historyDto.HistoryId,
                historyType = historyDto.HistoryType,
                historyName = historyDto.HistoryName,
                machineId   = historyDto.MachineId,
            });

            response.EnsureSuccessStatusCode();
            return(await response.Content.ReadAsAsync <HistoryDto>());
        }
示例#11
0
        public Task <List <UserAccess> > UserHistory([FromQuery] HistoryDto history)
        {
            if (history.UserID == null)
            {
                return(Task.FromResult(new List <UserAccess>()));
            }
            var userInDb = _context.UserAccesses.FirstOrDefault(x => x.UserID == Guid.Parse(history.UserID));

            if (userInDb == null)
            {
                return(null);
            }
            var accesses = _context.UserAccesses.Where(x => x.UserID == Guid.Parse(history.UserID)).ToList();

            return(Task.FromResult(accesses));
        }
        public List <HistoryDto> GetModel()
        {
            List <HistoryDto> hList = new List <HistoryDto>();

            var list = _uow.Domains.Entities.Select(x => x.MainUrl).ToList();

            foreach (var u in list)
            {
                var urlHistory = new HistoryDto {
                    Url = u
                };
                var dates = _uow.TestsTime.Entities
                            .Where(c => c.Domain.MainUrl.Contains(u)).Select(x => x.Date).ToList();
                urlHistory.dates = dates;
                hList.Add(urlHistory);
            }
            return(hList);
        }
        protected async Task CreateUpdatedHistoryAsync(TOut newItem, TOut previousItem)
        {
            var differences = GetUpdatedDifferenceValueList(newItem, previousItem);

            if (!differences.Any())
            {
                return;
            }

            var history = new HistoryDto
            {
                EntityName      = typeof(TIn).Name,
                EntityId        = newItem.Id.ToString(),
                IsEntityDeleted = false,
                CreatedAt       = DateTime.UtcNow,
                Differences     = differences
            };

            await historyService.CreateAsync(history);
        }
示例#14
0
        public override void Run()
        {
            this.AcadDoc = this.AcAppComObj.Documents.Open(this.AbsPath, null, null);
            //TODO 相应方法
            AcadBlocks blocks = this.AcadDoc.Blocks;
            //1.获取要替换图号的规则
            HistoryDto dto = Util.GetDrwingsDto(AcadDoc.Name);

            try
            {
                foreach (AcadBlock block in blocks)
                {
                    foreach (AcadEntity entity in block)
                    {
                        //2.替换审核者、设计者、日期等属性
                        Util.ReplaceProperty(entity, blocks, this.GetDefaultRules());
                        //3.替换装配图中的明细表中的编号
                        Util.ReplaceDrawingCode(entity, AcAppComObj);
                        entity.Update();
                    }
                }
                dto.FileStatus = "处理完成";
                dto.FilePath   = dto.FilePath.Replace("\\", "\\\\");
                Util.UpdateHistory(dto);
                var fileName = Util.SplitCode(Util.newCode);
                if (AcAppComObj.ActiveDocument.Saved == false)
                {
                    AcAppComObj.ActiveDocument.SaveAs(this.SavePath + fileName + "\\" + Util.newCode, AcSaveAsType.ac2013_dwg, null);
                    this.AcadDoc.Close();
                    GC.Collect();
                }
            }
            catch (Exception ex)
            {
                dto.FileStatus = "处理失败," + ex.Message;
                dto.FilePath   = dto.FilePath.Replace("\\", "\\\\");
                Util.UpdateHistory(dto);
                AcAppComObj.ActiveDocument.SaveAs(this.SavePath + "失败的图纸文件" + "\\" + Util.newCode, AcSaveAsType.ac2013_dwg, null);
                this.AcadDoc.Close();
            }
        }
        private List <HistoryDto> GetSampleHistory()
        {
            var history = new List <HistoryDto>();

            var firstItem = new HistoryDto
            {
                CustomerId = 12,
                Products   = GetSampleProducts()
            };


            var secondItem = new HistoryDto
            {
                CustomerId = 13,
                Products   = GetSampleProducts().Skip(2),
            };

            history.Add(firstItem);
            history.Add(secondItem);
            return(history);
        }
示例#16
0
        public async Task SetHistoryStateAsync(int userId, string title)
        {
            var state = await _appDbContext.Stages.Include(p => p.Issues).AsNoTracking().Where(p => p.UserId == userId).ToListAsync();

            foreach (var stage in state)
            {
                stage.User = null;
                foreach (var issue in stage.Issues)
                {
                    issue.Stage     = null;
                    issue.NextIssue = null;
                    issue.User      = null;
                }
            }

            _bufferHistory = new HistoryDto()
            {
                Body   = JsonConvert.SerializeObject(state),
                Title  = title,
                UserId = userId
            };
        }
        /// <summary>
        /// Должно срабатывать когда человек зашел в сессию
        /// </summary>
        /// <param name="id">Идентификатор сессии</param>
        /// <returns></returns>
        public async Task EnterToSession(long id)
        {
            // Группа для SignalR (потом мб на гуид переделаем)
            var groupId = Convert.ToString(id);

            // Добавляем это подключение в группу
            await Groups.AddToGroupAsync(Context.ConnectionId, groupId);

            // Если нет такой сессии
            if (!_db.ChatSessions.Any(x => x.Id == id))
            {
                return;
            }

            // Получаем историю ответов для сессии
            var answersHistory = _db.ChatSessionAnswers
                                 .Where(x => x.SessionId == id).ToList();

            // Если нет ниодного ответа
            if (answersHistory.Any())
            {
                // Получаем сессию из БД
                var session = _db.ChatSessions
                              .Include(x => x.ChatSessionAnswers)
                              .ThenInclude(x => x.Question)
                              .ThenInclude(x => x.Buttons)
                              .First(x => x.Id == id);

                // Формируем историю для отправки
                var history = _mapper.Map <HistoryDto>(session);

                // Сериализуем в JSON
                //var json = JsonConvert.SerializeObject(history);

                // Отправляем историю к новому подключившемуся к сессии человеку
                await Clients.Caller.SendAsync("EnterToSession", history);
            }
            else
            {
                // Получаем сессию из БД
                var session = _db.ChatSessions
                              .Include(x => x.Chat)
                              .ThenInclude(x => x.Questions)
                              .ThenInclude(x => x.Buttons)
                              .First(x => x.Id == id);

                // Получаем первый вопрос
                var firstQuestion = session.Chat.Questions.First(x => x.QueueNumber == 0);

                var answer = new ChatSessionAnswer()
                {
                    QuestionId = firstQuestion.Id,
                    SessionId  = id,
                };

                // Добавляем в историю новый вопрос
                _db.ChatSessionAnswers.Add(answer);
                _db.SaveChanges();

                answer.Question = firstQuestion;

                // Формируем историю для отправки
                var history = new HistoryDto()
                {
                    QuestionsHistory   = null,
                    NextQuestion       = _mapper.Map <NextQuestionDto>(answer),
                    IsSessionCompleted = session.IsCompleted
                };

                // Сериализуем в JSON
                //var json = JsonConvert.SerializeObject(history);

                // Отправляем историю к новому подключившемуся к сессии человеку
                await Clients.Caller.SendAsync("EnterToSession", history);
            }
        }
示例#18
0
        protected override void Initialize()
        {
            base.Initialize();
            _mockHistoryManager = new Mock <IHistoryManager>();

            _manager = new ReportElementManager(
                _mockHistoryManager.Object,
                mockUnitOfWork.Object,
                mockMapper.Object);

            _reportElement = new ReportElement
            {
                Id     = 1,
                Hours  = Domain.Core.Model.Enums.ReportElementHours.Hour168,
                Sensor = new Sensor()
                {
                    Id = 1, Name = "Sensor1"
                },
                SensorId = 1
            };

            reportElements = new List <ReportElement>()
            {
                new ReportElement {
                    Id     = 1,
                    Hours  = Domain.Core.Model.Enums.ReportElementHours.Hour168,
                    Sensor = new Sensor()
                    {
                        Id = 1, Name = "Sensor1"
                    },
                    Dashboard = new Dashboard()
                    {
                        Id = 1, Name = "Dashboard1"
                    },
                    SensorId = 1
                },
                new ReportElement {
                    Id     = 2,
                    Hours  = Domain.Core.Model.Enums.ReportElementHours.Hour168,
                    Sensor = new Sensor()
                    {
                        Id = 2, Name = "Sensor2"
                    },
                    Dashboard = new Dashboard()
                    {
                        Id = 1, Name = "Dashboard1"
                    },
                    Type     = ReportElementType.Wordcloud,
                    SensorId = 2
                }
            };

            histories = new List <History>()
            {
                new History {
                    Id     = 1,
                    Date   = DateTimeOffset.Now.AddDays(-(int)_reportElement.Hours),
                    Sensor = new Sensor()
                    {
                        Id = 5, Name = "Sensor5", SensorType = new SensorType()
                        {
                            MeasurementType = Domain.Core.Model.Enums.MeasurementType.Bool
                        }
                    },
                    BoolValue = true
                },
                new History {
                    Id     = 2,
                    Date   = new DateTimeOffset(),
                    Sensor = new Sensor()
                    {
                        Id = 1, Name = "Sensor1", SensorType = new SensorType()
                        {
                            MeasurementType = Domain.Core.Model.Enums.MeasurementType.Int
                        }
                    },
                    IntValue = 2
                },
                new History {
                    Id     = 3,
                    Date   = new DateTimeOffset(),
                    Sensor = new Sensor()
                    {
                        Id = 2, Name = "Sensor2", SensorType = new SensorType()
                        {
                            MeasurementType = Domain.Core.Model.Enums.MeasurementType.Int
                        }
                    },
                    IntValue = 3
                },
                new History {
                    Id     = 4,
                    Date   = DateTimeOffset.Now.AddDays(-(int)_reportElement.Hours),
                    Sensor = new Sensor()
                    {
                        Id = 3, Name = "Sensor3", SensorType = new SensorType()
                        {
                            MeasurementType = Domain.Core.Model.Enums.MeasurementType.Int
                        }
                    },
                    IntValue = 3
                }
            };

            mockUnitOfWork.Setup(u => u.ReportElementRepo
                                 .GetById(It.IsAny <int>()))
            .Returns((int i) =>
                     Task.FromResult(reportElements.Where(x => x.Id == i).FirstOrDefault()));

            mockUnitOfWork.Setup(u => u.HistoryRepo
                                 .GetHistoriesBySensorIdAndDate(It.IsAny <int>(), It.IsAny <DateTimeOffset>()))
            .Returns((int i, DateTimeOffset date) =>
                     Task.FromResult(histories.Where(x => x.Id == i && x.Date == date)));

            mockUnitOfWork.Setup(u => u.HistoryRepo
                                 .GetAvgSensorsValuesPerDays(It.IsAny <int>(), It.IsAny <DateTime>(), It.IsAny <DateTime>()))
            .Returns(Task.FromResult <IEnumerable <AvgSensorValuePerDay> >(new List <AvgSensorValuePerDay> {
                _avgSensorValuePerDay
            }));

            _reportElementDto = new ReportElementDto
            {
                Id            = 1,
                Hours         = Domain.Core.Model.Enums.ReportElementHours.Hour168,
                DashboardId   = 1,
                SensorId      = 1,
                Type          = ReportElementType.Wordcloud,
                IsActive      = true,
                IsLocked      = true,
                DashboardName = "DashboardTest"
            };

            _gaugeDto = new GaugeDto
            {
                Id              = 1,
                Hours           = Domain.Core.Model.Enums.ReportElementHours.Hour168,
                SensorId        = 1,
                SensorName      = "Sensor1",
                MeasurementName = "*C"
            };

            _historyDto = new HistoryDto
            {
                Id       = 3,
                Date     = new DateTimeOffset(),
                IntValue = 3
            };

            _avgSensorValuePerDay = new AvgSensorValuePerDay()
            {
                WeekDay  = DateTime.Now,
                AvgValue = 3
            };

            _boolValuePercentagePerHour = new BoolValuePercentagePerHour()
            {
                DayDate        = DateTime.Now,
                HourTime       = DateTime.Now.Hour,
                TrueCount      = 1,
                TrueFalseCount = 2,
                TruePercentage = 50
            };
        }
        public IActionResult Index()
        {
            HistoryDto dto = new HistoryDto();;

            return(View(dto));
        }