void BuildProjects(BuildContext ctx, ServerEventArgs ev) { foreach (SourceInfo source in ctx.Server.GetSources(ctx.AppId)) { if (ev.ProjectId != -1 && ev.ProjectId != source.ProjectId) { continue; } foreach (SourceTagInfo stag in source.SourceTags) { try { string sourcesPath = source.GetAddinSourcePath(ctx, stag); if (!Directory.Exists(sourcesPath) || !Directory.Exists(stag.GetPackagePath(ctx)) || stag.Status == SourceTagStatus.Waiting) { BuildSource(ctx, source, stag); } } catch (Exception ex) { try { File.AppendAllText(stag.GetLogFile(ctx), "<pre>" + HttpUtility.HtmlEncode(ex.ToString()) + "</pre>"); PushFiles(ctx, source, stag, true); ctx.Server.SetSourceTagStatus(ctx.AppId, stag.Id, SourceTagStatus.BuildError); } catch { } } } } }
void Build(BuildContext ctx, ServerEventArgs ev) { try { ctx.ServerSettings = ctx.Server.GetSettings(); } catch (Exception ex) { HandleError(ctx, ex); return; } foreach (ApplicationInfo app in ctx.ServerSettings.Applications.Where(ap => ev.AppId == -1 || ev.AppId == ap.Id)) { try { ctx.Application = app; UpdateSourceTags(ctx, ev); BuildProjects(ctx, ev); } catch (Exception ex) { if (!HandleError(ctx, ex)) { return; } } } try { ctx.Status = "Waiting"; } catch (Exception ex) { HandleError(ctx, ex); return; } }
void HandleEvent(object sender, ServerEventArgs e) { LogService.WriteLine("Got event: " + e.AppId + " " + e.ProjectId + " " + e.EventId + " " + e.EventArgs); lock (eventQueue) { eventQueue.Enqueue(e); } buildEvent.Set(); }
void QueueBuildAll() { ServerEventArgs e = new ServerEventArgs() { EventId = "BuildAll", AppId = -1, ProjectId = -1 }; lock (eventQueue) { eventQueue.Enqueue(e); } }
public void UpdateSourceTags(BuildContext ctx, ServerEventArgs ev) { ctx.Status = "Updating version control source tags"; foreach (SourceInfo s in ctx.Server.GetSources(ctx.AppId)) { if (ev.ProjectId != -1 && s.ProjectId != ev.ProjectId) { continue; } ctx.Status = "Updating version control source tags for project '" + s.ProjectName + "'"; UpdateSourceTags(ctx, s, true); } }
void ReadEvents() { do { try { string lin; do { lin = eventsReader.ReadLine(); }while (lin != "[event]" && lin != null); if (lin == null) { throw new Exception("Disconnected"); } ServerEventArgs args = new ServerEventArgs(); args.EventId = eventsReader.ReadLine(); args.AppId = int.Parse(eventsReader.ReadLine()); args.ProjectId = int.Parse(eventsReader.ReadLine()); int nargs = int.Parse(eventsReader.ReadLine()); List <string> eargs = new List <string> (); for (int n = 0; n < nargs; n++) { eargs.Add(eventsReader.ReadLine()); } args.EventArgs = eargs.ToArray(); if (Event != null) { Event(this, args); } } catch (Exception ex) { try { eventsReader.Close(); } catch { } Connected = false; eventsThread = null; eventsReader = null; ThreadPool.QueueUserWorkItem(delegate { if (Disconnected != null) { Disconnected(this, EventArgs.Empty); } }); return; } } while (true); }
void QueueBuildAll() { ServerEventArgs e = new ServerEventArgs () { EventId = "BuildAll" }; lock (eventQueue) { eventQueue.Enqueue (e); } }
void HandleEvent(object sender, ServerEventArgs e) { lock (eventQueue) { eventQueue.Enqueue (e); } buildEvent.Set (); }
void BuildProjects(BuildContext ctx, ServerEventArgs ev) { foreach (SourceInfo source in ctx.Server.GetSources (ctx.AppId)) { if (ev.ProjectId != -1 && ev.ProjectId != source.ProjectId) continue; foreach (SourceTagInfo stag in source.SourceTags) { try { string sourcesPath = source.GetAddinSourcePath (ctx, stag); if (!Directory.Exists (sourcesPath) || !Directory.Exists (stag.GetPackagePath (ctx)) || stag.Status == SourceTagStatus.Waiting) { BuildSource (ctx, source, stag); } } catch (Exception ex) { try { File.AppendAllText (stag.GetLogFile (ctx), "<pre>" + HttpUtility.HtmlEncode (ex.ToString ()) + "</pre>"); PushFiles (ctx, source, stag, true); ctx.Server.SetSourceTagStatus (ctx.AppId, stag.Id, SourceTagStatus.BuildError); } catch { } } } } }
void Build(BuildContext ctx, ServerEventArgs ev) { try { ctx.ServerSettings = ctx.Server.GetSettings (); } catch (Exception ex) { HandleError (ctx, ex); return; } foreach (ApplicationInfo app in ctx.ServerSettings.Applications.Where (ap => ev.AppId == -1 || ev.AppId == ap.Id)) { try { ctx.Application = app; UpdateSourceTags (ctx, ev); BuildProjects (ctx, ev); } catch (Exception ex) { if (!HandleError (ctx, ex)) return; } } try { ctx.Status = "Waiting"; } catch (Exception ex) { HandleError (ctx, ex); return; } }
public void UpdateSourceTags(BuildContext ctx, ServerEventArgs ev) { ctx.Status = "Updating version control source tags"; foreach (SourceInfo s in ctx.Server.GetSources (ctx.AppId)) { if (ev.ProjectId != -1 && s.ProjectId != ev.ProjectId) continue; ctx.Status = "Updating version control source tags for project '" + s.ProjectName + "'"; UpdateSourceTags (ctx, s, true); } }
void ReadEvents() { do { try { string lin; do { lin = eventsReader.ReadLine (); } while (lin != "[event]" && lin != null); if (lin == null) throw new Exception ("Disconnected"); ServerEventArgs args = new ServerEventArgs (); args.EventId = eventsReader.ReadLine (); Console.WriteLine ("Got event " + args.EventId); args.AppId = int.Parse (eventsReader.ReadLine ()); args.ProjectId = int.Parse (eventsReader.ReadLine ()); int nargs = int.Parse (eventsReader.ReadLine ()); List<string> eargs = new List<string> (); for (int n=0; n<nargs; n++) eargs.Add (eventsReader.ReadLine ()); args.EventArgs = eargs.ToArray (); if (Event != null) Event (this, args); } catch { try { eventsReader.Close (); } catch { } Connected = false; eventsThread = null; eventsReader = null; ThreadPool.QueueUserWorkItem (delegate { if (Disconnected != null) Disconnected (this, EventArgs.Empty); }); return; } } while (true); }
void QueueBuildAll() { ServerEventArgs e = new ServerEventArgs () { EventId = "BuildAll", AppId=-1, ProjectId=-1 }; lock (eventQueue) { eventQueue.Enqueue (e); } }
void HandleEvent(object sender, ServerEventArgs e) { LogService.WriteLine ("Got event: " + e.AppId + " " + e.ProjectId + " " + e.EventId + " " + e.EventArgs); lock (eventQueue) { eventQueue.Enqueue (e); } buildEvent.Set (); }