public override string Execute(params string[] args) { FileInfo descFile = new FileInfo(GetValue <string>(args, 0, "descFile")); FileInfo metaFile = new FileInfo(GetValue <string>(args, 1, "metaFile")); string npdmFilePath = GetValue <string>(args, 2); FileInfo npdmFile = new FileInfo(string.IsNullOrEmpty(npdmFilePath) ? Path.ChangeExtension(descFile.FullName, ".npdm") : npdmFilePath); bool forceGenerateAcid = false; // GetValue<bool>(args, 3); if (!descFile.Exists) { throw new CommandException("Desc Not Found"); } if (!metaFile.Exists) { throw new CommandException("Meta Not Found"); } if (!npdmFile.Exists && Directory.Exists(npdmFile.FullName) && npdmFile.Attributes.HasFlag(FileAttributes.Directory)) { npdmFile = new FileInfo(Path.Combine(npdmFile.FullName, Path.ChangeExtension(descFile.Name, ".npdm"))); } try { DescModel desc = DescModel.FromXml(descFile.FullName); MetaModel meta = MetaModel.FromXml(metaFile.FullName); NpdmGenerator.CreateNpdm(desc, meta, forceGenerateAcid, npdmFile.FullName); } catch (Exception ex) { throw new CommandException(ex.Message); } return($"Done {npdmFile.FullName}"); }
public override string Execute(params string[] args) { FileInfo descFile = new FileInfo(GetValue <string>(args, 0, "descFile")); string metaFilePath = GetValue <string>(args, 1); if (!descFile.Exists) { throw new CommandException("Desc Not Found"); } try { DescModel desc = DescModel.FromXml(descFile.FullName); MetaModel meta = (File.Exists(metaFilePath)) ? MetaModel.FromXml(metaFilePath) : null; desc.Acid = Convert.ToBase64String(NpdmGenerator.GetAcidBytes(desc, meta)); File.WriteAllText(descFile.FullName, desc.XMLSerialize()); } catch (Exception ex) { throw new CommandException(ex.Message); } return($"Done {descFile.FullName}"); }
private void MB_EditDesc_Click(object sender, EventArgs e) { using (OpenFileDialog oFD = new OpenFileDialog() { Filter = "DESC files|*.desc", RestoreDirectory = true }) { if (oFD.ShowDialog() == DialogResult.OK) { try { DescModel desc = DescModel.FromXml(oFD.FileName); new DescEditor(desc, oFD.FileName).Show(); this.Hide(); } catch (Exception ex) { MessageBox.Show(ex.Message); } } } }