void OnCartTapped(object sender, EventArgs args)
        {
            var        tenderSelected = ((TappedEventArgs)args).Parameter;
            tenderItem tender         = (tenderItem)tenderSelected;

            DisplayAlert("Success", tender.AddToCartQuantity + " Item " + tender.Reference + " has been successfully added to cart ", "OK");
        }
Example #2
0
        async Task <List <tenderItem> > retrieveTenderFromDatabase(int page)
        {
            List <tenderItem>   tenderItems   = new List <tenderItem>();
            List <dbTenderItem> dbTenderItems = await Task.Run <List <dbTenderItem> >(() => App.Database.getTendersAsync(page));

            foreach (var item in dbTenderItems)
            {
                Dictionary <string, string> fileLinks = JsonConvert.DeserializeObject <Dictionary <string, string> >(item.FileLinks);
                tenderItem tenderitem = new tenderItem();
                tenderitem.Reference          = item.Reference;
                tenderitem.Title              = item.Title;
                tenderitem.OriginatingStation = item.OriginatingSource;
                tenderitem.ClosingDate        = item.ClosingDate;
                tenderitem.BidClosingDate     = item.BidClosingDate;
                tenderitem.FeeBeforeGST       = item.FeeBeforeGST;
                tenderitem.FeeAfterGST        = item.FeeAfterGST;
                tenderitem.FeeGST             = item.FeeGST;
                tenderitem.TendererClass      = item.TendererClass;
                tenderitem.Name              = item.Name;
                tenderitem.OffinePhone       = item.OffinePhone;
                tenderitem.Extension         = item.Extension;
                tenderitem.MobilePhone       = item.MobilePhone;
                tenderitem.Email             = item.Email;
                tenderitem.Fax               = item.Fax;
                tenderitem.FileLinks         = fileLinks;
                tenderitem.CheckedValue      = item.CheckedValue;
                tenderitem.AddToCartQuantity = item.AddToCartQuantity;
                tenderitem.BookmarkImage     = item.BookmarkImage;

                tenderItems.Add(tenderitem);
            }

            return(tenderItems);
        }
Example #3
0
        public static async Task <string> PostManageTenderBookmark(string username, tenderItem tender, string action)
        {
            string result = "";

            string tenderClosingDate = tender.ClosingDate;

            if (action != "delete")
            {
                //tenderClosingDate = tenderClosingDate.Replace("Closing date: ", "");
                if (tender.TenderSource == "0")
                {
                    tenderClosingDate = tenderClosingDate.Replace(" at ", " ");
                }
            }

            //default add tender bookmark action
            var parameters = new FormUrlEncodedContent(new[] {
                new KeyValuePair <string, string>("username", username),
                new KeyValuePair <string, string>("tenderReferenceNumber", tender.Reference),
                new KeyValuePair <string, string>("tenderTitle", tender.Title),
                new KeyValuePair <string, string>("originatingSource", tender.OriginatingStation),
                new KeyValuePair <string, string>("closingDate", tenderClosingDate)
            });

            if (action == "delete")
            {
                parameters = new FormUrlEncodedContent(new[] {
                    new KeyValuePair <string, string>("username", username),
                    new KeyValuePair <string, string>("tenderReferenceNumber", tender.Reference),
                    new KeyValuePair <string, string>("tenderTitle", tender.Reference),
                    new KeyValuePair <string, string>("isDelete", "1"),
                });
            }

            HttpClient httpClient = new HttpClient();

            try
            {
                var response = await httpClient.PostAsync("https://pockettender.000webhostapp.com/process_manageTenderBookmark.php", parameters);

                if (response.IsSuccessStatusCode)
                {
                    result = await response.Content.ReadAsStringAsync();
                }
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex);
            }

            return(result);
        }
Example #4
0
        async void onDeleteTapped(object sender, EventArgs args)
        {
            var            tenderSelected = ((TappedEventArgs)args).Parameter;
            tenderBookmark tenderBookmark = (tenderBookmark)tenderSelected;
            tenderItem     tender         = new tenderItem();

            tender.Reference = tenderBookmark.tenderReferenceNumber;
            List <tenderBookmark> tempBookmarkList = (List <tenderBookmark>)listView.ItemsSource;

            var answer = await DisplayAlert("Remove bookmark", "Are you sure you want to remove bookmark '" + tender.Reference + "'?", "YES", "NO");

            if (answer)
            {
                //remove bookmark from listview
                foreach (var bookmarkItem in tempBookmarkList.ToList())
                {
                    if (bookmarkItem == tenderBookmark)
                    {
                        int index = tempBookmarkList.IndexOf(bookmarkItem);
                        tempBookmarkList.Remove(bookmarkItem);
                    }
                }

                //Refresh listview
                listView.ItemsSource = tempBookmarkList.ToList();

                //Display error message when there are no bookmark
                if (tempBookmarkList.Count <= 0)
                {
                    errorMsg.Text      = "No bookmark found.";
                    errorMsg.IsVisible = true;
                    upBtn.IsVisible    = false;
                }

                //Remove bookmark from database
                string httpTask = await Task.Run <string>(() => HttpRequestHandler.PostManageTenderBookmark(userSession.username, tender, "delete"));

                var httpResult = httpTask.ToString();
                Console.WriteLine(httpResult);
                int count = 0;

                while (count < 3 && httpResult != "Success")
                {
                    Console.WriteLine("Looping for failure delete");
                    httpTask = await Task.Run <string>(() => HttpRequestHandler.PostManageTenderBookmark(userSession.username, tender, "delete"));

                    httpResult = httpTask.ToString();
                    count++;
                }
            }
        }
        void onQuantityChanged(object sender, EventArgs args)
        {
            var        entry  = sender as Entry;
            var        input  = entry.Text;
            tenderItem tender = (tenderItem)entry.BindingContext;

            Console.WriteLine(tender);
            if (tender != null)
            {
                ((tenderItem)entry.BindingContext).AddToCartQuantity = input;
            }
            else
            {
                Console.WriteLine("It's is null!");
            }
        }
        public tenderDetailPage(tenderItem aTenderItem)
        {
            InitializeComponent();

            string[] words       = Regex.Split(aTenderItem.ClosingDate, ": ");
            string   closingDate = words[1];

            tenderRefLbl.Text    = aTenderItem.Reference;
            tenderTitleLbl.Text  = aTenderItem.Title;
            oriStationLbl.Text   = aTenderItem.OriginatingStation;
            closingDateLbl.Text  = closingDate;
            bidCloseDateLbl.Text = aTenderItem.BidClosingDate;
            feeBeforeGSTLbl.Text = aTenderItem.FeeBeforeGST;
            feeGSTLbl.Text       = aTenderItem.FeeGST;
            feeAfterGSTLbl.Text  = aTenderItem.FeeAfterGST;
            nameLbl.Text         = aTenderItem.Name;
            officePhoneLbl.Text  = aTenderItem.OffinePhone;
            extensionLbl.Text    = aTenderItem.Extension;
            mobilePhoneLbl.Text  = aTenderItem.MobilePhone;
            emailLbl.Text        = aTenderItem.Email;
            faxLbl.Text          = aTenderItem.Fax;

            //Create hyperlink labels for downloadable files
            int currentGridRow = 32;

            foreach (KeyValuePair <string, string> file in aTenderItem.FileLinks)
            {
                Console.WriteLine("Key: " + file.Key);
                //create the hyperlink label
                var label = new Label {
                    Text = file.Key, TextColor = Color.DodgerBlue, Margin = new Thickness(0, 0, 0, 5)
                };
                var tapGestureRecognizer = new TapGestureRecognizer();
                tapGestureRecognizer.Tapped += (s, e) => { Device.OpenUri(new Uri(file.Value)); };
                label.GestureRecognizers.Add(tapGestureRecognizer);

                //add hyperlink label into grid
                displayGrid.RowDefinitions.Add(new RowDefinition {
                    Height = new GridLength(1, GridUnitType.Star)
                });

                displayGrid.Children.Add(label, 0, currentGridRow);
                Grid.SetColumnSpan(label, 2);
                currentGridRow++;
            }
        }
