Ejemplo n.º 1
0
        public static List <PdfFileModel> GetServicePdfFileList(string path, string virtuarl)
        {
            List <PdfFileModel> l = new List <PdfFileModel>();
            string directory      = path;// HttpContext.Current.Server.MapPath(path);

            if (Directory.Exists(directory))
            {
                DirectoryInfo di = new DirectoryInfo(directory);

                FileInfo[] FI = di.GetFiles("*.pdf");//只查.zip文件
                if (FI.Length > 0)
                {
                    foreach (FileInfo tmpFI in FI)
                    {
                        PdfFileModel one = new PdfFileModel();
                        one.create = tmpFI.CreationTime;
                        one.name   = tmpFI.Name;
                        try
                        {
                            one.guid = Guid.Parse(one.name.Substring(0, one.name.Length - 4));
                        }
                        catch
                        {
                            one.guid = Guid.Empty;
                        }
                        one.path    = virtuarl + tmpFI.Name;
                        one.fordate = one.create.Date.AddMonths(-1).ToString("yyyyMM");
                        l.Add(one);
                    }
                }
            }
            return(l);
        }
Ejemplo n.º 2
0
        /// <summary>
        /// 日报列表
        /// </summary>
        /// <param name="path"></param>
        /// <param name="virtuarl"></param>
        /// <returns></returns>
        public static List <PdfFileModel> GetServiceDayList(string path, string virtuarl)
        {
            List <PdfFileModel> l = new List <PdfFileModel>();
            string directory      = path;

            if (Directory.Exists(directory))
            {
                DirectoryInfo di = new DirectoryInfo(directory);

                FileInfo[] FI = di.GetFiles();
                if (FI.Length > 0)
                {
                    foreach (FileInfo tmpFI in FI)
                    {
                        PdfFileModel one = new PdfFileModel();
                        one.create     = tmpFI.CreationTime;
                        one.name       = tmpFI.Name;
                        one.day        = one.name.Substring(0, one.name.Length - 4);
                        one.reporttype = 1;
                        one.path       = virtuarl + tmpFI.Name;
                        one.fordate    = one.create.Date.ToString("yyyy-MM-dd");
                        l.Add(one);
                    }
                }
            }
            return(l);
        }
Ejemplo n.º 3
0
        public static List <PdfFileModel> GetPdfFileList(string path)
        {
            List <PdfFileModel> l = new List <PdfFileModel>();

            //string directory = HttpContext.Current.Server.MapPath(path);
            if (Directory.Exists(path))
            {
                DirectoryInfo di = new DirectoryInfo(path);

                FileInfo[] FI = di.GetFiles("*.pdf");//只查.zip文件
                if (FI.Length > 0)
                {
                    foreach (FileInfo tmpFI in FI)
                    {
                        PdfFileModel one = new PdfFileModel();
                        one.create  = tmpFI.CreationTime;
                        one.name    = tmpFI.Name;
                        one.path    = ".." + path + "/" + tmpFI.Name;
                        one.fordate = one.create.Date.AddMonths(-1).ToString("yyyyMM");
                        l.Add(one);
                    }
                }
            }
            return(l);
        }
Ejemplo n.º 4
0
        /// <summary>
        /// 周报列表
        /// </summary>
        /// <param name="path"></param>
        /// <param name="virtuarl"></param>
        /// <returns></returns>
        public static List <PdfFileModel> GetServiceFileList(string path, string virtuarl)
        {
            List <PdfFileModel> l = new List <PdfFileModel>();
            string directory      = path;

            if (Directory.Exists(directory))
            {
                DirectoryInfo di = new DirectoryInfo(directory);

                FileInfo[] FI = di.GetFiles();
                if (FI.Length > 0)
                {
                    foreach (FileInfo tmpFI in FI)
                    {
                        PdfFileModel one = new PdfFileModel();
                        one.create     = tmpFI.CreationTime;
                        one.name       = tmpFI.Name;
                        one.week       = Convert.ToInt32(one.name.Substring(0, one.name.Length - 4));// Utils.GetWeekOfYear(one.create);
                        one.reporttype = 2;
                        one.path       = virtuarl + tmpFI.Name;
                        one.fordate    = one.create.Date.ToString("yyyyMMdd");
                        l.Add(one);
                    }
                }
            }
            return(l);
        }
Ejemplo n.º 5
0
        public async Task <PdfFileModel> AddAsync(PdfFileModel model)
        {
            var entry = await _context.Files.AddAsync(model);

            Debug.Assert(entry.State == EntityState.Added);

            return(entry.Entity);
        }
Ejemplo n.º 6
0
        public PdfViewerControl(StorageFile file, PdfFileModel pdfFile, bool isMain)
        {
            this.InitializeComponent();

            ViewerPageViewModel = new PdfViewerViewModel();
            PdfViewerViewType   = PdfViewerViewType.Normal;

            File          = file;
            PdfFile       = pdfFile;
            IsMainPdfFile = isMain;
        }
