Book a Demo

Author Topic: Add-In, C#, Audit View  (Read 7448 times)

carolin.boeckler

  • EA User
  • **
  • Posts: 34
  • Karma: +0/-0
    • View Profile
Add-In, C#, Audit View
« on: October 27, 2011, 01:09:39 am »
Hi, I create a pdf report with itextsharp in c# as an add-in.
I also want to include the parameters of audit view, but I don't know, how I can do this. With the following SQL
"SELECT * FROM t_snapshot WHERE Notes like '"+elem.ElementGUID+"*'"
I was able to get the elements, but I cannot read the answer.
In the xml Report is something like "<BinContent1 xmlns:dt="urn:schemas-microsoft-com:datatypes" dt:dt="bin.base64">" and the same with "<BinContent2 xmlns:dt="urn:schemas-microsoft-com:datatypes" dt:dt="bin.base64">". After base64tostring I can read BinContent2, there is written the author and the date of the last change.
Example: <metadata><Row Number="0" Standard="1"><Level LevelName="Requirement" Name="<<Functional>> Das System muss recyelbar sein" GUID="{E0835288-71E2-46b6-B0FC-338E918BC2D9}"/></Row><Details User="boeckcro" DateTime="2011-10-05 20:54:09"/></metadata>
 But BinContent1 I cannot read. After base64tostring there is only stupid things like "PKÒ¦E?žXùdstr.datUT...".
Does anybody has an idea if it is possible to read the changes of audit view?
Best regards, Caro

Geert Bellekens

  • EA Guru
  • *****
  • Posts: 13523
  • Karma: +574/-33
  • Make EA work for YOU!
    • View Profile
    • Enterprise Architect Consultant and Value Added Reseller
Re: Add-In, C#, Audit View
« Reply #1 on: October 27, 2011, 05:54:40 pm »
Caro,

I think it's zipped.

Geert

carolin.boeckler

  • EA User
  • **
  • Posts: 34
  • Karma: +0/-0
    • View Profile
Re: Add-In, C#, Audit View
« Reply #2 on: October 27, 2011, 07:17:01 pm »
Hi Geert,

I do not really believe this.

I tried already something. Let me explain:
Here is the interesting xml part after I use
string tt="SELECT * FROM t_snapshot WHERE Notes like '"+elem.ElementGUID+"*'";
string xml = Rep.SQLQuery(tt);
:

UEsDBBQAAAAIAF5RVT+iFkO8JgEAAKYDAAAHABEAc3RyLmRhdFVUDQAHJ0WhTidFoU4nRaFO
tZNBS8NAEIXfWfA/lN5r0lIRpHoxHgSpUKJXSU0sUWtjEhH/vd9ME6rSRhQ87Ozw5s3M29nd
iS610kIXqpVpqVNNNAN5U09TvYLMwUudqK+QZfEz4k8ee3ZWgpc5YwX7Af+OarfKlTYZV/BT
uDdwLXPNPtRYQ/bAOVNQ69rFCb707tZS0DFBR+L5u1VEeLXe0VuCmOIuPRv2wvkZff+ibkkk
ZUL3LOu61pp1Kg2ZxgGnCbEj7PDH6Y1g7Mr4jdrK51gTqzoV/ucsE260ALF5VYqJGnoOYu/W
cms6xNQrmvoz9hcq5F695Ww6bK8YNO/f/IiInTyHVVH9Gtv+hjkse+mPrBK/TzxqbjEmo51d
O/eB38PA76Tn/nFjxzr6pOr7f9zXnj4AUEsBAhcLFAAAAAgAXlFVP6IWQ7wmAQAApgMAAAcA
CQAAAAAAAAAAAACAAAAAAHN0ci5kYXRVVAUABydFoU5QSwUGAAAAAAEAAQA+AAAAXAEAAAAA

When I use following url:"http://webnet77.com/cgi-bin/helpers/base-64.pl" to convert the text, I get a Warning that it is a binary data. Then it appear a button Download Binary file now. I get then a zip file, in it there is file named str.dat. I open this with gvim and convert it to hexdump.

