| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106 |
- using System;
- using System.Collections.Generic;
- using System.Linq;
- namespace TeamAAS_VP.Core.Sfis
- {
- public static class SfisDelimiters
- {
- public const char Field = (char)127;
- }
- public class SfisResponse
- {
- public string Raw { get; set; }
- public string[] Fields { get; set; } = new string[0];
- public int ReturnCode { get; set; }
- public string Message { get; set; }
- public bool IsSuccess => ReturnCode == 1;
- public string GetField(int index)
- {
- if (Fields == null || index < 0 || index >= Fields.Length)
- return null;
- return Fields[index];
- }
- public static SfisResponse Parse(string raw)
- {
- var response = new SfisResponse { Raw = raw ?? string.Empty };
- if (string.IsNullOrWhiteSpace(raw))
- {
- response.ReturnCode = 0;
- response.Message = "SFIS 返回为空";
- return response;
- }
- response.Fields = raw.Split(SfisDelimiters.Field);
- if (response.Fields.Length > 0 && int.TryParse(response.Fields[0], out int code))
- response.ReturnCode = code;
- else
- response.ReturnCode = 0;
- response.Message = response.Fields.Length > 1 ? response.Fields[1] : raw;
- return response;
- }
- }
- public class SfisUnitContext
- {
- public string Isn { get; set; }
- public string ReelIdSn { get; set; }
- public string MoNumber { get; set; }
- public string PassType { get; set; }
- public string AoiLocTag { get; set; }
- public bool TestPassed { get; set; } = true;
- public string ErrorCode { get; set; }
- public IList<SfisTestRecord> TestRecords { get; set; } = new List<SfisTestRecord>();
- }
- public class SfisTestRecord
- {
- public string TestName { get; set; }
- public bool Passed { get; set; }
- public string Value { get; set; }
- }
- public class SfisWorkflowStepResult
- {
- public string StepName { get; set; }
- public SfisResponse Response { get; set; }
- }
- public class SfisWorkflowResult
- {
- public bool Success { get; set; }
- public string Isn { get; set; }
- public IList<SfisWorkflowStepResult> Steps { get; set; } = new List<SfisWorkflowStepResult>();
- public string ErrorMessage { get; set; }
- public SfisWorkflowStepResult GetStep(string stepName)
- {
- return Steps.FirstOrDefault(s => s.StepName == stepName);
- }
- }
- public class SfisInputDataPayload
- {
- public string PassType { get; set; }
- public string MoNumber { get; set; }
- public string ReelIdSn { get; set; }
- public string AoiLocTag { get; set; }
- public string Isn { get; set; }
- public string BuildDataString()
- {
- return string.Join(
- SfisDelimiters.Field.ToString(),
- PassType ?? string.Empty,
- MoNumber ?? string.Empty,
- ReelIdSn ?? string.Empty,
- AoiLocTag ?? string.Empty,
- Isn ?? string.Empty);
- }
- }
- }
|