Example #7
0
        public static async Task <Object> getTenderPage(HtmlDocument htmlDocument)
        {
            var htmlNodes = htmlDocument.DocumentNode.SelectNodes("//tbody/tr");
            int rowCount  = 0;

            //List to store tender items
            List <tenderItem> tenderItems = new List <tenderItem>();

            //Loop through the tender items to get the tender details for each of the tenders
            foreach (var trNode in htmlNodes)
            {
                //If the row is not the first row, create the tender item
                if (rowCount > 0)
                {
                    //Get contact details of the tender
                    var tdNodes     = trNode.ChildNodes;
                    var tdNodeCount = tdNodes.Count;
                    int count       = 0;

                    tenderItem tender = new tenderItem();

                    foreach (var tdNode in tdNodes)
                    {
                        if (tdNodeCount > 3)
                        {
                            if (!String.IsNullOrWhiteSpace(tdNode.InnerHtml))
                            {
                                switch (count)
                                {
                                case 0:
                                    string aNodeString = tdNode.InnerHtml.Trim();
                                    var    htmlDoc     = new HtmlDocument();
                                    htmlDoc.LoadHtml(aNodeString);
                                    var aNode = htmlDoc.DocumentNode.SelectSingleNode("//a");

                                    tender.Reference = aNode.InnerHtml;
                                    break;

                                case 1:
                                    tender.Title = tdNode.FirstChild.InnerHtml;
                                    break;

                                case 2:
                                    tender.OriginatingStation = tdNode.InnerHtml;
                                    break;

                                case 3:
                                    tender.ClosingDate = "Closing date: " + tdNode.InnerHtml;
                                    break;

                                case 4:
                                    tender.BidClosingDate = tdNode.InnerHtml;
                                    break;

                                case 5:
                                    tender.FeeBeforeGST = tdNode.InnerHtml;
                                    break;

                                case 6:
                                    tender.FeeGST = tdNode.InnerHtml;
                                    break;

                                case 7:
                                    tender.FeeAfterGST = tdNode.InnerHtml;
                                    break;
                                }
                                count++;
                            }
                        }
                        else
                        {
                            if (!String.IsNullOrWhiteSpace(tdNode.InnerHtml))
                            {
                                tender.TendererClass = tdNode.InnerHtml;
                            }
                        }
                    }

                    if (tdNodeCount > 3)
                    {
                        //Get the ORIGINATOR details of the tender item
                        string url = "http://www2.sesco.com.my/etender/notice/notice_originator.jsp?Referno=" + WebUtility.UrlEncode(tender.Reference);

                        string httpTask = await Task.Run <string>(() => HttpRequestHandler.GetRequest(url, false));

                        var httpResult = httpTask.ToString();

                        var htmlDoc = new HtmlDocument();
                        htmlDoc.LoadHtml(httpResult);
                        var originatorTrNodes    = htmlDoc.DocumentNode.SelectNodes("//table/tr/td/table/tr");
                        int originatorTrRowCount = 0;

                        if (originatorTrNodes != null)
                        {
                            foreach (var originatorTrNode in originatorTrNodes)
                            {
                                var originatorTdNodes = originatorTrNode.ChildNodes;
                                foreach (var originatorTdNode in originatorTdNodes)
                                {
                                    if (!String.IsNullOrWhiteSpace(originatorTdNode.InnerHtml) && !originatorTdNode.FirstChild.HasChildNodes)
                                    {
                                        //The originator info starts on row 3, thus row 0,1,2 are skipped
                                        switch (originatorTrRowCount)
                                        {
                                        case 3:
                                            tender.Name = originatorTdNode.InnerHtml;
                                            break;

                                        case 4:
                                            tender.OffinePhone = originatorTdNode.InnerHtml;
                                            break;

                                        case 5:
                                            tender.Extension = originatorTdNode.InnerHtml;
                                            break;

                                        case 6:
                                            tender.MobilePhone = originatorTdNode.InnerHtml;
                                            break;

                                        case 7:
                                            tender.Email = originatorTdNode.InnerHtml;
                                            break;

                                        case 8:
                                            tender.Fax = originatorTdNode.InnerHtml;
                                            break;

                                        default:
                                            break;
                                        }
                                    }
                                }
                                originatorTrRowCount++;
                            }
                        }


                        //Get the downloadable files of the tender item
                        string url2 = "http://www2.sesco.com.my/etender/notice/notice_tender.jsp?Referno=" + WebUtility.UrlEncode(tender.Reference);

                        string httpTask2 = await Task.Run <string>(() => HttpRequestHandler.GetRequest(url2, false));

                        var httpResult2 = httpTask2.ToString();

                        var htmlDoc2 = new HtmlDocument();
                        htmlDoc2.LoadHtml(httpResult2);

                        var filesTdNodes = htmlDoc2.DocumentNode.SelectNodes("//table/tr/td");

                        if (filesTdNodes != null)
                        {
                            var fileLinkNodes = filesTdNodes.Elements("a");


                            foreach (var fileLinkNode in fileLinkNodes)
                            {
                                if (fileLinkNode.NodeType == HtmlNodeType.Element)
                                {
                                    string   fileName  = fileLinkNode.InnerHtml;
                                    string   fileLink  = fileLinkNode.Attributes["href"].Value;
                                    string[] linkSplit = Regex.Split(fileLink, "noticeDoc/");
                                    string   link      = "http://www2.sesco.com.my/noticeDoc/" + Uri.EscapeUriString(linkSplit[1]);
                                    tender.FileLinks[fileName] = link;
                                }
                            }
                        }

                        tenderItems.Add(tender);
                    }

                    rowCount++;
                }
                else
                {
                    rowCount++;
                }
            }

            return(tenderItems);
        }
Example #8
0
        private static async Task <Object> getEligibleTenderPage(HtmlDocument htmlDocument)
        {
            var divNodes       = htmlDocument.DocumentNode.SelectNodes("//td/div");
            int divCount       = 0;
            int childNodeCount = 0;

            //List to store tender items
            List <tenderItem> tenderItems = new List <tenderItem>();
            tenderItem        tender      = new tenderItem();

            foreach (var divNode in divNodes)
            {
                //the tender data starts at 11th div
                if (divCount > 10)
                {
                    //Get available tender details
                    foreach (var childNode in divNode.ChildNodes)
                    {
                        if (!String.IsNullOrWhiteSpace(childNode.InnerHtml))
                        {
                            if (!childNode.Attributes.Contains("href"))
                            {
                                switch (childNodeCount)
                                {
                                case 0:
                                    tender = new tenderItem();
                                    break;

                                case 1:
                                    tender.Reference = childNode.InnerHtml.Trim();
                                    break;

                                case 2:
                                    tender.Title = childNode.InnerHtml.Trim();
                                    break;

                                case 3:
                                    tender.TendererClass = "Tenderer class: " + childNode.InnerHtml.Trim();
                                    break;

                                case 4:
                                    tender.BidClosingDate = "Bid closes: " + childNode.InnerHtml.Trim();
                                    break;

                                case 5:
                                    tender.ClosingDate = "Closing date: " + childNode.InnerHtml.Trim();
                                    break;

                                case 6:
                                    tender.FeeBeforeGST = childNode.InnerHtml.Trim();

                                    break;
                                }
                                childNodeCount++;
                            }
                        }
                    }
                }
                if (childNodeCount == 7)
                {
                    tenderItems.Add(tender);
                    childNodeCount = 0;
                }
                divCount++;
            }

            //Get the checkedValue for the tender items
            var inputNodes = htmlDocument.DocumentNode.SelectNodes("//td/input");

            foreach (var inputNode in inputNodes)
            {
                string inputValue = inputNode.Attributes["value"].Value;
                if (inputValue != "1")
                {
                    //string[] inputValueWords = Regex.Split(inputValue, "|");
                    string[] inputValueWords = inputValue.Split('|');

                    foreach (var item in tenderItems)
                    {
                        if (inputValueWords[0].Trim() == item.Reference)
                        {
                            var index = tenderItems.IndexOf(item);
                            tenderItems[index].CheckedValue = inputValue;
                            //item.CheckedValue = inputValue;
                        }
                    }
                    //Console.WriteLine("Node: " + inputValue);
                }
            }

            return(tenderItems);
        }
