private bool SequentialApply(IOperationCollection operations, IDataContainer data) { switch (operations.CommonAction) { case OperationCode.REPLACE: case OperationCode.INSERT_OR_IGNORE: { foreach (var operation in operations) { ValueOperation opr = (ValueOperation)operation; data.UnsafeAdd(opr.FromKey, opr.Record); } return(true); } case OperationCode.DELETE: { return(false); } case OperationCode.DELETE_RANGE: case OperationCode.CLEAR: { throw new Exception("Logical error."); } default: throw new NotSupportedException(); } }
public FacetField(string alias, string label, bool multiValue, FacetSortSpec valueOrderBy = FacetSortSpec.OrderHitsDesc, bool expandSelection = true, int minHitCount = 0, ValueOperation valueOperation = ValueOperation.ValueOperationOr) { Alias = alias; Label = label; Multivalue = multiValue; ValueOrderBy = valueOrderBy; ExpandSelection = expandSelection; MinHitCount = minHitCount; SelectionOperation = valueOperation; }
public static float UpdateValue(float value, ValueOperation operation, float argument) { switch (operation) { case ValueOperation.Set: return(argument); case ValueOperation.Add: return(value + argument); case ValueOperation.Mult: return(value * argument); default: return(value); } }
public SpecialEvent(ValueOperation operation, float argument) { Operation = operation; Argument = argument; }
public ClientPortfellVM() { decimal totalMarkedValueUSD = 0; //Сумма текущих стоимостей всех инструментов decimal totalUSDprifit = 0; //Сумма всех прибылей от каждого инструмента //..............<Заполнение таблицы Investment>.................... #region InvestCollection = new ObservableCollection <ToolsInvestmentDetails>(); TotalInvestCollection = new ObservableCollection <TotalInvest>(); // Actives DataTable tableInf = userDAL.GetInvestmentDetails.CurrActives(order); for (int i = 0; i < tableInf.Rows.Count; i++) // Сумма всех активов в USD , нужна для подсчета % { string _value = tableInf.Rows[i][4].ToString(); decimal _marketVUSD = Convert.ToDecimal(tableInf.Rows[i][3]); if (_value != "USD") { _marketVUSD = ValueOperation.ValueToUSD(_value, _marketVUSD); } ActiveSumm += _marketVUSD; } for (int i = 0; i < tableInf.Rows.Count; i++) { string Type = tableInf.Rows[i][6].ToString(); Type = (Type == "") ? "Alternative Invest" : Type; string _value = tableInf.Rows[i][4].ToString(); decimal _marketVUSD = Convert.ToDecimal(tableInf.Rows[i][3]); if (_value != "USD") { _marketVUSD = ValueOperation.ValueToUSD(_value, _marketVUSD); } decimal _nowQuote = QuteParse.QuoteByIsin(tableInf.Rows[i][0].ToString()); decimal _aqpr = Convert.ToDecimal(tableInf.Rows[i][1]); decimal _units = Convert.ToDecimal(tableInf.Rows[i][2]); decimal _profit = ((_units * _nowQuote) - (_units * _aqpr)); _profit = (_marketVUSD == _aqpr) ?0:_profit; InvestCollection.Add(new ToolsInvestmentDetails() { Type = Type, Isin = tableInf.Rows[i][0].ToString(), Value = _value, currentDate = (DateTime.Now.Date).ToString(), Date = tableInf.Rows[i][5].ToString(), Markedvalue = tableInf.Rows[i][3].ToString(), MarkedvalueUSD = _marketVUSD.ToString("N2"), Units = _units.ToString(), AqPr = _aqpr.ToString(), Quote = _nowQuote.ToString(), profit = _profit.ToString("N2"), Percent = ((_units * _nowQuote) / ActiveSumm * 100).ToString("N2") }); } // "Saxxxo", "IB" #region try { DataTable saxIbtable = userDAL.GetInvestmentDetails.GetInvestmentSaxoIb(Order); int roxsTable = saxIbtable.Rows.Count; InvestCollection.Add(new ToolsInvestmentDetails() { Type = "Transfer" }); if (roxsTable > 0) { for (int i = 0; i < roxsTable; i++) { InvestCollection.Add(new ToolsInvestmentDetails() { Type = saxIbtable.Rows[i][0].ToString().ToUpper(), Date = saxIbtable.Rows[i][3].ToString(), MarkedvalueUSD = saxIbtable.Rows[i][2].ToString(), Value = saxIbtable.Rows[i][1].ToString() }); } } InvestCollection.Add(new ToolsInvestmentDetails() { Type = "TOTAL RESULTS", MarkedvalueUSD = totalMarkedValueUSD.ToString("N2"), Percent = (totalMarkedValueUSD / ((Convert.ToDecimal(Cash) + totalMarkedValueUSD) / 100)).ToString("N2") + " %", profit = totalUSDprifit.ToString("N2") }); } catch (Exception ex) { // BOX.ShowError(ex.Message, ex.Source); } #endregion #endregion //.............<Заполнение таблицы Inflow>..................... #region InflowDetailsCollection = new ObservableCollection <InflowTools>(); DataTable tableIn = userDAL.GetInvestmentDetails.GetInflowDetails(order); for (int i = 0; i < tableIn.Rows.Count; i++) { InflowDetailsCollection.Add(new InflowTools() { CashAccount = tableIn.Rows[i][0].ToString(), aqprice = tableIn.Rows[i][5].ToString(), CashAccSumm = Convert.ToDecimal(tableIn.Rows[i][4]), countPaper = Convert.ToDecimal(tableIn.Rows[i][6]), date = Convert.ToDateTime(tableIn.Rows[i][7]), Isin = tableIn.Rows[i][2].ToString(), security = tableIn.Rows[i][3].ToString(), }); } #endregion //......................<Заоплнение Outflow>..................... #region WithdrawDetailsCollection = new ObservableCollection <Withdraw>(); DataTable table = userDAL.GetInvestmentDetails.OutFlow(order); for (int i = 0; i < table.Rows.Count; i++) { WithdrawDetailsCollection.Add(new Withdraw() { Summ = table.Rows[i][0].ToString(), Date = table.Rows[i][1].ToString() }); } #endregion //..............<Заполнение таблицы CELL Summary>.................... #region Collection = new ObservableCollection <ToolsInvestmentDetailsTotal>(); Collection.Add(new ToolsInvestmentDetailsTotal() { Type = "Cash Account", Balance = Cash.ToString("N2") }); Collection.Add(new ToolsInvestmentDetailsTotal() { Type = "Market value of investments", Balance = Marcet }); Collection.Add(new ToolsInvestmentDetailsTotal() { Type = "Fund Value", Balance = Found }); Collection.Add(new ToolsInvestmentDetailsTotal() { Type = "Min Cash Allocation", Balance = MINCash }); Collection.Add(new ToolsInvestmentDetailsTotal() { Type = "Encasment", Balance = Encasment }); Model.ClientReportVM report = new Model.ClientReportVM(); var tools = report.Tools; var toolstitle = report.ToolsTitle; var total = report.totallSumm; RiscDict dic = new RiscDict(); decimal totalmidCELLTV = 0; for (int i = 0; i < toolstitle.Length; i++) { if (toolstitle[i] != "leveraged_ETF") { decimal toolPrice = Convert.ToDecimal(tools.Rows[0][i]); int midd = dic.MiddCELLTV(toolstitle[i]); if (midd != 0) { var activeMidd = (toolPrice / midd) * 100; totalmidCELLTV += activeMidd; } } } decimal CELLTV = totalmidCELLTV / total; LTV = CELLTV; //Collection.Add(new ToolsInvestmentDetailsTotal() { Type= "CELLTV", Balance = (CELLTV).ToString("N2")+" %" }); #endregion }
public bool Leaf(IOperationCollection operations, IDataContainer data) { var records = (IOrderedSet <IData, IData>)data; //sequential optimization if (operations.IsAllMonotoneAndPoint && (records.Count == 0 || operations.Locator.KeyComparer.Compare(records.Last.Key, operations[0].FromKey) < 0)) { switch (operations.CommonAction) { case OperationCode.REPLACE: case OperationCode.INSERT_OR_IGNORE: { KeyValuePair <IData, IData>[] array = new KeyValuePair <IData, IData> [operations.Count]; int idx = 0; foreach (var operation in operations) { ValueOperation opr = (ValueOperation)operation; array[idx++] = new KeyValuePair <IData, IData>(opr.FromKey, opr.Record); } records.AddOrdered(array, 0, array.Length); return(true); } case OperationCode.READ: case OperationCode.READ_RANGE: case OperationCode.DELETE: case OperationCode.DELETE_RANGE: case OperationCode.CLEAR: case OperationCode.REFRESH: case OperationCode.REFRESH_POINT: case OperationCode.REFRESH_RANGE: { return(false); } } } //standart apply bool isModified = false; foreach (var opr in operations) { switch (opr.Code) { case OperationCode.REPLACE: { records[opr.FromKey] = ((ReplaceOperation)opr).Record; isModified = true; } break; case OperationCode.INSERT_OR_IGNORE: { if (records.ContainsKey(opr.FromKey)) { continue; } records[opr.FromKey] = ((InsertOrIgnoreOperation)opr).Record; isModified = true; } break; case OperationCode.DELETE: { if (records.Remove(opr.FromKey)) { isModified = true; } } break; case OperationCode.DELETE_RANGE: { if (records.Remove(opr.FromKey, true, opr.ToKey, true)) { isModified = true; } } break; case OperationCode.CLEAR: { records.Clear(); isModified = true; } break; case OperationCode.READ: { if (ReadCallback == null) { break; } IData record; if (records.TryGetValue(opr.FromKey, out record)) { ReadCallback(((ReadOperation)opr).Handle, true, Locator, opr.FromKey, record); } else { ReadCallback(((ReadOperation)opr).Handle, false, Locator, opr.FromKey, default(IData)); } } break; case OperationCode.READ_RANGE: { if (ReadCallback == null) { break; } foreach (var kv in records.Forward(opr.FromKey, true, opr.ToKey, true)) { ReadCallback(((ReadOperation)opr).Handle, true, Locator, opr.FromKey, kv.Value); } } break; case OperationCode.REFRESH: case OperationCode.REFRESH_POINT: case OperationCode.REFRESH_RANGE: break; default: throw new NotImplementedException(); } } return(isModified); }
public void Benchmark() { IScriptContext context = new ScriptContext(); //Example 0: Machine ExecutableMachine machine = ExecutableMachine.Create(); int iterations = 2;// 10000000; //loops = 10000000 ValueOperation op0 = machine.CreateOperation <ValueOperation>(); op0.Value = iterations; SetValueOperation op1 = machine.CreateOperation <SetValueOperation>(); op1.Id = "loops"; // counter = 0 ValueOperation op2 = machine.CreateOperation <ValueOperation>(); op2.Value = 0; SetValueOperation op3 = machine.CreateOperation <SetValueOperation>(); op3.Id = "counter"; //while (loops > 0) RegisterOperation op4 = machine.CreateOperation <RegisterOperation>(); op4.Destination = MachineRegisters.BX; op4.Value = 0; GetValueOperation op5 = machine.CreateOperation <GetValueOperation>(); op5.Id = "loops"; CmpOperation op6 = machine.CreateOperation <CmpOperation>(); JmpIfOperation op7 = machine.CreateOperation <JmpIfOperation>(); op7.Offset = 8; //loops = loops -1; GetValueOperation op8 = machine.CreateOperation <GetValueOperation>(); op8.Id = "loops"; DecOperation op9 = machine.CreateOperation <DecOperation>(); SetValueOperation op10 = machine.CreateOperation <SetValueOperation>(); op10.Id = "loops"; //counter = counter + 1; GetValueOperation op11 = machine.CreateOperation <GetValueOperation>(); op11.Id = "counter"; IncOperation op12 = machine.CreateOperation <IncOperation>(); SetValueOperation op13 = machine.CreateOperation <SetValueOperation>(); op13.Id = "counter"; JmpOperation op14 = machine.CreateOperation <JmpOperation>(); op14.Offset = -10; machine.CreateOperation <RetOperation>(); machine.Execute(context); object rez = context.GetItem("counter", true); Assert.Equal(iterations, rez); }