コード例 #1
0
        public async Task <ActionResult <int> > Count([FromBody] Tracking_TrackingFilterDTO Tracking_TrackingFilterDTO)
        {
            if (!ModelState.IsValid)
            {
                throw new BindException(ModelState);
            }

            TrackingFilter TrackingFilter = ConvertFilterDTOToFilterEntity(Tracking_TrackingFilterDTO);

            TrackingFilter = await TrackingService.ToFilter(TrackingFilter);

            int count = await TrackingService.Count(TrackingFilter);

            return(count);
        }
コード例 #2
0
        public async Task <ActionResult <List <Tracking_TrackingDTO> > > List([FromBody] Tracking_TrackingFilterDTO Tracking_TrackingFilterDTO)
        {
            if (!ModelState.IsValid)
            {
                throw new BindException(ModelState);
            }

            TrackingFilter TrackingFilter = ConvertFilterDTOToFilterEntity(Tracking_TrackingFilterDTO);

            TrackingFilter = await TrackingService.ToFilter(TrackingFilter);

            List <Tracking> Trackings = await TrackingService.List(TrackingFilter);

            List <Tracking_TrackingDTO> Tracking_TrackingDTOs = Trackings
                                                                .Select(c => new Tracking_TrackingDTO(c)).ToList();

            return(Tracking_TrackingDTOs);
        }
コード例 #3
0
        private TrackingFilter ConvertFilterDTOToFilterEntity(Tracking_TrackingFilterDTO Tracking_TrackingFilterDTO)
        {
            TrackingFilter TrackingFilter = new TrackingFilter();

            TrackingFilter.Selects   = TrackingSelect.ALL;
            TrackingFilter.Skip      = Tracking_TrackingFilterDTO.Skip;
            TrackingFilter.Take      = Tracking_TrackingFilterDTO.Take;
            TrackingFilter.OrderBy   = Tracking_TrackingFilterDTO.OrderBy;
            TrackingFilter.OrderType = Tracking_TrackingFilterDTO.OrderType;

            TrackingFilter.Id              = Tracking_TrackingFilterDTO.Id;
            TrackingFilter.TrackerId       = Tracking_TrackingFilterDTO.TrackerId;
            TrackingFilter.TargetId        = Tracking_TrackingFilterDTO.TargetId;
            TrackingFilter.PlaceId         = Tracking_TrackingFilterDTO.PlaceId;
            TrackingFilter.PlaceCheckingId = Tracking_TrackingFilterDTO.PlaceCheckingId;
            TrackingFilter.CreatedAt       = Tracking_TrackingFilterDTO.CreatedAt;
            TrackingFilter.UpdatedAt       = Tracking_TrackingFilterDTO.UpdatedAt;
            return(TrackingFilter);
        }
コード例 #4
0
        public async Task <ActionResult> ExportTemplate([FromBody] Tracking_TrackingFilterDTO Tracking_TrackingFilterDTO)
        {
            if (!ModelState.IsValid)
            {
                throw new BindException(ModelState);
            }

            string path = "Templates/Tracking_Template.xlsx";

            byte[]       arr    = System.IO.File.ReadAllBytes(path);
            MemoryStream input  = new MemoryStream(arr);
            MemoryStream output = new MemoryStream();
            dynamic      Data   = new ExpandoObject();

            using (var document = StaticParams.DocumentFactory.Open(input, output, "xlsx"))
            {
                document.Process(Data);
            };
            return(File(output.ToArray(), "application/octet-stream", "Tracking.xlsx"));
        }
