private decimal getContactID(IReportFilterNode filterNode, out int rntContactId) { IRecordContext _context = ((EBSVirtualReportTablesPackage)this.Parent)._globalContext.AutomationContext.CurrentWorkspace; string logMessage; string logNote; if (null != _context) { WorkspaceRecordType workspaceType = _context.WorkspaceType; if ((workspaceType == WorkspaceRecordType.Incident) || (workspaceType == WorkspaceRecordType.Contact)) { IContact contactRecord = _context.GetWorkspaceRecord(RightNow.AddIns.Common.WorkspaceRecordType.Contact) as IContact; if (null != contactRecord) { IList <ICustomAttribute> customAttributes = contactRecord.CustomAttributes; rntContactId = contactRecord.ID; object val = CustomAttrHelper.fetchCustomAttrValue(customAttributes, new string[] { "Accelerator$ebs_contact_party_id" }, 0, rntContactId) ["Accelerator$ebs_contact_party_id"]; if (null == val) { logMessage = "Provide an EBS Contact ID to search for Repair Orders. No search performed."; logNote = null; ConfigurationSetting.logWrap.DebugLog(0, rntContactId, logMessage, logNote); return(-1); } else if (Convert.ToDecimal(val) <= 0) { logMessage = "Provide a valid EBS Contact ID to search for Repair Orders. No search performed for ebs_contact_party_id " + val; logNote = null; ConfigurationSetting.logWrap.DebugLog(0, rntContactId, logMessage, logNote); return(-1); } else { return(Convert.ToDecimal(val)); } } } } rntContactId = 0; decimal contact_id = 0; object filter_value = getEqualsFilterValue(filterNode, "HiddenContactID", true); if (null != filter_value) { contact_id = Convert.ToDecimal(filter_value); } if (contact_id > 0) { return(contact_id); } logMessage = "Provide a valid EBS Contact ID to search for Repair Orders. Ignoring ebs_contact_party_id " + contact_id; logNote = null; ConfigurationSetting.logWrap.DebugLog(logMessage: logMessage, logNote: logNote); return(0); }
public bool validateSerialNumber(String serialNum) { IList <ICustomAttribute> conCustomAttributes = Contact.CustomAttributes; string[] conCustomAttrs = { "Accelerator$ebs_contact_org_id" }; Dictionary <String, Object> conCustomAttrResults = CustomAttrHelper.fetchCustomAttrValue(conCustomAttributes, conCustomAttrs, this._logIncidentId, 0); string contactOrgId = conCustomAttrResults["Accelerator$ebs_contact_org_id"] != null ? conCustomAttrResults["Accelerator$ebs_contact_org_id"].ToString() : "0"; if (contactOrgId == "0") { DialogResult result = MessageBox.Show("Current contact did not associate to a EBS contact correctly. Cannot do the serial number validation. ", "Info", MessageBoxButtons.OK, MessageBoxIcon.Information); if (result == DialogResult.OK) { string logMessage = "Current contact did not associate to a EBS contact correctly. Cannot do the serial number validation."; string logNote = ""; _log.ErrorLog(incidentId: _logIncidentId, logMessage: logMessage, logNote: logNote); return(false); } } try { bool isValid = _repairOrderControl.SerialNumberValidation(serialNum, contactOrgId); if (!isValid) { _repairOrderControl.SetValidedResult(isValid); } return(isValid); } catch (Exception ex) { throw ex; } }
private void bw_LoadROList(object sender, DoWorkEventArgs e) { string logMessage, logNote; var sr_id = ""; var sr_num = ""; IList <ICustomAttribute> customAttributes = incident.CustomAttributes; string[] incCustomAttrs = { "Accelerator$ebs_sr_id", "Accelerator$ebs_sr_num" }; Dictionary <String, Object> incCustomAttrsResults = CustomAttrHelper.fetchCustomAttrValue(customAttributes, incCustomAttrs, this._logIncidentId, 0); sr_id = incCustomAttrsResults["Accelerator$ebs_sr_id"] != null ? incCustomAttrsResults["Accelerator$ebs_sr_id"].ToString() : ""; sr_num = incCustomAttrsResults["Accelerator$ebs_sr_num"] != null ? incCustomAttrsResults["Accelerator$ebs_sr_num"].ToString() : ""; //Check incident whether associated to a service request if (!String.IsNullOrWhiteSpace(sr_id)) { //If incident is related to a SR //Lookup repair order by service request id RepairOrder ro = new RepairOrder(); RepairOrder[] results = null; try { results = ro.LookupList(sr_id, sr_num, _logIncidentId, 0); e.Result = results; } catch (Exception ex) { e.Cancel = true; bw_roList.CancelAsync(); string message = ex.Message; MessageBox.Show(message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); logMessage = "Error in loading Repair Order List. Error: " + ex.Message; _log.ErrorLog(incidentId: _logIncidentId, logMessage: logMessage); return; } if (ro.ErrorMessage != null) { e.Cancel = true; logMessage = "Loading Repair Order List is failed. SR ID = " + sr_id; logNote = "Response shows error code when loading repair order list. Response's error message: " + ro.ErrorMessage; _log.ErrorLog(incidentId: _logIncidentId, logMessage: logMessage, logNote: logNote); return; } else { logMessage = "Loading Repair Order List Successfully. Current Service Request has " + results.Length + " Repair Order(s)"; logNote = ""; _log.DebugLog(incidentId: _logIncidentId, logMessage: logMessage, logNote: logNote); } } else { e.Result = null; } }
private void bw_ValidateSerialNum(object sender, DoWorkEventArgs e) { string logMessage, logNote; string serialNum = (string)e.Argument; IContact Contact = _rc.GetWorkspaceRecord(RightNow.AddIns.Common.WorkspaceRecordType.Contact) as IContact; if (Contact == null) { e.Cancel = true; logMessage = "Contact is empty. Cannot do the serial number validation. "; logNote = ""; _log.DebugLog(incidentId: _logIncidentId, logMessage: logMessage, logNote: logNote); e.Result = logMessage; return; } IList <ICustomAttribute> conCustomAttributes = Contact.CustomAttributes; string[] conCustomAttrs = { "Accelerator$ebs_contact_org_id" }; Dictionary <String, Object> conCustomAttrResults = CustomAttrHelper.fetchCustomAttrValue(conCustomAttributes, conCustomAttrs, this._logIncidentId, 0); string contactOrgId = conCustomAttrResults["Accelerator$ebs_contact_org_id"] != null ? conCustomAttrResults["Accelerator$ebs_contact_org_id"].ToString() : "0"; if (contactOrgId == "0") { logMessage = "Current contact did not associate to a EBS contact correctly. Cannot do the serial number validation."; _log.DebugLog(incidentId: _logIncidentId, logMessage: logMessage); e.Result = null; return; } try { bool isValid = SerialNumberValidation(serialNum, contactOrgId); e.Result = isValid; } catch (Exception ex) { logMessage = "Serial Number Validation thread is cancelled, because error: " + ex.Message; _log.ErrorLog(incidentId: _logIncidentId, logMessage: logMessage); e.Cancel = true; } }
// Triggered when the workspace is saved void _recordContext_Saved(object sender, EventArgs e) { //Update incident record because updated incident has been saved. Incident = _recordContext.GetWorkspaceRecord(RightNow.AddIns.Common.WorkspaceRecordType.Incident) as IIncident; //get custom fields sr_id var sr_id = ""; IList <ICustomAttribute> incCustomAttributes = Incident.CustomAttributes; string[] incCustomAttrSrId = { "Accelerator$siebel_sr_id" }; Dictionary <String, Object> incCustomAttrResultSrId = CustomAttrHelper.fetchCustomAttrValue(incCustomAttributes, incCustomAttrSrId, this._logIncidentId, 0); sr_id = incCustomAttrResultSrId["Accelerator$siebel_sr_id"] != null ? incCustomAttrResultSrId["Accelerator$siebel_sr_id"].ToString() : ""; if (!String.IsNullOrWhiteSpace(sr_id) && canAddNewActivity) { // Create Activity SaveActivityToSiebel(sr_id); } }
private decimal getIncidentID(IReportFilterNode filterNode, int rntContactId, out int rntIncidentId) { IRecordContext _context = ((EBSVirtualReportTablesPackage)this.Parent)._globalContext.AutomationContext.CurrentWorkspace; if (null != _context) { WorkspaceRecordType workspaceType = _context.WorkspaceType; if (workspaceType == WorkspaceRecordType.Incident) { IIncident incidentRecord = _context.GetWorkspaceRecord(RightNow.AddIns.Common.WorkspaceRecordType.Incident) as IIncident; if (null != incidentRecord) { IList <ICustomAttribute> customAttributes = incidentRecord.CustomAttributes; rntIncidentId = incidentRecord.ID; object val = CustomAttrHelper.fetchCustomAttrValue(customAttributes, new string[] { "Accelerator$ebs_sr_id" }, rntIncidentId, rntContactId) ["Accelerator$ebs_sr_id"]; return((null != val) ? Convert.ToDecimal(val) : 0); } } } decimal incident_id = 0; rntIncidentId = 0; object filter_value = getEqualsFilterValue(filterNode, "HiddenIncidentID", false); if (null != filter_value) { incident_id = Convert.ToDecimal(filter_value); } if (incident_id > 0) { return(incident_id); } string logMessage = "Provide a valid EBS Incident ID to search for Repair Orders. Ignoring ebs_sr_id " + incident_id; string logNote = null; ConfigurationSetting.logWrap.DebugLog(rntIncidentId, 0, logMessage, logNote); return(0); }
void _recordContext_Saved(object sender, EventArgs e) { if (!isEnabledEditing && this.creatingRO == false) { return; } string logMessage, logNote; //get current sr id var sr_id = ""; IList <ICustomAttribute> incCustomAttributes = Incident.CustomAttributes; string[] incCustomAttrs = { "Accelerator$ebs_sr_id" }; Dictionary <String, Object> incCustomAttrsResults = CustomAttrHelper.fetchCustomAttrValue(incCustomAttributes, incCustomAttrs, this._logIncidentId, 0); sr_id = incCustomAttrsResults["Accelerator$ebs_sr_id"] != null ? incCustomAttrsResults["Accelerator$ebs_sr_id"].ToString() : ""; //Check whether need to send request to server if (!String.IsNullOrWhiteSpace(sr_id) && _repairOrderControl.isAddingRO == true) { //Add new RO to server logMessage = "Need to add a Repair Order for SR. SR ID = " + sr_id; logNote = ""; _log.DebugLog(incidentId: _logIncidentId, logMessage: logMessage, logNote: logNote); SaveRepairOrderToServer(Convert.ToDecimal(sr_id)); _repairOrderControl.isAddingRO = false; } else if (!String.IsNullOrWhiteSpace(_repairOrderControl.changingRONum) && _repairOrderControl.isChangingRO == true) { //Update RO to server logMessage = "Need to edit Repair Order. Repair Order id = " + _repairOrderControl.changingRONum; logNote = ""; _log.DebugLog(incidentId: _logIncidentId, logMessage: logMessage, logNote: logNote); SaveRepairOrderToServer(Convert.ToDecimal(sr_id)); _repairOrderControl.isChangingRO = false; } }
private string getSerialNumber(IReportFilterNode filterNode, int rntContactId, out int rntIncidentId) { IRecordContext _context = ((EBSVirtualReportTablesPackage)this.Parent)._globalContext.AutomationContext.CurrentWorkspace; if (null != _context) { WorkspaceRecordType workspaceType = _context.WorkspaceType; if (workspaceType == WorkspaceRecordType.Incident) { IIncident incidentRecord = _context.GetWorkspaceRecord(RightNow.AddIns.Common.WorkspaceRecordType.Incident) as IIncident; if (null != incidentRecord) { IList <ICustomAttribute> customAttributes = incidentRecord.CustomAttributes; rntIncidentId = incidentRecord.ID; object val = CustomAttrHelper.fetchCustomAttrValue(customAttributes, new string[] { "Accelerator$ebs_serial_number" }, rntIncidentId, rntContactId) ["Accelerator$ebs_serial_number"]; return((null != val) ? val.ToString() : ""); } } } string serial_number = ""; rntIncidentId = 0; object filter_value = getEqualsFilterValue(filterNode, "HiddenSerialNumber", true); if (null != filter_value) { serial_number = Convert.ToString(filter_value); } if (!String.IsNullOrWhiteSpace(serial_number)) { return(serial_number); } return(""); }
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$ebs_sr_id", "Accelerator$ebs_sr_num", "Accelerator$ebs_serial_number" }; Dictionary <String, Object> incCustomAttrsResults = CustomAttrHelper.fetchCustomAttrValue(customAttributes, incCustomAttrs, this._logIncidentId, 0); sr_id = incCustomAttrsResults["Accelerator$ebs_sr_id"] != null ? incCustomAttrsResults["Accelerator$ebs_sr_id"].ToString() : ""; sr_num = incCustomAttrsResults["Accelerator$ebs_sr_num"] != null ? incCustomAttrsResults["Accelerator$ebs_sr_num"].ToString() : ""; e.Result = null; if (!String.IsNullOrWhiteSpace(sr_id) || !String.IsNullOrWhiteSpace(sr_num)) { // Call to SR Lookup and Display SR Details ServiceRequest sr = new ServiceRequest(); try { sr = sr.Lookup(Convert.ToDecimal(sr_id), sr_num, _logIncidentId, 0); } catch (Exception ex) { e.Cancel = true; MessageBox.Show(ex.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; } 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.EbsContactID == "0") ? "" : sr.EbsContactID; storedSeverityId = Convert.ToInt32(sr.SeverityID == null ? 0 : sr.SeverityID); storedRequestStatusId = Convert.ToInt32(sr.StatusID == null ? 0 : sr.StatusID); storedRequestTypeId = Convert.ToInt32(sr.RequestTypeID == null ? 0 : sr.RequestTypeID); storedSubject = sr.Summary; ebsStoredSerialNum = (sr.SerialNumber == null ? "" : sr.SerialNumber); ebsStoredInstanceID = (decimal)(sr.ProductID == null ? 0 : sr.ProductID); bool sr_obj_ver_num = false; bool sr_owner_id = false; foreach (ICustomAttribute cusAttr in customAttributes) { if (cusAttr.PackageName == "Accelerator" && cusAttr.GenericField.Name == "Accelerator$ebs_sr_obj_ver_num") { sr_obj_ver_num = true; cusAttr.GenericField.DataValue.Value = Convert.ToInt32(sr.SrObjVerNum == null ? 0 : sr.SrObjVerNum); } if (cusAttr.PackageName == "Accelerator" && cusAttr.GenericField.Name == "Accelerator$ebs_sr_owner_id") { sr_owner_id = true; cusAttr.GenericField.DataValue.Value = sr.OwnerID.HasValue ? Convert.ToString(sr.OwnerID) : ""; } } if (sr_obj_ver_num == false) { logMessage = "Custom attribute is not defined. Cannot get Accelerator$ebs_sr_obj_ver_num."; ConfigurationSetting.logWrap.ErrorLog(incidentId: _logIncidentId, logMessage: logMessage); } if (sr_owner_id == false) { logMessage = "Custom attribute is not defined. Cannot get Accelerator$ebs_sr_owner_id."; ConfigurationSetting.logWrap.ErrorLog(incidentId: _logIncidentId, logMessage: logMessage); } if (sr_obj_ver_num == false || sr_owner_id == 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); } }