|
Hi,
if your producer does not signal it is done producing the file, the only
things you can do are:
- wait a very long time;
- or loop {wait a short time; try; exit on success;}
BTW: if the web service is going to send the PDF back to the client, it will
have to delete the file also; that too can fail because the file is being
read by another process (Antivirus, Google desktop, whatever).
The remedy is: loop {try; exit on success; wait a short time;}
Luc Pattyn [Forum Guidelines] [My Articles]
this weeks tips:
- make Visual display line numbers: Tools/Options/TextEditor/...
- show exceptions with ToString() to see all information
- before you ask a question here, search CodeProject, then Google
|
|
|
|
|
You can use a FileSystemWatcher for this.
This class is used to monitor a certain folder on the filesystem (disk) where your service runs.
It fires events when something changes to the filesystem (eg. file created, renamed, deleted,...)
Say your PDF printer saves the file as c:\temp\pdf\someName.pdf, then you can monitor the c:\temp\pdf folder with the FileSystemWatcher.
When a file is created in that directory (by your pdf printer) an event is thrown. You can catch this event and
then send the newly generated file.
For more info on this class please visit the MSDN site here[^].
Hope this helps!
Tim Wuytens
|
|
|
|
|
Tim,
Thanks for the reply!
It is indeed a valid suggestion, though i have few questions.
When the PDF printer starts printing a file would be at a location so the filewatcher checks that a file is created and the event gets fired thereby.
The filewatcher can identify creation, deletion, modification but i guess my requirement is something like creation complete.
Something should be fired once the file is created and completly loaded!
gauthee
|
|
|
|
|
I took a quick look at the documentation of Nova PDF and found that you can catch events from the printer driver self.
There is an event NOVAPDF2_ENDDOC which fires when the job is done. Maybe this could be of use for you?
I've used the PDF document found on http://www.novapdf.com/download/pdf/novasdk.pdf[^]
See on page 28 of this document for the events.
See heading 4.5 on page 20 to see how to register to the events.
There's even something about e-mailing the converted documents in this guide.
Hope this helps as well!
Tim Wuytens
|
|
|
|
|
I have a need to populate a treeview control with a file containing as much as 500,000 lines of data. The data file contains information that could be saved as an Excel .xls file, or a .csv file, or a straight text file. I have a C# project that reads the data from an excel file and populates my treeview control, but it takes FOREVER for just 25,000 lines. And Excel files have the 65K line limit anyway.
Can someone tell me what the fastest methode would be to populate a treeview control with data from a file that could contain as many as a half a million lines or more?
Thanks.
|
|
|
|
|
That would say would be a horrendifying experience to the user loading from a text file considering the largest wait time unless the system had enough powerful horsepowers to process it as if it possessed a magical wand.
|
|
|
|
|
Just a couple of ideas:
1) Call BeginUpdate before you add the nodes and then EndUpdate once you are done.
2) If possible, use the Nodes.AddRange method instead of the Nodes.Add method.
Regardless, half a million lines in a treeview sounds a tad daft...
|
|
|
|
|
I think your approach is wrong here - populating anything user oriented (except my bank account) with 500,000 somethings is pointless. No user would be able to make sense of that much data.
"It was the day before today.... I remember it like it was yesterday."
-Moleman
|
|
|
|
|
I agree. The approach is wrong. There are other approaches that work better. I'm betting that someone somewhere has implemented a control that can keep a portion of the file in the visible window while the user scrolls up or down. It may not be the ideal solution, but it definitely is not the worst.
Phil
|
|
|
|
|
Load it dynamically. On form load, load the first-level tree nodes, and when the user expands and individual node load it's children.
If they are all first-level nodes you have some serious design issues to deal with.
|
|
|
|
|
Hi,
within a single run of your app you can get this for free by creating the
dialog only once, and reusing it over and over.
Across app sessions, you obviously would need to store and retrieve the info
somehow.
Luc Pattyn [Forum Guidelines] [My Articles]
this weeks tips:
- make Visual display line numbers: Tools/Options/TextEditor/...
- show exceptions with ToString() to see all information
- before you ask a question here, search CodeProject, then Google
|
|
|
|
|
hey thanks for the reply,
ofcourse my problem is on Across app sessions,
the problem is when i store the PageSettings
and and set the PageSetupDialog.PageSettings
it shows the default values... and not the values that i have saved.
and im sure that the PageSettings that i have saved in the Properties
do not contain the default values...
maybe when you do PageSetupDialog.PageSettings = somePageSettings;
it doesnt effect the PageSetupDialog... i dont know cause evrything
i do results with displaying the default values again...
Net
|
|
|
|
|
Hi,
Can anybody please assist me with the following.I have googled but no luck.
I receive a dataset from a webservice which contains all data i requested. How can I simply insert all the rows which are in the dataset into SQL database?
The dataset contains three tables and the sql database destination has the exact same tables and columns.
any help, suggestions or articles will be greatly appreciated.
|
|
|
|
|
|
did u try doing a stored procedure and an insert sql command?
|
|
|
|
|
Did you search here on codeproject? I'm sure you will find necessary articles.
|
|
|
|
|
I want to take the value of textBox1.text, pass it to a find routine and then display the results of all lines that have the given text.
The find portion I have figured out. the IndexOf routine I have not figured out.
Here is my find routine;
private void btnFind_Click(object sender, System.EventArgs e)
{
try
{
int StartPosition;
StringComparison SearchType;
if (chkMatchCase.Checked == true)
{
SearchType = StringComparison.Ordinal;
}
else
{
SearchType = StringComparison.OrdinalIgnoreCase;
}
StartPosition = mMain.rtbDoc.Text.IndexOf(txtSearchTerm.Text, SearchType);
if (StartPosition == 0)
{
MessageBox.Show("String: " + txtSearchTerm.Text.ToString() + " not found", "No Matches", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
return;
}
mMain.rtbDoc.Select(StartPosition, txtSearchTerm.Text.Length);
mMain.rtbDoc.ScrollToCaret();
mMain.Focus();
btnFindNext.Enabled = true;
}
catch (Exception ex)
{
MessageBox.Show(ex.Message.ToString(), "Error");
}
}
Lets say I want to search for and display every line that has the word "one" in it and then display it in a RichTextBox
one plus four
two plus four
three plus four
one minus four
one divided by four
two minus four
two divided by four
three plus five
three minus five
When the search is done, it show like this in the RTB with nothing else.;
one plus four
one minus four
one divided by four
Thanks in advance!
Brian
|
|
|
|
|
Hello,
I'm not sure if I understand you right,
but if you have a multiline TextBox and want to iterate over the lines to find the lines with a search string in it.
Then use a method like this:
using System.Collections.Specialized;
public static StringCollection FindLinesOverSearchString(string[] LinesToSearch, string TextToSearch)
{
StringCollection resultLines = new StringCollection();
if(LinesToSearch!=null)
{
foreach(string actLine in LinesToSearch)
{
if(actLine.IndexOf(TextToSearch)!=-1)
{
resultLines.Add(actLine);
}
}
}
return resultLines;
}
And call it like this:
StringCollection textboxresult = FindLinesOverSearchString(yourTextBox.Lines, "searchstring");
All the best,
Martin
|
|
|
|
|
Martin, if I understand you correctly,
The method will find what I want.
I am not sure I understand how I take the value of the textbox as a string and pass it to the above routine and then get it to the second textbox.
I understand the string collextion piece, as it looks fairly simple in that respect.
Thanks,
Brian
|
|
|
|
|
solutionsville wrote: I am not sure I understand how I take the value of the textbox as a string and pass it to the above routine
You don't need to do that.
The method I posted, takes a string[] as parameter for the lines to search.
The TextBox class has a property called "Lines" which is type of string[], and this will be passed as parameter.
FindLinesOverSearchString(yourTextBox.Lines, "searchstring");
The second parameter is quit simple the string to search.
The result is in my case a dynamic collection of the type: System.Collections.Specialized.StringCollection.
This class has an "Add" method, which will be used to add the matching line to the collection.
If you now have the result and want to show it in a second multiline textbox:
StringCollection resultLines = FindLinesOverSearchString(yourTextBox.Lines, "searchstring");
string[] resultAsStringArray = new string[resultLines.Count];
resultLines.CopyTo(resultAsStringArray,0);
yourTextBoxResult.Lines = resultAsStringArray;
Hope it helps!
All the best,
Martin
|
|
|
|
|
That explains it better. I will have to mull this over a little more before I get it to sink in and work the way we are talking about.
Thanks for the help!
Brian
|
|
|
|
|
You are wellcome!
All the best,
Martin
|
|
|
|
|
solutionsville wrote: Lets say I want to search for and display every line that has the word "one" in it and then display it in a RichTextBox
Here's how you can use IndexOf()
<br />
int hasOne;<br />
<br />
string strWorkString = string.Empty;<br />
strWorkString = "one plus 3";<br />
<br />
hasOne = strWorkString.IndexOf("one");<br />
That will report where in the string "one" is found. Also,
solutionsville wrote: MessageBox.Show("String: " + txtSearchTerm.Text.ToString() + " not found", "No Matches", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
When you do that, you should really use string.Format(). Do it like so:
<br />
MessageBox.Show(string.Format("String: {0} not found", txtSearchTerm.Text.ToString()), "No Matches", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);<br />
I get all the news I need from the weather report - Paul Simon (from "The Only Living Boy in New York")
|
|
|
|
|
PLS TELL ME HOW TO FORMAT STRING TO DATE FORMAT YYYYMMDD
KETAN
|
|
|
|
|
YOU DONT NEED TO SHOUT!!!
But as you (almost) said please:
myDate.ToString("yyyyMMdd");
|
|
|
|