Exemplo n.º 1
0
        // POST api/values
        public WebDataCollection Post([FromBody] string productName)
        {
            WebDataCollection webDataCollection = new WebDataCollection();
            WebDataMain       webDataMain       = new WebDataMain();

            if (string.IsNullOrEmpty(productName))
            {
                return(webDataCollection);
            }
            else
            {
                Parallel.Invoke(() =>
                {
                    webDataCollection.shopHiveList = webDataMain.GetShopHiveDataAsync(productName);
                },
                                () =>
                {
                    webDataCollection.shopHiveList = webDataMain.GetSymbiosDataAsync(productName);
                },
                                () =>
                {
                    webDataCollection.shopHiveList = webDataMain.GetYayvoDataAsync(productName);
                }
                                );
                return(webDataCollection);
            }
        }
Exemplo n.º 2
0
        public async Task <WebDataCollection> GetAsync(string productName)
        {
            WebDataCollection webDataCollection = new WebDataCollection();
            WebDataMain       webDataMain       = new WebDataMain();

            if (string.IsNullOrEmpty(productName))
            {
                return(webDataCollection);
            }
            else
            {
                Thread th1 = new Thread(() => webDataCollection.shopHiveList = webDataMain.GetShopHiveDataAsync(productName));
                Thread th2 = new Thread(() => webDataCollection.symbiosList = webDataMain.GetSymbiosDataAsync(productName));
                Thread th3 = new Thread(() => webDataCollection.YavooList = webDataMain.GetYayvoDataAsync(productName));

                th1.SetApartmentState(ApartmentState.STA);
                th2.SetApartmentState(ApartmentState.STA);
                th3.SetApartmentState(ApartmentState.STA);
                th1.Start();
                th2.Start();
                th3.Start();

                th1.Join();
                th2.Join();
                th3.Join();

                webDataCollection.DarazList = await webDataMain.StartDarazCrawlerAsync(productName);

                // Task t1 = Task.Factory.StartNew(() => webDataCollection.shopHiveList = webDataMain.GetShopHiveDataAsync(productName));
                // Task t2 = Task.Factory.StartNew(() => webDataCollection.symbiosList = webDataMain.GetSymbiosDataAsync(productName));
                // Task t3 = Task.Factory.StartNew(() => webDataCollection.YavooList = webDataMain.GetYayvoDataAsync(productName));


                // Task.WaitAll(t1, t2, t3);
                return(webDataCollection);


                // th2.SetApartmentState(ApartmentState.STA);
                // th3.SetApartmentState(ApartmentState.STA);

                //Task t1 = Task.Run(() => th1.Start());
                //Task t2 = Task.Run(() => th2.Start());
                // Task t3 = Task.Run(() => th3.Start());
                //t1.Wait();

                //  await Task.WhenAll(t1, t2, t3);
            }
        }
Exemplo n.º 3
0
        public async Task <WebDataCollection> GetDarazListAsync(string productName)
        {
            WebDataCollection webDataCollection = new WebDataCollection();
            WebDataMain       webDataMain       = new WebDataMain();

            if (string.IsNullOrEmpty(productName))
            {
                return(webDataCollection);
            }
            else
            {
                webDataCollection.DarazList = await webDataMain.StartDarazCrawlerAsync(productName);

                return(webDataCollection);
            }
        }
Exemplo n.º 4
0
        public async Task <WebDataCollection> GetSymbiosListAsync(string productName)
        {
            WebDataCollection webDataCollection = new WebDataCollection();
            WebDataMain       webDataMain       = new WebDataMain();

            if (string.IsNullOrEmpty(productName))
            {
                return(webDataCollection);
            }
            else
            {
                Thread th1 = new Thread(() => webDataCollection.symbiosList = webDataMain.GetSymbiosDataAsync(productName));

                th1.SetApartmentState(ApartmentState.STA);
                th1.Start();
                th1.Join();
                return(webDataCollection);
            }
        }