-
-
Notifications
You must be signed in to change notification settings - Fork 559
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #786 from skadefro/master
add url detector to nm
- Loading branch information
Showing
13 changed files
with
502 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,129 @@ | ||
using Newtonsoft.Json; | ||
using OpenRPA.Input; | ||
using OpenRPA.Interfaces; | ||
using OpenRPA.Interfaces.entity; | ||
using System; | ||
using System.Collections.Generic; | ||
using System.IO; | ||
using System.Linq; | ||
using System.Text; | ||
using System.Threading.Tasks; | ||
using System.Windows.Controls; | ||
|
||
namespace OpenRPA.NM | ||
{ | ||
public class URLDetectorPlugin : ObservableObject, IDetectorPlugin | ||
{ | ||
public IDetector Entity { get; set; } | ||
public string Name | ||
{ | ||
get | ||
{ | ||
if (Entity != null && !string.IsNullOrEmpty(Entity.name)) return Entity.name; | ||
return "URLDetector"; | ||
} | ||
} | ||
public string URL | ||
{ | ||
get | ||
{ | ||
if (Entity == null) return null; | ||
if (!Entity.Properties.ContainsKey("URL")) return null; | ||
var _val = Entity.Properties["URL"]; | ||
if (_val == null) return null; | ||
return _val.ToString(); | ||
} | ||
} | ||
public bool IgnoreCase | ||
{ | ||
get | ||
{ | ||
if (Entity == null) return false; | ||
if (!Entity.Properties.ContainsKey("IgnoreCase")) return false; | ||
var _val = Entity.Properties["URL"]; | ||
if (_val == null) return IgnoreCase; | ||
return _val.ToString().ToLower() == "true"; | ||
} | ||
set | ||
{ | ||
Entity.Properties["IgnoreCase"] = value.ToString(); | ||
NotifyPropertyChanged("IgnoreCase"); | ||
} | ||
} | ||
private Views.URLDetectorView view; | ||
public UserControl editor | ||
{ | ||
get | ||
{ | ||
if (view == null) | ||
{ | ||
view = new Views.URLDetectorView(this); | ||
view.PropertyChanged += (s, e) => | ||
{ | ||
NotifyPropertyChanged("Entity"); | ||
NotifyPropertyChanged("Name"); | ||
NotifyPropertyChanged("URL"); | ||
}; | ||
} | ||
return view; | ||
} | ||
} | ||
public event DetectorDelegate OnDetector; | ||
public void RaiseDetector(Download download) | ||
{ | ||
if (!Running) return; | ||
var e = new DetectorEvent(download); | ||
OnDetector?.Invoke(this, e, EventArgs.Empty); | ||
} | ||
public void RaiseDetector(URLDetectorEvent e) | ||
{ | ||
if (!Running) return; | ||
OnDetector?.Invoke(this, e, EventArgs.Empty); | ||
} | ||
FileSystemWatcher watcher = null; | ||
private IOpenRPAClient client = null; | ||
public void Initialize(IOpenRPAClient client, IDetector InEntity) | ||
{ | ||
this.client = client; | ||
Entity = InEntity; | ||
watcher = new FileSystemWatcher(); | ||
Start(); | ||
} | ||
public bool Running { get; set; } = false; | ||
public void Start() | ||
{ | ||
try | ||
{ | ||
Running = true; | ||
} | ||
catch (Exception ex) | ||
{ | ||
Log.Error(ex.ToString()); | ||
} | ||
} | ||
public void Stop() | ||
{ | ||
Running = false; | ||
} | ||
public void Initialize(IOpenRPAClient client) | ||
{ | ||
} | ||
} | ||
public class URLDetectorEvent : IDetectorEvent | ||
{ | ||
public IElement element { get; set; } | ||
public string host { get; set; } | ||
public string fqdn { get; set; } | ||
public string url { get; set; } | ||
public string result { get; set; } | ||
public URLDetectorEvent(string url) | ||
{ | ||
host = Environment.MachineName.ToLower(); | ||
fqdn = System.Net.Dns.GetHostEntry(Environment.MachineName).HostName.ToLower(); | ||
this.url = url; | ||
result = url; | ||
} | ||
|
||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
<UserControl x:Class="OpenRPA.NM.Views.URLDetectorView" | ||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" | ||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" | ||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" | ||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008" | ||
xmlns:or="clr-namespace:OpenRPA.NM.Resources" | ||
mc:Ignorable="d" | ||
d:DesignHeight="450" d:DesignWidth="800"> | ||
<Grid> | ||
<TextBlock Height="23" HorizontalAlignment="Left" Margin="67,20,0,0" Text="{x:Static or:strings.detector_name}" VerticalAlignment="Top" Width="110" /> | ||
<TextBox Height="23" HorizontalAlignment="Left" Margin="183,20,0,0" Text="{Binding Path=EntityName, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" VerticalAlignment="Top" Width="222" /> | ||
<TextBlock Height="23" HorizontalAlignment="Left" Margin="67,50,0,0" Text="{x:Static or:strings.detector_url}" VerticalAlignment="Top" Width="110" /> | ||
<TextBox Height="23" HorizontalAlignment="Left" Margin="183,50,0,0" Text="{Binding Path=URL, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" VerticalAlignment="Top" Width="222" /> | ||
|
||
<TextBlock Height="23" HorizontalAlignment="Left" Margin="35,80,0,0" Text="{x:Static or:strings.plugin_ignore_case}" VerticalAlignment="Top" Width="110" /> | ||
<CheckBox Height="23" HorizontalAlignment="Left" Margin="151,80,0,0" VerticalAlignment="Top" Width="222" x:Name="plugin_ignore_case" | ||
Checked="plugin_ignore_caseChanged" Unchecked="plugin_ignore_caseChanged" /> | ||
<TextBlock Height="23" HorizontalAlignment="Left" Margin="180,80,0,0" Text="{x:Static or:strings.plugin_ignore_case_help}" VerticalAlignment="Top" /> | ||
|
||
|
||
|
||
<TextBlock Height="23" HorizontalAlignment="Left" Margin="180,110,0,0" Text="{x:Static or:strings.plugin_urldetector_general_help}" VerticalAlignment="Top" /> | ||
<TextBlock Height="23" HorizontalAlignment="Left" Margin="180,140,0,0" Text="Example" VerticalAlignment="Top" /> | ||
|
||
<TextBox Height="23" HorizontalAlignment="Left" Margin="183,170,0,0" Text="^https://www.google.com/search\?q=" VerticalAlignment="Top" Width="222" /> | ||
|
||
<Button Content="{x:Static or:strings.detector_button_select}" HorizontalAlignment="Left" Margin="67,110,0,0" VerticalAlignment="Top" Width="100" RenderTransformOrigin="0.769,-0.134" Click="Select_Click" /> | ||
<!--<Button Content="{x:Static or:strings.detector_button_open_selector}" HorizontalAlignment="Left" Margin="67,134,0,0" VerticalAlignment="Top" Width="100" RenderTransformOrigin="0.769,-0.134" Click="Open_Selector_Click" />--> | ||
|
||
|
||
|
||
</Grid> | ||
</UserControl> |
Oops, something went wrong.