TraningControlPlugin изменения
This commit is contained in:
parent
1392b3b93f
commit
8d3e51f798
|
|
@ -15,7 +15,7 @@ internal static class RevisionClass
|
|||
public const string Major = "3";
|
||||
public const string Minor = "8";
|
||||
public const string Build = "3";
|
||||
public const string Revision = "3154";
|
||||
public const string Revision = "3158";
|
||||
|
||||
public const string MainVersion = Major + "." + Minor;
|
||||
public const string FullVersion = Major + "." + Minor + "." + Build + "." + Revision;
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
%COREVERSION%=3
|
||||
%REVISION%=3154
|
||||
%REVISION%=3158
|
||||
%MINOR%=8
|
||||
%MAJOR%=3
|
||||
|
|
|
|||
|
|
@ -485,6 +485,7 @@ namespace VisualPascalABCPlugins
|
|||
|
||||
public interface ICompilerConsoleWindow
|
||||
{
|
||||
void AddTextToCompilerMessages(string text);
|
||||
void ClearConsole();
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -477,6 +477,7 @@ namespace VisualPascalABCPlugins
|
|||
|
||||
public interface ICompilerConsoleWindow
|
||||
{
|
||||
void AddTextToCompilerMessages(string text);
|
||||
void ClearConsole();
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1 +1 @@
|
|||
3.8.3.3154
|
||||
3.8.3.3158
|
||||
|
|
|
|||
|
|
@ -1 +1 @@
|
|||
!define VERSION '3.8.3.3154'
|
||||
!define VERSION '3.8.3.3158'
|
||||
|
|
|
|||
|
|
@ -42,8 +42,9 @@ namespace DBAccessPluginNamespace
|
|||
sw.WriteLine(pass);
|
||||
}*/
|
||||
}
|
||||
catch (Exception)
|
||||
catch (Exception e)
|
||||
{
|
||||
Plugin.AddMessage(e);
|
||||
res = false;
|
||||
}
|
||||
return res;
|
||||
|
|
@ -59,7 +60,10 @@ namespace DBAccessPluginNamespace
|
|||
if (full == root)
|
||||
isroot = true;
|
||||
}
|
||||
catch { }
|
||||
catch (Exception e)
|
||||
{
|
||||
Plugin.AddMessage(e);
|
||||
}
|
||||
return isroot;
|
||||
}
|
||||
|
||||
|
|
@ -75,7 +79,10 @@ namespace DBAccessPluginNamespace
|
|||
parent = Directory.GetParent(full).FullName;
|
||||
hasparent = true;
|
||||
}
|
||||
catch { }
|
||||
catch (Exception e)
|
||||
{
|
||||
Plugin.AddMessage(e);
|
||||
}
|
||||
return hasparent;
|
||||
}
|
||||
|
||||
|
|
@ -202,8 +209,7 @@ namespace DBAccessPluginNamespace
|
|||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
MessageBox.Show(e.ToString());
|
||||
e = e;
|
||||
Plugin.AddMessage(e);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -256,7 +262,7 @@ namespace DBAccessPluginNamespace
|
|||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
MessageBox.Show(ex.ToString());
|
||||
Plugin.AddMessage(ex);
|
||||
}
|
||||
}
|
||||
else
|
||||
|
|
@ -291,7 +297,7 @@ namespace DBAccessPluginNamespace
|
|||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
MessageBox.Show(ex.ToString());
|
||||
Plugin.AddMessage(ex);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -321,7 +327,7 @@ namespace DBAccessPluginNamespace
|
|||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
MessageBox.Show(ex.ToString());
|
||||
Plugin.AddMessage(ex);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -45,6 +45,7 @@ namespace VisualPascalABCPlugins
|
|||
loginForm = new LoginForm(this);
|
||||
this.Workbench = Workbench;
|
||||
VisualEnvironmentCompiler = Workbench.VisualEnvironmentCompiler;
|
||||
//Workbench.CompilerConsoleWindow.
|
||||
//var tbitem = Workbench.MainForm.Controls.Find("", true);
|
||||
// RegisterForm.VisualEnvironmentCompiler = VisualEnvironmentCompiler; // Пока форма регистрации никак не связана с компилятором
|
||||
|
||||
|
|
@ -55,18 +56,7 @@ namespace VisualPascalABCPlugins
|
|||
public void Execute()
|
||||
{
|
||||
loginForm.SiteProvider = User;
|
||||
|
||||
loginForm.ShowDialog(); // OK никогда не будет
|
||||
/*if (loginForm.Authorized)
|
||||
{
|
||||
toolStripButton.ToolTipText = "Авторизация выполнена";
|
||||
toolStripButton.Image = loginForm.PluginImageAuthorized.Image;
|
||||
}
|
||||
else
|
||||
{
|
||||
toolStripButton.ToolTipText = "Авторизация: вход не выполнен";
|
||||
toolStripButton.Image = loginForm.PluginImage.Image;
|
||||
}*/
|
||||
}
|
||||
|
||||
public string FullAuthNameFromNETDisk()
|
||||
|
|
@ -84,12 +74,19 @@ namespace VisualPascalABCPlugins
|
|||
authName = auth;
|
||||
}
|
||||
}
|
||||
catch (Exception)
|
||||
catch (Exception e)
|
||||
{
|
||||
AddMessage(e);
|
||||
}
|
||||
return authName;
|
||||
}
|
||||
|
||||
public void AddMessage(string text)
|
||||
{
|
||||
Workbench.CompilerConsoleWindow.AddTextToCompilerMessages(text + Environment.NewLine);
|
||||
}
|
||||
public void AddMessage(Exception e) => AddMessage(e.ToString());
|
||||
|
||||
public string WorkingDirectory()
|
||||
{
|
||||
var FileName = Workbench.ServiceContainer.DocumentService.CurrentCodeFileDocument.FileName;
|
||||
|
|
@ -107,10 +104,18 @@ namespace VisualPascalABCPlugins
|
|||
|
||||
public /*async*/ void TryLogin(string login, string pass)
|
||||
{
|
||||
var answer = User.Login("", login, pass);
|
||||
if (answer.Result == "Success")
|
||||
// Гасим все исключения
|
||||
try
|
||||
{
|
||||
loginForm.ChangeControlsAfterLogin(login);
|
||||
var answer = User.Login("", login, pass);
|
||||
if (answer.Result == "Success")
|
||||
{
|
||||
loginForm.ChangeControlsAfterLogin(login);
|
||||
}
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
AddMessage(e);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -168,22 +173,37 @@ namespace VisualPascalABCPlugins
|
|||
|
||||
string[] ReadLoginPassFromAuth(string AuthFileFullName)
|
||||
{
|
||||
var n = 10000;
|
||||
var arr = new byte[n];
|
||||
int nbytes;
|
||||
using (var fs = new FileStream(AuthFileFullName, FileMode.Open))
|
||||
{
|
||||
nbytes = fs.Read(arr, 0, n);
|
||||
string[] lparr = new string[0];
|
||||
try
|
||||
{
|
||||
var n = 10000;
|
||||
var arr = new byte[n];
|
||||
int nbytes;
|
||||
// Здесь может быть ьисключение если с файлом или путем проблемы
|
||||
using (var fs = new FileStream(AuthFileFullName, FileMode.Open))
|
||||
{
|
||||
nbytes = fs.Read(arr, 0, n);
|
||||
}
|
||||
var data = new byte[nbytes];
|
||||
System.Array.Copy(arr, data, nbytes);
|
||||
// Здесь может быть исключение если ключ неправильный
|
||||
var lp = LoginUtils.Decrypt(data);
|
||||
lparr = lp.Split((char)10);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
AddMessage(e);
|
||||
}
|
||||
var data = new byte[nbytes];
|
||||
System.Array.Copy(arr, data, nbytes);
|
||||
var lp = LoginUtils.Decrypt(data);
|
||||
var lparr = lp.Split((char)10);
|
||||
return lparr;
|
||||
}
|
||||
|
||||
public void AfterAddInGUI()
|
||||
{
|
||||
if (Item == null)
|
||||
{
|
||||
AddMessage("Плагин Teacher Control отключён. Не выполнено условие LightPTExists || AuthExists");
|
||||
return;
|
||||
}
|
||||
menuItem = (ToolStripMenuItem)Item.menuItem;
|
||||
toolStripButton = (ToolStripButton)Item.toolStripButton;
|
||||
// Попытка выполнить автоматический вход из информации в auth.dat
|
||||
|
|
@ -224,13 +244,14 @@ namespace VisualPascalABCPlugins
|
|||
{
|
||||
var login = ss[0];
|
||||
var pass = ss[1];
|
||||
// В TryLogin может быть исключение, которое не перехватывается этим кодом, т.к.в другом потоке
|
||||
System.Threading.Tasks.Task.Run(() => TryLogin(login, pass));
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
e = e;
|
||||
AddMessage(e);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -63,14 +63,15 @@ type
|
|||
client.Timeout := TimeSpan.FromSeconds(10);
|
||||
end;
|
||||
|
||||
function SendPostRequest(FullFIO, Password, LessonName, TaskName, TaskStatus: string): Task<string>;
|
||||
function SendPostRequest(FullFIO, Password, LessonName, TaskName, TaskResult, TaskResultInfo: string): Task<string>;
|
||||
begin
|
||||
var values := Dict(
|
||||
( 'shortFIO', '' ),
|
||||
( 'FIO', FullFIO ),
|
||||
( 'taskName', TaskName ),
|
||||
( 'lessonName', LessonName ),
|
||||
( 'type', TaskStatus ),
|
||||
( 'type', TaskResult ),
|
||||
( 'resultInfo', TaskResultInfo ),
|
||||
( 'content', '' ),
|
||||
( 'password', Password )
|
||||
);
|
||||
|
|
@ -233,7 +234,6 @@ function Encrypt(src: string): array of byte; // записать в файл
|
|||
begin
|
||||
var ae := Aes.Create();
|
||||
var key := Encoding.UTF8.GetBytes(ProcessorId);
|
||||
var encrypted: array of byte;
|
||||
var crypt := ae.CreateEncryptor(key, key);
|
||||
var ms := new MemoryStream();
|
||||
var cs := new CryptoStream(ms, crypt, CryptoStreamMode.Write);
|
||||
|
|
@ -254,7 +254,6 @@ begin
|
|||
end;
|
||||
var ae := Aes.Create();
|
||||
var key := Encoding.UTF8.GetBytes(ProcessorId);
|
||||
var encrypted: array of byte;
|
||||
var crypt := ae.CreateDecryptor(key, key);
|
||||
var ms := new MemoryStream(data);
|
||||
var cs := new CryptoStream(ms, crypt, CryptoStreamMode.Read);
|
||||
|
|
@ -1102,12 +1101,27 @@ begin
|
|||
WriteInfoCallBack(LessonName,TName, TaskResult, TaskResultInfo);
|
||||
end;
|
||||
|
||||
procedure WriteInfoToLocalDatabase(LessonName,TaskName: string; result: TaskStatus; AdditionalInfo: string := '');
|
||||
procedure WriteInfoToDatabases(LessonName,TaskName: string; TaskResult: TaskStatus; AdditionalInfo: string := '');
|
||||
begin
|
||||
try
|
||||
System.IO.File.AppendAllText('db.txt', $'{LessonName} {TaskName} {dateTime.Now.ToString(''u'')} {Result.ToString} {AdditionalInfo}' + #10);
|
||||
System.IO.File.AppendAllText('db.txt', $'{LessonName} {TaskName} {dateTime.Now.ToString(''u'')} {TaskResult.ToString} {AdditionalInfo}' + #10);
|
||||
var auth := FindAuthDat;
|
||||
// Console.WriteLine(auth);
|
||||
// Считать логин пароль из auth
|
||||
var f: file of byte;
|
||||
Reset(f,auth);
|
||||
var data := f.Elements.ToArray;
|
||||
var arr := Decrypt(data).Split(#10);
|
||||
var login,pass: string;
|
||||
if arr.Length >= 2 then
|
||||
begin
|
||||
login := arr[0];
|
||||
pass := arr[1];
|
||||
// Теперь как-то записать в БД информацию
|
||||
var User := new ServerAccessProvider(ServerAddr);
|
||||
var t2 := User.SendPostRequest(login, pass, LessonName, TaskName, TaskResult.ToString, AdditionalInfo);
|
||||
var v := t2.Result;
|
||||
//Console.WriteLine(v);
|
||||
end;
|
||||
except
|
||||
on e: Exception do
|
||||
Console.WriteLine(e.Message);
|
||||
|
|
@ -1150,7 +1164,7 @@ initialization
|
|||
var tn := TypeName(CurrentIOSystem);
|
||||
if (tn = 'IOStandardSystem') or (tn = '__ReadSignalOISystem') or (tn = 'IOGraphABCSystem') then
|
||||
CurrentIOSystem := new IOLightSystem;
|
||||
WriteInfoCallBack := WriteInfoToLocalDatabase;
|
||||
WriteInfoCallBack := WriteInfoToDatabases;
|
||||
// Расшифровка LightPT.dat
|
||||
LoadLightPTInfo;
|
||||
finalization
|
||||
|
|
|
|||
Loading…
Reference in a new issue