public void TestRemoveFFD() { var tempConnection = DataBaseLink.Fabricate.CreateConnection(_connection, ConnectionType.Npgsql); DataBaseLink.DbLink dbLink = new DbLink(tempConnection); //инструмент fin_instrument fin_instrument = new fin_instrument("roman", 13, "bushuev"); if (FinInstrument.FindId(dbLink, fin_instrument.ident) == null) { FinInstrument.Insert(dbLink, fin_instrument); } var result = FinInstrument.FindId(dbLink, fin_instrument.ident); //fisd_id ffd ffd = new ffd() { ds_id = 17, fi_id = result.fi_id, fif_id = 11, }; if (FFD.Find(dbLink, ffd.fi_id, ffd.ds_id, ffd.fif_id) == null) { FFD.Insert(dbLink, ffd); var ffdResult = FFD.Find(dbLink, result.fi_id, ffd.ds_id, ffd.fif_id); FFD.Remove(dbLink, ffdResult); } else { var ffdResult = FFD.Find(dbLink, result.fi_id, ffd.ds_id, ffd.fif_id); FFD.Remove(dbLink, ffdResult); } }
//insert public static void Insert(DbLink dbLink, ffd ffd) { string query = @"insert into ffd(fisd_id, fi_id, ds_id, fif_id) values(nextval('mir_sequence'), @fi_id, @ds_id, @fif_id);"; dbLink.GetConnection().Execute(query, ffd); }
public void TestRemoveFisdItem() { var tempConnection = DataBaseLink.Fabricate.CreateConnection(_connection, ConnectionType.Npgsql); DbLink dbLink = new DbLink(tempConnection); //создать финансовый инструмент fin_instrument fin_instrument = new fin_instrument("roman", 13, "bushuev"); if (FinInstrument.FindId(dbLink, fin_instrument.ident) == null) { FinInstrument.Insert(dbLink, fin_instrument); } var resultFI = FinInstrument.FindId(dbLink, fin_instrument.ident); //ffd ffd ffd = new ffd() { ds_id = 17, fi_id = resultFI.fi_id, fif_id = 8, }; if (FFD.Find(dbLink, resultFI.fi_id, ffd.ds_id, ffd.fif_id) == null) { FFD.Insert(dbLink, ffd); } var ffdResult = FFD.Find(dbLink, resultFI.fi_id, ffd.ds_id, ffd.fif_id); //dict_item dict_item dict_item = new dict_item() { fif_id = 8, key_v = "RUB", }; var resultDictItem = DictItem.FindId(dbLink, dict_item.key_v, dict_item.fif_id); //fisd_item fisd_item fisd_item = new fisd_item() { dat_from = new DateTime(2017, 08, 05), fisd_id = ffdResult.fisd_id, val = resultDictItem.key_v }; if (FisdItem.FindId(dbLink, fisd_item.fisd_id, fisd_item.dat_from) == null) { FisdItem.Insert(dbLink, fisd_item); var one = FisdItem.FindId(dbLink, fisd_item.fisd_id, fisd_item.dat_from); FisdItem.Remove(dbLink, one.fisd_id, one.dat_from); } else { var one = FisdItem.FindId(dbLink, fisd_item.fisd_id, fisd_item.dat_from); FisdItem.Remove(dbLink, one.fisd_id, one.dat_from); } }
//remove public static void Remove(DbLink dbLink, ffd ffd) { string query = string.Format("delete from ffd t where t.fi_id = {0} and t.ds_id = {1} and t.fif_id = {2}", ffd.fi_id, ffd.ds_id, ffd.fif_id); dbLink.GetConnection().Execute(query); }
public void TestInsertQuote() { //вставим несколько значений за разные даты var tempConnection = DataBaseLink.Fabricate.CreateConnection(_connection, ConnectionType.Npgsql); DataBaseLink.DbLink dbLink = new DbLink(tempConnection); //создать финансовый инструмент fin_instrument fin_instrument = new fin_instrument("roman", 13, "bushuev"); if (FinInstrument.FindId(dbLink, fin_instrument.ident) == null) { FinInstrument.Insert(dbLink, fin_instrument); } var result = FinInstrument.FindId(dbLink, fin_instrument.ident); ffd ffd = new ffd() { ds_id = 17, fi_id = result.fi_id, fif_id = 3 }; if (FFD.Find(dbLink, result.fi_id, ffd.ds_id, ffd.fif_id) == null) { FFD.Insert(dbLink, ffd); } var ffdResult = FFD.Find(dbLink, result.fi_id, ffd.ds_id, ffd.fif_id); fisd_dq fisd_dq = new fisd_dq() { dat = DateTime.Today.AddDays(-1), fisd_id = ffdResult.fisd_id, val = 10.0m }; if (FisdDq.FindId(dbLink, fisd_dq.fisd_id, fisd_dq.dat) == null) { FisdDq.Insert(dbLink, fisd_dq); } fisd_dq = new fisd_dq() { dat = DateTime.Today, fisd_id = ffdResult.fisd_id, val = 11.0m }; if (FisdDq.FindId(dbLink, fisd_dq.fisd_id, fisd_dq.dat) == null) { FisdDq.Insert(dbLink, fisd_dq); } }
public void TestRemoveFisdNum() { var tempConnection = DataBaseLink.Fabricate.CreateConnection(_connection, ConnectionType.Npgsql); DataBaseLink.DbLink dbLink = new DbLink(tempConnection); fin_instrument fin_instrument = new fin_instrument("roman", 13, "bushuev"); if (FinInstrument.FindId(dbLink, fin_instrument.ident) == null) { FinInstrument.Insert(dbLink, fin_instrument); } var result = FinInstrument.FindId(dbLink, fin_instrument.ident); //fisd_id ffd ffd = new ffd() { ds_id = 17, fi_id = result.fi_id, fif_id = 11, }; if (FFD.Find(dbLink, result.fi_id, ffd.ds_id, ffd.fif_id) == null) { FFD.Insert(dbLink, ffd); } var ffdResult = FFD.Find(dbLink, result.fi_id, ffd.ds_id, ffd.fif_id); fisd_num fisd_num = new fisd_num() { fisd_id = ffdResult.fisd_id, dat_from = new DateTime(2018, 03, 24), val = 320.0m }; if (FisdNum.FindId(dbLink, ffdResult.fisd_id, fisd_num.dat_from) == null) { FisdNum.Insert(dbLink, fisd_num); var one = FisdNum.FindId(dbLink, fisd_num.fisd_id, fisd_num.dat_from); FisdNum.Remove(dbLink, fisd_num.fisd_id, fisd_num.dat_from); } else { FisdNum.Insert(dbLink, fisd_num); var one = FisdNum.FindId(dbLink, fisd_num.fisd_id, fisd_num.dat_from); FisdNum.Remove(dbLink, fisd_num.fisd_id, one.dat_from); } }
public void TestRemoveFisdDate() { var tempConnection = DataBaseLink.Fabricate.CreateConnection(_connection, ConnectionType.Npgsql); DataBaseLink.DbLink dbLink = new DbLink(tempConnection); //создать финансовый инструмент fin_instrument fin_instrument = new fin_instrument("roman", 13, "bushuev"); if (FinInstrument.FindId(dbLink, fin_instrument.ident) == null) { FinInstrument.Insert(dbLink, fin_instrument); } var result = FinInstrument.FindId(dbLink, fin_instrument.ident); //fisd_id ffd ffd = new ffd() { ds_id = 17, fi_id = result.fi_id, fif_id = 11, }; if (FFD.Find(dbLink, result.fi_id, ffd.ds_id, ffd.fif_id) == null) { FFD.Insert(dbLink, ffd); } var ffdResult = FFD.Find(dbLink, result.fi_id, ffd.ds_id, ffd.fif_id); //создать fisd_date fisd_date fisdDate = new fisd_date() { fisd_id = ffdResult.fisd_id, dat_from = new DateTime(2018, 03, 25), val = new DateTime(2018, 03, 25) }; if (FisdDate.FindId(dbLink, fisdDate.fisd_id, fisdDate.dat_from) == null) { FisdDate.Insert(dbLink, fisdDate); var one = FisdDate.FindId(dbLink, fisdDate.fisd_id, fisdDate.dat_from); FisdDate.Remove(dbLink, fisdDate.fisd_id, one.dat_from); } else { var one = FisdDate.FindId(dbLink, fisdDate.fisd_id, fisdDate.dat_from); FisdDate.Remove(dbLink, fisdDate.fisd_id, one.dat_from); } }
void Start() { StiffnessCoeffecient = 0.0f; DampringCoeffecient = 0.0f; DisplacementStepSize = 0.001f; HeartAmplitudeRate = 0.0f; maxperupdate_count = 0; minperupdate_count = 0; set_heartrate = false; maxheartper = 0; minheartper = 0; firsttimecollision = true; dampingforce = true; other_parameters = BeatingScriptObject.GetComponent<beatingHeart>(); heartper = other_parameters.per; GetComponent<Rigidbody>().constraints = RigidbodyConstraints.FreezePosition | RigidbodyConstraints.FreezeRotation; freeFormDeformation = BeatingScriptObject.GetComponent<ffd>(); startx = transform.position.x; starty = transform.position.y; startz = transform.position.z; /* Debug.Log("Unity Starting coordinates"); position.Set((float)startx,(float)starty,(float)startz); Debug.Log(position); */ running = init(); if(running == 0) Debug.Log("Device Initialized"); hapticoriginx = getX(); hapticoriginy = getY(); hapticoriginz = getZ(); /* Debug.Log("Haptic Starting coordinates"); hapticorigin.Set((float)hapticoriginx,(float)hapticoriginy,(float)hapticoriginz); Debug.Log(hapticorigin); */ position.Set((float)hapticoriginx,(float)hapticoriginy,(float)hapticoriginz); GetComponent<Rigidbody>().MovePosition(position); getTransform(tr); initialquaternion = matrixToQuaternion(tr); initialangles = FromQ2 (initialquaternion); //rigidbody.MoveRotation( Quaternion.Euler((float)initialangles.y,(float)initialangles.x,(float)initialangles.z)); //rigidbody.MoveRotation(initialquaternion); initialanglex = transform.eulerAngles.x; initialangley = transform.eulerAngles.y; initialanglez = transform.eulerAngles.z; Debug.Log("Euler Angles: " +initialanglex +" " +initialangley +" " +initialanglez); scaleanglex = initialangles.x - initialanglex; if(scaleanglex<0) scaleanglex = scaleanglex + 360; scaleangley = initialangles.y - initialangley; if(scaleangley<0) scaleangley = scaleangley + 360; scaleanglez = initialangles.z - initialanglez; if(scaleanglez<0) scaleanglez = scaleanglez + 360; Debug.Log("Initial Angles From Quat: " +initialangles.x +" " +initialangles.y +" " +initialangles.z); }
private void Save(Dictionary <PortfolioPosition, TimeSeries> storage) { foreach (var x in storage) { var transaction = _dbLink.GetConnection().BeginTransaction(IsolationLevel.ReadCommitted); try { // найдем тип финансового инструмента var finIdent = x.Key.Ident; var finType = x.Key.FinType; string finTypeIdent = _mapping.GetAI(finType); #region финансовый инструмент fin_instrument finInstrument = new fin_instrument() { ident = finIdent, title = finIdent, ft_id = int.Parse(finTypeIdent) }; if (FinInstrument.FindId(_dbLink, finInstrument.ident) == null) { FinInstrument.Insert(_dbLink, finInstrument); } finInstrument = FinInstrument.FindId(_dbLink, finInstrument.ident); #endregion #region Data_source data_source dataSource = new data_source() { ident = _providerParams[SCALAR].ToString(), }; dataSource = DataSource.FindId(_dbLink, dataSource.ident); #endregion #region fisd_id ffd ffd = new ffd() { ds_id = dataSource.ds_id, fi_id = finInstrument.fi_id, fif_id = int.Parse(_mapping.GetAI(x.Value.Attribute)) }; if (FFD.Find(_dbLink, ffd.fi_id, ffd.ds_id, ffd.fif_id) == null) { FFD.Insert(_dbLink, ffd); } ffd = FFD.Find(_dbLink, ffd.fi_id, ffd.ds_id, ffd.fif_id); #endregion #region TimeSeries foreach (var z in x.Value.Series) { fisd_dq fisd_dq = new fisd_dq() { dat = z.Key, val = z.Value, fisd_id = ffd.fisd_id }; if (FisdDq.FindId(_dbLink, fisd_dq.fisd_id, fisd_dq.dat) == null) { FisdDq.Insert(_dbLink, fisd_dq); } else { FisdDq.Update(_dbLink, fisd_dq); } } #endregion transaction.Commit(); } catch (Exception ex) { transaction.Rollback(); } } }
private void Save(Dictionary <KeyValuePair <PortfolioPosition, Enum>, ScalarNum> storage) { foreach (var x in storage) { var transaction = _dbLink.GetConnection().BeginTransaction(IsolationLevel.ReadCommitted); try { // найдем тип финансового инструмента var finIdent = x.Key.Key.Ident; var finType = x.Key.Key.FinType; string finTypeIdent = _mapping.GetAI(finType); #region финансовый инструмент fin_instrument finInstrument = new fin_instrument() { ident = finIdent, title = finIdent, ft_id = int.Parse(finTypeIdent) }; if (FinInstrument.FindId(_dbLink, finInstrument.ident) == null) { FinInstrument.Insert(_dbLink, finInstrument); } finInstrument = FinInstrument.FindId(_dbLink, finInstrument.ident); #endregion #region Data_source data_source dataSource = new data_source() { ident = _providerParams[SCALAR].ToString(), }; dataSource = DataSource.FindId(_dbLink, dataSource.ident); #endregion #region fisd_id ffd ffd = new ffd() { ds_id = dataSource.ds_id, fi_id = finInstrument.fi_id, fif_id = int.Parse(_mapping.GetAI(x.Key.Value)) }; if (FFD.Find(_dbLink, ffd.fi_id, ffd.ds_id, ffd.fif_id) == null) { FFD.Insert(_dbLink, ffd); } ffd = FFD.Find(_dbLink, ffd.fi_id, ffd.ds_id, ffd.fif_id); #endregion fisd_num fisdNum = new fisd_num() { dat_from = x.Value.Dictionary.First().Key, fisd_id = ffd.fisd_id, val = x.Value.Dictionary.First().Value }; FisdNum.Insert(_dbLink, fisdNum); transaction.Commit(); } catch (Exception ex) { transaction.Rollback(); } } }