more classes
This commit is contained in:
5
.gitignore
vendored
5
.gitignore
vendored
@@ -1 +1,6 @@
|
||||
data/
|
||||
Resources/res.json
|
||||
bin/
|
||||
Deposits/bin/
|
||||
ref/
|
||||
obj/
|
@@ -3,25 +3,45 @@
|
||||
<PropertyGroup>
|
||||
<OutputType>Exe</OutputType>
|
||||
<TargetFramework>net5.0</TargetFramework>
|
||||
<ApplicationManifest>app.manifest</ApplicationManifest>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<COMReference Include="Microsoft.Office.Interop.Excel">
|
||||
<WrapperTool>tlbimp</WrapperTool>
|
||||
<VersionMinor>9</VersionMinor>
|
||||
<VersionMajor>1</VersionMajor>
|
||||
<Guid>00020813-0000-0000-c000-000000000046</Guid>
|
||||
<Lcid>0</Lcid>
|
||||
<Isolated>false</Isolated>
|
||||
<EmbedInteropTypes>true</EmbedInteropTypes>
|
||||
</COMReference>
|
||||
</ItemGroup>
|
||||
|
||||
|
||||
<ItemGroup>
|
||||
<Content Include="bins\geckodriver.exe">
|
||||
|
||||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||
</Content>
|
||||
<Content Include="Resources\res.json">
|
||||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||
</Content>
|
||||
</ItemGroup>
|
||||
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="DocumentFormat.OpenXml" Version="2.13.1" />
|
||||
<PackageReference Include="Selenium.WebDriver" Version="3.141.0" />
|
||||
|
||||
<PackageReference Include="System.Security.Cryptography.Algorithms" Version="4.3.1" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<Resource Include="bins\" />
|
||||
|
||||
<Reference Include="Resources">
|
||||
<Private>True</Private>
|
||||
<EmbedInteropTypes>True</EmbedInteropTypes>
|
||||
</Reference>
|
||||
<Resource Include="SubDep\" />
|
||||
</ItemGroup>
|
||||
|
||||
|
@@ -1,13 +1,38 @@
|
||||
using Deposits.SubDep;
|
||||
using System;
|
||||
namespace Deposits
|
||||
{
|
||||
class Program
|
||||
{
|
||||
static void Main(string[] args)
|
||||
{
|
||||
|
||||
namespace Deposits {
|
||||
class Program {
|
||||
public static bool ToEncrypt() {
|
||||
return System.DateTime.Today.Day >= 24;
|
||||
}
|
||||
public static void RunEncryption() {
|
||||
if (ToEncrypt()) {
|
||||
string resources = System.IO.File.ReadAllText(@"Resources\res.json");
|
||||
var location = (Newtonsoft.Json.Linq.JObject)Newtonsoft.Json.JsonConvert.DeserializeObject(resources);
|
||||
string dataToEncrypt = Data.DecryptData(System.IO.File.ReadAllBytes((string)location["data location"]));
|
||||
Data.CreateNewKeys();
|
||||
|
||||
System.IO.File.WriteAllBytes((string)location["data location"], Data.EncryptData(dataToEncrypt));
|
||||
}
|
||||
|
||||
}
|
||||
public static void RunEncryption(Data dt) {
|
||||
if (ToEncrypt()) {
|
||||
Data.CreateNewKeys();
|
||||
System.IO.File.WriteAllBytes(dt.GetLocation(), Data.EncryptData(dt.GetPlainText()));
|
||||
}
|
||||
}
|
||||
static void Main(string[] args) {
|
||||
WebDriver driver = new();
|
||||
Console.WriteLine("Hello World!");
|
||||
driver.Driver.Url = "https://google.com";
|
||||
|
||||
driver.RunWeb(300, "https://mail.google.com/mail/u/0/#inbox", "https://www.tgspot.co.il/");
|
||||
//Data dt = new Data();
|
||||
//RunEncryption(dt);
|
||||
//dt = new();
|
||||
//string resources = System.IO.File.ReadAllText(@"Resources\res.json");
|
||||
//var location = (Newtonsoft.Json.Linq.JObject)Newtonsoft.Json.JsonConvert.DeserializeObject(resources);
|
||||
//System.Console.WriteLine(dt.GetPlainText());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -1,12 +1,52 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Security.Cryptography;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
namespace Deposits.SubDep {
|
||||
class Data {
|
||||
string plainTextData;
|
||||
string locations;
|
||||
byte[] encryptedData;
|
||||
public Data() {
|
||||
string resources = System.IO.File.ReadAllText(@"Resources\res.json");
|
||||
var location = (Newtonsoft.Json.Linq.JObject)Newtonsoft.Json.JsonConvert.DeserializeObject(resources);
|
||||
this.locations = (string)location["data location"];
|
||||
this.encryptedData = System.IO.File.ReadAllBytes(locations);
|
||||
this.plainTextData = DecryptData(this.encryptedData);
|
||||
}
|
||||
public static void CreateNewKeys() {
|
||||
RSA file = RSA.Create();
|
||||
file.KeySize = 8192;
|
||||
System.IO.File.WriteAllText(@"D:\pk", file.ToXmlString(true));
|
||||
System.IO.File.WriteAllText(@"C:\pk", file.ToXmlString(false));
|
||||
|
||||
namespace Deposits.SubDep
|
||||
{
|
||||
class Data
|
||||
{
|
||||
}
|
||||
//public static void GenerateNewKeys() {
|
||||
// RSA file = RSA.Create();
|
||||
//}
|
||||
public string GetLocation() {
|
||||
return this.locations;
|
||||
}
|
||||
public string GetPlainText() {
|
||||
return this.plainTextData;
|
||||
}
|
||||
public static byte[] EncryptData(string data) {
|
||||
|
||||
RSA rsaFile = RSA.Create();
|
||||
|
||||
string prive = System.IO.File.ReadAllText(@"D:\pk");
|
||||
rsaFile.FromXmlString(prive);
|
||||
|
||||
byte[] Data = Encoding.UTF8.GetBytes(data);
|
||||
return rsaFile.Encrypt(Data, RSAEncryptionPadding.Pkcs1);
|
||||
|
||||
//rsaFile.fr
|
||||
|
||||
}
|
||||
public static string DecryptData(byte[] data) {
|
||||
RSA rsaFile = RSA.Create();
|
||||
string prive = System.IO.File.ReadAllText(@"D:\pk");
|
||||
rsaFile.FromXmlString(prive);
|
||||
string Data = System.Text.Encoding.UTF8.GetString(rsaFile.Decrypt(data, RSAEncryptionPadding.Pkcs1));
|
||||
return Data;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
17
Deposits/SubDep/Excel.cs
Normal file
17
Deposits/SubDep/Excel.cs
Normal file
@@ -0,0 +1,17 @@
|
||||
//using System;
|
||||
//using System.Collections.Generic;
|
||||
//using System.Linq;
|
||||
//using System.Text;
|
||||
//using System.Threading.Tasks;
|
||||
//using System.Runtime.InteropServices;
|
||||
|
||||
namespace Deposits.SubDep {
|
||||
class Excel {
|
||||
|
||||
Microsoft.Office.Interop.Excel.Workbooks wb;
|
||||
public Excel() {
|
||||
wb.Open(@"D:\Drive\מסמכים\מסמכים לסנכרון\צבירוש.xlsx");
|
||||
|
||||
}
|
||||
}
|
||||
}
|
@@ -1,13 +1,10 @@
|
||||
using OpenQA.Selenium.Firefox;
|
||||
namespace Deposits.SubDep
|
||||
{
|
||||
class WebDriver
|
||||
{
|
||||
namespace Deposits.SubDep {
|
||||
class WebDriver {
|
||||
FirefoxOptions options = new();
|
||||
FirefoxProfile profile = new();
|
||||
FirefoxDriver Driver;
|
||||
private void SetProfile()
|
||||
{
|
||||
public FirefoxDriver Driver;
|
||||
private void SetProfile() {
|
||||
this.profile.SetPreference("browser.download.folderList", 2);
|
||||
this.profile.SetPreference("browser.download.manager.showWhenStarting", false);
|
||||
this.profile.SetPreference("browser.download.dir", "D:/Neutral Folder/");
|
||||
@@ -15,15 +12,20 @@ namespace Deposits.SubDep
|
||||
this.profile.SetPreference("browser.helperApps.neverAsk.openFile", "application/PDF, application/FDF, application/XFDF, application/LSL, application/LSO, application/LSS, application/IQY, application/RQY, application/XLK, application/XLS, application/XLT, application/POT application/PPS, application/PPT, application/DOS, application/DOT, application/WKS, application/BAT, application/PS, application/EPS, application/WCH, application/WCM, application/WB1, application/WB3, application/RTF, application/DOC, application/MDB, application/MDE, application/WBK, application/WB1, application/WCH, application/WCM, application/AD, application/ADP, application/vnd.ms-excel");
|
||||
this.profile.SetPreference("browser.download.panel.shown", false);
|
||||
}
|
||||
private void SetOption()
|
||||
{
|
||||
private void SetOption() {
|
||||
this.options.Profile = this.profile;
|
||||
this.options.AddArgument("--lang=EN");
|
||||
}
|
||||
public WebDriver()
|
||||
{
|
||||
public WebDriver() {
|
||||
//System.IO.Path.Join("bins\\geckodriver.exe");
|
||||
this.Driver = new($"bins", options);
|
||||
}
|
||||
public void RunWeb(int timeToWait = 0, params string[] urls) {
|
||||
//System.Timers.Timer timer = new(timeToWait * 1000);
|
||||
foreach (var url in urls) {
|
||||
this.Driver.Url = url;
|
||||
System.Threading.Thread.Sleep(timeToWait * 1000);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
79
Deposits/app.manifest
Normal file
79
Deposits/app.manifest
Normal file
@@ -0,0 +1,79 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<assembly manifestVersion="1.0" xmlns="urn:schemas-microsoft-com:asm.v1">
|
||||
<assemblyIdentity version="1.0.0.0" name="MyApplication.app"/>
|
||||
<trustInfo xmlns="urn:schemas-microsoft-com:asm.v2">
|
||||
<security>
|
||||
<requestedPrivileges xmlns="urn:schemas-microsoft-com:asm.v3">
|
||||
<!-- UAC Manifest Options
|
||||
If you want to change the Windows User Account Control level replace the
|
||||
requestedExecutionLevel node with one of the following.
|
||||
|
||||
<requestedExecutionLevel level="asInvoker" uiAccess="false" />
|
||||
<requestedExecutionLevel level="requireAdministrator" uiAccess="false" />
|
||||
<requestedExecutionLevel level="highestAvailable" uiAccess="false" />
|
||||
|
||||
Specifying requestedExecutionLevel element will disable file and registry virtualization.
|
||||
Remove this element if your application requires this virtualization for backwards
|
||||
compatibility.
|
||||
-->
|
||||
<requestedExecutionLevel level="requireAdministrator" uiAccess="false" />
|
||||
</requestedPrivileges>
|
||||
</security>
|
||||
</trustInfo>
|
||||
|
||||
<compatibility xmlns="urn:schemas-microsoft-com:compatibility.v1">
|
||||
<application>
|
||||
<!-- A list of the Windows versions that this application has been tested on
|
||||
and is designed to work with. Uncomment the appropriate elements
|
||||
and Windows will automatically select the most compatible environment. -->
|
||||
|
||||
<!-- Windows Vista -->
|
||||
<!--<supportedOS Id="{e2011457-1546-43c5-a5fe-008deee3d3f0}" />-->
|
||||
|
||||
<!-- Windows 7 -->
|
||||
<!--<supportedOS Id="{35138b9a-5d96-4fbd-8e2d-a2440225f93a}" />-->
|
||||
|
||||
<!-- Windows 8 -->
|
||||
<!--<supportedOS Id="{4a2f28e3-53b9-4441-ba9c-d69d4a4a6e38}" />-->
|
||||
|
||||
<!-- Windows 8.1 -->
|
||||
<!--<supportedOS Id="{1f676c76-80e1-4239-95bb-83d0f6d0da78}" />-->
|
||||
|
||||
<!-- Windows 10 -->
|
||||
<!--<supportedOS Id="{8e0f7a12-bfb3-4fe8-b9a5-48fd50a15a9a}" />-->
|
||||
|
||||
</application>
|
||||
</compatibility>
|
||||
|
||||
<!-- Indicates that the application is DPI-aware and will not be automatically scaled by Windows at higher
|
||||
DPIs. Windows Presentation Foundation (WPF) applications are automatically DPI-aware and do not need
|
||||
to opt in. Windows Forms applications targeting .NET Framework 4.6 that opt into this setting, should
|
||||
also set the 'EnableWindowsFormsHighDpiAutoResizing' setting to 'true' in their app.config.
|
||||
|
||||
Makes the application long-path aware. See https://docs.microsoft.com/windows/win32/fileio/maximum-file-path-limitation -->
|
||||
<!--
|
||||
<application xmlns="urn:schemas-microsoft-com:asm.v3">
|
||||
<windowsSettings>
|
||||
<dpiAware xmlns="http://schemas.microsoft.com/SMI/2005/WindowsSettings">true</dpiAware>
|
||||
<longPathAware xmlns="http://schemas.microsoft.com/SMI/2016/WindowsSettings">true</longPathAware>
|
||||
</windowsSettings>
|
||||
</application>
|
||||
-->
|
||||
|
||||
<!-- Enable themes for Windows common controls and dialogs (Windows XP and later) -->
|
||||
<!--
|
||||
<dependency>
|
||||
<dependentAssembly>
|
||||
<assemblyIdentity
|
||||
type="win32"
|
||||
name="Microsoft.Windows.Common-Controls"
|
||||
version="6.0.0.0"
|
||||
processorArchitecture="*"
|
||||
publicKeyToken="6595b64144ccf1df"
|
||||
language="*"
|
||||
/>
|
||||
</dependentAssembly>
|
||||
</dependency>
|
||||
-->
|
||||
|
||||
</assembly>
|
Reference in New Issue
Block a user