public void SaveChanges() { if (String.IsNullOrEmpty(txtPortfolio.Text)) { Telerik.WinControls.RadMessageBox.Show(Program.LanguageDefault.DictionaryPortfolio["fieldEmptyPortfolio"]); return; } SymbolGroup portChanged = new SymbolGroup() { Name = txtPortfolio.Text, Type = (int)GroupType.Portfolio, Index = ParentControl.GetPortfolioNewIndex(), Symbols = "" }; UpdatePortfolios = new List <string> { txtPortfolio.Text }; SqlConnection _connection = DBlocalSQL.Connect(); List <SymbolGroup> listpoPortfolios = DBlocalSQL.LoadGroups(GroupType.Index, _connection); listpoPortfolios.AddRange(DBlocalSQL.LoadGroups(GroupType.Portfolio, _connection)); DBlocalSQL.Disconnect(_connection); foreach (var listpoPortfolio in listpoPortfolios) { if (listpoPortfolio.Name.ToUpper() == portChanged.Name.ToUpper() || Program.LanguageDefault.DictionaryTabAssets["tabAll"] == portChanged.Name.ToUpper()) { Telerik.WinControls.RadMessageBox.Show(String.Format(Program.LanguageDefault.DictionaryPortfolio["portfolioExisted"], txtPortfolio.Text)); return; } UpdatePortfolios.Add(listpoPortfolio.Name); } listpoPortfolios.Add(portChanged); SqlConnection _connection2 = DBlocalSQL.Connect(); DBlocalSQL.SaveGroups(listpoPortfolios, _connection2); DBlocalSQL.Disconnect(_connection2); PortFolio = txtPortfolio.Text; DialogResult = DialogResult.OK; Close(); }
public void LoadStockDaily() { if (!mFrmMain2.measureTime.IsRunning) { mFrmMain2.measureTime.Start(); } long timeEllapsed = mFrmMain2.measureTime.ElapsedMilliseconds; Candles.Clear(); CandlesBasic.Clear(); CandlesHistory.Clear(); mFrmMain2.timeEllapsedDatabaseAccess = mFrmMain2.measureTime.ElapsedMilliseconds; try { SqlConnection _connection = DBlocalSQL.Connect(); CandlesDaily = DBlocalSQL.GetBarDataAll(Symbol, Interval, (int)Periodicity, _connection); DBlocalSQL.Disconnect(_connection); int size = Program.LoginAuthentication.Login.ToUpper().Equals("GUEST") ? Properties.Settings.Default.History > 300 ? 300 : Properties.Settings.Default.History : Properties.Settings.Default.History; if (CandlesDaily.Count > size) { CandlesDaily = CandlesDaily.GetRange(CandlesDaily.Count - size, size); } //Get all data from localDB /*string conString = "Data Source=(LocalDB)\\v11.0;AttachDbFilename=\"C:\\Users\\Admin\\Desktop\\PLENA\\M4\\trunk\\M4 C# DDF\\PlenaData.mdf\";Integrated Security=True"; * SqlConnection localdbCon = new SqlConnection(conString); * localdbCon.Open(); * SqlCommand cmd = new SqlCommand("SELECT DateTicks, Date, Symbol, OpenPrice, HighPrice, LowPrice, ClosePrice, VolumeF, VolumeS, VolumeT, AdjustS, AdjustD FROM BaseDay WHERE Symbol = N'" + Symbol + "'", localdbCon); * SqlDataReader rdr = cmd.ExecuteReader(); * CandlesDaily = new List<BarData>(); * while (rdr.Read()) * { * long dateTick = rdr.GetInt64(0); * DateTime date = rdr.GetDateTime(1); * string symbol = rdr.GetString(2); * double openPrice = rdr.GetDouble(3); * double highPrice = rdr.GetDouble(4); * double lowPrice = rdr.GetDouble(5); * double closePrice = rdr.GetDouble(6); * double volumeF = rdr.GetDouble(7); * long volumeS = rdr.GetInt64(8); * long volumeT = rdr.GetInt64(9); * double adjustS = rdr.GetDouble(10); * double adjustD = rdr.GetDouble(10); * * CandlesDaily.Add(new BarData() { * TradeDateTicks = dateTick, * TradeDate = date, * Symbol = symbol, * OpenPrice = openPrice, * HighPrice = highPrice, * LowPrice = lowPrice, * ClosePrice = closePrice, * VolumeF = volumeF, * VolumeS = volumeS, * VolumeT = volumeT, * AdjustS = adjustS, * AdjustD = adjustD * }); * * // Do somthing with this rows string, for example to put them in to a list * }*/ mFrmMain2.timeEllapsedDatabaseAccess = mFrmMain2.measureTime.ElapsedMilliseconds - mFrmMain2.timeEllapsedDatabaseAccess; Console.WriteLine("DBDAILYSHARED() -> " + mFrmMain2.timeEllapsedDatabaseAccess); } catch (Exception ex) { Console.WriteLine(ex.Message + CandlesDaily.Count); } }
private void RadButton3Click(object sender, EventArgs e) { bool allRemoved = false; if (ddlPortfolios.SelectedItem != null) { DialogResult dialogResult = Telerik.WinControls.RadMessageBox.Show(Program.LanguageDefault.DictionaryPortfolio["ConfirmDeletePortfolio"], "", MessageBoxButtons.OKCancel, Telerik.WinControls.RadMessageIcon.Question); if (dialogResult == DialogResult.OK) { //Update portfolio "All": bool remove = true; List <string> SymbolsNew = ParentControl.UserPortfolios.First(p => p.Name == ddlPortfolios.Text).Symbols.Split(new char[] { ',' }).ToList(); for (int i = 0; i < SymbolsNew.Count(); i++) { // This symbol exists in another portfolio? foreach (SymbolGroup port in ParentControl.UserPortfolios.GetRange(1, ParentControl.UserPortfolios.Count() - 1)) { if (port.Name == ddlPortfolios.Text) { continue; } if (port.Symbols.Split(new char[] { ',' }).ToList().Exists(s => s == SymbolsNew[i])) { remove = false; } } if (remove) { List <string> userSymbols = ParentControl.UserPortfolios[0].Symbols.Split(new char[] { ',' }).ToList(); if (userSymbols.Remove(SymbolsNew[i])) { ParentControl.UserPortfolios[0].Symbols = string.Join(",", userSymbols.ToArray()); } ParentControl.UserPortfolios[0].Symbols = string.Join(",", userSymbols.ToArray()); List <Symbol> updateSync = new List <Symbol>(); foreach (string s in userSymbols) { updateSync.Add(new Symbol() { Code = s }); } SqlConnection _con = DBlocalSQL.Connect(); DBlocalSQL.SaveSymbols(updateSync, _con, true); DBlocalSQL.Disconnect(_con); allRemoved = true; } } ParentControl.RemovePortfolio(ddlPortfolios.Text); if (allRemoved) { frmMain2.ReloadStockListPortfolios(); //Update PortfolioView1 ParentControl.LoadPortfolios(new List <string>() { "All" }); } LoadPortfolioSelection(); } } PreviewPortfolio = ""; foreach (RadListDataItem r in radListControl1.Items.Where(r => r.Text.ToUpper() == ddlFilter.SelectedItem.Text.ToUpper())) { radListControl1.SelectedItem = r; } foreach (RadListDataItem r in radListControl2.Items) { if (r.Text.ToUpper() == ddlFilter.SelectedItem.Text.ToUpper()) { radListControl2.SelectedItem = r; } } }
/// <summary> /// Do all the changes necessary to each file of the path \\BASE to the new Version. /// </summary> public static void CheckFileVersions(string version) { //Check SQL database: SqlConnection _con = DBlocalSQL.Connect(); string sqlVersion = DBlocalSQL.GetSqlVersion(_con); if (sqlVersion != version) { //do the changes to the SQL file // switch(version) // ... // ... // ... DBlocalSQL.SaveSqlVersion(_con, version); } DBlocalSQL.Disconnect(_con); if (!Directory.Exists(BasePath)) { throw new System.ArgumentException("Path doesn't exist."); } Version = version; string[] oldFiles = GetDifferentVersion(BasePath, Version); foreach (var file in oldFiles) { if (file.Contains("WORKSPACE")) { if (file.Contains("Workspace.xml")) { //do the changes to the workspace.xml file // switch(version) // ... // ... ChangeVersion(file, Version); } else if (file.Contains("WorkspaceLoad.xml")) { //do the changes to the workspaceLoad.xml file // switch(version) // ... // ... // ... ChangeVersion(file, Version); } else if (file.Contains("ATIVOS")) { //do the changes to the files which starts with ATIVOS // switch(version) // ... // ... // ... ChangeVersion(file, Version); } else { //do the changes to the remainder files in this path. // switch(version) // ... // ... // ... ChangeVersion(file, Version); } } else if (file.Contains("UPDATE")) { //do the changes to the files in this path. // ... // ... // ... ChangeVersion(file, Version); } else if (file.Contains("TEMPLATES")) { //do the changes to the files in this path. // ... // ... // ... ChangeVersion(file, Version); } else if (file.Contains("LOGIN")) { //do the changes to the files in this path. // ... // ... // ... ChangeVersion(file, Version); } else if (file.Contains("FEATURES")) { //do the changes to the files in this path. // ... // ... // ... ChangeVersion(file, Version); } else if (file.Contains("CONFIG")) { //do the changes to the files in this path. // ... // ... // ... ChangeVersion(file, Version); } } }
public void SaveChanges() { List <string> updatePortfolios = new List <string>(); SymbolGroup portChanged; if (ddlPortfolios.SelectedItem != null) { //Create a new portfolio portChanged = new SymbolGroup() { Name = ddlPortfolios.SelectedItem.Text == Program.LanguageDefault.DictionaryTabAssets["tabAll"] ? "All" : ddlPortfolios.SelectedItem.Text, Type = (int)DataServer.Interface.GroupType.Portfolio, Index = ParentControl.GetPortfolioNewIndex() }; List <string> Symbols = new List <string>(); foreach (var r in radListControl2.Items) { string[] codeParse = r.Text.Split(new[] { ' ' }); string newAsset = codeParse[0]; Symbols.Add(newAsset); } portChanged.Symbols = string.Join(",", Symbols.ToArray()); //Replace it on User's Portfolios List <string> SymbolsNew = new List <string>(); foreach (var p in ParentControl.UserPortfolios) { if (p.Name != portChanged.Name) { continue; } // if (UnorderedEqual(p.Symbols, portChanged.Symbols)) // continue; SymbolsNew = p.Symbols.Split(new char[] { ',' }).ToList(); //Remove os simbolos removidos if (!UnorderedEqual(SymbolsNew, Symbols.ToArray())) { for (int i = 0; i < SymbolsNew.Count; i++) { if (!Symbols.Any(s => s == SymbolsNew[i])) { //Update portfolio "All": bool remove = true; // This symbol exists in another portfolio? foreach (SymbolGroup port in ParentControl.UserPortfolios.GetRange(1, ParentControl.UserPortfolios.Count() - 1)) { if (port.Name == portChanged.Name) { continue; } if (port.Symbols.Split(new char[] { ',' }).ToList().Exists(s => s == SymbolsNew[i])) { remove = false; } } if (remove) { List <string> userSymbols = ParentControl.UserPortfolios[0].Symbols.Split(new char[] { ',' }).ToList(); if (userSymbols.Remove(SymbolsNew[i])) { ParentControl.UserPortfolios[0].Symbols = string.Join(",", userSymbols.ToArray()); } ParentControl.UserPortfolios[0].Symbols = string.Join(",", userSymbols.ToArray()); List <Symbol> updateSync = new List <Symbol>(); foreach (string s in userSymbols) { updateSync.Add(new Symbol() { Code = s }); } SqlConnection _con = DBlocalSQL.Connect(); DBlocalSQL.SaveSymbols(updateSync, _con, true); DBlocalSQL.Disconnect(_con); if (!updatePortfolios.Exists(s => s == "All")) { updatePortfolios.Insert(0, "All"); } } SymbolsNew.Remove(SymbolsNew[i]); i--; } } } List <string> symbolsRequest = new List <string>(); //insere os simbolos inseridos foreach (string symbol in Symbols) { if (!SymbolsNew.Any(s => s == symbol)) { SymbolsNew.Add(symbol); //Update portfolio "All": if (!ParentControl.UserPortfolios[0].Symbols.Split(new char[] { ',' }).ToList().Exists(s => s == symbol)) { ParentControl.UserPortfolios[0].Symbols += "," + symbol; //Add request to list: symbolsRequest.Add(symbol); List <Symbol> updateSync = new List <Symbol>(); foreach (string s in SymbolsNew) { updateSync.Add(new Symbol() { Code = s }); } SqlConnection _con = DBlocalSQL.Connect(); DBlocalSQL.SaveSymbols(updateSync, _con, true); DBlocalSQL.Disconnect(_con); if (!updatePortfolios.Exists(s => s == "All")) { updatePortfolios.Insert(0, "All"); } } } } if (symbolsRequest.Count() > 0) { //Sync new symbol with HUB: MessageService.SubmitRequest(new MSRequest("INSERT SYMBOL m" + ParentControl.MFrmMain2._messageRequestID, MSRequestStatus.Pending, MSRequestType.GetHistoricalData, MSRequestOwner.M4, new object[] { symbolsRequest, (int)BaseType.Days })); ParentControl.MFrmMain2.AddRequestedOperation(new Operations("m" + ParentControl.MFrmMain2._messageRequestID, M4Core.Enums.TypeOperations.LoadSelectView, new object[] { })); } updatePortfolios.Add(p.Name); p.Symbols = string.Join(",", SymbolsNew.ToArray()); break; } if (updatePortfolios.Count > 0) { frmMain2.SaveUserPortfolios(ParentControl.UserPortfolios.GetRange(1, ParentControl.UserPortfolios.Count() - 1)); frmMain2.ReloadStockListPortfolios(); //Update PortfolioView1 ParentControl.LoadPortfolios(updatePortfolios); } } Changes = false; }