|
Hi, I have a web method that is very chatty, here is sample output from it;
<?xml version="1.0" encoding="UTF-8"?>
<soap:Envelope xmlns:tns="http://tempuri.org/" xmlns:types="http://tempuri.org/" xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<soap:Body soap:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/">
<types:MyWebMethodResponse>
<MyWebMethodResult href="#id1"/>
</types:MyWebMethodResponse>
<soapenc:Array soapenc:arrayType="types:MyType[1]" id="id1">
<Item href="#id2"/>
</soapenc:Array>
<types:MyType id="id2" xsi:type="types:MyType">
<Id xsi:type="xsd:string">someid</Id>
<Number xsi:type="xsd:string">Number 1</Number>
<Title xsi:type="xsd:string">Title</Title>
<Addr xsi:type="xsd:string">some address</Addr>
<City xsi:type="xsd:string">some city</City>
<State xsi:type="xsd:string">some state</State>
<Zip xsi:type="xsd:string">11111</Zip>
<Times href="#id3"/>
</types:MyType>
<soapenc:Array soapenc:arrayType="types:Time[256]" id="id3">
<Item href="#id5"/>
<Item href="#id6"/>
<Item href="#id7"/>
<Item href="#id8"/>
<Item href="#id9"/>
...
<Item href="#id258"/>
<Item href="#id259"/>
<Item href="#id260"/>
</soapenc:Array>
<types:Time id="id5" xsi:type="types:Time">
<StartTime xsi:type="xsd:dateTime">2007-01-29T13:18:00.0000000-08:00</StartTime>
<EndTime xsi:type="xsd:dateTime">2007-01-29T13:18:00.0000000-08:00</EndTime>
</types:Time>
<types:Time id="id260" xsi:type="types:Time">
<StartTime xsi:type="xsd:dateTime">2007-01-29T13:18:00.0000000-08:00</StartTime>
<EndTime xsi:type="xsd:dateTime">2007-01-29T13:18:00.0000000-08:00</EndTime>
</types:Time>
</soap:Body>
</soap:Envelope>
All of those <Item href...> take up a lot of space, is there a way instruct .net not generate it?
This is the declaration over the webservice C# class file;
[WebService(Namespace=Constants.NAMESPACE), ToolboxItem(false), SoapRpcService]
The web method just has plain, [WebMethod] attribute and that's it.
Thanks,
|
|
|
|
|
I had posted this question two weeks back but till date no one has responed. Is this indeed an issue with the combobox? I hope I'm clear with my question and this time I will get some help from this forum.
ComboBox control has got selectedindexchanged event. As the name suggest this event should fire when selected item change for the combobox. But this event fires even when the currently selected item is selected again from the dropdown list of combobox.
e.g.
if I have loaded following items in my combobox say
item1
item2
item3
item4
with item1 as selected when my application starts.
Now if from UI, I again select the "item1" (which is already selected in combo box) then also the selectedindexchanged event fires. In this case the index has not changed still the selectedindexchanged event fires. I find this bit strange.
Is there anyway to findout when the selected item has changed by User. I want some kind of notification when user indeed changes the combobox selected item (not when combobox.selecteditem is set through code)?
regards
KC
|
|
|
|
|
You have to store your selected index, and compare it to what is in the control after the event fires. The event should check first, then store the value for next time.
Christian Graus - Microsoft MVP - C++
Metal Musings - Rex and my new metal blog
|
|
|
|
|
Christian
Thanks for your reply. I agree to your solution where I have to remember the previously selected index and match it with the newly selected index in the eventhandler. If new and previous indexes are same then skip the execution of handler. But this is not going to serve my purpose.
What I want is, I want to skip the execution of ComboboxSelectedIndexChanged Eventhandler when the already selected item in the combobox is again selected by user (i.e. user clicks the combobox and select the same item again). I don't mind if combobox SelectedIndex changed event fires through some code i.e. ComboBox.SelectedIndex = 2;
So in nutshell want to restrict the eventhandler when same item is selected through user interaction.
|
|
|
|
|
Well, you plainly can't stop the event from firing. Until it fires, you can't make your code run at all.
Christian Graus - Microsoft MVP - C++
Metal Musings - Rex and my new metal blog
|
|
|
|
|
You could combine it with TextChanged event
|
|
|
|
|
Try overriding the combobox control. Very, very basic example below;
class ComboBoxWidget: System.Windows.Forms.ComboBox
{
#region private member variables
private int _selectedIndex = -1;
#endregion
#region overrides
protected override void OnSelectedIndexChanged( EventArgs e )
{
if( this.SelectedIndex != this._selectedIndex )
{
this._selectedIndex = this.SelectedIndex;
base.OnSelectedIndexChanged( e );
}
}
public override int SelectedIndex
{
get
{
return base.SelectedIndex;
}
set
{
this._selectedIndex = value;
base.SelectedIndex = this._selectedIndex;
}
}
#endregion
}
|
|
|
|
|
How to call .mht files in C# project?
|
|
|
|
|
What is an mht file ?
Christian Graus - Microsoft MVP - C++
Metal Musings - Rex and my new metal blog
|
|
|
|
|
In Visual Studio Team System, the manual test case is saved as .mht file. Manual tests are nothing more than a .mht file that has been added to your project, when you create a Manual Test.
|
|
|
|
|
using System.Diagnostics
Process.Start("notepad","D:\\somefile.txt");
this works, though there is probably a better way to do it
|
|
|
|
|
I have a simple C# application with an embedded Internet Explorer Active X component for quickly displaying and printing HTML pages. This application is not seen by PC Anywhere. If this application is active on the screen it will show the background of the host and part of the screen will be inaccessable by the remote computer. Has anyone else seen this or better have a fix for it?
Thanks,
Darrell
|
|
|
|
|
Any form that has any sort of transparency, is not visible over a remote connection. Is that the problem ?
Christian Graus - Microsoft MVP - C++
Metal Musings - Rex and my new metal blog
|
|
|
|
|
Remote desktop doesn't support directx
|
|
|
|
|
I need some help with being able to open a document that is listed in a datatable and is displayed in a datagridview. The code below returns a series of results from a database and these results include the file paths of files on my computer. What I want to be able to do is doulble click on a particular file path in the link column and have that file open.
Hits hits = searcher.Search(query);
DataTable dt = new DataTable();
dt.Columns.Add("link", typeof(string));
for (int j = 0; j < hits.Length(); j++)
{
Document doc = hits.Doc(j);
DataRow row = dt.NewRow();
row["link"] = doc.Get("link");
dt.Rows.Add(row);
}
MessageBox.Show("Search Complete", "", MessageBoxButtons.OK);
return dt;
|
|
|
|
|
I have solved the problem, just in case anyone is interested.
private void dgv_CellContentDoubleClick(object sender, DataGridViewCellEventArgs e)
{
SearchIndex search = new SearchIndex();
search.docOpen(this.dgv.CurrentCell.Value.ToString());
}
public void docOpen(string path)
{
Process proc = new Process();
proc.StartInfo.FileName = "iexplore";
proc.StartInfo.Arguments = path;
proc.Start();
}
|
|
|
|
|
This problem has to do with updating a control/dataset based on the DataRecevied event of the serial port. Now I know you are thinking cross threading (which it might be) but let me explain.
I have a dataset in the main UI form that is databound to a number of controls. When I change the values of the dataset the bound controls update. This is fine, but when I update the values of the dataset via the DataReceived event the values DON'T update? To illlustrate the problem simply I have stripped down the code to it's most basic form. I hope someone can shed some light on the problem.
<br />
public Form1()<br />
{<br />
InitializeComponent();<br />
}<br />
<br />
private void Form1_Load(object sender, EventArgs e)<br />
{<br />
UnitDataSet uds = new UnitDataSet();<br />
uds.DIns.ReadXml("Data.xml");<br />
<br />
_comms = new Comms(uds);<br />
<br />
Label lblInputState = new Label();<br />
panel1.Controls.Add(lblInputState);<br />
<br />
lblInputState.DataBindings.Add("Text", uds.Tables["DIns"], "state");<br />
}<br />
<br />
public void button1_Click(object sender, EventArgs e)<br />
{<br />
_comms.ChangeValue();<br />
}<br />
}<br />
<br />
============================================================<br />
<br />
class Comms<br />
{<br />
SerialPort _sp;<br />
UnitDataSet _uds;<br />
<br />
public Comms(UnitDataSet uds)<br />
{<br />
_uds = uds;<br />
_sp = new SerialPort("COM7", 9600, Parity.None, 8, StopBits.One);<br />
_sp.DataReceived += new SerialDataReceivedEventHandler(_sp_DataReceived);<br />
_sp.Open();<br />
}<br />
<br />
private void _sp_DataReceived(object sender, SerialDataReceivedEventArgs e)<br />
{<br />
ChangeValue();<br />
}<br />
<br />
public void ChangeValue()<br />
{<br />
bool tmp = (bool)_uds.Tables["DIns"].Rows[0]["state"];<br />
_uds.Tables["DIns"].Rows[0]["state"] = !tmp;<br />
}<br />
}<br />
Visual C# Express 2005
|
|
|
|
|
If you enable the debugger to break on all CLR exceptions (Tools -> Exceptions -> Check the box) and run the form under debug mode if it's a one of the many cross-thread problems then the debugger should trap the exception.
Try using in the DataReceived handler, this.Invoke(ChangeValue) , which will be thread-safe.
|
|
|
|
|
Thanks for you comments Ed. I can't seem to find Tools -> Exceptions. I'm using Visual C# express? I'll try your invoke method now.
|
|
|
|
|
there is no this.invoke() ??!
|
|
|
|
|
The Invoke method is a member of the Form data type, it's used to provide thread-safe updates of the form's controls / components. If you're not using a form you might want to take a look at my article[^] :->, which will allow you to do the thread-safe invocation from anywhere.
The Exceptions box is under Debug | Exceptions sorry, I don't know about the express edition but that's where it is in the Standard edition of VS.
|
|
|
|
|
Thanks Ed! Actually I saw you article today when I was searching for help. You are right it's not a form. I scanned over your article but it seemed quite complex to me (I still haven't really got my head around delegates or generics) but I'm fast running out of options so I'm going to study it and hopefully I'll find the answer.
|
|
|
|
|
The article actually needs an update, which will make it simpler to use (removes generics). I've got the changed code here[^]. Basically from inside your DataReceived handler all you need to do is call:
InvocationHelper.Invoke(this.ChangeValue); All the delegate is is a pointer to a function (if you know C), if you don't it's basically a variable which stores information about a particular function or method, you can then pass this variable around as a normal variable, and you can also invoke the function the delegate points to as well.
The helper routine basically just bubbles up through the class hiearchy to see if the class implements the interface ISynchronizewhatever , this just defines the Invoke method and means that the class can do things in a thread-safe manner.
PS, generics are quite simple to understand and incredibly useful once you know how.
|
|
|
|
|
Thanks again Ed! I've just arrived and work this morning and it's great to see your message. Well, although I'm new to generics, I am actually using them in my project already. I'm sure I'll use them more and more as they do seem well suited to many situations, I'm just getting to the 'once you know how part'. The word delegate makes me nervous, but I'll put it with the 'once you know how' and I'm sure I'll get the hang of it. Hey, your source has been blocked, could you zip it please? Thanks heaps, you've been great.
Oh, I forgot to say that under the Debug -> Exceptions, are you refering to the 'thrown' check box or the 'user-handled' check box associated with the CLR Exceptions tree?
-- modified at 15:05 Wednesday 14th February, 2007
|
|
|
|
|
Ok, zipped, same location[^] but .zip on the end, thanks for finding that out about the .cs extensions, never knew about that.
Best way to think of delegates is to just treat them as variables, they're nothing more anyway.
The checkbox is thrown, it helps a lot because the debugger will break when an exception is thrown rather than when it is not handled, e.g. if you've got a try / catch block normally it'd pass through and execute the catch, but with this it breaks on the exception inside the try allowing you to find the source of the problem.
|
|
|
|