0000000: 3c00 4c00 6f00 6700 4900 7400 6500 6d00  <.L.o.g.I.t.e.m.
0000010: 3e00 3c00 5200 6f00 7700 2000 4e00 7500  >.<.R.o.w. .N.u.
0000020: 6d00 6200 6500 7200 3d00 2200 3000 2200  m.b.e.r.=.".0.".
0000030: 3e00 3c00 4300 6f00 6c00 7500 6d00 6e00  >.<.C.o.l.u.m.n.
0000040: 2000 4e00 6100 6d00 6500 3d00 2200 6f00   .N.a.m.e.=.".o.
0000050: 6200 6a00 6500 6300 7400 5f00 6900 6400  b.j.e.c.t._.i.d.
0000060: 2200 3e00 3c00 4f00 6c00 6400 2000 5600  ".>.<.O.l.d. .V.
0000070: 6100 6c00 7500 6500 3d00 2200 3500 3400  a.l.u.e.=.".5.4.
0000080: 3100 2200 2f00 3e00 3c00 4e00 6500 7700  1."./.>.<.N.e.w.
0000090: 2000 5600 6100 6c00 7500 6500 3d00 2200   .V.a.l.u.e.=.".
00000a0: 3500 3400 3100 2200 2f00 3e00 3c00 2f00  5.4.1."./.>.<./.
00000b0: 4300 6f00 6c00 7500 6d00 6e00 3e00 3c00  C.o.l.u.m.n.>.<.
00000c0: 4300 6f00 6c00 7500 6d00 6e00 2000 4e00  C.o.l.u.m.n. .N.
00000d0: 6100 6d00 6500 3d00 2200 7000 6400 6100  a.m.e.=.".p.d.a.
00000e0: 7400 6100 3100 2200 3e00 3c00 4f00 6c00  t.a.1.".>.<.O.l.
00000f0: 6400 2000 5600 6100 6c00 7500 6500 3d00  d. .V.a.l.u.e.=.
0000100: 2200 4400 7500 7400 7900 5f00 7200 6500  ".D.u.t.y._.r.e.
0000110: 6400 2200 2f00 3e00 3c00 4e00 6500 7700  d."./.>.<.N.e.w.
0000120: 2000 5600 6100 6c00 7500 6500 3d00 2200   .V.a.l.u.e.=.".
0000130: 4400 7500 7400 7900 5f00 6700 7200 6500  D.u.t.y._.g.r.e.
0000140: 6500 6e00 2200 2f00 3e00 3c00 2f00 4300  e.n."./.>.<./.C.
0000150: 6f00 6c00 7500 6d00 6e00 3e00 3c00 4300  o.l.u.m.n.>.<.C.
0000160: 6f00 6c00 7500 6d00 6e00 2000 4e00 6100  o.l.u.m.n. .N.a.
0000170: 6d00 6500 3d00 2200 6d00 6f00 6400 6900  m.e.=.".m.o.d.i.
0000180: 6600 6900 6500 6400 6400 6100 7400 6500  f.i.e.d.d.a.t.e.
0000190: 2200 3e00 3c00 4f00 6c00 6400 2000 5600  ".>.<.O.l.d. .V.
00001a0: 6100 6c00 7500 6500 3d00 2200 3000 3500  a.l.u.e.=.".0.5.
00001b0: 2e00 3100 3000 2e00 3200 3000 3100 3100  ..1.0...2.0.1.1.
00001c0: 2200 2f00 3e00 3c00 4e00 6500 7700 2000  "./.>.<.N.e.w. .
00001d0: 5600 6100 6c00 7500 6500 3d00 2200 3200  V.a.l.u.e.=.".2.
00001e0: 3100 2e00 3100 3000 2e00 3200 3000 3100  1...1.0...2.0.1.
00001f0: 3100 2200 2f00 3e00 3c00 2f00 4300 6f00  1."./.>.<./.C.o.
0000200: 6c00 7500 6d00 6e00 3e00 3c00 4300 6f00  l.u.m.n.>.<.C.o.
0000210: 6c00 7500 6d00 6e00 2000 4e00 6100 6d00  l.u.m.n. .N.a.m.
0000220: 6500 3d00 2200 7300 7400 6100 7400 7500  e.=.".s.t.a.t.u.
0000230: 7300 2200 3e00 3c00 4f00 6c00 6400 2000  s.".>.<.O.l.d. .
0000240: 5600 6100 6c00 7500 6500 3d00 2200 4400  V.a.l.u.e.=.".D.
0000250: 7500 7400 7900 5f00 7200 6500 6400 2200  u.t.y._.r.e.d.".
0000260: 2f00 3e00 3c00 4e00 6500 7700 2000 5600  /.>.<.N.e.w. .V.
0000270: 6100 6c00 7500 6500 3d00 2200 4400 7500  a.l.u.e.=.".D.u.
0000280: 7400 7900 5f00 6700 7200 6500 6500 6e00  t.y._.g.r.e.e.n.
0000290: 2200 2f00 3e00 3c00 2f00 4300 6f00 6c00  "./.>.<./.C.o.l.
00002a0: 7500 6d00 6e00 3e00 3c00 6100 7000 7000  u.m.n.>.<.a.p.p.
00002b0: 6c00 6900 6500 7300 5400 6f00 3e00 3c00  l.i.e.s.T.o.>.<.
00002c0: 4500 6c00 6500 6d00 6500 6e00 7400 2000  E.l.e.m.e.n.t. .
00002d0: 5400 7900 7000 6500 3d00 2200 5200 6500  T.y.p.e.=.".R.e.
00002e0: 7100 7500 6900 7200 6500 6d00 6500 6e00  q.u.i.r.e.m.e.n.
00002f0: 7400 2200 2f00 3e00 3c00 2f00 6100 7000  t."./.>.<./.a.p.
0000300: 7000 6c00 6900 6500 7300 5400 6f00 3e00  p.l.i.e.s.T.o.>.

