예제 #1
0
 public bool register(Data data)
 {
     User_db user = new User_db();
     string password = Cryptopraphy.Encryption(data.getString("password"));
     data.add("password", password);
     return user.register_user(data);
 }
예제 #2
0
        private async Task LoadAsync(String url, CancellationToken cancel)
        {
            var handler = new HttpClientHandler {AllowAutoRedirect = false};
            var http = new HttpClient(handler);
            http.DefaultRequestHeaders.Add("User-Agent",
                "Mozilla/5.0 (compatible; MSIE 10.0; Windows NT 6.2; WOW64; Trident / 6.0)");



            //Get a correct URL from the given one (e.g. transform codeproject.com to http://codeproject.com)
            var uri = Sanitize(url);

            //Make the request
            var request = await http.GetAsync(uri);
            //var request = await http.GetStringAsync(uri);
            cancel.ThrowIfCancellationRequested();

            //Get the response stream
            var response = await request.Content.ReadAsStringAsync();
            cancel.ThrowIfCancellationRequested();
            var html = new Html();
            txtHtml.Text = response;
            html.CarId = Convert.ToInt32(textBox1.Text);
            html.html = response;
            html.Processed = false;
            var data = new Data();
            data.InsertHtmlData(html);
            cancel.ThrowIfCancellationRequested();

            /* Use the document */
        }
예제 #3
0
        public Data searchLucene(Data data)
        {
            Account_lg account = new Account_lg();
            List<string> item = new List<string>();
            Lucene.Net.Store.Directory directory = FSDirectory.Open(new DirectoryInfo("C:\\Visual Studio 2010\\Transaction" + "\\LuceneIndex"));
            var analyzer = new StandardAnalyzer(Version.LUCENE_29);
            IndexReader reader = IndexReader.Open(directory, true);
            IndexSearcher searcher = new IndexSearcher(reader);

            MultiFieldQueryParser parser = new MultiFieldQueryParser(Lucene.Net.Util.Version.LUCENE_29, new string[] { "name", "username" }, analyzer);  //search for multifield
            Query query = parser.Parse((data.getString("search")) + "*"); //cant search blank text with wildcard as first character

            TopScoreDocCollector collector = TopScoreDocCollector.Create(1000, true);
            searcher.Search(query, collector);
            ScoreDoc[] hits = collector.TopDocs().ScoreDocs;
            int count = hits.Length;

            for (int i = 0; i < count; i++)
            {
                int docId = hits[i].Doc;
                float score = hits[i].Score;

                Document doc = searcher.Doc(docId);

                string id = doc.Get("id");
                item.Add(id);
            }
            Data list = account.selectUser(data, item.ToArray());
            reader.Dispose();
            searcher.Dispose();

            return list;
        }
예제 #4
0
 public void transferTo(Data data)
 {
     Data db = new Data();
     db.open();
     db.insert("UPDATE account SET balance=(balance+@amount) WHERE user_id=@user_id", data);
     db.close();
 }
예제 #5
0
 public void transaction(Data data)
 {
     Data db = new Data();
     db.open();
     db.insert("INSERT INTO transaction (from_id, to_id, amount, time, from_name, to_name) VALUES (@from_id, @to_id, @amount, now(), @from_name, @to_name)", data);
     db.close();
 }
예제 #6
0
            async Task LoadAsync(int carId, String url, string userAgent, CancellationToken cancel)
            {
                var handler = new HttpClientHandler { AllowAutoRedirect = false };
                var http = new HttpClient(handler);
                http.DefaultRequestHeaders.Add("User-Agent", userAgent );



                //Get a correct URL from the given one (e.g. transform codeproject.com to http://codeproject.com)
                var uri = Sanitize(url);

                //Make the request
                var request = await http.GetAsync(uri);
                //var request = await http.GetStringAsync(uri);
                cancel.ThrowIfCancellationRequested();

                //Get the response stream
                var response = await request.Content.ReadAsStringAsync();
                cancel.ThrowIfCancellationRequested();
                var html = new Html
                {
                    CarId = carId,
                    html = response,
                    Processed = false
                };
                var data = new Data();
                data.InsertHtmlData(html);
                cancel.ThrowIfCancellationRequested();

                /* Use the document */
            }
예제 #7
0
        public Data searchLucene(Data data)
        {
            Search_gl search = new Search_gl();
            List<string> item = new List<string>();
            Lucene.Net.Store.Directory directory = FSDirectory.Open(new DirectoryInfo(Environment.CurrentDirectory + "\\LuceneIndex"));
            var analyzer = new StandardAnalyzer(Version.LUCENE_29);

            IndexReader reader = IndexReader.Open(directory, true);
            IndexSearcher searcher = new IndexSearcher(reader);

            //QueryParser queryParser = new QueryParser(Version.LUCENE_29, "summary", analyzer);  //search for single field
            MultiFieldQueryParser parser = new MultiFieldQueryParser(new string[] {"name", "summary"}, analyzer);  //search for multifield
            Query query = parser.Parse((data.getString("search")) + "*"); //cant search blank text with wildcard as first character

            TopScoreDocCollector collector = TopScoreDocCollector.create(1000, true);
            searcher.Search(query, collector);
            ScoreDoc[] hits = collector.TopDocs().ScoreDocs;
            int count = hits.Length;

            for (int i = 0; i < count; i++)
            {
                int docId = hits[i].doc;
                float score = hits[i].score;

                Document doc = searcher.Doc(docId);

                string id = doc.Get("id");
                item.Add(id);
            }
            Data list = search.search(data, item.ToArray());
            reader.Close();
            searcher.Close();

            return list;
        }
예제 #8
0
 public Data selectImage(Data data)
 {
     Data db = new Data();
     db.open();
     Data result = db.select("SELECT path, caption FROM image WHERE id=@imageId", data);
     db.close();
     return result;
 }