Example #9
0
        async void retrieveBookmarkTenderDetails(tenderBookmark tenderBookmark)
        {
            int currentGridRow;

            activityIndicator.IsVisible = true;
            activityIndicator.IsRunning = true;

            //Get tender details
            string httpTask = await Task.Run <string>(() => HttpRequestHandler.PostGetBookmarkDetails(tenderBookmark.tenderReferenceNumber, tenderBookmark.tenderTitle));

            var httpResult = httpTask.ToString();

            //var htmlDoc = new HtmlDocument();
            //htmlDoc.LoadHtml(httpResult);

            //Extract tender data from the response
            //var tenders = await DataExtraction.getWebData(httpResult, "tender");
            if (httpResult != "Tender not found" && httpResult != "Missing parameter(s)")
            {
                scrapped_tender scrappedTender = JsonConvert.DeserializeObject <scrapped_tender>(httpResult);
                tenderItem      aTenderItem    = new tenderItem();

                //Copying tender details from scrapped_tender object to tender item object
                aTenderItem.Company            = scrappedTender.originatingSource;
                aTenderItem.TenderSource       = scrappedTender.tenderSource;
                aTenderItem.Reference          = scrappedTender.reference;
                aTenderItem.Agency             = scrappedTender.agency;
                aTenderItem.Title              = scrappedTender.title;
                aTenderItem.Category           = scrappedTender.category;
                aTenderItem.OriginatingStation = scrappedTender.originatingSource;
                aTenderItem.ClosingDate        = scrappedTender.closingDate;

                if (scrappedTender.docInfoJson != null)
                {
                    dynamic docInfo = JsonConvert.DeserializeObject(scrappedTender.docInfoJson);
                    if (docInfo.bidCloseDate != null)
                    {
                        aTenderItem.BidClosingDate = docInfo.bidCloseDate;
                    }

                    if (docInfo.feeBeforeGST != null)
                    {
                        aTenderItem.FeeBeforeGST = docInfo.feeBeforeGST;
                    }

                    if (docInfo.feeGST != null)
                    {
                        aTenderItem.FeeGST = docInfo.feeGST;
                    }

                    if (docInfo.feeAfterGST != null)
                    {
                        aTenderItem.FeeAfterGST = docInfo.feeAfterGST;
                    }
                }

                if (scrappedTender.originatorJson != null)
                {
                    dynamic originatorInfo = JsonConvert.DeserializeObject(scrappedTender.originatorJson);
                    if (originatorInfo.name != null)
                    {
                        aTenderItem.Name = originatorInfo.name;
                    }

                    if (originatorInfo.officePhone != null)
                    {
                        aTenderItem.OffinePhone = originatorInfo.officePhone;
                    }

                    if (originatorInfo.extension != null)
                    {
                        aTenderItem.Extension = originatorInfo.extension;
                    }

                    if (originatorInfo.mobilePhone != null)
                    {
                        aTenderItem.MobilePhone = originatorInfo.mobilePhone;
                    }

                    if (originatorInfo.email != null)
                    {
                        aTenderItem.Email = originatorInfo.email;
                    }

                    if (originatorInfo.fax != null)
                    {
                        aTenderItem.Fax = originatorInfo.fax;
                    }
                }

                if (scrappedTender.fileLinks != null)
                {
                    Dictionary <string, string> fileLinks = JsonConvert.DeserializeObject <Dictionary <string, string> >(scrappedTender.fileLinks);
                    aTenderItem.FileLinks = fileLinks;
                    //{"Folder 1.zip":"http:\/\/www2.sesco.com.my\/noticeDoc\/Folder 1.zip","Folder 2.zip":"http:\/\/www2.sesco.com.my\/noticeDoc\/Folder 2.zip","Folder 3.zip":"http:\/\/www2.sesco.com.my\/noticeDoc\/Folder 3.zip","Folder 4.zip":"http:\/\/www2.sesco.com.my\/noticeDoc\/Folder 4.zip"}
                }
                //List<tenderItem> tenderItems = (List<tenderItem>)tenders;

                activityIndicator.IsVisible = false;
                activityIndicator.IsRunning = false;

                //if (tenderItems.Count > 0)
                if (aTenderItem != null)
                {
                    tenderRefLbl.Text    = aTenderItem.Reference;
                    tenderTitleLbl.Text  = aTenderItem.Title;
                    oriStationLbl.Text   = aTenderItem.OriginatingStation;
                    closingDateLbl.Text  = aTenderItem.ClosingDate;
                    bidCloseDateLbl.Text = aTenderItem.BidClosingDate;
                    feeBeforeGSTLbl.Text = aTenderItem.FeeBeforeGST;
                    feeGSTLbl.Text       = aTenderItem.FeeGST;
                    feeAfterGSTLbl.Text  = aTenderItem.FeeAfterGST;

                    if (aTenderItem.Company == "Sarawak Energy")
                    {
                        nameLbl.Text        = aTenderItem.Name;
                        officePhoneLbl.Text = aTenderItem.OffinePhone;
                        extensionLbl.Text   = aTenderItem.Extension;
                        mobilePhoneLbl.Text = aTenderItem.MobilePhone;
                        emailLbl.Text       = aTenderItem.Email;
                        faxLbl.Text         = aTenderItem.Fax;
                    }
                    else
                    {
                        displayGrid.Children.Remove(bidCloseDateTitleLbl);
                        displayGrid.Children.Remove(bidCloseLayout);
                        displayGrid.Children.Remove(boxView11);
                        displayGrid.Children.Remove(docFeeTitleLbl);
                        displayGrid.Children.Remove(feeBeforeGSTLbl);
                        displayGrid.Children.Remove(boxView13);
                        displayGrid.Children.Remove(gstTitleLbl);
                        displayGrid.Children.Remove(feeGSTLbl);
                        displayGrid.Children.Remove(boxView15);
                        displayGrid.Children.Remove(feeAfterGSTTitleLbl);
                        displayGrid.Children.Remove(feeAfterGSTLbl);
                        displayGrid.Children.Remove(boxView17);

                        displayGrid.Children.Remove(originatorTitleLbl);
                        displayGrid.Children.Remove(nameTitleLbl);
                        displayGrid.Children.Remove(offPhoneTitleLbl);
                        displayGrid.Children.Remove(extTitleLbl);
                        displayGrid.Children.Remove(mobPhoneTitleLbl);
                        displayGrid.Children.Remove(emailTitleLbl);
                        displayGrid.Children.Remove(faxTitleLbl);

                        displayGrid.Children.Remove(nameLbl);
                        displayGrid.Children.Remove(officePhoneLbl);
                        displayGrid.Children.Remove(extensionLbl);
                        displayGrid.Children.Remove(mobilePhoneLbl);
                        //displayGrid.Children.Remove(emailLbl);
                        displayGrid.Children.Remove(emailLayout);
                        displayGrid.Children.Remove(faxLbl);

                        displayGrid.Children.Remove(boxView20);
                        displayGrid.Children.Remove(boxView22);
                        displayGrid.Children.Remove(boxView24);
                        displayGrid.Children.Remove(boxView26);
                        displayGrid.Children.Remove(boxView28);
                        displayGrid.Children.Remove(boxView30);

                        for (int i = 0; i < 21; i++)
                        {
                            displayGrid.RowDefinitions.RemoveAt(displayGrid.RowDefinitions.Count() - 1);
                        }
                    }

                    Console.WriteLine("Tender source is : " + aTenderItem.TenderSource);
                    if (aTenderItem.TenderSource == "1")
                    {
                        //If tender is from myProcurement, display its category and agency
                        currentGridRow = displayGrid.RowDefinitions.Count();

                        //Create labels for category and add into the grid
                        var categoryLabel = new Label {
                            Text = "Category: ", Margin = new Thickness(0, 5, 0, 0), FontAttributes = FontAttributes.Bold
                        };
                        var categoryDataLabel = new Label {
                            Text = aTenderItem.Category, Margin = new Thickness(0, 5, 0, 0)
                        };
                        displayGrid.RowDefinitions.Add(new RowDefinition {
                            Height = new GridLength(1, GridUnitType.Auto)
                        });
                        displayGrid.Children.Add(categoryLabel, 0, currentGridRow);
                        displayGrid.Children.Add(categoryDataLabel, 1, currentGridRow);
                        currentGridRow++;

                        //Create boxView as separator
                        var categoryBoxView = new BoxView {
                            BackgroundColor = Color.LightGray, HeightRequest = 1, Margin = new Thickness(0, 5, 0, 0), VerticalOptions = LayoutOptions.End, HorizontalOptions = LayoutOptions.FillAndExpand
                        };
                        displayGrid.RowDefinitions.Add(new RowDefinition {
                            Height = new GridLength(1, GridUnitType.Auto)
                        });
                        displayGrid.Children.Add(categoryBoxView, 0, currentGridRow);
                        Grid.SetColumnSpan(categoryBoxView, 2);
                        currentGridRow++;

                        //Create labels for agency and add into the grid
                        var agencyLabel = new Label {
                            Text = "Agency: ", Margin = new Thickness(0, 5, 0, 0), FontAttributes = FontAttributes.Bold
                        };
                        var agencyLayout = new StackLayout {
                            Margin = new Thickness(0, 5, 0, 0)
                        };
                        var agencyDataLabel = new Label {
                            Text = aTenderItem.Agency
                        };
                        agencyLayout.Children.Add(agencyDataLabel);

                        displayGrid.RowDefinitions.Add(new RowDefinition {
                            Height = new GridLength(1, GridUnitType.Auto)
                        });
                        displayGrid.Children.Add(agencyLabel, 0, currentGridRow);
                        displayGrid.Children.Add(agencyLayout, 1, currentGridRow);
                        currentGridRow++;

                        //Create boxView as separator
                        var agencyBoxView = new BoxView {
                            BackgroundColor = Color.LightGray, HeightRequest = 1, Margin = new Thickness(0, 5, 0, 0), VerticalOptions = LayoutOptions.End, HorizontalOptions = LayoutOptions.FillAndExpand
                        };
                        displayGrid.RowDefinitions.Add(new RowDefinition {
                            Height = new GridLength(1, GridUnitType.Auto)
                        });
                        displayGrid.Children.Add(agencyBoxView, 0, currentGridRow);
                        Grid.SetColumnSpan(agencyBoxView, 2);
                    }

                    //Create hyperlink labels for downloadable files
                    if (aTenderItem.FileLinks != null)
                    {
                        if (aTenderItem.FileLinks.Count > 0)
                        {
                            currentGridRow = displayGrid.RowDefinitions.Count();
                            Console.WriteLine("Current grid row : " + currentGridRow);
                            //<Label Text="Downloadable Files: " x:Name="downloadLbl" Grid.Row="31" Grid.Column="0" FontSize="16" Grid.ColumnSpan="2" FontAttributes="Bold" Margin="0,20,0,10"/>
                            var downloadLabel = new Label {
                                Text = "Downloadable Files: ", Margin = new Thickness(0, 20, 0, 10), FontSize = 16, FontAttributes = FontAttributes.Bold
                            };
                            displayGrid.RowDefinitions.Add(new RowDefinition {
                                Height = new GridLength(1, GridUnitType.Auto)
                            });
                            displayGrid.Children.Add(downloadLabel, 0, currentGridRow);
                            Grid.SetColumnSpan(downloadLabel, 2);
                            currentGridRow++;
                            foreach (KeyValuePair <string, string> file in aTenderItem.FileLinks)
                            {
                                Console.WriteLine("Key: " + file.Key + "row: " + currentGridRow);
                                //create the hyperlink label
                                var label = new Label {
                                    Text = file.Key, TextColor = Color.DodgerBlue, Margin = new Thickness(0, 0, 0, 5)
                                };
                                var tapGestureRecognizer = new TapGestureRecognizer();
                                tapGestureRecognizer.Tapped += (s, e) => { Device.OpenUri(new Uri(file.Value)); };
                                label.GestureRecognizers.Add(tapGestureRecognizer);

                                //add hyperlink label into grid
                                displayGrid.RowDefinitions.Add(new RowDefinition {
                                    Height = new GridLength(1, GridUnitType.Auto)
                                });

                                displayGrid.Children.Add(label, 0, currentGridRow);
                                Grid.SetColumnSpan(label, 2);
                                currentGridRow++;
                            }
                        }
                    }
                }
                else
                {
                    await DisplayAlert("Not found", "Tender '" + tenderBookmark.tenderReferenceNumber + "' is not available!", "OK");

                    var page = App.Current.MainPage as rootPage;
                    var tenderBookmarkPage = new tenderBookmarkPage();
                    page.changePage(tenderBookmarkPage);
                }
            }
            else
            {
                if (httpResult == "Tender not found")
                {
                    await DisplayAlert("Tender Not found", "Tender '" + tenderBookmark.tenderReferenceNumber + "' is not available!", "OK");

                    var page = App.Current.MainPage as rootPage;
                    var tenderBookmarkPage = new tenderBookmarkPage();
                    page.changePage(tenderBookmarkPage);
                }
                else
                {
                    await DisplayAlert("Failed", httpResult.ToString(), "OK");

                    var page = App.Current.MainPage as rootPage;
                    var tenderBookmarkPage = new tenderBookmarkPage();
                    page.changePage(tenderBookmarkPage);
                }
            }
        }
