public ServiceRequest LookupSR(string incident_id, int _logIncidentId = 0, int _logContactId = 0) { if (String.IsNullOrWhiteSpace(SRURL) || String.IsNullOrWhiteSpace(SRServiceUsername) || String.IsNullOrWhiteSpace(SRServicePassword)) { throw new Exception("Provider's InitForSR not run."); } string request, response, logMessage, logNote; SRSVC.WC_Service_Request_BSClient client = new SRSVC.WC_Service_Request_BSClient(binding, addr); MyEndpointBehavior eBehavior = new MyEndpointBehavior(); client.Endpoint.Behaviors.Add(eBehavior); if(SRServiceTimeout > 0) client.InnerChannel.OperationTimeout = TimeSpan.FromMilliseconds(SRServiceTimeout ); SRSVC.WC_Service_Request_BSQueryPage_Input ip = new SRSVC.WC_Service_Request_BSQueryPage_Input(); ServiceRequest sr = new ServiceRequest(); ip.ListOfWc_Service_Request_Io = new SRSVC.ListOfWc_Service_Request_IoQuery(); ip.ListOfWc_Service_Request_Io.ServiceRequest = new SRSVC.ServiceRequestQuery(); ip.ListOfWc_Service_Request_Io.ServiceRequest.Id = new SRSVC.queryType(); if (!String.IsNullOrEmpty(incident_id)) { ip.ListOfWc_Service_Request_Io.ServiceRequest.Id.Value = "='" + incident_id + "'"; } else { throw new Exception("Service Request ID is empty."); } ip.ListOfWc_Service_Request_Io.ServiceRequest.Description = new SRSVC.queryType(); ip.ListOfWc_Service_Request_Io.ServiceRequest.Description.Value = String.Empty; ip.ListOfWc_Service_Request_Io.ServiceRequest.ContactId = new SRSVC.queryType(); ip.ListOfWc_Service_Request_Io.ServiceRequest.ContactId.Value = String.Empty; ip.ListOfWc_Service_Request_Io.ServiceRequest.OwnedById = new SRSVC.queryType(); ip.ListOfWc_Service_Request_Io.ServiceRequest.OwnedById.Value = String.Empty; ip.ListOfWc_Service_Request_Io.ServiceRequest.Owner = new SRSVC.queryType(); ip.ListOfWc_Service_Request_Io.ServiceRequest.Owner.Value = String.Empty; ip.ListOfWc_Service_Request_Io.ServiceRequest.Priority = new SRSVC.queryType(); ip.ListOfWc_Service_Request_Io.ServiceRequest.Priority.Value = String.Empty; ip.ListOfWc_Service_Request_Io.ServiceRequest.SRNumber = new SRSVC.queryType(); ip.ListOfWc_Service_Request_Io.ServiceRequest.SRNumber.Value = String.Empty; ip.ListOfWc_Service_Request_Io.ServiceRequest.SRType = new SRSVC.queryType(); ip.ListOfWc_Service_Request_Io.ServiceRequest.SRType.Value = String.Empty; ip.ListOfWc_Service_Request_Io.ServiceRequest.SerialNumber = new SRSVC.queryType(); ip.ListOfWc_Service_Request_Io.ServiceRequest.SerialNumber.Value = String.Empty; ip.ListOfWc_Service_Request_Io.ServiceRequest.Severity = new SRSVC.queryType(); ip.ListOfWc_Service_Request_Io.ServiceRequest.Severity.Value = String.Empty; ip.ListOfWc_Service_Request_Io.ServiceRequest.Status = new SRSVC.queryType(); ip.ListOfWc_Service_Request_Io.ServiceRequest.Status.Value = String.Empty; ip.ListOfWc_Service_Request_Io.ServiceRequest.Type = new SRSVC.queryType(); ip.ListOfWc_Service_Request_Io.ServiceRequest.Type.Value = String.Empty; ip.ListOfWc_Service_Request_Io.ServiceRequest.ProductId = new SRSVC.queryType(); ip.ListOfWc_Service_Request_Io.ServiceRequest.ProductId.Value = String.Empty; ip.ListOfWc_Service_Request_Io.ServiceRequest.Product = new SRSVC.queryType(); ip.ListOfWc_Service_Request_Io.ServiceRequest.Product.Value = String.Empty; ip.LOVLanguageMode = "LIC"; ip.ViewMode = "All"; Stopwatch stopwatch = new Stopwatch(); try { SRSVC.WC_Service_Request_BSQueryPage_Output op; using (new OperationContextScope(client.InnerChannel)) { MessageHeader usrMsgHdr = MessageHeader.CreateHeader("UsernameToken", "http://siebel.com/webservices", SRServiceUsername); OperationContext.Current.OutgoingMessageHeaders.Add(usrMsgHdr); MessageHeader pwdMsgHdr = MessageHeader.CreateHeader("PasswordText", "http://siebel.com/webservices", SRServicePassword); OperationContext.Current.OutgoingMessageHeaders.Add(pwdMsgHdr); stopwatch.Start(); op = client.WC_Service_Request_BSQueryPage(ip); stopwatch.Stop(); request = eBehavior.msgInspector.reqPayload; response = eBehavior.msgInspector.resPayload; SRSVC.ServiceRequestData opData = op.ListOfWc_Service_Request_Io.ServiceRequest[0]; sr.RequestID = opData.Id; sr.RequestNumber = opData.SRNumber; //sr.IncidentID //sr.IncidentRef sr.Status = opData.Status; sr.Severity = opData.Severity; sr.RequestType = opData.SRType; sr.Summary = opData.Description; sr.SerialNumber = opData.SerialNumber; sr.Owner = opData.Owner; sr.OwnerID = opData.OwnedById; sr.Product = opData.ProductId; sr.ProductDescription = opData.Product; } 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); } catch (Exception ex) { request = eBehavior.msgInspector.reqPayload; response = eBehavior.msgInspector.resPayload; sr.ErrorMessage = "There has been an error communicating with Siebel. 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); handleSiebelException(ex, "Lookup Service Request", _logIncidentId, _logContactId); } return sr; }
public ServiceRequest UpdateSR(ServiceRequest sr, int _logIncidentId = 0, int _logContactId = 0) { if (String.IsNullOrWhiteSpace(SRURL) || String.IsNullOrWhiteSpace(SRServiceUsername) || String.IsNullOrWhiteSpace(SRServicePassword)) { throw new Exception("Provider's InitForSR not run."); } string request, response, logMessage, logNote; SRSVC.WC_Service_Request_BSClient client = new SRSVC.WC_Service_Request_BSClient(binding, addr); MyEndpointBehavior eBehavior = new MyEndpointBehavior(); client.Endpoint.Behaviors.Add(eBehavior); if(SRServiceTimeout > 0) client.InnerChannel.OperationTimeout = TimeSpan.FromMilliseconds(SRServiceTimeout ); SRSVC.WC_Service_Request_BSUpdate_Input ip = new SRSVC.WC_Service_Request_BSUpdate_Input(); ip.ListOfWc_Service_Request_Io = new SRSVC.ListOfWc_Service_Request_IoData(); ip.ListOfWc_Service_Request_Io.ServiceRequest = new SRSVC.ServiceRequestData[1]; ip.ListOfWc_Service_Request_Io.ServiceRequest[0] = new SRSVC.ServiceRequestData(); if (sr.RequestID != null) { ip.ListOfWc_Service_Request_Io.ServiceRequest[0].Id = sr.RequestID; } else { sr.ErrorMessage = "The following error occurred when doing the Create: SR ID is empty"; return sr; } if (sr.Summary != null) { ip.ListOfWc_Service_Request_Io.ServiceRequest[0].Description = sr.Summary; } else { ip.ListOfWc_Service_Request_Io.ServiceRequest[0].Description = String.Empty; } if (sr.ContactID != null) { ip.ListOfWc_Service_Request_Io.ServiceRequest[0].ContactId = sr.ContactID; } else { ip.ListOfWc_Service_Request_Io.ServiceRequest[0].ContactId = String.Empty; } if (sr.Severity != null) { ip.ListOfWc_Service_Request_Io.ServiceRequest[0].Severity = sr.Severity; } else { ip.ListOfWc_Service_Request_Io.ServiceRequest[0].Severity = String.Empty; } if (sr.RequestType != null) { ip.ListOfWc_Service_Request_Io.ServiceRequest[0].SRType = sr.RequestType; } else { ip.ListOfWc_Service_Request_Io.ServiceRequest[0].SRType = String.Empty; } if (sr.SerialNumber != null) { ip.ListOfWc_Service_Request_Io.ServiceRequest[0].SerialNumber = sr.SerialNumber; } else { ip.ListOfWc_Service_Request_Io.ServiceRequest[0].SerialNumber = String.Empty; } if (sr.Status != null) { ip.ListOfWc_Service_Request_Io.ServiceRequest[0].Status = sr.Status; } else { ip.ListOfWc_Service_Request_Io.ServiceRequest[0].Status = String.Empty; } if (sr.IncidentID != null || sr.IncidentRef != null) { ip.ListOfWc_Service_Request_Io.ServiceRequest[0].IntegrationId = sr.IncidentID + "," + sr.IncidentRef; } if (sr.RnowHost != null) { ip.ListOfWc_Service_Request_Io.ServiceRequest[0].IntegrationSite = sr.RnowHost; } else { ip.ListOfWc_Service_Request_Io.ServiceRequest[0].IntegrationSite = String.Empty; } ip.LOVLanguageMode = "LIC"; ip.ViewMode = "All"; Stopwatch stopwatch = new Stopwatch(); try { SRSVC.WC_Service_Request_BSUpdate_Output op; using (new OperationContextScope(client.InnerChannel)) { MessageHeader usrMsgHdr = MessageHeader.CreateHeader("UsernameToken", "http://siebel.com/webservices", SRServiceUsername); OperationContext.Current.OutgoingMessageHeaders.Add(usrMsgHdr); MessageHeader pwdMsgHdr = MessageHeader.CreateHeader("PasswordText", "http://siebel.com/webservices", SRServicePassword); OperationContext.Current.OutgoingMessageHeaders.Add(pwdMsgHdr); stopwatch.Start(); op = client.WC_Service_Request_BSUpdate(ip); stopwatch.Stop(); request = eBehavior.msgInspector.reqPayload; response = eBehavior.msgInspector.resPayload; SRSVC.ServiceRequestId opData = op.ListOfWc_Service_Request_Io[0]; sr.RequestID = opData.Id; } 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); } catch (Exception ex) { request = eBehavior.msgInspector.reqPayload; response = eBehavior.msgInspector.resPayload; sr.ErrorMessage = "There has been an error communicating with Siebel. 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); handleSiebelException(ex, "Update Service Request", _logIncidentId, _logContactId); } return sr; }
private Boolean checkSRStatus(string sr_id) { string logMessage, logNote; if (String.IsNullOrWhiteSpace(sr_id)) return false; // load SR ServiceRequest sr = new ServiceRequest(); try { sr = sr.Lookup(sr_id, _logIncidentId, 0); } catch (Exception ex) { string message = ex.Message; MessageBox.Show(message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); logMessage = "Error in loading Service Request. Error: " + ex.Message; logNote = ""; _log.ErrorLog(incidentId: _logIncidentId, logMessage: logMessage, logNote: logNote); return false; } if (sr.ErrorMessage != null) { logMessage = "Loading Service Request is failed. SR ID = " + sr_id; logNote = "Response shows error code when loading service request. Response's error message: " + sr.ErrorMessage; _log.ErrorLog(incidentId: _logIncidentId, logMessage: logMessage, logNote: logNote); return false; } if (sr.Status == "Closed") { String message = "Activity cannot be saved in Siebel because the Service Request is closed."; MessageBoxButtons buttons = MessageBoxButtons.OK; DialogResult result; result = System.Windows.Forms.MessageBox.Show(this, message, "Warning", buttons, MessageBoxIcon.Warning); logMessage = "Cannot propagate the activity to Siebel."; logNote = message; _log.ErrorLog(logMessage: logMessage, logNote: logNote, incidentId: _logIncidentId); return false; } else { return true; } }
/* This method calls * WC_Contacts_BSClient : WC_Contacts_BSQueryPage * Called by SRlistVirtualTable GetRows() to display Service Requests for a contact */ public ServiceRequest[] LookupSRbyContactPartyID(IList<string> columns, string contact_id, int _logIncidentId = 0, int _logContactId = 0) { if (String.IsNullOrWhiteSpace(SRURL) || String.IsNullOrWhiteSpace(SRServiceUsername) || String.IsNullOrWhiteSpace(SRServicePassword)) { throw new Exception("Provider's InitForSR is not run."); } string request, response, logMessage, logNote; binding.MaxReceivedMessageSize = 2147483647; CONTACTSVC.WC_Contacts_BSClient client = new CONTACTSVC.WC_Contacts_BSClient(binding, addr); MyEndpointBehavior eBehavior = new MyEndpointBehavior(); client.Endpoint.Behaviors.Add(eBehavior); if(SRServiceTimeout > 0) client.InnerChannel.OperationTimeout = TimeSpan.FromMilliseconds(SRServiceTimeout ); CONTACTSVC.WC_Contacts_BSQueryPage_Input ip = new CONTACTSVC.WC_Contacts_BSQueryPage_Input(); ip.ListOfWc_Contacts_Io = new CONTACTSVC.ListOfWc_Contacts_IoQuery(); ip.ListOfWc_Contacts_Io.Contact = new CONTACTSVC.ContactQuery(); ip.ListOfWc_Contacts_Io.Contact.Id = new CONTACTSVC.queryType(); ip.ListOfWc_Contacts_Io.Contact.Id.Value = "='" + contact_id + "'"; ip.ListOfWc_Contacts_Io.Contact.ListOfServiceRequest = new CONTACTSVC.ListOfServiceRequestQuery(); ip.ListOfWc_Contacts_Io.Contact.ListOfServiceRequest.ServiceRequest = new CONTACTSVC.ServiceRequestQuery(); ip.ListOfWc_Contacts_Io.Contact.ListOfServiceRequest.ServiceRequest.SRNumber = new CONTACTSVC.queryType(); foreach (PropertyInfo propertyInfo in ip.ListOfWc_Contacts_Io.Contact.ListOfServiceRequest.ServiceRequest.GetType().GetProperties()) { /* bc Incident/SR report tab is a special case, the columns are hard coded and fixed * to show the combined rnow and siebel rows, IntegratrionId, summary, Id * are diffent name */ foreach (string column in columns) { if (propertyInfo.Name == column.Split('.')[1] || propertyInfo.Name == "IntegrationId" || propertyInfo.Name == "Id" || propertyInfo.Name == "Abstract" ) { if (propertyInfo.PropertyType == typeof(CONTACTSVC.queryType)) { CONTACTSVC.queryType queryType = new CONTACTSVC.queryType(); propertyInfo.SetValue(ip.ListOfWc_Contacts_Io.Contact.ListOfServiceRequest.ServiceRequest, queryType, null); } break; } } } ip.LOVLanguageMode = "LIC"; ip.ViewMode = "All"; Stopwatch stopwatch = new Stopwatch(); CONTACTSVC.WC_Contacts_BSQueryPage_Output opList; try { using (new OperationContextScope(client.InnerChannel)) { MessageHeader usrMsgHdr = MessageHeader.CreateHeader("UsernameToken", "http://siebel.com/webservices", SRServiceUsername); OperationContext.Current.OutgoingMessageHeaders.Add(usrMsgHdr); MessageHeader pwdMsgHdr = MessageHeader.CreateHeader("PasswordText", "http://siebel.com/webservices", SRServicePassword); OperationContext.Current.OutgoingMessageHeaders.Add(pwdMsgHdr); stopwatch.Start(); opList = client.WC_Contacts_BSQueryPage(ip); stopwatch.Stop(); request = eBehavior.msgInspector.reqPayload; logMessage = "Request of SRs by contactID (Success). Siebel Contact ID = " + contact_id; logNote = "Request Payload: " + request; log.DebugLog(_logIncidentId, _logContactId, logMessage, logNote); response = eBehavior.msgInspector.resPayload; logMessage = "Response of SRs by contactID (Success). Siebel Contact ID = " + contact_id; logNote = "Response Payload: " + response; log.DebugLog(_logIncidentId, _logContactId, logMessage, logNote, (int)stopwatch.ElapsedMilliseconds); } } catch (Exception ex) { request = eBehavior.msgInspector.reqPayload; logMessage = "Request of SRs by contactID (Failure). Siebel Contact ID = " + contact_id; logNote = "Request Payload: " + request; log.DebugLog(_logIncidentId, _logContactId, logMessage, logNote); response = eBehavior.msgInspector.resPayload; logMessage = "Response of SRs by contactID (Failure). Siebel Contact ID = " + contact_id; logNote = "Response Payload: " + response; log.DebugLog(_logIncidentId, _logContactId, logMessage, logNote); handleSiebelException(ex, "LookupSRbyContactPartyID"); throw ex; } CONTACTSVC.ContactData contactData = opList.ListOfWc_Contacts_Io.Contact[0]; if (contactData.ListOfServiceRequest.ServiceRequest == null) return null; ServiceRequest[] retvals = new ServiceRequest[contactData.ListOfServiceRequest.ServiceRequest.Length]; int i = 0; foreach (CONTACTSVC.ServiceRequestData sr in contactData.ListOfServiceRequest.ServiceRequest) { if (sr.IntegrationId == null || sr.IntegrationId == "") { ServiceRequest req = new ServiceRequest(); req.RequestID = sr.Id; req.RequestNumber = sr.SRNumber; req.Status = sr.Status; req.Summary = sr.Abstract; req.RequestDate = (DateTime)sr.Created; retvals[i] = req; i++; } } return retvals; }
private void SaveToSiebel(bool isCreate) { bool sr_saved; ServiceRequest sr = null; string logMessage, logNote; // Make sure we actually have an asset and a saved incident if (Contact != null) { //Compose Service Request sr = new ServiceRequest(); // Set Service Request attributes - severity, status, request type, contact party id, etc. KeyValuePair<String, String> severityKeyPair = sr.rnSeverityToServerSeverity(selected_rn_severity_id); selected_server_severity = severityKeyPair.Key; sr.Severity = severityKeyPair.Key; KeyValuePair<String, String> statusKeyPair = sr.rnStatusToServerStatus(selected_rn_request_status_id); selected_server_request_status = statusKeyPair.Key; sr.Status = statusKeyPair.Key; KeyValuePair<String, String> requestTypeKeyPair = sr.rnRequestTypeToServerRequestType(selected_rn_request_type_id); selected_server_request_type = requestTypeKeyPair.Key; sr.RequestType = requestTypeKeyPair.Key; sr.ContactID = selectedContactPartyId; if (String.IsNullOrEmpty(selectedContactOrgId) || selectedContactOrgId == "0") { sr.ContactOrgID = null; } else { sr.ContactOrgID = selectedContactOrgId; } sr.Summary = Incident.Subject; sr.RequestDate = (Incident.Created.HasValue) ? Incident.Created.Value : DateTime.Now; sr.IncidentOccurredDate = (Incident.Created.HasValue) ? Incident.Created.Value : DateTime.Now; sr.IncidentRef = Incident.RefNo; sr.IncidentID = Incident.ID.ToString(); sr.SerialNumber = current_serial_num; if(!String.IsNullOrEmpty(currentProductID)){ sr.ProductID = currentProductID; } else { sr.ProductID = null; } if (_siebelDefaultSrOwnerId != null) { sr.OwnerID = _siebelDefaultSrOwnerId; } try { if (isCreate) { //Create Service Request sr.RnowHost = ConfigurationSetting.rnt_host; logMessage = "Ready to create Service Request"; _log.DebugLog(incidentId: _logIncidentId, logMessage: logMessage); sr_saved = sr.Create(_logIncidentId, 0); } else { //Update Service Request //Set custom attribute fields for update var sr_id = ""; var sr_num = ""; var sr_owner_id = ""; IList<ICustomAttribute> incCustomAttributes = Incident.CustomAttributes; string[] incCustomAttrs = { "Accelerator$siebel_sr_id", "Accelerator$siebel_sr_num", "Accelerator$siebel_sr_owner_id"}; Dictionary<String, Object> incCustomAttrsResults = CustomAttrHelper.fetchCustomAttrValue(incCustomAttributes, incCustomAttrs, this._logIncidentId, 0); sr_id = incCustomAttrsResults["Accelerator$siebel_sr_id"] != null ? incCustomAttrsResults["Accelerator$siebel_sr_id"].ToString() : ""; sr_num = incCustomAttrsResults["Accelerator$siebel_sr_num"] != null ? incCustomAttrsResults["Accelerator$siebel_sr_num"].ToString() : ""; sr_owner_id = incCustomAttrsResults["Accelerator$siebel_sr_owner_id"] != null ? incCustomAttrsResults["Accelerator$siebel_sr_owner_id"].ToString() : ""; sr.RequestID = sr_id; sr.RequestNumber = sr_num; sr.RnowHost = ConfigurationSetting.rnt_host; if (sr_owner_id != "") { sr.OwnerID = sr_owner_id; } logMessage = "Ready to update Service Request. SR ID = " + sr_id; logNote = ""; _log.DebugLog(incidentId: _logIncidentId, logMessage: logMessage, logNote: logNote); sr_saved = sr.Update(_logIncidentId, 0); } } catch (Exception ex) { logMessage = "Error in creating/updating Service Request.Error Message: " + ex.Message; logNote = ""; _log.ErrorLog(incidentId: _logIncidentId, logMessage: logMessage, logNote: logNote); string message = ex.Message; MessageBox.Show(message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } if (!sr_saved) { // If Service Request is not saved successfully, show error. string message = "There has been an error communicating with Siebel. Please check log for detail."; MessageBox.Show(message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); logMessage = "Error in creating/updating Service Request."; logNote = "Response shows error code. Response's error message: " + sr.ErrorMessage; _log.ErrorLog(incidentId: _logIncidentId, logMessage: logMessage, logNote: logNote); return; } else { logMessage = "Created/Updated Service Request successfully. SR ID = " + sr.RequestID; logNote = ""; _log.DebugLog(incidentId: _logIncidentId, logMessage: logMessage, logNote: logNote); // After update successfully, update the values which are stored information from Siebel side try { storedRequestType = selected_server_request_type; storedRequestStatus = selected_server_request_status; storedSeverity = selected_server_severity; siebelStoredSerialNum = current_serial_num; } catch (Exception ex) { logMessage = "Error in updating incident fields with Service Request information, after created/updated SR. Error Message: " + ex.Message; _log.ErrorLog(incidentId: _logIncidentId, logMessage: logMessage); return; } if (isCreate) { //Check the interaction, we need created, after created a new service request string sr_id = sr.RequestID; int currentThreadCount = Incident.Threads.Count == 0 ? 0 : Incident.Threads[0].ID; int storedThreadsCount = 0; IList<ICustomAttribute> incCustomAttributes = Incident.CustomAttributes; string[] incCustomAttrThread = { "Accelerator$siebel_max_thread_id" }; Dictionary<String, Object> incCustomAttrResultThread = CustomAttrHelper.fetchCustomAttrValue(incCustomAttributes, incCustomAttrThread, this._logIncidentId, 0); storedThreadsCount = incCustomAttrResultThread["Accelerator$siebel_max_thread_id"] != null ? (int)incCustomAttrResultThread["Accelerator$siebel_max_thread_id"] : 0; // If have new thread, then call function SaveInteractionToSiebel to create interaction if (currentThreadCount != storedThreadsCount && !String.IsNullOrWhiteSpace(sr_id)) { logMessage = "After created new SR, need to store new threads to Siebel System. Stored Thread Count = " + storedThreadsCount + "; Current Thread Count = " + currentThreadCount; logNote = ""; _log.DebugLog(incidentId: _logIncidentId, logMessage: logMessage, logNote: logNote); SaveNoteToSiebel(sr_id, currentThreadCount, storedThreadsCount, true); } // Iterate through the incident custom attributes and set values try { bool sr_id_found = false; bool sr_num_found = false; bool sr_owner_id_found = false; foreach (ICustomAttribute cusAttr in incCustomAttributes) { if (cusAttr.PackageName == "Accelerator" && cusAttr.GenericField.Name == "Accelerator$siebel_sr_id") { sr_id_found = true; cusAttr.GenericField.DataValue.Value = sr.RequestID; UpdateIncCustomAttr(Incident.ID, "siebel_sr_id", sr.RequestID); } if (cusAttr.PackageName == "Accelerator" && cusAttr.GenericField.Name == "Accelerator$siebel_sr_num") { ServiceRequest createdSR = sr.Lookup(sr.RequestID, _logIncidentId); sr_num_found = true; if (createdSR != null) { cusAttr.GenericField.DataValue.Value = createdSR.RequestNumber; UpdateIncCustomAttr(Incident.ID, "siebel_sr_num", createdSR.RequestNumber); } } if (cusAttr.PackageName == "Accelerator" && cusAttr.GenericField.Name == "Accelerator$siebel_sr_owner_id") { sr_owner_id_found = true; cusAttr.GenericField.DataValue.Value = sr.OwnerID; UpdateIncCustomAttr(Incident.ID, "siebel_sr_owner_id", sr.OwnerID); } } if (sr_id_found == false) { logMessage = "Custom attribute is not defined. Cannot get Accelerator$siebel_sr_id."; _log.ErrorLog(incidentId:_logIncidentId, logMessage: logMessage); } if (sr_num_found == false) { logMessage = "Custom attribute is not defined. Cannot get Accelerator$siebel_sr_num."; _log.ErrorLog(incidentId: _logIncidentId, logMessage: logMessage); } if (sr_owner_id_found == false) { logMessage = "Custom attribute is not defined. Cannot get Accelerator$siebel_sr_owner_id."; _log.ErrorLog(incidentId: _logIncidentId, logMessage: logMessage); } if (sr_id_found == false || sr_num_found == false || sr_owner_id_found == false) { MessageBox.Show("Custom Attribute configuration missing. Please check log for detail.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } } catch (Exception ex) { logMessage = "Error in updating incident fields with Service Request information, after created new SR.Error Message: " + ex.Message; _log.ErrorLog(incidentId: _logIncidentId, logMessage: logMessage); return; } logMessage = " Updating incident fields with Service Request information, after created new SR successfully.siebel_sr_id = " + sr.RequestID.ToString() + "; siebel_sr_num = " + sr.RequestNumber + "; siebel_sr_owner_id = " + sr.OwnerID.ToString() + "."; _log.DebugLog(incidentId: _logIncidentId, logMessage: logMessage); } } } }
void _recordContext_Saving(object sender, CancelEventArgs e) { string logMessage, logNote; storedContactPartyId = _serviceRequestControl.storedContactPartyId; storedSeverity = _serviceRequestControl.storedSeverity; storedRequestStatus = _serviceRequestControl.storedRequestStatus; storedRequestType = _serviceRequestControl.storedRequestType; storedSubject = _serviceRequestControl.storedSubject; siebelStoredSerialNum = _serviceRequestControl.siebelStoredSerialNum; siebelStoredProductID = _serviceRequestControl.siebelStoredProductID; this._serviceRequestControl.LeaveFocusWhenSaving(); Contact = _recordContext.GetWorkspaceRecord(RightNow.AddIns.Common.WorkspaceRecordType.Contact) as IContact; if (Contact == null) { _serviceRequestControl.tbSerialNo.Enabled = true; DialogResult result = MessageBox.Show("Contact is empty. Cannot do the serial number validation. ", "Info", MessageBoxButtons.OK, MessageBoxIcon.Information); if (result == DialogResult.OK) { logMessage = "Contact is empty. Cannot do the serial number validation. "; logNote = ""; _log.DebugLog(incidentId: _logIncidentId, logMessage: logMessage, logNote: logNote); e.Cancel = true; return; } } // get custom attribute Accelerator$siebel_sr_id value var sr_id = ""; IList<ICustomAttribute> incCustomAttributes = Incident.CustomAttributes; string[] incCustomAttrSrId = { "Accelerator$siebel_sr_id", "Accelerator$siebel_serial_number"}; Dictionary<String, Object> incCustomAttrSrIdResult = CustomAttrHelper.fetchCustomAttrValue(incCustomAttributes, incCustomAttrSrId, this._logIncidentId, 0); sr_id = incCustomAttrSrIdResult["Accelerator$siebel_sr_id"] != null ? incCustomAttrSrIdResult["Accelerator$siebel_sr_id"].ToString() : ""; rnStoredSerialNum = !String.IsNullOrWhiteSpace((string)incCustomAttrSrIdResult["Accelerator$siebel_serial_number"])? incCustomAttrSrIdResult["Accelerator$siebel_serial_number"].ToString() : ""; // If Incident's Contact has associated to an Siebel Contact, it does not support to edit it. if (!String.IsNullOrWhiteSpace(sr_id) && currentContactID != Contact.ID) { string message = "This incident has been associated to a Siebel Contact, we cannot allow changing the contact via this addin. Please change the primary contact back."; MessageBoxButtons buttons = MessageBoxButtons.OK; DialogResult result; // Show message box to mention the assigned contact party id result = System.Windows.Forms.MessageBox.Show(this, message, "Message", buttons, MessageBoxIcon.Information); logMessage = "Cannot changing incident's primary contact. This incident has been associated to an Siebel Contact, Contact ID = " + Contact.ID; logNote = ""; _log.DebugLog(incidentId: _logIncidentId, logMessage: logMessage, logNote: logNote); if (result == DialogResult.OK) { e.Cancel = true; return; } } current_serial_num = _serviceRequestControl.tbSerialNo.Text; //Validate serial number bool isValidSerial; if (current_serial_num != "") { try { isValidSerial = this.validateSerialNumber(current_serial_num); } catch (Exception ex) { logMessage = "Incident saving is cancelled, because error: " + ex.Message; _log.ErrorLog(incidentId: _logIncidentId, logMessage: logMessage); e.Cancel = true; return; } if (isValidSerial) { currentProductID = _serviceRequestControl.siebelProductId; } else { //Invalid Error logMessage = "The serial number (" + current_serial_num + ") is invalid. It does not belong to current contact's organization."; logNote = ""; _log.NoticeLog(incidentId: _logIncidentId, logMessage: logMessage, logNote: logNote); string message = "The serial number is invalid. It does not belong to current contact's organization."; MessageBoxButtons buttons = MessageBoxButtons.OK; DialogResult result; // Show message box to mention the assigned contact party id result = MessageBox.Show(this, message, "Error", buttons, MessageBoxIcon.Error); if (result == DialogResult.OK) { //current_serial_num = siebelStoredSerialNum; //currentInstanceID = siebelStoredInstanceID; e.Cancel = true; return; } } } else { currentProductID = ""; } //Update current incident's serial number if (current_serial_num != rnStoredSerialNum) this.setSerialNum(current_serial_num); //Get Oracle Service Clould product ID according to Siebel product information string rnProductId = null; if (currentProductID != null) { rnProductId = this.getProductId(currentProductID); } //Set current incident's product if (!String.IsNullOrEmpty(rnProductId)) { Incident.ProductID = Convert.ToInt32(rnProductId); } else { Incident.ProductID = null; } ServiceRequest sr = new ServiceRequest(); current_subject = Incident.Subject; //get current incident status id and convert to Siebel status id selected_rn_request_status_id = Incident.Status.StatusID; selected_server_request_status = sr.rnStatusToServerStatus(selected_rn_request_status_id).Key; //get current incident severity id and convert to Siebel severity id if (!Incident.SeverityID.Equals(null)) { selected_rn_severity_id = (int)Incident.SeverityID; } else { selected_rn_severity_id = 0; } selected_server_severity = sr.rnSeverityToServerSeverity(selected_rn_severity_id).Key; //get current incident type id and serial number selected_rn_request_type_id = 0; string[] incCustomAttrs = { "Accelerator$siebel_sr_request_type"}; Dictionary<String, Object> incCustomAttrsResults = CustomAttrHelper.fetchCustomAttrValue(incCustomAttributes, incCustomAttrs, this._logIncidentId, 0); selected_rn_request_type_id = incCustomAttrsResults["Accelerator$siebel_sr_request_type"] != null ? (int)incCustomAttrsResults["Accelerator$siebel_sr_request_type"] : 0; //convert to Siebel type id selected_server_request_type = sr.rnRequestTypeToServerRequestType(selected_rn_request_type_id).Key; logMessage = "In CheckIncidentUpdates, get all current value."; logNote = "incident status id = " + selected_rn_request_status_id + ", sr status id = " + selected_server_request_status + "incident severity id = " + selected_rn_request_type_id + ", sr severity id = " + selected_server_severity + "incident type id = " + selected_rn_request_type_id + ", sr type id = " + selected_server_request_type + "incident serial num = " + current_serial_num + ", incident subject = " + current_subject; _log.DebugLog(incidentId: _logIncidentId, logMessage: logMessage, logNote: logNote); }
private void bw_LoadSRDetails(object sender, DoWorkEventArgs e) { var sr_id = ""; var sr_num = ""; string logMessage, logNote; IList<ICustomAttribute> customAttributes = incident.CustomAttributes; string[] incCustomAttrs = { "Accelerator$siebel_sr_id", "Accelerator$siebel_sr_num", "Accelerator$siebel_serial_number" }; Dictionary<String, Object> incCustomAttrsResults = CustomAttrHelper.fetchCustomAttrValue(customAttributes, incCustomAttrs, this._logIncidentId, 0); sr_id = incCustomAttrsResults["Accelerator$siebel_sr_id"] != null ? incCustomAttrsResults["Accelerator$siebel_sr_id"].ToString() : ""; sr_num = incCustomAttrsResults["Accelerator$siebel_sr_num"] != null ? incCustomAttrsResults["Accelerator$siebel_sr_num"].ToString() : ""; e.Result = null; if (!String.IsNullOrWhiteSpace(sr_id)) { // Call to SR Lookup and Display SR Details ServiceRequest sr = new ServiceRequest(); try { sr = sr.Lookup(sr_id, _logIncidentId, 0); } catch (Exception ex) { string message = ex.Message; MessageBox.Show(message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); e.Cancel = true; logMessage = "Error in loading Service Request. Error: " + ex.Message; logNote = ""; _log.ErrorLog(incidentId: _logIncidentId, logMessage: logMessage, logNote: logNote); return; } if (sr.ErrorMessage != null) { e.Cancel = true; logMessage = "Loading Service Request is failed. SR ID = " + sr_id; logNote = "Response shows error code when loading service request. Response's error message: " + sr.ErrorMessage; _log.ErrorLog(incidentId: _logIncidentId, logMessage: logMessage, logNote: logNote); return; } e.Result = sr; //Set stored value (need them to decide whether field is changed) storedContactPartyId = (sr.ContactID == "0") ? "" : sr.ContactID; storedSeverity = sr.Severity; storedRequestStatus = sr.Status; storedRequestType = sr.RequestType; storedSubject = sr.Summary; siebelStoredSerialNum = (sr.SerialNumber == null ? "" : sr.SerialNumber); siebelStoredProductID = (sr.ProductID == null ? "" : sr.ProductID); bool sr_owner_id = false; bool sr_num_ca = false; foreach (ICustomAttribute cusAttr in customAttributes) { if (cusAttr.PackageName == "Accelerator" && cusAttr.GenericField.Name == "Accelerator$siebel_sr_owner_id") { sr_owner_id = true; cusAttr.GenericField.DataValue.Value = !String.IsNullOrEmpty(sr.OwnerID)? sr.OwnerID : ""; } if (cusAttr.PackageName == "Accelerator" && cusAttr.GenericField.Name == "Accelerator$siebel_sr_num") { sr_num_ca = true; cusAttr.GenericField.DataValue.Value = !String.IsNullOrEmpty(sr.RequestNumber) ? sr.RequestNumber : ""; } } if (sr_num_ca == false) { logMessage = "Custom attribute is not defined. Cannot get Accelerator$siebel_sr_num."; ConfigurationSetting.logWrap.ErrorLog(incidentId: _logIncidentId, logMessage: logMessage); } if (sr_owner_id == false) { logMessage = "Custom attribute is not defined. Cannot get Accelerator$siebel_sr_owner_id."; ConfigurationSetting.logWrap.ErrorLog(incidentId: _logIncidentId, logMessage: logMessage); } if (sr_owner_id == false||sr_num_ca == false) { MessageBox.Show("Custom Attribute configuration missing. Please check log for detail.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } logMessage = "Loaded Service Request. SR ID = " + sr_id; _log.DebugLog(incidentId: _logIncidentId, logMessage: logMessage); } else { //Display Empty page if no Service Request associated logMessage = "No Service Request associated. Show empty form."; logNote = ""; _log.DebugLog(incidentId: _logIncidentId, logMessage: logMessage, logNote: logNote); } }
// Add Siebel Service Request row private void addSiebelSrRow(ref IList<string> columns, ref ReportDataRow reportDataRow, ref IList<IReportRow> reportRows, ServiceRequest req) { foreach (var column in columns) { ReportDataCell reportDataCell = new ReportDataCell(); switch (column) { case "Siebel$SRlistTable.SrNumber": reportDataCell.GenericValue = req.RequestNumber; break; case "Siebel$SRlistTable.Status": reportDataCell.GenericValue = req.Status; break; case "Siebel$SRlistTable.Summary": reportDataCell.GenericValue = req.Summary; break; case "Siebel$SRlistTable.Created": reportDataCell.GenericValue = req.RequestDate; break; case "Siebel$SRlistTable.IncidentRef": reportDataCell.GenericValue = ""; break; case "Siebel$SRlistTable.HiddenSRconcatIncident_ID": reportDataCell.GenericValue = req.RequestID + "_"; break; } reportDataRow.Cells.Add(reportDataCell); } reportRows.Add(reportDataRow); }
// Add Siebel Service Request row private void addSiebelSrRow(ref IList<string> columns, ref ReportDataRow reportDataRow, ref IList<IReportRow> reportRows, Hashtable srHashtable, ServiceRequest req) { bool srInRnow = false; foreach (var column in columns) { ReportDataCell reportDataCell = new ReportDataCell(); switch (column) { case "Siebel$SRlistTable.SrNumber": reportDataCell.GenericValue = req.RequestNumber; if (srHashtable.ContainsKey(req.RequestNumber)) srInRnow = true; break; case "Siebel$SRlistTable.Status": reportDataCell.GenericValue = req.Status; break; case "Siebel$SRlistTable.Summary": reportDataCell.GenericValue = req.Summary; break; case "Siebel$SRlistTable.Created": reportDataCell.GenericValue = req.RequestDate; break; case "Siebel$SRlistTable.IncidentRef": reportDataCell.GenericValue = ""; break; case "Siebel$SRlistTable.HiddenSRconcatIncident_ID": reportDataCell.GenericValue = req.RequestID + "_"; break; } reportDataRow.Cells.Add(reportDataCell); } if (!srInRnow) { reportRows.Add(reportDataRow); srInRnow = false; } }