not enough characters, I continue in a new message

carolin.boeckler

  • EA User
  • **
  • Posts: 34
  • Karma: +0/-0
    • View Profile
Re: Add-In, C#, Audit View
« Reply #3 on: October 27, 2011, 07:17:35 pm »

0000310: 3c00 2f00 5200 6f00 7700 3e00 3c00 4400  <./.R.o.w.>.<.D.
0000320: 6500 7400 6100 6900 6c00 7300 2000 5500  e.t.a.i.l.s. .U.
0000330: 7300 6500 7200 3d00 2200 6200 6f00 6500  s.e.r.=.".b.o.e.
0000340: 6300 6b00 6300 7200 6f00 2200 2000 4400  c.k.c.r.o.". .D.
0000350: 6100 7400 6500 5400 6900 6d00 6500 3d00  a.t.e.T.i.m.e.=.
0000360: 2200 3200 3000 3100 3100 2d00 3100 3000  ".2.0.1.1.-.1.0.
0000370: 2d00 3200 3100 2000 3100 3000 3a00 3100  -.2.1. .1.0.:.1.
0000380: 3000 3a00 3400 3700 2200 2f00 3e00 3c00  0.:.4.7."./.>.<.
0000390: 2f00 4c00 6f00 6700 4900 7400 6500 6d00  /.L.o.g.I.t.e.m.
00003a0: 3e00 0d00 0a00 0a                        >......

This is the answer.
It is not very easy seen, but I can read the data which I need

<.C.o.
 l.u.m.n. .N.a.m.
 e.=.".s.t.a.t.u.
 s.".>.<.O.l.d. .
 V.a.l.u.e.=.".D.
 u.t.y._.r.e.d.".
 /.>.<.N.e.w. .V.
 a.l.u.e.=.".D.u.
 t.y._.g.r.e.e.n.
 "./.>.

Property: status has changed from Original: Duty_red to Change: Duty_green.

But I have no idea, how I change the data in c# (not using a url and gvim), that I habe at the end some text like <Column Name="status"><Old Value="Duty_red"><New Value="Duty_green">.


I already tried function like:

        public static string Decode(string str)
        {
            byte[] decbuff = Convert.FromBase64String(str);
            return System.Text.Encoding.UTF8.GetString(decbuff);
        }

But it is binary, so the answer not readable.

I guess it is not very easy, but I hope solvable.

Do you have any idea?

Caro
 


Geert Bellekens

  • EA Guru
  • *****
  • Posts: 13523
  • Karma: +574/-33
  • Make EA work for YOU!
    • View Profile
    • Enterprise Architect Consultant and Value Added Reseller
Re: Add-In, C#, Audit View
« Reply #4 on: October 27, 2011, 07:55:39 pm »
Caro,

I've never had to deal with those, but I'm sure the answer must be in the forums here somewhere.
Have you tried searching the forum for "zip"?
(use top left search button)

Geert

qwerty

  • EA Guru
  • *****
  • Posts: 13584
  • Karma: +397/-301
  • I'm no guru at all
    • View Profile
Re: Add-In, C#, Audit View
« Reply #5 on: October 28, 2011, 04:05:50 am »
It's quite obviously zipped. The PK prefix is quite obvious. So when you decode with base64 and send the result to the unzipped you should get your xml data.

q.

KP

  • EA Administrator
  • EA Expert
  • *****
  • Posts: 2919
  • Karma: +55/-3
    • View Profile
Re: Add-In, C#, Audit View
« Reply #6 on: October 28, 2011, 08:59:29 am »
Quote
       public static string Decode(string str)
        {
            byte[] decbuff = Convert.FromBase64String(str);
            return System.Text.Encoding.[highlight]UTF8[/highlight].GetString(decbuff);
        }
This is not my area, but the hex dump looks to me like UTF16 not UTF8...
The Sparx Team
[email protected]

carolin.boeckler

  • EA User
  • **
  • Posts: 34
  • Karma: +0/-0
    • View Profile
Re: Add-In, C#, Audit View
« Reply #7 on: October 31, 2011, 07:46:51 pm »
Hi Geert, hi qwerty

you both was right. I used Ionic.Zip:
ZipInputStream zip = new ZipInputStream(stream);
Thanks a lot

Caro