Example #10
0
        public tenderDetailPage(tenderItem aTenderItem)
        {
            BindingContext = this;

            InitializeComponent();
            int currentGridRow;

            /*string closingDate = "";
             * if (aTenderItem.Company == "Sarawak Energy")
             * {
             *  isOriginatorInfoPresent = true;
             *  string[] words = Regex.Split(aTenderItem.ClosingDate, ": ");
             *  closingDate = words[1];
             * }*/
            Console.WriteLine("Tender source is from: " + aTenderItem.TenderSource);
            tenderRefLbl.Text    = aTenderItem.Reference;
            tenderTitleLbl.Text  = aTenderItem.Title;
            oriStationLbl.Text   = aTenderItem.OriginatingStation;
            closingDateLbl.Text  = aTenderItem.ClosingDate;
            bidCloseDateLbl.Text = aTenderItem.BidClosingDate;
            feeBeforeGSTLbl.Text = aTenderItem.FeeBeforeGST;
            feeGSTLbl.Text       = aTenderItem.FeeGST;
            feeAfterGSTLbl.Text  = aTenderItem.FeeAfterGST;

            string[] originatingSource = aTenderItem.OriginatingStation.Split();
            string   tempStr           = "";

            if (originatingSource.Count() > 2)
            {
                tempStr = originatingSource[0] + " " + originatingSource[1];
            }
            if (tempStr == "Sarawak Energy")
            {
                nameLbl.Text        = aTenderItem.Name;
                officePhoneLbl.Text = aTenderItem.OffinePhone;
                extensionLbl.Text   = aTenderItem.Extension;
                mobilePhoneLbl.Text = aTenderItem.MobilePhone;
                emailLbl.Text       = aTenderItem.Email;
                faxLbl.Text         = aTenderItem.Fax;
            }
            else
            {
                displayGrid.Children.Remove(bidCloseDateTitleLbl);
                displayGrid.Children.Remove(bidCloseLayout);
                displayGrid.Children.Remove(boxView11);
                displayGrid.Children.Remove(docFeeTitleLbl);
                displayGrid.Children.Remove(feeBeforeGSTLbl);
                displayGrid.Children.Remove(boxView13);
                displayGrid.Children.Remove(gstTitleLbl);
                displayGrid.Children.Remove(feeGSTLbl);
                displayGrid.Children.Remove(boxView15);
                displayGrid.Children.Remove(feeAfterGSTTitleLbl);
                displayGrid.Children.Remove(feeAfterGSTLbl);
                displayGrid.Children.Remove(boxView17);

                displayGrid.Children.Remove(originatorTitleLbl);
                displayGrid.Children.Remove(nameTitleLbl);
                displayGrid.Children.Remove(offPhoneTitleLbl);
                displayGrid.Children.Remove(extTitleLbl);
                displayGrid.Children.Remove(mobPhoneTitleLbl);
                displayGrid.Children.Remove(emailTitleLbl);
                displayGrid.Children.Remove(faxTitleLbl);

                displayGrid.Children.Remove(nameLbl);
                displayGrid.Children.Remove(officePhoneLbl);
                displayGrid.Children.Remove(extensionLbl);
                displayGrid.Children.Remove(mobilePhoneLbl);
                //displayGrid.Children.Remove(emailLbl);
                displayGrid.Children.Remove(emailLayout);
                displayGrid.Children.Remove(faxLbl);

                displayGrid.Children.Remove(boxView20);
                displayGrid.Children.Remove(boxView22);
                displayGrid.Children.Remove(boxView24);
                displayGrid.Children.Remove(boxView26);
                displayGrid.Children.Remove(boxView28);
                displayGrid.Children.Remove(boxView30);

                for (int i = 0; i < 21; i++)
                {
                    displayGrid.RowDefinitions.RemoveAt(displayGrid.RowDefinitions.Count() - 1);
                }
            }

            Console.WriteLine("Tender source is : " + aTenderItem.TenderSource);
            if (aTenderItem.TenderSource == "1")
            {
                //If tender is from myProcurement, display its category and agency
                currentGridRow = displayGrid.RowDefinitions.Count();

                //Create labels for category and add into the grid
                var categoryLabel = new Label {
                    Text = "Category: ", Margin = new Thickness(0, 5, 0, 0), FontAttributes = FontAttributes.Bold
                };
                var categoryDataLabel = new Label {
                    Text = aTenderItem.Category, Margin = new Thickness(0, 5, 0, 0)
                };
                displayGrid.RowDefinitions.Add(new RowDefinition {
                    Height = new GridLength(1, GridUnitType.Auto)
                });
                displayGrid.Children.Add(categoryLabel, 0, currentGridRow);
                displayGrid.Children.Add(categoryDataLabel, 1, currentGridRow);
                currentGridRow++;

                //Create boxView as separator
                var categoryBoxView = new BoxView {
                    BackgroundColor = Color.LightGray, HeightRequest = 1, Margin = new Thickness(0, 5, 0, 0), VerticalOptions = LayoutOptions.End, HorizontalOptions = LayoutOptions.FillAndExpand
                };
                displayGrid.RowDefinitions.Add(new RowDefinition {
                    Height = new GridLength(1, GridUnitType.Auto)
                });
                displayGrid.Children.Add(categoryBoxView, 0, currentGridRow);
                Grid.SetColumnSpan(categoryBoxView, 2);
                currentGridRow++;

                //Create labels for agency and add into the grid
                var agencyLabel = new Label {
                    Text = "Agency: ", Margin = new Thickness(0, 5, 0, 0), FontAttributes = FontAttributes.Bold
                };
                var agencyLayout = new StackLayout {
                    Margin = new Thickness(0, 5, 0, 0)
                };
                var agencyDataLabel = new Label {
                    Text = aTenderItem.Agency
                };
                agencyLayout.Children.Add(agencyDataLabel);

                displayGrid.RowDefinitions.Add(new RowDefinition {
                    Height = new GridLength(1, GridUnitType.Auto)
                });
                displayGrid.Children.Add(agencyLabel, 0, currentGridRow);
                displayGrid.Children.Add(agencyLayout, 1, currentGridRow);
                currentGridRow++;

                //Create boxView as separator
                var agencyBoxView = new BoxView {
                    BackgroundColor = Color.LightGray, HeightRequest = 1, Margin = new Thickness(0, 5, 0, 0), VerticalOptions = LayoutOptions.End, HorizontalOptions = LayoutOptions.FillAndExpand
                };
                displayGrid.RowDefinitions.Add(new RowDefinition {
                    Height = new GridLength(1, GridUnitType.Auto)
                });
                displayGrid.Children.Add(agencyBoxView, 0, currentGridRow);
                Grid.SetColumnSpan(agencyBoxView, 2);
            }

            //Create hyperlink labels for downloadable files
            if (aTenderItem.FileLinks.Count > 0)
            {
                currentGridRow = displayGrid.RowDefinitions.Count();
                Console.WriteLine("Current grid row : " + currentGridRow);
                //<Label Text="Downloadable Files: " x:Name="downloadLbl" Grid.Row="31" Grid.Column="0" FontSize="16" Grid.ColumnSpan="2" FontAttributes="Bold" Margin="0,20,0,10"/>
                var downloadLabel = new Label {
                    Text = "Downloadable Files: ", Margin = new Thickness(0, 20, 0, 10), FontSize = 16, FontAttributes = FontAttributes.Bold
                };
                displayGrid.RowDefinitions.Add(new RowDefinition {
                    Height = new GridLength(1, GridUnitType.Auto)
                });
                displayGrid.Children.Add(downloadLabel, 0, currentGridRow);
                Grid.SetColumnSpan(downloadLabel, 2);
                currentGridRow++;
                foreach (KeyValuePair <string, string> file in aTenderItem.FileLinks)
                {
                    Console.WriteLine("Key: " + file.Key + "row: " + currentGridRow);
                    //create the hyperlink label
                    var label = new Label {
                        Text = file.Key, TextColor = Color.DodgerBlue, Margin = new Thickness(0, 0, 0, 5)
                    };
                    var tapGestureRecognizer = new TapGestureRecognizer();
                    tapGestureRecognizer.Tapped += (s, e) => { Device.OpenUri(new Uri(file.Value)); };
                    label.GestureRecognizers.Add(tapGestureRecognizer);

                    //add hyperlink label into grid
                    displayGrid.RowDefinitions.Add(new RowDefinition {
                        Height = new GridLength(1, GridUnitType.Auto)
                    });

                    displayGrid.Children.Add(label, 0, currentGridRow);
                    Grid.SetColumnSpan(label, 2);
                    currentGridRow++;
                }
            }
        }
