WriteLine() public static method

public static WriteLine ( Exception ex ) : void
ex System.Exception
return void
コード例 #1
0
 static Settings()
 {
     try {
         string file = "cydin.config";
         if (!File.Exists(file))
         {
             file = Path.Combine("/etc/", "cydin.config");
             if (!File.Exists(file))
             {
                 file = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.Personal), ".config");
                 file = Path.Combine(file, "cydin.config");
                 if (!File.Exists(file))
                 {
                     Default = new Settings();
                     return;
                 }
             }
         }
         XmlSerializer ser = new XmlSerializer(typeof(Settings));
         using (StreamReader sr = new StreamReader(file)) {
             Default = (Settings)ser.Deserialize(sr);
         }
     } catch (Exception ex) {
         LogService.WriteLine(ex);
         Default = new Settings();
     }
 }
コード例 #2
0
        public void Log(LogSeverity severity, string message)
        {
            string txt = severity + " [" + DateTime.Now.ToLongTimeString() + "] " + message;

            LogService.WriteLine(txt);
            Server.Log(severity, message);
        }
コード例 #3
0
        IEnumerable <string> RunCommand(string gitDir, string cmd, StringBuilder log)
        {
            if (log != null)
            {
                log.AppendLine("> git " + cmd);
            }
            LogService.WriteLine("> git " + cmd);
            StringBuilder output = new StringBuilder();
            StringBuilder error  = new StringBuilder();

            try {
                BuildService.RunCommand(false, GitCommand, cmd, output, error, Timeout, gitDir);
            } catch (Exception ex) {
                throw new Exception(ex.Message + ": " + output.ToString() + " " + error.ToString());
            }
            if (log != null)
            {
                log.AppendLine(output.ToString());
            }
            LogService.WriteLine(output.ToString());

            List <string> lines = new List <string> ();
            StringReader  sr    = new StringReader(output.ToString());
            string        line;

            while ((line = sr.ReadLine()) != null)
            {
                lines.Add(line);
            }
            return(lines);
        }
コード例 #4
0
        public void Log(Exception ex)
        {
            string txt = "Error [" + DateTime.Now.ToLongTimeString() + "] " + ex.ToString();

            LogService.WriteLine(txt);
            Server.Log(LogSeverity.Error, ex.ToString());
        }
コード例 #5
0
        public void Start(string url)
        {
            mainContext.Server        = new Server();
            mainContext.LocalSettings = Settings.Default;
            mainContext.LocalSettings.Dump();

            if (url == null)
            {
                url = mainContext.LocalSettings.WebSiteUrl;
            }
            if (url != null)
            {
                mainContext.Server.Url = url + "/WebService/Server.asmx";
            }

            int i = mainContext.Server.Url.IndexOf("/WebService");

            mainContext.ServerUrl = mainContext.Server.Url.Substring(0, i);
            LogService.WriteLine("Connecting to: " + mainContext.ServerUrl);

            if (running)
            {
                return;
            }

            if (mainContext.LocalSettings.AppArmorSandbox)
            {
                SandboxService.Initialize();
            }

            running       = true;
            builderThread = new Thread(Run);
            builderThread.Start();
        }
コード例 #6
0
 bool ConnectToServer(BuildContext ctx)
 {
     try {
         if (ctx.Connect())
         {
             ctx.Connected = true;
             return(true);
         }
         else
         {
             if (ctx.FirstNotAuthorised)
             {
                 LogService.WriteLine("ERROR: Connection to server not authorized.");
                 LogService.WriteLine("To enable connections from this service, go to the administration page");
                 LogService.WriteLine("in the server and click on the Change Service option.");
                 ctx.FirstNotAuthorised = false;
             }
             else
             {
                 LogService.WriteLine("Connection not authorized. Trying again.");
             }
         }
     } catch (Exception ex) {
         LogService.WriteLine("Connection failed: " + ex.Message);
     }
     ctx.Connected = false;
     return(false);
 }
コード例 #7
0
 public void Dump()
 {
     LogService.WriteLine("Web Server: {0}", WebSiteUrl);
     LogService.WriteLine("Data Path: {0}", DataPath);
     LogService.WriteLine("MSBuild command: {0}", MSBuildCommand);
     LogService.WriteLine("Poll wait: {0}", PollWaitMinutes + "m");
     LogService.WriteLine("Live Events Connection: {0}", LiveEventsConnection);
 }
コード例 #8
0
 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();
 }
コード例 #9
0
 bool HandleError(BuildContext ctx, Exception ex)
 {
     try {
         ctx.Status = "ERROR: " + ex.Message;
         ctx.Log(ex);
         return(true);
     } catch (Exception e) {
         LogService.WriteLine(e);
         ctx.Connected = false;
         return(false);
     }
 }
コード例 #10
0
        void UpdateRepo(BuildContext ctx, int sourceId, string url, StringBuilder output)
        {
            string gitDir = GetGitPath(ctx, sourceId);

            if (!Directory.Exists(gitDir))
            {
                RunCommand(".", "clone --depth=1 --no-single-branch " + url + " " + gitDir, output);
            }
            else
            {
                try {
                    RunCommand(gitDir, "fetch origin", output);
                } catch (Exception ex) {
                    LogService.WriteLine("Error: " + ex.Message);
                    // If something goes wrong while updating, reclone
                    Directory.Delete(gitDir, true);
                    RunCommand(null, "clone --depth=1 --no-single-branch " + url + " " + gitDir, output);
                }
            }
        }
コード例 #11
0
ファイル: BazaarPuller.cs プロジェクト: jsuarezruiz/cydin
        void UpdateRepo(BuildContext ctx, int sourceId, string url, StringBuilder output)
        {
            string bzrDir = GetBzrPath(ctx, sourceId);

            if (!Directory.Exists(bzrDir))
            {
                RunCommand(".", "checkout " + url + " " + bzrDir, output);
            }
            else
            {
                try {
                    RunCommand(bzrDir, "update", output);
                } catch (Exception ex) {
                    LogService.WriteLine(ex);
                    // If something goes wrong while updating, reclone
                    Directory.Delete(bzrDir, true);
                    RunCommand(".", "checkout " + url + " " + bzrDir, output);
                }
            }
        }