/// <summary> /// New position in stream. /// </summary> /// <param name="svc"></param> /// <param name="line">Received line.</param> /// <returns>true if it was processed by current handler, otherwise it means ignoring.</returns> public override bool Positioned(ISvc svc, RawText line) { if (svc.Sln.SolutionConfigList == null) { svc.Sln.SolutionConfigList = new List <IConfPlatform>(); } string _line; while ((_line = svc.ReadLine(this)) != null && _line.Trim() != "EndGlobalSection") { string left = _line.Before('=')?.Trim(); // Debug|Win32 = Debug|Win32 if (left == null || String.Compare(left, "DESCRIPTION", StringComparison.OrdinalIgnoreCase) == 0) { LSender.Send(this, $"Solution Configuration has been ignored for line '{_line}'", Message.Level.Debug); continue; } string[] cfg = left.Split('|'); if (cfg.Length < 2) { continue; } LSender.Send(this, $"Solution Configuration ->['{cfg[0]}' ; '{cfg[1]}']", Message.Level.Info); svc.Sln.SolutionConfigList.Add(new ConfigSln(cfg[0], cfg[1])); } return(true); }
public DiffProcessor(IWorkerConfiguration workerConfig, ISynchronization sync, ISvc source, ISvc target, IBlackMirrorHttpClient httpClient, ISyncLogger syncLogger, IUser defaultPushUser) { //this.mirror = mirror; this.sync = sync; this.source = source; this.target = target; this.httpClient = httpClient; this.syncLogger = syncLogger; this.defaultPushUser = defaultPushUser; this.ignoredFiles = sync.Mirror.IgnoredFiles?.ToList() ?? new List <string>(); this.ignoredFiles.AddRange(new[] { @"^\.svn\\?.*$", @"(^\.git\\.*$)|(^\.git$)", @"^.*\\node_modules\\.*$", @"^.*\\bower_components\\.*$", @"^packages\\?.*$", @"^.*\.dll$", @"^.*\.pdb", @"^.*\.nupkg", @"^.*\.tar", @"^.*\.tgz", @"^.*\.jar", @"^.*\.exe", }); this.retriever = new UserRetriever(workerConfig); this.timeoutMaxRetryCount = workerConfig.TimeoutMaxRetryCount; }
/// <summary> /// New position in stream. /// </summary> /// <param name="svc"></param> /// <param name="line">Received line.</param> /// <returns>true if it was processed by current handler, otherwise it means ignoring.</returns> public override bool Positioned(ISvc svc, RawText line) { string _line; while ((_line = svc.ReadLine(this)) != null && _line.Trim() != "EndGlobalSection") { int pos = _line.IndexOf('='); // Guids: src = dest if (pos < 0) { LSender.Send(this, $"Incorrect NestedProjects records: '{_line}'", Message.Level.Warn); return(false); } string src = _line.Substring(0, pos).Trim(); string dest = _line.Substring(pos + 1).Trim(); LSender.Send(this, $"NestedProjects '{src}' -> '{dest}'", Message.Level.Info); var parent = svc.Sln.SolutionFolderList.Where(f => f.header.pGuid == dest).First(); svc.Sln.SolutionFolderList.Where(f => f.header.pGuid == src) .ForEach(f => f.header.parent.Value = parent); svc.Sln.ProjectItemList.Where(p => p.pGuid == src) .ForEach(p => p.parent.Value = parent); } return(true); }
/// <summary> /// New position in stream. /// </summary> /// <param name="svc"></param> /// <param name="line">Received line.</param> /// <returns>true if it was processed by current handler, otherwise it means ignoring.</returns> public override bool Positioned(ISvc svc, RawText line) { if (svc.Sln.ExtItems == null) { svc.Sln.ExtItems = new Dictionary <string, string>(); } string _line; while ((_line = svc.ReadLine(this)) != null && _line.Trim() != "EndGlobalSection") { int pos = _line.IndexOf('='); if (pos < 0) // we will use non-strict processing { svc.Sln.ExtItems[_line.Trim()] = null; LSender.Send(this, $"Found extensible null record:{_line}", Message.Level.Info); continue; } string key = _line.Substring(0, pos).Trim(); string val = _line.Substring(pos + 1).Trim(); svc.Sln.ExtItems[key] = val; LSender.Send(this, $"Found extensible key-value: `{key}` = `{val}`", Message.Level.Info); } return(true); }
public void Handle(ISynchronization sync) { try { var passwordRetriever = new UserRetriever(this.workerConfig); var message = $"Starting synchronization {sync.Id}"; Logging.Log().Warning(message); this.syncLogger.Log(sync, message); SvcFactory factory = new SvcFactory(sync, passwordRetriever, syncLogger); ISvc source = factory.Create(sync.Mirror.SourceRepository); ISvc target = factory.Create(sync.Mirror.TargetRepository); var diffProcessor = new DiffProcessor( this.workerConfig, sync, source, target, this.httpClient, this.syncLogger, sync.Mirror.TargetRepository.PushUser); source.CloneOrUpdate(); target.CloneOrUpdate(); var sourceLog = source.GetLog(); var targetLog = target.GetLog(); var comparer = new RepositoryComparer(this.httpClient, sync.Mirror, sourceLog, targetLog); var revisions = comparer.GetRevisionsAwaitingForSync(); for (int i = revisions.Count - 1; i >= 0; i--) { var revision = revisions[i]; var m = $"Applying revision {revision.Id} {revision.Author} {revision.Message}"; Logging.Log().Warning(m); this.syncLogger.Log(sync, m); diffProcessor.ApplyRevision(revision); } var o = $"Synchronization {sync.Id} OK"; Logging.Log().Information(o); this.syncLogger.Log(sync, o); var cl = $"Cleaning up..."; Logging.Log().Information(cl); this.syncLogger.Log(sync, cl); source.CleanUp(); target.CleanUp(); } catch (Exception ex) { this.syncLogger.Log(sync, $"Error: {ex}"); throw; } }
/// <summary> /// New position in stream. /// </summary> /// <param name="svc"></param> /// <param name="line">Received line.</param> /// <returns>true if it was processed by current handler, otherwise it means ignoring.</returns> public override bool Positioned(ISvc svc, RawText line) { var pItem = new ProjectItem(line.trimmed, svc.Sln.SolutionDir); if (pItem.pGuid == null || !String.Equals(Guids.SLN_FOLDER, pItem.pType, StringComparison.OrdinalIgnoreCase)) { return(false); } LSender.Send(this, $"Found solution-folder: '{pItem.name}'", Message.Level.Info); var folderItems = new List <RawText>(); while ((line = svc.ReadLine(this)) != null && (line != "EndProject")) { if (!line.trimmed.StartsWith("ProjectSection(SolutionItems) = preProject", StringComparison.Ordinal)) { continue; } for (line = svc.ReadLine(this); line != null; line = svc.ReadLine(this)) { if (line.trimmed.StartsWith("EndProjectSection", StringComparison.Ordinal)) { break; } var item = line.trimmed.Before('='); if (item == null) { LSender.Send( this, $"Ignored incorrect item for '{pItem.name}':{pItem.pGuid} - '{line}'", Message.Level.Warn ); continue; } item = item.TrimEnd(); LSender.Send(this, $"Found item: '{item}'", Message.Level.Info); folderItems.Add(new RawText(item, svc.CurrentEncoding)); } } if (svc.Sln.SolutionFolderList == null) { svc.Sln.SolutionFolderList = new List <SolutionFolder>(); } svc.Sln.SolutionFolderList.Add(new SolutionFolder(pItem, folderItems)); return(true); }
protected void Process(ISvc svc) { _coh = new CoHandlers(SlnHandlers); DoPreProcessing(svc); { string line; while ((line = svc.ReadLine()) != null) { DoPositioned(svc, new RawText(line, svc.CurrentEncoding)); } } DoPostProcessing(svc); }
/// <summary> /// New position in stream. /// </summary> /// <param name="svc"></param> /// <param name="line">Received line.</param> /// <returns>true if it was processed by current handler, otherwise it means ignoring.</returns> public override bool Positioned(ISvc svc, RawText line) { int pos = line.trimmed.LastIndexOfAny(new char[] { '=', ' ' }); string version; if (pos == -1 || lineType == LineType.Unknown || String.IsNullOrWhiteSpace(version = line.trimmed.Substring(pos + 1))) { LSender.Send(this, $"Incorrect version info from header: '{line.trimmed}'", Message.Level.Warn); return(false); } LSender.Send(this, $"Found version from header: '{lineType}' = '{version}'", Message.Level.Info); var h = new SlnHeader(svc.Sln.Header); switch (lineType) { case LineType.FormatVersion: { h.SetFormatVersion(version); break; } case LineType.VisualStudioVersion: { h.SetVisualStudioVersion(version); break; } case LineType.MinimumVisualStudioVersion: { h.SetMinimumVersion(version); break; } case LineType.ProgramVersion: { h.SetProgramVersion(version); break; } default: { return(false); } } svc.Sln.SetHeader(h); return(true); }
/// <summary> /// New position in stream. /// </summary> /// <param name="svc"></param> /// <param name="line">Received line.</param> /// <returns>true if it was processed by current handler, otherwise it means ignoring.</returns> public override bool Positioned(ISvc svc, RawText line) { if (svc.Sln.ProjectConfigList == null) { svc.Sln.ProjectConfigList = new List <IConfPlatformPrj>(); } var records = new Dictionary <Cortege, ConfigPrj>(new EqCortegeComparer()); string _line; while ((_line = svc.ReadLine(this)) != null && _line.Trim() != "EndGlobalSection") { var v = Parse(ref _line, out LineAttr ltype); if (ltype == LineAttr.InvalidOrUnknown) { LSender.Send(this, $"Incorrect Project Configuration: {v}; raw: '{_line}'", Message.Level.Warn); continue; } //NOTE: Build0 and Deploy0 records are valid too. Even if an ActiveCfg is corrupted and does not exist at all. if (!records.ContainsKey(v)) { LSender.Send(this, $"Found Project Configuration: {v}", Message.Level.Info); records[v] = new ConfigPrj(v.cprj, v.pGuid, false, new ConfigSln(v.csln)); svc.Sln.ProjectConfigList.Add(records[v]); } if (ltype == LineAttr.Build0) { LSender.Send(this, $"Project Configuration, update Build.0 {v}", Message.Level.Debug); records[v].IncludeInBuild = true; continue; } if (ltype == LineAttr.Deploy0) { LSender.Send(this, $"Project Configuration, update Deploy.0 {v}", Message.Level.Debug); records[v].IncludeInDeploy = true; continue; } } return(true); }
/// <summary> /// New position in stream. /// </summary> /// <param name="svc"></param> /// <param name="line">Received line.</param> /// <returns>true if it was processed by current handler, otherwise it means ignoring.</returns> public override bool Positioned(ISvc svc, RawText line) { var pItem = GetProjectItem(line.trimmed, svc.Sln.SolutionDir); if (pItem.pGuid == null) { return(false); } if (svc.Sln.ProjectItemList == null) { svc.Sln.ProjectItemList = new List <ProjectItem>(); } svc.Sln.ProjectItemList.Add(pItem); return(true); }
protected virtual void DoPositioned(ISvc svc, RawText line) { foreach (ISlnHandler h in SlnHandlers) { if (!h.Condition(line)) { continue; } if (TrackedPosition(h, svc, line) && (h.CoHandlers == null || !_coh.Contains(h.Id))) { return; } } svc.Track(line); }
private bool TrackedPosition(ISlnHandler h, ISvc svc, RawText line) { bool isAct = h.IsActivated(svc); TransactTracking <ISection, IList <ISection> > tt = null; if (h.LineControl == LineAct.Process) { tt = svc.TransactTrack(line, isAct ? h : null); } if (!isAct) { return(false); } bool res = h.Positioned(svc, line); tt?.Action(res ? TransactAction.Commit : TransactAction.Rollback); return(res); }
/// <summary> /// Checks the readiness to process data. /// </summary> /// <param name="svc"></param> /// <returns>True value if it's ready at current time.</returns> public override bool IsActivated(ISvc svc) { return((svc.Sln.ResultType & SlnItems.ExtItems) == SlnItems.ExtItems); }
/// <summary> /// Checks the readiness to process data. /// </summary> /// <param name="svc"></param> /// <returns>True value if it's ready at current time.</returns> public abstract bool IsActivated(ISvc svc);
/// <summary> /// Checks the readiness to process data. /// </summary> /// <param name="svc"></param> /// <returns>True value if it's ready at current time.</returns> public override bool IsActivated(ISvc svc) { return((svc.Sln.ResultType & SlnItems.SolutionConfPlatforms) == SlnItems.SolutionConfPlatforms); }
/// <summary> /// New position in stream. /// </summary> /// <param name="svc"></param> /// <param name="line">Received line.</param> /// <returns>true if it was processed by current handler, otherwise it means ignoring.</returns> public override bool Positioned(ISvc svc, RawText line) { if (svc.Sln.ProjectConfigList == null) { svc.Sln.ProjectConfigList = new List <IConfPlatformPrj>(); } /* * [Projects Guid] [Solution pair] [Project pair] * {A7BF1F9C-F18D-423E-9354-859DC3CFAFD4}.CI_Release|Any CPU.ActiveCfg = Release|Any CPU - configuration name * {A7BF1F9C-F18D-423E-9354-859DC3CFAFD4}.CI_Release|Any CPU.Build.0 = Release|Any CPU - flag of build (this line exists only when this flag is true) */ string _line; var cortege = new Dictionary <Cortege, ConfigPrj>(new EqCortegeComparer()); while ((_line = svc.ReadLine(this)) != null && _line.Trim() != "EndGlobalSection") { int x, y; x = _line.IndexOf('.'); var pGuid = _line.Substring(0, x).Trim(); y = _line.IndexOf('.', ++x); string csln = _line.Substring(x, y - x).Trim(); x = _line.IndexOf('=', ++y); string type = _line.Substring(y, x - y).Trim(); string cprj = _line.Substring(x + 1).Trim(); bool isActiveCfg = type.Equals("ActiveCfg", StringComparison.OrdinalIgnoreCase); bool isBuild0 = type.Equals("Build.0", StringComparison.OrdinalIgnoreCase); bool isDeploy0 = type.Equals("Deploy.0", StringComparison.OrdinalIgnoreCase); if (!isActiveCfg && !isBuild0 && !isDeploy0) { LSender.Send(this, $"Project Configuration has been ignored for line '{_line}'", Message.Level.Debug); continue; } var ident = new Cortege() { pGuid = pGuid, csln = csln, cprj = cprj, }; if (!cortege.ContainsKey(ident)) { LSender.Send(this, $"New Project Configuration `{pGuid}`, `{csln}` = `{cprj}` /{type}", Message.Level.Info); cortege[ident] = new ConfigPrj(cprj, pGuid, isBuild0, new ConfigSln(csln)); svc.Sln.ProjectConfigList.Add(cortege[ident]); continue; } if (isBuild0) { LSender.Send(this, $"Project Configuration, update Build.0 `{pGuid}`", Message.Level.Debug); cortege[ident].IncludeInBuild = true; continue; } if (isDeploy0) { LSender.Send(this, $"Project Configuration, update Deploy.0 `{pGuid}`", Message.Level.Debug); cortege[ident].IncludeInDeploy = true; continue; } } return(true); }
public Grain1(ISvc svc) { _svc = svc; }
/// <summary> /// New position in stream. /// </summary> /// <param name="svc"></param> /// <param name="line">Received line.</param> /// <returns>true if it was processed by current handler, otherwise it means ignoring.</returns> public abstract bool Positioned(ISvc svc, RawText line);
protected virtual void DoPostProcessing(ISvc svc) { SlnHandlers.ForEach((h) => h.PostProcessing(svc)); }
/// <summary> /// The logic after processing file. /// </summary> /// <param name="svc"></param> public virtual void PostProcessing(ISvc svc) { }
/// <summary> /// The logic before processing file. /// </summary> /// <param name="svc"></param> public virtual void PreProcessing(ISvc svc) { }