Example #11
0
        public static async Task <Object> getTelekomTender(HtmlDocument htmlDocument)
        {
            var htmlNodes = htmlDocument.DocumentNode.SelectNodes("//table");
            int count     = 0;

            //List to store tender items
            List <tenderItem> tenderItems     = new List <tenderItem>();
            DateTime          currentDateTime = DateTime.Now;

            //Loop through the table nodes to get the list of tenders
            foreach (HtmlNode node in htmlNodes)
            {
                //Console.WriteLine("Node html nodes runned");
                if (count != 0)
                {
                    int    nodeCount   = 0;
                    string tenderMonth = node.ParentNode.PreviousSibling.InnerHtml;
                    string lastMonth   = currentDateTime.AddMonths(-1).ToString("MMMM").ToLower();
                    //Only display the tenders published in current month
                    if (currentDateTime.ToString("MMMM").ToLower() == tenderMonth.ToLower() || lastMonth == tenderMonth.ToLower())
                    {
                        //Loop through the tr nodes in the table node
                        foreach (var trNode in node.ChildNodes)
                        {
                            if (!String.IsNullOrWhiteSpace(trNode.OuterHtml))
                            {
                                //Skip 0 as the first tr node is the title of the list
                                if (nodeCount != 0)
                                {
                                    int        tdCount = 0;
                                    tenderItem tender  = new tenderItem();
                                    tender.OriginatingStation = "Telekom";
                                    foreach (var tdNode in trNode.ChildNodes)
                                    {
                                        if (!String.IsNullOrWhiteSpace(tdNode.InnerHtml))
                                        {
                                            switch (tdCount)
                                            {
                                            case 0:
                                                //Console.WriteLine("Date: " + tdNode.InnerHtml);
                                                break;

                                            case 1:
                                                tender.Title = tdNode.InnerHtml;
                                                //Console.WriteLine("Tender Title: " + tdNode.InnerHtml);
                                                break;

                                            case 2:
                                                foreach (var childNode in tdNode.ChildNodes)
                                                {
                                                    if (!String.IsNullOrWhiteSpace(childNode.InnerHtml))
                                                    {
                                                        if (childNode.Attributes["href"] != null)
                                                        {
                                                            string fileName = childNode.InnerHtml.Trim();
                                                            string link     = childNode.Attributes["href"].Value;
                                                            tender.FileLinks[fileName] = childNode.Attributes["href"].Value;
                                                            //Console.WriteLine("Link: " + childNode.Attributes["href"].Value);
                                                            //Console.WriteLine("Link Name: " + childNode.InnerHtml.Trim());
                                                        }
                                                    }
                                                }
                                                break;
                                            }
                                            tdCount++;
                                        }
                                    }
                                    tender.Company = "Telekom";
                                    tenderItems.Add(tender);
                                }
                                nodeCount++;
                            }
                        }
                    }
                }
                count++;
            }

            return(tenderItems);
        }
Example #12
0
        /*void OnCartTapped(object sender, EventArgs args)
         * {
         *  var tenderSelected = ((TappedEventArgs)args).Parameter;
         *  tenderItem tender = (tenderItem)tenderSelected;
         *
         *  DisplayAlert("Success", tender.AddToCartQuantity + " Item " + tender.Reference + " has been successfully added to cart ", "OK");
         * }*/

        async void OnBookmarkTapped(object sender, EventArgs eventArgs)
        {
            //check if user is logged in
            if (userSession.userLoginCookie == "")
            {
                DisplayAlert("Login required", "Please login first to bookmark this item.", "OK");
            }
            else
            {
                var        tenderSelected = ((TappedEventArgs)eventArgs).Parameter;
                tenderItem tender         = (tenderItem)tenderSelected;
                //var image = sender as Image;
                Console.WriteLine("Image now is: " + ((Image)sender).Source.ToString());

                if (((Image)sender).Source.ToString() == "File: bookmarkfilled.png")
                {
                    ((Image)sender).Source = "bookmark.png";
                    DisplayAlert("Cancel bookmark", "Tender '" + tender.Reference + "' has been removed from bookmark!", "OK");

                    string httpTask = await Task.Run <string>(() => HttpRequestHandler.PostManageTenderBookmark(userSession.username, tender, "delete"));

                    var httpResult = httpTask.ToString();
                    Console.WriteLine(httpResult);
                    int count = 0;

                    while (count < 3 && httpResult != "Success")
                    {
                        Console.WriteLine("Looping for failure delete");
                        httpTask = await Task.Run <string>(() => HttpRequestHandler.PostManageTenderBookmark(userSession.username, tender, "delete"));

                        httpResult = httpTask.ToString();
                        count++;
                    }
                }
                else
                {
                    ((Image)sender).Source = "bookmarkfilled.png";
                    DisplayAlert("Add bookmark", "Tender '" + tender.Reference + "' has been successfully added to bookmark!", "OK");

                    string httpTask = await Task.Run <string>(() => HttpRequestHandler.PostManageTenderBookmark(userSession.username, tender, "add"));

                    var httpResult = httpTask.ToString();
                    Console.WriteLine(httpResult);
                    int count = 0;

                    while (count < 3 && httpResult != "Success")
                    {
                        Console.WriteLine("Looping for failure add");
                        httpTask = await Task.Run <string>(() => HttpRequestHandler.PostManageTenderBookmark(userSession.username, tender, "add"));

                        httpResult = httpTask.ToString();
                        count++;
                    }
                }
            }


            //Display tender list with or without bookmark

            //send request to database everyone user tap on bookmark
        }
