Exemplo n.º 1
0
        void searchFolder(SWIFolder folder, string pattern, List <SWIFile> files)
        {
            foreach (string newPath in Directory.GetFiles(folder.GetFullPath(), "*.*").Where(i => Path.GetFileName(i).ToLower().Contains(pattern.ToLower())))
            {
                if (folder.right > 0)
                {
                    files.Add(new SWIFile()
                    {
                        path     = folder.Combine(Path.GetFileName(newPath)),
                        name     = folder.fullname + Path.DirectorySeparatorChar.ToString() + Repository.TranslateFileName(newPath) + (FileHelper.IsSealReportFile(newPath) ? "" : Path.GetExtension(newPath)),
                        last     = System.IO.File.GetLastWriteTime(newPath).ToString("G", Repository.CultureInfo),
                        isreport = FileHelper.IsSealReportFile(newPath),
                        right    = folder.right
                    });
                }
            }

            foreach (string subFolder in Directory.GetDirectories(folder.GetFullPath()))
            {
                SWIFolder sub = getFolder(folder.Combine(subFolder));
                if (sub.right > 0)
                {
                    searchFolder(sub, pattern, files);
                }
            }
        }
Exemplo n.º 2
0
        public ActionResult SWIGetFolderDetail(string path)
        {
            try
            {
                SWIFolder folder = getFolder(path);
                var       files  = new List <SWIFile>();
                if (folder.right > 0)
                {
                    foreach (string newPath in Directory.GetFiles(folder.GetFullPath(), "*.*").Where(i => !FileHelper.IsSealAttachedFile(i)))
                    {
                        files.Add(new SWIFile()
                        {
                            path     = folder.Combine(Path.GetFileName(newPath)),
                            name     = Repository.TranslateFileName(newPath) + (FileHelper.IsSealReportFile(newPath) ? "" : Path.GetExtension(newPath)),
                            last     = System.IO.File.GetLastWriteTime(newPath).ToString("G", Repository.CultureInfo),
                            isReport = FileHelper.IsSealReportFile(newPath),
                            right    = folder.right
                        });
                    }
                }
                SetCookie(SealLastFolderCookieName, path);

                return(Json(new SWIFolderDetail()
                {
                    folder = folder, files = files.ToArray()
                }));
            }
            catch (Exception ex)
            {
                return(handleSWIException(ex));
            }
        }
Exemplo n.º 3
0
        void fillFolder(SWIFolder folder)
        {
            List <SWIFolder> subFolders = new List <SWIFolder>();

            if (folder.IsPersonal && WebUser.PersonalFolderRight == PersonalFolderRight.None)
            {
                return;
            }

            string folderPath = folder.GetFullPath();

            foreach (string subFolder in Directory.GetDirectories(folderPath))
            {
                if (folder.IsPersonal && subFolder.ToLower() == WebUser.DashboardPersonalFolder.ToLower())
                {
                    continue;
                }

                SWIFolder sub = getFolder(folder.Combine(subFolder));
                //Add if right on this folder, or a sub folder is defined with this root
                if ((sub.right > 0) || WebUser.SecurityGroups.Exists(i => i.Folders.Exists(j => j.Path.StartsWith(sub.path + (sub.path == Path.DirectorySeparatorChar.ToString() ? "" : Path.DirectorySeparatorChar.ToString())) && j.FolderRight != FolderRight.None)))
                {
                    fillFolder(sub);
                    subFolders.Add(sub);
                }
            }
            folder.folders = subFolders.ToArray();
        }
Exemplo n.º 4
0
        void fillFolder(SWIFolder folder)
        {
            List <SWIFolder> subFolders = new List <SWIFolder>();

            if (folder.IsPersonal && !WebUser.HasPersonalFolder)
            {
                return;
            }

            string folderPath = folder.GetFullPath();

            foreach (string subFolder in Directory.GetDirectories(folderPath))
            {
                //Hack: do not display images sub-directory when the directory contains the ui-* files (for jquery)
                if (Path.GetFileName(subFolder).ToLower() == "images")
                {
                    if (Directory.GetFiles(subFolder, "ui-*.png").Length > 10)
                    {
                        continue;
                    }
                }

                SWIFolder sub = getFolder(folder.Combine(subFolder));
                //Add if right on this folder, or a sub folder is defined with this root
                if ((sub.right > 0) || WebUser.SecurityGroups.Exists(i => i.Folders.Exists(j => j.Path.StartsWith(sub.path + (sub.path == "\\" ? "" : "\\")) && j.FolderRight != FolderRight.None)))
                {
                    fillFolder(sub);
                    subFolders.Add(sub);
                }
            }
            folder.folders = subFolders.ToArray();
        }
Exemplo n.º 5
0
        //[HttpPost]
        //public ActionResult SWExecuteReport(string path, bool? render, string viewGUID, string outputGUID)
        //{
        //    try
        //    {
        //        //if (!CheckAuthentication()) return Content(_loginContent);

        //        Report report = null;
        //        Repository repository = null;

        //        SWIFolder folder = getParentFolder(path);
        //        if (folder.right == 0) throw new Exception("Error: no right on this folder");
        //        if (!string.IsNullOrEmpty(outputGUID) && (FolderRight)folder.right == FolderRight.Execute) throw new Exception("Error: no right to execute output on this folder");

        //        string filePath = getFullPath(path);
        //        if (!System.IO.File.Exists(filePath)) throw new Exception("Error: report does not exist");
        //        repository = Repository.CreateFast();
        //        report = Report.LoadFromFile(filePath, repository);

        //        var execution = initReportExecution(report, viewGUID, outputGUID);
        //        execution.RenderHTMLDisplayForViewer();
        //        return getFileResult(report.HTMLDisplayFilePath, report);
        //    }
        //    catch (Exception ex)
        //    {
        //        return HandleException(ex);
        //    }
        //}

        private void setFolder()
        {
            var       path   = "\\";
            SWIFolder folder = getFolder(path);
            var       files  = new List <SWIFile>();

            if (folder.right > 0)
            {
                foreach (string newPath in Directory.GetFiles(folder.GetFullPath(), "*.*"))
                {
                    if (folder.files && FileHelper.IsSealReportFile(newPath))
                    {
                        continue;
                    }

                    files.Add(new SWIFile()
                    {
                        path     = folder.Combine(Path.GetFileName(newPath)),
                        name     = Repository.TranslateFileName(newPath) + (FileHelper.IsSealReportFile(newPath) ? "" : Path.GetExtension(newPath)),
                        last     = System.IO.File.GetLastWriteTime(newPath).ToString("G", Repository.CultureInfo),
                        isReport = FileHelper.IsSealReportFile(newPath),
                        right    = folder.right
                    });
                }
            }
            SetCookie(SealLastFolderCookieName, path);
        }
Exemplo n.º 6
0
        public ActionResult SWIGetFolderDetail(string path)
        {
            writeDebug("SWIGetFolderDetail");
            try
            {
                SWIFolder folder = getFolder(path);
                var       files  = new List <SWIFile>();
                if (folder.right > 0)
                {
                    foreach (string newPath in Directory.GetFiles(folder.GetFullPath(), "*.*"))
                    {
                        //check right on files only
                        if (folder.files && FileHelper.IsSealReportFile(newPath))
                        {
                            continue;
                        }
                        if (folder.IsPersonal && newPath.ToLower() == WebUser.ProfilePath.ToLower())
                        {
                            continue;
                        }

                        files.Add(new SWIFile()
                        {
                            path     = folder.Combine(Path.GetFileName(newPath)),
                            name     = Repository.TranslateFileName(newPath) + (FileHelper.IsSealReportFile(newPath) ? "" : Path.GetExtension(newPath)),
                            last     = System.IO.File.GetLastWriteTime(newPath).ToString("G", Repository.CultureInfo),
                            isreport = FileHelper.IsSealReportFile(newPath),
                            right    = folder.right
                        });
                    }
                }
                setCookie(SealLastFolderCookieName, path);

                return(Json(new SWIFolderDetail()
                {
                    folder = folder, files = files.ToArray()
                }));
            }
            catch (Exception ex)
            {
                return(HandleSWIException(ex));
            }
        }