public IAsyncEnumerable <IBuild> All(Id?projectId = null) { var parameters = projectId.HasValue ? new List <string> { $"project:{projectId.Value}" } : new List <string>(); var sequence = new Paged <IBuild, BuildListDto>( _instance, async() => { var buildLocator = parameters.IsNotEmpty() ? string.Join(",", parameters) : null; // LOG.debug("Retrieving queued builds from ${instance.serverUrl} using query '$buildLocator'") return(await _instance.Service.QueuedBuilds(buildLocator).ConfigureAwait(false)); }, async(list) => { var tasks = list.Items.Select(build => Build.Create(build.Id, _instance)); var builds = await Task.WhenAll(tasks).ConfigureAwait(false); return(new Page <IBuild>(builds, list.NextHref)); }); return(sequence); }
public int CompareTo(Id?other) { if (other == null || other.GetType() != typeof(Id)) { return(1); } return(Value.CompareTo(other.Value)); }
internal string GetUserUrlPage( string pageName, string tab = null, Id?projectId = null, Id?buildId = null, Id?testNameId = null, Id?userId = null, Id?modId = null, bool?personal = null, Id?buildTypeId = null, string branch = null) { var param = new List <string>(); if (tab != null) { param.Add($"tab={WebUtility.UrlEncode(tab)}"); } if (projectId.HasValue) { param.Add($"projectId={WebUtility.UrlEncode(projectId.Value.StringId)}"); } if (buildId.HasValue) { param.Add($"buildId={WebUtility.UrlEncode(buildId.Value.StringId)}"); } if (testNameId.HasValue) { param.Add($"testNameId={WebUtility.UrlEncode(testNameId.Value.StringId)}"); } if (userId.HasValue) { param.Add($"userId={WebUtility.UrlEncode(userId.Value.StringId)}"); } if (modId.HasValue) { param.Add($"modId={WebUtility.UrlEncode(modId.Value.StringId)}"); } if (personal.HasValue) { var personalStr = personal.Value ? "true" : "false"; param.Add($"personal={personalStr}"); } if (buildTypeId.HasValue) { param.Add($"buildTypeId={WebUtility.UrlEncode(buildTypeId.Value.StringId)}"); } if (!String.IsNullOrEmpty(branch)) { param.Add($"branch={WebUtility.UrlEncode(branch)}"); } var paramStr = param.IsNotEmpty() ? String.Join("&", param) : String.Empty; return($"{this.ServerUrl}/{pageName}?{paramStr}"); }
public bool Equals(Id?other) { if (ReferenceEquals(null, other)) { return(false); } if (ReferenceEquals(this, other)) { return(true); } return(_value.Equals(other.Value())); }
public override bool Equals(object obj) { Id?pc = obj as Id?; if (pc == null) { return(false); } Id o = pc.Value; return(o.id == id); }
public ConnectionDataFull( string address, IdentityData identity, TsVersionSigned?versionSign = null, string?username = null, Password?serverPassword = null, string?defaultChannel = null, Password?defaultChannelPassword = null, Id?logId = null) : base(address, logId) { Identity = identity; VersionSign = versionSign ?? (Tools.IsLinux ? TsVersionSigned.VER_LIN_3_X_X : TsVersionSigned.VER_WIN_3_X_X); Username = username ?? "TSLibUser"; ServerPassword = serverPassword ?? Password.Empty; DefaultChannel = defaultChannel ?? string.Empty; DefaultChannelPassword = defaultChannelPassword ?? Password.Empty; }
/// <summary> /// Loads holiday data from an XML file and adds, merges, removes or replaces /// the standard German holidays which are calculated automatically. /// All element and attribute names/values must match XML standards, but are not case sensitive. /// Dates not in scope of the year given with CTOR will just be ignored. /// </summary> /// <remarks> /// "Add": a holiday is added, even when a holiday already exists for this date. /// "Merge": a holiday is added, unless there is already a holiday present for this date. /// "Replace": an existing standard holiday is compeltely replaced with the data loaded. /// "Remove:" remove a standard holiday from the list. /// </remarks> /// <param name="path">A URI string referencing the holidays XML file to load.</param> public void Load(string path) { // load holiday data from XML file var holidayQuery = from holiday in XElement.Load(path).Elements() where holiday.Name.ToString().ToLower() == "holiday" select holiday; foreach (XElement holiday in holidayQuery) { // get the standard German holiday id (if any) Id?holidayId = null; if (holiday.Attributes().Count(e => e.Name.ToString().ToLower() == "id") != 0) { holidayId = (Id)Enum.Parse(typeof(Id), holiday.Attributes().First( e => e.Name.ToString().ToLower() == "id").Value, true); } // what to do with this holiday? The default action is "Merge". ActionType action = ActionType.Merge; if (holiday.Attributes().Count(e => e.Name.ToString().ToLower() == "action") != 0) { action = (ActionType)Enum.Parse(typeof(ActionType), holiday.Attributes().First( e => e.Name.ToString().ToLower() == "action").Value, true); } // remove an existing (standard German) holiday if (action == ActionType.Remove && holidayId.HasValue) { Remove(this[holidayId.Value]); continue; } // get the dates (if any) DateTime dateFrom = DateTime.MinValue; DateTime dateTo = DateTime.MinValue; if (holiday.Elements().Count(e => e.Name.ToString().ToLower() == "datefrom") != 0 && holiday.Elements().Count(e => e.Name.ToString().ToLower() == "dateto") != 0) { dateFrom = DateTime.Parse( holiday.Elements().First(e => e.Name.ToString().ToLower() == "datefrom").Value); dateTo = DateTime.Parse(holiday.Elements().First(e => e.Name.ToString().ToLower() == "dateto").Value); // Swap dates if mixed up if (dateFrom > dateTo) { DateTime tmp = dateFrom; dateFrom = dateTo; dateTo = tmp; } // holiday must be within the year given by CTOR if (dateFrom.Year < _year && dateTo.Year == _year) { dateFrom = new DateTime(_year, 1, 1); } if (dateFrom.Year == _year && dateTo.Year > _year) { dateTo = new DateTime(_year, 12, 31); } if (dateFrom.Year != _year && dateTo.Year != _year) { continue; } } // get the holiday type Type holidayType = (Type) Enum.Parse(typeof(Type), holiday.Elements().First(e => e.Name.ToString().ToLower() == "type").Value, true); string name = holiday.Elements().First(e => e.Name.ToString().ToLower() == "name").Value; // get the federal state ids (if any) XElement stateIds = null; List <GermanFederalStates.Id> germanFederalStateIds = new List <GermanFederalStates.Id>(); if (holiday.Elements().Any(e => e.Name.ToString().ToLower() == "publicholidaystateids")) { stateIds = holiday.Elements().First(e => e.Name.ToString().ToLower() == "publicholidaystateids"); if (stateIds.HasElements) { foreach (XElement stateId in stateIds.Elements()) { germanFederalStateIds.Add((GermanFederalStates.Id)Enum.Parse(typeof(GermanFederalStates.Id), stateId.Value, true)); } } } // Only with Replace action the dates may be missing if (action != ActionType.Replace && (dateFrom == DateTime.MinValue || dateTo == DateTime.MinValue)) { throw new Exception("Missig 'date from' and/or 'date to' in XML data."); } while (dateFrom <= dateTo) { DateTime tmpDateFrom = new DateTime(dateFrom.Ticks); GermanHoliday germanHoliday = new GermanHoliday(holidayId, holidayType, name, () => tmpDateFrom); germanHoliday.PublicHolidayStateIds = germanFederalStateIds; switch (action) { case ActionType.Merge: Merge(germanHoliday); break; case ActionType.Add: Add(germanHoliday); break; case ActionType.Replace: if (holidayId.HasValue) { // replace the existing standard date only if a new date was given if (tmpDateFrom != DateTime.MinValue) { this[holidayId.Value].DoCalcDate = () => tmpDateFrom; } this[holidayId.Value].Type = holidayType; this[holidayId.Value].Name = name; // replace state ids, if any were supplied if (stateIds != null) { this[holidayId.Value].PublicHolidayStateIds = germanFederalStateIds; } } break; } dateFrom = dateFrom.AddDays(1); } } }
public string NullableIdField(Id?idArg) => idArg?.IdentifierForType <Dependency>();
public ConnectionData(string address, Id?logId = null) { Address = address; LogId = logId ?? Id.Null; }
public ITestRunsLocator ForTest(Id testId) { this._testId = testId; return(this); }
public ITestRunsLocator ForProject(Id projectId) { this._affectedProjectId = projectId; return(this); }
public IBuildLocator SnapshotDependencyTo(Id buildId) { _snapshotDependencyTo = buildId; return(this); }
public IBuildLocator FromBuildType(Id buildTypeId) { _buildTypeId = buildTypeId; return(this); }
public IInvestigationLocator ForProject(Id projectId) { this._affectedProjectId = projectId; return(this); }
public string GetHomeUrl(Id?specificBuildTypeId = null, bool?includePersonalBuilds = null) => Instance.GetUserUrlPage( "viewModification.html", modId: Id, buildTypeId: specificBuildTypeId, personal: includePersonalBuilds);
public ITestRunsLocator ForBuild(Id buildId) { this._buildId = buildId; return(this); }
public InventoryItemModel(Id?id, string?name, bool activated) { this.id = id; this.name = name; this.activated = activated; }