|
You are welcome
|
|
|
|
|
I am programming a movie info collect tool. I think store all data with XML is OK.
Here is the MovieDataXML
<?xml version="1.0" encoding="utf-8" ?>
<Data>
<Movie>
<ChineseName>aa</ChineseName>
<EnglishName>aa</EnglishName>
<Year>aa</Year>
<Area>aa</Area>
<Type>aa</Type>
<Language>aa</Language>
<Subtitle>aa</Subtitle>
<IMDB>aa</IMDB>
<Resolution>aa</Resolution>
<Director>aa</Director>
<Actors>aa</Actors>
<Introduction>aa</Introduction>
<BelongTo>aa</BelongTo>
<DiscNumber>aa</DiscNumber>
</Movie>
</Data>
And when I try to read the data.
ClassXMLHandler clsXmlHandler = new ClassXMLHandler();
string strMovieData = "Data";
XmlNode xNodeMovieData = clsXmlHandler.MovieDataDocument.SelectSingleNode(strMovieData);
XmlNodeReader xReader = new XmlNodeReader(xNodeMovieData);
Here is the problem
If I read XML data by DataTable
There will be a Exception "DataTable does not support schema inference from Xml",
If I create this DataTable schema manually,there is no data in that DataTable.
DataTable dtMovieData = new DataTable();
dtMovieData.ReadXml(xReader);
But I found it is OK if I use DataSet instead of DataTable
DataSet ds = new DataSet();
ds.ReadXml(xReader);
I don't know why.
|
|
|
|
|
I get this string from device : 6.623E-2\n,#wz4y
How do i get 6.623E-2 ?
thanks
|
|
|
|
|
|
|
What about
- yourstring.Split(new char[] { '\n' }) or
- yourstring.Substring(0, yourstring.IndexOf('\n') or
- Regex.Match with pattern @"^([^\n]+)\n.*"
regards
modified 12-Sep-18 21:01pm.
|
|
|
|
|
\n or \r\n are concidered new lines.
if you load following string:
"test\r\nmore test"
in a multiline textbox it will appear:
test
more test
|
|
|
|
|
|
But you need to be sure that the '\n' is there or test for -1.
|
|
|
|
|
Hi,
How can i "store" a image in a xml file?
I am thinking in a byte[] like in sql server.
<user>
<f_name>John<f_name>
<l_name>Black<l_name>
<image>w3cvbjr7lerr4hh56ws2<image>
<user>
Any help welcome; link, code, whatever
nelsonpaixao@yahoo.com.br
trying to help & get help
|
|
|
|
|
Since you can't stored just any old character you want in an XML file, you'll have to convert the image to a string that XML can hold. A thought off the top of my head says convert it to a base64 string and store that.
|
|
|
|
|
|
I have a application I have built that uses a SQL Server express database to store the data. I have built a logging functions which writes the log entrys of whats going on in the application to a text file on the hard disk. When I set the logging to DEBUG mode (which logs a ton of stuff) it takes a long time for certain things to run as its writing a bunch of data to the text file. If they set the logs to WARN... it only writes important information to the log file.
This all works great, but I would really like to log everything so if there is a problem with the application I can look at the users log file and tell exactly what they were doing to try and reproduce the error. So I was thinking about writing the logs to the database which would mean I could insert all entrys and just query the items I need to return which brings up my question.
If i start to insert a ton of data into the database, at what point could I overload the database?
XXX Querys a hour/second?
Database reaches XXX size?
I know this will depend on the users machine also, but its not going out to a wide user base, more like 10 people.
|
|
|
|
|
Brad Wick wrote: I know this will depend on the users machine
This is just 1 of the considerations. Database design will have a big impact, as will proper connection control and a whole host of other things. I suspect the only real way of finding out is to test it.
Bob
Ashfield Consultants Ltd
|
|
|
|
|
I am passing in the procedure name and a parameter array. The values in the array are correct, yet I'm not getting any data back:
public DataSet ExecuteQueryProc(string sParameterName, SqlParameter[] ParamArray)
{
DataSet oDataSet = new DataSet();
SqlConnection oConn = GetConnection(true);
if (oConn != null)
{
SqlCommand oCommand = new SqlCommand();
oCommand.Connection = oConn;
oCommand.CommandText = sParameterName;
oCommand.CommandType = CommandType.StoredProcedure;
oCommand.Parameters.AddRange(ParamArray);
SqlDataAdapter oAdapter = new SqlDataAdapter();
oAdapter.SelectCommand = oCommand;
oAdapter.Fill(oDataSet);
}
return oDataSet;
}
>
Anyone wanna take a stab it this?
Everything makes sense in someone's mind
|
|
|
|
|
oConn equaling null would result in no data.
Just because we can; does not mean we should.
|
|
|
|
|
Have you tried running the proc in query analyser with the EXACT paramters you are passing? Its often easy to get a trailng space on a string that results in no data, or similar problems. I often just do a bit of code to generate the exact call (with the param values in the correct quites etc), then test it in query analyser.
Bob
Ashfield Consultants Ltd
|
|
|
|
|
Hi
I have a project where I want to start X threads for processing in the background while the main thread does other stuff. However, as soon as the main thread is finished with its work it should wait for all the other threads to finish before continue.
I looked at threadpool and found it to be insufficient (due to reasons I will not discuss here).
What I try instead is to implement my own pool of threads starting with:
Thread[] threads = new Thread[numthreads];
for (int i = 0; i < this.threads.Length; i++)
{
threads[i] = new Thread(Handler);
threads[i].Start();
}
I figured I could use ManualResetEvent to wait for the threads to finish. My question is this though:
Can I use a single resetevent for all threads to signal, or do I really need to have <numthreads> resetevents and use WaitHandle.WaitAll()?
How about the other way around? Can I have a single resetevent that all threads are listening to (waiting for input to process), and then only the first thread to catch the signal from the mainthread to actually start processing?
|
|
|
|
|
If your worker threads are terminating after they have done their work, you can just use Thread.Join on each one from your main thread.
If they stay around in a loop, waiting for the next batch of work, then you need a Barrier ( not a memory barrier - that's something different ). As it happens, I've just been playing with the new Barrier class in .NET 4.0, but I guess that doesn't help you much
The easiest way to implement this at the moment, is to have an int that you set to your numthreads before you start the threads. When each thread finishes its work, it calls Interlocked.Decrement and if it is the last thread, it signals an AutoResetEvent that the main thread is waiting on.
Nick
----------------------------------
Be excellent to each other
|
|
|
|
|
I'm having an odd issue that appears to have cropped up out of nowhere.
I have a program that uses a plugin interface to add separate modules. I have the main application project, and main function library, and about 6 plugins. In the library, I've defined a Global class to access a few static variables. I needed a dispatcher reference, so I added a static variable in the Global class, which is then set when the main application starts up. The plugins will often then use this variable when they need a dispatcher and none is available.
Originally, this all worked fine, and I haven't changed anything in the Global class; however, now, none of the plugins can see the value of the static variable. I did a little testing, and was able to find this:
If I declare a variable, but don't set a value in the Global class; but then give it a value in the Main Application, it comes up as null when read by a plugin. I have:
In the Global class:
public static string Test;
In Window_Loaded for main app:
Global.Test = "Test";
When checking in a plugin:
MessageBox.Show(Global.Test);
it returns null. I do have a reference to the Global class in the plugin.
If I set the value in the declaration in the Global class it works fine:
In the Global Class:
public stating string Test = "Test";
If I then add this to the Window_Loaded of the main app:
Globa.Test = "MyNewTest";
In the plugin, it displays "Test", even though it was previously set to "MyNewTest" at startup.
I have also checked the value from the main app - checking the value at anytime in the main app returns the correct "MyNewTest".
It appears that when the variable is assigned a value from the main application project, it is not accessible from any of the plugin projects (all different classes, of course).
As I mentioned, this previously worked fine, and I haven't altered the Global class. Additionally, I've also checked plugins that I haven't changed, and they don't seem to work now either, even though none of the components have changed (I've added new plugins, but checking the main app, the Global class and a plugin, all of which have not changed, still show this issue).
Any insight on this would be greatly appreciated.
Thanks,
Mike
|
|
|
|
|
Do you use multiple threads? If yes, you may try to use the volatile keyword for the variable:
public static volatile string Test;
regards
modified 12-Sep-18 21:01pm.
|
|
|
|
|
I am using multiple threads. I tried using the volatile keyword, and no such luck. It almost looks like it is accessing another instance of the static variable.
If it helps, in my testing, all 3 parts (declaring the variable, setting it and calling it) are all happening in the same thread.
It holds the value up until I get to the plugin, then it reverts to whatever the constructor is (or null if the variable is not explicitly defined at declaration). This is what led me to believe perhaps it is accessing another instance of the static variable (which shouldn't be possible, as far as I understand.)
Thanks for any insight,
Mike
|
|
|
|
|
I have two databases (I'll call them (A) and (B) for this discussion) that keep Customer information. (A) uses a system generated integer for the unique record ID and (B) uses its Company_Code and Customer_Code data fields as its unique record ID. I can change the database structure for (A) but not (B). I added Company_Code and Customer_Code fields to (A) so I can relate (A) and (B) customer records. If i'm working in a child record in (A) I know the interger for the customer, but I have to query the parent for the (B) key when I need information from (B). If i'm working in (B) I know the Company_Code, Customer_Code, but again, I have to query (A) parent record to get the correct integer value if I need information from (A). So I came up with the following solution that I need help with. (I should mention I'm a newbie programmer and would gladly consider other solutions)
1. I created a simple class:
public class CustomerIDPair: IComparer<CustomerIDPair>, IComparable<CustomerIDPair>
{
private string _company_Code = string.Empty;
private string _customer_Code = string.Empty;
public CustomerIDPair()
{
}
public CustomerIDPair(string Company_Code, string Customer_Code)
{
_company_Code = Company_Code;
_customer_Code = Customer_Code;
}
public string Company_Code
{
get { return _company_Code; }
set { _company_Code = value; }
}
public string Customer_Code
{
get { return _customer_Code; }
set { _customer_Code = value; }
}
public override string ToString()
{
return _company_Code.Trim() + ", " + _customer_Code.Trim();
}
#region IComparer<CustomerIDPair> Members
public int Compare(CustomerIDPair x, CustomerIDPair y)
{
string strX = x.Company_Code.Trim().PadLeft(3) + x.Customer_Code.Trim().PadLeft(10);
string strY = y.Company_Code.Trim().PadLeft(3) + y.Customer_Code.Trim().PadLeft(10);
return string.Compare(strX, strY, true);
}
#endregion
#region IComparable<CustomerIDPair> Members
public int CompareTo(CustomerIDPair other)
{
string strX = this.Company_Code.Trim().PadLeft(3) + this.Customer_Code.Trim().PadLeft(10);
string strY = other.Company_Code.Trim().PadLeft(3) + other.Customer_Code.Trim().PadLeft(10);
return string.Compare(strX, strY, true);
}
#endregion
}
2. I created 2 Dictionarys 'AtoB<int, CustomerIDPair>' and 'BtoA<CustomerIDPair, int>' , then populated them from A on application startup
Assume there is a customer that is identified in A as 14, and identifed as "EZE","TLC" in B
So:
AtoB[14] correctly evalates to a CustomerIDPair from with I can retrieve the company_Code and customer_Code.
But:
CustomerIDPair custID = new CustomerIDPair("EZE","TLC");
int test = BtoA[custId];
raises a KeyNotFoundException
Does anyone have any ideas how to make this work?
Thanks in advance
Russ
|
|
|
|
|
ret7679 wrote: But:
CustomerIDPair custID = new CustomerIDPair("EZE","TLC");
int test = BtoA[custId];
raises a KeyNotFoundException
This totally makes sense: you create a new CustomerIDPair object and try to locate it in the dictionary. But since you haven't added the newly created CustomerIDPair to the dictionary it simply doesn't exist there.
regards
modified 12-Sep-18 21:01pm.
|
|
|
|
|
There is a CustomerIDPair in the BtoA Dictionary whose Company_Code is "EZE" and whose Customer_Code is "TLC" which was added when I created and populated the Dictionary. The problem seems to be in equating this new CustomerIDPair with the original.
|
|
|
|