public IState NextStage(DocumentProcess dc) { if (dc.doc.DocSignature == 2) { dc.documentState = DocumentState.Approval; return(new Approval()); } else { throw new SignatureProcessException(); } }
public IState NextStage(DocumentProcess dc) { if (dc.doc.DocApproval == 1) { Console.WriteLine($"{dc.doc.GetName} прошел весь процес"); return(new FinalState()); } else { throw new ApprovalProcessException(); } }
public IState NextStage(DocumentProcess dc) { if (dc.doc.DocVote == 5) { dc.documentState = DocumentState.Signature; return(new Signature()); } else { throw new VoteProcessException(); } }
static void Main(string[] args) { Document doc1 = new Document("Document 1"); DocumentProcess dc1 = new DocumentProcess(doc1); try { doc1.VoteDoc(); doc1.VoteDoc(); doc1.VoteDoc(); Console.WriteLine("После двух голосов " + dc1.documentState); doc1.VoteDoc(); doc1.VoteDoc(); dc1.NextStage(); Console.WriteLine("После 5 голосов " + dc1.documentState); doc1.SignatureDoc(); doc1.SignatureDoc(); dc1.NextStage(); Console.WriteLine("После 2 подписей " + dc1.documentState); doc1.ApprovalDoc(); dc1.NextStage(); } catch (VoteProcessException e) { Console.WriteLine(e.Message); } catch (SignatureProcessException e) { Console.WriteLine(e.Message); } catch (ApprovalProcessException e) { Console.WriteLine(e.Message); } catch (FinalProcessException e) { Console.WriteLine(e.Message); } catch (DocException e) { Console.WriteLine(e.Message); } catch (VoteException e) { Console.WriteLine(e.Message); } catch (SignatureException e) { Console.WriteLine(e.Message); } catch (ApprovalException e) { Console.WriteLine(e.Message); } }
public IState NextStage(DocumentProcess dc) { throw new FinalProcessException(); }