• R/O
  • SSH
  • HTTPS

mantisbtmonitor: Commit


Commit MetaInfo

Revision27 (tree)
Time2017-09-07 06:32:13
Authorderekwildstar

Log Message

- Anexação de arquivos funcional! :)

Change Summary

Incremental Difference

--- trunk/client/prj/MantisNotification.bdsproj (revision 26)
+++ trunk/client/prj/MantisNotification.bdsproj (revision 27)
@@ -150,7 +150,7 @@
150150 <VersionInfo Name="MajorVer">1</VersionInfo>
151151 <VersionInfo Name="MinorVer">2</VersionInfo>
152152 <VersionInfo Name="Release">3</VersionInfo>
153- <VersionInfo Name="Build">543</VersionInfo>
153+ <VersionInfo Name="Build">570</VersionInfo>
154154 <VersionInfo Name="Debug">False</VersionInfo>
155155 <VersionInfo Name="PreRelease">False</VersionInfo>
156156 <VersionInfo Name="Special">False</VersionInfo>
@@ -162,7 +162,7 @@
162162 <VersionInfoKeys>
163163 <VersionInfoKeys Name="CompanyName"></VersionInfoKeys>
164164 <VersionInfoKeys Name="FileDescription"></VersionInfoKeys>
165- <VersionInfoKeys Name="FileVersion">1.2.3.543</VersionInfoKeys>
165+ <VersionInfoKeys Name="FileVersion">1.2.3.570</VersionInfoKeys>
166166 <VersionInfoKeys Name="InternalName"></VersionInfoKeys>
167167 <VersionInfoKeys Name="LegalCopyright"></VersionInfoKeys>
168168 <VersionInfoKeys Name="LegalTrademarks"></VersionInfoKeys>
--- trunk/client/res/Attachments.xml (revision 26)
+++ trunk/client/res/Attachments.xml (revision 27)
@@ -1 +1 @@
1-<?xml version="1.0" standalone="yes"?> <DATAPACKET Version="2.0"><METADATA><FIELDS><FIELD attrname="Id" fieldtype="i4"/><FIELD attrname="Filename" fieldtype="string" WIDTH="250"/><FIELD attrname="Date" fieldtype="date"/><FIELD attrname="FileSize" fieldtype="i4"/></FIELDS><PARAMS/></METADATA><ROWDATA><ROW Id="36051" Filename="PrototipoTelaUniversalFinanceiro.zip" Date="20170330" FileSize="639521"/><ROW Id="36050" Filename="PrototipoTelaUnivFinanc.png" Date="20170330" FileSize="122228"/><ROW Id="36049" Filename="TelaTJPEConsig.png" Date="20170330" FileSize="16943"/><ROW Id="36048" Filename="TelaPensionistas.png" Date="20170330" FileSize="20352"/><ROW Id="36047" Filename="TelaEntradaGenerica.png" Date="20170330" FileSize="19457"/><ROW Id="36046" Filename="TelaDescontoSassepe.png" Date="20170330" FileSize="18903"/><ROW Id="36045" Filename="TelaAtivosInativos.png" Date="20170330" FileSize="18734"/><ROW Id="36041" Filename="ImagensUniversalFinanceiro.zip" Date="20170330" FileSize="289248"/></ROWDATA></DATAPACKET>
\ No newline at end of file
1+<?xml version="1.0" standalone="yes"?> <DATAPACKET Version="2.0"><METADATA><FIELDS><FIELD attrname="Id" fieldtype="i4"/><FIELD attrname="Filename" fieldtype="string" WIDTH="250"/><FIELD attrname="Date" fieldtype="dateTime"/><FIELD attrname="FileSize" fieldtype="i4"/></FIELDS><PARAMS/></METADATA><ROWDATA><ROW Id="36051" Filename="PrototipoTelaUniversalFinanceiro.zip" Date="20170330" FileSize="639521"/><ROW Id="36050" Filename="PrototipoTelaUnivFinanc.png" Date="20170330" FileSize="122228"/><ROW Id="36049" Filename="TelaTJPEConsig.png" Date="20170330" FileSize="16943"/><ROW Id="36048" Filename="TelaPensionistas.png" Date="20170330" FileSize="20352"/><ROW Id="36047" Filename="TelaEntradaGenerica.png" Date="20170330" FileSize="19457"/><ROW Id="36046" Filename="TelaDescontoSassepe.png" Date="20170330" FileSize="18903"/><ROW Id="36045" Filename="TelaAtivosInativos.png" Date="20170330" FileSize="18734"/><ROW Id="36041" Filename="ImagensUniversalFinanceiro.zip" Date="20170330" FileSize="289248"/></ROWDATA></DATAPACKET>
\ No newline at end of file
--- trunk/client/src/lib/UFunctions.pas (revision 26)
+++ trunk/client/src/lib/UFunctions.pas (revision 27)
@@ -19,12 +19,13 @@
1919 function DecodeIssueInfo(AIssueData: String): TIssueInfo;
2020 procedure OpenIssueWithMantis(AIssueNumber: Cardinal);
2121 procedure DownloadAttachment(AAttachmentId: Cardinal; AFileName: String; AOpen: Boolean = True);
22+function UploadAttachment(AIssueNumber: Cardinal; AFileName: String): Cardinal;
2223
2324 implementation
2425
2526 uses
2627 Windows, Classes, SysUtils, ShellApi, EncdDecd, UMNWSWrapperFunctions, Forms,
27- Controls;
28+ Controls, UConfigurations, IdGlobalProtocols;
2829
2930 procedure OpenIssueWithMantis(AIssueNumber: Cardinal);
3031 const
@@ -85,10 +86,42 @@
8586 end;
8687
8788 if AOpen then
88- begin
8989 ShellExecute(0, 'open', PChar(AFileName), nil, nil, SW_SHOWNORMAL);
90+end;
9091
91- end;
92+function UploadAttachment(AIssueNumber: Cardinal; AFileName: String): Cardinal;
93+var
94+ SS: TStringStream;
95+ FS: TFileStream;
96+ MimeType: String;
97+ FileContents: String;
98+begin
99+ with TIdMimeTable.Create(False) do
100+ try
101+ MimeType := GetFileMIMEType(AFileName);
102+ finally
103+ Free;
104+ end;
105+
106+ FS := TFileStream.Create(AFileName,fmOpenRead or fmShareExclusive);
107+ try
108+ SS := TStringStream.Create('');
109+ try
110+ SS.CopyFrom(FS,FS.Size);
111+ FileContents := EncodeString(SS.DataString);
112+ finally
113+ SS.Free;
114+ end;
115+ finally
116+ FS.Free;
117+ end;
118+
119+ Result := AddAttachment(Configurations.UserName
120+ ,Configurations.Password
121+ ,AIssueNumber
122+ ,ExtractFileName(AFileName)
123+ ,MimeType
124+ ,FileContents);
92125 end;
93126
94127 end.
--- trunk/client/src/lib/UMNWSWrapperFunctions.pas (revision 26)
+++ trunk/client/src/lib/UMNWSWrapperFunctions.pas (revision 27)
@@ -18,12 +18,12 @@
1818 function GetIssueInfo(AIssueNumber: Cardinal): String;
1919 function GetAttachments(AIssueNumber: Cardinal; AClientDataSet: TClientDataSet): Boolean;
2020 function GetAttachmentData(AAttachmentId: Cardinal): String;
21+function AddAttachment(AUserName: String; APassword: String; AIssueId: Cardinal; AFileName: String; AMimeType: String; ABase64Contents: String): Cardinal;
2122
22-
2323 implementation
2424
2525 uses
26- mnws, Windows, SysUtils, Classes, XMLXForm;
26+ mnws, Windows, SysUtils, Classes, XMLXForm, IdGlobalProtocols;
2727
2828 function Login(PUserName, PPassword: String): TUserInfo;
2929 var
@@ -49,7 +49,6 @@
4949
5050 function UserIssues(AUserId: Integer): String;
5151 begin
52-// ZeroMemory(@Result,SizeOf(TUserInfo));
5352 Result := GetmnwsPortType.userIssues(AUserId);
5453 end;
5554
@@ -110,7 +109,27 @@
110109 Result := GetmnwsPortType.getAttachmentData(AAttachmentId);
111110 end;
112111
112+function AddAttachment(AUserName: String; APassword: String; AIssueId: Cardinal; AFileName: String; AMimeType: String; ABase64Contents: String): Cardinal;
113+var
114+ Retorno: String;
115+begin
116+ // Erros genéricos: Exceções levantadas e que não foram tratadas no servidor
117+ try
118+ Retorno := GetmnwsPortType.addAttachment(AUserName, APassword, AIssueId, AFileName, AMimeType, ABase64Contents);
119+ except
120+ on E: Exception do
121+ raise Exception.Create('Ocorreu um erro ao anexar o arquivo. A mensagem de erro foi: '#13#10#13#10 + E.Message);
122+ end;
113123
124+ // Erros do serviço: Exceções levantadas e que foram tratadas no servidor
125+ try
126+ Result := StrToInt(Retorno);
127+ except
128+ on E: Exception do
129+ raise Exception.Create('Ocorreu um erro ao anexar o arquivo. O Webservice retornou a seguinte mensagem de erro: '#13#10#13#10 + Retorno);
130+ end;
131+end;
132+
114133 initialization
115134
116135 end.
--- trunk/client/src/lib/mnws.pas (revision 26)
+++ trunk/client/src/lib/mnws.pas (revision 27)
@@ -4,7 +4,7 @@
44 // WSDL : http://192.168.251.88/mnws/index.php?wsdl
55 // Encoding : UTF-8
66 // Version : 1.0
7-// (30/08/2017 16:19:30 - 1.33.2.5)
7+// (06/09/2017 15:56:04 - 1.33.2.5)
88 // ************************************************************************ //
99
1010 unit mnws;
@@ -45,6 +45,7 @@
4545 function getStatuses: WideString; stdcall;
4646 function getAttachments(const aIssueId: integer): WideString; stdcall;
4747 function getAttachmentData(const aAttachmentId: integer): WideString; stdcall;
48+ function addAttachment(const aUserName: WideString; const aPassword: WideString; const aIssueId: integer; const aFileName: WideString; const aMimeType: WideString; const aBase64Contents: WideString): WideString; stdcall;
4849 end;
4950
5051 function GetmnwsPortType(UseWSDL: Boolean=System.False; Addr: string=''; HTTPRIO: THTTPRIO = nil): mnwsPortType;
--- trunk/client/src/UFormIssue.pas (revision 26)
+++ trunk/client/src/UFormIssue.pas (revision 27)
@@ -56,12 +56,16 @@
5656 KRDGAttachments: TKRKDBGrid;
5757 PAABAttachments: TPopupActionBar;
5858 MNUIDownloadAttachment: TMenuItem;
59+ MNUIDownloadAndOpen: TMenuItem;
60+ SADIAttachment: TSaveDialog;
61+ MNUIN1: TMenuItem;
62+ MNUIAttachNew: TMenuItem;
63+ OPDIAttachment: TOpenDialog;
5964 CLDSAttachmentsId: TIntegerField;
6065 CLDSAttachmentsFilename: TStringField;
61- CLDSAttachmentsDate: TDateField;
66+ CLDSAttachmentsDate: TDateTimeField;
6267 CLDSAttachmentsFileSize: TIntegerField;
63- MNUIDownloadAndOpen: TMenuItem;
64- SADIAttachment: TSaveDialog;
68+ procedure MNUIAttachNewClick(Sender: TObject);
6569 procedure MNUIDownloadAndOpenClick(Sender: TObject);
6670 procedure MNUIDownloadAttachmentClick(Sender: TObject);
6771 procedure KRDGRelatedIssuesDrawColumnCell(Sender: TObject;
@@ -201,6 +205,16 @@
201205 GetRelatedIssues(FIssueInfo.Id,CLDSRelatedIssues);
202206 end;
203207
208+procedure TFormIssue.MNUIAttachNewClick(Sender: TObject);
209+begin
210+ inherited;
211+ if OPDIAttachment.Execute then
212+ begin
213+ UploadAttachment(FIssueInfo.Id,OPDIAttachment.FileName);
214+ LoadAttachments;
215+ end;
216+end;
217+
204218 procedure TFormIssue.MNUIDownloadAndOpenClick(Sender: TObject);
205219 begin
206220 inherited;
Show on old repository browser