Пример #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;
        }
Пример #2
0
        public ServiceRequest LookupSR(decimal incident_id, string incident_number, int _logIncidentId = 0, int _logContactId = 0)
        {
            if (String.IsNullOrWhiteSpace(SRLookupURL) || String.IsNullOrWhiteSpace(SRServiceUsername) || String.IsNullOrWhiteSpace(SRServicePassword))
            {
                throw new Exception("Provider's InitForSR not run.");
            }

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

            ServiceRequest result = new ServiceRequest();
            string request = "";
            string response = "";
            string logMessage, logNote;

            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;

            SR.InputParameters3 ip_get_sr = new SR.InputParameters3();
            ip_get_sr.P_API_VERSION = 1;
            ip_get_sr.P_API_VERSIONSpecified = true;
            ip_get_sr.P_INCIDENT_ID = incident_id;
            ip_get_sr.P_INCIDENT_IDSpecified = true;
            ip_get_sr.P_INCIDENT_NUMBER = incident_number;
            List<SR_LOOKUP_CONTACT> contacts = new List<SR_LOOKUP_CONTACT>();
            ip_get_sr.X_CONTACT = contacts.ToArray();
            List<SR_LOOKUP_TASK> tasks = new List<SR_LOOKUP_TASK>();
            ip_get_sr.X_TASKS = tasks.ToArray();
            //ip.X_GETSR_OUT_REC = new SRL.APPSCS_SERVICEREQUEX16438971X1X2();
            Stopwatch stopwatch = new Stopwatch();
            try
            {
                request = serializer.Serialize(ip_get_sr);
                stopwatch.Start();
                SR.OutputParameters3 op = client.GET_SR_INFO(ip_get_sr);
                stopwatch.Stop();
                //response = client.ResponseSoapContext.Envelope.Envelope.InnerXml;
                response = serializer.Serialize(op);

                if (op.X_RETURN_STATUS == "S")
                {
                    result.RequestID = op.X_GETSR_OUT_REC.INCIDENT_ID;
                    result.RequestNumber = op.X_GETSR_OUT_REC.INCIDENT_NUMBER;
                    result.IncidentID = op.X_GETSR_OUT_REC.EXTATTRIBUTE15;
                    result.IncidentRef = op.X_GETSR_OUT_REC.EXTATTRIBUTE14;
                    result.StatusID = op.X_GETSR_OUT_REC.INCIDENT_STATUS_ID;
                    result.Status = op.X_GETSR_OUT_REC.INCIDENT_STATUS;
                    result.SeverityID = op.X_GETSR_OUT_REC.INCIDENT_SEVERITY_ID;
                    result.Severity = op.X_GETSR_OUT_REC.INCIDENT_SEVERITY;
                    result.RequestTypeID = op.X_GETSR_OUT_REC.INCIDENT_TYPE_ID;
                    result.RequestType = op.X_GETSR_OUT_REC.INCIDENT_TYPE;
                    result.Summary = op.X_GETSR_OUT_REC.SUMMARY;
                    result.SrObjVerNum = op.X_GETSR_OUT_REC.OBJECT_VERSION_NUMBER;
                    result.SerialNumber = op.X_GETSR_OUT_REC.SERIAL_NUMBER;
                    result.ProductID = op.X_GETSR_OUT_REC.CUSTOMER_PRODUCT_ID;
                    result.Product = op.X_GETSR_OUT_REC.PRODUCT;
                    result.ProductDescription = op.X_GETSR_OUT_REC.PRODUCT_DESCRIPTION;

                    result.Owner = op.X_GETSR_OUT_REC.SR_OWNER;
                    result.OwnerID = op.X_GETSR_OUT_REC.SR_OWNER_ID;

                    logMessage = "Request of loading Service Request (Success). SR ID = " + incident_id;
                    logNote = "Request Payload: " + request;
                    log.DebugLog(_logIncidentId, _logContactId, logMessage, logNote);

                    logMessage = "Response of loading Service Request (Success). SR ID = " + incident_id;
                    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 loading Service Request (Failure). SR ID = " + incident_id + " Error: " + op.X_MSG_DATA;
                    logNote = "Request Payload: " + request;
                    log.ErrorLog(_logIncidentId, _logContactId, logMessage, logNote);

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

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

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

            return result;
        }
Пример #3
0
        public ServiceRequest UpdateSR(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_UPDATE_FIELDS sr_info = new SR_UPDATE_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;
                //req_info.CONTRACT_ID = 38373;
                sr_info.CONTRACT_IDSpecified = true;

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

                // Hard-coding some values
                if (String.IsNullOrEmpty(sr.ContactOrgID) || sr.ContactOrgID == "0")
                    sr_info.CUSTOMER_ID = 4429;
                else
                    sr_info.CUSTOMER_ID = Convert.ToDecimal(sr.ContactOrgID);
                sr_info.CUSTOMER_IDSpecified = true;
                sr_info.CALLER_TYPE = "ORGANIZATION";

                if (sr.OwnerID.HasValue)
                {
                    sr_info.OWNER_ID = sr.OwnerID;
                    sr_info.OWNER_IDSpecified = true;
                }
                /*

                if (sr.InstanceID.HasValue)
                {
                    sr_info.CUSTOMER_PRODUCT_ID = sr.InstanceID.Value;
                    sr_info.CUSTOMER_PRODUCT_IDSpecified = true;
                }
                */
                sr_info.VERIFY_CP_FLAG = "N";
                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;

                }
                else
                {
                    sr_info.CUSTOMER_PRODUCT_ID = null;
                    sr_info.CUSTOMER_PRODUCT_IDSpecified = true;
                    sr_info.INVENTORY_ORG_ID = 204;
                    sr_info.INVENTORY_ORG_IDSpecified = true;
                }


                SR.InputParameters8 ip_update_sr = new SR.InputParameters8();
                ip_update_sr.P_REQUEST_ID = sr.RequestID;
                ip_update_sr.P_REQUEST_IDSpecified = true;
                ip_update_sr.P_REQUEST_NUMBER = sr.RequestNumber;
                ip_update_sr.P_API_VERSION = 4.0M;
                ip_update_sr.P_API_VERSIONSpecified = true;
                ip_update_sr.P_SERVICE_REQUEST_REC = sr_info;

                ip_update_sr.P_OBJECT_VERSION_NUMBER = sr.SrObjVerNum;
                ip_update_sr.P_OBJECT_VERSION_NUMBERSpecified = true;

                // Hard-coding the contact for the demo


                List<SR_UPDATE_CONTACT> clist = new List<SR_UPDATE_CONTACT>();

                ip_update_sr.P_CONTACTS = clist.ToArray();

                // Notes
                List<SR_UPDATE_NOTES> notes = new List<SR_UPDATE_NOTES>();
                if (!String.IsNullOrWhiteSpace(sr.Notes))
                {
                    SR_UPDATE_NOTES note = new SR_UPDATE_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;

                    notes.Add(note);

                }
                ip_update_sr.P_NOTES = notes.ToArray();

                ip_update_sr.P_AUTO_ASSIGN = String.Empty;
                ip_update_sr.P_DEFAULT_CONTRACT_SLA_IND = "Y";
                ip_update_sr.P_INIT_MSG_LIST = "T";
                ip_update_sr.P_COMMIT = "T";
                ip_update_sr.P_REQUEST_NUMBER = String.Empty;
                ip_update_sr.P_CALLED_BY_WORKFLOW = String.Empty;
                Stopwatch stopwatch = new Stopwatch();
                try
                {
                    request = serializer.Serialize(ip_update_sr);
                    stopwatch.Start();
                    SR.OutputParameters8 op_update_sr = client.UPDATE_SERVICEREQUEST(ip_update_sr);
                    stopwatch.Stop();
                    response = serializer.Serialize(op_update_sr);

                    if (op_update_sr.X_RETURN_STATUS == "S")
                    {
                        SR_UPDATE data = op_update_sr.X_SR_UPDATE_OUT_REC;

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

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

                        logMessage = "Response of updating Service Request (Failure). SR ID = " + sr.RequestID + " Error: " + op_update_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 updating Service Request (Failure). SR ID = " + sr.RequestID + " Error: " + ex.Message;
                    logNote = "Request Payload: " + request;
                    log.ErrorLog(_logIncidentId, _logContactId, logMessage, logNote);

                    logMessage = "Response of updating Service Request (Failure). SR ID = " + sr.RequestID + " Error: " + ex.Message;
                    logNote = "Response Payload: " + response;
                    log.ErrorLog(_logIncidentId, _logContactId, logMessage, logNote);

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


            return result;

        }