public FolderTreeViewItemViewModel(string name, string path, CloudFoundry.Net.Types.Application app, ushort id)
     : base(null, true)
 {
     Messenger.Default.Send<NotificationMessageAction<ICloudFoundryProvider>>(new NotificationMessageAction<ICloudFoundryProvider>(Messages.GetCloudFoundryProvider, p => this.provider = p));
     this.name = name;
     this.app = app;
     this.path = path;
     this.id = id;
 }
 public FileTreeViewItemViewModel(string name, string path, CloudFoundry.Net.Types.Application app, ushort id)
     : base(null, true)
 {
     Messenger.Default.Send<NotificationMessageAction<ICloudFoundryProvider>>(new NotificationMessageAction<ICloudFoundryProvider>(Messages.GetCloudFoundryProvider, p => this.provider = p));
     this.name = name;
     this.app = app;
     this.path = path;
     this.id = id;
     this.fileExtension = System.IO.Path.GetExtension(name);
     OpenFileCommand = new RelayCommand<MouseButtonEventArgs>(OpenFile);
     OpenFileFromContextCommand = new RelayCommand(OpenFileFromContext);
 }
        public bool Detect(CloudFoundry.WindowsPrison.Prison prison)
        {
            string exe = GetExecutable(Path.Combine(this.path, "bin"), "detect");

            string outputPath = Path.Combine(this.cacheDir, "detect.yml");
            string script = string.Format("{0} {1} > {2} 2>&1", exe, this.appDir, outputPath);

            Logger.Debug("Running detect script: {0}", script);

            Process process = prison.Execute(null, script, this.appDir, false, null, null, null, null);

            var startTs = DateTime.Now;
            while (prison.JobObject != null && prison.JobObject.ActiveProcesses > 0)
            {
                if ((DateTime.Now - startTs).TotalSeconds > 30)
                {
                    Logger.Debug("Staging's detect script timed out. Killing all job processes. Detect path: {0}", exe);
                    prison.JobObject.TerminateProcesses(-2);
                    break;
                }

                Thread.Sleep(100);
            }

            if (File.Exists(outputPath))
            {
                this.detectOutput = File.ReadAllText(outputPath);
                Logger.Debug("Detect output: {0}", this.detectOutput);
                File.Delete(outputPath);
            }
            else
            {
                Logger.Warning("Detect output missing. Detect yml path: {0}", outputPath);
            }

            if (process.ExitCode == 0)
            {
                return true;
            }
            else
            {
                Logger.Warning("Detect process exited with {0}", process.ExitCode);
                return false;
            }
        }
        public Process StartCompile(CloudFoundry.WindowsPrison.Prison prison)
        {
            string exe = GetExecutable(Path.Combine(path, "bin"), "compile");
            string args = string.Format("{0} {1} >> {2} 2>&1", this.appDir, this.cacheDir, this.logFile);
            Logger.Debug("Running compile script {0} {1}", exe, args);

            var script = string.Format("{0} {1}", exe, args);

            Process process = prison.Execute(null, script, this.appDir, false, null, null, null, null);

            return process;
        }
        public ReleaseInfo GetReleaseInfo(CloudFoundry.WindowsPrison.Prison prison)
        {
            string exe = GetExecutable(Path.Combine(this.path, "bin"), "release");

            string outputPath = Path.Combine(this.cacheDir, "release.yml");
            string script = string.Format("{0} {1} > {2} 2>&1", exe, this.appDir, outputPath);

            Process process = prison.Execute(null, script, this.appDir, false, null, null, null, null);

            process.WaitForExit(5000);

            string output = File.ReadAllText(outputPath);
            File.Delete(outputPath);
            using (var reader = new StringReader(output))
            {
                Deserializer deserializer = new Deserializer();
                return (ReleaseInfo)deserializer.Deserialize(reader, typeof(ReleaseInfo));
            }
        }