Ejemplo n.º 1
0
        public RepairOrder CreateRO(RepairOrder ro, int _logIncidentId = 0, int _logContactId = 0)
        {
            RepairOrder result = ro;
            string request = "";
            string response = "";
            string logMessage, logNote;

            if (String.IsNullOrWhiteSpace(ROCreateURL) || String.IsNullOrWhiteSpace(ROServiceUsername) || String.IsNullOrWhiteSpace(ROServicePassword))
            {
                throw new Exception("Provider's InitForRO not run.");
            }

            RO.CSD_REPAIRS_PUB_Service client = EBSProxyFactory.GetDepotInstance(ROCreateURL, ROServiceUsername, ROServicePassword, ROServiceTimeout);
            RO.SOAHeader hdr = new RO.SOAHeader();
            hdr.Responsibility = "ORACLE_SUPPORT";
            hdr.RespApplication = "CSS";
            hdr.Org_Id = "204";
            hdr.SecurityGroup = "STANDARD";
            hdr.NLSLanguage = "AMERICAN";

            client.SOAHeaderValue = hdr;

            if (ro.RepairNumber == null)
            {
                RO.InputParameters ip_create_ro = new RO.InputParameters();
                ip_create_ro.P_API_VERSION_NUMBER = 1.0M;
                ip_create_ro.P_API_VERSION_NUMBERSpecified = true;
                ip_create_ro.P_INIT_MSG_LIST = "T";
                ip_create_ro.P_COMMIT = "F";
                ip_create_ro.P_CREATE_DEFAULT_LOGISTICS = "N";

                RO.APPSCSD_REPAIRS_PUB_RX220752X1X6 ro_info = new RO.APPSCSD_REPAIRS_PUB_RX220752X1X6();
                ro_info.INCIDENT_ID = ro.ServiceRequestID;
                ro_info.INCIDENT_IDSpecified = true;
                ro_info.UNIT_OF_MEASURE = ro.UnitOfMeasure;
                ro_info.REPAIR_TYPE_ID = ro.RepairTypeID;
                ro_info.REPAIR_TYPE_IDSpecified = true;
                ro_info.QUANTITY = ro.Quantity;
                ro_info.QUANTITYSpecified = true;
                ro_info.INVENTORY_ITEM_ID = ro.InventoryItemID;
                ro_info.INVENTORY_ITEM_IDSpecified = true;
                ro_info.APPROVAL_REQUIRED_FLAG = ro.ApprovalRequired;
                ro_info.CURRENCY_CODE = ro.Currency;
                ro_info.PROBLEM_DESCRIPTION = ro.ProblemDescription;
                ro_info.RESOURCE_ID = ro.ResourceID;
                ro_info.RESOURCE_IDSpecified = true;
                ro_info.AUTO_PROCESS_RMA = String.Empty;
                ro_info.SERIAL_NUMBER = ro.SerialNumber;
                if (!string.IsNullOrWhiteSpace(ro.HasValidSerialNumber))
                    ro_info.ATTRIBUTE15 = ro.HasValidSerialNumber;

                ip_create_ro.P_REPLN_REC = ro_info;
                Stopwatch stopwatch = new Stopwatch();
                try
                {
                    request = serializer.Serialize(ip_create_ro);
                    stopwatch.Start();
                    RO.OutputParameters op_create_ro = client.CREATE_REPAIR_ORDER(ip_create_ro);
                    stopwatch.Stop();
                    response = serializer.Serialize(op_create_ro);

                    if (op_create_ro.X_RETURN_STATUS == "S")
                    {
                        result.RepairNumber = op_create_ro.X_REPAIR_NUMBER;
                        result.RepairLineID = Convert.ToDecimal(op_create_ro.X_REPAIR_LINE_ID);

                        logMessage = "Request of creating Repair Order (Success). Created RO Number: " + result.RepairNumber;
                        logNote = "Request Payload: " + request;
                        log.DebugLog(_logIncidentId, _logContactId, logMessage, logNote);

                        logMessage = "Response of creating Repair Order (Success). Created RO Number: " + result.RepairNumber;
                        logNote = "Response Payload: " + response;

                        log.DebugLog(_logIncidentId, _logContactId, logMessage, logNote, (int)stopwatch.ElapsedMilliseconds);
                    }
                    else
                    {
                        result.ErrorMessage = "There has been an error communicating with EBS. Please check log for detail.";

                        logMessage = "Request of creating Repair Order (Failure). " + op_create_ro.X_MSG_DATA;
                        logNote = "Request Payload: " + request;
                        log.ErrorLog(_logIncidentId, _logContactId, logMessage, logNote);

                        logMessage = "Response of creating Repair Order (Failure). " + op_create_ro.X_MSG_DATA;
                        logNote = "Response Payload: " + response;
                        log.ErrorLog(_logIncidentId, _logContactId, logMessage, logNote);
                    }
                }
                catch (Exception ex)
                {
                    result.ErrorMessage = "There has been an error communicating with EBS. Please check log for detail.";

                    logMessage = "Request of creating Repair Order (Failure). " + ex.Message;
                    logNote = "Request Payload: " + request;
                    log.ErrorLog(_logIncidentId, _logContactId, logMessage, logNote);

                    logMessage = "Response of creating Repair Order (Failure). " + ex.Message;
                    logNote = "Response Payload: " + response;
                    log.ErrorLog(_logIncidentId, _logContactId, logMessage, logNote);

                    handleEBSException(ex, "Create Repair Order", _logIncidentId, _logContactId);
                }

            }

            return result;
        }
