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
|
// ---------------------------------------------------------------------------
/*
Classes utilisées pour la lecture des queues des thread
*/
// ---------------------------------------------------------------------------
// retourne la valeur de retour d'un thread
// 0 NOK et 1 OK
// class TNotifier : public TCppInterfacedObject<TThreadProcedure> {
// int lValue;
// private:
// TForm9* form;
// public:
// TNotifier(int ValSet, TForm9* _form) : lValue(ValSet), form(_form) {}
// INTFOBJECT_IMPL_IUNKNOWN(TInterfacedObject);
// void __fastcall Invoke() {}
// } ;
// ---------------------------------------------------------------------------
// Retourne la valeur des traces générées par les thread
class TLogMessage : public TCppInterfacedObject<Classes::TThreadProcedure> {
String Msg;
private:
TForm9* form;
String LogTime;
public:
TLogMessage(String _Msg, TForm9* _form) : Msg(_Msg), form(_form) {
}
INTFOBJECT_IMPL_IUNKNOWN(TInterfacedObject);
void __fastcall Invoke() {
AnsiString Funct, LineId, Resp, Status;
Funct = Msg.SubString(1, Msg.Pos(",") - 1);
Msg.Delete(1, Msg.Pos(","));
LineId = Msg.SubString(1, Msg.Pos(",") - 1);
Msg.Delete(1, Msg.Pos(","));
Resp = Msg.SubString(1, Msg.Pos(",") - 1);
Msg.Delete(1, Msg.Pos(","));
Status = Msg;
form->mLogger.FillStream(DateTimeToStr(Now()), Funct, LineId, Resp,
Status);
form->mLogger.Execute();
}
};
// ---------------------------------------------------------------------------
class THreadNotification
: public TCppInterfacedObject<Classes::TThreadProcedure> {
bool lValue;
private:
TForm9* form;
public:
THreadNotification(bool ValSet, TForm9* _form)
: lValue(ValSet), form(_form) {
}
INTFOBJECT_IMPL_IUNKNOWN(TInterfacedObject);
void __fastcall Invoke() {
form->NotifyResult(lValue);
}
};
// ---------------------------------------------------------------------------
class TErrorMessage : public TCppInterfacedObject<Classes::TThreadProcedure> {
String FErrorMsg1;
String FErrorMsg2;
private:
TForm9* form;
public:
TErrorMessage(String _EMsg1, String _EMsg2, TForm9* _form)
: FErrorMsg1(_EMsg1), FErrorMsg2(_EMsg2), form(_form) {
}
INTFOBJECT_IMPL_IUNKNOWN(TInterfacedObject);
void __fastcall Invoke() {
UnicodeString Ts;
Ts = DateTimeToStr(Now());
Ts += L" " + FErrorMsg1 + L" " + FErrorMsg2;
form->Memo1->Lines->Add(Ts);
if (!form->ChangeSize)
form->ChangeFormSize();
if (DataModule1->Enabled == true)
DataModule1->Enabled = false;
}
};
// ---------------------------------------------------------------------------
class THreadNotificationExcel
: public TCppInterfacedObject<Classes::TThreadProcedure> {
bool lValue;
TStringList* mList;
private:
TForm9* form;
public:
THreadNotificationExcel(bool ValSet, TStringList* _mlist, TForm9* _form)
: lValue(ValSet), mList(_mlist), form(_form) {
}
INTFOBJECT_IMPL_IUNKNOWN(TInterfacedObject);
void __fastcall Invoke() {
if (lValue)
form->MFieldsContent->Assign(mList);
else
form->MFieldsContent->Clear();
form->NotifyResultExcel(lValue);
}
}; |
Partager