using Newtonsoft.Json; using System; using System.Collections.Generic; using System.Linq; using System.Web; using System.Configuration; using System.Diagnostics; namespace VRS.Handler { /// /// GetCosSign 的摘要说明 /// public class GetCosSign : IHttpHandler { private string sign = ""; public void ProcessRequest(HttpContext context) { runpptcmd(); context.Response.ContentType = "text/plain"; context.Response.Write(sign); } public void runpptcmd(string args = "", string material_id = "", params string[] teps) { Process p = new Process(); string path = ""; p.StartInfo.FileName = @"C:\Program Files\dotnet\dotnet.exe"; string sArguments = path; foreach (string sigstr in teps) { sArguments += " " + sigstr; //传递参数 } //sArguments += " " + args; //args = @"E:\netcoreapp2.1\demo.dll"; // args = ConfigurationManager.AppSettings["cos_sign_path"]; sArguments += " " + args + material_id; p.StartInfo.Arguments = sArguments; p.StartInfo.UseShellExecute = false; p.StartInfo.RedirectStandardOutput = true; p.StartInfo.RedirectStandardInput = true; p.StartInfo.RedirectStandardError = true; p.StartInfo.CreateNoWindow = true; p.Start(); p.BeginOutputReadLine(); p.OutputDataReceived += new DataReceivedEventHandler(p_OutputWin); p.WaitForExit(); } void p_OutputWin(object sender, DataReceivedEventArgs e) { if (!string.IsNullOrEmpty(e.Data)) { sign = e.Data; } } public bool IsReusable { get { return false; } } } }