Beispiel #1
0
        public void TestAddDataPointHistoryData()
        {
            IUnitOfWork unitOfWork = new AdoUnitOfWork();
            IDataPointHistoryDataRepository dataPointHistoryDataRepository = new DataPointHistoryDataRepository(unitOfWork);

            DataPointHistoryDataService dataPointHistoryDataService
                = new DataPointHistoryDataService(dataPointHistoryDataRepository,
                                                  unitOfWork);

            List <DataPointHistoryData> dataPointHistoryDatas = new List <DataPointHistoryData>();

            for (int i = 0; i < 5000; i++)
            {
                DataPointHistoryData dataPointHistoryData = new DataPointHistoryData()
                {
                    Id        = Guid.NewGuid().ToString("D"),
                    DataPoint = new DataPoint()
                    {
                        Id = 1726
                    },
                    DateTime = DateTime.Now,
                    Value    = 123456789.12345
                };

                dataPointHistoryDatas.Add(dataPointHistoryData);
            }

            AddDataPointHistoryDataRequst requst = new AddDataPointHistoryDataRequst();

            requst.DataPointHistoryDatasToAdd = dataPointHistoryDatas;

            AddDataPointHistoryDataResponse response =
                dataPointHistoryDataService.AddDataPointHistoryData(requst);
        }
Beispiel #2
0
        public AddDataPointHistoryDataResponse AddDataPointHistoryData(AddDataPointHistoryDataRequst requst)
        {
            AddDataPointHistoryDataResponse response = new AddDataPointHistoryDataResponse();

            try
            {
                foreach (DataPointHistoryData dataPointHistoryData in requst.DataPointHistoryDatasToAdd)
                {
                    dataPointHistoryDataRepository.Add(dataPointHistoryData);
                }

                unitOfWork.Commit();
            }
            catch (Exception ex)
            {
                string message = "添加失败!错误信息:/n" + ex.Message;
                response = new AddDataPointHistoryDataResponse()
                {
                    ResponseSucceed = false,
                    Message         = "添加失败"
                };
                LoggingFactory.GetLogger().WriteDebugLogger(message);

                return(response);
            }

            return(response);
        }