public IActionResult UpdateStatusSet(long ssId, string statusSetJson) { StatusSet newStatusSet = StatusSetFromJson(statusSetJson); if (newStatusSet == null) { return(BadRequest()); } using (var context = new TodoContext()) { StatusSet oldStatusSet = context.StatusSets.Find(ssId); if (oldStatusSet == null) { return(NotFound()); } var oldEnt = context.Attach(oldStatusSet); oldEnt.Collection("Statuses").Load(); oldStatusSet.Name = newStatusSet.Name; foreach (var status in oldStatusSet.Statuses) { var ent = context.Statuses.Remove(status); } oldStatusSet.Statuses.Clear(); foreach (var status in newStatusSet.Statuses) { context.Statuses.Add(status); oldStatusSet.Statuses.Add(status); } context.SaveChanges(); return(NoContent()); } }
public RezPls(DalamudPluginInterface pluginInterface) { Dalamud.Initialize(pluginInterface); Version = Assembly.GetExecutingAssembly().GetName().Version?.ToString() ?? ""; Config = RezPlsConfig.Load(); StatusSet = new StatusSet(); _actorWatcher = new ActorWatcher(StatusSet); _overlay = new Overlay(_actorWatcher); _interface = new Interface(this); if (Config.Enabled) { Enable(); } else { Disable(); } Dalamud.Commands.AddHandler("/rezpls", new CommandInfo(OnRezPls) { HelpMessage = "Open the configuration window for RezPls.", ShowInHelp = true, }); }
public async Task <ActionResult> DeleteConfirmed(int id) { StatusSet statusSet = await db.StatusSets.FindAsync(id); db.StatusSets.Remove(statusSet); await db.SaveChangesAsync(); return(RedirectToAction("Index")); }
/// <summary> /// Get a short representation of the status set. /// </summary> /// <param name="ss">The StatusSet to format</param> /// <returns>An anonymous object representing the StatusSet</returns> public object GetShortModel(StatusSet ss) { using (var context = new TodoContext()) { var entity = context.Attach(ss); entity.Collection("Statuses").Load(); ss = entity.Entity; } return(ss); }
private volatile bool _disposedValue = false; // To detect redundant calls public StatusBarViewModel() { Global = Locator.Current.GetService <Global>(); Backend = BackendStatus.NotConnected; UseTor = false; Tor = TorStatus.NotRunning; Peers = 0; BtcPrice = "$0"; ActiveStatuses = new StatusSet(); }
public StatusBarViewModel(Global global) { Global = global; Backend = BackendStatus.NotConnected; UseTor = false; Tor = TorStatus.NotRunning; Peers = 0; BtcPrice = "$0"; ActiveStatuses = new StatusSet(); }
public async Task <ActionResult> Edit([Bind(Include = "Id,StatusDescription,LastUpdated,Active,StatusType")] StatusSet statusSet) { if (ModelState.IsValid) { db.Entry(statusSet).State = EntityState.Modified; await db.SaveChangesAsync(); return(RedirectToAction("Index")); } ViewBag.StatusType = new SelectList(db.StatusTypes, "Id", "StatusTypeDescription", statusSet.StatusType); return(View(statusSet)); }
// GET: StatusSets/Delete/5 public async Task <ActionResult> Delete(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } StatusSet statusSet = await db.StatusSets.FindAsync(id); if (statusSet == null) { return(HttpNotFound()); } return(View(statusSet)); }
public IActionResult CreateStatusSet(string newStatusSetJson) { StatusSet newStatusSet = StatusSetFromJson(newStatusSetJson); if (newStatusSet == null) { return(BadRequest()); } using (var context = new TodoContext()) { context.StatusSets.Add(newStatusSet); context.SaveChanges(); return(CreatedAtRoute("GetStatusSet", new { ssId = newStatusSet.Id }, GetDetailedModel(newStatusSet))); } }
// GET: StatusSets/Edit/5 public async Task <ActionResult> Edit(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } StatusSet statusSet = await db.StatusSets.FindAsync(id); if (statusSet == null) { return(HttpNotFound()); } ViewBag.StatusType = new SelectList(db.StatusTypes, "Id", "StatusTypeDescription", statusSet.StatusType); return(View(statusSet)); }
private void MainWindow_Load(object sender, EventArgs e) { this.progressBar1.Maximum = Properties.Settings.Default.Timer; this.progressBar1.Step = Properties.Settings.Default.Timer / 1000; statusSet = new StatusSet(setStatus); performStep = new PerformStep(performStepM); char[] delimiterChars = { ';', ':' }; List<string> fileRows = new List<string>(); try { StreamReader sReader = File.OpenText("config.ini"); string read = null; while ((read = sReader.ReadLine()) != null) { fileRows.Add(read); } } catch (Exception) { MessageBox.Show("Не найден файл config.ini"); this.Close(); } if (fileRows.Count == 0) { MessageBox.Show("Файл настроек пуст"); this.Close(); } Element[] elem = new Element[fileRows.Count]; int i = 0; foreach (string str in fileRows) { string[] stringParts = str.Split(delimiterChars); elem[i] = new Element(stringParts[0], stringParts[1]); elem[i].Location = new Point(0, elem[i].Height*i); panel1.Controls.Add(elem[i]); i++; } Watcher watcher = new Watcher(fileRows); watcher.parent = this; Thread watchDuty = new Thread(new ThreadStart(watcher.watch)); watchDuty.Start(); }
private volatile bool _disposedValue = false; // To detect redundant calls public StatusBarViewModel(string dataDir, Network network, Config config, HostedServices hostedServices, SmartHeaderChain smartHeaderChain, WasabiSynchronizer synchronizer, LegalDocuments?legalDocuments) { DataDir = dataDir; Network = network; Config = config; HostedServices = hostedServices; SmartHeaderChain = smartHeaderChain; Synchronizer = synchronizer; LegalDocuments = legalDocuments; Backend = BackendStatus.NotConnected; UseTor = false; Tor = TorStatus.NotRunning; Peers = 0; BtcPrice = "$0"; ActiveStatuses = new StatusSet(); }
private volatile bool _disposedValue = false; // To detect redundant calls public StatusBarViewModel(string dataDir, Network network, Config config, HostedServices hostedServices, SmartHeaderChain smartHeaderChain, WasabiSynchronizer synchronizer) { DataDir = dataDir; Network = network; Config = config; HostedServices = hostedServices; SmartHeaderChain = smartHeaderChain; Synchronizer = synchronizer; Backend = BackendStatus.NotConnected; UseTor = false; Tor = TorStatus.NotRunning; Peers = 0; _exchangeRate = ""; IsExchangeRateAvailable = false; ActiveStatuses = new StatusSet(); }
private void MainWindow_Load(object sender, EventArgs e) { this.progressBar1.Maximum = Properties.Settings.Default.Timer; this.progressBar1.Step = Properties.Settings.Default.Timer / 1000; statusSet = new StatusSet(setStatus); performStep = new PerformStep(performStepM); char[] delimiterChars = { ';', ':' }; List <string> fileRows = new List <string>(); try { StreamReader sReader = File.OpenText("config.ini"); string read = null; while ((read = sReader.ReadLine()) != null) { fileRows.Add(read); } } catch (Exception) { MessageBox.Show("Не найден файл config.ini"); this.Close(); } if (fileRows.Count == 0) { MessageBox.Show("Файл настроек пуст"); this.Close(); } Element[] elem = new Element[fileRows.Count]; int i = 0; foreach (string str in fileRows) { string[] stringParts = str.Split(delimiterChars); elem[i] = new Element(stringParts[0], stringParts[1]); elem[i].Location = new Point(0, elem[i].Height * i); panel1.Controls.Add(elem[i]); i++; } Watcher watcher = new Watcher(fileRows); watcher.parent = this; Thread watchDuty = new Thread(new ThreadStart(watcher.watch)); watchDuty.Start(); }
public IActionResult DeleteStatusSet(long ssId) { using (var context = new TodoContext()) { StatusSet oldStatusSet = context.StatusSets.Find(ssId); if (oldStatusSet == null) { return(NotFound()); } var oldEnt = context.Attach(oldStatusSet); oldEnt.Collection("Statuses").Load(); foreach (var status in oldStatusSet.Statuses) { context.Statuses.Remove(status); } context.StatusSets.Remove(oldStatusSet); context.SaveChanges(); return(NoContent()); } }
public static void UpdateStatusList(Dictionary <int, StatusSet> set) { // update current status List <int> toRemove = new List <int>(); foreach (StatusSet s in set.Values) { // dont show icon if expired if (s.singleStatus.expired) { if (DebugSwitch.UIManager) { Debug.Log($"UIM UpdateStatusList: {s.singleStatus.name} has expired."); } toRemove.Add(s.singleStatus.GetHashCode()); } else { // update countdown text GameObject icon = s.icon; TextMeshProUGUI cdText = icon.transform.Find("countdown").GetComponent <TextMeshProUGUI>(); cdText.text = Mathf.CeilToInt(s.singleStatus.countdown).ToString(); } } // remove expired status foreach (int j in toRemove) { StatusSet s = set[j]; set.Remove(s.singleStatus.GetHashCode()); UIManager.DestroyIconGO(s.icon); } int i = 0; foreach (StatusSet s in set.Values) { // reset position RectTransform rt = s.icon.GetComponent <RectTransform>(); rt.anchoredPosition = GetIconOffset(i); i++; } }
protected virtual void OnStatusSet(StatusEventsArgs e) { StatusSet?.Invoke(this, e); }
/// <summary> /// Get a detailed representation of the status set. /// </summary> /// <param name="ss">The StatusSet to format</param> /// <returns>An anonymous object representing the StatusSet</returns> public object GetDetailedModel(StatusSet ss) { return(GetShortModel(ss)); }
public StatusViewModel() : base(Locator.Current.GetService <IViewStackService>()) { Global = Locator.Current.GetService <Global>(); Backend = BackendStatus.NotConnected; UseTor = false; Tor = TorStatus.NotRunning; Peers = 0; BtcPrice = "$0"; ActiveStatuses = new StatusSet(); UseTor = Global.Config.UseTor; // Do not make it dynamic, because if you change this config settings only next time will it activate. _status = ActiveStatuses.WhenAnyValue(x => x.CurrentStatus) .Select(x => x.ToString()) .ObserveOn(RxApp.MainThreadScheduler) .ToProperty(this, x => x.Status) .DisposeWith(Disposables); bool progressReset = true; _progressPercent = this.WhenAnyValue(x => x.ActiveStatuses.CurrentStatus, x => x.Peers) .Select(tup => { var(status, peers) = tup; if (peers == 0 && progressReset) { progressReset = false; return(0.01); } switch (status.Type) { case StatusType.Ready: progressReset = true; return(1); case StatusType.Synchronizing: return(status.Percentage / 200.0 + 0.3); case StatusType.Connecting: default: return(0.3); } }) .ToProperty(this, x => x.ProgressPercent); if (Global.IsInitialized) { OnInitialized(this, EventArgs.Empty); } else { Global.Initialized += OnInitialized; } Peers = Tor == TorStatus.NotRunning ? 0 : Nodes.Count; Observable.FromEventPattern <bool>(typeof(P2pBlockProvider), nameof(P2pBlockProvider.DownloadingBlockChanged)) .ObserveOn(RxApp.MainThreadScheduler) .Subscribe(x => DownloadingBlock = x.EventArgs) .DisposeWith(Disposables); IDisposable walletCheckingInterval = null; Observable.FromEventPattern <bool>(typeof(Wallet), nameof(Wallet.InitializingChanged)) .ObserveOn(RxApp.MainThreadScheduler) .Subscribe(x => { if (x.EventArgs) { TryAddStatus(StatusType.WalletLoading); if (walletCheckingInterval is null) { walletCheckingInterval = Observable.Interval(TimeSpan.FromSeconds(1)) .ObserveOn(RxApp.MainThreadScheduler) .Subscribe(_ => { var wallet = Global.Wallet; if (wallet is { }) { var startingHeight = SmartHeader.GetStartingHeader(wallet.Network).Height; if (wallet.LastProcessedFilter?.Header?.Height is uint lastProcessedFilterHeight && lastProcessedFilterHeight > startingHeight && Global.BitcoinStore?.SmartHeaderChain?.TipHeight is uint tipHeight && tipHeight > startingHeight) { var allFilters = tipHeight - startingHeight; var processedFilters = lastProcessedFilterHeight - startingHeight; var perc = allFilters == 0 ? 100 : ((decimal)processedFilters / allFilters * 100); TryAddStatus(StatusType.WalletProcessingFilters, (ushort)perc); } var txProcessor = wallet.TransactionProcessor; if (txProcessor is { }) { var perc = txProcessor.QueuedTxCount == 0 ? 100 : ((decimal)txProcessor.QueuedProcessedTxCount / txProcessor.QueuedTxCount * 100); TryAddStatus(StatusType.WalletProcessingTransactions, (ushort)perc); } }