private string GetDocLocation(int docID, int databaseChooise) { string DocLocation = "Error"; try { //da den kun såger behøver der ikke at være adgang til all string DBName = new DataBaseManager().GetDatabaseLocation(databaseChooise); using (var _reposetory = new PoliceDBEntities("name=" + DBName)) { //SELECT[id],[docLocation] FROM[PoliceDB].[dbo].[Doc] WHERE[Doc].[id] like 70598; string sqlCode = "SELECT[id],[docLocation] FROM[" + new DataBaseManager().GetDatabaseName(DBName) + "].[dbo].[Doc] WHERE [Doc].[id] like '" + docID + "';"; var docs = _reposetory.Doc.SqlQuery(sqlCode).ToList(); if (docs.Count != 0) { DocLocation = docs[0].docLocation; } } } catch (Exception ex) { Console.WriteLine(ex.ToString()); } return(DocLocation); }
private List <int> GetDocIDs(int wordID, int databaseChooise) { List <int> DocIds = new List <int>(); try { //da den kun såger behøver der ikke at være adgang til all string DBName = new DataBaseManager().GetDatabaseLocation(databaseChooise); using (var _reposetory = new PoliceDBEntities("name=" + DBName)) { // SELECT[DocId],[WordId] FROM[PoliceDB].[dbo].[Connection] WHERE[Connection].[WordId] like 2092; string sqlCode = "SELECT[DocId],[WordId] FROM[" + new DataBaseManager().GetDatabaseName(DBName) + "].[dbo].[Connection] WHERE[Connection].[WordId] like '" + wordID + "';"; var cons = _reposetory.Connection.SqlQuery(sqlCode).ToList(); if (cons.Count != 0) { foreach (var con in cons) { DocIds.Add(con.DocId); } } } } catch (Exception ex) { Console.WriteLine(ex.ToString()); } return(DocIds); }
private int GetWordID(string wordtext, int databaseChooise) { int wordId = -1; try { //da den kun såger behøver der ikke at være adgang til all string DBName = new DataBaseManager().GetDatabaseLocation(databaseChooise); using (var _reposetory = new PoliceDBEntities("name=" + DBName)) { string sqlCode = "SELECT[id],[text] FROM[" + new DataBaseManager().GetDatabaseName(DBName) + "].[dbo].[Word] WHERE [Word].[text] like '" + wordtext + "';"; var ws = _reposetory.Word.SqlQuery(sqlCode).ToList(); if (ws.Count != 0) { wordId = ws[0].id; } } } catch (Exception ex) { Console.WriteLine(ex.ToString()); } return(wordId); }
public int GetDocId(string sDocLocation, string DatabaseLNavn) { int docId = -1; try { //da den kun såger behøver der ikke at være adgang til all using (var _reposetory = new PoliceDBEntities("name=" + DatabaseLNavn)) { string sqlCode = "SELECT[id],[docLocation] FROM[" + new DataBaseManager().GetDatabaseName(DatabaseLNavn) + "].[dbo].[Doc] WHERE[Doc].[docLocation] like '" + sDocLocation + "';"; //Console.WriteLine(sqlCode); var ws = _reposetory.Doc.SqlQuery(sqlCode).ToList(); if (ws.Count != 0) { docId = ws[0].id; Console.Write("-"); } else { // den burte altid kunne finde ordet men hvis ikke adder vi den da vi asumen at der er en fejl i databasen CreateDoc(new Doc() { docLocation = sDocLocation }); docId = GetDocId(sDocLocation, DatabaseLNavn); Console.Write("ERROR DOC WAS NOT FOUND HAVE CREATEDE IT " + sDocLocation); } } } catch (Exception ex) { Console.WriteLine(ex.ToString()); } return(docId); }
//get docs from databe chossen by input/PDB public List <Doc> GetDocs(string PDB) { List <Doc> docs = new List <Doc>(); try { using (var _reposertory = new PoliceDBEntities(PDB)) { docs = _reposertory.Doc.ToList(); } } catch (Exception ex) { Console.WriteLine(ex.ToString()); } return(docs); }
public int GetWordID(string wordtext) { int wordId = -1; try { //da den kun såger behøver der ikke at være adgang til all using (var _reposetory = new PoliceDBEntities("name= PoliceDBEntities")) { string sqlCode = "SELECT[id],[text] FROM[PoliceDB].[dbo].[Word] WHERE [Word].[text] like '" + wordtext + "';"; var ws = _reposetory.Word.SqlQuery(sqlCode).ToList(); if (ws.Count != 0) { wordId = ws[0].id; } } } catch (Exception ex) { Console.WriteLine(ex.ToString()); } return(wordId); }