Example #13
0
        async void displayNormalSearch(string httpTaskResult)
        {
            activityIndicator.IsVisible = true;
            activityIndicator.IsRunning = true;

            List <scrapped_tender> scrappedTenders = new List <scrapped_tender>();
            List <tenderItem>      tenderItems     = new List <tenderItem>();

            scrappedTenders = JsonConvert.DeserializeObject <List <scrapped_tender> >(httpTaskResult);
            foreach (scrapped_tender scrappedTender in scrappedTenders)
            {
                tenderItem tender = new tenderItem();
                tender.Company            = scrappedTender.originatingSource;
                tender.TenderSource       = scrappedTender.tenderSource;
                tender.Reference          = scrappedTender.reference;
                tender.Agency             = scrappedTender.agency;
                tender.Title              = scrappedTender.title;
                tender.Category           = scrappedTender.category;
                tender.OriginatingStation = scrappedTender.originatingSource;
                tender.ClosingDate        = scrappedTender.closingDate;

                if (scrappedTender.docInfoJson != null)
                {
                    dynamic docInfo = JsonConvert.DeserializeObject(scrappedTender.docInfoJson);
                    if (docInfo.bidCloseDate != null)
                    {
                        tender.BidClosingDate = docInfo.bidCloseDate;
                    }

                    if (docInfo.feeBeforeGST != null)
                    {
                        tender.FeeBeforeGST = docInfo.feeBeforeGST;
                    }

                    if (docInfo.feeGST != null)
                    {
                        tender.FeeGST = docInfo.feeGST;
                    }

                    if (docInfo.feeAfterGST != null)
                    {
                        tender.FeeAfterGST = docInfo.feeAfterGST;
                    }
                }

                if (scrappedTender.originatorJson != null)
                {
                    dynamic originatorInfo = JsonConvert.DeserializeObject(scrappedTender.originatorJson);
                    if (originatorInfo != null)
                    {
                        if (originatorInfo.name != null)
                        {
                            tender.Name = originatorInfo.name;
                        }

                        if (originatorInfo.officePhone != null)
                        {
                            tender.OffinePhone = originatorInfo.officePhone;
                        }

                        if (originatorInfo.extension != null)
                        {
                            tender.Extension = originatorInfo.extension;
                        }

                        if (originatorInfo.mobilePhone != null)
                        {
                            tender.MobilePhone = originatorInfo.mobilePhone;
                        }

                        if (originatorInfo.email != null)
                        {
                            tender.Email = originatorInfo.email;
                        }

                        if (originatorInfo.fax != null)
                        {
                            tender.Fax = originatorInfo.fax;
                        }
                    }
                }

                if (scrappedTender.fileLinks != null)
                {
                    Dictionary <string, string> fileLinks = JsonConvert.DeserializeObject <Dictionary <string, string> >(scrappedTender.fileLinks);
                    tender.FileLinks = fileLinks;
                    //{"Folder 1.zip":"http:\/\/www2.sesco.com.my\/noticeDoc\/Folder 1.zip","Folder 2.zip":"http:\/\/www2.sesco.com.my\/noticeDoc\/Folder 2.zip","Folder 3.zip":"http:\/\/www2.sesco.com.my\/noticeDoc\/Folder 3.zip","Folder 4.zip":"http:\/\/www2.sesco.com.my\/noticeDoc\/Folder 4.zip"}
                }
                tenderItems.Add(tender);
            }

            if (userSession.username != "")
            {
                List <tenderBookmark> bookmarkHttpTask = await Task.Run <List <tenderBookmark> >(() => retrieveBookmark());

                List <tenderBookmark> tenderBookmarks = bookmarkHttpTask.ToList();
                if (tenderBookmarks.Count > 0)
                {
                    foreach (var tenderItem in tenderItems)
                    {
                        foreach (var tenderBookmark in tenderBookmarks)
                        {
                            if (tenderItem.Reference != "" && tenderItem.Reference != null)
                            {
                                if (tenderItem.Reference == tenderBookmark.tenderReferenceNumber)
                                {
                                    tenderItem.BookmarkImage = "bookmarkfilled.png";
                                    break;
                                }
                            }
                            else
                            {
                                if (tenderItem.Title == tenderBookmark.tenderTitle)
                                {
                                    tenderItem.BookmarkImage = "bookmarkfilled.png";
                                    break;
                                }
                            }
                        }
                    }
                }
            }

            pageTitle.IsVisible         = true;
            activityIndicator.IsVisible = false;
            activityIndicator.IsRunning = false;
            if (tenderItems.Count > 0)
            {
                upBtn.IsVisible = true;
            }
            else
            {
                errorMsg.IsVisible = true;
            }

            listView.ItemsSource         = tenderItems;
            listView.SeparatorVisibility = SeparatorVisibility.None;
            listView.ItemSelected       += onItemSelected;
        }
Example #14
0
        async void displayKeywordResult(List <dbTenderItem> dbTenderItems)
        {
            activityIndicator.IsVisible = true;
            activityIndicator.IsRunning = true;

            List <tenderItem> tenderItems = new List <tenderItem>();

            foreach (var item in dbTenderItems)
            {
                Dictionary <string, string> fileLinks = JsonConvert.DeserializeObject <Dictionary <string, string> >(item.FileLinks);
                tenderItem tenderitem = new tenderItem();
                tenderitem.Company            = item.Company;
                tenderitem.Reference          = item.Reference;
                tenderitem.TenderSource       = item.TenderSource;
                tenderitem.Category           = item.Category;
                tenderitem.Agency             = item.Agency;
                tenderitem.Title              = item.Title;
                tenderitem.OriginatingStation = item.OriginatingSource;
                tenderitem.ClosingDate        = item.ClosingDate;
                tenderitem.BidClosingDate     = item.BidClosingDate;
                tenderitem.FeeBeforeGST       = item.FeeBeforeGST;
                tenderitem.FeeAfterGST        = item.FeeAfterGST;
                tenderitem.FeeGST             = item.FeeGST;
                tenderitem.TendererClass      = item.TendererClass;
                tenderitem.Name              = item.Name;
                tenderitem.OffinePhone       = item.OffinePhone;
                tenderitem.Extension         = item.Extension;
                tenderitem.MobilePhone       = item.MobilePhone;
                tenderitem.Email             = item.Email;
                tenderitem.Fax               = item.Fax;
                tenderitem.FileLinks         = fileLinks;
                tenderitem.CheckedValue      = item.CheckedValue;
                tenderitem.AddToCartQuantity = item.AddToCartQuantity;
                tenderitem.BookmarkImage     = item.BookmarkImage;

                tenderItems.Add(tenderitem);
            }

            //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;
                                }
                            }
                        }
                    }
                }
            }

            pageTitle.IsVisible         = true;
            activityIndicator.IsVisible = false;
            activityIndicator.IsRunning = false;
            if (tenderItems.Count > 0)
            {
                upBtn.IsVisible = true;
            }
            else
            {
                errorMsg.IsVisible = true;
            }

            listView.ItemsSource         = tenderItems;
            listView.SeparatorVisibility = SeparatorVisibility.None;
            listView.ItemSelected       += onItemSelected;
        }
