public async Task <IActionResult> CreateJexus(JexusOptions jexusOptions)
        {
            //表单检查
            if (!ModelState.IsValid)
            {
                return(View(jexusOptions));
            }

            //构建配置文件内容
            JexusSH jexusSH = new JexusSH(jexusOptions);
            await jexusSH.JexusBuild();

            //构建配置文件及生成数据库数据
            CreateDirOrFile createDirOrFile = new CreateDirOrFile();
            JexusSql        jexusSql        = new JexusSql();

            jexusSql.Email    = jexusOptions.email;
            jexusSql.Sitename = jexusOptions.Sitename;
            jexusSql.SHType   = "Jexus";

            var jq = await createDirOrFile.CreateJexusSh(jexusSH.Re(), _sqlContext, jexusSql);

            ViewBag.host = HttpContext.Request.Host;

            return(Redirect("./JexusSH?DownM=" + jq.DownM));
        }
        public async Task <JexusSql> CreateJexusSh(List <string> shList, SQLContext context, JexusSql jexusSql)
        {
            string dirPath = shDir + @"/" + DateTime.Now.Date.ToString("yyyyMMdd");

            if (!Directory.Exists(dirPath))
            {
                Directory.CreateDirectory(dirPath);
            }

            string filename = DateTime.Now.ToString("yyyyMMddHHmmssff");
            var    filepath = dirPath + @"/" + filename + ".sh";

            //在硬盘中写入文件、在数据库中生成数据
            await Task.Run(() =>
            {
                FileStream fileStream     = new FileStream(filepath, FileMode.Create);
                StreamWriter streamWriter = new StreamWriter(fileStream);
                //写入命令到 sh
                streamWriter.WriteLine("cd /usr/jexus/siteconf");
                streamWriter.WriteLine("echo >" + jexusSql.Sitename);
                foreach (var i in shList)
                {
                    streamWriter.WriteLine(@"echo " + "\"" + i + "\"");
                }

                streamWriter.WriteLine("cd /usr/jexus");
                streamWriter.WriteLine("./jws strat " + jexusSql.Sitename);
                //写入结束
                streamWriter.Close();
                fileStream.Close();
                //写入数据库
                jexusSql.DateTime = DateTime.Now;
                jexusSql.FilePath = filepath;
                jexusSql.DownM    = filename;
                context.jexusSqls.Add(jexusSql);
                context.SaveChanges();
            });

            return(jexusSql);
        }