public QcInspectionResponse UpdateQcInspection(QcInspectionRequest qc)
 {
     return(_qcInspectionService.UpdateQcInspection(qc));
 }
Exemplo n.º 2
0
        public QcInspectionResponse UpdateQcInspection(QcInspectionRequest qc)
        {
            var inspection = new MaterialInspectionUpdateRequestMessage_sync();

            inspection.MaterialInspection          = new MaterialInspectionUpdateRequest();
            inspection.MaterialInspection.ID       = new BusinessTransactionDocumentID();
            inspection.MaterialInspection.ID.Value = qc.ExternalId;

            inspection.MaterialInspection.Decision = new MaterialInspectionUpdateRequestDecision();
            inspection.MaterialInspection.Decision.ActualInspectedQuantity       = new NONNEGATIVE_Quantity();
            inspection.MaterialInspection.Decision.ActualInspectedQuantity.Value = qc.InspectionQty;

            inspection.MaterialInspection.Decision.NonconformingUnitsNumberValueSpecified = true;
            inspection.MaterialInspection.Decision.NonconformingUnitsNumberValue          = qc.QtyFailed;

            if (!string.IsNullOrEmpty(qc.AcceptanceExternalId))
            {
                inspection.MaterialInspection.Decision.ProposedAcceptanceStatusCodeSpecified = true;
                inspection.MaterialInspection.Decision.ProposedAcceptanceStatusCode          = (AcceptanceStatusCode)Enum.Parse(typeof(AcceptanceStatusCode), qc.AcceptanceExternalId);
            }

            inspection.MaterialInspection.Decision.DecisionMakerEmployeeID       = new EmployeeID();
            inspection.MaterialInspection.Decision.DecisionMakerEmployeeID.Value = qc.CompletedByExternalId;

            inspection.MaterialInspection.Decision.Code       = new InspectionDecisionCode();
            inspection.MaterialInspection.Decision.Code.Value = qc.ResultExternalId;

            inspection.MaterialInspection.Decision.AttachmentFolder = new MaintenanceAttachmentFolder();
            inspection.MaterialInspection.Decision.AttachmentFolder.DocumentListCompleteTransmissionIndicatorSpecified = true;
            inspection.MaterialInspection.Decision.AttachmentFolder.DocumentListCompleteTransmissionIndicator          = true;
            inspection.MaterialInspection.Decision.AttachmentFolder.Document = new MaintenanceAttachmentFolderDocument[1];
            var document = new MaintenanceAttachmentFolderDocument();

            document.VisibleIndicatorSpecified = true;
            document.VisibleIndicator          = true;
            document.CategoryCode       = "3";
            document.TypeCode           = new DocumentTypeCode();
            document.TypeCode.Value     = "10001";
            document.Name               = qc.documentName;
            document.ExternalLinkWebURI = qc.documentUrl;

            if (!string.IsNullOrEmpty(qc.DocumentExternalId))
            {
                document.UUID                = new UUID();
                document.UUID.Value          = qc.DocumentExternalId;
                document.ActionCode          = ActionCode.Item04;
                document.ActionCodeSpecified = true;
            }

            inspection.MaterialInspection.Decision.AttachmentFolder.Document[0] = document;

            try
            {
                _sapClient.Update(inspection);
            }
            catch (Exception e)
            {
                return(new QcInspectionResponse {
                    Errors = new List <string> {
                        "Failure to update Qc Inspection: " + e.Message
                    }
                });
            }



            return(QueryQcInspection(qc.ExternalId));
        }