public IEnumerable <string> UninstallPackage(IPackage package, bool inDetails) { Exception exception = null; IEnumerable <string> result = null; try { result = this.PackageManager.UninstallPackage(package); } catch (Exception ex) { exception = ex; throw; } finally { // Log the result of the uninstall var telemetry = WebMatrixTelemetryServiceProvider.GetTelemetryService(); if (telemetry != null) { string appId = _webMatrixHost.WebSite.ApplicationIdentifier; telemetry.LogPackageUninstall(_galleryId, package.Id, appId, exception, inDetails, isFeatured: false, isCustomFeed: !FeedSource.IsBuiltIn); } } if (_webMatrixHost != null) { _webMatrixHost.ShowNotification(string.Format(Resources.Notification_Uninstalled, _packageKind, package.Id)); } return(result); }
/// <summary> /// raised any time any file changes - filter for supported file types, and add jobs to the queue /// </summary> /// <param name="source"></param> /// <param name="e"></param> protected void SourceFileChanged(object source, FileSystemEventArgs e) { try { var ext = (new FileInfo(e.FullPath)).Extension; if (Regex.IsMatch(ext, @"\.(less|scss|sass|coffee|js|css|ts)", RegexOptions.IgnoreCase)) { if (e.ChangeType == WatcherChangeTypes.Changed) { bool?doIt = null; OrangeJob.JobType jobType = OrangeJob.JobType.Compile; switch (ext.ToLowerInvariant()) { case ".less": doIt = prefUtility.GetPref(e.FullPath, "AutoCompileLess", true) as bool?; break; case ".scss": case ".sass": doIt = prefUtility.GetPref(e.FullPath, "AutoCompileSass", true) as bool?; break; case ".coffee": doIt = prefUtility.GetPref(e.FullPath, "AutoCompileCoffee", true) as bool?; break; case ".js": doIt = e.FullPath.EndsWith(".min.js") ? false : prefUtility.GetPref(e.FullPath, "AutoMinifyJS", false) as bool?; jobType = OrangeJob.JobType.Minify; break; case ".css": doIt = e.FullPath.EndsWith(".min.css") ? false : prefUtility.GetPref(e.FullPath, "AutoMinifyCSS", false) as bool?; jobType = OrangeJob.JobType.Minify; break; case ".ts": doIt = prefUtility.GetPref(e.FullPath, "AutoCompileTypeScript", true) as bool?; break; } if (doIt.HasValue && doIt.Value && _worker != null) { _worker.AddItem(new OrangeJob() { Path = e.FullPath, OutputPath = GetOutputPath(e.FullPath), Type = jobType, Source = OrangeJob.JobSource.Save }); } } } } catch (Exception ex) { _host.ShowNotification("There was an error compiling your file: " + ex.ToString()); } }
/// <summary> /// process a file, generating the compiled output /// </summary> /// <param name="item"></param> protected void ProcessItem(OrangeJob job) { var threadedOpenCmd = new Action(() => { mainDispatcher.Invoke(new Action(() => { var openCommand = host.HostCommands.OpenFileInEditor; if (openCommand.CanExecute(job.OutputPath)) { openCommand.Execute(job.OutputPath); } })); }); try { // do the actual compilation work CompileResults results = compiler.Process(job); // show the notification bar to notify the user it happened if (!String.IsNullOrEmpty(results.Message)) { host.ShowNotification(results.Message, "Open File", threadedOpenCmd); } host.Logger.Log(TraceLevel.Info, string.Format("Success: Compiled {0} to generate {1}", job.Path, job.OutputPath)); // refresh the tree so the new file (if created) shows up if (results.IsNewFile) { mainDispatcher.Invoke(new Action(() => { var refreshCommand = host.HostCommands.GetCommand(CommonCommandIds.GroupId, (int)CommonCommandIds.Ids.Refresh); if (refreshCommand.CanExecute(null)) { refreshCommand.Execute(null); } })); } } catch (Exception ex) { Console.WriteLine(ex); host.Logger.Log(TraceLevel.Error, string.Format("Error compiling {0}: {1}", job.Path, ex.ToString())); host.ShowNotification("There was an error processing " + job.Path, "Open File", threadedOpenCmd); } }
//-------------------------------------------------------------------------- // // Constructors // //-------------------------------------------------------------------------- #region Constructors /// <summary> /// Initializes a new instance of the NodePowerTools class. /// </summary> public WebMatrixExtension() : base("WebMatrixExtension") { _launchDebuggerCommand = new DelegateCommand(p => { try { _mainScriptPath = this.GetMainFileName(); var nodeInspectorUrl = string.Format("{0}/{1}/debug", _host.WebSite.Uri.ToString(), _mainScriptPath); Process.Start("chrome", nodeInspectorUrl); } catch (Win32Exception ex) { _host.ShowNotification("Chrome is not installed! Node Inspector requires Chrome."); } catch (Exception ex) { _host.ShowExceptionMessage("Node Power Tools", "There was a problem launching chrome. Are you sure it's installed?", ex); } //Process.Start("chrome", _host.WebSite.Uri.ToString()); }); }