Here is my code. I Get the printticket from print job. I Need Printjob informations like copycount, media size, media type, duplex printing and other details. But I can default values from the printticket like copycount is always 1 and sometime no. of pages in job also comes 0. Now struggle with this problem. I Need Help to solve this problem.
PrintServer myPrintServer = new PrintServer(@"\\MyMachine");
PrintQueueCollection myPrintQueues = myPrintServer.GetPrintQueues();
foreach (PrintQueue pq in myPrintQueues)
if (pq.QueueStatus != PrintQueueStatus.Error)
foreach (PrintSystemJobInfo job in pq.GetPrintJobInfoCollection())
if (bNewJob == true)
PrintTicket pt = job.HostingPrintQueue.CurrentJobSettings.CurrentPrintTicket;
UpdateText("Current Copies : " + pt.CopyCount.Value.ToString());
UpdateText("Default Copies : " + dpt.CopyCount.Value.ToString());
UpdateText("User Copies : " + upt.CopyCount.Value.ToString());
UpdateText("Full Name :" + job.HostingPrintQueue.FullName.ToString());
UpdateText("Job ID : " + job.JobIdentifier.ToString());
UpdateText("Job Name : " + job.JobName.ToString());
DateTime dt = job.TimeJobSubmitted;
UpdateText("Submitter :" + job.Submitter.ToString());
UpdateText("Hosted Server :" + job.HostingPrintServer.Name.ToString());
UpdateText("No of Pages :" + job.NumberOfPages.ToString());
While this project I'm on is MVC, this question isn't specific to MVC, so I felt like this was the right place. Anyhow, we are using the Repository pattern for data access. One particular entity type, e.g. SharedObj, has several other entity types that the SharedObj entity can be tied to. Each is an IEnumerable, like this:
So when we add a child object to one of those collections of SharedObj, we have a method like this:
// 'entity' is of type 'SharedObj'publicvoid AddObj(ObjType objType, int objId)
// case/break for each remaining entity type
"ObjType" is an enumeration of object types. The "GetRepository" method calls "DependencyResolver.Current.GetService<irepository<t>>();" and we use Unity for dependency injection.
Is there a way to make a more generic "Add" call based on the supplied "ObjType"? Or is this the only concept that can be applied in order to achieve what we're doing?
djj55: Nice but may have a permission problem
Pete O'Hanlon: He has my permission to run it.
Similar to what Pete said; I'd prefer to use a Dictionary<type,List<whatever>>
And I think that having AddObj perform GetRepository and GetByID violates the Single Responsibility Principle.
By passing in the object, you could probably also leverage generics and simplify things even more.
This array shows music times: 1 - 1/2 - 1/4 - 1/8 and so on.
I think it should be written by recursive function, because I couldn't do it by while and for loop.
Now, I need all sorted figures that sum of them are equal 1. For example:
1/2 - 1/2
1/2 - 1/4 - 1/4
1/4 - 1/2 - 1/4
1/4 - 1/4 - 1/2
1/4 - 1/4 - 1/4 - 1/4
1/8 - 1/2 - 1/4 - 1/8
1/8 - 1/2 - 1/8 - 1/4
1/8 - 1/2 - 1/8 - 1/8 - 1/8
Of course, number of figures will be too many more if we add 1/16 and 1/32 and ... .
I can print them in a web page(response.write) or in a c console; it's not important. But the algorithm should be as simple as possible.
Thank you all.
Sounds like homework. And I think your implementation so far is going to cause trouble -- particularly due to the use of floating-point values (integers will suffice). And I definitely wouldn't use recursion.
I'd also like to pass along a hint. Rather than starting from 1/1 and splitting, consider starting from 1/16 - 1/16 ... and work up to 16/16 (or 32/32, whatever).
I have finished an implementation that uses an enumeration to define the values and returns an IEnumerable of Lists of the values; it's pretty slick and not much code. What do you have so far?
Edit: Due to poor performance when considering 1/32 and 1/64, I may look into a stack-based approach rather than the brute-force iterative approach.
Comparisons between the iterative and stack implementations:
6 rhythms found in 00:00:00.0000072
6 rhythms found in 00:00:00.0000057
// 1/4, with dots
8 rhythms found in 00:00:00.0000121
8 rhythms found in 00:00:00.0000064
56 rhythms found in 00:00:00.0015299
56 rhythms found in 00:00:00.0008122
// 1/8, with dots
114 rhythms found in 00:00:00.0015542
114 rhythms found in 00:00:00.0008210
5272 rhythms found in 00:00:00.0055043
5272 rhythms found in 00:00:00.0024528
// 1/16, with dots
24098 rhythms found in 00:00:00.0125192
24098 rhythms found in 00:00:00.0074718
So it looks like the stack-based algorithm generally takes about half the time as the iterative version.
I still haven't performed a full run on 1/32 or 1/64.
1) What I did was pick the smallest fraction I wanted to use ( 1/4, 1/8, 1/16, etc.) and then keep track of how many I had. The denominator doesn't change; so you only need to keep track of the numerator. The resulting fraction can be reduced later if desired -- that's only a matter of display.
I also found that using 1/32 and 1/64 took a very long time with my technique.