當前位置: 首頁>>代碼示例>>Golang>>正文


Golang cdd.PrintJobStateDiff類代碼示例

本文整理匯總了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
}
開發者ID:nooyoo11,項目名稱:cups-connector,代碼行數:32,代碼來源:cups.go

示例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
}
開發者ID:TechEdge01,項目名稱:cups-connector,代碼行數:28,代碼來源:cups.go


注:本文中的github.com/google/cups-connector/cdd.PrintJobStateDiff類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。