public PagedQueryResultModel ProcessSqlScript(SqlScriptModel sqlScript) { var sqlRequest = sqlScript.SqlRequest; AddParameters(sqlScript); var connectionString = string.IsNullOrEmpty(sqlRequest.ConnectionStringName) ? config.ConnectionString : config.GetUserConnectionString(sqlRequest.ConnectionStringName); //var connectionString = "Data Source = 193.93.216.233;Initial Catalog = TILT2_DEV;Integrated Security = False;User Id = sae;Password=Devabit1@"; var offset = (sqlRequest.PaginationModel.PageNumber - 1) * sqlRequest.PaginationModel.PageSize + sqlRequest.PaginationModel.Skip; var pageSize = sqlRequest.PaginationModel.PageSize; using (var connection = new SqlConnection(connectionString)) { connection.Open(); //var totalCount = new SqlCommand(SqlExpression.CountExpression(sqlRequest.SqlScript), connection).ExecuteScalar(); // sqlRequest.SqlScript.AddPaginationToScript(offset, pageSize); var sqlCommand = new SqlCommand(sqlRequest.SqlScript, connection); var sqlDataAdapter = new SqlDataAdapter(sqlCommand); var dataSet = new DataSet(); sqlDataAdapter.Fill(dataSet); var parser = new DataSetParser(dataSet); var result = parser.ToQueryResultModel(); var totalCount = result.Rows.Count; result.Rows = result.Rows.Skip(Convert.ToInt32(offset)).Take(Convert.ToInt32(pageSize)).ToList(); return(new PagedQueryResultModel { TotalCount = totalCount,// (int?)totalCount ?? 0, PageCount = (long)Math.Ceiling((double)totalCount / sqlRequest.PaginationModel.PageSize), PageNumber = sqlRequest.PaginationModel.PageNumber, HasNext = Math.Ceiling((double)totalCount / sqlRequest.PaginationModel.PageSize) > sqlRequest.PaginationModel.PageNumber, Result = result }); } }
public List <Werknemer> GetAll() { List <Werknemer> werknemerList = new List <Werknemer>(); try { string sql = "SELECT A.AccountId, A.Naam, A.Achternaam, A.Email, F.Stad, Werknemer.FiliaalId, Werknemer.WerknemerId FROM Account AS A INNER JOIN Werknemer on A.Accountid = Werknemer.AccountID " + "INNER JOIN Filiaal AS F on Werknemer.FiliaalId = f.FiliaalId "; List <KeyValuePair <string, string> > parameters = new List <KeyValuePair <string, string> >() { }; DataSet results = ExecuteSql(sql, parameters); for (int x = 0; x < results.Tables[0].Rows.Count; x++) { Werknemer w = DataSetParser.DataSetToWerknemer(results, x); werknemerList.Add(w); } return(werknemerList); } catch (Exception e) { throw e; } }
public List <Order> GetAll() { List <Order> orderList = new List <Order>(); try { string sql = "SELECT o.OrderID, o.Datum, o.OntvangerId, o.WerknemerID, o.Ontvangen, o.Aantal, o.ProductID, o.VerzenderID, o.Verzonden FROM [Order] AS o where Ontvangen = 0"; List <KeyValuePair <string, string> > parameters = new List <KeyValuePair <string, string> >(); DataSet results = ExecuteSql(sql, parameters); for (int x = 0; x < results.Tables[0].Rows.Count; x++) { Order o = DataSetParser.DataSetToOrder(results, x); orderList.Add(o); } return(orderList); } catch (Exception e) { throw e; } }
public List <Product> Zoeken(string zoekterm) { List <Product> productList = new List <Product>(); try { string sql = "SELECT Product.ProductID , Product.CategorieId, Product.Omschrijving, Product.naam, Product.Aantal, Product.Prijs, Product.Soort, Product.Actief, Product.Tweedehands, Categorie.Naam, Product.ImagePath FROM Product INNER JOIN Categorie ON Product.CategorieID = Categorie.CategorieID WHERE CHARINDEX(@zoekterm, Product.Naam) > 0 ORDER BY Product.Naam"; List <KeyValuePair <string, string> > parameters = new List <KeyValuePair <string, string> > { new KeyValuePair <string, string>("Zoekterm", zoekterm), }; DataSet results = ExecuteSql(sql, parameters); for (int x = 0; x < results.Tables[0].Rows.Count; x++) { Product p = DataSetParser.DataSetToProduct(results, x); productList.Add(p); } return(productList); } catch (Exception e) { throw e; } }
public List <Product> GetAllGames() { List <Product> productList = new List <Product>(); try { string sql = "select Product.ProductID , Product.CategorieId, Product.Omschrijving,Product.naam,Product.Aantal, Product.Prijs, Product.Soort,Product.Actief,Product.Tweedehands,Product.Naam, Product.ImagePath from Product where CategorieId <= 9"; List <KeyValuePair <string, string> > parameters = new List <KeyValuePair <string, string> > { }; DataSet results = ExecuteSql(sql, parameters); for (int x = 0; x < results.Tables[0].Rows.Count; x++) { Product p = DataSetParser.DataSetToProduct(results, x); productList.Add(p); } return(productList); } catch (Exception e) { throw e; } }
public List <BestellingProduct> GetAllById(long id) { List <BestellingProduct> BestelList = new List <BestellingProduct>(); try { string sql = "SELECT Product.Naam, Product.Omschrijving, ProductBestelling.aantal, Product.Prijs, Bestelling.Datum FROM ((ProductBestelling INNER JOIN Product ON ProductBestelling.ProductId = Product.ProductId) INNER JOIN Bestelling ON ProductBestelling.BestellingID = Bestelling.BestellingID) WHERE KlantID = @klantID"; List <KeyValuePair <string, string> > parameters = new List <KeyValuePair <string, string> > { new KeyValuePair <string, string>("klantID", id.ToString()), }; DataSet results = ExecuteSql(sql, parameters); for (int x = 0; x < results.Tables[0].Rows.Count; x++) { BestellingProduct p = DataSetParser.DataSetToBestellingProduct(results, x); BestelList.Add(p); } return(BestelList); } catch (Exception e) { throw e; } }
public List <Bestelling> GetAll() { List <Bestelling> bestellingList = new List <Bestelling>(); try { string sql = "SELECT Datum, KlantID FROM Bestelling"; List <KeyValuePair <string, string> > parameters = new List <KeyValuePair <string, string> > { }; DataSet results = ExecuteSql(sql, parameters); for (int x = 0; x < results.Tables[0].Rows.Count; x++) { Bestelling b = DataSetParser.DataSetToBestelling(results, x); bestellingList.Add(b); } return(bestellingList); } catch (Exception e) { throw e; } }
public List <Traject> GetTrajectenbyStations(long beginStationId, long eindStationId) { try { string query = "SELECT id, naam, actief FROM GetTrajects" + " WHERE beginPerronId IN ( SELECT Id FROM Perron WHERE stationId = @beginstationid)" + " AND eindPerronId IN ( SELECT Id FROM Perron WHERE = @eindstationid"; List <KeyValuePair <string, string> > parameters = new List <KeyValuePair <string, string> >() { new KeyValuePair <string, string>("beginstationid", beginStationId.ToString()), new KeyValuePair <string, string>("eindstationid", eindStationId.ToString()) }; DataSet results = ExecuteSql(query, parameters); List <Traject> trajecten = new List <Traject>(); if (results != null) { for (int x = 0; x < results.Tables[0].Rows.Count; x++) { Traject t = DataSetParser.DataSetToTraject(results, x); trajecten.Add(t); } } return(trajecten); } catch { return(null); } }
static void Main(string[] args) { LexConfig config = new LexConfig( new DataSet[] { DataSetParser.Parse("TokensDefinitions", Resources.TokenDefinitions) }, new DataSet[] { DataSetParser.Parse("DataType Words", Resources.DataTypes) }); StructureConfig structureConfig = new StructureConfig(DataSetParser.Parse("Structure Configuration", Resources.XsGrammarConfig)); TokenSet tokenSet = new Lexer(config, structureConfig).Lex(Resources.XsFunction); Debug.Imp("STATS:"); Debug.Imp($"Contains {tokenSet.Length} tokens!"); for (int i = 0; i < config.Tokens.All.Length; i++) { if (tokenSet.GetAllOfType(config.Tokens.All.GetSet(i).Name, out TokenSet set)) { Debug.Imp($"Contains type [{config.Tokens.All.GetSet(i).Name}] {set.Length} times!"); } } Debug.Log("Tokens found: " + tokenSet.Length); //Debug.Log(tokenSet); StringBuilder sb = new StringBuilder(Resources.XsFunction.Length); for (int i = 0; i < tokenSet.Length; i++) { sb.Append(tokenSet[i].Value); } File.WriteAllText("D:/Temp/Ree.txt", sb.ToString()); Debug.Pause(); }
public List <Review> GetAllReviewsByUserID(int id) { string Query = "SELECT TOP(10) [Reviews].ID, [Reviews].Body, [Reviews].Rating, [Reviews].DatePosted, [Users].ID, [Users].Name, [Books].ID, [Books].Title " + "FROM ([Reviews] " + "INNER JOIN [Books] ON [Books].ID = [Reviews].BookID " + "INNER JOIN [Users] ON [Users].ID = [Reviews].UserID) " + "WHERE [Users].ID = @userid " + "ORDER BY [Reviews].DatePosted DESC"; List <KeyValuePair <string, string> > Params = new List <KeyValuePair <string, string> >(); Params.Add(new KeyValuePair <string, string>("userid", id.ToString())); DataSet Results = this.ExecuteSQL(Query, Params); List <Review> Reviews = new List <Review>(); if (Results != null) { for (int i = 0; i < Results.Tables[0].Rows.Count; i++) { Review r = DataSetParser.DataSetToReview(Results, i); Reviews.Add(r); } } return(Reviews); }
public void ReadExampleDataSet() { DataSetParser dataSetParser = new DataSetParser(); dataSetParser.ReadFile(@"../../../DataSets/a_example.in"); Assert.Equal(6, dataSetParser.dataSetInfo.NumberCompiledFiles); Assert.Equal(3, dataSetParser.dataSetInfo.NumberTargetFiles); Assert.Equal(2, dataSetParser.dataSetInfo.NumberAvailableServers); Assert.Equal(6, dataSetParser.dataSetInfo.CompiledFiles.Count); var dependendencies = dataSetParser.dataSetInfo.CompiledFiles[5].compiledFileDependencies; Assert.Equal(2, dependendencies.Count); Assert.Equal("c2", dependendencies[0]); Assert.Equal("c3", dependendencies[1]); Assert.Equal(3, dataSetParser.dataSetInfo.TargetFiles.Count); var lastTargetFile = dataSetParser.dataSetInfo.TargetFiles[2]; Assert.Equal("c5", lastTargetFile.FileName); Assert.Equal(53, lastTargetFile.Deadline); Assert.Equal(35, lastTargetFile.GoalPoints); }
public List <Product> GetAll() { try { string sql = "SELECT P.Id, P.Naam, P.Prijs, P.Grootte, P.Kleur, P.Beschrijving, P.Voorraad, C.Naam, P.CategorieId, P.Actief FROM Product as P INNER JOIN Categorie as C ON P.CategorieId = C.Id"; List <Product> producten = new List <Product>(); List <KeyValuePair <string, string> > parameters = new List <KeyValuePair <string, string> > { }; ExecuteSql(sql, parameters); DataSet result = ExecuteSql(sql, parameters); if (result != null && result.Tables[0].Rows.Count > 0) { for (int x = 0; x < result.Tables[0].Rows.Count; x++) { Product p = DataSetParser.DataSetToProduct(result, x); producten.Add(p); } } return(producten); } catch (Exception e) { throw e; } }
public List <Filiaal> GetAll() { try { string sql = "select * from Filiaal"; List <Filiaal> lijstfiliaal = new List <Filiaal>(); List <KeyValuePair <string, string> > parameters = new List <KeyValuePair <string, string> > { }; DataSet results = ExecuteSql(sql, parameters); if (results != null && results.Tables[0].Rows.Count > 0) { for (int i = 0; i < results.Tables[0].Rows.Count; i++) { Filiaal f = DataSetParser.DataSetToFiliaal(results, i); lijstfiliaal.Add(f); } } return(lijstfiliaal); } catch (Exception ex) { throw ex; } }
public List <Categorie> GetAll() { try { string sql = "SELECT C.Id, C.Naam, C.Actief, Count(P.Naam) as Aantal From Categorie as C LEFT JOIN Product as P ON C.Id = P.CategorieId GROUP BY C.Id, C.Naam, C.Actief"; List <Categorie> categorien = new List <Categorie>(); List <KeyValuePair <string, string> > parameters = new List <KeyValuePair <string, string> > { }; ExecuteSql(sql, parameters); DataSet result = ExecuteSql(sql, parameters); if (result != null && result.Tables[0].Rows.Count > 0) { for (int x = 0; x < result.Tables[0].Rows.Count; x++) { Categorie c = DataSetParser.DataSetToCategorie(result, x); categorien.Add(c); } } return(categorien); } catch (Exception e) { throw e; } }
public List <Bestelling> GetAllFromUser(long Id) { try { string sql = "SELECT Besteldatum, Leverdatum, TotaalPrijs From Bestelling WHERE Accountid = @id"; List <Bestelling> bestellingen = new List <Bestelling>(); List <KeyValuePair <string, string> > parameters = new List <KeyValuePair <string, string> > { new KeyValuePair <string, string>("Id", Id.ToString()), }; ExecuteSql(sql, parameters); DataSet result = ExecuteSql(sql, parameters); if (result != null && result.Tables[0].Rows.Count > 0) { for (int x = 0; x < result.Tables[0].Rows.Count; x++) { Bestelling b = DataSetParser.DataSetToBestelling(result, x); bestellingen.Add(b); } } return(bestellingen); } catch (Exception e) { throw e; } }
public List <Klant> GetAll() { List <Klant> klantList = new List <Klant>(); try { string sql = "SELECT Naam, Achternaam, Email, Postcode, Huisnummer, Geboortedatum, Punten, AccountID FROM Klant INNER JOIN Account ON klant.klantID = account.AccountID"; List <KeyValuePair <string, string> > parameters = new List <KeyValuePair <string, string> > { }; DataSet results = ExecuteSql(sql, parameters); for (int x = 0; x < results.Tables[0].Rows.Count; x++) { Klant k = DataSetParser.DataSetToKlant(results, x); klantList.Add(k); } return(klantList); } catch (Exception e) { throw e; } }
public ChatroomContainerViewModel FetchRooms() { ChatroomContainerViewModel roomsList = new ChatroomContainerViewModel(); string SQL = "SELECT * FROM [Chatroom]"; List <KeyValuePair <object, object> > parameters = new List <KeyValuePair <object, object> >(); DataTable dt = new BaseMssqlContext().ExecuteQuery(SQL, parameters); roomsList.Rooms = new List <ChatroomViewModel>(); for (int j = 0; j < dt.Rows.Count; j++) { roomsList.Rooms.Add(DataSetParser.DatasetToChatroom(dt, j)); } foreach (ChatroomViewModel chatView in roomsList.Rooms) { List <int> members = new List <int>(); string SQLrooms = "SELECT user_id FROM [Chatroom_User] WHERE chatroom_id = @Chatroom_Id AND access_verified = 1"; List <KeyValuePair <object, object> > param = new List <KeyValuePair <object, object> >(); param.Add(new KeyValuePair <object, object>("Chatroom_Id", chatView.Id)); DataTable dataTable = new BaseMssqlContext().ExecuteQuery(SQLrooms, param); for (int i = 0; i < dataTable.Rows.Count; i++) { members.Add(Convert.ToInt32(dataTable.Rows[i][0])); } chatView.MemberList = members; } FillRoomList(roomsList); return(roomsList); }
public List <Categorie> GetAll() { try { string sql = "SELECT * From Categorie"; List <Categorie> categorieList = new List <Categorie>(); List <KeyValuePair <string, string> > parameters = new List <KeyValuePair <string, string> > { }; DataSet result = ExecuteSql(sql, parameters); if (result != null && result.Tables[0].Rows.Count > 0) { for (int x = 0; x < result.Tables[0].Rows.Count; x++) { Categorie c = DataSetParser.DataSetToCategorie(result, x); categorieList.Add(c); } } return(categorieList); } catch (Exception e) { throw e; } }
public List <Product> Zoeken(string Zoekterm) { List <Product> productList = new List <Product>(); try { string sql = "SELECT P.Id, P.Naam, P.Prijs, P.Grootte, P.Kleur, P.Beschrijving, P.Voorraad, C.Naam, P.CategorieId, P.Actief FROM Product as P INNER JOIN Categorie as C ON P.CategorieId = C.Id WHERE CHARINDEX(@zoekterm, P.Naam) > 0 ORDER BY P.Naam"; List <KeyValuePair <string, string> > parameters = new List <KeyValuePair <string, string> > { new KeyValuePair <string, string>("zoekterm", Zoekterm), }; DataSet results = ExecuteSql(sql, parameters); for (int x = 0; x < results.Tables[0].Rows.Count; x++) { Product p = DataSetParser.DataSetToProduct(results, x); productList.Add(p); } return(productList); } catch (Exception e) { throw e; } }
public List <Account> GetAll() { List <Account> accountList = new List <Account>(); try { string sql = "SELECT Naam, Achternaam, Email FROM Account"; List <KeyValuePair <string, string> > parameters = new List <KeyValuePair <string, string> > { }; DataSet results = ExecuteSql(sql, parameters); for (int x = 0; x < results.Tables[0].Rows.Count; x++) { Account a = DataSetParser.DataSetToAccount(results, x); accountList.Add(a); } return(accountList); } catch (Exception e) { throw e; } }
public List <Accommodation> Search(string searchTerm) { List <Accommodation> accommodationList = new List <Accommodation>(); searchTerm = CustomFormat(searchTerm); try { string sql = "SELECT [AccommodationID], [Title], [Description], [Image], [Country] FROM Accommodation WHERE [Title] LIKE @SearchTerm OR [Description] LIKE @SearchTerm"; List <KeyValuePair <string, string> > parameters = new List <KeyValuePair <string, string> >() { new KeyValuePair <string, string>("@SearchTerm", "%" + searchTerm + "%") }; DataSet results = ExecuteSql(sql, parameters); for (int x = 0; x < results.Tables[0].Rows.Count; x++) { Accommodation a = DataSetParser.DataSetToAccommodation(results, x); accommodationList.Add(GetPrices(a)); } return(accommodationList); } catch { throw; } }
public LocationViewModel GetByID(long LocationId) { string SQL = "SELECT * FROM [Location] WHERE ID = @Location_ID"; List <KeyValuePair <object, object> > param = new List <KeyValuePair <object, object> >(); param.Add(new KeyValuePair <object, object>("Location_ID", LocationId)); DataTable dt = ExecuteQuery(SQL, param); LocationViewModel result = DataSetParser.DataSetToLocation(dt, 0); return(result); }
public List <ShiftDTO> GetAllShiftsForClub(string month) { string query = "SELECT * FROM dienst WHERE MONTH(startMoment) = @month"; List <KeyValuePair <string, string> > parameters = new List <KeyValuePair <string, string> >(); // parameters.Add(new KeyValuePair<string, string>("id", id.ToString())); parameters.Add(new KeyValuePair <string, string>("month", month)); DataSet results = ExecuteQuery(query, parameters); List <ShiftDTO> shifts = new List <ShiftDTO>(); if (results != null) { for (int i = 0; i < results.Tables[0].Rows.Count; i++) { ShiftDTO shift = DataSetParser.DataSetToShift(results, i); if (shift.ID != 0) { // Get members ID query = "SELECT lidID FROM `lid-dienst-combo` WHERE dienstID=@id"; parameters.Clear(); parameters.Add(new KeyValuePair <string, string>("id", shift.ID.ToString())); DataSet res = ExecuteQuery(query, parameters); if (res.Tables[0].Rows.Count != 0) { int memberId = (int)res.Tables[0].Rows[0][0]; // Get actual member query = "SELECT * FROM leden WHERE id = @id"; parameters.Clear(); parameters.Add(new KeyValuePair <string, string>("id", memberId.ToString())); DataSet member = ExecuteQuery(query, parameters); // Add member to shift shift.Members = DataSetParser.DataSetToMember(member, 0); } } shifts.Add(shift); } } return(shifts); }
public ChatroomViewModel GetById(long roomId) { string SQL = "SELECT * FROM [Chatroom] WHERE ID = @Chatroom_ID"; List <KeyValuePair <object, object> > parameters = new List <KeyValuePair <object, object> >(); parameters.Add(new KeyValuePair <object, object>("Chatroom_ID", roomId)); DataTable dt = ExecuteQuery(SQL, parameters); ChatroomViewModel result = DataSetParser.DatasetToChatroom(dt, 0); return(result); }
public void ReadBigDataSet() { DataSetParser dataSetParser = new DataSetParser(); dataSetParser.ReadFile(@"../../../DataSets/f_big.in"); Assert.Equal(9992, dataSetParser.dataSetInfo.NumberCompiledFiles); Assert.Equal(4336, dataSetParser.dataSetInfo.NumberTargetFiles); Assert.Equal(100, dataSetParser.dataSetInfo.NumberAvailableServers); Assert.Equal(9992, dataSetParser.dataSetInfo.CompiledFiles.Count); Assert.Equal(4336, dataSetParser.dataSetInfo.TargetFiles.Count); }
public Author GetAuthorByID(int id) { string Query = $"SELECT Authors.ID, Authors.Name, Authors.DateOfBirth, Authors.Info FROM Authors WHERE [Authors].ID = @AuthorID"; List <KeyValuePair <string, string> > Params = new List <KeyValuePair <string, string> >(); Params.Add(new KeyValuePair <string, string>("AuthorID", id.ToString())); DataSet Result = this.ExecuteSQL(Query, Params); Author A = null; if (Result != null) { A = DataSetParser.DataSetToAuthor(Result, 0); } return(A); }
public void FindAddressBy(ClubModel club) { string query = "Select * from adres where zipcode=@zipcode"; List <KeyValuePair <string, string> > parameters = new List <KeyValuePair <string, string> >(); parameters.Add(new KeyValuePair <string, string>("zipcode", club.ZipCode)); DataSet results = ExecuteQuery(query, parameters); AddressModel address = new AddressModel(); if (results != null && results.Tables[0].Rows.Count > 0) { address = DataSetParser.DataSetToaddress(results, 0); } club.AID = address.AID; }
public Book GetBookByID(int id) { string Query = "EXEC GetBookByID @BookID = @id"; List <KeyValuePair <string, string> > Params = new List <KeyValuePair <string, string> >(); Params.Add(new KeyValuePair <string, string>("id", id.ToString())); DataSet Result = this.ExecuteSQL(Query, Params); Book B = null; if (Result != null) { B = DataSetParser.DataSetToBook(Result, 0); } return(B); }
public List <Accommodation> QuickSearch(SearchVm sm) { List <Accommodation> result = new List <Accommodation>(); if (!string.IsNullOrEmpty(sm.Search)) { sm.Search = CustomFormat(sm.Search); } string sql = "SELECT [AccommodationId], [Title], [Description], [Image], " + "[Country] FROM [Accommodation]"; List <KeyValuePair <string, string> > parameters = new List <KeyValuePair <string, string> >(); if (sm.Country != null) { sql += "WHERE [Country] = @country"; parameters.Add(new KeyValuePair <string, string>("@country", Convert.ToInt32(sm.Country).ToString())); } DataSet results = ExecuteSql(sql, parameters); for (int x = 0; x < results.Tables[0].Rows.Count; x++) { Accommodation a = DataSetParser.DataSetToAccommodation(results, x); result.Add(GetPrices(a)); } if (sm.TravelType == TravelTypes.Zomer) { result = result.Where(n => n.DatePrices.Count(m => m.Date.Month >= 3 || m.Date.Month <= 9) != 0).ToList(); } else if (sm.TravelType == TravelTypes.Winter) { result = result.Where(n => n.DatePrices.Count(m => m.Date.Month <= 2 || m.Date.Month >= 10) != 0) .ToList(); } if (sm.Month != null) { result = result.Where(n => n.DatePrices.Count(m => m.Date.Month == (int)(Months)sm.Month + 1) != 0).ToList(); } return(result); }
public ScheduleDTO FindScheduleById(int id) { string query = "Select * from schema where id=@id"; List <KeyValuePair <string, string> > parameters = new List <KeyValuePair <string, string> >(); parameters.Add(new KeyValuePair <string, string>("id", id.ToString())); DataSet results = ExecuteQuery(query, parameters); ScheduleDTO s = new ScheduleDTO(); if (results != null && results.Tables[0].Rows.Count > 0) { s = DataSetParser.DataSetToSchedule(results, 0); } return(s); }