public GitBackupStatus InPlaceGitBackup(string repositoryFolder) { var isValidGitRepository = Repository.IsValid(repositoryFolder); var createdRepository = false; if (!isValidGitRepository) { _logger.InfoFormat("Initializing git repository in folder '{0}'...", repositoryFolder); repositoryFolder = Repository.Init(repositoryFolder, false); createdRepository = true; } var numberOfFilesAdded = 0; var numberOfFilesChanged = 0; var numberOfFilesRemoved = 0; using (var repository = new Repository(repositoryFolder)) { var options = new StatusOptions(); var status = repository.RetrieveStatus(options); _logger.Debug("Repository Status: " + JsonConvert.SerializeObject(status)); if (status.IsDirty) { var untractedFiles = status.Untracked; foreach (var untrackedFile in untractedFiles) { _logger.Info("Added: " + untrackedFile.FilePath); var stageOptions = new StageOptions(); repository.Stage(untrackedFile.FilePath, stageOptions); numberOfFilesAdded++; } var modifiedFiles = status.Modified; foreach (var modifiedFile in modifiedFiles) { _logger.Info("Modified: " + modifiedFile.FilePath); var stageOptions = new StageOptions(); repository.Stage(modifiedFile.FilePath, stageOptions); numberOfFilesChanged++; } var removedFiles = status.Missing; foreach (var removedFile in removedFiles) { _logger.Info("Removed: " + removedFile.FilePath); var stageOptions = new StageOptions(); repository.Stage(removedFile.FilePath, stageOptions); numberOfFilesRemoved++; } var email = GetNoReplyEmail(); var author = new Signature(Environment.UserName, email, DateTimeOffset.Now); var committer = new Signature(Environment.UserName, email, DateTimeOffset.Now); var commitOptions = new CommitOptions(); _logger.Info("Commiting..."); repository.Commit(DateTime.Now.ToString(CultureInfo.InvariantCulture), author, committer, commitOptions); } } var gitBackupStatus = new GitBackupStatus(createdRepository, numberOfFilesAdded, numberOfFilesChanged, numberOfFilesRemoved); return(gitBackupStatus); }
private static void Status(StatusOptions opts) { try { var bcore = LoadCore(); string bsname = GetBackupSetName(opts.BSName, bcore.SrcDependencies); TablePrinter table = new TablePrinter(); table.AddHeaderRow(new string[] { "Path", "Status" }); List <(int, string)>?trackclasses; try { trackclasses = Core.ReadTrackClassFile(Path.Combine(GetBUSourceDir(), TrackClassFile)); } catch { trackclasses = null; } foreach (var change in bcore.GetWTStatus(bsname, true, trackclasses, opts.BackupHash)) { table.AddBodyRow(new string[] { change.path, change.change.ToString() }); } Console.WriteLine(table); } catch (Exception e) { Console.WriteLine(e.Message); } }
protected override void HandleGit(Repository repo, string directory, string relativeDir, string repoUrl) { var options = new StatusOptions { IncludeIgnored = true, IncludeUntracked = true, Show = StatusShowOption.IndexAndWorkDir, DetectRenamesInIndex = true, DetectRenamesInWorkDir = true, }; List <StatusEntry> statuses = repo.RetrieveStatus(options) .Where(s => s.State == FileStatus.Ignored || s.State == FileStatus.NewInWorkdir) .ToList(); bool hasChanges = statuses.Count > 0; PrintLine($"{(hasChanges ? Cyan : White)}{relativeDir}"); if (!hasChanges) { return; } foreach (StatusEntry status in statuses) { bool isDirectory = status.FilePath.EndsWith("/"); PrintLine($" [{(isDirectory ? 'D' : 'F')}] {status.FilePath}"); } }
private void Update() { // look at the web cam every so often if (WebCamTexture != null && WebCamTexture.isPlaying) { switch (Status) { case StatusOptions.wait: case StatusOptions.failed: _accrued += Time.deltaTime; if (_accrued > PollTime) { _status = StatusOptions.look; } break; case StatusOptions.looking: // nothing to do break; case StatusOptions.look: _status = StatusOptions.looking; Look(WebCamTexture); break; } } // dispatch messages while (_messages.Count > 0 && OnMessage != null) { OnMessage(this, _messages.Dequeue()); } }
private void setupOptions(string Username, SecureString SecurePassword, string RepoPath, string RepoUrl) { credentials = new SecureUsernamePasswordCredentials() { Username = Username, Password = SecurePassword }; var credentialsProvider = new CredentialsHandler((_url, _user, _cred) => new SecureUsernamePasswordCredentials { Username = Username, Password = SecurePassword }); fetchOptions = new FetchOptions() { CredentialsProvider = credentialsProvider }; pullOptions = new PullOptions() { FetchOptions = fetchOptions }; pushOptions = new PushOptions() { CredentialsProvider = credentialsProvider }; cloneOptions = new CloneOptions() { CredentialsProvider = credentialsProvider }; statusOptions = new StatusOptions() { ExcludeSubmodules = true, IncludeUnaltered = false }; }
protected void Page_Load(object sender, EventArgs e) { SystemID = string.IsNullOrEmpty(Request["sysId"]) ? 0 : Convert.ToInt32(Request["sysId"]); List <SystemInfo> systems = new List <SystemInfo>(); systems.Add(new SystemInfo { ID = 0, Name = "全部系统" }); systems.AddRange(loginService.AdminSystems); ddlSystems.DataSource = systems; ddlSystems.DataTextField = "Name"; ddlSystems.DataValueField = "ID"; ddlSystems.DataBind(); ddlSystems.SelectedValue = SystemID.ToString(); ddlSystems.AutoPostBack = false; if (Request.QueryString["action"] == "ExportToExcel") { ExportToExcel(); Response.End(); } Status = string.IsNullOrEmpty(Request["status"]) ? StatusOptions.Valid : (StatusOptions)Convert.ToInt32(Request["status"]); AccountType = string.IsNullOrEmpty(Request["accountType"]) ? UserTypeOptions.General : (UserTypeOptions)Convert.ToInt32(Request["accountType"]); Keyword = Request["keyword"] == null ? string.Empty : Request["keyword"]; IsOnlyWhiteUser = Request["checkOnlyWhite"] == null ? false : Convert.ToBoolean(Request["checkOnlyWhite"]); ReturnUrl = HttpUtility.UrlEncode(Request.RawUrl); BindData(); }
public override void Run(Result result, ScanResult scanResult) { foreach (var gitRepository in scanResult.Repositories) { using (var repo = new Repository(gitRepository.DirectoryInfo.FullName)) { StatusOptions options = new StatusOptions(); options.Show = StatusShowOption.IndexAndWorkDir; options.DetectRenamesInIndex = true; options.DetectRenamesInWorkDir = true; options.RecurseIgnoredDirs = true; RepositoryStatus status = repo.RetrieveStatus(options); if (!status.IsDirty) { string gitPath = ConfigurationManager.AppSettings["GitPath"]; if (!String.IsNullOrWhiteSpace(gitPath)) { ProcessStartInfo psi = new ProcessStartInfo(); psi.FileName = gitPath; psi.WorkingDirectory = gitRepository.DirectoryInfo.FullName; psi.Arguments = String.Format("clean -xdf \"{0}\"", gitRepository.DirectoryInfo.FullName); Process.Start(psi); } } else { result.AddResultItem(gitRepository, Domain.Enums.EMessageLevel.Warning, "Cannot clean - there are uncommitted changes"); } } } }
//#region 修改用户账号类型 ///// <summary> ///// 修改用户账号类型 ///// </summary> //private void UpdateUserAccountType() //{ // int id = GetQueryString("uid").ToInt32(0); // UserTypeOptions accountType = (UserTypeOptions)GetQueryString("st").ToInt32(0); // new URBasicInfoService().UpdateAccountType(id, accountType); //} //#endregion #region 修改用户状态 /// <summary> /// 修改用户状态 /// </summary> private void UpdateUserStatus() { int id = GetQueryString("uid").ToInt32(0); StatusOptions status = (StatusOptions)GetQueryString("st").ToInt32(0); new URBasicInfoService().UpdateUserStatus(id, status); }
/// <summary> /// 更新用户状态 /// </summary> /// <param name="userId"></param> /// <param name="status"></param> public void UpdateUserStatus(int userId, StatusOptions status) { User user = DABasicInfoHelper.GetUser(userId); user.Status = status; UpdateUser(user); }
public Ride(int id, string name, CategoryOptions category, StatusOptions status, List <Report> reports = null) { Id = id; Name = name; Category = category; Status = status; Reports = reports; }
public Report(int id, Ride rideReportedOn, StatusOptions status, DateTime reportTime, string notes) { Id = id; RideReportedOn = rideReportedOn; Status = status; ReportTime = reportTime; Notes = notes; }
public static ICollection <Item> GetItems(Repository repo, StatusShowOption showOption) { StatusOptions stagedOptions = new StatusOptions() { Show = showOption, IncludeIgnored = false }; var fileNames = repo.RetrieveStatus(stagedOptions).Select(x => x.FilePath).ToList(); return(BuildTreeFromRepo.RecurseRepoItems(fileNames, repo.Info.WorkingDirectory)); }
public void OnExecute() { var checker = StatusCheckerFactory.Create(); var options = new StatusOptions(PathToStorage, WarningThreshold, CriticalThreshold, Verbose); var status = checker.GetStatus(options); foreach (var line in status) { ConsoleWriter.WriteLine(line.MessageType, line.Message); } }
/// <summary> /// 根据账号或姓名模糊查找,并分页返回用户信息列表 /// </summary> /// <param name="sysId"></param> /// <param name="status"></param> /// <param name="accountType"></param> /// <param name="keyword"></param> /// <param name="onlyWhiteUser"></param> /// <param name="pageIndex"></param> /// <param name="pageSize"></param> /// <param name="recordCount"></param> /// <returns></returns> public List <User> GetUsers(int sysId, StatusOptions status, UserTypeOptions accountType, string keyword, bool onlyWhiteUser, int pageIndex, int pageSize, ref int recordCount) { //权限判断 loginService.HaveAdminRight(sysId, true); //if (loginService.LoginUser.AccountType == UserTypeOptions.ProductAdmin) //{ // return DABasicInfoHelper.GetUsers(sysId, status, accountType, keyword, onlyWhiteUser, pageIndex, pageSize, ref recordCount); //} return(DABasicInfoHelper.GetUsers(sysId, status, accountType, keyword, onlyWhiteUser, pageIndex, pageSize, ref recordCount)); }
internal static string ToSerializedValue(this StatusOptions value) { switch (value) { case StatusOptions.Ready: return("Ready"); case StatusOptions.Pending: return("Pending"); } return(null); }
public IObservable <bool> IsWorkingDirectoryClean(ILocalRepositoryModel repository) { // The `using` appears to resolve this issue: // https://github.com/github/VisualStudio/issues/1306 using (var repo = gitService.GetRepository(repository.LocalPath)) { var statusOptions = new StatusOptions { ExcludeSubmodules = true }; var isClean = !IsFilthy(repo.RetrieveStatus(statusOptions)); return(Observable.Return(isClean)); } }
/// <summary> /// Adapted from: https://edi.wang/post/2019/3/26/operate-git-with-net-core /// </summary> private static void ExploreLibGit2Sharp() { var writer = Console.Out; var repositoryDirectoryPath = @"C:\Temp\R5T.E0004.Private"; using (var repository = new Repository(repositoryDirectoryPath)) { writer.WriteLine($"Branch count: {repository.Branches.Count()}"); foreach (var branch in repository.Branches) { writer.WriteLine($"{branch.FriendlyName} is head? {branch.IsCurrentRepositoryHead}"); if (branch.IsCurrentRepositoryHead) { var localBranchAheadBy = branch.TrackingDetails.AheadBy.GetValueOrDefault(); writer.WriteLine($"Remote branch ahead by: {localBranchAheadBy}"); } } var statusOptions = new StatusOptions() { }; var repositoryStatus = repository.RetrieveStatus(); repository.analyze var mergeOptions = new MergeOptions { FastForwardStrategy = FastForwardStrategy. } var mergeResult = repository.Merge(, ); var commit = repository.Commits.First(); var fetchResult = repository. var repositoryStatus = repository.RetrieveStatus(); global::LibGit2Sharp.Handlers. Commands.Fetch() } }
public async Task <IProduct> GetProductByIDAsync(int ID) { //throw new NotImplementedException(); Product product = new Product(); using (var Client = new HttpClient()){ Client.BaseAddress = new Uri("https://ticapacitacion.com/webapi/northwind/"); Client.DefaultRequestHeaders.Accept.Clear(); Client.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json")); // Notificar aqui que la API Web será invocad this.statusOpc = StatusOptions.CallingWebAPI; Notify(); HttpResponseMessage Response = await Client.GetAsync($"product/{ID}"); // Notificar aquí que se va a verificar el resultado de la llamada this.statusOpc = StatusOptions.VerifyingResult; Notify(); if (Response.IsSuccessStatusCode) { var JSONProduct = await Response.Content.ReadAsStringAsync(); product = JsonConvert.DeserializeObject <Product>(JSONProduct); if (product != null) { // Notificar aqui que el produto fue encontrado this.statusOpc = StatusOptions.ProductFound; Notify(); } else { // notificar producto no encontrado this.statusOpc = StatusOptions.ProductNotFound; Notify(); } } } return(product); }
public void CanDetectedVariousKindsOfRenaming() { string path = InitNewRepository(); using (var repo = new Repository(path)) { Touch(repo.Info.WorkingDirectory, "file.txt", "This is a file with enough data to trigger similarity matching.\r\n" + "This is a file with enough data to trigger similarity matching.\r\n" + "This is a file with enough data to trigger similarity matching.\r\n" + "This is a file with enough data to trigger similarity matching.\r\n"); Commands.Stage(repo, "file.txt"); repo.Commit("Initial commit", Constants.Signature, Constants.Signature); File.Move(Path.Combine(repo.Info.WorkingDirectory, "file.txt"), Path.Combine(repo.Info.WorkingDirectory, "renamed.txt")); var opts = new StatusOptions { DetectRenamesInIndex = true, DetectRenamesInWorkDir = true }; RepositoryStatus status = repo.RetrieveStatus(opts); // This passes as expected Assert.Equal(FileStatus.RenamedInWorkdir, status.Single().State); Commands.Stage(repo, "file.txt"); Commands.Stage(repo, "renamed.txt"); status = repo.RetrieveStatus(opts); Assert.Equal(FileStatus.RenamedInIndex, status.Single().State); File.Move(Path.Combine(repo.Info.WorkingDirectory, "renamed.txt"), Path.Combine(repo.Info.WorkingDirectory, "renamed_again.txt")); status = repo.RetrieveStatus(opts); Assert.Equal(FileStatus.RenamedInWorkdir | FileStatus.RenamedInIndex, status.Single().State); } }
void CheckChangesInGitRepo(DirectoryInfo rootFolder) { try { var repo = new Repository(rootFolder.FullName); var options = new StatusOptions(); var repositoryStatus = repo.RetrieveStatus(options); if (repositoryStatus.IsDirty) { Console.WriteLine("Repo [{0} in {1}] is dirty", rootFolder.Name, rootFolder.Parent.FullName); } } catch (Exception ex) { Console.WriteLine("Repo [{0}] cannot be read: [{1}]", rootFolder.Name, ex.Message); } }
public void CanDetectedVariousKindsOfRenaming() { string path = InitNewRepository(); using (var repo = new Repository(path)) { Touch(repo.Info.WorkingDirectory, "file.txt", "This is a file with enough data to trigger similarity matching.\r\n" + "This is a file with enough data to trigger similarity matching.\r\n" + "This is a file with enough data to trigger similarity matching.\r\n" + "This is a file with enough data to trigger similarity matching.\r\n"); Commands.Stage(repo, "file.txt"); repo.Commit("Initial commit", Constants.Signature, Constants.Signature); File.Move(Path.Combine(repo.Info.WorkingDirectory, "file.txt"), Path.Combine(repo.Info.WorkingDirectory, "renamed.txt")); var opts = new StatusOptions { DetectRenamesInIndex = true, DetectRenamesInWorkDir = true }; RepositoryStatus status = repo.RetrieveStatus(opts); // This passes as expected Assert.Equal(FileStatus.RenamedInWorkdir, status.Single().State); Commands.Stage(repo, "file.txt"); Commands.Stage(repo, "renamed.txt"); status = repo.RetrieveStatus(opts); Assert.Equal(FileStatus.RenamedInIndex, status.Single().State); File.Move(Path.Combine(repo.Info.WorkingDirectory, "renamed.txt"), Path.Combine(repo.Info.WorkingDirectory, "renamed_again.txt")); status = repo.RetrieveStatus(opts); Assert.Equal(FileStatus.RenamedInWorkdir | FileStatus.RenamedInIndex, status.Single().State); } }
public void ShouldHandle_InvalidPath() { // Arrange var fakeAPI = new FakeDiskAPI(); var directoryMock = new Mock <IDirectoryWrapper>(); directoryMock.Setup(dir => dir.Exists(It.IsAny <string>())).Returns(false); var checker = new StatusChecker(fakeAPI, directoryMock.Object); var opt = new StatusOptions(@"c:\temp", 50, 20); // Act var logs = checker.GetStatus(opt); // Assert Assert.AreEqual(1, logs.Count); var log = logs.First(); Assert.AreEqual($@"ERROR - Verify that you have the correct path: c:\temp", log.Message); Assert.AreEqual(MessageType.Critical, log.MessageType); }
public void ShouldHandle_Exceptions() { // Arrange var fakeAPI = new FakeDiskAPI_ThrowsExceptions(); var directoryMock = new Mock <IDirectoryWrapper>(); directoryMock.Setup(dir => dir.Exists(It.IsAny <string>())).Returns(true); var checker = new StatusChecker(fakeAPI, directoryMock.Object); var opt = new StatusOptions(@"c:\temp", 50, 20); // Act var logs = checker.GetStatus(opt); // Assert Assert.AreEqual(1, logs.Count); var log = logs.First(); Assert.AreEqual($"ERROR - Something went wrong!", log.Message); Assert.AreEqual(MessageType.Critical, log.MessageType); }
public void ShouldReturn_ProperStatus(double warning, double critical, string message, MessageType messageType) { // Arrange var fakeAPI = new FakeDiskAPI(); var directoryMock = new Mock <IDirectoryWrapper>(); directoryMock.Setup(dir => dir.Exists(It.IsAny <string>())).Returns(true); var checker = new StatusChecker(fakeAPI, directoryMock.Object); var opt = new StatusOptions(@"c:\temp", warning, critical); // Act var logs = checker.GetStatus(opt); // Assert Assert.AreEqual(1, logs.Count); var log = logs.First(); Assert.AreEqual(message, log.Message); Assert.AreEqual(messageType, log.MessageType); }
/// <exception cref="InvalidOperationException"></exception> /// <exception cref="ObjectDisposedException"></exception> /// <exception cref="OperationCanceledException"> /// Thrown if the cancellation token is cancelled or the gateway connection is closed while sending. /// </exception> public async Task UpdateStatusAsync(StatusOptions options, CancellationToken?cancellationToken = null) { if (isDisposed) { throw new ObjectDisposedException(GetType().FullName); } if (state != GatewayState.Connected) { throw new InvalidOperationException("The gateway is not currently connected!"); } CancellationToken ct = cancellationToken ?? CancellationToken.None; await RepeatTrySendPayload(ct, "UpdateStatus", async() => { // Try to send the status update await socket.SendStatusUpdate(options).ConfigureAwait(false); }).ConfigureAwait(false); }
public void RetrievingTheStatusWithoutIncludeIgnoredIgnoresButDoesntInclude() { string repoPath = InitNewRepository(); using (var repo = new Repository(repoPath)) { const string relativePath = "look-ma.txt"; Touch(repo.Info.WorkingDirectory, relativePath, "I'm going to be ignored!"); var opt = new StatusOptions { IncludeIgnored = false }; Assert.False(opt.IncludeIgnored); RepositoryStatus status = repo.RetrieveStatus(opt); Assert.Equal(new[] { relativePath }, status.Untracked.Select(s => s.FilePath)); Touch(repo.Info.WorkingDirectory, ".gitignore", "*.txt" + Environment.NewLine); RepositoryStatus newStatus = repo.RetrieveStatus(opt); Assert.Equal(".gitignore", newStatus.Untracked.Select(s => s.FilePath).Single()); Assert.False(newStatus.Ignored.Any()); } }
private Option <int, Error> RunStatusCommand(StatusOptions opts) => ConfigurationHelper.LoadEnvironmentVariables(Environment, opts.File, opts.EnvFiles) .Match( some: _ => ConfigLoader.LoadMigration(ConfigLoader.GetFilePath(Environment, opts.File)) .Match( some: x => ConfigurationHelper .SelectDbProvider(x.Provider, x.ConnectionString, x.ConnectionTimeoutSec) .SelectJournal(x.JournalTo) .SelectTransaction(x.Transaction) .SelectLogOptions(Logger, VerbosityLevel.Min) .SelectScripts(x.Scripts) .AddVariables(x.Vars) .OverrideConnectionFactory(ConnectionFactory) .Match( some: builder => { var engine = builder.Build(); if (!engine.TryConnect(out var message)) { return(Option.None <int, Error>(Error.Create(message)));
public static async Task GetRepositoryChanges(RepoModel repoModel, CancellationToken ct) { await Task.Run(() => { try { //Todo: SX_Core and AutoDEMO_DemoFiles take 20+ seconds var stopWatch = new Stopwatch(); stopWatch.Start(); using (var repo = new Repository(repoModel.Path)) { var statusOptions = new StatusOptions { IncludeIgnored = false, IncludeUnaltered = false, IncludeUntracked = false, Show = StatusShowOption.WorkDirOnly, //don't check index dir for performance RecurseIgnoredDirs = false, RecurseUntrackedDirs = false, ExcludeSubmodules = true }; //this is slower?! statusOptions = new StatusOptions(); var repoStatus = repo.RetrieveStatus(statusOptions); GetFileStatusInfo(repoStatus, out var Changes, out var ChangeString); repoModel.ChangeString = ChangeString; repoModel.Changes = Changes; stopWatch.Stop(); var ts = stopWatch.Elapsed; Debug.WriteLine($"GetRepositoryChanges: {repoModel.Name} - {ts.Hours:D2}h:{ts.Minutes:D2}m:{ts.Seconds:D2}s:{ts.Milliseconds:D3}ms"); } } catch (Exception ex) { Debug.WriteLine($"GetRepoModelSolutionsList: {ex.Message}"); } }, ct); }
public override void Run(Result result, ScanResult scanResult) { string username = String.Empty; FetchOptions fetchOptions = ReadFetchOptions(out username); foreach (var gitRepository in scanResult.Repositories) { using (var repo = new Repository(gitRepository.DirectoryInfo.FullName)) { StatusOptions options = new StatusOptions(); options.Show = StatusShowOption.IndexAndWorkDir; options.DetectRenamesInIndex = true; options.DetectRenamesInWorkDir = true; options.RecurseIgnoredDirs = true; RepositoryStatus status = repo.RetrieveStatus(options); if (!status.IsDirty) { if (repo.Head.TrackingDetails.AheadBy == 0) { Output.WriteLine("Pulling changes for repo: {0}", gitRepository.DirectoryInfo.FullName); repo.Fetch("origin", fetchOptions); Commit latestCommit = repo.Head.TrackedBranch.Commits.FirstOrDefault(); if (latestCommit != null) { repo.Merge(latestCommit, new Signature(username, username, new DateTimeOffset(DateTime.Now))); } } else { result.AddResultItem(gitRepository, EMessageLevel.Warning, "Cannot pull - there are unpushed changes"); } } else { result.AddResultItem(gitRepository, EMessageLevel.Warning, "Cannot pull - there are uncommitted changes"); } } } }
public string GetSatusOfRepo(string repoPath) { string status = string.Empty; using (var repo = new Repository(repoPath)) { StatusOptions options = new StatusOptions(); options.IncludeUnaltered = true; options.IncludeIgnored = true; options.ExcludeSubmodules = false; options.RecurseIgnoredDirs = true; options.Show = StatusShowOption.IndexAndWorkDir; foreach (var item in repo.RetrieveStatus(options)) { status += item.FilePath + ": " + item.State.ToString() + "\n"; } foreach (var branch in repo.Branches) { status += "Branch " + branch.CanonicalName + ": "; if (branch.TrackingDetails != null) { if (branch.TrackingDetails.AheadBy.HasValue) { status += "ahead by " + branch.TrackingDetails.AheadBy.Value + ", "; } if (branch.TrackingDetails.BehindBy.HasValue) { status += "behind by " + branch.TrackingDetails.BehindBy.Value + "."; } } status += "\n"; } } return(status); }
/// <exception cref="DiscordWebSocketException">Thrown if the payload fails to send because of a WebSocket error.</exception> /// <exception cref="InvalidOperationException">Thrown if the socket is not connected.</exception> public async Task SendStatusUpdate(StatusOptions options) { DiscordApiData data = new DiscordApiData(DiscordApiDataType.Container); data.Set("since", options.AfkSince); data.Set("afk", options.Afk); data.Set("status", options.GetStatusString()); if (options.Game != null) { DiscordApiData gameData = new DiscordApiData(DiscordApiDataType.Container); data.Set("game", gameData); gameData.Set("name", options.Game.Name); gameData.Set("type", (int)options.Game.Type); gameData.Set("url", options.Game.Url); } // Check with the game status update limiter await gameStatusUpdateRateLimiter.Invoke().ConfigureAwait(false); // Send status update await SendPayload(GatewayOPCode.StatusUpdate, data).ConfigureAwait(false); }
private void UpdateVisibility(StatusOptions status) { LoadingStatus.Visibility = (status == StatusOptions.Connecting) ? Visibility.Visible : Visibility.Collapsed; ConnectionError.Visibility = (status == StatusOptions.ConnectionError) ? Visibility.Visible : Visibility.Collapsed; ParseError.Visibility = (status == StatusOptions.ParseError) ? Visibility.Visible : Visibility.Collapsed; RiverList.Visibility = (status == StatusOptions.Ok) ? Visibility.Visible : Visibility.Collapsed; }
public void RetrievingTheStatusWithoutIncludeIgnoredIgnoresButDoesntInclude() { string repoPath = InitNewRepository(); using (var repo = new Repository(repoPath)) { const string relativePath = "look-ma.txt"; Touch(repo.Info.WorkingDirectory, relativePath, "I'm going to be ignored!"); var opt = new StatusOptions { IncludeIgnored = false }; Assert.False(opt.IncludeIgnored); RepositoryStatus status = repo.RetrieveStatus(opt); Assert.Equal(new[] { relativePath }, status.Untracked.Select(s => s.FilePath)); Touch(repo.Info.WorkingDirectory, ".gitignore", "*.txt" + Environment.NewLine); RepositoryStatus newStatus = repo.RetrieveStatus(opt); Assert.Equal(".gitignore", newStatus.Untracked.Select(s => s.FilePath).Single()); Assert.False(newStatus.Ignored.Any()); } }