public void ValidatePropertyValueNotEmpty(IDataWebScraperStepProperty dataWebScraperStepProperty)
 {
     if (string.IsNullOrWhiteSpace(dataWebScraperStepProperty.Value))
     {
         throw new NullReferenceException($"The property {dataWebScraperStepProperty.Key} should not be empty.");
     }
 }
        public IDataWebScraperStepProperty GetFirstProperty(DataWebScraperStepPropertyType dataWebScraperStepPropertyType, IEnumerable <IDataWebScraperStepProperty> dataWebScraperStepProperties)
        {
            IDataWebScraperStepProperty dataWebScraperStepProperty = dataWebScraperStepProperties.FirstOrDefault(p => p.DataWebScraperStepPropertyType == dataWebScraperStepPropertyType);

            if (dataWebScraperStepProperty == null)
            {
                throw new NullReferenceException($"There is no property for type '{dataWebScraperStepPropertyType.ToString()}'.");
            }

            return(dataWebScraperStepProperty);
        }
        internal void ValidatePropertyValueNumericNotZero(IDataWebScraperStepProperty dataWebScraperStepProperty)
        {
            ValidatePropertyValueNotEmpty(dataWebScraperStepProperty);

            if (!int.TryParse(dataWebScraperStepProperty.Value, out int convertedProperty))
            {
                throw new NullReferenceException($"The property {dataWebScraperStepProperty.Key} does not contains a numeric value.");
            }
            else
            {
                if (convertedProperty == 0)
                {
                    throw new NullReferenceException($"The property {dataWebScraperStepProperty.Key} should not be zero.");
                }
            }
        }
Beispiel #4
0
        public void Execute(WebBrowser webBrowser, IEnumerable <IDataWebScraperStepProperty> dataWebScraperStepProperties)
        {
            IDataWebScraperStepProperty urlProperty = DataWebScrapperStepPropertyValidator.GetFirstProperty(DataWebScraperStepPropertyType.Url, dataWebScraperStepProperties);
            IDataWebScraperStepProperty millisecondsToHoldProperty = DataWebScrapperStepPropertyValidator.GetFirstProperty(DataWebScraperStepPropertyType.MillisecondsToHold, dataWebScraperStepProperties);

            DataWebScrapperStepPropertyValidator.ValidatePropertyValueNotEmpty(urlProperty);
            DataWebScrapperStepPropertyValidator.ValidatePropertyValueNumericNotZero(millisecondsToHoldProperty);

            DataWebScraperThreadHolder = ThreadHolderManagerFactory.GetDataWebScraperThreadHolder(long.Parse(millisecondsToHoldProperty.Value));
            DataWebScraperThreadHolder.SetThreadValue(false);
            try
            {
                webBrowser.DocumentCompleted += WebBrowser_DocumentCompleted;
                webBrowser.Navigate(urlProperty.Value);
                //DataWebScraperThreadHolder.WaitUntilValue(true);
            }catch (Exception e)
            {
                string r = e.Message;
            }
        }
Beispiel #5
0
 public void RemoveDataWebScraperStepProperty(IDataWebScraperStepProperty dataWebScraperStepProperty)
 {
     _dataWebScraperStepProperties.Remove(dataWebScraperStepProperty);
 }
Beispiel #6
0
 public void AddDataWebScraperStepProperty(IDataWebScraperStepProperty dataWebScraperStepProperty)
 {
     _dataWebScraperStepProperties.Add(dataWebScraperStepProperty);
 }