protected uSyncAction ReportItem(string file) { try { var node = syncFileService.LoadXElement(file); try { var change = serializer.IsCurrent(node); var action = uSyncActionHelper <TObject> .ReportAction(change, node.GetAlias()); action.Message = ""; if (action.Change > ChangeType.NoChange) { action.Details = tracker.GetChanges(node); if (action.Details == null || action.Details.Count() == 0) { action.Message = "Change details cannot be calculated"; } action.Message = $"{action.Change.ToString()}"; } return(action); } catch (FormatException fex) { return(uSyncActionHelper <TObject> .ReportActionFail(Path.GetFileName(file), $"format error {fex.Message}")); } } catch (Exception ex) { return(uSyncActionHelper <TObject> .ReportActionFail(Path.GetFileName(file), $"Reporing error {ex.Message}")); } }
public bool CheckVersionFile(string folder) { var versionFile = Path.Combine(syncFileService.GetAbsPath(folder), "usync.config"); if (!syncFileService.FileExists(versionFile)) { return(false); } else { try { var node = syncFileService.LoadXElement(versionFile); var format = node.Attribute("format").ValueOrDefault(""); if (!format.InvariantEquals(uSyncConstants.FormatVersion)) { var expectedVersion = SemVersion.Parse(uSyncConstants.FormatVersion); if (SemVersion.TryParse(format, out SemVersion current)) { if (current.CompareTo(expectedVersion) >= 0) { return(true); } } return(false); } } catch { return(false); } } return(true); }