예제 #9
0
 public bool insert(Data data)
 {
     Data db = new Data();
     db.open();
     int result = db.insert("INSERT INTO account(balance, user_id, date) VALUES (1000.00, @user_id, now())", data);
     db.close();
     return true;
 }
예제 #10
0
 public Data selectTransaction(Data data)
 {
     Data db = new Data();
     db.open();
     Data result = db.select("SELECT * FROM transaction WHERE from_id=@user_id OR to_id=@user_id", data);
     db.close();
     return result;
 }
예제 #11
0
 public Data selectInserted(Data data)
 {
     Data db = new Data();
     db.open();
     Data result = db.select("SELECT * FROM profile WHERE name=@name AND address=@address AND email=@email AND phone=@phone", data);
     db.close();
     return result;
 }
예제 #12
0
 public bool register_user(Data data)
 {
     Data db = new Data();
     db.open();
     int result = db.insert("INSERT INTO user(username, password, firstname, lastname) VALUES (@username, @password, @firstname, @lastname)", data);
     db.close();
     return true;
 }
예제 #13
0
 public Data getUserID(Data data)
 {
     Data db = new Data();
     db.open();
     Data result = db.select("SELECT id, username FROM user WHERE username=@username", data);
     db.close();
     return result;
 }
예제 #14
0
 public bool insert(Data data)
 {
     Data db = new Data();
     db.open();
     int result = db.insert("INSERT INTO rating(value, profile_id, user_id) VALUES (@value, @profile_id, @user_id)", data);
     db.close();
     return true;
 }
예제 #15
0
 public Data getTotalRating(Data data)
 {
     Data db = new Data();
     db.open();
     Data result = db.select("SELECT value FROM rating WHERE profile_id=@profile_id", data);
     db.close();
     return result;
 }
예제 #16
0
 public Data getRatingThree(Data data)
 {
     Data db = new Data();
     db.open();
     Data result = db.select("SELECT * FROM rating WHERE value=3 AND profile_id=@profile_id", data);
     db.close();
     return result;
 }
예제 #17
0
 public Data checkUserRating(Data data)
 {
     Data db = new Data();
     db.open();
     Data result = db.select("SELECT id FROM rating WHERE profile_id=@profile_id AND user_id=@user_id", data);
     db.close();
     return result;
 }
예제 #18
0
 public bool update(Data data)
 {
     Profile_db profile = new Profile_db();
     GoogleMap_gl google = new GoogleMap_gl();
     data.add("latitude", google.GetLatitudeLongitude(data).Item1.ToString());
     data.add("longitude", google.GetLatitudeLongitude(data).Item2.ToString());
     return profile.update(data);
 }
예제 #19
0
파일: CcDal.cs 프로젝트: wcrowe/CarCrawler
 public CcDal()
 {
     DataAccess = new Data();
     // DataAccess.CleanTables();
     _emptyList = DataAccess.GetEmptyDetail();
     _feeds = DataAccess.GetActiveFeeds();
     _predicates = DataAccess.GetPredicates();
 }
예제 #20
0
 public Data numPerRate(Data data)
 {
     Data db = new Data();
     db.open();
     Data result = db.select("SELECT id FROM rating WHERE profile_id=@profile_id AND value=@value", data);
     db.close();
     return result;
 }
예제 #21
0
 public Data login(Data data)
 {
     Data db = new Data();
     db.open();
     Data result = db.select("SELECT username, firstname, lastname FROM user WHERE username = @username AND password = @password", data);
     db.close();
     return result;
 }
예제 #22
0
        public Data advanceSearch(Data data)
        {
            Data radius = searchRadius(data);
            if (data.getString("search") != "" && data.getString("range") !="" && data.getString("rate") != "")
            {

            }
        }
예제 #23
0
 public Data select(Data data)
 {
     Data db = new Data();
     db.open();
     Data result = db.select("SELECT * FROM profile WHERE id=@id", data);
     db.close();
     return result;
 }
예제 #24
0
 public Data getSearchForIndex(Data data)
 {
     Data db = new Data();
     db.open();
     Data result = db.select("SELECT * FROM profile", data);
     db.close();
     return result;
 }
예제 #25
0
 public Data getUser(Data data)
 {
     Data db = new Data();
     db.open();
     Data result = db.select("SELECT * FROM user WHERE id=@user_id", data);
     db.close();
     return result;
 }
예제 #26
0
 public Data select(Data data)
 {
     Data db = new Data();
     db.open();
     Data result = db.select("SELECT * FROM account WHERE user_id=@user_id", data);
     db.close();
     return result;
 }
예제 #27
0
 public Data selectAll(Data data)
 {
     Data db = new Data();
     db.open();
     Data result = db.select("SELECT * FROM profile ORDER BY name ASC LIMIT @page, 10", data);
     db.close();
     return result;
 }
예제 #28
0
 public Data luceneSelect(Data data)
 {
     Data db = new Data();
     db.open();
     Data result = db.select("SELECT * FROM user", data);
     db.close();
     return result;
 }
예제 #29
0
 public bool insert(Data data)
 {
     Data db = new Data();
     db.open();
     int result = db.insert("INSERT INTO image(name, path, caption, profile_id) VALUES (@name, @path, @caption, @profile_id)", data);
     db.close();
     return true;
 }
예제 #30
0
 public void transfer(Data userAccount, Data targetAccount, Data data)
 {
     double enterAmount = Convert.ToDouble(data.getString("balance"));
     Account_db account = new Account_db();
     targetAccount.add("amount", enterAmount);
     userAccount.add("amount", enterAmount);
     account.transferTo(targetAccount);
     account.transferFrom(userAccount);
 }