Exemplo n.º 1
0
        public ServiceRequest CreateSR(ServiceRequest sr, int _logIncidentId = 0, int _logContactId = 0)
        {
            if (String.IsNullOrWhiteSpace(SRServiceURL) || String.IsNullOrWhiteSpace(SRServiceUsername) || String.IsNullOrWhiteSpace(SRServicePassword))
            {
                throw new Exception("Provider's InitForSR not run.");
            }

            ServiceRequest result = sr;
            string request = "";
            string response = "";
            string logMessage, logNote;

            SR.CS_SERVICEREQUEST_PUB_Service client = EBSProxyFactory.GetSRServiceInstance(SRServiceURL, SRServiceUsername, SRServicePassword, SRServiceTimeout);

            SR.SOAHeader hdr = new SR.SOAHeader();
            hdr.Responsibility = "SERVICE";
            hdr.RespApplication = "CS";
            hdr.Org_Id = "204";
            hdr.SecurityGroup = "STANDARD";
            hdr.NLSLanguage = "AMERICAN";

            client.SOAHeaderValue = hdr;


            // Now to set the values for the request            

            if (!sr.RequestID.HasValue)
            {
                SR_CREATE_FIELDS sr_info = new SR_CREATE_FIELDS();
                // SR.APPSCS_SERVICEREQUEST_PUB_SERVIC7 req_info = new SR.APPSCS_SERVICEREQUEST_PUB_SERVIC7();

                sr_info.REQUEST_DATE = sr.RequestDate;
                sr_info.REQUEST_DATESpecified = true;
                sr_info.TYPE_ID = sr.RequestTypeID;
                sr_info.TYPE_IDSpecified = true;
                sr_info.STATUS_ID = sr.StatusID;
                sr_info.STATUS_IDSpecified = true;
                sr_info.SEVERITY_ID = sr.SeverityID;
                sr_info.SEVERITY_IDSpecified = true;
                sr_info.SUMMARY = sr.Summary;
                sr_info.CURRENT_SERIAL_NUMBER = sr.SerialNumber;
                if (sr.ProductID.HasValue)
                {
                    sr_info.CUSTOMER_PRODUCT_ID = sr.ProductID;
                    sr_info.CUSTOMER_PRODUCT_IDSpecified = true;
                    sr_info.INVENTORY_ORG_ID = 204;
                    sr_info.INVENTORY_ORG_IDSpecified = true;

                }

                // add RnowHost to extra attr 13
                sr_info.EXTERNAL_ATTRIBUTE_13 = sr.RnowHost;

                // added by rranaa for oow 2014
                sr_info.EXTERNAL_ATTRIBUTE_14 = sr.IncidentRef;
                sr_info.EXTERNAL_ATTRIBUTE_15 = sr.IncidentID;

                sr_info.CUSTOMER_ID = Convert.ToDecimal(sr.ContactOrgID);
                sr_info.CUSTOMER_IDSpecified = true;
                sr_info.CALLER_TYPE = "ORGANIZATION";
                sr_info.GROUP_TYPE = "RS_GROUP";

                if (sr.CreatedByID.HasValue)
                {
                    sr_info.CREATED_BYSpecified = true;
                    sr_info.CREATED_BY = sr.CreatedByID;
                }

                if (sr.OwnerID.HasValue)
                {
                    sr_info.OWNER_IDSpecified = true;
                    sr_info.OWNER_ID = sr.OwnerID;
                }
                /*
                if (sr.InstanceID.HasValue)
                {
                    sr_info.CUSTOMER_PRODUCT_ID = sr.InstanceID.Value;
                    sr_info.CUSTOMER_PRODUCT_IDSpecified = true;
                }
                */
                if (sr.IncidentOccurredDate.HasValue)
                {
                    sr_info.INCIDENT_OCCURRED_DATE = sr.IncidentOccurredDate.Value;
                    sr_info.INCIDENT_OCCURRED_DATESpecified = true;
                }

                SR.InputParameters ip_create_sr = new SR.InputParameters();
                ip_create_sr.P_API_VERSION = 4.0M;
                ip_create_sr.P_API_VERSIONSpecified = true;
                ip_create_sr.P_SERVICE_REQUEST_REC = sr_info;

                // Hard-coding the contact for the demo
                SR_CREATE_CONTACT sr_contact = new SR_CREATE_CONTACT();
                //c.CONTACT_POINT_ID = 7675;
                sr_contact.CONTACT_POINT_IDSpecified = true;
                sr_contact.CONTACT_POINT_TYPE = "PHONE";
                sr_contact.PARTY_ID = Convert.ToDecimal(sr.EbsContactID);

                sr_contact.PARTY_IDSpecified = true;
                sr_contact.PRIMARY_FLAG = "Y";
                sr_contact.PARTY_ROLE_CODE = "CONTACT";
                sr_contact.CONTACT_TYPE = "PARTY_RELATIONSHIP";

                List<SR_CREATE_CONTACT> sr_clist = new List<SR_CREATE_CONTACT>();
                sr_clist.Add(sr_contact);

                ip_create_sr.P_CONTACTS = sr_clist.ToArray();

                // Notes
                List<SR_CREATE_NOTES> sr_notes = new List<SR_CREATE_NOTES>();
                if (!String.IsNullOrWhiteSpace(sr.Notes))
                {
                    SR_CREATE_NOTES note = new SR_CREATE_NOTES();
                    note.NOTE = sr.Notes;
                    note.NOTE_CONTEXT_TYPE_01 = String.Empty;
                    note.NOTE_CONTEXT_TYPE_02 = String.Empty;
                    note.NOTE_CONTEXT_TYPE_03 = String.Empty;
                    note.NOTE_DETAIL = String.Empty;
                    note.NOTE_TYPE = String.Empty;

                    sr_notes.Add(note);

                }
                ip_create_sr.P_NOTES = sr_notes.ToArray();

                ip_create_sr.P_AUTO_ASSIGN = String.Empty;
                ip_create_sr.P_AUTO_GENERATE_TASKS = String.Empty;
                ip_create_sr.P_DEFAULT_CONTRACT_SLA_IND = "Y";
                ip_create_sr.P_INIT_MSG_LIST = "T";
                ip_create_sr.P_COMMIT = "T";
                ip_create_sr.P_REQUEST_NUMBER = String.Empty;
                Stopwatch stopwatch = new Stopwatch();
                try
                {
                    request = serializer.Serialize(ip_create_sr);
                    stopwatch.Start();
                    SR.OutputParameters op_create_sr = client.CREATE_SERVICEREQUEST(ip_create_sr);
                    stopwatch.Stop();
                    response =  serializer.Serialize(op_create_sr);

                    if (op_create_sr.X_RETURN_STATUS == "S")
                    {
                        SR_CREATE data = op_create_sr.X_SR_CREATE_OUT_REC;
                        result.RequestID = data.REQUEST_ID;
                        result.RequestNumber = data.REQUEST_NUMBER;

                        logMessage = "Request of creating Service Request (Success). Created SR ID: " + result.RequestID;
                        logNote = "Request Payload: " + request;
                        log.DebugLog(_logIncidentId, _logContactId, logMessage, logNote);

                        logMessage = "Response of creating Service Request (Success). Created SR ID: " + result.RequestID;
                        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 Service Request (Failure). " + op_create_sr.X_MSG_DATA;
                        logNote = "Request Payload: " + request;
                        log.ErrorLog(_logIncidentId, _logContactId, logMessage, logNote);

                        logMessage = "Response of creating Service Request (Failure). " + op_create_sr.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 Service Request (Failure). " + ex.Message;
                    logNote = "Request Payload: " + request;
                    log.ErrorLog(_logIncidentId, _logContactId, logMessage, logNote);

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

                    handleEBSException(ex, "Create Service Request", _logIncidentId, _logContactId);
                }
            }


            return result;
        }
 /// <remarks/>
 public void CREATE_SERVICEREQUESTAsync(InputParameters InputParameters) {
     this.CREATE_SERVICEREQUESTAsync(InputParameters, null);
 }
 /// <remarks/>
 public void CREATE_SERVICEREQUESTAsync(InputParameters InputParameters, object userState) {
     if ((this.CREATE_SERVICEREQUESTOperationCompleted == null)) {
         this.CREATE_SERVICEREQUESTOperationCompleted = new System.Threading.SendOrPostCallback(this.OnCREATE_SERVICEREQUESTOperationCompleted);
     }
     this.InvokeAsync("CREATE_SERVICEREQUEST", new object[] {
                 InputParameters}, this.CREATE_SERVICEREQUESTOperationCompleted, userState);
 }
 /// <remarks/>
 public System.IAsyncResult BeginCREATE_SERVICEREQUEST(InputParameters InputParameters, System.AsyncCallback callback, object asyncState) {
     return this.BeginInvoke("CREATE_SERVICEREQUEST", new object[] {
                 InputParameters}, callback, asyncState);
 }