protected override void EndProcessing() { for (int i = 1; i <= _list.Count; i++) { IQUserObject sid = _list[i - 1]; if (this.Force || this.ShouldProcess(sid.UserName + " - " + sid.HostName, "Logging off")) { this.UpdateProgress(0, i, sid); this.WriteVerbose("Executing remote log off of '" + sid.UserName + "' on '" + sid.HostName + "'..."); this.Remover.LogoffRemoteUser(sid); } } this.UpdateProgress(0); }
private void UpdateProgress(int id, int on, IQUserObject sid) { string status; if (sid.HostName == LH || sid.HostName == Environment.GetEnvironmentVariable(COMPUTERNAME)) { status = string.Format(STATUS_FORMAT, on, this.TotalCount, sid.UserName); } else { status = string.Format(MULTI_STATUS_FORMAT, sid.HostName, string.Format(STATUS_FORMAT, on, this.TotalCount, sid.UserName)); } var pr = new ProgressRecord(id, ACTIVITY, status); double num = Math.Round((((double)on / (double)this.TotalCount) * 100), 2, MidpointRounding.ToEven); pr.PercentComplete = Convert.ToInt32(num); this.WriteProgress(pr); }
IList <IQUserObject> IWildcardMatcher.PerformWildcardMatch(IList <IQUserObject> list, string property, string wildcardSearch) { if (property != "SessionName" && property != "UserName") { throw new ArgumentException("Only 'SessionName' and 'UserName' support wildcard searching!"); } var search = new WildcardPattern(wildcardSearch, WildcardOptions.IgnoreCase); PropertyInfo pi = typeof(IQUserObject).GetProperty(property, BindingFlags.Public | BindingFlags.Instance); for (int i = list.Count - 1; i >= 0; i--) { IQUserObject obj = list[i]; string value = pi.GetValue(obj) as string; if (!search.IsMatch(value)) { list.Remove(obj); } } return(list); }
public void LogoffRemoteUser(IQUserObject sid) { ProcessStartInfo psi = this.NewProcessStartInfo(sid.Id.Value, sid.HostName); this.Run(psi); }