示例#1
0
 public static Bitmap GetImage(string img_name, Subfolders sub)//get image from source using image name and subfolder
 {
     using (Image img = Image.FromFile(Path.Combine(basePath, sub.ToString(), img_name)))
     {
         return(new Bitmap(img));
     }
 }
示例#2
0
        public IEnumerable <KeyValuePair <string, string> > GetInfoPairs()
        {
            var list = new List <KeyValuePair <string, string> >();

            list.Add(new KeyValuePair <string, string>("diskcache_autoclean", AutoClean ? "1" : "0"));
            list.Add(new KeyValuePair <string, string>("diskcache_asyncwrites", AsyncWrites ? "1" : "0"));
            list.Add(new KeyValuePair <string, string>("diskcache_subfolders", Subfolders.ToString()));
            list.Add(new KeyValuePair <string, string>("diskcache_network_drive", CacheDriveOnNetwork() ? "1" : "0"));
            list.Add(new KeyValuePair <string, string>("diskcache_filesystem", GetCacheDrive()?.DriveFormat ?? ""));
            list.Add(new KeyValuePair <string, string>("diskcache_drive_avail", GetCacheDrive()?.AvailableFreeSpace.ToString() ?? ""));
            list.Add(new KeyValuePair <string, string>("diskcache_drive_total", GetCacheDrive()?.TotalSize.ToString() ?? ""));
            list.Add(new KeyValuePair <string, string>("diskcache_virtualpath", VirtualCacheDir));
            return(list);
        }
示例#3
0
        public IEnumerable <IIssue> GetIssues()
        {
            List <IIssue> issues = new List <IIssue>();

            if (cleaner != null)
            {
                issues.AddRange(cleaner.GetIssues());
            }

            if (!c.get("diskcache.hashModifiedDate", true))
            {
                issues.Add(new Issue("DiskCache", "V4.0 no longer supports hashModifiedDate=false. Please remove this attribute.", IssueSeverity.ConfigurationError));
            }

            if (!HasFileIOPermission())
            {
                issues.Add(new Issue("DiskCache", "Failed to start: Write access to the cache directory is prohibited by your .NET trust level configuration.",
                                     "Please configure your .NET trust level to permit writing to the cache directory. Most medium trust configurations allow this, but yours does not.", IssueSeverity.ConfigurationError));
            }

            if (!HasNTFSPermission())
            {
                issues.Add(new Issue("DiskCache", "Not working: Your NTFS Security permissions are preventing the application from writing to the disk cache",
                                     "Please give user " + GetExecutingUser() + " read and write access to directory \"" + PhysicalCacheDir + "\" to correct the problem. You can access NTFS security settings by right-clicking the aforementioned folder and choosing Properties, then Security.", IssueSeverity.ConfigurationError));
            }

            if (!Started && !Enabled)
            {
                issues.Add(new Issue("DiskCache", "DiskCache is disabled in Web.config. Set enabled=true on the <diskcache /> element to fix.", null, IssueSeverity.ConfigurationError));
            }

            //Warn user about setting hashModifiedDate=false in a web garden.
            if (this.AsyncBufferSize < 1024 * 1024 * 2)
            {
                issues.Add(new Issue("DiskCache", "The asyncBufferSize should not be set below 2 megabytes (2097152). Found in the <diskcache /> element in Web.config.",
                                     "A buffer that is too small will cause requests to be processed synchronously. Remember to set the value to at least 4x the maximum size of an output image.", IssueSeverity.ConfigurationError));
            }


            if (CacheDriveOnNetwork())
            {
                issues.Add(new Issue("DiskCache", "It appears that the cache directory is located on a network drive.",
                                     "Both IIS and ASP.NET have trouble hosting websites with large numbers of folders over a network drive, such as a SAN. The cache will create " +
                                     Subfolders.ToString() + " subfolders. If the total number of network-hosted folders exceeds 100, you should contact [email protected] and consult the documentation for details on configuring IIS and ASP.NET for this situation.", IssueSeverity.Warning));
            }

            return(issues);
        }