Example #15
0
        public async void retrieveAndDisplayFirstPageTenders()
        {
            activityIndicator.IsRunning = true;
            activityIndicator.IsVisible = true;

            //Retrieve originating sources from server
            string origSourceHttpTask = await Task.Run <string>(() => HttpRequestHandler.PostRetrieveOrigSources());

            while (origSourceHttpTask == null)
            {
                origSourceHttpTask = await Task.Run <string>(() => HttpRequestHandler.PostRetrieveOrigSources());
            }

            if (origSourceHttpTask != null)
            {
                if (origSourceHttpTask != "Originating sources not found")
                {
                    Console.WriteLine("HTTP TASK IS: " + origSourceHttpTask);
                    originatingSources = JsonConvert.DeserializeObject <List <string> >(origSourceHttpTask);
                    currentFilter      = originatingSources; //Default filter contain all sources
                }
            }

            //Show tenders from database first if exists, then clear database to make way for new tenders
            List <tenderItem> dbtenders1 = await Task.Run <List <tenderItem> >(() => retrieveTenderFromDatabase(1));

            //List<tenderItem> dbtenders2 = await Task.Run<List<tenderItem>>(() => retrieveTenderFromDatabase(2));
            if (dbtenders1.Count > 0)
            {
                if (userSession.username != "")
                {
                    List <tenderBookmark> bookmarkHttpTask = await Task.Run <List <tenderBookmark> >(() => retrieveBookmark());

                    List <tenderBookmark> tenderBookmarks = bookmarkHttpTask.ToList();
                    if (tenderBookmarks.Count > 0)
                    {
                        foreach (var tenderItem in dbtenders1)
                        {
                            foreach (var tenderBookmark in tenderBookmarks)
                            {
                                if (tenderItem.Reference != "" && tenderItem.Reference != null)
                                {
                                    if (tenderItem.Reference == tenderBookmark.tenderReferenceNumber)
                                    {
                                        tenderItem.BookmarkImage = "bookmarkfilled.png";
                                        break;
                                    }
                                }
                                else
                                {
                                    if (tenderItem.Title == tenderBookmark.tenderTitle)
                                    {
                                        tenderItem.BookmarkImage = "bookmarkfilled.png";
                                        break;
                                    }
                                }
                            }
                        }
                    }
                }
                tenderListing        = dbtenders1;
                listView.ItemsSource = dbtenders1;

                /*if (dbtenders2.Count > 0)
                 * {
                 *  nextPage.IsVisible = true;
                 * }*/
                filterButton.IsVisible      = true;
                sortButton.IsVisible        = true;
                activityIndicator.IsRunning = false;
                activityIndicator.IsVisible = false;
                await WaitAndExecuteUpdateTenders(10000);
            }
            else
            {
                //Sending HTTP request to obtain the SEB tender page data
                //string httpTask = await Task.Run<string>(() => getPageData("http://www2.sesco.com.my/etender/notice/notice.jsp"));
                //var httpResult = httpTask;

                //Extract tender data from the response
                //var tenders = await DataExtraction.getWebData(httpResult, "tender");

                //Retrieve Telekom tenders
                //string httpTaskTelekom = await Task.Run<string>(() => getPageData("https://www.tm.com.my/DoingBusinessWithTM/pages/notices.aspx?Year=2018"));
                //var httpResultTelekom = httpTaskTelekom;
                //Console.WriteLine("TELEKOM: " + httpTaskTelekom);
                //Extract tender data from the response
                //var tendersTelekom = await DataExtraction.getWebData(httpResultTelekom, "telekom");

                //List<tenderItem> tenderItems = (List<tenderItem>)tendersTelekom;
                //tenderItems.AddRange((List<tenderItem>)tenders);
                //Get bookmark details from online database

                List <scrapped_tender> scrappedTenders = new List <scrapped_tender>();
                List <tenderItem>      tenderItems     = new List <tenderItem>();
                //Retrieve tenders from server
                string url            = "https://pockettender.000webhostapp.com/process_getTenders.php";
                string httpTaskResult = await Task.Run <string>(() => HttpRequestHandler.GetRequest(url, false));

                if (httpTaskResult != null)
                {
                    if (httpTaskResult != "No tender found")
                    {
                        scrappedTenders = JsonConvert.DeserializeObject <List <scrapped_tender> >(httpTaskResult);

                        if (scrappedTenders != null)
                        {
                            Console.WriteLine("Number of scrapped tenders: " + scrappedTenders.Count);
                            //Convert scrapped tender item into tender item
                            foreach (scrapped_tender scrappedTender in scrappedTenders)
                            {
                                tenderItem tender = new tenderItem();
                                tender.Company            = scrappedTender.originatingSource;
                                tender.TenderSource       = scrappedTender.tenderSource;
                                tender.Reference          = scrappedTender.reference;
                                tender.Agency             = scrappedTender.agency;
                                tender.Title              = scrappedTender.title;
                                tender.Category           = scrappedTender.category;
                                tender.OriginatingStation = scrappedTender.originatingSource;
                                tender.ClosingDate        = scrappedTender.closingDate;

                                //{"bidCloseDate":"N\/A","feeBeforeGST":"RM 0.00","feeGST":"RM 0.00","feeAfterGST":"RM 0.00"}
                                //{ "name":"Francesca Lim","officePhone":"082-441188","extension":"1126","mobilePhone":null,"email":null,"fax":null}
                                //{"PMS106-14-Instruction.pdf":"http:\/\/www2.sesco.com.my\/noticeDoc\/PMS106-14-Instruction.pdf"}

                                if (scrappedTender.docInfoJson != null)
                                {
                                    dynamic docInfo = JsonConvert.DeserializeObject(scrappedTender.docInfoJson);
                                    if (docInfo != null)
                                    {
                                        if (docInfo.bidCloseDate != null)
                                        {
                                            tender.BidClosingDate = docInfo.bidCloseDate;
                                        }

                                        if (docInfo.feeBeforeGST != null)
                                        {
                                            tender.FeeBeforeGST = docInfo.feeBeforeGST;
                                        }

                                        if (docInfo.feeGST != null)
                                        {
                                            tender.FeeGST = docInfo.feeGST;
                                        }

                                        if (docInfo.feeAfterGST != null)
                                        {
                                            tender.FeeAfterGST = docInfo.feeAfterGST;
                                        }
                                    }
                                }

                                if (scrappedTender.originatorJson != null)
                                {
                                    dynamic originatorInfo = JsonConvert.DeserializeObject(scrappedTender.originatorJson);
                                    if (originatorInfo != null)
                                    {
                                        if (originatorInfo.name != null)
                                        {
                                            tender.Name = originatorInfo.name;
                                        }

                                        if (originatorInfo.officePhone != null)
                                        {
                                            tender.OffinePhone = originatorInfo.officePhone;
                                        }

                                        if (originatorInfo.extension != null)
                                        {
                                            tender.Extension = originatorInfo.extension;
                                        }

                                        if (originatorInfo.mobilePhone != null)
                                        {
                                            tender.MobilePhone = originatorInfo.mobilePhone;
                                        }

                                        if (originatorInfo.email != null)
                                        {
                                            tender.Email = originatorInfo.email;
                                        }

                                        if (originatorInfo.fax != null)
                                        {
                                            tender.Fax = originatorInfo.fax;
                                        }
                                    }
                                }

                                if (scrappedTender.fileLinks != null)
                                {
                                    Dictionary <string, string> fileLinks = JsonConvert.DeserializeObject <Dictionary <string, string> >(scrappedTender.fileLinks);
                                    tender.FileLinks = fileLinks;
                                    //{"Folder 1.zip":"http:\/\/www2.sesco.com.my\/noticeDoc\/Folder 1.zip","Folder 2.zip":"http:\/\/www2.sesco.com.my\/noticeDoc\/Folder 2.zip","Folder 3.zip":"http:\/\/www2.sesco.com.my\/noticeDoc\/Folder 3.zip","Folder 4.zip":"http:\/\/www2.sesco.com.my\/noticeDoc\/Folder 4.zip"}
                                }
                                tenderItems.Add(tender);
                            }
                        }

                        if (userSession.username != "")
                        {
                            List <tenderBookmark> bookmarkHttpTask = await Task.Run <List <tenderBookmark> >(() => retrieveBookmark());

                            List <tenderBookmark> tenderBookmarks = bookmarkHttpTask.ToList();
                            if (tenderBookmarks.Count > 0)
                            {
                                foreach (var tenderItem in tenderItems)
                                {
                                    foreach (var tenderBookmark in tenderBookmarks)
                                    {
                                        if (tenderItem.Reference != "" && tenderItem.Reference != null)
                                        {
                                            if (tenderItem.Reference == tenderBookmark.tenderReferenceNumber)
                                            {
                                                tenderItem.BookmarkImage = "bookmarkfilled.png";
                                                break;
                                            }
                                        }
                                        else
                                        {
                                            if (tenderItem.Title == tenderBookmark.tenderTitle)
                                            {
                                                tenderItem.BookmarkImage = "bookmarkfilled.png";
                                                break;
                                            }
                                        }
                                    }
                                }
                            }
                        }
                        Console.WriteLine("Num of tender items: " + tenderItems.Count);
                        tenderListing        = tenderItems;
                        listView.ItemsSource = tenderItems;
                    }
                }

                //Save page 1 tenders to database
                await saveToTenderDb(tenderItems, 1);

                //save subsequent page tenders to database;
                //await storeAllTenders();
                filterButton.IsVisible      = true;
                sortButton.IsVisible        = true;
                activityIndicator.IsRunning = false;
                activityIndicator.IsVisible = false;

                await WaitAndExecuteUpdateTenders(10800000);
            }
        }
