TeacherControlPlugin.cs - шифрованные модули
This commit is contained in:
parent
ba23a01e29
commit
ee31ed94b3
|
|
@ -15,7 +15,7 @@ internal static class RevisionClass
|
|||
public const string Major = "3";
|
||||
public const string Minor = "10";
|
||||
public const string Build = "3";
|
||||
public const string Revision = "3616";
|
||||
public const string Revision = "3617";
|
||||
|
||||
public const string MainVersion = Major + "." + Minor;
|
||||
public const string FullVersion = Major + "." + Minor + "." + Build + "." + Revision;
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
%COREVERSION%=3
|
||||
%REVISION%=3616
|
||||
%MINOR%=10
|
||||
%REVISION%=3617
|
||||
%COREVERSION%=3
|
||||
%MAJOR%=3
|
||||
|
|
|
|||
|
|
@ -111,6 +111,9 @@ namespace VisualPascalABCPlugins
|
|||
}
|
||||
|
||||
public delegate IAsyncResult InvokeDegegate(Delegate method, params object[] args);
|
||||
|
||||
public delegate string ConvertTextDelegate(string FileName, string text); // Ýòî ïîêà òîëüêî äëÿ øèôðîâàííîãî Tasks.
|
||||
|
||||
public interface IVisualEnvironmentCompiler
|
||||
{
|
||||
PascalABCCompiler.ICompiler Compiler
|
||||
|
|
@ -143,7 +146,7 @@ namespace VisualPascalABCPlugins
|
|||
{
|
||||
get;
|
||||
}
|
||||
|
||||
ConvertTextDelegate ConvertUnitTextProperty { get; set; }
|
||||
}
|
||||
|
||||
public interface ICodeFileDocument
|
||||
|
|
|
|||
|
|
@ -1 +1 @@
|
|||
3.10.3.3616
|
||||
3.10.3.3617
|
||||
|
|
|
|||
|
|
@ -1 +1 @@
|
|||
!define VERSION '3.10.3.3616'
|
||||
!define VERSION '3.10.3.3617'
|
||||
|
|
|
|||
|
|
@ -610,6 +610,9 @@ procedure SetMessagesOn;
|
|||
/// Выключить дополнительные сообщения о записи в удаленную базу данных
|
||||
procedure SetMessageOff;
|
||||
|
||||
/// Шифрование строки
|
||||
function EncryptString(src: string): string;
|
||||
|
||||
implementation
|
||||
|
||||
uses __RedirectIOMode;
|
||||
|
|
@ -1041,6 +1044,12 @@ begin
|
|||
Result := ms.ToArray;
|
||||
end;
|
||||
|
||||
function EncryptString(src: string): string;
|
||||
begin
|
||||
var bytes := Encrypt(src);
|
||||
Result := Convert.ToBase64String(bytes);
|
||||
end;
|
||||
|
||||
function Decrypt(data: array of byte): string;
|
||||
begin
|
||||
if data = nil then
|
||||
|
|
|
|||
|
|
@ -34,6 +34,8 @@ namespace VisualPascalABC
|
|||
public delegate void SetFlagDelegate(bool flag);
|
||||
private SetFlagDelegate SetCompilingButtonsEnabled;
|
||||
private SetFlagDelegate SetDebugButtonsEnabled;
|
||||
public ConvertTextDelegate ConvertUnitTextProperty { get; set; }
|
||||
|
||||
public delegate void SetTextDelegate(string text);
|
||||
private SetTextDelegate SetStateText;
|
||||
private SetTextDelegate AddTextToCompilerMessages;
|
||||
|
|
@ -247,13 +249,21 @@ namespace VisualPascalABC
|
|||
{
|
||||
case PascalABCCompiler.SourceFileOperation.GetText:
|
||||
if (tp != null)
|
||||
return ed.Document.TextContent;
|
||||
{
|
||||
string Text1 = ed.Document.TextContent;
|
||||
if (ConvertUnitTextProperty != null)
|
||||
Text1 = ConvertUnitTextProperty(FileName, Text1);
|
||||
return Text1;
|
||||
}
|
||||
|
||||
if (!File.Exists(FileName))
|
||||
return null;
|
||||
/*TextReader tr = new StreamReader(file_name, System.Text.Encoding.GetEncoding(1251));
|
||||
string Text = tr.ReadToEnd();
|
||||
tr.Close();*/
|
||||
string Text = PascalABCCompiler.FileReader.ReadFileContent(FileName, null);
|
||||
if (ConvertUnitTextProperty != null)
|
||||
Text = ConvertUnitTextProperty(FileName, Text);
|
||||
return Text;
|
||||
case PascalABCCompiler.SourceFileOperation.Exists:
|
||||
if (tp != null)
|
||||
|
|
|
|||
|
|
@ -34,6 +34,7 @@ namespace VisualPascalABC
|
|||
private SetFlagDelegate SetCompilingButtonsEnabled;
|
||||
private SetFlagDelegate SetDebugButtonsEnabled;
|
||||
public delegate void SetTextDelegate(string text);
|
||||
public delegate string ConvertUnitText(string FileName, string text); // Это пока только для шифрованного Tasks. В остальных случаях он нулевой
|
||||
private SetTextDelegate SetStateText;
|
||||
private SetTextDelegate AddTextToCompilerMessages;
|
||||
private bool Compilation = false;
|
||||
|
|
@ -249,9 +250,6 @@ namespace VisualPascalABC
|
|||
return ed.Document.TextContent;
|
||||
if (!File.Exists(FileName))
|
||||
return null;
|
||||
/*TextReader tr = new StreamReader(file_name, System.Text.Encoding.GetEncoding(1251));
|
||||
string Text = tr.ReadToEnd();
|
||||
tr.Close();*/
|
||||
string Text = PascalABCCompiler.FileReader.ReadFileContent(FileName, null);
|
||||
return Text;
|
||||
case PascalABCCompiler.SourceFileOperation.Exists:
|
||||
|
|
|
|||
|
|
@ -4,6 +4,8 @@ using System.Windows.Forms;
|
|||
using System.IO;
|
||||
using VisualPascalABCPlugins.DBAccess;
|
||||
using PascalABCCompiler;
|
||||
using System.Linq;
|
||||
using static System.Net.Mime.MediaTypeNames;
|
||||
|
||||
namespace VisualPascalABCPlugins
|
||||
{
|
||||
|
|
@ -53,6 +55,23 @@ namespace VisualPascalABCPlugins
|
|||
TryChangeServerAddress(ref ServerAddress);
|
||||
User.ServAddr = ServerAddress;
|
||||
loginForm = new LoginForm(this);
|
||||
VisualEnvironmentCompiler.ConvertUnitTextProperty = (FileName, Text) =>
|
||||
{
|
||||
string fname = Path.GetFileNameWithoutExtension(FileName);
|
||||
if (fname == "Tasks")
|
||||
{
|
||||
int newLinePos = Text.IndexOf('\n');
|
||||
string firstLine = newLinePos == -1 ? Text : Text.Substring(0, newLinePos);
|
||||
if (firstLine.Contains("encrypted"))
|
||||
{
|
||||
string remainingText = Text.Substring(newLinePos + 1);
|
||||
Text = TeacherPluginUtils.DecryptString(remainingText);
|
||||
}
|
||||
|
||||
return Text;
|
||||
}
|
||||
return Text;
|
||||
};
|
||||
}
|
||||
// RegisterForm.VisualEnvironmentCompiler = VisualEnvironmentCompiler; // Пока форма регистрации никак не связана с компилятором
|
||||
|
||||
|
|
@ -63,24 +82,6 @@ namespace VisualPascalABCPlugins
|
|||
//Workbench.ServiceContainer.BuildService.BeforeCompile += BeforeCompileHandler;
|
||||
}
|
||||
|
||||
public object TeacherSourceFilesProvider(string FileName, SourceFileOperation FileOperation)
|
||||
{
|
||||
switch (FileOperation)
|
||||
{
|
||||
case SourceFileOperation.GetText:
|
||||
if (!File.Exists(FileName)) return null;
|
||||
string Text = FileReader.ReadFileContent(FileName, null);
|
||||
// Здесь можно дешифровать когда надо
|
||||
//File.AppendAllText("d:\\aaaa.txt", FileName + "\n");
|
||||
return Text;
|
||||
case SourceFileOperation.Exists:
|
||||
return File.Exists(FileName);
|
||||
case SourceFileOperation.GetLastWriteTime:
|
||||
return File.GetLastWriteTime(FileName);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public void Execute()
|
||||
{
|
||||
loginForm.SiteProvider = User;
|
||||
|
|
|
|||
|
|
@ -41,6 +41,12 @@ namespace VisualPascalABCPlugins
|
|||
}
|
||||
return encrypted;
|
||||
}
|
||||
public static string EncryptString(string src)
|
||||
{
|
||||
var bytes = Encrypt(src);
|
||||
return Convert.ToBase64String(bytes);
|
||||
}
|
||||
|
||||
|
||||
public static string Decrypt(byte[] data)
|
||||
{
|
||||
|
|
@ -59,6 +65,12 @@ namespace VisualPascalABCPlugins
|
|||
return text;
|
||||
}
|
||||
|
||||
public static string DecryptString(string data)
|
||||
{
|
||||
var bytes = Convert.FromBase64String(data);
|
||||
return Decrypt(bytes);
|
||||
}
|
||||
|
||||
public static string[] ReadLoginPassFromAuth(string AuthFileFullName)
|
||||
{
|
||||
// Исключения обрабатываются уровнем выше
|
||||
|
|
|
|||
|
|
@ -610,6 +610,9 @@ procedure SetMessagesOn;
|
|||
/// Выключить дополнительные сообщения о записи в удаленную базу данных
|
||||
procedure SetMessageOff;
|
||||
|
||||
/// Шифрование строки
|
||||
function EncryptString(src: string): string;
|
||||
|
||||
implementation
|
||||
|
||||
uses __RedirectIOMode;
|
||||
|
|
@ -1041,6 +1044,12 @@ begin
|
|||
Result := ms.ToArray;
|
||||
end;
|
||||
|
||||
function EncryptString(src: string): string;
|
||||
begin
|
||||
var bytes := Encrypt(src);
|
||||
Result := Convert.ToBase64String(bytes);
|
||||
end;
|
||||
|
||||
function Decrypt(data: array of byte): string;
|
||||
begin
|
||||
if data = nil then
|
||||
|
|
|
|||
Loading…
Reference in a new issue