public void Run(ErlangEditor.Core.Entity.NodeEntity aEntity) { if(prc_ != null) { try { prc_.Kill(); } catch { } prc_ = null; } if (string.IsNullOrWhiteSpace(ErlangEditor.Core.ConfigUtil.Config.ConsolePath) || string.IsNullOrWhiteSpace(ErlangEditor.Core.ConfigUtil.Config.ShellPath) || !System.IO.File.Exists(ErlangEditor.Core.ConfigUtil.Config.ConsolePath) || !System.IO.File.Exists(ErlangEditor.Core.ConfigUtil.Config.ShellPath)) throw new Exception("Erlang shell设置有误,请在\"设置\"页设置好shell路径。"); var prc = new Process(); prc.StartInfo = new ProcessStartInfo(); prc.StartInfo.CreateNoWindow = !aEntity.ShowShell; prc.StartInfo.FileName = aEntity.ShowShell ? ErlangEditor.Core.ConfigUtil.Config.ShellPath : ErlangEditor.Core.ConfigUtil.Config.ConsolePath; var sln = ErlangEditor.Core.SolutionUtil.Solution; var pathSB = new StringBuilder(1024); var startupSB = new StringBuilder(1024); var pas = string.Empty; //这个...比较矛盾 foreach (var i in aEntity.Apps) { if (sln.Apps.Any(j => j.Name == i)) { var app = sln.Apps.First(j => j.Name == i); var path = string.Empty; path = System.IO.Path.Combine(ErlangEditor.Core.Helper.EntityTreeUtil.GetPath(app), "ebin"); //pas += string.Concat(app.IncludePath.Select(x => string.Format("-pa {0} ", x))); if(!string.IsNullOrWhiteSpace(path)) pathSB.AppendFormat("-pz \"{0}\" ", path); if (app.StartupAsMFA && !string.IsNullOrWhiteSpace(app.StartupMFA)) { startupSB.AppendFormat("-s {0} ", app.StartupMFA); } } } prc.StartInfo.Arguments = string.Format("-name {0} " , aEntity.NodeName) + pathSB.ToString() + pas + startupSB.ToString(); prc.StartInfo.UseShellExecute = false; prc.StartInfo.WorkingDirectory = ErlangEditor.Core.Helper.EntityTreeUtil.GetBasePath; //prc.StartInfo.RedirectStandardInput = prc.StartInfo.RedirectStandardOutput = true; prc.StartInfo.WindowStyle = aEntity.ShowShell ? ProcessWindowStyle.Normal : ProcessWindowStyle.Hidden; prc.EnableRaisingEvents = true; prc.Exited += (a, b) => { var evt = Closed; if (evt != null) evt(this, new ShellClosedEventArgs()); prc_ = null; }; prc.OutputDataReceived += (a, b) => { var evt = NewOutput; if (evt != null) evt(this, new NewOutputLineEventArgs { NodeName = aEntity.NodeName, Data = b.Data }); }; prc_ = prc; prc.Start(); prc.BeginOutputReadLine(); }
public RecentProjectVM(ErlangEditor.Core.Entity.RecentProjectEntity aEntity) { Entity = aEntity; if (aEntity != null) { Path = aEntity.Path; Title = aEntity.Title; } }
public NodeVM(ErlangEditor.Core.Entity.NodeEntity aEntity) { Entity = aEntity; if (aEntity != null) { Name = aEntity.NodeName; } Proxy = new RunProxy.SolutionRunner(); Proxy.Closed += (a, b) => { State = false; ErlangEditor.Core.NodeUtil.StopNode(aEntity.NodeName); }; AppNames = new ObservableCollection<string>(); foreach (var i in aEntity.Apps) AppNames.Add(i); Proxy.NewOutput += (a, b) => { Dispatcher.Invoke(new Action(() => { App.MainViewModel.Output.Add(new OutputVM { NodeName = b.NodeName, Info = b.Data }); })); }; }
private void FileCompiled(ErlangEditor.Core.Entity.FileEntity aEntity) { var libPath = System.IO.Path.Combine(ErlangEditor.Core.Helper.EntityTreeUtil.GetBasePath, ErlangEditor.Core.SolutionUtil.Solution.Name); var src = ErlangEditor.Core.Helper.EntityTreeUtil.GetParent(aEntity); var app = ErlangEditor.Core.Helper.EntityTreeUtil.GetParent(src) as ErlangEditor.Core.Entity.ApplicationEntity; var appPath = ErlangEditor.Core.Helper.EntityTreeUtil.GetPath(app); if (aEntity.IsAppFile) { var souPath = System.IO.Path.Combine(appPath, "ebin", aEntity.DisplayName); var tarPath = System.IO.Path.Combine(libPath, app.Name, "ebin", aEntity.DisplayName); lstCopy_.Add(new Tuple<string,string>(souPath, tarPath)); } else { var souPath = System.IO.Path.Combine(appPath, "ebin", aEntity.DisplayName + ".beam"); var tarPath = System.IO.Path.Combine(libPath, app.Name, "ebin", aEntity.DisplayName + ".beam"); lstCopy_.Add(new Tuple<string,string>(souPath, tarPath)); } pb.Value++; Debug.WriteLine(pb.Value); }
public void ScanBin(ErlangEditor.Core.Entity.ApplicationEntity aEntity) { if (string.IsNullOrWhiteSpace(ErlangEditor.Core.ConfigUtil.Config.ConsolePath) || string.IsNullOrWhiteSpace(ErlangEditor.Core.ConfigUtil.Config.ShellPath) || !System.IO.File.Exists(ErlangEditor.Core.ConfigUtil.Config.ConsolePath) || !System.IO.File.Exists(ErlangEditor.Core.ConfigUtil.Config.ShellPath)) throw new Exception("Erlang shell设置有误,请在\"设置\"页设置好shell路径。"); var lstBeam = new List<string>(); foreach (var j in new ErlangEditor.Core.Entity.ApplicationEntity[] { aEntity }) { var ebin = j.Folders.First(i => i.Name == "ebin"); var ebinpath = ErlangEditor.Core.Helper.EntityTreeUtil.GetPath(ebin); foreach (var i in j.Folders.First(x => x.Name == "src").Files) { var filepath = System.IO.Path.Combine(ebinpath, i.DisplayName + ".beam"); if (System.IO.File.Exists(filepath)) { lstBeam.Add(i.DisplayName); dictMods_.Remove(i.DisplayName); } } } if (lstBeam.Count > 0) { var lst = string.Format("[{0}]", string.Join(",", lstBeam)); var prc = new Process(); prc.StartInfo = new ProcessStartInfo(); prc.StartInfo.CreateNoWindow = true; prc.StartInfo.FileName = ErlangEditor.Core.ConfigUtil.Config.ConsolePath; prc.StartInfo.Arguments = string.Format("-noshell +pc unicode -eval \"" + "L = {0}," + "B = fun(X)-> lists:map(fun({{A,B}})-> io:format(\\\"~p,~p,~p~n\\\",[X,A,B]) end, X:module_info(exports)) end," + "lists:map(fun(X)-> B(X) end, L)," + "io:format(\\\"break00\\\")," + "M = fun(X)-> lists:map(fun({{A,V}})->if A=:=msummary-> io:format(\\\"~p,~ts~n\\\",[X,V]);true->ok end end, X:module_info(attributes)) end," + "try lists:map(fun(X)-> M(X) end, L) catch _:_->io:format(\\\"\\\") end," + "io:format(\\\"break00\\\")," + "S = fun(X)-> lists:map(fun({{A,V}})->if A=:=summary->[{{F,Arity,D}}] = V, io:format(\\\"~p,~p,~p,~ts~n\\\",[X,F,Arity,D]);true->ok end end, X:module_info(attributes)) end," + "try lists:map(fun(X)-> S(X) end, L) catch _:_->io:format(\\\"\\\") end," + "init:stop().\" {1}", lst, " -pa " + System.IO.Path.Combine(ErlangEditor.Core.Helper.EntityTreeUtil.GetPath(aEntity) + "\\ebin")); prc.StartInfo.UseShellExecute = false; prc.StartInfo.WorkingDirectory = ErlangEditor.Core.Helper.EntityTreeUtil.GetBasePath; prc.StartInfo.RedirectStandardOutput = true; prc.StartInfo.WindowStyle = ProcessWindowStyle.Hidden; prc.EnableRaisingEvents = true; prc.StartInfo.StandardOutputEncoding = Encoding.UTF8; prc.Start(); var result = prc.StandardOutput.ReadToEnd(); UpdateDict(result); prc.WaitForExit(30000); } }
public void ScanAllBin(ErlangEditor.Core.Entity.SolutionEntity aSln) { FreeCache(); ScanBin(aSln); }
public void DropApplication(ErlangEditor.Core.Entity.ApplicationEntity aEntity) { foreach (var i in aEntity.Folders.First(x => x.Name == "src").Files) { dictMods_.Remove(i.DisplayName); } }