|
I would usually try opening it in Reflector ( + ReflexIL plugin) and then just edit the function at the IL level. Much easier that way - if you have the Reflector decompile it completely it will almost always make some mistakes, which you'd have to fix.
If someone was so silly as to use "Reflector breakers" I'd probably first try the tools from NTCore (eg using Rebel.NET to replace the function)
|
|
|
|
|
Hi Guys
Hope you can help. I'm writing a program to do a record count within an XML file
The XML file is structured as per below:
<WEBRequest>
<Request>
<BlockA>
<REC>
<CustomerNumber></CustomerNumber>
<FirstName></FirstName>
<LastName></LastName>
<Email></Email>
</REC>
</BlockA>
<BlockB>
<REC>
<FirstName></FirstName>
<LastName></LastName>
<OrderDetail></OrderDetail>
<PartType></PartType>
</REC>
<REC>
<FirstName></FirstName>
<LastName></LastName>
<OrderDetail></OrderDetail>
<PartType></PartType>
</REC>
<REC>
<FirstName></FirstName>
<LastName></LastName>
<OrderDetail></OrderDetail>
<PartType></PartType>
</REC>
</BlockB>
<BlockC>
....
....
....
....
</BlockC>
....
....
....
</Request>
What I need to do is count and output number of <REC>'s for each <Block> element and output to a cell within excel (Excel Automation is working).
E.g.
BlockA = 1 REC
BlockB = 3 REC
.
.
.
BlockM = 32 REC
I have the excel automated correctly, however, I'm afraid that my inexperience with XML is quite telling, so I dont have a clear idea on how to do the record count.
Thanks in advance!!!
Grg!
|
|
|
|
|
Using XDocument it's quite easy:
XDocument doc = XDocument.Load("YourXMLHere.xml");
var distinctBlocks = from rec in doc.Descendants()
where rec.Name.ToString().StartsWith("Block")
select rec;
var results = from rec in distinctBlocks.Descendants("REC")
select rec;
var output = (from rec in results
group rec by rec.Parent.Name into g
select new {Block = g.Key, Count = g.Count()}).ToList();
modified on Tuesday, April 27, 2010 3:55 PM
|
|
|
|
|
Thanks for Info!
I don't suppose you have the c# code?
|
|
|
|
|
GrgBalden wrote: I don't suppose you have the c# code?
That was C#(3) code.
Using XLinq => Linq to XML.
modified on Wednesday, April 28, 2010 10:33 AM
|
|
|
|
|
Hi can anyone else help with this, I'm somewhat limited to c#2 (using VS2005)??
|
|
|
|
|
here you go.
I created a dummy class that holds the Block name and the rec count:
public class BlockCount
{
private int count = 0;
public int Count
{
get { return count; }
set { count = value; }
}
private string block;
public string Block
{
get { return block; }
set { block = value; }
}
}
private void button1_Click(object sender, EventArgs e)
{
XmlDocument doc = new XmlDocument();
doc.Load("Abs.xml");
XmlNodeList requests = doc.GetElementsByTagName("Request");
if (requests != null && requests.Count > 0)
{
blocks = new List<BlockCount>();
foreach (XmlNode nd in requests)
{
foreach (XmlNode blck in nd.ChildNodes)
{
BlockCount c = new BlockCount();
c.Block = blck.Name;
foreach (XmlNode rec in blck.ChildNodes)
{
c.Count++;
}
blocks.Add(c);
}
}
}
dataGridView1.DataSource = blocks;
}
}
modified on Wednesday, April 28, 2010 2:11 PM
|
|
|
|
|
Thank you kindly!!!
Will give this a go tommorow!
|
|
|
|
|
i would like to achieve a checkbox on a ColumnHeader in a listview.
i have been trying for days.
i have achieved a checkbox on the right spot in the listview by virtual placing it on top.
<br />
[DllImport("user32")]<br />
private static extern IntPtr SetParent(IntPtr hWndChild, IntPtr hWndNewParent);<br />
<br />
protected override void OnHandleCreated(EventArgs e)<br />
{<br />
SetParent(_cCehckBox.Handle, Handle);<br />
base.OnHandleCreated(e);<br />
}<br />
but the visual style/effect of the header causes the checkbox to fall in the background if you hover the mouse of the header.
the Header class doesn't provide anu usefull stuff, atleast i don't see any usefull stuff.
i have bene reading alot about it and viewed many things regarding headers.
i have also been using ...
<br />
protected override void WndProc(ref Message message)<br />
{<br />
....<br />
}<br />
filtering on WM_NOTIFY for 'HDN_ITEMCHANGINGA', 'HDN_ITEMCHANGEDA', 'HDN_BEGINTRACKA', 'HDN_BEGINTRACKW'.
i used a piece of code from a project here on codeproject, virtually unchanged.
but i only get the windows handle, the other things are empty.
[StructLayout(LayoutKind.Sequential)]
private struct NMHDR
{
public IntPtr hwndFrom;
public int idFrom;
public int code;
}
base.WndProc(ref message);
*/
const int WM_NOTIFY = 0x004E;
const int HDN_FIRST = (0 - 300);
const int HDN_BEGINTRACKA = (HDN_FIRST - 6);
const int HDN_BEGINTRACKW = (HDN_FIRST - 26);
bool callBase = true;
switch (message.Msg)
{
case WM_NOTIFY:
NMHDR nmhdr = (NMHDR)message.GetLParam(typeof(NMHDR));
OnMessageNeedsSending("WM_NOTIFY " + message, Color.Black);
OnMessageNeedsSending("code: " + nmhdr.code + ", hwndFrom: " + nmhdr.hwndFrom + ", idFrom: " + nmhdr.idFrom, Color.Black);
switch (nmhdr.code)
{
case HDN_BEGINTRACKA:
OnMessageNeedsSending("HDN_BEGINTRACKA " + message, Color.Black);
break;
case HDN_BEGINTRACKW:
OnMessageNeedsSending("HDN_BEGINTRACKW " + message, Color.Black);
break;
}
break;
}
if (callBase)
{
base.WndProc(ref message);
}
}
http://www.codeguru.com/forum/showthread.php?t=352366[^]
http://www.codeguru.com/cpp/controls/listview/headercontrol/comments.php/c1057/?thread=12184[^]
A Much Easier to Use ListView[^]
is there is a why to add properties, like Controls 'xxx.Add(checkbox); ?.
Bad = knowing 2 much
modified on Tuesday, April 27, 2010 11:04 AM
|
|
|
|
|
i extented ...
[StructLayout(LayoutKind.Sequential)]
private struct NMHDR
{
public IntPtr hwndFrom;
public int idFrom;
public int code;
}
to ...
[StructLayout(LayoutKind.Sequential)]
private struct NMHDR2
{
public IntPtr hwndFrom;
public int idFrom;
public int code;
public int coder;
}
this new variable 'coder' contains numbers, like: -12, -16, -23 -320, -321, -326 -327, -530
-12 and -530 seam to be mouseover and mouseleave.
-16 and -326 seam to be mouseclick / down and mouse release.
i posted a logoutput.
http://pastebin.com/HuCk5cac[^]
anyone experienced with this?
Bad = knowing 2 much
modified on Tuesday, April 27, 2010 2:47 PM
|
|
|
|
|
this is the entire code to create a listview with a checkbox in the left upper corner of the ListView.
NM_CUSTOMDRAW seams to be the message when the mouse hover over the headers.
but i fail to keep the checkBox visible / ontop @ all time.
if you slightly hoover of the first header, the headers mousehover effect draws over the check.
anyone an idea how to prevent this?
using System;
using System.Drawing;
using System.Runtime.InteropServices;
using System.Windows.Forms;
namespace Listview_Colum_header_checkbox
{
class CCehckBox2 : CheckBox
{
public CCehckBox2()
{
Width = 14;
Height = 14;
}
}
class CustomChechBox2 : Control
{
readonly CCehckBox2 _chb = new CCehckBox2();
public CustomChechBox2()
{
Size = new Size(16, 16);
_chb.Location = new Point(0, 0);
Controls.Add(_chb);
}
}
class CListview2 : ListView
{
public delegate void MessageNeedsSendingCallback(string message, Color color);
public event MessageNeedsSendingCallback OnMessageNeedsSending;
private readonly CustomChechBox2 _cCehckBox = new CustomChechBox2();
private readonly ColumnHeader _header1, _header2, _header3 = new ColumnHeader();
#region PInvoke Declarations
[DllImport("User32", CallingConvention = CallingConvention.Cdecl)]
private static extern uint RealGetWindowClass(IntPtr hwnd, System.Text.StringBuilder pszType, int cchType);
[DllImport("user32")]
private static extern IntPtr SetParent(IntPtr hWndChild, IntPtr hWndNewParent);
[DllImport("user32.dll")]
private static extern IntPtr SendMessage(IntPtr hWnd, int Msg, IntPtr wParam, IntPtr lParam);
#endregion
public CListview2()
{
View = View.Details;
_header1 = Columns.Add("");
_header1.Width = (Location.X + 5) + 12;
_header1.Name = "CheckBox";
_header1.DisplayIndex = 0;
_header2 = Columns.Add("bah");
_header2.Width = 50;
_header3 = Columns.Add("boh");
_header3.Width = 50;
var wijd = _cCehckBox.Width;
var hoog = _cCehckBox.Height;
_cCehckBox.Location = new Point((Location.X + 5), (Location.Y + 5));
}
protected override void OnHandleCreated(EventArgs e)
{
SetParent(_cCehckBox.Handle, Handle);
base.OnHandleCreated(e);
}
[StructLayout(LayoutKind.Sequential)]
private struct NMHDR
{
public IntPtr hwndFrom;
public int idFrom;
public int code;
public int coder;
}
private const int WM_NOTIFY = 0x4E;
private const int CCM_FIRST = 8192;
private const int CCM_SETBKCOLOR = (CCM_FIRST + 1);
private const int CCM_SETCOLORSCHEME = (CCM_FIRST + 2);
private const int CCM_GETCOLORSCHEME = (CCM_FIRST + 3);
private const int CCM_GETDROPTARGET = (CCM_FIRST + 4);
private const int CCM_SETUNICODEFORMAT = (CCM_FIRST + 5);
private const int CCM_GETUNICODEFORMAT = (CCM_FIRST + 6);
private const int HDN_FIRST = (0 - 300);
private const int HDM_FIRST = 4608;
private const int HDM_HITTEST = (HDM_FIRST + 6);
private const int HDM_GETITEMRECT = (HDM_FIRST + 7);
private const int HDM_SETIMAGELIST = (HDM_FIRST + 8);
private const int HDM_GETIMAGELIST = (HDM_FIRST + 9);
private const int HDM_ORDERTOINDEX = (HDM_FIRST + 15);
private const int HDM_CREATEDRAGIMAGE = (HDM_FIRST + 16);
private const int HDM_GETORDERARRAY = (HDM_FIRST + 17);
private const int HDM_SETORDERARRAY = (HDM_FIRST + 18);
private const int HDM_SETHOTDIVIDER = (HDM_FIRST + 19);
private const int HDM_SETUNICODEFORMAT = CCM_SETUNICODEFORMAT;
private const int HDM_GETUNICODEFORMAT = CCM_GETUNICODEFORMAT;
private const int HDN_ITEMCHANGINGA = (HDN_FIRST - 0);
private const int HDN_ITEMCHANGINGW = (HDN_FIRST - 20);
private const int HDN_ITEMCHANGEDA = (HDN_FIRST - 1);
private const int HDN_ITEMCHANGEDW = (HDN_FIRST - 21);
private const int HDN_ITEMCLICKA = (HDN_FIRST - 2);
private const int HDN_ITEMCLICKW = (HDN_FIRST - 22);
private const int HDN_ITEMDBLCLICKA = (HDN_FIRST - 3);
private const int HDN_ITEMDBLCLICKW = (HDN_FIRST - 23);
private const int HDN_DIVIDERDBLCLICKA = (HDN_FIRST - 5);
private const int HDN_DIVIDERDBLCLICKW = (HDN_FIRST - 25);
private const int HDN_BEGINTRACKA = (HDN_FIRST - 6);
private const int HDN_BEGINTRACKW = (HDN_FIRST - 26);
private const int HDN_ENDTRACKA = (HDN_FIRST - 7);
private const int HDN_ENDTRACKW = (HDN_FIRST - 27);
private const int HDN_TRACKA = (HDN_FIRST - 8);
private const int HDN_TRACKW = (HDN_FIRST - 28);
private const int HDN_GETDISPINFOA = (HDN_FIRST - 9);
private const int HDN_GETDISPINFOW = (HDN_FIRST - 29);
private const int HDN_BEGINDRAG = (HDN_FIRST - 10);
private const int HDN_ENDDRAG = (HDN_FIRST - 11);
private const int HDN_ITEMCHANGING = HDN_ITEMCHANGINGA;
private const int HDN_ITEMCHANGED = HDN_ITEMCHANGEDA;
private const int HDN_ITEMCLICK = HDN_ITEMCLICKA;
private const int HDN_ITEMDBLCLICK = HDN_ITEMDBLCLICKA;
private const int HDN_DIVIDERDBLCLICK = HDN_DIVIDERDBLCLICKA;
private const int HDN_BEGINTRACK = HDN_BEGINTRACKA;
private const int HDN_ENDTRACK = HDN_ENDTRACKA;
private const int HDN_TRACK = HDN_TRACKA;
private const int HDN_GETDISPINFO = HDN_GETDISPINFOA;
private const int NM_FIRST = 0;
private const int NM_OUTOFMEMORY = (NM_FIRST - 1);
private const int NM_CLICK = (NM_FIRST - 2);
private const int NM_DBLCLK = (NM_FIRST - 3);
private const int NM_RETURN = (NM_FIRST - 4);
private const int NM_RCLICK = (NM_FIRST - 5);
private const int NM_RDBLCLK = (NM_FIRST - 6);
private const int NM_SETFOCUS = (NM_FIRST - 7);
private const int NM_KILLFOCUS = (NM_FIRST - 8);
private const int NM_CUSTOMDRAW = (NM_FIRST - 12);
private const int NM_HOVER = (NM_FIRST - 13);
private const int NM_NCHITTEST = (NM_FIRST - 14);
private const int NM_KEYDOWN = (NM_FIRST - 15);
private const int NM_RELEASEDCAPTURE = (NM_FIRST - 16);
private const int NM_SETCURSOR = (NM_FIRST - 17);
private const int NM_CHAR = (NM_FIRST - 18);
protected override void WndProc(ref Message message)
{
bool callBase = true;
switch (message.Msg)
{
case WM_NOTIFY:
NMHDR nmhdr = (NMHDR)message.GetLParam(typeof(NMHDR));
OnMessageNeedsSending("code: " + nmhdr.code + ", hwndFrom: " + nmhdr.hwndFrom + ", idFrom: " + nmhdr.idFrom + ", coder: " + nmhdr.coder, Color.Black);
switch (nmhdr.coder)
{
case HDN_BEGINTRACKA:
OnMessageNeedsSending("HDN_BEGINTRACKA " + message, Color.Black);
break;
case HDN_BEGINTRACKW:
OnMessageNeedsSending("HDN_BEGINTRACKW " + message, Color.Black);
break;
case HDN_ENDTRACKW:
OnMessageNeedsSending("HDN_ENDTRACKW " + message, Color.Black);
break;
case HDN_ITEMCLICKA:
OnMessageNeedsSending("HDN_ITEMCLICKA " + message, Color.Black);
break;
case HDN_ITEMDBLCLICKW:
OnMessageNeedsSending("HDN_ITEMDBLCLICKW " + message, Color.Black);
break;
case HDN_ITEMCLICKW:
OnMessageNeedsSending("HDN_ITEMCLICKW " + message, Color.Black);
break;
case HDN_ITEMCHANGINGW:
OnMessageNeedsSending("HDN_ITEMCHANGINGW " + message, Color.Black);
break;
case HDN_ITEMCHANGEDA:
OnMessageNeedsSending("HDN_ITEMCHANGEDA " + message, Color.Black);
break;
case HDN_ITEMCHANGEDW:
OnMessageNeedsSending("HDN_ITEMCHANGEDW " + message, Color.Black);
break;
case NM_HOVER:
OnMessageNeedsSending("NM_HOVER " + message, Color.Black);
break;
case NM_RELEASEDCAPTURE:
OnMessageNeedsSending("NM_RELEASEDCAPTURE" + message, Color.Black);
break;
case NM_CUSTOMDRAW:
callBase = false;
OnMessageNeedsSending("NM_CUSTOMDRAW" + message, Color.Black);
_cCehckBox.BringToFront();
_cCehckBox.Invalidate();
break;
default:
OnMessageNeedsSending("code: " + nmhdr.code + ", hwndFrom: " + nmhdr.hwndFrom + ", idFrom: " + nmhdr.idFrom + ", coder: " + nmhdr.coder, Color.Black);
break;
}
break;
}
if (callBase)
{
base.WndProc(ref message);
}
}
}
}
Bad = knowing 2 much
|
|
|
|
|
So the deeper I get into my first Windows Forms application the more I'm questioning myself. In the VB6 days I would distribute my apps with a password protected MS Access db (not very secure) and hope nobody hacked into it.
In this app. I created my MDF in MS SQL 2008, copied the mdf and ldf to my VS 2008 application directory and set up a datasource connection to it. When I view the db in VS 2008 I see all of my tables, views and sproc's but I do not see a security node or users. So does my mdf get distributed with no security? Can anyone just attach it to their local MSSQL version and open the db? If it is in fact wide open, can it be locked down or do I need a different solution?
|
|
|
|
|
It's wide open. (SQL Server 2008 R2 has an encryption option, but probably not in the express edition).
The problem is that you cannot encrypt these files, because they will be opened by the SQLServer service, running under Userid that has probably no access to the encryption keys.
If you want to encrypt your database, distribute an SQL Server Compact 3.5 database, and attach a password to it (which of course will be known to your program, and suitably obfuscated in the executable)
|
|
|
|
|
Thank you Michel -
I actually started this project using SqlCe but I was worried it would not be robust enough or become corrupt so I switched.
|
|
|
|
|
|
add the below line at end of your code
label5.Refresh();
Cheers
Rajesh B --> A Poor Workman Blames His Tools <--
|
|
|
|
|
thanks =)
but the solution is to use Convert.toString(anydouble) instead of anydouble.toString()
|
|
|
|
|
Why did you delete your question? Now all we have an answer to an unknown question.
|
|
|
|
|
Kind of like sitting with "42", not knowing what the question is.
Quite frustrating acutally..
|
|
|
|
|
I working in solution vb.net for convert to C#.
my question about this " CopyFile(My.Application.Info.DirectoryPath & "\Ids", "Z:\ID", 1)".
wath the function for this and how do that in C#? .
thnks
|
|
|
|
|
Use System.IO Name Space
System.IO.File.Copy (SourceFilename,TragetFilename);
Cheers
Rajesh B --> A Poor Workman Blames His Tools <--
|
|
|
|
|
|
You could probably just put it in a VB.net/C# converter..
|
|
|
|
|
|
I'm not sure what that means
|
|
|
|
|