Example #16
0
        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>(() => getPageData("http://www2.sesco.com.my/etender/notice/notice.jsp"));
             * var httpResult = httpTask;
             *
             * //Extract tender data from the response
             * var tenders = await DataExtraction.getWebData(httpResult, "tender");
             *
             * //Retrieve Telekom tenders
             * string httpTaskTelekom = await Task.Run<string>(() => getPageData("https://www.tm.com.my/DoingBusinessWithTM/pages/notices.aspx?Year=2018"));
             * var httpResultTelekom = httpTaskTelekom;
             * //Console.WriteLine("TELEKOM:" + httpResultTelekom);
             * //Extract tender data from the response
             * var tendersTelekom = await DataExtraction.getWebData(httpResultTelekom, "telekom");
             *
             * List<tenderItem> tenderItems = (List<tenderItem>)tendersTelekom;
             * tenderItems.AddRange((List<tenderItem>)tenders);
             * //List<tenderItem> tenderItems = (List<tenderItem>)tenders;
             */

            List <scrapped_tender> scrappedTenders = new List <scrapped_tender>();
            List <tenderItem>      tenderItems     = new List <tenderItem>();
            //Retrieve tenders from server
            string url            = "https://pockettender.000webhostapp.com/process_getTenders.php";
            string httpTaskResult = await Task.Run <string>(() => HttpRequestHandler.GetRequest(url, false));

            if (httpTaskResult != null)
            {
                if (httpTaskResult != "No tender found")
                {
                    scrappedTenders = JsonConvert.DeserializeObject <List <scrapped_tender> >(httpTaskResult);
                    Console.WriteLine("Number of scrapped tenders: " + scrappedTenders.Count + " yes");
                    //Convert scrapped tender item into tender item
                    if (scrappedTenders != null)
                    {
                        foreach (scrapped_tender scrappedTender in scrappedTenders)
                        {
                            tenderItem tender = new tenderItem();
                            tender.Company            = scrappedTender.originatingSource;
                            tender.TenderSource       = scrappedTender.tenderSource;
                            tender.Reference          = scrappedTender.reference;
                            tender.Agency             = scrappedTender.agency;
                            tender.Title              = scrappedTender.title;
                            tender.Category           = scrappedTender.category;
                            tender.OriginatingStation = scrappedTender.originatingSource;
                            tender.ClosingDate        = scrappedTender.closingDate;

                            //{"bidCloseDate":"N\/A","feeBeforeGST":"RM 0.00","feeGST":"RM 0.00","feeAfterGST":"RM 0.00"}
                            //{ "name":"Francesca Lim","officePhone":"082-441188","extension":"1126","mobilePhone":null,"email":null,"fax":null}
                            //{"PMS106-14-Instruction.pdf":"http:\/\/www2.sesco.com.my\/noticeDoc\/PMS106-14-Instruction.pdf"}

                            if (scrappedTender.docInfoJson != null)
                            {
                                dynamic docInfo = JsonConvert.DeserializeObject(scrappedTender.docInfoJson);
                                if (docInfo != null)
                                {
                                    if (docInfo.bidCloseDate != null)
                                    {
                                        tender.BidClosingDate = docInfo.bidCloseDate;
                                    }

                                    if (docInfo.feeBeforeGST != null)
                                    {
                                        tender.FeeBeforeGST = docInfo.feeBeforeGST;
                                    }

                                    if (docInfo.feeGST != null)
                                    {
                                        tender.FeeGST = docInfo.feeGST;
                                    }

                                    if (docInfo.feeAfterGST != null)
                                    {
                                        tender.FeeAfterGST = docInfo.feeAfterGST;
                                    }
                                }
                            }

                            if (scrappedTender.originatorJson != null)
                            {
                                dynamic originatorInfo = JsonConvert.DeserializeObject(scrappedTender.originatorJson);
                                if (originatorInfo != null)
                                {
                                    if (originatorInfo.name != null)
                                    {
                                        tender.Name = originatorInfo.name;
                                    }

                                    if (originatorInfo.officePhone != null)
                                    {
                                        tender.OffinePhone = originatorInfo.officePhone;
                                    }

                                    if (originatorInfo.extension != null)
                                    {
                                        tender.Extension = originatorInfo.extension;
                                    }

                                    if (originatorInfo.mobilePhone != null)
                                    {
                                        tender.MobilePhone = originatorInfo.mobilePhone;
                                    }

                                    if (originatorInfo.email != null)
                                    {
                                        tender.Email = originatorInfo.email;
                                    }

                                    if (originatorInfo.fax != null)
                                    {
                                        tender.Fax = originatorInfo.fax;
                                    }
                                }
                            }

                            if (scrappedTender.fileLinks != null)
                            {
                                Dictionary <string, string> fileLinks = JsonConvert.DeserializeObject <Dictionary <string, string> >(scrappedTender.fileLinks);
                                tender.FileLinks = fileLinks;
                                //{"Folder 1.zip":"http:\/\/www2.sesco.com.my\/noticeDoc\/Folder 1.zip","Folder 2.zip":"http:\/\/www2.sesco.com.my\/noticeDoc\/Folder 2.zip","Folder 3.zip":"http:\/\/www2.sesco.com.my\/noticeDoc\/Folder 3.zip","Folder 4.zip":"http:\/\/www2.sesco.com.my\/noticeDoc\/Folder 4.zip"}
                            }
                            tenderItems.Add(tender);
                        }
                    }

                    if (userSession.username != "")
                    {
                        List <tenderBookmark> bookmarkHttpTask = await Task.Run <List <tenderBookmark> >(() => retrieveBookmark());

                        List <tenderBookmark> tenderBookmarks = bookmarkHttpTask.ToList();
                        if (tenderBookmarks.Count > 0)
                        {
                            foreach (var tenderItem in tenderItems)
                            {
                                foreach (var tenderBookmark in tenderBookmarks)
                                {
                                    if (tenderItem.Reference != "" && tenderItem.Reference != null)
                                    {
                                        if (tenderItem.Reference == tenderBookmark.tenderReferenceNumber)
                                        {
                                            tenderItem.BookmarkImage = "bookmarkfilled.png";
                                            break;
                                        }
                                    }
                                    else
                                    {
                                        if (tenderItem.Title == tenderBookmark.tenderTitle)
                                        {
                                            tenderItem.BookmarkImage = "bookmarkfilled.png";
                                            break;
                                        }
                                    }
                                }
                            }
                        }
                    }
                    tenderListing        = tenderItems;
                    listView.ItemsSource = tenderItems;
                }
            }
            DisplayAlert("Update Tenders", "Updating tender listing. Please wait while the update is running...", "Okay");
            //Display the activity indicator to show activity running in the background
            activityIndicator.IsRunning = true;
            activityIndicator.IsVisible = true;

            //Disable next page and previous page button to disallow user from navigating to other page while update is running
            //previousPage.IsEnabled = false;
            //nextPage.IsEnabled = false;

            //delete existing tenders from database
            deleteAllTenders();

            //Save page 1 tenders to database
            await saveToTenderDb(tenderItems, 1);

            //save subsequent page tenders to database;
            //await storeAllTenders();

            List <tenderItem> dbtenders1 = await Task.Run <List <tenderItem> >(() => retrieveTenderFromDatabase(1));


            //Get bookmark details from online database
            if (userSession.username != "")
            {
                List <tenderBookmark> bookmarkHttpTask = await Task.Run <List <tenderBookmark> >(() => retrieveBookmark());

                List <tenderBookmark> tenderBookmarks = bookmarkHttpTask.ToList();
                if (tenderBookmarks.Count > 0)
                {
                    foreach (var tenderItem in dbtenders1)
                    {
                        foreach (var tenderBookmark in tenderBookmarks)
                        {
                            if (tenderItem.Reference != "" && tenderItem.Reference != null)
                            {
                                if (tenderItem.Reference == tenderBookmark.tenderReferenceNumber)
                                {
                                    tenderItem.BookmarkImage = "bookmarkfilled.png";
                                    break;
                                }
                            }
                            else
                            {
                                if (tenderItem.Title == tenderBookmark.tenderTitle)
                                {
                                    tenderItem.BookmarkImage = "bookmarkfilled.png";
                                    break;
                                }
                            }
                        }
                    }
                }
            }

            //await DisplayAlert("Update Tenders", "Refresh Tenders", "Okay");
            tenderListing        = tenderItems;
            listView.ItemsSource = tenderItems;

            activityIndicator.IsRunning = false;
            activityIndicator.IsVisible = false;
            //previousPage.IsEnabled = true;
            //nextPage.IsEnabled = true;

            await WaitAndExecuteUpdateTenders(10800000);
        }