/// <remarks/>
 public void GET_REPAIR_ORDERS_WEBSRVCAsync(InputParameters InputParameters, object userState) {
     if ((this.GET_REPAIR_ORDERS_WEBSRVCOperationCompleted == null)) {
         this.GET_REPAIR_ORDERS_WEBSRVCOperationCompleted = new System.Threading.SendOrPostCallback(this.OnGET_REPAIR_ORDERS_WEBSRVCOperationCompleted);
     }
     this.InvokeAsync("GET_REPAIR_ORDERS_WEBSRVC", new object[] {
                 InputParameters}, this.GET_REPAIR_ORDERS_WEBSRVCOperationCompleted, userState);
 }
 /// <remarks/>
 public System.IAsyncResult BeginGET_REPAIR_ORDERS_WEBSRVC(InputParameters InputParameters, System.AsyncCallback callback, object asyncState) {
     return this.BeginInvoke("GET_REPAIR_ORDERS_WEBSRVC", new object[] {
                 InputParameters}, callback, asyncState);
 }
 /// <remarks/>
 public void GET_REPAIR_ORDERS_WEBSRVCAsync(InputParameters InputParameters) {
     this.GET_REPAIR_ORDERS_WEBSRVCAsync(InputParameters, null);
 }
        /// <summary>
        /// Returns a list of repair orders from EBS
        /// </summary>
        /// <param name="contact_id"></param>
        /// <param name="incident_id"></param>
        /// <param name="incident_number"></param>
        /// <param name="repair_number"></param>
        /// <param name="rntIncidentId"></param>
        /// <param name="rntContactId"></param>
        public RepairOrder[] LookupRepairOrderList(decimal contact_id, decimal incident_id, 
            string incident_number, string repair_number,
            int rntIncidentId = 0, int rntContactId = 0)
        {
            RepairOrder[] retvals = new RepairOrder[0];
            string logMessage, logNote;
                //validate user name and password for EBS web service
            if (String.IsNullOrWhiteSpace(RepairOrderListURL) ||
                String.IsNullOrWhiteSpace(RepairOrderListServiceUsername) ||
                String.IsNullOrWhiteSpace(RepairOrderListServicePassword))
            {
                throw new Exception("Provider's InitForRO not run.");
            }
                //create a soap header
            REPAIR_ORDER.CSD_REPAIR_ORDERS_WEB_Service client = EBSProxyFactory.GetRepairOrderListInstance(RepairOrderListURL, RepairOrderListServiceUsername, RepairOrderListServicePassword, RepairOrderListServiceTimeout);
            REPAIR_ORDER.SOAHeader hdr = new REPAIR_ORDER.SOAHeader();
            hdr.Responsibility = "DEPOT REPAIR";
            hdr.RespApplication = "CSD";
            hdr.SecurityGroup = "STANDARD";
            hdr.NLSLanguage = "AMERICAN";
            hdr.Org_Id = "204";

            client.SOAHeaderValue = hdr;
                //create request payload
            REPAIR_ORDER.InputParameters ip = new REPAIR_ORDER.InputParameters();
            bool has_incident = false;
            bool has_contact = false;
            if (incident_id > 0)
            {
                ip.P_INCIDENT_ID = Convert.ToString(incident_id);
                ip.P_INCIDENT_IDSpecified = true;
                has_incident = true;
            }
            else
            {
                ip.P_INCIDENT_ID = "";
                ip.P_INCIDENT_IDSpecified = false;
            }
            if (contact_id > 0)
            {
                has_contact = true;
                ip.P_SR_CONTACT_PARTY_ID = Convert.ToString(contact_id);
                ip.P_SR_CONTACT_PARTY_IDSpecified = true;
                ip.P_SR_CONTACT_TYPE = "PARTY_RELATIONSHIP";
            }
            else
            {
                ip.P_SR_CONTACT_PARTY_ID = "";
                ip.P_SR_CONTACT_PARTY_IDSpecified = false;
                ip.P_SR_CONTACT_TYPE = "";
            }
            bool has_repair_number = false;
            if (String.IsNullOrWhiteSpace(repair_number))
            {
                ip.P_REPAIR_NUMBER = "";
            }
            else
            {
                has_repair_number = true;
                ip.P_REPAIR_NUMBER = repair_number;
            }
            bool has_incident_number = false;
            if (String.IsNullOrWhiteSpace(incident_number))
            {
                ip.P_INCIDENT_NUMBER = "";
            }
            else
            {
                has_incident_number = true;
                ip.P_INCIDENT_NUMBER = incident_number;
            }
            string parameters = String.Format("GET_REPAIR_ORDERS_WEBSRVC for contact_id {0}, incident_id {1}, incident_number {2}, repair_number {3}",
                Convert.ToString(contact_id), Convert.ToString(incident_id), Convert.ToString(incident_number), Convert.ToString(repair_number));

            if ( !(has_incident | has_contact | has_repair_number | has_incident_number) )
            {
                logMessage = parameters + ". No valid parameters found. No search performed.";
                logNote = null;
                ConfigurationSetting.logWrap.DebugLog(incidentId: rntIncidentId, contactId: rntContactId, logMessage: logMessage, logNote: logNote);
                return retvals;
            }
            ip.P_RECORD_LIMIT = 100;
            ip.P_RECORD_LIMITSpecified = true;
            ip.P_REPAIR_LINE_ID = "";
            ip.P_REPAIR_LINE_IDSpecified = false;
            ip.P_SR_CUSTOMER_PARTY_ID = "";
            ip.P_SR_CUSTOMER_PARTY_IDSpecified = false;
            ip.P_SR_CUSTOMER_TYPE = "";

            logMessage = parameters + ". Request payload.";
            logNote = serializer.Serialize(ip);
            ConfigurationSetting.logWrap.DebugLog(incidentId: rntIncidentId, contactId: rntContactId, logMessage: logMessage, logNote: logNote);
            Stopwatch stopwatch = new Stopwatch();
            stopwatch.Start();
                //invoke ebs
            StringBuilder response = new StringBuilder("[{}");
            try
            {
                REPAIR_ORDER.OutputParameters opList = client.GET_REPAIR_ORDERS_WEBSRVC(ip);
                List<RepairOrder> items = new List<RepairOrder>();

                foreach (REPAIR_ORDER_LIST op in opList.X_REPLN_TBL)
                {
                    RepairOrder ro = new RepairOrder(getPropertyValues(op), contact_id, incident_id);
                    items.Add(ro);
                    response.Append(",").Append(ro.ToJSON());
                }
                retvals = items.ToArray();
            }
            catch (Exception ex)
            {
                handleEBSException(ex, parameters, rntIncidentId, rntContactId);
                throw;
            }
            stopwatch.Stop();
            int timeElapsed = stopwatch.Elapsed.Milliseconds;
            logMessage = new StringBuilder(parameters)
                .Append(" returned ").Append(retvals.Count()).Append(" records in ")
                .Append(timeElapsed).Append("ms")
                .ToString();
            logNote = response.Append(",{\"Count\":").Append("\"")
                .Append(retvals.Count()).Append("\"}]").ToString();
            ConfigurationSetting.logWrap.DebugLog(incidentId: rntIncidentId, contactId: rntContactId, logMessage: logMessage, logNote: logNote, timeElapsed: timeElapsed);
            return retvals;
        }