private static void IE529Processing(string webUrl, int sadDocumentTypeId, ref string comments, NamedTraceLogger.TraceAction trace) { comments = "Reexport of goods failed"; trace("Entering ClearenceHelpers.IE529Processing", 61, TraceSeverity.Verbose); using (Entities _entities = new Entities(webUrl)) { SADDocumentType _sad = Element.GetAtIndex <SADDocumentType>(_entities.SADDocument, sadDocumentTypeId); foreach (SADGood _gdx in _sad.SADGood(_entities)) { IPRClearThroughCustoms(_entities, _gdx, trace); } comments = "Reexport of goods"; trace("ClearenceHelpers.IE529Processing SubmitChanges", 61, TraceSeverity.Verbose); _entities.SubmitChanges(); } }
private static void SADPZCProcessing(string webUrl, CustomsDocument.DocumentType messageType, int sadDocumentTypeId, ref string comments, List <Warnning> warnings, NamedTraceLogger.TraceAction trace) { trace("Entering ClearenceHelpers.SADPZCProcessing", 71, TraceSeverity.Verbose); List <CommonClearanceData> _tasksList = new List <CommonClearanceData>(); using (Entities entities = new Entities(webUrl)) { SADDocumentType sad = Element.GetAtIndex <SADDocumentType>(entities.SADDocument, sadDocumentTypeId); foreach (SADGood _sgx in sad.SADGood(entities)) { switch (_sgx.SPProcedure.RequestedProcedure()) { case CustomsProcedureCodes.FreeCirculation: if (messageType == CustomsDocument.DocumentType.SAD) { comments = "Document added"; continue; } if (_sgx.SPProcedure.PreviousProcedure() == CustomsProcedureCodes.CustomsWarehousingProcedure) { _tasksList.Add(CWPrepareClearance(entities, _sgx)); //Procedure 4071 } else if (_sgx.SPProcedure.PreviousProcedure() == CustomsProcedureCodes.InwardProcessing) { IPRClearThroughCustoms(entities, _sgx, trace); //Procedure 4051 } else { string _msg = string.Format("Unexpected previous procedure code {1} for the {0} message", messageType, _sgx.SPProcedure.PreviousProcedure()); trace("IPRDataConsistencyException at ClearenceHelpers.SADPZCProcessing: ", 140, TraceSeverity.Verbose); throw new IPRDataConsistencyException("SADPZCProcessing.FreeCirculation", _msg, null, c_wrongProcedure); } break; case CustomsProcedureCodes.InwardProcessing: { if (messageType == CustomsDocument.DocumentType.SAD) { comments = "Document added"; continue; } if (_sgx.SPProcedure.PreviousProcedure() == CustomsProcedureCodes.CustomsWarehousingProcedure) { _tasksList.Add(CWPrepareClearance(entities, _sgx)); //Procedure 5171 } // Procedure 5100 or 5171 Clearence _newClearance = Clearence.CreataClearance(entities, "InwardProcessing", ClearenceProcedure._5171, _sgx); CreateIPRAccount(entities, _newClearance, CustomsDocument.DocumentType.PZC, out comments, warnings, trace); break; } case CustomsProcedureCodes.CustomsWarehousingProcedure: Clearence _newWarehousinClearance = Clearence.CreataClearance(entities, "CustomsWarehousingProcedure", ClearenceProcedure._7100, _sgx); if (messageType == CustomsDocument.DocumentType.PZC) { comments = "CW account creation error"; CWAccountData _accountData = new CWAccountData(_newWarehousinClearance.Id.Value); _accountData.GetAccountData(entities, _newWarehousinClearance, ImportXMLCommon.Convert2MessageType(CustomsDocument.DocumentType.SAD), warnings, trace); _tasksList.Add(_accountData); } else { comments = "Document added"; } break; case CustomsProcedureCodes.NoProcedure: case CustomsProcedureCodes.ReExport: default: throw new IPRDataConsistencyException("SADPZCProcessing.RequestedProcedure", string.Format("Unexpected procedure code for the {0} message", messageType), null, c_wrongProcedure); } //switch ( _sgx.Procedure.RequestedProcedure() ) } //foreach ( SADGood _sgx in sad.SADGood ) entities.SubmitChanges(); } //using ( Entities entities foreach (CommonClearanceData _accountData in _tasksList) { if (_accountData is CWAccountData) { CreateCWAccount((CWAccountData)_accountData, webUrl, out comments); } else if (_accountData is CWClearanceData) { CWClearThroughCustoms((CWClearanceData)_accountData, webUrl, out comments); } } }