|
This is what I suggest as a test: keep things as simple as possible. Hence use a boolean class member:
bool firstPage=true;
then do:
e.HasMorePages=firstPage;
firstPage=false;
That should print two pages, no matter what. Then take it from there.
|
|
|
|
|
I'll give it a try. Thanks!
|
|
|
|
|
Hello all,
Am developing mapwinGIS appln. I have inserted the vscrollbar control on moveing up and down nothing changes. Am suppose to give code for it. but i dont know how to go about it. Can someone help me out or give an idea of how to go about it??? or any sample code for it pls??
|
|
|
|
|
|
I'm new to sql and would appreciate some help on the best way to structure the following type of operation. I have a db containing stock symbols. I'm retrieving each symbol, calculating a series of moving averages and updating the symbol table with the calculated values for each row in the symbol table. The way I have things structured below takes "for ever" to run through? Utlimately there will be a 1000 or more symbols in the db. Any help would be appreciated!
try
{
SQLiteConnection conn = new SQLiteConnection(Constants.ConnectionString);
if (conn.State == ConnectionState.Closed)
conn.Open();
string CommandText = "SELECT symbol FROM master;";
SQLiteDataAdapter dataAdapter = new SQLiteDataAdapter(CommandText, conn);
DataTable dt = new DataTable();
dataAdapter.Fill(dt);
DataTable symdt = new DataTable();
IMovingAverage ma20 = new SimpleMovingAverage(20);
IMovingAverage ma50 = new SimpleMovingAverage(50);
IMovingAverage ma200 = new SimpleMovingAverage(200);
foreach (DataRow r in dt.Rows)
{
CommandText = "SELECT * FROM " + r["Symbol"].ToString() + ";";
SQLiteDataAdapter symdataAdapter = new SQLiteDataAdapter(CommandText, conn);
symdataAdapter.Fill(symdt);
int count = 0;
foreach (DataRow symr in symdt.Rows)
{
if (symdt.Rows.Count >= 20)
{
ma20.AddSample(Convert.ToSingle(symdt.Rows[count]["Close"]));
symdt.Rows[count]["MA20"] = ma20.Average;
}
if (symdt.Rows.Count >= 50)
{
ma50.AddSample(Convert.ToSingle(symdt.Rows[count]["Close"]));
symdt.Rows[count]["MA50"] = ma50.Average;
}
if (symdt.Rows.Count >= 200)
{
ma200.AddSample(Convert.ToSingle(symdt.Rows[count]["Close"]));
symdt.Rows[count]["MA200"] = ma200.Average;
}
++count;
}
SQLiteCommandBuilder mySqlCommandBuilder = new SQLiteCommandBuilder(symdataAdapter);
symdataAdapter.Update(symdt);
symdt.Clear();
symdataAdapter.Dispose();
ma20.ClearSamples();
ma200.ClearSamples();
ma50.ClearSamples();
}
dt.Clear();
dataAdapter.Dispose();
conn.Close();
conn.Dispose();
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
}
|
|
|
|
|
|
While this approach could I'm sure be made to work I want to keep the general structure of what I'm doing since I'll be calculating other indicators not supported in SQL.
|
|
|
|
|
boreland wrote: calculating other indicators not supported in SQL
Such as? You stated you are calculating running averages, that indicates numeric data
I know the language. I've read a book. - _Madmatt
|
|
|
|
|
Could someone please advise if a transactional approach would be more efficient and if some how to do this using a datatable?
|
|
|
|
|
Your calculation of moving averages looks suspect. It looks like you're just adding the value from the nTh row to your "moving average", rather than the average of n rows...
You would likely get better performance and less memory consumption if you used a DataReader instead of a DataAdabtor and DataTables, and did your updates atomically as needed on a different connection using ExecuteNonQuery with an update statement instead of relying on a batch update...
|
|
|
|
|
They both appear to do the same thing to me, what should each one be used for and what one has a less performance hit?
Thanks!
|
|
|
|
|
Reading the documentation and, if important to you, performing a little experiment should provide the answer. Did you look at the values returned?
|
|
|
|
|
I am developing an add-in for VS for latex. The very first functionality I wish to implement is a button "compile" (to pdf). Well I can do that, but what I want is
1. Do not show a console window
2. Redirect text output (with errors/warnings/mesasges) from pdftex . The next step will be to parse these results and show them in a separate window.
I use the following code:
Document doc = _applicationObject.ActiveDocument;
if (Path.GetExtension(doc.Name) == ".tex")
{
var p = new System.Diagnostics.Process();
var pinfo =new ProcessStartInfo
{
CreateNoWindow = true,
FileName = "pdflatex",
Arguments = string.Format("\"{0}\" -c-style-errors", doc.FullName),
WorkingDirectory = Path.GetDirectoryName(doc.FullName),
};
p.EnableRaisingEvents = true;
p.Exited += p_Exited;
p.StartInfo = pinfo;
p.Start();
}
I have observed the following issues:
1. Uncommenting RedirectStandardError = true causes that pdftex does not work (no output file is generated at all)
If RedirectStandardError = true is commented, then pdftex does it's job. But:
2. Despite CreateNoWindow = true console still shows up.
3. p_Exited is never called
As you see none of things I wanted to do actually works. It is quite depressing. Any ideas?
Thanks--
Greetings - Jacek
|
|
|
|
|
Hi,
The exact behavior of a program is determined by the program itself; the StartInfo parameters only influence the way Windows simulates a user launching a process. If pdftex decides to open a console, there is nothing to stop it.
Didn't you forget to:
- set UseShellExecute false?
- also redirect standard output?
- addevent handlers or threads to actually read the output/error stream?
FYI: I just finished this article [^] on a related subject.
|
|
|
|
|
Luc Pattyn wrote: If pdftex decides to open a console, there is nothing to stop it
There are programs for LateX (like LyX), which use pdftex and no console is opened -- they show pdftex' output in some "output" window. So, it is possible to redirect the output.
Luc Pattyn wrote: Didn't you forget to: (etc.)
No, i did not forget.
void p_ErrorDataReceived(object sender, DataReceivedEventArgs e)
{
Console.WriteLine("err:" + e.Data);
}
void p_OutputDataReceived(object sender, DataReceivedEventArgs e)
{
Console.WriteLine("out:" + e.Data);
}
void p_Exited(object sender, EventArgs e)
{...
I put breakpoints inside all these handlers, but they were never reached (breakpoints in other places work, so it is not a debugger problem).
I am close to giving up all this mess.
Greetings - Jacek
|
|
|
|
|
Jacek Gajek wrote: No, i did not forget.
That does not fit well with the code you have shown.
I'm afraid I can't provide any more help, unless you show actual code.
|
|
|
|
|
Luc Pattyn wrote: That does not fit well with the code you have shown.
I meant I hadn't forgotten to add apriopriate lines after reading your post, of course . Here is the full code.
public void Exec(string commandName, vsCommandExecOption executeOption, ref object varIn, ref object varOut, ref bool handled)
{
handled = false;
if(executeOption == vsCommandExecOption.vsCommandExecOptionDoDefault)
{
if(commandName == "LatexAddin.Connect.LatexAddin")
{
Document doc = _applicationObject.ActiveDocument;
if (Path.GetExtension(doc.Name) == ".tex")
{
var p = new System.Diagnostics.Process();
var pinfo =new ProcessStartInfo
{
WindowStyle=ProcessWindowStyle.Hidden,
CreateNoWindow = true,
FileName = "pdflatex",
Arguments = string.Format("\"{0}\" -c-style-errors", doc.FullName),
WorkingDirectory = Path.GetDirectoryName(doc.FullName),
RedirectStandardError = true,
RedirectStandardOutput = true,
UseShellExecute = false
};
p.StartInfo = pinfo;
p.OutputDataReceived += p_OutputDataReceived;
p.ErrorDataReceived += p_ErrorDataReceived;
p.EnableRaisingEvents = true;
p.Exited += p_Exited;
p.Start();
}
return;
}
}
}
void p_ErrorDataReceived(object sender, DataReceivedEventArgs e)
{
Console.WriteLine("out:" + e.Data);
}
void p_OutputDataReceived(object sender, DataReceivedEventArgs e)
{
Console.WriteLine("out:" + e.Data);
}
void p_Exited(object sender, EventArgs e)
{
Console.Beep();
((Process) sender).Exited -= p_Exited;
((Process)sender).OutputDataReceived -= p_OutputDataReceived;
((Process)sender).ErrorDataReceived -= p_ErrorDataReceived;
}
Greetings - Jacek
|
|
|
|
|
For something like that that I'm playing with this week, I use:
this.process.StartInfo.CreateNoWindow = false ;
this.process.StartInfo.WindowStyle = System.Diagnostics.ProcessWindowStyle.Hidden ; <-- may be unnecessary
this.process.StartInfo.UseShellExecute = false ;
this.process.StartInfo.RedirectStandardInput =
this.process.StartInfo.RedirectStandardOutput =
this.process.StartInfo.RedirectStandardError = true ;
this.process.Start() ;
And I don't use the events.
One of the problems[^] into which I ran is that reading from the error stream seems to block.
I now have a work-around for that, which I may submit in an article today.
|
|
|
|
|
Thanks.
PIEBALDconsult wrote: this.process.StartInfo.WindowStyle = System.Diagnostics.ProcessWindowStyle.Hidden ; <-- may be unnecessary
This one did the trick.
Greetings - Jacek
|
|
|
|
|
Hurray it worked! thank you so much
Solution:
process.Start();
process.ErrorDataReceived+=new DataReceivedEventHandler(process_ErrorDataReceived);
process.OutputDataReceived+=new DataReceivedEventHandler(process_OutputDataReceived);
process.BeginOutputReadLine();
process.BeginErrorReadLine();
Greetings - Jacek
|
|
|
|
|
right. You did peek at my article?
|
|
|
|
|
Umm, yeach. Thank you both then.
Greetings - Jacek
|
|
|
|
|
you're welcome.
|
|
|
|
|
Some time ago, I had to do something similar (executing a command line tool from an ASP.NET application and parsing the result).
The following code worked for me:
ProcessStartInfo info = new ProcessStartInfo(executablePath)
{
UseShellExecute = false,
CreateNoWindow = true,
RedirectStandardError = true,
RedirectStandardOutput = true
};
|
|
|
|
|
Suppose i am writing code in .net e.g
int i=10
then .net show me red line under the code where error occurs.we know the i have not apply semicolon at the end of syntax(int i=10;)
who handles these error while writing the source code???.
|
|
|
|