コード例 #1
0
ファイル: Automatr.cs プロジェクト: eatplayhate/versionr
        private void RunTasks()
        {
            AutomatrLog.Log("Running tasks... " + (Program.Options.Force ? "(forced)" : ""));
            foreach (AutomatrTask task in Config.Tasks)
            {
                AutomatrLog.Log("Running Task: " + task.Command);
                var processInfo = new ProcessStartInfo("cmd.exe", "/c " + task.Command);
                processInfo.CreateNoWindow         = true;
                processInfo.UseShellExecute        = false;
                processInfo.RedirectStandardError  = true;
                processInfo.RedirectStandardOutput = true;

                var process = Process.Start(processInfo);

                process.OutputDataReceived += (object sender, DataReceivedEventArgs e) => AutomatrLog.Log(e.Data, AutomatrLog.LogLevel.Info);
                process.BeginOutputReadLine();

                process.ErrorDataReceived += (object sender, DataReceivedEventArgs e) => AutomatrLog.Log(e.Data, AutomatrLog.LogLevel.Error);
                process.BeginErrorReadLine();

                process.WaitForExit();

                Console.WriteLine("Exit Code: {0}", process.ExitCode);
                process.Close();
            }
        }
コード例 #2
0
        public void Write(string path)
        {
            XmlSerializer seralizer = new XmlSerializer(GetType());

            using (StreamWriter writer = new StreamWriter(path))
            {
                seralizer.Serialize(writer, this);
            }
            AutomatrLog.Log("Wrote config " + path, AutomatrLog.LogLevel.Verbose);
        }
コード例 #3
0
ファイル: Automatr.cs プロジェクト: eatplayhate/versionr
        private bool Connect()
        {
            RemoteConfig remote = m_Area.GetRemote("default");

            AutomatrLog.Log("Attempting to connect to remote:");
            AutomatrLog.Log("\tHost = " + remote.Host);
            AutomatrLog.Log("\tPort = " + remote.Port);
            AutomatrLog.Log("\tModule = " + remote.Module);
            return(m_Client.Connect(Client.ToVersionrURL(remote)));
        }
コード例 #4
0
ファイル: Program.cs プロジェクト: eatplayhate/versionr
        public static void Main(string[] args)
        {
            Options = new AutomatrOptions();
            Parser parser = new Parser(new Action <ParserSettings>((ParserSettings p) => { p.CaseSensitive = false; p.IgnoreUnknownArguments = false; p.MutuallyExclusive = true; }));
            bool   parse  = parser.ParseArguments(args, Options);

            if (Options.Version)
            {
                AutomatrLog.Log("Automatr " + Version, AutomatrLog.LogLevel.Info);
                return;
            }

            AutomatrConfig config   = AutomatrConfig.Load(Options.ConfigPath);
            Automatr       automatr = new Automatr(config);

            automatr.Run();
        }
コード例 #5
0
        public static AutomatrConfig Load(string path)
        {
            XmlSerializer serializer = new XmlSerializer(typeof(AutomatrConfig));

            AutomatrConfig result = null;

            try
            {
                using (StreamReader reader = new StreamReader(path))
                {
                    result = (AutomatrConfig)serializer.Deserialize(reader);
                }
                AutomatrLog.Log("Loaded config " + path, AutomatrLog.LogLevel.Verbose);
            }
            catch
            {
                result = new AutomatrConfig();
            }

            return(result);
        }
コード例 #6
0
ファイル: Automatr.cs プロジェクト: eatplayhate/versionr
        public void Run()
        {
            AutomatrLog.Log("Loaded area " + Config.Path + "... ", false);
            m_Area = Area.Load(new DirectoryInfo(Config.Path));
            AutomatrLog.Log("Done");
            AutomatrLog.Log("Creating Client... ", false);
            m_Client = new Client(m_Area);
            AutomatrLog.Log("Done.");

            if (!Connect())
            {
                AutomatrLog.Log("Connection Failed!", AutomatrLog.LogLevel.Error);
                Environment.Exit(1);
            }
            AutomatrLog.Log("Connection successful.");
            BranchStatus status = GetStatus();

            AutomatrLog.Log("Branch status: " + status);
            if (status == BranchStatus.Behind || Program.Options.Force)
            {
                RunTasks();
            }
        }