public tenderPage() { BindingContext = this; var label = new Label { Text = "text" }; //StackLayout stackLayout = new StackLayout(); //var childToRaise = stackLayout.Children.First(); InitializeComponent(); //Set "Previous" and "Next" hyperlink label. var previousLblTapRecognizer = new TapGestureRecognizer(); previousLblTapRecognizer.Tapped += onPreviousPageTapped; previousPage.GestureRecognizers.Add(previousLblTapRecognizer); previousPage.IsVisible = false; //"Previous" label is set to invisible for first page var nextLblTapRecognizer = new TapGestureRecognizer(); nextLblTapRecognizer.Tapped += onNextPageTapped; nextPage.GestureRecognizers.Add(nextLblTapRecognizer); //Sending HTTP request to obtain the tender page data Task <string> httpTask = Task.Run <string>(() => HttpRequestHandler.GetRequest("http://www2.sesco.com.my/etender/notice/notice.jsp", false)); var httpResult = httpTask.Result.ToString(); //Small data extraction to get "Next" and "Previous" page hyperlinks var htmlDoc = new HtmlDocument(); htmlDoc.LoadHtml(httpResult); var aNodes = htmlDoc.DocumentNode.SelectNodes("//a"); if (aNodes != null) { foreach (var aNode in aNodes) { if (aNode.InnerHtml == "Previous") { previousUrl = "http://www2.sesco.com.my/etender/notice/" + aNode.Attributes["href"].Value; isPreviousAvailable = true; } else if (aNode.InnerHtml == "Next") { nextUrl = "http://www2.sesco.com.my/etender/notice/" + aNode.Attributes["href"].Value; isNextAvailable = true; } } } //Extract tender data from the response var tenders = DataExtraction.getWebData(httpResult, "tender"); List <tenderItem> tenderItems = (List <tenderItem>)tenders; listView.ItemsSource = tenderItems; listView.SeparatorVisibility = SeparatorVisibility.None; listView.ItemSelected += onItemSelected; }
public async Task WaitAndExecuteUpdateTenders(int milisec) { await Task.Delay(milisec); //Sending HTTP request to obtain the tender page data string httpTask = await Task.Run <string>(() => HttpRequestHandler.GetRequest("http://www2.sesco.com.my/etender/vendor/vendor_tender_eligible.jsp", true)); var httpResult = httpTask; //Extract tender data from the response var tenders = await DataExtraction.getWebData(httpResult, "eligibelTenderPage"); List <tenderItem> tenderItems = (List <tenderItem>)tenders; //delete existing eligible tenders List <dbTenderItem> dbtenders0 = await App.Database.getTendersAsync(0); await deleteDatabaseEligibleTenders(dbtenders0); //save all eligible tenders to database await saveToTenderDb(tenderItems, 0); //Get bookmark details from database if (userSession.username != "") { //string httpTask = await Task.Run<string>(() => HttpRequestHandler.GetRequest("http://www2.sesco.com.my/etender/vendor/vendor_tender_eligible.jsp", true)); //Task<List<tenderBookmark>> bookmarkHttpTask = Task.Run<List<tenderBookmark>>(() => retrieveBookmark()); List <tenderBookmark> tenderBookmarks = await retrieveBookmark(); if (tenderBookmarks != null) { //List<tenderBookmark> tenderBookmarks = bookmarkHttpTask; if (tenderBookmarks.Count > 0) { foreach (var tenderItem in tenderItems) { foreach (var tenderBookmark in tenderBookmarks) { if (tenderItem.Reference == tenderBookmark.tenderReferenceNumber) { tenderItem.BookmarkImage = "bookmarkfilled.png"; break; } } } } } } await DisplayAlert("Update Tenders", "Refresh Tenders", "Okay"); listView.ItemsSource = tenderItems; await WaitAndExecuteUpdateTenders(10800000); }
public tenderEligiblePage() { BindingContext = this; InitializeComponent(); var items = Enumerable.Range(0, 10); //Sending HTTP request to obtain the tender page data Task <string> httpTask = Task.Run <string>(() => HttpRequestHandler.GetRequest("http://www2.sesco.com.my/etender/vendor/vendor_tender_eligible.jsp", true)); var httpResult = httpTask.Result.ToString(); //Extract tender data from the response var tenders = DataExtraction.getWebData(httpResult, "eligibelTenderPage"); List <tenderItem> tenderItems = (List <tenderItem>)tenders; listView.ItemsSource = tenderItems; listView.SeparatorVisibility = SeparatorVisibility.None; listView.ItemSelected += onItemSelected; }
public editContactPerson() { BindingContext = this; InitializeComponent(); //Sending HTTP request to obtain the company profile data Task <string> httpTask = Task.Run <string>(() => HttpRequestHandler.GetRequest("http://www2.sesco.com.my/etender/vendor/vendor_contact_edit.jsp", true)); var httpResult = httpTask.Result.ToString(); //Extract company profile data from the response //var profileData = DataExtraction.getWebData(httpResult, "userContactPerson"); var profileData = Task.Run <Object>(() => DataExtraction.getWebData(httpResult, "userContactPerson")); ContactPerson profile = (ContactPerson)profileData.Result; name.Text = profile.Name; telephoneNo.Text = profile.TelephoneNo; faxNo.Text = profile.FaxNo; emailAddress.Text = profile.EmailAddress; }
public editCompanyProfile() { BindingContext = this; InitializeComponent(); //Sending HTTP request to obtain the company profile data Task <string> httpTask = Task.Run <string>(() => HttpRequestHandler.GetRequest("http://www2.sesco.com.my/etender/vendor/vendor_company_edit.jsp", true)); var httpResult = httpTask.Result.ToString(); //Extract company profile data from the response var profileData = Task.Run <Object>(() => DataExtraction.getWebData(httpResult, "userCompanyProfile")); //var profileData = DataExtraction.getWebData(httpResult, "userCompanyProfile"); CompanyProfile profile = (CompanyProfile)profileData.Result; companyName.Text = profile.CompanyName; companyRegistrationNo.Text = profile.CompanyRegistrationNo; mailingAddress.Text = profile.MailingAddress; country.Text = profile.Country; name = profile.CompanyName; regno = profile.CompanyRegistrationNo; coucode = profile.Country; }
public tenderSearchResultPage(string searchTenderResult) { //BindingContext = this; var label = new Label { Text = "text" }; //StackLayout stackLayout = new StackLayout(); //var childToRaise = stackLayout.Children.First(); InitializeComponent(); //Set "Previous" and "Next" hyperlink label. var previousLblTapRecognizer = new TapGestureRecognizer(); previousLblTapRecognizer.Tapped += onPreviousPageTapped; previousPage.GestureRecognizers.Add(previousLblTapRecognizer); previousPage.IsVisible = false; //"Previous" label is set to invisible for first page var nextLblTapRecognizer = new TapGestureRecognizer(); nextLblTapRecognizer.Tapped += onNextPageTapped; nextPage.GestureRecognizers.Add(nextLblTapRecognizer); nextPage.IsVisible = false; //Sending HTTP request to obtain the tender page data var httpResult = searchTenderResult; //Small data extraction to get "Next" and "Previous" page hyperlinks var htmlDoc = new HtmlDocument(); htmlDoc.LoadHtml(httpResult); var aNodes = htmlDoc.DocumentNode.SelectNodes("//a"); if (aNodes != null) { foreach (var aNode in aNodes) { if (aNode.InnerHtml == "Previous") { previousUrl = "http://www2.sesco.com.my/etender/notice/" + aNode.Attributes["href"].Value; isPreviousAvailable = true; previousPage.IsVisible = true; } else if (aNode.InnerHtml == "Next") { nextUrl = "http://www2.sesco.com.my/etender/notice/" + aNode.Attributes["href"].Value; isNextAvailable = true; nextPage.IsVisible = true; } } } //Extract tender data from the response var tenders = DataExtraction.getWebData(httpResult, "tender"); List <tenderItem> tenderItems = (List <tenderItem>)tenders; if (tenderItems.Count > 0) { Console.WriteLine("Tender list item no.1 ref: " + tenderItems.First().Title); } else { Console.WriteLine("No item returned!!"); } listView.ItemsSource = tenderItems; listView.SeparatorVisibility = SeparatorVisibility.None; listView.ItemSelected += onItemSelected; /*Console.WriteLine("testing"); * BindingContext = this; * var label = new Label { Text = "text" }; * //StackLayout stackLayout = new StackLayout(); * //var childToRaise = stackLayout.Children.First(); * * InitializeComponent(); * * //Set "Previous" and "Next" hyperlink label. * var previousLblTapRecognizer = new TapGestureRecognizer(); * previousLblTapRecognizer.Tapped += onPreviousPageTapped; * previousPage.GestureRecognizers.Add(previousLblTapRecognizer); * previousPage.IsVisible = false; //"Previous" label is set to invisible for first page * * var nextLblTapRecognizer = new TapGestureRecognizer(); * nextLblTapRecognizer.Tapped += onNextPageTapped; * nextPage.GestureRecognizers.Add(nextLblTapRecognizer); * * //Retrieve string search result passed from searchTenderPage * var httpResult = searchTenderResult; * * //Small data extraction to get "Next" and "Previous" page hyperlinks * var htmlDoc = new HtmlDocument(); * htmlDoc.LoadHtml(httpResult); * var aNodes = htmlDoc.DocumentNode.SelectNodes("//a"); * if (aNodes != null) * { * foreach (var aNode in aNodes) * { * if (aNode.InnerHtml == "Previous") * { * previousUrl = "http://www2.sesco.com.my/etender/notice/" + aNode.Attributes["href"].Value; * isPreviousAvailable = true; * } * else if (aNode.InnerHtml == "Next") * { * nextUrl = "http://www2.sesco.com.my/etender/notice/" + aNode.Attributes["href"].Value; * isNextAvailable = true; * } * } * } * * * //Extract tender data from the response * var tenders = DataExtraction.getWebData(httpResult, "searchtenderpage"); * List<tenderItem> tenderItems = (List<tenderItem>)tenders; * * listView.ItemsSource = tenderItems; * listView.SeparatorVisibility = SeparatorVisibility.None; * listView.ItemSelected += onItemSelected;*/ }
async void retrieveEligibleTenders() { activityIndicator.IsVisible = true; activityIndicator.IsRunning = true; //Show tenders from database first if exists, then clear database to make way for new tenders List <tenderItem> dbtenders0 = await Task.Run <List <tenderItem> >(() => retrieveTenderFromDatabase(0)); if (dbtenders0.Count > 0) { //Get bookmark details from database if (userSession.username != "") { //string httpTask = await Task.Run<string>(() => HttpRequestHandler.GetRequest("http://www2.sesco.com.my/etender/vendor/vendor_tender_eligible.jsp", true)); //Task<List<tenderBookmark>> bookmarkHttpTask = Task.Run<List<tenderBookmark>>(() => retrieveBookmark()); List <tenderBookmark> tenderBookmarks = await retrieveBookmark(); if (tenderBookmarks != null) { //List<tenderBookmark> tenderBookmarks = bookmarkHttpTask; if (tenderBookmarks.Count > 0) { foreach (var tenderItem in dbtenders0) { foreach (var tenderBookmark in tenderBookmarks) { if (tenderItem.Reference == tenderBookmark.tenderReferenceNumber) { tenderItem.BookmarkImage = "bookmarkfilled.png"; break; } } } } } } listView.ItemsSource = dbtenders0; pageTitle.IsVisible = true; activityIndicator.IsRunning = false; activityIndicator.IsVisible = false; upBtn.IsVisible = true; await WaitAndExecuteUpdateTenders(10000); } else { //Sending HTTP request to obtain the tender page data string httpTask = await Task.Run <string>(() => HttpRequestHandler.GetRequest("http://www2.sesco.com.my/etender/vendor/vendor_tender_eligible.jsp", true)); var httpResult = httpTask; //Extract tender data from the response var tenders = await DataExtraction.getWebData(httpResult, "eligibelTenderPage"); List <tenderItem> tenderItems = (List <tenderItem>)tenders; //Get bookmark details from database if (userSession.username != "") { //string httpTask = await Task.Run<string>(() => HttpRequestHandler.GetRequest("http://www2.sesco.com.my/etender/vendor/vendor_tender_eligible.jsp", true)); //Task<List<tenderBookmark>> bookmarkHttpTask = Task.Run<List<tenderBookmark>>(() => retrieveBookmark()); List <tenderBookmark> tenderBookmarks = await retrieveBookmark(); if (tenderBookmarks != null) { //List<tenderBookmark> tenderBookmarks = bookmarkHttpTask; if (tenderBookmarks.Count > 0) { foreach (var tenderItem in tenderItems) { foreach (var tenderBookmark in tenderBookmarks) { if (tenderItem.Reference == tenderBookmark.tenderReferenceNumber) { tenderItem.BookmarkImage = "bookmarkfilled.png"; break; } } } } } } listView.ItemsSource = tenderItems; //save all eligible tenders to database await saveToTenderDb(tenderItems, 0); pageTitle.IsVisible = true; activityIndicator.IsVisible = false; activityIndicator.IsRunning = false; //pageTitle.IsVisible = true; if (tenderItems.Count > 0) { upBtn.IsVisible = true; } await WaitAndExecuteUpdateTenders(10800000); } }