Ejemplo n.º 1
0
        public void start(MainWindow windowRef)
        {
            new Thread(() =>
            {
                while (runInstance)
                {
                    try
                    {
                        using (HttpRequest httpRequest = new HttpRequest())
                        {
                            httpRequest.ClearAllHeaders();
                            httpRequest.UserAgent      = Http.ChromeUserAgent();
                            httpRequest.ConnectTimeout = 10000;

                            string response = httpRequest.Get(settings.productURL, null).ToString();

                            bool hasHit = false;
                            for (int i = 0; i < saveItem.successKeys.Length; i++)
                            {
                                if (response.Contains(saveItem.successKeys[i]))
                                {
                                    hasHit = true;
                                }
                            }

                            if (hasHit)
                            {
                                //hit logic
                                lastHit = DateTime.Now;
                            }


                            Interlocked.Increment(ref timesChecked);

                            windowRef.stockListView.Dispatcher.BeginInvoke(new Action(delegate()
                            {
                                LoggerFactory.debug(this, "Updating the listview object.");

                                DashboardViewItem changeItem = engineInstance.dashItems.Where(var => var == dashItem).First();

                                if (lastHit != DateTime.MinValue)
                                {
                                    changeItem.lastHit = Helpers.TimeAgo(lastHit);
                                }

                                changeItem.timesChecked = timesChecked + " Times";
                            }));
                        }
                    }
                    catch (Exception ex)
                    {
                        //No error handling as of yet
                        LoggerFactory.debug(this, ex.Message);
                    }

                    Thread.Sleep(settings.interval * 1000);
                }
            }).Start();
        }
Ejemplo n.º 2
0
        public Instance(EngineSettings settings, ConfigurationSaveItem saveItem, StockEngine engineInstance, DashboardViewItem dashItem)
        {
            this.settings       = settings;
            this.saveItem       = saveItem;
            this.engineInstance = engineInstance;
            this.dashItem       = dashItem;

            LoggerFactory.debug(this, "Started instance on config: " + saveItem.viewItem.configName);
        }
Ejemplo n.º 3
0
        public void createInstance(ConfigurationSaveItem saveItem, EngineSettings settings)
        {
            if (saveItem != null)
            {
                DashboardViewItem dashItem = new DashboardViewItem
                {
                    product      = settings.productURL,
                    store        = saveItem.viewItem.configName,
                    lastHit      = "Never", //Most of this will be changed
                    price        = settings.price,
                    timesChecked = "0 Times",
                    timeStarted  = DateTime.Now.ToString("MM-dd-yyyy hh:mm:ss tt")
                };

                dashItems.Add(dashItem);

                Instance newInstance = new Instance(settings, saveItem, this, dashItem);

                currentInstances.Add(newInstance);

                newInstance.start(windowRef);
            }
        }