Advertisement
Guest User

Untitled

a guest
Apr 19th, 2018
66
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 4.23 KB | None | 0 0
  1. private static RegistrationPipelineState GetFirstStageState(DeclarationDocflowState declarationDocflowState)
  2.         {
  3.             switch (declarationDocflowState)
  4.             {
  5.                 case DeclarationDocflowState.Unknown:
  6.                     return RegistrationPipelineState.CreatedDeclaration;
  7.                 case DeclarationDocflowState.Sent:
  8.                 case DeclarationDocflowState.HasFailedTransaction:
  9.                 case DeclarationDocflowState.HasSuccessfulTransaction:
  10.                     return RegistrationPipelineState.SentDeclaration;
  11.                 case DeclarationDocflowState.Successful:
  12.                     return RegistrationPipelineState.AcceptedDeclaration;
  13.                 case DeclarationDocflowState.Failed:
  14.                     return RegistrationPipelineState.RejectedDeclaration;
  15.                 default:
  16.                     throw new ArgumentOutOfRangeException(nameof(declarationDocflowState), declarationDocflowState, null);
  17.             }
  18.         }
  19.  
  20.         private static RegistrationPipelineState GetSecondStageState(DeclarationDemandDocflowState declarationDemandDocflowState)
  21.         {
  22.             switch (declarationDemandDocflowState)
  23.             {
  24.                 case DeclarationDemandDocflowState.Unknown:
  25.                     return RegistrationPipelineState.SentDeclaration;
  26.                 case DeclarationDemandDocflowState.AcceptedDeclaration:
  27.                     return RegistrationPipelineState.AcceptedDeclarationDemand;
  28.                 case DeclarationDemandDocflowState.RejectedDeclaration:
  29.                     return RegistrationPipelineState.RejectedDeclarationDemand;
  30.                 default:
  31.                     throw new ArgumentOutOfRangeException(nameof(declarationDemandDocflowState), declarationDemandDocflowState, null);
  32.             }
  33.         }
  34.  
  35.         private static RegistrationPipelineState GetThirdStageState(ReportDocflowState reportDocflowState)
  36.         {
  37.             switch (reportDocflowState)
  38.             {
  39.                 case ReportDocflowState.Unknown:
  40.                     return RegistrationPipelineState.ReportCreated;
  41.                 case ReportDocflowState.Sent:
  42.                 case ReportDocflowState.HasFailedTransaction:
  43.                 case ReportDocflowState.HasSuccessfulTransaction:
  44.                     return RegistrationPipelineState.ReportSent;
  45.                 case ReportDocflowState.Successful:
  46.                     return RegistrationPipelineState.ReportAccepted;
  47.                 case ReportDocflowState.Failed:
  48.                     return RegistrationPipelineState.ReportRejected;
  49.                 default:
  50.                     throw new ArgumentOutOfRangeException(nameof(reportDocflowState), reportDocflowState, null);
  51.             }
  52.         }
  53.  
  54.         private static RegistrationPipelineState GetState(
  55.             DeclarationDocflowState declarationDocflowState,
  56.             DeclarationDemandDocflowState declarationDemandDocflowState,
  57.             ReportDocflowState reportDocflowState)
  58.         {
  59.             try
  60.             {
  61.                 var lastStage = GetFirstStageState(declarationDocflowState);
  62.                 if (lastStage != RegistrationPipelineState.AcceptedDeclaration)
  63.                 {
  64.                     lastStage = GetSecondStageState(declarationDemandDocflowState);
  65.                     if (lastStage != RegistrationPipelineState.AcceptedDeclarationDemand)
  66.                     {
  67.                         lastStage = GetThirdStageState(reportDocflowState);
  68.                         if (lastStage != RegistrationPipelineState.ReportAccepted)
  69.                         {
  70.                             //lastStage = GetForthState(reportDemandDocflowState);
  71.                         }
  72.                     }
  73.                 }
  74.                 return lastStage;
  75.             }
  76.             catch (ArgumentOutOfRangeException e)
  77.             {
  78.                 throw new IllegalProgramException("Unknown RegistrationPipelineState")
  79.                     .AddData("DeclarationDocflowState", declarationDocflowState)
  80.                     .AddData("DeclarationDemandDocflowState", declarationDemandDocflowState)
  81.                     .AddData("ReportDocflowState", reportDocflowState)
  82.                     .AddData("Exception", e);
  83.             }
  84.         }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement