Beispiel #1
0
        protected void SetSourceFiles(string sDir)
        {
            List <FileData> flsWorking  = new List <FileData>();
            List <FileData> fldrWorking = new List <FileData>();

            List <string> lstFileExtensions = new List <string>();

            lstFileExtensions.Add(".css");
            lstFileExtensions.Add(".js");
            lstFileExtensions.Add(".ascx");
            lstFileExtensions.Add(".master");

            if (Directory.Exists(sDir))
            {
                string sDirParent = "";

                if (sDir.LastIndexOf(@"\") > 0)
                {
                    sDirParent = sDir.Substring(0, sDir.LastIndexOf(@"\"));
                }
                else
                {
                    sDirParent = sDir.Substring(0, sDir.LastIndexOf(@"/"));
                }

                FileData skinFolder = helpFile.GetFolderInfo("/", sDir);

                skinFolder.FolderPath = FileDataHelper.MakeWebFolderPath(sDir);

                fldrWorking = helpFile.SpiderDeepFoldersFD(FileDataHelper.MakeWebFolderPath(sDir));

                fldrWorking.Add(skinFolder);

                try {
                    if (Directory.Exists(Server.MapPath("~/includes")))
                    {
                        FileData incFolder = helpFile.GetFolderInfo("/", Server.MapPath("~/includes"));
                        fldrWorking.Add(incFolder);
                    }
                    if (Directory.Exists(Server.MapPath("~/js")))
                    {
                        FileData incFolder = helpFile.GetFolderInfo("/", Server.MapPath("~/js"));
                        fldrWorking.Add(incFolder);
                    }
                    if (Directory.Exists(Server.MapPath("~/css")))
                    {
                        FileData incFolder = helpFile.GetFolderInfo("/", Server.MapPath("~/css"));
                        fldrWorking.Add(incFolder);
                    }
                } catch (Exception ex) { }

                helpFile.IncludeAllFiletypes();

                foreach (FileData f in fldrWorking)
                {
                    List <FileData> fls = helpFile.GetFiles(f.FolderPath);

                    flsWorking = (from m in flsWorking.Union(fls).ToList()
                                  join e in lstFileExtensions on m.FileExtension.ToLowerInvariant() equals e
                                  select m).ToList();
                }

                flsWorking = flsWorking.Where(x => x.MimeType.StartsWith("text") && (x.FolderPath.ToLowerInvariant().StartsWith(SiteData.AdminFolderPath) == false)).ToList();

                GeneralUtilities.BindRepeater(rpFiles, flsWorking.Distinct().OrderBy(x => x.FileName).OrderBy(x => x.FolderPath).ToList());
            }
        }
Beispiel #2
0
        protected List <FileData> SetSourceFiles(string templateFileUri)
        {
            List <FileData> flsWorking  = new List <FileData>();
            List <FileData> fldrWorking = new List <FileData>();

            List <string> lstFileExtensions = new List <string>();

            lstFileExtensions.Add(".css");
            lstFileExtensions.Add(".js");
            lstFileExtensions.Add(".cshtml");

            HttpServerUtility server = HttpContext.Current.Server;

            string templateFile = server.MapPath(templateFileUri);

            if (File.Exists(templateFile))
            {
                templateFile = templateFile.Replace(@"/", @"\");

                string skinPath = templateFile.Substring(0, templateFile.LastIndexOf(@"\")).ToLowerInvariant();
                string skinName = skinPath.Substring(skinPath.LastIndexOf(@"\") + 1);

                FileData skinFolder = helpFile.GetFolderInfo("/", templateFile);
                skinFolder.FolderPath = FileDataHelper.MakeWebFolderPath(templateFile);
                fldrWorking           = helpFile.SpiderDeepFoldersFD(FileDataHelper.MakeWebFolderPath(templateFile));
                fldrWorking.Add(skinFolder);

                try {
                    string assetPath = String.Format("~/assets/{0}", skinName);

                    if (Directory.Exists(server.MapPath(assetPath)))
                    {
                        FileData incFolder = helpFile.GetFolderInfo("/", server.MapPath(assetPath));
                        fldrWorking.Add(incFolder);

                        var assetFlds = helpFile.SpiderDeepFoldersFD(FileDataHelper.MakeWebFolderPath(incFolder.FolderPath));

                        fldrWorking = fldrWorking.Union(assetFlds).ToList();
                    }
                } catch (Exception ex) { }

                try {
                    if (Directory.Exists(server.MapPath("~/includes")))
                    {
                        FileData incFolder = helpFile.GetFolderInfo("/", server.MapPath("~/includes"));
                        fldrWorking.Add(incFolder);
                    }
                    if (Directory.Exists(server.MapPath("~/js")))
                    {
                        FileData incFolder = helpFile.GetFolderInfo("/", server.MapPath("~/js"));
                        fldrWorking.Add(incFolder);
                    }
                    if (Directory.Exists(server.MapPath("~/css")))
                    {
                        FileData incFolder = helpFile.GetFolderInfo("/", server.MapPath("~/css"));
                        fldrWorking.Add(incFolder);
                    }

                    if (Directory.Exists(server.MapPath("~/Scripts")))
                    {
                        FileData incFolder = helpFile.GetFolderInfo("/", server.MapPath("~/Scripts"));
                        fldrWorking.Add(incFolder);
                    }
                    if (Directory.Exists(server.MapPath("~/Content")))
                    {
                        FileData incFolder = helpFile.GetFolderInfo("/", server.MapPath("~/Content"));
                        fldrWorking.Add(incFolder);
                    }
                } catch (Exception ex) { }

                helpFile.IncludeAllFiletypes();

                foreach (FileData f in fldrWorking)
                {
                    List <FileData> fls = helpFile.GetFiles(f.FolderPath);

                    flsWorking = (from m in flsWorking.Union(fls).ToList()
                                  join e in lstFileExtensions on m.FileExtension.ToLowerInvariant() equals e
                                  select m).ToList();
                }

                flsWorking = flsWorking.Where(x => x.MimeType.StartsWith("text")).ToList();
            }

            if (flsWorking == null)
            {
                flsWorking = new List <FileData>();
            }

            return(flsWorking.Distinct().OrderBy(x => x.FileName).OrderBy(x => x.FolderPath).ToList());
        }