Ejemplo n.º 7
0
        private void ContentDialog_PrimaryButtonClick(ContentDialog sender, ContentDialogButtonClickEventArgs args)
        {
            ErrorText.Visibility = Visibility.Collapsed;

            if (FilesListBox.SelectedItem is PdfFileModel pdfFile)
            {
                Result = pdfFile;
            }
            else
            {
                ErrorText.Visibility = Visibility.Visible;
                args.Cancel          = true;
            }
        }
Ejemplo n.º 8
0
        public void LoadPdfViewer(StorageFile file, PdfFileModel pdfFile)
        {
            PivotItem newItem = new PivotItem
            {
                Header = file.DisplayName,
                //IconSource = new Microsoft.UI.Xaml.Controls.SymbolIconSource() { Symbol = Symbol.Document }
            };

            Frame frame = new Frame();

            frame.Navigated += Frame_Navigated;
            frame.Navigate(typeof(PdfViewerSource), new object[] { file, pdfFile });
            newItem.Content = frame;

            PivotControl.Items.Add(newItem);
            PivotControl.SelectedItem = newItem;
        }
Ejemplo n.º 9
0
        private async Task <StorageFile> OpenFile(PdfFileModel pdfFile)
        {
            try
            {
                var file = await StorageFile.GetFileFromPathAsync(pdfFile.FullFilePath);

                if (file != null)
                {
                    var tempFile = await StorageApplicationPermissions.FutureAccessList.GetFileAsync(pdfFile.FileToken);

                    if (tempFile != null)
                    {
                        return(await Task.FromResult(tempFile));
                    }
                }
                return(await Task.FromResult <StorageFile>(null));
            }
            catch (Exception)
            {
                return(await Task.FromResult <StorageFile>(null));
            }
        }
Ejemplo n.º 10
0
        private void LoadPdfViewer(StorageFile file, PdfFileModel pdfFile)
        {
            //PivotItem newItem = new PivotItem
            //{
            //    Header = file.DisplayName,
            //IconSource = new Microsoft.UI.Xaml.Controls.SymbolIconSource() { Symbol = Symbol.Document }
            //};

            /*Frame frame = new Frame();
             *
             * frame.Navigated += Frame_Navigated;
             * frame.Navigate(typeof(PdfViewerPage), new object[] { file, pdfFile, true });
             * newItem.Content = frame;*/

            //newItem.Content = new PdfViewerControl(file, pdfFile, true);

            //PivotControl.Items.Insert(PivotControl.Items.Count - 1, newItem);
            //PivotControl.SelectedItem = newItem;

            //PdfContentViewGrid.Children.Clear();
            //PdfContentViewGrid.Children.Add(new PdfViewerControl(file, pdfFile, true));
        }
Ejemplo n.º 11
0
        /// <summary>
        /// 月报列表
        /// </summary>
        /// <param name="path"></param>
        /// <param name="virtuarl"></param>
        /// <returns></returns>
        public static List <PdfFileModel> GetServiceMonthList(string path, string virtuarl)
        {
            List <PdfFileModel> l = new List <PdfFileModel>();
            string directory      = path;

            if (Directory.Exists(directory))
            {
                DirectoryInfo di = new DirectoryInfo(directory);

                FileInfo[] FI = di.GetFiles();
                if (FI.Length > 0)
                {
                    foreach (FileInfo tmpFI in FI)
                    {
                        PdfFileModel one = new PdfFileModel();
                        if (!tmpFI.Name.EndsWith(".txt"))
                        {
                            continue;
                        }
                        one.create     = tmpFI.CreationTime;
                        one.name       = tmpFI.Name;
                        one.month      = one.name.Substring(0, one.name.Length - 4);
                        one.reporttype = 3;
                        one.haspdf     = false;
                        var h = FI.FirstOrDefault(p => p.Name.StartsWith(one.month) && p.Name.EndsWith(".pdf"));
                        if (h != null)//存在pdf
                        {
                            one.haspdf = true;
                        }
                        one.path    = virtuarl + tmpFI.Name;
                        one.fordate = one.month.Substring(0, 4) + "年" + one.month.Substring(4) + "月";
                        l.Add(one);
                    }
                }
            }
            return(l);
        }
Ejemplo n.º 12
0
 private void OnButtonFavoriteToggled(PdfViewerSource pdfViewer, PdfFileModel pdfFile)
 {
     PdfViewerButtonToggledClicked?.Invoke(pdfViewer, pdfFile);
 }
Ejemplo n.º 13
0
        private async void Content_PdfViewerButtonToggledClicked(PdfViewerSource pdfViewer, PdfFileModel pdfFile)
        {
            if (PdfFiles.Exists(x => x.FullFilePath == pdfFile.FullFilePath))
            {
                PdfFiles.Where(x => x.FullFilePath == pdfFile.FullFilePath).FirstOrDefault().IsFavorite = pdfFile.IsFavorite;
            }

            await SaveSettings(PdfFiles);
        }