コード例 #1
0
        public void ProcessRequest(HttpRequest request, ISite site)
        {
            string[] tmp = new string[request.UploadedFiles.Count];
            request.UploadedFiles.Keys.CopyTo(tmp, 0);
            BinaryReader br = new BinaryReader(request.UploadedFiles[tmp[0]].Stream);
            MemoryStream ms = new MemoryStream();
            BinaryWriter bw = new BinaryWriter(ms);

            while (br.BaseStream.Position < br.BaseStream.Length)
            {
                bw.Write(br.ReadBytes(1024));
            }
            br.Close();
            bw.Flush();
            request.ResponseWriter.Write(FileCache.CacheFile(ms.ToArray()));
            bw.Close();
        }
コード例 #2
0
        private async Task <bool> ExecuteAsync(bool replaceJobsFile, ILog logHelper)
        {
            var retVal = true;

            if (replaceJobsFile)
            {
                if (Network.IsOnline)
                {
                    var artifactTemplates = BuildDependency.DependencyFile.LoadFile(DependencyFile, logHelper);
                    await BuildDependency.JobsFile.WriteJobsFileAsync(JobsFile, artifactTemplates);

                    if (FileCache.Enabled)
                    {
                        FileCache.CacheFile(JobsFile, JobsFile);
                    }
                }
                else if (FileCache.Enabled)
                {
                    var cachedJobsFile = FileCache.GetCachedFile(JobsFile);
                    if (File.Exists(cachedJobsFile))
                    {
                        File.Copy(cachedJobsFile, JobsFile, true);
                    }
                }
            }

            var jobs = BuildDependency.JobsFile.ReadJobsFile(JobsFile);

            var tasks = jobs.OfType <DownloadFileJob>().Select(job => job.Execute(logHelper, WorkingDir)).ToArray();

            foreach (var task in tasks)
            {
                retVal &= await task;
            }
            tasks = jobs.OfType <UnzipFilesJob>().Select(job => job.Execute(logHelper, WorkingDir)).ToArray();
            foreach (var task in tasks)
            {
                retVal &= await task;
            }
            return(retVal);
        }