• R/O
  • SSH
  • HTTPS

openpishcrawler: Commit


Commit MetaInfo

Revision6 (tree)
Time2019-10-10 13:16:48
Authorsebastiandotnet

Log Message

- rename suspended to reported

Change Summary

Incremental Difference

--- OpenPishCrawler/Data/SuspendedList.cs (revision 5)
+++ OpenPishCrawler/Data/SuspendedList.cs (revision 6)
@@ -6,12 +6,6 @@
66 {
77 public class SuspendedList : BindingList<Suspended>, ITypedList
88 {
9- public SuspendedList(IEnumerable<string> items)
10- {
11- foreach (var item in items)
12- Add(new Suspended(item));
13- }
14-
159 public event Action ItemDeleted;
1610
1711 public PropertyDescriptorCollection GetItemProperties(PropertyDescriptor[] listAccessors)
--- OpenPishCrawler/Service/OpenPishSuspended.cs (revision 5)
+++ OpenPishCrawler/Service/OpenPishSuspended.cs (revision 6)
@@ -4,16 +4,16 @@
44 using System.IO;
55 using System.Xml.Linq;
66 using OpenPishCrawler.Data;
7+using OpenPishCrawler.Extensions;
78
89 namespace OpenPishCrawler.Service
910 {
1011 public class OpenPishSuspended
1112 {
12- private SuspendedList _view;
13-
1413 public OpenPishSuspended()
1514 {
1615 LoadFromFilesystem();
16+ Items.ItemDeleted += SaveToFileSystem;
1717 }
1818
1919 public int Count
@@ -24,7 +24,7 @@
2424 }
2525 }
2626
27- private List<string> Items { get; set; } = new List<string>();
27+ public SuspendedList Items { get; private set; } = new SuspendedList();
2828
2929 private string FolderPath
3030 {
@@ -49,27 +49,19 @@
4949 public bool Suspended(string url)
5050 {
5151 var result = default(bool);
52- result = Items.Any(e => e.Equals(url, StringComparison.InvariantCultureIgnoreCase));
52+ result = Items.Any(e => e.Url.ToWebHostAppSubdomain().Equals(url.ToWebHostAppSubdomain(), StringComparison.InvariantCultureIgnoreCase));
5353 return result;
5454 }
55-
55+
5656 public void Add(string url)
5757 {
5858 if (!Suspended(url))
5959 {
60- Items.Add(url);
60+ Items.Add(new Data.Suspended(url));
6161 SaveToFileSystem();
6262 }
6363 }
6464
65- public bool Remove(string url)
66- {
67- var result = Items.Remove(url);
68- if(result)
69- SaveToFileSystem();
70- return result;
71- }
72-
7365 public void Clear()
7466 {
7567 if (Items.Count > 0)
@@ -79,23 +71,6 @@
7971 }
8072 }
8173
82- public SuspendedList View()
83- {
84- if (null != _view)
85- throw new InvalidOperationException("Another view is already in use.");
86- _view = new SuspendedList(Items);
87- _view.ItemDeleted += Update;
88- return _view;
89- }
90-
91- public void Update()
92- {
93- Items.Clear();
94- foreach (var item in _view)
95- Items.Add(item.Url);
96- SaveToFileSystem();
97- }
98-
9974 private void LoadFromFilesystem()
10075 {
10176 var filePath = FilePath;
@@ -103,7 +78,9 @@
10378 if (File.Exists(filePath))
10479 {
10580 var rootNode = XElement.Load(filePath).FirstNode as XElement;
106- Items = rootNode.Elements("Suspended").Select(e => e.Value).ToList();
81+ var items = rootNode.Elements("Suspended").Select(e => new Suspended(e.Value));
82+ foreach (var item in items)
83+ Items.Add(item);
10784 }
10885 }
10986
@@ -112,7 +89,7 @@
11289 var filePath = FilePath;
11390 var rootNode = new XElement(typeof(OpenPishSuspended).Assembly.GetName().Name);
11491 foreach (var item in Items)
115- rootNode.Add(new XElement("Suspended", item));
92+ rootNode.Add(new XElement("Suspended", item.Url));
11693 if (!Directory.Exists(FolderPath))
11794 Directory.CreateDirectory(FolderPath);
11895 rootNode.Save(filePath);
--- OpenPishCrawler/MainForm.Designer.cs (revision 5)
+++ OpenPishCrawler/MainForm.Designer.cs (revision 6)
@@ -31,22 +31,22 @@
3131 this.StateCheckBox = new System.Windows.Forms.CheckBox();
3232 this.MainTabControl = new System.Windows.Forms.TabControl();
3333 this.WebhostappPage = new System.Windows.Forms.TabPage();
34+ this.PishDataGridView = new OpenPishCrawler.Controls.WebhostAppDataGridview();
3435 this.SuspendedPage = new System.Windows.Forms.TabPage();
36+ this.SuspendedDataGridView = new OpenPishCrawler.Controls.SuspendedDataGridView();
37+ this.dataGridViewTextBoxColumn1 = new System.Windows.Forms.DataGridViewTextBoxColumn();
38+ this.dataGridViewButtonColumn1 = new System.Windows.Forms.DataGridViewButtonColumn();
3539 this.ErrorCountLabel = new System.Windows.Forms.Label();
3640 this.ErrorCountHeaderLabel = new System.Windows.Forms.Label();
3741 this.RunCountHeaderLabel = new System.Windows.Forms.Label();
3842 this.RunCountLabel = new System.Windows.Forms.Label();
39- this.PishDataGridView = new OpenPishCrawler.Controls.WebhostAppDataGridview();
4043 this.UrlColumn = new System.Windows.Forms.DataGridViewTextBoxColumn();
4144 this.TargetColumn = new System.Windows.Forms.DataGridViewTextBoxColumn();
4245 this.SuspendColumn = new System.Windows.Forms.DataGridViewButtonColumn();
43- this.SuspendedDataGridView = new OpenPishCrawler.Controls.SuspendedDataGridView();
44- this.dataGridViewTextBoxColumn1 = new System.Windows.Forms.DataGridViewTextBoxColumn();
45- this.dataGridViewButtonColumn1 = new System.Windows.Forms.DataGridViewButtonColumn();
4646 this.MainTabControl.SuspendLayout();
4747 this.WebhostappPage.SuspendLayout();
48+ ((System.ComponentModel.ISupportInitialize)(this.PishDataGridView)).BeginInit();
4849 this.SuspendedPage.SuspendLayout();
49- ((System.ComponentModel.ISupportInitialize)(this.PishDataGridView)).BeginInit();
5050 ((System.ComponentModel.ISupportInitialize)(this.SuspendedDataGridView)).BeginInit();
5151 this.SuspendLayout();
5252 //
@@ -86,6 +86,29 @@
8686 this.WebhostappPage.Text = "000webhostapp";
8787 this.WebhostappPage.UseVisualStyleBackColor = true;
8888 //
89+ // PishDataGridView
90+ //
91+ this.PishDataGridView.AllowUserToAddRows = false;
92+ this.PishDataGridView.AllowUserToDeleteRows = false;
93+ this.PishDataGridView.AllowUserToOrderColumns = true;
94+ this.PishDataGridView.AllowUserToResizeColumns = false;
95+ this.PishDataGridView.AllowUserToResizeRows = false;
96+ this.PishDataGridView.BackgroundColor = System.Drawing.SystemColors.Control;
97+ this.PishDataGridView.BorderStyle = System.Windows.Forms.BorderStyle.None;
98+ this.PishDataGridView.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize;
99+ this.PishDataGridView.Columns.AddRange(new System.Windows.Forms.DataGridViewColumn[] {
100+ this.UrlColumn,
101+ this.TargetColumn,
102+ this.SuspendColumn});
103+ this.PishDataGridView.Dock = System.Windows.Forms.DockStyle.Fill;
104+ this.PishDataGridView.Location = new System.Drawing.Point(0, 0);
105+ this.PishDataGridView.Margin = new System.Windows.Forms.Padding(4);
106+ this.PishDataGridView.Name = "PishDataGridView";
107+ this.PishDataGridView.PishingPagesDataSource = null;
108+ this.PishDataGridView.RowHeadersVisible = false;
109+ this.PishDataGridView.Size = new System.Drawing.Size(596, 274);
110+ this.PishDataGridView.TabIndex = 1;
111+ //
89112 // SuspendedPage
90113 //
91114 this.SuspendedPage.Controls.Add(this.SuspendedDataGridView);
@@ -92,11 +115,46 @@
92115 this.SuspendedPage.Location = new System.Drawing.Point(4, 25);
93116 this.SuspendedPage.Margin = new System.Windows.Forms.Padding(0);
94117 this.SuspendedPage.Name = "SuspendedPage";
95- this.SuspendedPage.Size = new System.Drawing.Size(596, 269);
118+ this.SuspendedPage.Size = new System.Drawing.Size(596, 274);
96119 this.SuspendedPage.TabIndex = 1;
97- this.SuspendedPage.Text = "Suspended";
120+ this.SuspendedPage.Text = "Reported";
98121 this.SuspendedPage.UseVisualStyleBackColor = true;
99122 //
123+ // SuspendedDataGridView
124+ //
125+ this.SuspendedDataGridView.AllowUserToAddRows = false;
126+ this.SuspendedDataGridView.AllowUserToDeleteRows = false;
127+ this.SuspendedDataGridView.AllowUserToResizeColumns = false;
128+ this.SuspendedDataGridView.AllowUserToResizeRows = false;
129+ this.SuspendedDataGridView.BackgroundColor = System.Drawing.SystemColors.Control;
130+ this.SuspendedDataGridView.BorderStyle = System.Windows.Forms.BorderStyle.None;
131+ this.SuspendedDataGridView.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize;
132+ this.SuspendedDataGridView.Columns.AddRange(new System.Windows.Forms.DataGridViewColumn[] {
133+ this.dataGridViewTextBoxColumn1,
134+ this.dataGridViewButtonColumn1});
135+ this.SuspendedDataGridView.Dock = System.Windows.Forms.DockStyle.Fill;
136+ this.SuspendedDataGridView.Location = new System.Drawing.Point(0, 0);
137+ this.SuspendedDataGridView.MultiSelect = false;
138+ this.SuspendedDataGridView.Name = "SuspendedDataGridView";
139+ this.SuspendedDataGridView.RowHeadersVisible = false;
140+ this.SuspendedDataGridView.Size = new System.Drawing.Size(596, 274);
141+ this.SuspendedDataGridView.SuspendedDataSource = null;
142+ this.SuspendedDataGridView.TabIndex = 0;
143+ //
144+ // dataGridViewTextBoxColumn1
145+ //
146+ this.dataGridViewTextBoxColumn1.AutoSizeMode = System.Windows.Forms.DataGridViewAutoSizeColumnMode.Fill;
147+ this.dataGridViewTextBoxColumn1.DataPropertyName = "Url";
148+ this.dataGridViewTextBoxColumn1.HeaderText = "Url";
149+ this.dataGridViewTextBoxColumn1.Name = "dataGridViewTextBoxColumn1";
150+ this.dataGridViewTextBoxColumn1.ReadOnly = true;
151+ //
152+ // dataGridViewButtonColumn1
153+ //
154+ this.dataGridViewButtonColumn1.HeaderText = "Remove";
155+ this.dataGridViewButtonColumn1.Name = "dataGridViewButtonColumn1";
156+ this.dataGridViewButtonColumn1.UseColumnTextForButtonValue = true;
157+ //
100158 // ErrorCountLabel
101159 //
102160 this.ErrorCountLabel.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
@@ -138,29 +196,6 @@
138196 this.RunCountLabel.TabIndex = 8;
139197 this.RunCountLabel.Text = "0";
140198 //
141- // PishDataGridView
142- //
143- this.PishDataGridView.AllowUserToAddRows = false;
144- this.PishDataGridView.AllowUserToDeleteRows = false;
145- this.PishDataGridView.AllowUserToOrderColumns = true;
146- this.PishDataGridView.AllowUserToResizeColumns = false;
147- this.PishDataGridView.AllowUserToResizeRows = false;
148- this.PishDataGridView.BackgroundColor = System.Drawing.SystemColors.Control;
149- this.PishDataGridView.BorderStyle = System.Windows.Forms.BorderStyle.None;
150- this.PishDataGridView.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize;
151- this.PishDataGridView.Columns.AddRange(new System.Windows.Forms.DataGridViewColumn[] {
152- this.UrlColumn,
153- this.TargetColumn,
154- this.SuspendColumn});
155- this.PishDataGridView.Dock = System.Windows.Forms.DockStyle.Fill;
156- this.PishDataGridView.Location = new System.Drawing.Point(0, 0);
157- this.PishDataGridView.Margin = new System.Windows.Forms.Padding(4);
158- this.PishDataGridView.Name = "PishDataGridView";
159- this.PishDataGridView.PishingPagesDataSource = null;
160- this.PishDataGridView.RowHeadersVisible = false;
161- this.PishDataGridView.Size = new System.Drawing.Size(596, 274);
162- this.PishDataGridView.TabIndex = 1;
163- //
164199 // UrlColumn
165200 //
166201 this.UrlColumn.AutoSizeMode = System.Windows.Forms.DataGridViewAutoSizeColumnMode.Fill;
@@ -179,45 +214,10 @@
179214 //
180215 // SuspendColumn
181216 //
182- this.SuspendColumn.HeaderText = "Suspended";
217+ this.SuspendColumn.HeaderText = "Reported";
183218 this.SuspendColumn.Name = "SuspendColumn";
184219 this.SuspendColumn.UseColumnTextForButtonValue = true;
185220 //
186- // SuspendedDataGridView
187- //
188- this.SuspendedDataGridView.AllowUserToAddRows = false;
189- this.SuspendedDataGridView.AllowUserToDeleteRows = false;
190- this.SuspendedDataGridView.AllowUserToResizeColumns = false;
191- this.SuspendedDataGridView.AllowUserToResizeRows = false;
192- this.SuspendedDataGridView.BackgroundColor = System.Drawing.SystemColors.Control;
193- this.SuspendedDataGridView.BorderStyle = System.Windows.Forms.BorderStyle.None;
194- this.SuspendedDataGridView.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize;
195- this.SuspendedDataGridView.Columns.AddRange(new System.Windows.Forms.DataGridViewColumn[] {
196- this.dataGridViewTextBoxColumn1,
197- this.dataGridViewButtonColumn1});
198- this.SuspendedDataGridView.Dock = System.Windows.Forms.DockStyle.Fill;
199- this.SuspendedDataGridView.Location = new System.Drawing.Point(0, 0);
200- this.SuspendedDataGridView.MultiSelect = false;
201- this.SuspendedDataGridView.Name = "SuspendedDataGridView";
202- this.SuspendedDataGridView.RowHeadersVisible = false;
203- this.SuspendedDataGridView.Size = new System.Drawing.Size(596, 272);
204- this.SuspendedDataGridView.SuspendedDataSource = null;
205- this.SuspendedDataGridView.TabIndex = 0;
206- //
207- // dataGridViewTextBoxColumn1
208- //
209- this.dataGridViewTextBoxColumn1.AutoSizeMode = System.Windows.Forms.DataGridViewAutoSizeColumnMode.Fill;
210- this.dataGridViewTextBoxColumn1.DataPropertyName = "Url";
211- this.dataGridViewTextBoxColumn1.HeaderText = "Url";
212- this.dataGridViewTextBoxColumn1.Name = "dataGridViewTextBoxColumn1";
213- this.dataGridViewTextBoxColumn1.ReadOnly = true;
214- //
215- // dataGridViewButtonColumn1
216- //
217- this.dataGridViewButtonColumn1.HeaderText = "Remove";
218- this.dataGridViewButtonColumn1.Name = "dataGridViewButtonColumn1";
219- this.dataGridViewButtonColumn1.UseColumnTextForButtonValue = true;
220- //
221221 // MainForm
222222 //
223223 this.AutoScaleDimensions = new System.Drawing.SizeF(8F, 16F);
@@ -235,8 +235,8 @@
235235 this.Text = "OpenPish Crawler";
236236 this.MainTabControl.ResumeLayout(false);
237237 this.WebhostappPage.ResumeLayout(false);
238+ ((System.ComponentModel.ISupportInitialize)(this.PishDataGridView)).EndInit();
238239 this.SuspendedPage.ResumeLayout(false);
239- ((System.ComponentModel.ISupportInitialize)(this.PishDataGridView)).EndInit();
240240 ((System.ComponentModel.ISupportInitialize)(this.SuspendedDataGridView)).EndInit();
241241 this.ResumeLayout(false);
242242 this.PerformLayout();
@@ -246,9 +246,6 @@
246246 #endregion
247247 private Controls.WebhostAppDataGridview PishDataGridView;
248248 private System.Windows.Forms.CheckBox StateCheckBox;
249- private System.Windows.Forms.DataGridViewTextBoxColumn UrlColumn;
250- private System.Windows.Forms.DataGridViewTextBoxColumn TargetColumn;
251- private System.Windows.Forms.DataGridViewButtonColumn SuspendColumn;
252249 private System.Windows.Forms.TabControl MainTabControl;
253250 private System.Windows.Forms.TabPage WebhostappPage;
254251 private System.Windows.Forms.TabPage SuspendedPage;
@@ -259,6 +256,9 @@
259256 private System.Windows.Forms.Label ErrorCountHeaderLabel;
260257 private System.Windows.Forms.Label RunCountHeaderLabel;
261258 private System.Windows.Forms.Label RunCountLabel;
259+ private System.Windows.Forms.DataGridViewTextBoxColumn UrlColumn;
260+ private System.Windows.Forms.DataGridViewTextBoxColumn TargetColumn;
261+ private System.Windows.Forms.DataGridViewButtonColumn SuspendColumn;
262262 }
263263 }
264264
--- OpenPishCrawler/MainForm.cs (revision 5)
+++ OpenPishCrawler/MainForm.cs (revision 6)
@@ -32,7 +32,7 @@
3232 PishDataGridView.PishingPagesDataSource = service.PishingPages;
3333
3434 var suspended = OpenPishFactory.Instance<OpenPishSuspended>();
35- SuspendedDataGridView.SuspendedDataSource = suspended.View();
35+ SuspendedDataGridView.SuspendedDataSource = suspended.Items;
3636 }
3737
3838 private void Unbind()
Show on old repository browser