المساعد الشخصي الرقمي

مشاهدة النسخة كاملة : How useful WhiteFramework in C# to automate Print Jobs?



C# Programming
08-05-2011, 12:13 PM
Hi all,

I am developing a console application using C# to automate Print Job for a bulk of documents. Below I am mentioning my plan for developing and my approach.

Algorithm:

1)Fetch list of documents.
2)Process the document list one by one.
a)Launch the Application.
b)Wait till the application launched perfectly.
c)Fire the Print Job.
d)Wait for Print dialog appear.
e)Fire "ENTER" key press event.
f)Wait till spooling finish.
g)Close the document and application.
3)Update the XML with Print job info.


Code:
//Launch the file from the ******** specified in.
White.Core.Application application =White.Core.Application.Launch(@path);

Console.WriteLine("launch is done");

Thread.Sleep(3000);//Wait till Application Launched successfully.

//Sending Commands to Print(to press "Ctrl+P" button).
SendKeys.SendWait("^(p)");

Thread.Sleep(3000);//Wait till Print Dialog appear

//Sending Commands to Print(to press "Enter" Button).
SendKeys.SendWait("{ENTER}");

//Get the current time as the document fired for print job.
_printedTime = DateTime.Now;

Thread.Sleep(3000);//Wait till spooling Finish.

//Closing the ********
SendKeys.SendWait("%{F4}");


Now the problem is for waiting case I am blindly using Thread.Sleep(With Few seconds), which is not Ideal. So I need to know How I'll fix these issues using White Framework in C#.

Can anybody help me to fix this issue please. Any help will be appreciated.
Thanks in advance