/// <inheritdoc/> public override async Task <bool> IsPastDueAsync(string timerName, DateTime now, TimerSchedule schedule) { StatusEntry status = GetStatus(timerName); DateTime recordedNextOccurrence; if (status == null) { // If we've never recorded a status for this timer, write an initial // status entry. This ensures that for a new timer, we've captured a // status log for the next occurrence even though no occurrence has happened yet // (ensuring we don't miss an occurrence) DateTime nextOccurrence = schedule.GetNextOccurrence(now); await UpdateAsync(timerName, default(DateTime), nextOccurrence); recordedNextOccurrence = nextOccurrence; } else { // ensure that the schedule hasn't been updated since the last // time we checked, and if it has, update the status file DateTime expectedNextOccurrence = schedule.GetNextOccurrence(status.Last); if (status.Next != expectedNextOccurrence) { await UpdateAsync(timerName, status.Last, expectedNextOccurrence); } recordedNextOccurrence = status.Next; } // if now is after the last next occurrence we recorded, we know we've missed // at least one schedule instance return(now > recordedNextOccurrence); }
public void SetStatus(StatusEntry status) { key = status.key; last_status_update_time.Restart(); string text = status.LastStatusMessage; bool cancel = status.LastStatusMessageCancellable; ObjTextSquare.IsEnabled = cancel; ObjTextSquare.Width = 16; ObjTextSquareText.Text = cancel ? "X" : "■"; ObjTextBlock.Text = Utilities.Strings.StringTools.TrimToLengthWithEllipsis(text); ObjTextBlock.ToolTip = text; double w = ObjTextBlock.ActualWidth; if (String.IsNullOrEmpty(text)) { Visibility = Visibility.Collapsed; ObjProgressBar.Value = 0; ObjProgressBar.Visibility = Visibility.Collapsed; } else { Visibility = Visibility.Visible; double pct = status.UpdatePerunage; ObjProgressBar.Value = 100 * pct; ObjProgressBar.Visibility = pct > 0.0 ? Visibility.Visible : Visibility.Collapsed; } }
public void RetrievingTheStatusOfARepositoryReturnNativeFilePaths() { // Build relative path string relFilePath = Path.Combine("directory", "Testfile.txt"); // Open the repository string repoPath = InitNewRepository(); using (var repo = new Repository(repoPath)) { Touch(repo.Info.WorkingDirectory, relFilePath, "Anybody out there?"); // Add the file to the index Commands.Stage(repo, relFilePath); // Get the repository status RepositoryStatus repoStatus = repo.RetrieveStatus(); Assert.Equal(1, repoStatus.Count()); StatusEntry statusEntry = repoStatus.Single(); Assert.Equal(relFilePath, statusEntry.FilePath); Assert.Equal(statusEntry.FilePath, repoStatus.Added.Select(s => s.FilePath).Single()); } }
public void Add(string Key, StatusEntry Value) { lock (_cacheLock) { _cache[Key] = Value; } }
public FileStatus(StatusEntry entry) { Entry = entry; switch (entry.State) { case LibGit2Sharp.FileStatus.Conflicted: Status = Status.Conflicted; break; case LibGit2Sharp.FileStatus.DeletedFromIndex: case LibGit2Sharp.FileStatus.DeletedFromWorkdir: Status = Status.Deleted; break; case LibGit2Sharp.FileStatus.ModifiedInIndex: case LibGit2Sharp.FileStatus.ModifiedInWorkdir: Status = Status.Modified; break; case LibGit2Sharp.FileStatus.NewInIndex: case LibGit2Sharp.FileStatus.NewInWorkdir: Status = Status.Added; break; case LibGit2Sharp.FileStatus.RenamedInIndex: case LibGit2Sharp.FileStatus.RenamedInWorkdir: Status = Status.Renamed; break; } }
public static FileStatusViewModel FromStagedChangeStatus(StatusEntry se) { return new FileStatusViewModel() { Path = se.FilePath, State = GetStagedState(se.State) }; }
public ActionResult AddVisit(int identry, Visit visit) { if (ModelState.IsValid) { var identity = (ClaimsPrincipal)Thread.CurrentPrincipal; var email = HttpContext.User.Identity.Name; // проверка в таблице Doctor doctor = db.Doctor.Where(l => l.login == email).First(); Entry entry = db.Entry.Where(l => l.id == identry).First(); // Schedule schedule = db.Schedule.Where(l => l.id == entry.id_schedule).First(); StatusEntry st = db.StatusEntry.Where(l => l.id == entry.id_status).First(); visit.id_patient = entry.id_patient; if (entry.id_doctor == doctor.id) { visit.id_doctor = doctor.id; } visit.date = schedule.date; Patient patient = db.Patient.Where(l => l.id == entry.id_patient).First(); patient.id_doctor = doctor.id; db.Visit.Add(visit); db.SaveChanges(); return(RedirectToAction("IndexForDoctor")); } return(View(visit)); }
public void DeserializesStatusFiles() { var status = StatusEntry.FromFile(_jf.Status.FullName); Assert.NotNull(status); Assert.Equal(new DateTimeOffset(2019, 1, 1, 0, 0, 39, TimeSpan.Zero), status.Timestamp); Assert.Equal("Status", status.Event); Assert.True(status.HasFlag(Flags.Docked)); Assert.True(status.HasFlag(Flags2.OnFootExterior)); Assert.Equal(1, status.Oxygen); Assert.Equal(1, status.Health); Assert.Equal(57.688763, status.Temperature); Assert.Equal("$humanoid_rechargetool_name;", status.SelectedWeapon); Assert.Equal(0.483871, status.Gravity); Assert.Equal(4, status.Pips.Sys); Assert.Equal(8, status.Pips.Eng); Assert.Equal(0, status.Pips.Wep); Assert.Equal((byte)0, status.FireGroup); Assert.Equal(GuiFocus.None, status.GuiFocus); Assert.Equal(32, status.Fuel.FuelMain); Assert.Equal(0.63, status.Fuel.FuelReservoir); Assert.Equal(0, status.Cargo); Assert.Equal(LegalState.Clean, status.LegalState); Assert.Equal(-12.955701, status.Latitude); Assert.Equal(6.249895, status.Longitude); Assert.Equal(49, status.Heading); Assert.Equal(2516467, status.Altitude); Assert.Equal("Shinrarta Dezhra A 1", status.BodyName); Assert.Equal(5635897, status.PlanetRadius); Assert.Equal(2, status.AdditionalFields.Count); Assert.Equal("Energylink", status.AdditionalFields["SelectedWeapon_Localised"]); Assert.Equal("AdditionalValue1", status.AdditionalFields["AdditionalField1"]); }
public ActionResult AddEntry(int iddoctor, Entry entry) { if (ModelState.IsValid) { var identity = (ClaimsPrincipal)Thread.CurrentPrincipal; var email = HttpContext.User.Identity.Name; // проверка в таблице Patient patient = db.Patient.Where(l => l.login == email).First(); StatusEntry st = db.StatusEntry.Where(l => l.name == "На рассмотрении").First(); Schedule sch = db.Schedule.Where(l => l.id == entry.id_schedule).First(); int z = patient.id; entry.id_patient = patient.id; entry.id_doctor = iddoctor; entry.id_status = st.id; sch.status = false; if (patient.name == null || patient.last_name == null || patient.patronymic == null || patient.adress == null || patient.date == null) { return(RedirectToAction("SendError")); } else { db.Entry.Add(entry); db.SaveChanges(); } } return(View("~/Views/Home/Index.cshtml")); }
public static void AddStatus(GameObject target, Status status) { int count = instance.statusEntries.Count; StatusEntry targetEntry = null; for (int i = 0; i < count; i++) { if (instance.statusEntries[i].target == target) { targetEntry = instance.statusEntries[i]; break; } } if (targetEntry != null) { targetEntry.AddStatus(status); return; } StatusEntry newStatus = new StatusEntry(target, new StatusContainer(status)); instance.statusEntries.Add(newStatus); }
public static void RemoveStatus(GameObject target, Status targetStatus) { int count = instance.statusEntries.Count; StatusEntry targetEntry = null; for (int i = 0; i < count; i++) { if (instance.statusEntries[i].target == target) { targetEntry = instance.statusEntries[i]; //statusManager.statusEntries.Remove(statusManager.statusEntries[i]); break; } } if (targetEntry != null) { targetEntry.RemoveStatus(targetStatus); if (string.IsNullOrEmpty(targetStatus.AnimBoolName) == false) { target.Entity().AnimHelper.PlayOrStopAnimBool(targetStatus.AnimBoolName, false); } if (targetEntry.GetStatusCount() < 1) { instance.statusEntries.Remove(targetEntry); } } }
public void RetrievingTheStatusOfARepositoryReturnNativeFilePaths() { // Initialize a new repository SelfCleaningDirectory scd = BuildSelfCleaningDirectory(); const string directoryName = "directory"; const string fileName = "Testfile.txt"; // Create a file and insert some content string directoryPath = Path.Combine(scd.RootedDirectoryPath, directoryName); string filePath = Path.Combine(directoryPath, fileName); Directory.CreateDirectory(directoryPath); File.WriteAllText(filePath, "Anybody out there?"); // Open the repository using (Repository repo = Repository.Init(scd.DirectoryPath)) { // Add the file to the index repo.Index.Stage(filePath); // Get the repository status RepositoryStatus repoStatus = repo.Index.RetrieveStatus(); Assert.Equal(1, repoStatus.Count()); StatusEntry statusEntry = repoStatus.Single(); Assert.Equal(Path.Combine(directoryName, fileName), statusEntry.FilePath); Assert.Equal(statusEntry.FilePath, repoStatus.Added.Single()); } }
/// <inheritdoc/> public override Task UpdateAsync(string timerName, DateTime lastOccurrence, DateTime nextOccurrence) { StatusEntry status = new StatusEntry { Last = lastOccurrence, Next = nextOccurrence }; string statusLine; using (StringWriter stringWriter = new StringWriter()) { _serializer.Serialize(stringWriter, status); statusLine = stringWriter.ToString(); } string statusFileName = GetStatusFileName(timerName); try { File.WriteAllText(statusFileName, statusLine); } catch { // best effort } return(Task.FromResult(true)); }
public int Insert(StatusEntry model) { int id = 0; using (SqlConnection conn = new SqlConnection(ConfigurationManager.ConnectionStrings["DefaultConnection"].ConnectionString)) { conn.Open(); using (SqlCommand cmd = new SqlCommand("dbo.Statuses_Insert", conn)) { cmd.CommandType = CommandType.StoredProcedure; cmd.Parameters.AddWithValue("@Title", model.Title); cmd.Parameters.AddWithValue("@Url", model.Url); cmd.Parameters.AddWithValue("@Company", model.Company); cmd.Parameters.AddWithValue("@StatusId", model.StatusId); SqlParameter parm = new SqlParameter("@Id", SqlDbType.Int); parm.Direction = ParameterDirection.Output; cmd.Parameters.Add(parm); cmd.ExecuteNonQuery(); id = (int)cmd.Parameters["@Id"].Value; }; conn.Close(); } return(id); }
public void UpdateStatus(string key, string message, long current_update_number, long total_update_count, bool cancellable) { Logging.Info("{0}:{1} ({2}/{3})", key, message, current_update_number, total_update_count); StatusEntry status_entry; lock (status_entries) { if (!status_entries.TryGetValue(key, out status_entry)) { status_entry = new StatusEntry(); status_entry.key = key; status_entries[key] = status_entry; } status_entry.last_updated = DateTime.UtcNow; status_entry.current_update_number = current_update_number; status_entry.total_update_count = total_update_count; status_entry.status_messages.Insert(0, new StatusMessage(message, cancellable)); while (status_entry.status_messages.Count > 100) { status_entry.status_messages.RemoveAt(status_entry.status_messages.Count - 1); } } if (null != OnStatusEntryUpdate) { OnStatusEntryUpdate(status_entry); } }
public static void AddStatus(Entity target, Status status, EffectStatus sourceEffect, SpecialAbility sourceAbility) { int count = statusManager.statusEntries.Count; StatusEntry targetEntry = null; for (int i = 0; i < count; i++) { if (statusManager.statusEntries[i].target == target) { targetEntry = statusManager.statusEntries[i]; break; } } if (targetEntry != null) { targetEntry.AddStatus(status, sourceEffect, sourceAbility); return; } StatusEntry newStatus = new StatusEntry(target, new StatusContainer(status)); statusManager.statusEntries.Add(newStatus); }
public static void AddStatus(GameObject target, Status status) { int count = instance.statusEntries.Count; StatusEntry targetEntry = null; for (int i = 0; i < count; i++) { if (instance.statusEntries[i].target == target) { targetEntry = instance.statusEntries[i]; break; } } if (targetEntry != null) { //Debug.Log("Status for " + target.gameObject.name + " exists"); targetEntry.AddStatus(status); return; } //Debug.Log("Status for " + target.gameObject.name + " Does not exist!"); StatusEntry newStatus = new StatusEntry(target, new StatusContainer(status)); instance.statusEntries.Add(newStatus); if (string.IsNullOrEmpty(status.AnimBoolName) == false) { target.Entity().AnimHelper.PlayOrStopAnimBool(status.AnimBoolName, true); } }
public ModifiedFile(Repository r, Commit commit, StatusEntry e, string entryFilePath) { Debug.Assert(entryFilePath == e.FilePath); _r = r; _commit = commit; _entry = e; Path = entryFilePath; }
public static FileStatusViewModel FromStagedChangeStatus(StatusEntry se) { return(new FileStatusViewModel() { Path = se.FilePath, State = GetStagedState(se.State) }); }
public void ReturnsNullWhenTheStatusFileIsEmpty() { using var dir = new TestFolder(); dir.WriteText("Status.json", string.Empty); var status = StatusEntry.FromFile(dir.Resolve("Status.json")); Assert.Null(status); }
public StatusGump(Player from) : base(200, 200) { StatusEntry[] entries = new StatusEntry[] { new StatusEntry("Race", from.Race), new StatusEntry("Skills", String.Format("{0}", (from.SkillsTotal / 10).ToString("F1"))), new StatusEntry("E.o.C", from.EssenceOfCharacter), new StatusEntry("bar"), new StatusEntry("Knockout Counts", from.KOCount), new StatusEntry("bar"), new StatusEntry("Hunger", String.Format("({0}/20)", from.Hunger)), new StatusEntry("Thirst", String.Format("({0}/20)", from.Thirst)) }; AddPage(1); AddBackground(0, 0, 255, 330, 9250); AddAlphaRegion(15, 15, 225, 300); AddButton(225, 15, 3, 4, 0, GumpButtonType.Reply, 0); // X AddButton(45, 235, 234, 234, 1, GumpButtonType.Reply, 0); AddLabel(57, 295, 1154, "Perks"); AddButton(150, 235, 229, 229, 2, GumpButtonType.Reply, 0); AddLabel(162, 295, 1154, "Skills"); AddButton(200, 125, 252, 253, 3, GumpButtonType.Reply, 0); //Reduce KO's AddLabel(20, 15, 1152, "Character Overview"); AddBar(40); for (int i = 0, y = 50; i < entries.Length; i++) { if (entries[i].Prompt == "bar") { y += 5; AddBar(y); y += 10; } else { AddLabel(20, y, LabelHue, entries[i].Prompt + ""); AddLabel(160, y, LabelHue, entries[i].Value.ToString()); y += 20; } } }
public StatusGump( Player from ) : base(200, 200) { StatusEntry[] entries = new StatusEntry[] { new StatusEntry("Race", from.Race), new StatusEntry("Skills", String.Format("{0}", (from.SkillsTotal / 10).ToString("F1"))), new StatusEntry("E.o.C", from.EssenceOfCharacter), new StatusEntry("bar"), new StatusEntry("Knockout Counts", from.KOCount), new StatusEntry("bar"), new StatusEntry("Hunger", String.Format("({0}/20)", from.Hunger )), new StatusEntry("Thirst", String.Format("({0}/20)", from.Thirst )) }; AddPage(1); AddBackground(0, 0, 255, 330, 9250); AddAlphaRegion(15, 15, 225, 300); AddButton(225, 15, 3, 4, 0, GumpButtonType.Reply, 0); // X AddButton(45, 235, 234, 234, 1, GumpButtonType.Reply, 0); AddLabel(57, 295, 1154, "Perks"); AddButton(150, 235, 229, 229, 2, GumpButtonType.Reply, 0); AddLabel(162, 295, 1154, "Skills"); AddButton(200, 125, 252, 253, 3, GumpButtonType.Reply, 0); //Reduce KO's AddLabel(20, 15, 1152, "Character Overview"); AddBar(40); for( int i = 0, y = 50; i < entries.Length; i++ ) { if( entries[i].Prompt == "bar" ) { y += 5; AddBar(y); y += 10; } else { AddLabel(20, y, LabelHue, entries[i].Prompt + ""); AddLabel(160, y, LabelHue, entries[i].Value.ToString()); y += 20; } } }
private void WriteFile(StatusEntry entry, int idx) { string startCharacters = " "; if (idx == _seletedLine) { startCharacters = ">>> "; } Console.WriteLine($"{startCharacters}{GetFileStatusFriendlyDescription(entry.State)} | {entry.FilePath}"); }
public ActionResult Create(StatusEntry statusEntry) { if (ModelState.IsValid) { db.StatusEntry.Add(statusEntry); db.SaveChanges(); return(RedirectToAction("Index")); } return(View(statusEntry)); }
public TestPage(ViewModelTest viewmodelTest) { this.viewmodelTest = viewmodelTest; BindingContext = this.viewmodelTest; InitializeComponent(); VersionTextLabel.SetBinding <ViewModelTest>(Label.TextProperty, vm => vm.VersionText, BindingMode.OneWay); LoginOkButton.SetBinding(Button.IsEnabledProperty, "LoginOK", BindingMode.OneWay); // TestEntry.SetBinding(Entry.KeyboardProperty,"TestEntry",BindingMode.OneWay); StatusEntry.SetBinding <ViewModelTest>(Entry.TextProperty, vm => vm.StatusText, BindingMode.OneWayToSource); }
public async Task <IActionResult> PutStatusEntry(long id, StatusEntry project) { if (id != project.Id) { return(BadRequest()); } return(await _statusEntryService.ModifyStatusEntry(project) ? (IActionResult)base.NoContent() : base.NotFound()); }
private void DoTheAction() { if (_gitEntries == null || _gitEntries.Count == 0) { return; } StatusEntry entry = _gitEntries[_seletedLine]; if (entry == null) { throw new ArgumentNullException(nameof(entry)); } switch (entry.State) { case FileStatus.NewInIndex: case FileStatus.ModifiedInIndex: case FileStatus.DeletedFromIndex: case FileStatus.RenamedInIndex: case FileStatus.TypeChangeInIndex: using (var repo = new Repository(_repositoryPath)) { Commands.Unstage(repo, entry.FilePath); } break; case FileStatus.NewInWorkdir: case FileStatus.ModifiedInWorkdir: case FileStatus.TypeChangeInWorkdir: case FileStatus.RenamedInWorkdir: using (var repo = new Repository(_repositoryPath)) { repo.Index.Add(entry.FilePath); repo.Index.Write(); } break; case FileStatus.DeletedFromWorkdir: using (var repo = new Repository(_repositoryPath)) { repo.Index.Remove(entry.FilePath); repo.Index.Write(); } break; default: throw new NotImplementedException(); } InitializeScreen(); }
/// <summary> /// Returns the <see cref="TimeSpan"/> duration that the specified timer is past due. /// </summary> /// <param name="timerName">The name of the timer.</param> /// <param name="now">The current time.</param> /// <param name="schedule">The <see cref="TimerSchedule"/>.</param> /// <returns>The duration the timer is past due.</returns> protected async Task <TimeSpan> GetPastDueDuration(string timerName, DateTime now, TimerSchedule schedule) { StatusEntry status = GetStatus(timerName); DateTime recordedNextOccurrence; if (status == null) { // If we've never recorded a status for this timer, write an initial // status entry. This ensures that for a new timer, we've captured a // status log for the next occurrence even though no occurrence has happened yet // (ensuring we don't miss an occurrence) DateTime nextOccurrence = schedule.GetNextOccurrence(now); await UpdateAsync(timerName, default(DateTime), nextOccurrence); recordedNextOccurrence = nextOccurrence; } else { // ensure that the schedule hasn't been updated since the last // time we checked, and if it has, update the status file DateTime expectedNextOccurrence; if (status.Last == default(DateTime)) { // there have been no executions of the function yet, so compute // from now expectedNextOccurrence = schedule.GetNextOccurrence(now); } else { // compute the next occurrence from the last expectedNextOccurrence = schedule.GetNextOccurrence(status.Last); } if (status.Next != expectedNextOccurrence) { await UpdateAsync(timerName, status.Last, expectedNextOccurrence); } recordedNextOccurrence = status.Next; } if (now > recordedNextOccurrence) { // if now is after the last next occurrence we recorded, we know we've missed // at least one schedule instance and we are past due return(now - recordedNextOccurrence); } else { // not past due return(TimeSpan.Zero); } }
public void DeserializesStatusFiles() { var status = StatusEntry.FromFile(_jf.Status.FullName); Assert.NotNull(status); Assert.Equal("Status", status.Event); Assert.True(status.HasFlag(Flags.Docked)); Assert.Equal(4, status.Pips.Sys); Assert.Equal(8, status.Pips.Eng); Assert.Equal(0, status.Pips.Wep); Assert.Equal(1, status.AdditionalFields.Count); Assert.Equal("AdditionalValue1", status.AdditionalFields["AdditionalField1"]); }
private StatusEntry Mapper(SqlDataReader reader) { StatusEntry model = new StatusEntry(); int index = 0; model.Id = reader.GetInt32(index++); model.Title = reader.GetString(index++); model.Url = reader.GetString(index++); model.Company = reader.GetString(index++); model.StatusId = reader.GetInt32(index++); model.Status = reader.GetString(index++); model.Modified = reader.GetDateTime(index++); return(model); }
internal async Task <StatusEntry> RemoveStatusEntry(long id) { StatusEntry StatusEntry = await GetStatusEntry(id); //if (StatusEntry == null) //{ // return NotFound(); //} _context.StatusEntries.Remove(StatusEntry); await _context.SaveChangesAsync(); return(await _context.StatusEntries.FindAsync(id)); }
public static string ToReadableString(this StatusEntry status) { if ((status.State & FileStatus.RenamedInIndex) == FileStatus.RenamedInIndex || (status.State & FileStatus.RenamedInWorkdir) == FileStatus.RenamedInWorkdir) { var oldFilePath = ((status.State & FileStatus.RenamedInIndex) != 0) ? status.HeadToIndexRenameDetails.OldFilePath : status.IndexToWorkDirRenameDetails.OldFilePath; return(string.Format(CultureInfo.InvariantCulture, "{0}: {1} -> {2}", status.State.ToReadableString(), oldFilePath, status.FilePath)); } return(string.Format(CultureInfo.InvariantCulture, "{0}: {1}", status.State.ToReadableString(), status.FilePath)); }
private static bool IsStaged(StatusEntry entry) { if ((entry.State & FileStatus.Added) == FileStatus.Added) { return true; } if ((entry.State & FileStatus.Staged) == FileStatus.Staged) { return true; } if ((entry.State & FileStatus.Removed) == FileStatus.Removed) { return true; } return false; }
/// <inheritdoc/> public override Task UpdateAsync(string timerName, DateTime lastOccurrence, DateTime nextOccurrence) { StatusEntry status = new StatusEntry { Last = lastOccurrence, Next = nextOccurrence }; string statusLine; using (StringWriter stringWriter = new StringWriter()) { _serializer.Serialize(stringWriter, status); statusLine = stringWriter.ToString(); } string statusFileName = GetStatusFileName(timerName); try { File.WriteAllText(statusFileName, statusLine); } catch { // best effort } return Task.FromResult(true); }
public ModifiedFile( Repository r, Commit commit, StatusEntry e ) { _r = r; _commit = commit; _entry = e; }
public GitFile(Repository repository, StatusEntry fileStatusEntry) { FileStatusEntry = fileStatusEntry; _path = Path.GetFullPath(string.Format(PATH_STRING, repository.Info.WorkingDirectory, FileStatusEntry.FilePath)).ToLower(); }
public FileStatusEntry(StatusEntry status) : this(status.FilePath, status.State) { }
private static bool IsStaged(StatusEntry entry) { if ((entry.State & FileStatus.NewInIndex) == FileStatus.NewInIndex) { return true; } if ((entry.State & FileStatus.ModifiedInIndex) == FileStatus.ModifiedInIndex) { return true; } if ((entry.State & FileStatus.DeletedFromIndex) == FileStatus.DeletedFromIndex) { return true; } return false; }
public ModifiedFile( Repository r, Commit commit, StatusEntry e, string entryFilePath ) { Debug.Assert( entryFilePath == e.FilePath ); _r = r; _commit = commit; _entry = e; Path = entryFilePath; }