public void DeleteMenu() { deletes = new Deletes(); Console.WriteLine("# DeleteMenu #"); Console.WriteLine("Select number to function:\n 1.delete student " + "2.delete class : " + "\n" + " OR Other Number to MainMenu"); int num = int.Parse(Console.ReadLine()); switch (num) { case 1: Console.WriteLine("Please enter the deleted student's id:"); int sid = int.Parse(Console.ReadLine()); deletes.DeleteStudent(sid); break; case 2: Console.WriteLine("Please enter the deleted class's id:"); int cid = int.Parse(Console.ReadLine()); deletes.DeleteClass(cid); break; default: break; } }
public override string ToString() { var builder = new StringBuilder(); builder.Append($"{nameof(Description)}: {Description}\n"); if (!string.IsNullOrEmpty(Link)) { builder.Append($"{nameof(Link)}: {Link}\n"); } foreach (var include in Includes.Select((value, i) => new { i, value })) { builder.Append($"{nameof(Includes)}[{include.i}]: {include.value}\n"); } foreach (var delete in Deletes.Select((value, i) => new { i, value })) { builder.Append($"{nameof(Deletes)}[{delete.i}]: {delete.value}\n"); } foreach (var arg in Arguments.Select((value, i) => new { i, value })) { builder.Append($"{nameof(Arguments)}[{arg.i}]: {arg.value}\n"); } return(builder.ToString()); }
public bool HasIllegalItems(string vaultRoot) { if ((Mirrors.Count() == 0) && (Deletes.Count() == 0)) { return(false); } if (IsStringIllegal(vaultRoot)) { return(true); } foreach (string mirror in Mirrors) { string local = GetLocalFolder(mirror, vaultRoot); if (IsStringIllegal(local)) { return(true); } } foreach (string delete in Deletes) { string local = delete;//GetLocalFolder(delete, vaultRoot); if (IsStringIllegal(local)) { return(true); } } return(false); }
public ActionResult DeleteCompany(int id, string table_name) { Deletes del = new Deletes(); del.DelStr(id, table_name); return(RedirectToAction("Index", "Home")); }
//public void UpdateBlockName(int index, string name) //{ // Blocks[index].Name = name; // if (Blocks[index].ImplementationInfo.IsSettled) // { // Blocks[index].ImplementationInfo.Unsettle(); // } //} public override void Commit(EarthworkBlockingForm storage) { BlockIdIndexMapper = new Dictionary <int, int>(); int index = 0; foreach (var block in Blocks) { BlockIdIndexMapper.Add(block.Id, index); index++; if (block.IsChanged) { block.Commit(storage); } } FaceRecorderForRevit recorder = PMSoftHelper.GetRecorder(nameof(EarthworkBlockingForm), storage.m_Doc); var jsonObj = JsonConvert.SerializeObject(this); recorder.WriteValue(SaveKeyHelper.GetSaveKey(SaveKeyHelper.SaveKeyTypeForEarthWork.EarthworkBlocking_Size, 1), jsonObj.Length.ToString()); recorder.WriteValue(SaveKeyHelper.GetSaveKey(SaveKeyHelper.SaveKeyTypeForEarthWork.EarthworkBlocking, 1), jsonObj); foreach (var block in Deletes) { //TODO ???Block的删除或需优化 Block总是新增节点,会造成数据量一致增加 recorder.WriteValue(SaveKeyHelper.GetSaveKey(SaveKeyHelper.SaveKeyTypeForEarthWork.EarthworkBlock_Size, block.Id), ""); recorder.WriteValue(SaveKeyHelper.GetSaveKey(SaveKeyHelper.SaveKeyTypeForEarthWork.EarthworkBlock, block.Id), ""); recorder.WriteValue(SaveKeyHelper.GetSaveKey(SaveKeyHelper.SaveKeyTypeForEarthWork.EarthworkBlockCPSettings_Size, block.Id), ""); recorder.WriteValue(SaveKeyHelper.GetSaveKey(SaveKeyHelper.SaveKeyTypeForEarthWork.EarthworkBlockCPSettings, block.Id), ""); } Adds.Clear(); Deletes.Clear(); }
public ActionResult DeleteWorker(int id, string table_name) { Deletes del = new Deletes(); del.DelStr(id, table_name); return(RedirectToAction("AllWorkers", "Home")); }
internal void ApplyInternal(CryptoDeleted deleted) { foreach (var t in BuyOrSell) { Deletes.Add(t.Id); } StateUpdateLoop(); }
public override void Rollback() { Blocks = new List <EarthworkBlock>(); Blocks.AddRange(Memo.Blocks); BlockIdIndexMapper = Memo.BlockIdIndexMapper; foreach (var Block in Blocks) { Block.Rollback(); } Adds.Clear(); Deletes.Clear(); }
public override void Delete(EarthworkBlock block) { //移除节点的所有元素(目的:解除图形配置),然后移除节点 block.Delete(this, block.ElementIds); Blocks.Remove(block); Deletes.Add(block); ////TODO 清空相关的信息 //FaceRecorderForRevit recorder = EarthworkBlockingConstraints.GetRecorder(nameof(EarthworkBlockingForm), Doc); //recorder.WriteValue(SaveKeyHelper.GetSaveKeyOfEarthworkBlockSize(block.Id), ""); //recorder.WriteValue(SaveKeyHelper.GetSaveKeyOfEarthworkBlock(block.Id), ""); //recorder.WriteValue(SaveKeyHelper.GetSaveKeyOfEarthworkBlockCPSettingsSize(block.Id), ""); //recorder.WriteValue(SaveKeyHelper.GetSaveKeyOfEarthworkBlockCPSettings(block.Id), ""); }
public override void SaveChanges() { base.SaveChanges(); var deleteFilter = DefaultWriteFilter & Builders <T> .Filter.Where(x => Deletes.ToArray().Contains(x.Id)); Collection.DeleteMany(deleteFilter); Deletes.Clear(); Updates.ForEach(ReplaceEntity); Updates.Clear(); }
public override int GetSimpleHashCode() { StringBuilder sb = new StringBuilder(); sb.Append(Id); sb.Append(Name); sb.Append("Adds:" + string.Join(",", Adds.Select(c => c.IntegerValue))); sb.Append("Deletes:" + string.Join(",", Deletes.Select(c => c.IntegerValue))); sb.Append(ImplementationInfo.StartTime); sb.Append(ImplementationInfo.ExposureTime); sb.Append(ImplementationInfo.EndTime); sb.Append(ImplementationInfo.IsConflicted); return(sb.ToString().GetHashCode()); }
public override void Delete(EarthworkBlocking blocking, ElementId elementId) { if (!ElementIds.Exists(p => p.IntegerValue == elementId.IntegerValue)) { return; } ElementIds.Remove(elementId); ElementIdValues.Remove(elementId.IntegerValue); Deletes.Add(elementId); CPSettings.DeapplySetting(blocking, new List <ElementId>() { elementId }); }
internal void Add(int deleteHash, string suggestion) { Entry entry; if (!Deletes.TryGetValue(deleteHash, out entry)) { entry = new Entry { count = 0, first = -1 }; } int next = entry.first; entry.count++; entry.first = Nodes.Count; Deletes[deleteHash] = entry; Nodes.Add(new Node { suggestion = suggestion, next = next }); }
private void StateUpdateLoop() { decimal avgCost = 0; decimal owned = 0; decimal cost = 0; var txs = new List <Transaction>(); DateTimeOffset?oldestOpen = null; var positionInstances = new List <PositionInstance>(); DateTimeOffset lastTransaction = DateTimeOffset.UtcNow; bool PurchaseProcessing(IStockTransaction st) { lastTransaction = st.When; if (owned == 0) { oldestOpen = st.When; positionInstances.Add(new PositionInstance(Ticker)); } avgCost = (avgCost * owned + st.Price * st.NumberOfShares) / (owned + st.NumberOfShares); owned += st.NumberOfShares; cost += st.Price * st.NumberOfShares; txs.Add( Transaction.DebitTx( Id, st.Id, Ticker, $"Purchased {st.NumberOfShares} shares @ ${st.Price}/share", st.Price * st.NumberOfShares, st.When, isOption: false ) ); positionInstances[positionInstances.Count - 1].Buy(st.NumberOfShares, st.Price, st.When); return(true); } bool SellProcessing(IStockTransaction st) { // TODO: this should never happen but in prod I see sell get // triggered before purchase... something is amiss if (positionInstances.Count > 0) { positionInstances[positionInstances.Count - 1].Sell(st.NumberOfShares, st.Price, st.When); } lastTransaction = st.When; txs.Add( Transaction.CreditTx( Id, st.Id, Ticker, $"Sold {st.NumberOfShares} shares @ ${st.Price}/share", st.Price * st.NumberOfShares, st.When, isOption: false ) ); txs.Add( Transaction.PLTx( Id, Ticker, $"Sold {st.NumberOfShares} shares @ ${st.Price}/share", avgCost * st.NumberOfShares, st.Price * st.NumberOfShares, st.When, isOption: false ) ); owned -= st.NumberOfShares; cost -= avgCost * st.NumberOfShares; return(true); } foreach (var st in BuyOrSell.OrderBy(e => e.When).ThenBy(i => BuyOrSell.IndexOf(i))) { if (Deletes.Contains(st.Id)) { continue; } if (st is StockPurchased sp) { PurchaseProcessing(sp); } else if (st is StockSold ss) { SellProcessing(ss); } if (owned == 0) { avgCost = 0; cost = 0; oldestOpen = null; } } AverageCost = avgCost; Owned = owned; Cost = cost; Transactions.Clear(); Transactions.AddRange(txs); PositionInstances.Clear(); PositionInstances.AddRange(positionInstances); DaysHeld = oldestOpen.HasValue ? (int)Math.Floor(DateTimeOffset.UtcNow.Subtract(oldestOpen.Value).TotalDays) : 0; DaysSinceLastTransaction = (int)DateTimeOffset.UtcNow.Subtract(lastTransaction).TotalDays; }
//public void LoadFromXml(XmlElement xml) //{ // Inserts.Clear(); // Updates.Clear(); // Deletes.Clear(); // foreach(XmlElement xitem in xml.SelectNodes("Insert")) // { // var item = new ChangeSetInsertItem(); // item.LoadFromXml(xitem); // Inserts.Add(item); // } //} public bool HasChanges() { return(Updates.Any() || Inserts.Any() || Deletes.Any()); }
internal void ApplyInternal(CryptoTransactionDeleted deleted) { Deletes.Add(deleted.TransactionId); StateUpdateLoop(); }
public RepositoryViewModel(IDispatcher dispatcher, IFactory <Profile> profileFactory) { UndoCommand = new ReactiveCommand(); AddCommand = new ReactiveCommand <bool>(); NameChangedCommand = new ReactiveCommand <string>(); SelectedContentChangedCommand = new ReactiveCommand <object>(); this.dispatcher = dispatcher; //Items = new ReactiveCollection<SelectDeleteItem>(Enumerable.Range(0, 10).Select(a => new SelectDeleteItem()).ToObservable()); ; //var undos = Items.ToCollectionChanged().Select(a => a.Value.Undo.Where(a => a).Select(b => new KeyValuePair<string, SelectDeleteItem>("Undo", a.Value))).SelectMany(a => a); var deletes = Items.ToCollectionChanged().Select(a => a.Value.Delete.Where(c => c).Select(b => new KeyValuePair <string, SelectDeleteItem>("Delete", a.Value))).SelectMany(a => a); var selects = Items.ToCollectionChanged().Select(a => a.Value.Select /*.Where(a => a)*/.Select(b => new KeyValuePair <bool, SelectDeleteItem>(b, a.Value))).SelectMany(a => a); var selects2 = Items.ToCollectionChanged().Where(a => Items.Count == 1).Select(a => Items.Single()).Select(b => new KeyValuePair <bool, SelectDeleteItem>(true, b)); var selects3 = Items.ToCollectionChanged().Where(a => Items.Count == 0 && a.Action == System.Collections.Specialized.NotifyCollectionChangedAction.Add) .Select(a => a.Value).Select(b => new KeyValuePair <bool, SelectDeleteItem>(true, b)); //selects2.DelaySubscription(TimeSpan.FromSeconds(1)).Subscribe(a => //{ //}); //selects3.Subscribe(a => //{ //}); this.Deletes = deletes.Select(a => a.Value).ToReactiveCollection(); deletes.Select(a => a.Value).Subscribe(a => Items.Remove(a)); (UndoCommand as ReactiveCommand).Subscribe(a => { if (Deletes.Any()) { var last = Deletes.Last(); Deletes.Remove(last); last.Delete.Value = false; last.Select.Value = Items.Count() == 0; Items.Add(last); } }); //(AddCommand as ReactiveCommand<bool>).Subscribe(a => //{ // bool parameter = (bool)a; // if (!Equals(parameter, true)) return; // //if (!string.IsNullOrWhiteSpace(FruitTextBox.Text)) // // FruitListBox.Items.Add(FruitTextBox.Text.Trim()); //}); (AddCommand as ReactiveCommand <bool>) .Where(b => b) .WithLatestFrom((NameChangedCommand as ReactiveCommand <string>), (bl, text) => text) .Subscribe(text => { Items.Add(new SelectDeleteItem(profileFactory.Build(text))); }); SelectedItem = selects.Merge(selects2).Where(a => a.Key).Select(a => a.Value).ToReactiveProperty(); //mode: ReactivePropertyMode.DistinctUntilChanged selects.Subscribe(a => { if (a.Key) { foreach (var x in Items.Where(b => b != a.Value)) { x.Select.Value = false; } } else if (a.Key == false && SelectedItem.Value == a.Value && Items.Count != 1) { this.SelectedItem.Value = null; } }); SelectedItem.Subscribe(a => { //this.dispatcher.InvokeAsync(() => this.SelectedItem.Value = a); }); // For some reason doesn't pick up initial selecteditem SelectedItem.Where(a => a != null).Take(1).Subscribe(a => { this.dispatcher.InvokeAsync(() => this.SelectedItem.Value = a); }); (SelectedContentChangedCommand as ReactiveCommand <object>).Subscribe(a => { (SelectedItem.Value.Value as Profile).Steps = (a as Dictionary <object, int>).Select(ba => ba.Key).Cast <Step>().ToArray(); }); }
private void StateUpdateLoop() { decimal quantity = 0; decimal cost = 0; var txs = new List <CryptoTransaction>(); DateTimeOffset?oldestOpen = null; var positionInstances = new List <PositionInstance>(); DateTimeOffset lastTransaction = DateTimeOffset.UtcNow; bool PurchaseProcessing(ICryptoTransaction st) { lastTransaction = st.When; if (quantity == 0) { oldestOpen = st.When; positionInstances.Add(new PositionInstance(Token)); } quantity += st.Quantity; cost += st.DollarAmount; txs.Add( CryptoTransaction.DebitTx( Id, st.Id, Token, $"Purchased {st.Quantity} for ${st.DollarAmount}", st.DollarAmount, st.When ) ); positionInstances[positionInstances.Count - 1].Buy(st.Quantity, st.DollarAmount, st.When); return(true); } bool SellProcessing(ICryptoTransaction st) { // TODO: this should never happen but in prod I see sell get // triggered before purchase... something is amiss if (positionInstances.Count > 0) { positionInstances[positionInstances.Count - 1].Sell(st.Quantity, st.DollarAmount, st.When); } lastTransaction = st.When; txs.Add( CryptoTransaction.CreditTx( Id, st.Id, Token, $"Sold {st.Quantity} for ${st.DollarAmount}", st.DollarAmount, st.When ) ); quantity -= st.Quantity; cost -= st.DollarAmount; return(true); } foreach (var st in BuyOrSell.OrderBy(e => e.When).ThenBy(i => BuyOrSell.IndexOf(i))) { if (Deletes.Contains(st.Id)) { continue; } if (st is CryptoPurchased sp) { PurchaseProcessing(sp); } else if (st is CryptoSold ss) { SellProcessing(ss); } if (quantity == 0) { cost = 0; oldestOpen = null; } } foreach (var a in Awards) { if (Deletes.Contains(a.Id)) { continue; } if (quantity == 0) { oldestOpen = a.When; } quantity += a.Quantity; } foreach (var y in Yields) { if (Deletes.Contains(y.Id)) { continue; } quantity += y.Quantity; } Quantity = quantity; Cost = cost; Transactions.Clear(); Transactions.AddRange(txs); PositionInstances.Clear(); PositionInstances.AddRange(positionInstances); DaysHeld = oldestOpen.HasValue ? (int)Math.Floor(DateTimeOffset.UtcNow.Subtract(oldestOpen.Value).TotalDays) : 0; DaysSinceLastTransaction = (int)DateTimeOffset.UtcNow.Subtract(lastTransaction).TotalDays; }
internal void Sort(IComparer <DocumentSnapshot> comparer) { Deletes.Sort(comparer); Adds.Sort(comparer); Updates.Sort(comparer); }
public override void Rollback() { Name = Memo.Name; Adds.Clear(); Deletes.Clear(); }
/// <summary>Clears all the data from the SuggestionStaging.</summary> public void Clear() { Deletes.Clear(); Nodes.Clear(); }
public override void Delete(T entity) { Deletes.Add(entity.Id); }