コード例 #1
0
        public JsonResult SelectData()
        {
            var data = new LeafletModel();

            using (var db = new LeafletContext())
            {
                data.Doors = db.Doors.Select(i => new DoorModel()
                {
                    Id         = i.Id,
                    DoorNo     = i.DoorNo,
                    Coordinate = i.Coordinate,
                    DistrictId = i.DistrictId
                }).ToList();

                data.Districts = db.Districts.Select(i => new DistrictModel()
                {
                    Id          = i.Id,
                    Name        = i.Name,
                    Coordinates = i.Coordinates
                }).ToList();
            }

            return(Json(data, JsonRequestBehavior.AllowGet));
        }
コード例 #2
0
        protected override void GetText()
        {
            try
            {
                PongResponse pingResponse = _pdfBoxServiceClient.Ping(new PingRequest {
                    Message = GROUPNAME
                });

                //SaleFinderDb.DeleteLeaflets(GROUPNAME);

                foreach (var leaflet in _leaflets)
                {
                    string       fullFileName = Path.Combine(_tempFolder, leaflet.DownloadedFileName);
                    LeafletModel leafletModel = new LeafletModel
                    {
                        FileName  = leaflet.DownloadedFileName,
                        GroupName = GROUPNAME,
                        Hash      = leaflet.MD5,
                        Status    = LeafletModelStatus.Processed,
                        Pages     = new List <LeafletPageModel>()
                    };
                    bool saleDateFound = false;
                    var  response      = _pdfBoxServiceClient.PdfPagesCount(new Messages.PDFInfoMessage {
                        FileName = fullFileName
                    });
                    for (int i = 0; i < response.PagesCount; i++)
                    {
                        byte[] fileContent = File.ReadAllBytes(leaflet.DownloadedFileName);

                        var exportMessage = _pdfBoxServiceClient.ImportExport(new PDFExportRequest
                        {
                            PDFInputMessage = new PDFInputMessage
                            {
                                FileName = fullFileName,
                                Pagenr   = i
                            }
                        });

                        LeafletPageModel leafletPageModel = new LeafletPageModel
                        {
                            PageNumber = i + 1,
                            Text       = exportMessage.PDFOutputMessage.Text
                        };

                        if (!saleDateFound)
                        {
                            Regex rgx = new Regex(@"\d{2}.\d{2}.\d{4}");
                            Match mat = rgx.Match(leafletPageModel.Text);
                            if (mat.Success)
                            {
                            }
                        }
                        //string fileNameWithoutExtension = Path.GetFileNameWithoutExtension(leaflet.DownloadedFileName);
                        //string textFileName = $"{fileNameWithoutExtension}_{i}.txt";

                        //File.WriteAllText(textFileName, exportMessage.PDFOutputMessage.Text);
                        leafletModel.Pages.Add(leafletPageModel);
                    }
                    SaleFinderDb.AddLeaflet(leafletModel);
                }
            }
            catch (RpcException e)
            {
            }
        }