Ejemplo n.º 2
0
        public RepairOrder UpdateRO(RepairOrder ro, int _logIncidentId = 0, int _logContactId = 0)
        {
            //throw new NotImplementedException();
            RepairOrder result = ro;
            string request = "";
            string response = "";

            string logMessage, logNote;

            if (String.IsNullOrWhiteSpace(ROUpdateURL) || String.IsNullOrWhiteSpace(ROServiceUsername) || String.IsNullOrWhiteSpace(ROServicePassword))
            {
                throw new Exception("Provider's InitForRO not run.");
            }

            RO.CSD_REPAIRS_PUB_Service client = EBSProxyFactory.GetDepotInstance(ROCreateURL, ROServiceUsername, ROServicePassword, ROServiceTimeout);
            RO.SOAHeader hdr = new RO.SOAHeader();
            hdr.Responsibility = "ORACLE_SUPPORT";
            hdr.RespApplication = "CSS";
            hdr.Org_Id = "204";
            hdr.SecurityGroup = "STANDARD";
            hdr.NLSLanguage = "AMERICAN";

            client.SOAHeaderValue = hdr;

            if (ro.RepairNumber != null)
            {
                RO.InputParameters1 ip_update_ro_status = new RO.InputParameters1();

                ip_update_ro_status.P_API_VERSION = 1.0M;
                ip_update_ro_status.P_API_VERSIONSpecified = true;
                ip_update_ro_status.P_INIT_MSG_LIST = "F";
                ip_update_ro_status.P_COMMIT = "T";

                RO.APPSCSD_REPAIRS_PUB_RX220752X3X7 repair_status = new RO.APPSCSD_REPAIRS_PUB_RX220752X3X7();

                repair_status.REPAIR_NUMBER = ro.RepairNumber;
                repair_status.REPAIR_STATUS_ID = ro.RepairStatusID;
                repair_status.REPAIR_STATUS_IDSpecified = true;
                repair_status.FROM_STATUS_ID = ro.StoredRepairStatusID;
                repair_status.FROM_STATUS_IDSpecified = true;
                repair_status.OBJECT_VERSION_NUMBER = 0;
                repair_status.OBJECT_VERSION_NUMBERSpecified = true;
                repair_status.REASON_CODE = String.Empty;
                ip_update_ro_status.P_REPAIR_STATUS_REC = repair_status;

                RO.APPSCSD_REPAIRS_PUB_X220752X3X18 other = new RO.APPSCSD_REPAIRS_PUB_X220752X3X18();
                other.CHECK_TASK_WIP = String.Empty;
                ip_update_ro_status.P_STATUS_UPD_CONTROL_REC = other;

                Stopwatch stopwatch = new Stopwatch();
                try
                {
                    request = serializer.Serialize(ip_update_ro_status);
                    stopwatch.Start();
                    RO.OutputParameters1 op_update_ro_status = client.UPDATE_RO_STATUS(ip_update_ro_status);
                    stopwatch.Stop();
                    response = serializer.Serialize(op_update_ro_status);
                    if (op_update_ro_status.X_RETURN_STATUS == "S")
                    {

                        result.RepairNumber = ro.RepairNumber;


                        logMessage = "Request of updating Repair Order (Success). RO Number = " + result.RepairNumber;
                        logNote = "Request Payload: " + request;
                        log.DebugLog(_logIncidentId, _logContactId, logMessage, logNote);

                        logMessage = "Response of updating Repair Order  (Success). RO Number = " + result.RepairNumber;
                        logNote = "Response Payload: " + response;

                        log.DebugLog(_logIncidentId, _logContactId, logMessage, logNote, (int)stopwatch.ElapsedMilliseconds);

                    }
                    else if (op_update_ro_status.X_RETURN_STATUS == "U")
                    {
                        result.ErrorMessage = String.Format("Cannot set status from {0} to {1}", ro.StoredRepairStatus, ro.RepairStatus);

                        logMessage = "Request of updating Repair Order(Failure). RO Number = " + result.RepairNumber + " Error: " + result.ErrorMessage;
                        logNote = "Request Payload: " + request;
                        log.ErrorLog(_logIncidentId, _logContactId, logMessage, logNote);

                        logMessage = "Response of updating Repair Order (Failure). RO Number = " + result.RepairNumber + " Error: " + result.ErrorMessage;
                        logNote = "Response Payload: " + response;
                        log.ErrorLog(_logIncidentId, _logContactId, logMessage, logNote);

                        result.RepairNumber = "-1";
                    }
                    else
                    {
                        result.ErrorMessage = "There has been an error communicating with EBS. Please check log for detail.";

                        logMessage = "Request of updating Repair Order(Failure). RO Number = "  +result.RepairNumber + " Error: " + op_update_ro_status.X_MSG_DATA;
                        logNote = "Request Payload: " + request;
                        log.ErrorLog(_logIncidentId, _logContactId, logMessage, logNote);

                        logMessage = "Response of updating Repair Order (Failure). RO Number = "  +result.RepairNumber + " Error: " + op_update_ro_status.X_MSG_DATA;
                        logNote = "Response Payload: " + response;
                        log.ErrorLog(_logIncidentId, _logContactId, logMessage, logNote);
                    }
                }
                catch (Exception ex)
                {
                    result.ErrorMessage = "There has been an error communicating with EBS. Please check log for detail.";

                    logMessage = "Request of updating Repair Order(Failure). RO Number = " + result.RepairNumber + " Error: " + ex.Message;
                    logNote = "Request Payload: " + request;
                    log.ErrorLog(_logIncidentId, _logContactId, logMessage, logNote);

                    logMessage = "Response of updating Repair Order (Failure). RO Number = " + result.RepairNumber + " Error: " + ex.Message;
                    logNote = "Response Payload: " + response;
                    log.ErrorLog(_logIncidentId, _logContactId, logMessage, logNote);

                    handleEBSException(ex, "Update Repair Order Status");
                }

            }

            return result;
        }