/// <summary> /// Constructor /// </summary> /// <param name="printJob">management base object as a print job</param> /// <param name="host">host name</param> public PrintJobData(ManagementBaseObject printJob, string host) { if (printJob == null) { return; } ServerHost = host; PrintJob = printJob; PrintJobTitle = new PrintJobTitle(); try { JobStatus = new PrintJobStatus(PrintJobStatusEnum.None, null); string name; int id; // extract printer name and job Id PrintHelper.ExtractNameAndId(printJob, out name, out id); PrintJobTitle.PrinterName = name; PrintJobTitle.JobID = id; PrintJobTitle.Document = printJob.Properties["Document"].Value.ToString(); PrintJobTitle.Host = printJob.Properties["HostPrintQueue"].Value.ToString(); if (!string.IsNullOrWhiteSpace(PrintJobTitle.Host)) { PrintJobTitle.Host = PrintJobTitle.Host.Replace("\\", "").Trim(); } PrintJobTitle.Owner = printJob.Properties["Owner"].Value.ToString(); Color = false; string color = printJob.Properties["Color"].Value.ToString(); if (!string.IsNullOrWhiteSpace(color)) { if (color.ToLower() != "monochrome") { Color = true; } } JobStatus = printJob.JobStatus(); int totalPages = -1; int.TryParse(printJob.Properties["TotalPages"].Value.ToString(), out totalPages); PrintJobTitle.TotalPages = totalPages; } catch (Exception ex) { throw new ArgumentException("Wrong PrintJobData", ex); } }
/// <summary> /// /// </summary> /// <param name="obj"></param> /// <returns></returns> public override bool Equals(object obj) { PrintJobTitle title = obj as PrintJobTitle; if (title == null) { return(false); } LogHelper.LogDebug(this + " & " + title); if (title.PrinterName == PrinterName && title.Document == Document && title.Owner == Owner && title.Host == Host && title.JobID == JobID) { return(true); } LogHelper.LogDebug("Not equal"); return(false); }