public static async Task CreateBackupInfo(string sitecoreInstance, string webfolder, IProfile profile, ISynchronizeInvoke invoke) { var backupInfo = new BackupInfo { SitecoreInstance = sitecoreInstance, Webroot = webfolder }; var backupInfoExtractor = new BackupInfoExtractorFactory(profile, invoke).Create(); await backupInfoExtractor.SaveToFile(backupInfo); }
public bool SaveToFileSync(BackupInfo backupInfo) { var doc = new XDocument(); doc.Add(backupInfo.Serialize()); doc.Save(Path.Combine(backupInfo.Webroot, Settings.BackupInfoFile)); return(true); }
public async Task <bool> SaveToFile(BackupInfo backupInfo) { var parameters = new Dictionary <string, dynamic> { { "xml", backupInfo.Serialize().ToString() }, { "OutputFile", $@"{backupInfo.Webroot}\{Settings.BackupInfoFile}" } }; await _scriptWrapper.Run(Modules.Functions.SaveBackupInfo, parameters); return(true); }
public static BackupInfo Parse(string xml) { if (xml.NotEmpty()) { var xmlDocument = new XmlDocument(); xmlDocument.LoadXml(xml); var info = new BackupInfo(); info.Parse(xmlDocument.DocumentElement); return(info); } return(null); }
public static XElement Serialize(this BackupInfo backupInfo) { var root = new XElement(Xml.Backup_Info.NodeName); var webroot = new XElement(Xml.Backup_Info.Webroot); webroot.SetAttributeValue(Xml.Attributes.Value, backupInfo.Webroot); root.Add(webroot); var instance = new XElement(Xml.Backup_Info.SitecoreInstance); instance.SetAttributeValue(Xml.Attributes.Value, backupInfo.SitecoreInstance); root.Add(instance); return(root); }
public BackupInfo GetFromArchiveSync(string fileName) { if (File.Exists(fileName)) { using (ZipArchive archive = ZipFile.OpenRead(fileName)) { var entry = archive.GetEntry(Settings.BackupInfoFile); if (entry != null) { entry.ExtractToFile(Xml.Backup_Info.FilePath, true); if (File.Exists(Xml.Backup_Info.FilePath)) { var info = new BackupInfo(Xml.Backup_Info.FilePath); File.Delete(Xml.Backup_Info.FilePath); return(info); } } } } return(null); }
public async Task <bool> SaveToFile(BackupInfo backupInfo) { return(await TaskHelper <bool> .AsyncPattern(SaveToFileSync, backupInfo)); }
public static void Parse(this BackupInfo backupInfo, XmlElement doc) { backupInfo.Webroot = doc.ChildNodes.GetTextValue(Xml.Backup_Info.Webroot, Xml.Attributes.Value); backupInfo.SitecoreInstance = doc.ChildNodes.GetTextValue(Xml.Backup_Info.SitecoreInstance, Xml.Attributes.Value); }