public void Build(ExecutionCompletedHandler handler = null) { Status = ApplicationStatus.Building; if (AppEnvironment.Settings.TestMode) { SolutionObj = new DummySolution(WorkSpace, Solution); } else { SolutionObj = new Solution(WorkSpace, Solution); } SolutionObj.ExecutionCompleted += handler; SolutionObj.ExecutionCompleted += (s, e) => { var buildResults = BuildResults.FromOutput(SolutionObj.Output); StatusMessage = buildResults.ToString(); if (buildResults.Success) { Status = ApplicationStatus.BuildCompleted; } else { Status = ApplicationStatus.BuildFailed; } }; var binaries = WorkSpace + Path.GetDirectoryName(Solution) + BinaryDirectory; OutputDirectory = GetNextOutputDirectory(); SolutionObj.BuildAsync(binaries, OutputDirectory); SetActiveApplication(_parent); Status = ApplicationStatus.Building; }
public static Executable RunCommandAsync(string fileName, string args, DataReceivedEventHandler eventhandler = null, ExecutionCompletedHandler completedHandler = null) { var executable = new Executable(fileName); executable.ExecutionCompleted += completedHandler; executable.RunAsync(args, eventHandler: eventhandler); return(executable); }
public void Execute(object sender, string sql, ExecutionCompletedHandler executionCompleted, ServiceExceptionHandler errorReceived) { string uriString = String.Format(ServicePoint + "/Services/execute.ashx?sql={0}", sql); HttpWebRequest client = WebRequest.CreateHttp(uriString); client.BeginGetResponse((async) => { HttpWebResponse res=null; try { res = (HttpWebResponse)client.EndGetResponse(async); } catch (Exception v) { Exception vv=new Exception(v.Message + " URL : " + uriString); if (errorReceived != null) errorReceived(async.AsyncState, new ServiceException(EErrorType.REQUEST, "Response error.")); return; } if (res.ContentType.Contains("text/result")) { int r=-1; Stream str=res.GetResponseStream(); using (StreamReader sr=new StreamReader(str)) { string s=sr.ReadToEnd(); int.TryParse(s, out r); } executionCompleted(async.AsyncState, r ); } else { //REQUEST,SERVER,READER,NODATA Stream str = res.GetResponseStream(); string s=String.Empty; string[] ss=null; string f=String.Empty; using (StreamReader sr = new StreamReader(str)) { s = sr.ReadToEnd(); } if (s != String.Empty) ss = s.Split(new char[] { '=' }, StringSplitOptions.RemoveEmptyEntries); EErrorType et=EErrorType.UNKNOWN; f = ss == null ? "UNKNOWN" : ss[0]; Enum.TryParse(f, out et); ServiceException ex=new ServiceException(et, ss[1]); if (errorReceived != null) errorReceived(async.AsyncState, ex); } }, sender); }