示例#4
0
        public static void SaveImage(OpenFileDialog openfile, Subfolders sub)
        {
            string savePath = Path.Combine(basePath, sub.ToString()); //Remote SubFolder path

            if (!Directory.Exists(basePath))
            {
                Directory.CreateDirectory(basePath);
            }
            if (!Directory.Exists(savePath))
            {
                Directory.CreateDirectory(savePath);
            }
            //save to remote destination
            var destination = Path.Combine(savePath, openfile.SafeFileName);

            File.Copy(openfile.FileName, destination, true); //Overwrite set to true
        }
示例#5
0
        public IEnumerable <IIssue> GetIssues()
        {
            List <IIssue> issues = new List <IIssue>();

            if (cleaner != null)
            {
                issues.AddRange(cleaner.GetIssues());
            }

            if (!HasFileIOPermission())
            {
                issues.Add(new Issue("DiskCache", "Failed to start: Write access to the cache directory is prohibited by your .NET trust level configuration.",
                                     "Please configure your .NET trust level to permit writing to the cache directory. Most medium trust configurations allow this, but yours does not.", IssueSeverity.ConfigurationError));
            }

            if (!HasNTFSPermission())
            {
                issues.Add(new Issue("DiskCache", "Not working: Your NTFS Security permissions are preventing the application from writing to the disk cache",
                                     "Please give user " + GetExecutingUser() + " read and write access to directory \"" + PhysicalCacheDir + "\" to correct the problem. You can access NTFS security settings by right-clicking the aformentioned folder and choosing Properties, then Security.", IssueSeverity.ConfigurationError));
            }

            if (!Started && !Enabled)
            {
                issues.Add(new Issue("DiskCache", "DiskCache is disabled in Web.config. Set enabled=true on the <diskcache /> element to fix.", null, IssueSeverity.ConfigurationError));
            }

            //Warn user about setting hashModifiedDate=false in a web garden.
            if (this.cleaner != null && cleaner.ExteralProcessCleaning && !this.HashModifiedDate)
            {
                issues.Add(new Issue("DiskCache", "You should set hashModifiedDate=\"true\" on the <diskcache /> element in Web.config.",
                                     "Setting false for this value in a Web Garden scenario can cause failed requests. (DiskCache detects one or more other process on this machine working on the same cache directory).", IssueSeverity.Critical));
            }
            if (this.AsyncBufferSize < 1024 * 1024 * 2)
            {
                issues.Add(new Issue("DiskCache", "The asyncBufferSize should not be set below 2 megabytes (2097152). Found in the <diskcache /> element in Web.config.",
                                     "A buffer that is too small will cause requests to be processed synchronously. Remember to set the value to at least 4x the maximum size of an output image.", IssueSeverity.ConfigurationError));
            }

            string physicalCache = PhysicalCacheDir;

            if (!string.IsNullOrEmpty(physicalCache))
            {
                bool isNetwork = false;
                if (physicalCache.StartsWith("\\\\"))
                {
                    isNetwork = true;
                }
                else
                {
                    try {
                        DriveInfo dri = new DriveInfo(Path.GetPathRoot(physicalCache));
                        if (dri.DriveType == DriveType.Network)
                        {
                            isNetwork = true;
                        }
                    } catch { }
                }
                if (isNetwork)
                {
                    issues.Add(new Issue("DiskCache", "It appears that the cache directory is located on a network drive.",
                                         "Both IIS and ASP.NET have trouble hosting websites with large numbers of folders over a network drive, such as a SAN. The cache will create " +
                                         Subfolders.ToString() + " subfolders. If the total number of network-hosted folders exceeds 100, you should contact [email protected] and consult the documentation for details on configuring IIS and ASP.NET for this situation.", IssueSeverity.Warning));
                }
            }

            return(issues);
        }
示例#6
0
 public static void DeleteImage(Subfolders sub, string image_name)
 {
     File.Delete(Path.Combine(basePath, sub.ToString(), image_name));
 }