Esempio n. 1
0
        public async Task <List <CameraDto> > PostExcelToCameraInfoAsync(IFormFile files)
        {
            if (files.Length == 0)
            {
                return(null);
            }

            DataTable dt = new DataTable();


            var data = ExcelHelper.ExcelToDataTable(files.OpenReadStream(), Path.GetExtension(files.FileName), "Sheet", true);

            var list = ListToDataTable.tolist <UpdateCameraDto>(data);
            List <CameraDto> listcamera = new List <CameraDto>();

            foreach (var item in list)
            {
                var camera = await _cameraAppService.GetListByCondition(new CameraCondition()
                {
                    Camera_ID = item.Camera_ID
                }, null);



                if (camera.TotalCount == 0)
                {
                    var Cameradata = await _cameraAppService.CreateAsync(item);

                    listcamera.Add(Cameradata);
                }
            }


            return(listcamera);
        }
Esempio n. 2
0
        public async Task <List <DVRDto> > PostExcelToDVRInfoAsync(IFormFile files)
        {
            if (files.Length == 0 || Path.GetExtension(files.FileName) != ".xlsx")
            {
                throw new Exception("上传文件格式错误");
                //return null;
            }

            DataTable dt = new DataTable();



            //  var dvr25 = await _dVRAppService.GetListAsync();

            var           data    = ExcelHelper.ExcelToDataTable(files.OpenReadStream(), Path.GetExtension(files.FileName), "Sheet", true);
            var           list    = ListToDataTable.tolist <UpdateDVRDto>(data);
            List <DVRDto> listdvr = new List <DVRDto>();

            foreach (var item in list)
            {
                var dvr = await _dVRAppService.GetListByCondition(null, null, null, item.DVR_ID);

                if (dvr.TotalCount == 0)
                {
                    var dvrdata = await _dVRAppService.CreateAsync(item);

                    listdvr.Add(dvrdata);
                }
            }
            return(listdvr);
        }
Esempio n. 3
0
        public async Task <List <AlarmDto> > PostExcelToDVRInfoAsync(IFormFile files)
        {
            if (files.Length == 0 || Path.GetExtension(files.FileName) != ".xlsx")
            {
                throw new Exception("上传文件格式错误");
                //return null;
            }

            DataTable dt = new DataTable();



            PagedAndSortedResultRequestDto resultRequestDto = new PagedAndSortedResultRequestDto()
            {
                MaxResultCount = 200000, SkipCount = 0, Sorting = "Id"
            };

            var             data      = ExcelHelper.ExcelToDataTable(files.OpenReadStream(), Path.GetExtension(files.FileName), "Sheet", true);
            var             list      = ListToDataTable.tolist <UpdateAlarmDto>(data);
            List <AlarmDto> listdvr   = new List <AlarmDto>();
            var             alarmdata = await _alarmAppService.GetListAsync(resultRequestDto);

            foreach (var item in list)
            {
                var dvr = alarmdata.Items.Where(u => u.Alarm_ID == item.Alarm_ID);
                if (dvr.Count() == 0)
                {
                    var dvrdata = await _alarmAppService.CreateAsync(item);

                    listdvr.Add(dvrdata);
                }
            }
            return(listdvr);
        }