public override void Execute(object parameter) { try { var wrapper = new StringSettingWrapper(_key, _value, _model); _manager.BindingProxy.SettingProperty = wrapper; base.Execute(parameter); } catch (Exception e) { Log.WarnFormat("An exception occurred while attempting to execute a ButtonSettingsCommand: {0}", e.Message); } }
public override IResult Execute(IResult previousResults) { try { if (string.IsNullOrWhiteSpace(SettingKey)) throw new Exception("Setting key cannot be empty"); Text = string.Join(Environment.NewLine, _lines); var builder = new StringBuilder(SettingsManager.GetTemporarySettingString(SettingKey)); builder.AppendLine(Text); var wrapper = new StringSettingWrapper(SettingKey, builder.ToString(), null); SettingsManager.BindingProxy.SettingProperty = wrapper; return new NextResult(); } catch (Exception e) { return new ExceptionOccurred(e); } }
public override IResult Execute(IResult previousResults) { try { if (string.IsNullOrWhiteSpace(Target)) throw new Exception("Target path is null or empty"); if (!File.Exists(Target)) return new FileNotFound {Target = Target}; if (!string.IsNullOrWhiteSpace(OutputFolder)) { if (!Directory.Exists(OutputFolder)) return new FileNotFound {Target = OutputFolder}; } bool vital; if (!bool.TryParse(Vital, out vital)) Log.Warn("Cannot convert vital value to valid boolean. Assuming vital = false."); var version = GetVersionForFile(Target, Version); var info = new FileInfo(Target); var task = Task<string>.Factory.StartNew(() => PathUtilities.HashFile(Target)); task.WaitUntilExited(); if (task.IsFaulted) Log.Warn("An issue occurred while attempting to generate the file hash: {0}", task.Exception); var wrapper = new FileInfoWrapper { FileName = info.Name, FileUrl = info.Name, Version = version.ToString(), Vital = vital, FileSize = info.Length, FileSha1 = task.Result, MsiProductCode = GetMsiPropertyFromFile(Target, "ProductCode"), MsiUpgradeCode = GetMsiPropertyFromFile(Target, "UpgradeCode"), }; var serializedWrapper = wrapper.ToXElement<FileInfoWrapper>(); // remove attributes from root serializedWrapper.Attributes().Remove(); var result = new XElement("InCommonProvision", new XAttribute("version", "1.0")); result.Add(serializedWrapper); if (!string.IsNullOrWhiteSpace(OutputKey)) { var settingsWrapper = new StringSettingWrapper(OutputKey, result.ToString(), null); SettingsManager.BindingProxy.SettingProperty = settingsWrapper; } if (!string.IsNullOrWhiteSpace(OutputFolder)) { var outputFileName = OutputFileName; if (string.IsNullOrWhiteSpace(OutputFileName)) outputFileName = GetInfoFilename(Target); File.WriteAllText(Path.Combine(OutputFolder, outputFileName), result.ToString(), new ASCIIEncoding()); } return new NextResult(); } catch (Exception e) { return new ExceptionOccurred(e); } }