This repository has been archived by the owner on Nov 13, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
MainWindow.xaml.cs
144 lines (123 loc) · 5.85 KB
/
MainWindow.xaml.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
using System;
using System.Windows;
using Word = Microsoft.Office.Interop.Word;
using winForms = System.Windows.Forms;
using System.IO;
using Path = System.IO.Path;
using System.Diagnostics;
namespace RezumeReader
{
public partial class MainWindow : Window
{
private Word.Application wordapp;
public Word.Application Wordapp { get => wordapp; set => wordapp = value; }
public MainWindow() => InitializeComponent();
private void Window_MouseLeftButtonDown(object sender, RoutedEventArgs e) => this.DragMove();
private void BtnClose_Click(object sender, RoutedEventArgs e) => this.Close();
/* Установка пути к папке с файлами */
private void BtnSPath_Click(object sender, RoutedEventArgs e)
{
winForms.FolderBrowserDialog folderDialog = new winForms.FolderBrowserDialog();
folderDialog.ShowNewFolderButton = false;
folderDialog.SelectedPath = System.AppDomain.CurrentDomain.BaseDirectory;
winForms.DialogResult result = folderDialog.ShowDialog();
if (result == winForms.DialogResult.OK)
{
String sPath = folderDialog.SelectedPath;
TbSPath.Text = sPath;
}
}
/* Установка пути к папке, в которую будут отправляться копии отсортированного */
private void BtnDPath_Click(object sender, RoutedEventArgs e)
{
winForms.FolderBrowserDialog folderDialog = new winForms.FolderBrowserDialog();
folderDialog.ShowNewFolderButton = true;
folderDialog.SelectedPath = System.AppDomain.CurrentDomain.BaseDirectory;
winForms.DialogResult result = folderDialog.ShowDialog();
if (result == winForms.DialogResult.OK)
{
String dPath = folderDialog.SelectedPath;
TbDPath.Text = dPath;
}
}
/* Начало сортировки */
private void BtnStartSort_Click(object sender, RoutedEventArgs e)
{
string sPath = TbSPath.Text;
string dPath = TbDPath.Text;
Wordapp = new Word.Application();
Wordapp.Visible = false;
try
{
string[] file_list = Directory.GetFiles(sPath, "*.docx"); //получаем список docx файлов
if (sPath.Length != 0 && dPath.Length != 0)
{
foreach (string file_to_read in file_list)
{
Wordapp.Application.Visible = false;
Wordapp.Documents.Open(file_to_read);
string wordtext = Wordapp.Documents.Open(file_to_read).Content.Text;
if (wordtext.Contains("Шаблон") == false &&
(wordtext.IndexOf(CbGender.Text, StringComparison.OrdinalIgnoreCase) >= 0) &&
(wordtext.IndexOf(CbEducation.Text, StringComparison.OrdinalIgnoreCase) >= 0) &&
(wordtext.IndexOf(CbCitizenship.Text, StringComparison.OrdinalIgnoreCase) >= 0) &&
(wordtext.IndexOf(CbScientist.Text, StringComparison.OrdinalIgnoreCase) >= 0) &&
(wordtext.IndexOf(CbPost.Text, StringComparison.OrdinalIgnoreCase) >= 0) &&
(wordtext.IndexOf(CbEnglish.Text, StringComparison.OrdinalIgnoreCase) >= 0))
File.Copy(file_to_read, dPath + @"\" + Path.GetFileName(file_to_read), true);
}
Process.Start("explorer", dPath);
}
else
{
ExceptionDialog exceptionDialog = new ExceptionDialog();
exceptionDialog.ShowDialog();
}
}
catch(Exception)
{
ExceptionDialog exceptionDialog = new ExceptionDialog();
exceptionDialog.ShowDialog();
}
Wordapp.Quit(true);
}
/* Checked события */
private void Gender_Checked(object sender, RoutedEventArgs e) => CbGender.IsEnabled = true;
private void Education_Checked(object sender, RoutedEventArgs e) => CbEducation.IsEnabled = true;
private void Citizenship_Checked(object sender, RoutedEventArgs e) => CbCitizenship.IsEnabled = true;
private void Scientist_Checked(object sender, RoutedEventArgs e) => CbScientist.IsEnabled = true;
private void Post_Checked(object sender, RoutedEventArgs e) => CbPost.IsEnabled = true;
private void English_Checked(object sender, RoutedEventArgs e) => CbEnglish.IsEnabled = true;
/* UNhecked события */
private void Gender_Unchecked(object sender, RoutedEventArgs e)
{
CbGender.IsEnabled = false;
CbGender.Text = "Пол";
}
private void Education_Unchecked(object sender, RoutedEventArgs e)
{
CbEducation.IsEnabled = false;
CbEducation.Text = "Пол";
}
private void Citizenship_Unchecked(object sender, RoutedEventArgs e)
{
CbCitizenship.IsEnabled = false;
CbCitizenship.Text = "Пол";
}
private void Scientist_Unchecked(object sender, RoutedEventArgs e)
{
CbScientist.IsEnabled = false;
CbScientist.Text = "Пол";
}
private void Post_Unchecked(object sender, RoutedEventArgs e)
{
CbPost.IsEnabled = false;
CbPost.Text = "Пол";
}
private void English_Unchecked(object sender, RoutedEventArgs e)
{
CbEnglish.IsEnabled = false;
CbEnglish.Text = "Пол";
}
}
}