示例#1
0
        }         // proc ICronJobExecute.RunJob

        bool ICronJobExecute.CanRunParallelTo(ICronJobExecute other)
        {
            if (other == this)             // do not run parallel the same job
            {
                return(false);
            }

            if (runAfterJob == null)
            {
                return(true);
            }
            else
            {
                return(!(other is ICronJobItem o) || runAfterJob.FirstOrDefault(c => Procs.IsFilterEqual(o.UniqueName, c)) == null || CanRunParallelTo(o));
            }
        }         // func ICronJobExecute.CanRunParallelTo
示例#2
0
        }         // proc CallFileItemNotify

        #endregion

        #region -- Directory Helper ---------------------------------------------------

        /// <summary>Checks if the file is receivable.</summary>
        /// <param name="fileDescription"></param>
        /// <returns></returns>
        internal bool IsInFileAllowed(IOdetteFile fileDescription)
        {
            if (directoryIn == null)
            {
                return(false);
            }

            if (fileNameFilter == null || fileNameFilter.Length == 0)
            {
                return(true);
            }

            foreach (var cur in fileNameFilter)
            {
                if (Procs.IsFilterEqual(fileDescription.VirtualFileName, cur))
                {
                    return(true);
                }
            }

            return(false);
        }         // func IsInFileAllowed
示例#3
0
        }         // proc OnEndReadConfiguration

        private bool TestFilter(XElement x, string subPath)
        {
            var value = x.GetAttribute <string>("filter", null);

            return(value == null || value.Length == 0 || value == "*" || Procs.IsFilterEqual(subPath, value));
        }         // func TestFilter
示例#4
0
        /// <summary></summary>
        /// <param name="r"></param>
        /// <returns></returns>
        public override async Task <bool> RequestAsync(IDEWebRequestScope r)
        {
            if (String.IsNullOrEmpty(filterPattern))
            {
                return(false);
            }

            // create the full file name
            var useIndex            = false;
            var fullDirectoryName   = this.directoryBase.FullName;
            var fileName            = Path.GetFullPath(Path.Combine(fullDirectoryName, ProcsDE.GetLocalPath(r.RelativeSubPath)));
            var directoryBaseOffset = fullDirectoryName[fullDirectoryName.Length - 1] == Path.DirectorySeparatorChar ? fullDirectoryName.Length - 1 : fullDirectoryName.Length;

            // Check for a directory escape
            if (!fileName.StartsWith(directoryBase.FullName, StringComparison.OrdinalIgnoreCase) ||
                (fileName.Length > directoryBaseOffset && fileName[directoryBaseOffset] != Path.DirectorySeparatorChar))
            {
                return(false);
            }

            // is the filename a directory, add index.html
            if (Directory.Exists(fileName))
            {
                if (!String.IsNullOrEmpty(r.AbsolutePath) && r.AbsolutePath[r.AbsolutePath.Length - 1] != '/')
                {
                    r.Redirect(r.AbsolutePath + '/');
                    return(true);
                }
                else
                {
                    fileName = Path.Combine(fileName, ConfigNode.GetAttribute <string>("indexPage"));
                    useIndex = true;
                }
            }
            else if (filterPattern != "*")             // check for filter pattern
            {
                if (!Procs.IsFilterEqual(Path.GetFileName(fileName), filterPattern))
                {
                    return(false);                    // pattern does not fit
                }
            }

            if (File.Exists(fileName))
            {
                // security
                DemandFile(r, fileName);
                // Send the file
                await Task.Run(() => r.WriteFile(fileName, GetFileContentType(fileName), defaultReadEncoding));

                return(true);
            }
            else if (useIndex && allowListing)             // write index table
            {
                await Task.Run(() => r.WriteResource(typeof(HttpWorker), "Resources.Listing.html", "text/html"));

                return(true);
            }
            else
            {
                return(false);
            }
        }         // func Request