コード例 #5
0
        public async Task <ActionResult> Export([FromBody] Tracking_TrackingFilterDTO Tracking_TrackingFilterDTO)
        {
            if (!ModelState.IsValid)
            {
                throw new BindException(ModelState);
            }

            MemoryStream memoryStream = new MemoryStream();

            using (ExcelPackage excel = new ExcelPackage(memoryStream))
            {
                #region Tracking
                var TrackingFilter = ConvertFilterDTOToFilterEntity(Tracking_TrackingFilterDTO);
                TrackingFilter.Skip = 0;
                TrackingFilter.Take = int.MaxValue;
                TrackingFilter      = await TrackingService.ToFilter(TrackingFilter);

                List <Tracking> Trackings = await TrackingService.List(TrackingFilter);

                var TrackingHeaders = new List <string[]>()
                {
                    new string[] {
                        "Id",
                        "TrackerId",
                        "TargetId",
                        "PlaceId",
                        "PlaceCheckingId",
                    }
                };
                List <object[]> TrackingData = new List <object[]>();
                for (int i = 0; i < Trackings.Count; i++)
                {
                    var Tracking = Trackings[i];
                    TrackingData.Add(new Object[]
                    {
                        Tracking.Id,
                        Tracking.TrackerId,
                        Tracking.TargetId,
                        Tracking.PlaceId,
                        Tracking.PlaceCheckingId,
                    });
                }
                excel.GenerateWorksheet("Tracking", TrackingHeaders, TrackingData);
                #endregion

                #region Place
                var PlaceFilter = new PlaceFilter();
                PlaceFilter.Selects   = PlaceSelect.ALL;
                PlaceFilter.OrderBy   = PlaceOrder.Id;
                PlaceFilter.OrderType = OrderType.ASC;
                PlaceFilter.Skip      = 0;
                PlaceFilter.Take      = int.MaxValue;
                List <Place> Places = await PlaceService.List(PlaceFilter);

                var PlaceHeaders = new List <string[]>()
                {
                    new string[] {
                        "Id",
                        "Name",
                        "PlaceGroupId",
                        "Radius",
                        "Latitude",
                        "Longtitude",
                    }
                };
                List <object[]> PlaceData = new List <object[]>();
                for (int i = 0; i < Places.Count; i++)
                {
                    var Place = Places[i];
                    PlaceData.Add(new Object[]
                    {
                        Place.Id,
                        Place.Name,
                        Place.PlaceGroupId,
                        Place.Radius,
                        Place.Latitude,
                        Place.Longtitude,
                    });
                }
                excel.GenerateWorksheet("Place", PlaceHeaders, PlaceData);
                #endregion
                #region PlaceChecking
                var PlaceCheckingFilter = new PlaceCheckingFilter();
                PlaceCheckingFilter.Selects   = PlaceCheckingSelect.ALL;
                PlaceCheckingFilter.OrderBy   = PlaceCheckingOrder.Id;
                PlaceCheckingFilter.OrderType = OrderType.ASC;
                PlaceCheckingFilter.Skip      = 0;
                PlaceCheckingFilter.Take      = int.MaxValue;
                List <PlaceChecking> PlaceCheckings = await PlaceCheckingService.List(PlaceCheckingFilter);

                var PlaceCheckingHeaders = new List <string[]>()
                {
                    new string[] {
                        "Id",
                        "AppUserId",
                        "PlaceId",
                        "PlaceCheckingStatusId",
                        "CheckInAt",
                        "CheckOutAt",
                    }
                };
                List <object[]> PlaceCheckingData = new List <object[]>();
                for (int i = 0; i < PlaceCheckings.Count; i++)
                {
                    var PlaceChecking = PlaceCheckings[i];
                    PlaceCheckingData.Add(new Object[]
                    {
                        PlaceChecking.Id,
                        PlaceChecking.AppUserId,
                        PlaceChecking.PlaceId,
                        PlaceChecking.PlaceCheckingStatusId,
                        PlaceChecking.CheckInAt,
                        PlaceChecking.CheckOutAt,
                    });
                }
                excel.GenerateWorksheet("PlaceChecking", PlaceCheckingHeaders, PlaceCheckingData);
                #endregion
                #region AppUser
                var AppUserFilter = new AppUserFilter();
                AppUserFilter.Selects   = AppUserSelect.ALL;
                AppUserFilter.OrderBy   = AppUserOrder.Id;
                AppUserFilter.OrderType = OrderType.ASC;
                AppUserFilter.Skip      = 0;
                AppUserFilter.Take      = int.MaxValue;
                List <AppUser> AppUsers = await AppUserService.List(AppUserFilter);

                var AppUserHeaders = new List <string[]>()
                {
                    new string[] {
                        "Id",
                        "Username",
                        "Password",
                        "DisplayName",
                        "Email",
                        "Phone",
                    }
                };
                List <object[]> AppUserData = new List <object[]>();
                for (int i = 0; i < AppUsers.Count; i++)
                {
                    var AppUser = AppUsers[i];
                    AppUserData.Add(new Object[]
                    {
                        AppUser.Id,
                        AppUser.Username,
                        AppUser.Password,
                        AppUser.DisplayName,
                        AppUser.Email,
                        AppUser.Phone,
                    });
                }
                excel.GenerateWorksheet("AppUser", AppUserHeaders, AppUserData);
                #endregion
                excel.Save();
            }
            return(File(memoryStream.ToArray(), "application/octet-stream", "Tracking.xlsx"));
        }