Exemplo n.º 1
0
        public async Task <(List <DefaultDataListDTO> defaultDataList, PageModel pageModel)> GetListAsync(QueryDefaultDataFilterModel model)
        {
            List <DefaultData> allDefaultData = await _defaultDataRepository.GetAllInfoFromCacheAsync();

            DeployConsoleHelper.WriteDebug(allDefaultData == null ? "以从环境获取数据,但为空" : $"以从环境获取数据,数量:{allDefaultData.Count}");
            if (allDefaultData == null)
            {
                return(null, new PageModel(model, 0));
            }
            Func <DefaultData, bool> searchDelegate  = model.GetSearchDelegate <DefaultData>();
            List <DefaultData>       defaultDataList = allDefaultData.Where(searchDelegate).ToList();
            var pageModel = new PageModel(model, defaultDataList.Count);

            defaultDataList = defaultDataList.Skip(model.Skip).Take(model.Take).ToList();
            DeployConsoleHelper.WriteDebug($"已通过条件筛选完毕,数量:{defaultDataList.Count}");
            var result = _mapper.Map <List <DefaultDataListDTO> >(defaultDataList);

            return(result, pageModel);
        }
        /// <summary>
        /// 解压文件
        /// </summary>
        /// <param name="rarFilePath"></param>
        /// <returns></returns>
        private void UnRarFile(string rarFilePath)
        {
            string directoryPath = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "UploadFiles", "Temp", Guid.NewGuid().ToString());

            if (Directory.Exists(directoryPath))
            {
                throw new DeployException("解压失败,请重新上传");
            }
            DirectoryInfo    directoryInfo     = Directory.CreateDirectory(directoryPath);
            var              winRarPath        = Path.Combine(DeployConfig.WinRarPath, "UnRaR.exe");
            string           directoryTempPath = $"x -o+ -y \"{rarFilePath}\" \"{directoryPath}\"";
            ProcessStartInfo processStartInfo  = ProcessManager.GetProcessStartInfo(winRarPath, directoryTempPath);

            DeployConsoleHelper.WriteDebug(directoryTempPath);
            var process = new Process {
                StartInfo = processStartInfo
            };

            void DataHandler(object sender, DataReceivedEventArgs e)
            {
                DeployConsoleHelper.WriteLine(e.Data);
            }

            process.OutputDataReceived += DataHandler;
            process.ErrorDataReceived  += DataHandler;
            if (process.Start())
            {
                process.BeginOutputReadLine();
                process.BeginErrorReadLine();
                process.WaitForExit();
                process.Dispose();
            }
            foreach (DirectoryInfo item in directoryInfo.GetDirectories())
            {
                CopyApplication(item);
            }
            directoryInfo.Delete(true);
        }