public bool LoadDataForUser(short user, string fileLoc, bool matchwithevryRec) { switch (user) { case 1: if ((user1DataObsrvColl = GetDataFromXml(fileLoc, user, matchwithevryRec)).Count > 0) { return(true); } else { return(false); } case 2: if ((user2DataObsrvColl = GetDataFromXml(fileLoc, user, matchwithevryRec)).Count > 0) { return(true); } else { return(false); } case 3: if ((consoleObsrvColl = ProcessDataFromConsoleDataSource(ReadFromTextFile(fileLoc), matchwithevryRec)).Count > 0) { return(true); } else { return(false); } case 4: if ((user1DataObsrvColl = UserDataReaderDataBase.GetDataFromDatabase(UserDataReaderDataBase.GetDataTable(""))).Count > 0) { return(true); } else { return(false); } case 5: consoleObsrvColl.Clear(); Int64 num = 122001001424000; var tempColl = new ObservableCollection <SpreadLogModel>(File.ReadAllLines(fileLoc).Select(v => SetDictionaryForConsole_NSEComparison(v, num)).Where(x => x != null)); // Console.WriteLine(DictionaryOrderId_SpreadLogModel.Count); consoleObsrvColl = (ObservableCollection <SpreadLogModel>)TransferFromDictionaryToCollection(DictionaryOrderId_SpreadLogModel); if (consoleObsrvColl.Count > 0) { return(true); } else { return(false); } default: return(false); } }
public bool LoadDataForUserFromDataBase(short user, string dateFrom, string dateTo, short sequence, bool IsLiveDb) { switch (sequence) { case 1: // string query_user1 = "select DISTINCT L.exorderno,L.logtime,ob.secdesc,L.price,L.origth ,L.ticktype,L.orderstate,L.side,L.token,L.qty,L.strategytype,L.userid,ob.type from order_combined_table L INNER JOIN order_combined_table R ON L.exorderno=R.exorderno and L.token=R.token and L.price=R.price ,orderbook_20171221 ob where R.userid = " + user + "and L.token=ob.token and L.orderstate=2 and L.tsinsert>='" + dateFrom + "' and L.tsinsert<='" + dateTo + "'order by L.exorderno"; if ((user1DataObsrvColl = UserDataReaderDataBase.GetDataFromDatabase(UserDataReaderDataBase.GetDataTable(user, dateFrom, dateTo))).Count > 0) { return(true); } else { return(false); } case 2: // string query_user2 = "select DISTINCT L.exorderno,L.logtime,ob.secdesc,L.price,L.origth ,L.ticktype,L.orderstate,L.side,L.token,L.qty,L.strategytype,L.userid,ob.type from order_combined_table L INNER JOIN order_combined_table R ON L.exorderno=R.exorderno and L.token=R.token and L.price=R.price ,orderbook_20171221 ob where R.userid = " + user + "and L.token=ob.token and L.orderstate=2 and L.tsinsert>='" + dateFrom + "' and L.tsinsert<='" + dateTo + "'order by L.exorderno"; if ((user2DataObsrvColl = UserDataReaderDataBase.GetDataFromDatabase(UserDataReaderDataBase.GetDataTable(user, dateFrom, dateTo))).Count > 0) { return(true); } else { return(false); } case 3: //UserDataReaderDataBase.AlphaDataTable.Clear(); if (!IsLiveDb) { #region #History Database IsSchemaCreated = false; IsCombinedTableCreationComplete = false; List <string> tablesName = UserDataReaderDataBase.GetTableNames(UserDataReaderDataBase.GetDateArray(Convert.ToDateTime(dateFrom), Convert.ToDateTime(dateTo))); List <String> ActualTableList = new List <string>(); firstDate = ""; foreach (var table in tablesName) { string query = "select count(*) as numberofrec from " + table; DataTable dt = UserDataReaderDataBase.GetDataTable(query); if (dt != null) { if (dt.Rows.Count > 0) { DataRow row = dt.Rows[0]; int count = Convert.ToInt32(row["numberofrec"]); if (count > 0) { if (!IsSchemaCreated) { firstDate = table; bool IsTableAlreadyExist = UserDataReaderDataBase.CreateTableForCombineResult("drop table order_combined_table;"); IsSchemaCreated = UserDataReaderDataBase.CreateTableForCombineResult("select * into order_combined_table from " + firstDate); } } } } else { ActualTableList.Add(table); } } if (ActualTableList.Count > 0) { foreach (var item in ActualTableList) { tablesName.Remove(item); } } if (tablesName.Count > 0) { if (IsSchemaCreated) { foreach (var table in tablesName) { string query = "Insert into order_combined_table select * from " + table; IsCombinedTableCreationComplete = UserDataReaderDataBase.CreateTableForCombineResult(query); } string date = tablesName[0]; date = date.Remove(0, date.IndexOf('_') + 1); string query_user3 = "select DISTINCT L.exorderno,L.logtime,ob.secdesc,L.price,L.origth ,L.ticktype,L.orderstate,L.side,L.token,L.qty,L.strategytype,L.userid,L.tsinsert,ob.type from order_combined_table L INNER JOIN order_combined_table R ON L.exorderno=R.exorderno and L.token=R.token and L.price=R.price ,orderbook_" + date + " ob where L.token=ob.token and L.orderstate=2 order by L.exorderno"; if ((UserDataReaderDataBase.AlphaDataTable = (DataTable)UserDataReaderDataBase.GetDataTable(query_user3)).Rows.Count > 0) { return(true); } else { return(false); } } else { return(false); } } else { return(false); } #endregion } else { #region #Live Database try { string query_user3 = "select DISTINCT L.exorderno,L.logtime,ob.secdesc,ob.symbol,L.price,L.origth ,L.ticktype,L.orderstate,L.side,L.token,L.qty,L.strategytype,L.userid,L.tsinsert,ob.type from orders L INNER JOIN orders R ON L.exorderno=R.exorderno and L.token=R.token and L.price=R.price ,orderbook ob where L.token=ob.token and L.orderstate=2 order by L.exorderno"; if ((UserDataReaderDataBase.AlphaDataTable = (DataTable)UserDataReaderDataBase.GetDataTable(query_user3)).Rows.Count > 0) { return(true); } else { return(false); } } catch (Exception ex) { System.Windows.MessageBox.Show(ex.ToString()); return(false); } #endregion } default: return(false); } }