private void HandleResult(CompressionResult result, int count) { string name = Path.GetFileName(result.OriginalFileName); if (result.Saving > 0 && File.Exists(result.ResultFileName)) { if (_dte.SourceControl.IsItemUnderSCC(result.OriginalFileName) && !_dte.SourceControl.IsItemCheckedOut(result.OriginalFileName)) { _dte.SourceControl.CheckOutItem(result.OriginalFileName); } File.Copy(result.ResultFileName, result.OriginalFileName, true); string text = "Compressed " + name + " by " + result.Saving + " bytes / " + result.Percent + "%"; _dte.StatusBar.Progress(true, text, AmountCompleted: count, Total: _selectedPaths.Count); } else { _dte.StatusBar.Progress(true, name + " is already optimized", AmountCompleted: count, Total: _selectedPaths.Count); } if (result.Saving > 0) { Logger.Log(result.ToString()); } }
void HandleResult(CompressionResult result, int count) { string name = Path.GetFileName(result.OriginalFileName); if (result.Saving > 0 && File.Exists(result.ResultFileName)) { if (_dte.SourceControl.IsItemUnderSCC(result.OriginalFileName) && !_dte.SourceControl.IsItemCheckedOut(result.OriginalFileName)) { _dte.SourceControl.CheckOutItem(result.OriginalFileName); } File.Copy(result.ResultFileName, result.OriginalFileName, true); File.Delete(result.ResultFileName); string text = "Compressed " + name + " by " + result.Saving + " bytes / " + result.Percent + "%"; _dte.StatusBar.Progress(true, text, count, _selectedPaths.Count + 1); Logger.Log(result.ToString()); string ext = Path.GetExtension(result.OriginalFileName).ToLowerInvariant().Replace(".jpeg", ".jpg"); var metrics = new Dictionary <string, double> { { "saving", result.Saving } }; Telemetry.TrackEvent(ext, metrics: metrics); } else { _dte.StatusBar.Progress(true, name + " is already optimized", AmountCompleted: count, Total: _selectedPaths.Count + 1); Logger.Log(name + " is already optimized"); if (result.Processed) { Telemetry.TrackEvent("Already optimized"); } } }
private void HandleResult(CompressionResult result, int count) { string name = Path.GetFileName(result.OriginalFileName); if (result.Saving > 0 && File.Exists(result.ResultFileName)) { if (_dte.SourceControl.IsItemUnderSCC(result.OriginalFileName) && !_dte.SourceControl.IsItemCheckedOut(result.OriginalFileName)) _dte.SourceControl.CheckOutItem(result.OriginalFileName); File.Copy(result.ResultFileName, result.OriginalFileName, true); string text = "Compressed " + name + " by " + result.Saving + " bytes / " + result.Percent + "%"; _dte.StatusBar.Progress(true, text, AmountCompleted: count, Total: _selectedPaths.Count); } else { _dte.StatusBar.Progress(true, name + " is already optimized", AmountCompleted: count, Total: _selectedPaths.Count); } if (result.Saving > 0) Logger.Log(result.ToString()); }