本文整理匯總了Golang中github.com/google/cups-connector/cdd.PrintJobStateDiff類的典型用法代碼示例。如果您正苦於以下問題:Golang PrintJobStateDiff類的具體用法?Golang PrintJobStateDiff怎麽用?Golang PrintJobStateDiff使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
在下文中一共展示了PrintJobStateDiff類的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。
示例1: convertJobState
// convertJobState converts CUPS job state to cdd.PrintJobStateDiff.
func convertJobState(cupsState, pages int32) cdd.PrintJobStateDiff {
state := cdd.PrintJobStateDiff{PagesPrinted: pages}
switch cupsState {
case 3: // PENDING
state.State = cdd.JobState{Type: "IN_PROGRESS"}
case 4: // HELD
state.State = cdd.JobState{Type: "IN_PROGRESS"}
case 5: // PROCESSING
state.State = cdd.JobState{Type: "IN_PROGRESS"}
case 6: // STOPPED
state.State = cdd.JobState{
Type: "STOPPED",
DeviceActionCause: &cdd.DeviceActionCause{ErrorCode: "OTHER"},
}
case 7: // CANCELED
state.State = cdd.JobState{
Type: "ABORTED",
UserActionCause: &cdd.UserActionCause{ActionCode: "CANCELLED"}, // Spelled with two L's.
}
case 8: // ABORTED
state.State = cdd.JobState{
Type: "ABORTED",
DeviceActionCause: &cdd.DeviceActionCause{ErrorCode: "PRINT_FAILURE"},
}
case 9: // COMPLETED
state.State = cdd.JobState{Type: "DONE"}
}
return state
}
示例2: convertJobState
// convertJobState converts CUPS job state to cdd.PrintJobStateDiff.
func convertJobState(cupsState int32) cdd.PrintJobStateDiff {
var state cdd.PrintJobStateDiff
switch cupsState {
case 3, 4, 5: // PENDING, HELD, PROCESSING
state.State = &cdd.JobState{Type: cdd.JobStateInProgress}
case 6: // STOPPED
state.State = &cdd.JobState{
Type: cdd.JobStateStopped,
DeviceActionCause: &cdd.DeviceActionCause{ErrorCode: cdd.DeviceActionCauseOther},
}
case 7: // CANCELED
state.State = &cdd.JobState{
Type: cdd.JobStateAborted,
UserActionCause: &cdd.UserActionCause{ActionCode: cdd.UserActionCauseCanceled},
}
case 8: // ABORTED
state.State = &cdd.JobState{
Type: cdd.JobStateAborted,
DeviceActionCause: &cdd.DeviceActionCause{ErrorCode: cdd.DeviceActionCausePrintFailure},
}
case 9: // COMPLETED
state.State = &cdd.JobState{Type: cdd.JobStateDone}
}
return state
}