public void PopulateLeadDetails() { IContact contactRecord = _recordContext.GetWorkspaceRecord(WorkspaceRecordType.Contact) as IContact; IIncident incidentRecord = _recordContext.GetWorkspaceRecord(WorkspaceRecordType.Incident) as IIncident; string leadType = populateLeadType(); IList <IGenericField> fields = _leadRecord.GenericFields; foreach (IGenericField field in fields) { switch (field.Name) { case "lead_name": if (contactRecord != null && incidentRecord != null) { string contactName = contactRecord.NameFirst + " " + contactRecord.NameLast; if (leadType.Equals(OSCOpportunitiesCommon.OpportunityRecordType)) { field.DataValue.Value = String.Format(OSCOpportunitiesCommon.OpportunityName, contactName, incidentRecord.RefNo); } else if (leadType.Equals(OSCOpportunitiesCommon.SalesLeadRecordType)) { field.DataValue.Value = String.Format(OSCOpportunitiesCommon.SalesLeadName, contactName, incidentRecord.RefNo); } } break; } } }
void AddressValidationControl_VerifyAddressClicked(AddressValidationControl ucontrol) { ucontrol.useSuggested.CheckState = CheckState.Unchecked; _isErrorFromResponse = true; IContact contactRecord = _recordContext.GetWorkspaceRecord(RightNow.AddIns.Common.WorkspaceRecordType.Contact) as IContact; Address contactAddress = new Address(); try { if (contactRecord.AddrCountryID != 1) { string errorMsg = "Please--USA only postal address verification!"; ucontrol.addrValidResponseText.Text = errorMsg; ConfigurationSetting.logWrap.NoticeLog(0, contactRecord.ID, logMessage: errorMsg); return; } // get the contactRecord.Addrxxx contactAddress.Address2 = contactRecord.AddrStreet; contactAddress.City = contactRecord.AddrCity; if (contactRecord.AddrProvID != null) { contactAddress.StateID = (int)contactRecord.AddrProvID; } contactAddress.Zip = contactRecord.AddrPostalCode; _responseAddr = null; _responseAddr = ValidateAddress(contactAddress); string addressStg = _responseAddr.Address2 + ", " + _responseAddr.City + ", " + _responseAddr.State + " " + _responseAddr.Zip5 + "-" + _responseAddr.Zip4; ucontrol.addrValidResponseText.Text = "Address verified: " + addressStg; _isErrorFromResponse = false; ConfigurationSetting.logWrap.DebugLog(0, contactRecord.ID, logMessage: ucontrol.addrValidResponseText.Text); if (_responseAddr.ReturnText != null) { string sanitizeMsg = _responseAddr.ReturnText.Replace("Default address:", "Address verified:"); ucontrol.addrValidResponseText.Text = sanitizeMsg + " " + addressStg; } } catch (Exception e) { // log e.Message if (e.Message.Contains("Authorization failure") || e.Message.Contains("Username exceeds maximum length") || e.Message.Contains("Misconfiguration or some other invalid data received.")) { ConfigurationSetting.logWrap.ErrorLog(0, contactRecord.ID, logMessage: e.Message); } else { ConfigurationSetting.logWrap.NoticeLog(0, contactRecord.ID, logMessage: e.Message); } ucontrol.addrValidResponseText.Text = "Not valid: " + e.Message; _isErrorFromResponse = true; } }
void _recordContext_DataLoaded(object sender, System.EventArgs e) { string recordTypeName = _recordContext.WorkspaceTypeName; if (recordTypeName == "Incident") { IIncident i = _recordContext.GetWorkspaceRecord(RightNow.AddIns.Common.WorkspaceRecordType.Incident) as IIncident; IContact c = _recordContext.GetWorkspaceRecord(RightNow.AddIns.Common.WorkspaceRecordType.Contact) as IContact; this.EnableControl(incident: i, contact: c); return; } if (recordTypeName == "Contact") { IContact c = _recordContext.GetWorkspaceRecord(RightNow.AddIns.Common.WorkspaceRecordType.Contact) as IContact; this.EnableControl(contact: c); return; } if (recordTypeName == "Chat") { IChat chat = _recordContext.GetWorkspaceRecord(RightNow.AddIns.Common.WorkspaceRecordType.Chat) as IChat; this.EnableControl(chat: chat); if (this._enableAutoSearchInChat == true) { _ebsContactSearchControl.autoSearchParameterInvoke(); } return; } }
/// <summary> /// Method which is called when any Workspace Rule Action is invoked. /// </summary> /// <param name="ActionName">The name of the Workspace Rule Action that was invoked.</param> public void RuleActionInvoked(string ActionName) { try { switch (ActionName) { case "RPSM": _incidentRecord = (IIncident)_recordContext.GetWorkspaceRecord(RightNow.AddIns.Common.WorkspaceRecordType.Incident); _contactRecord = _recordContext.GetWorkspaceRecord(RightNow.AddIns.Common.WorkspaceRecordType.Contact) as IContact; string RPSM = _rnConnectService.GetOrgTerritory(_contactRecord.OrgID.ToString(), ActionName); if (!string.IsNullOrEmpty(RPSM)) { _incidentRecord.Assigned.AcctID = Int32.Parse(RPSM); } break; case "RegDirector": _incidentRecord = (IIncident)_recordContext.GetWorkspaceRecord(RightNow.AddIns.Common.WorkspaceRecordType.Incident); _contactRecord = _recordContext.GetWorkspaceRecord(RightNow.AddIns.Common.WorkspaceRecordType.Contact) as IContact; string region = _rnConnectService.GetOrgTerritory(_contactRecord.OrgID.ToString(), ActionName); string RegDir = _rnConnectService.GetRegion(region); if (!string.IsNullOrEmpty(RegDir)) { _incidentRecord.Assigned.AcctID = Int32.Parse(RegDir); } break; } } catch (Exception e) { MessageBox.Show("error" + e); } }
/// <summary> /// Method which is called when any Workspace Rule Action is invoked. /// </summary> /// <param name="ActionName">The name of the Workspace Rule Action that was invoked.</param> public void RuleActionInvoked(string ActionName) { string fieldVal = ""; switch (ActionName) { case "PartsPriceAdj": _partsRecord = _recordContext.GetWorkspaceRecord(_recordContext.WorkspaceTypeName) as IGenericObject; fieldVal = GetFieldValue("part_price", _partsRecord); //Get value SetFieldValue("part_price_adj", fieldVal, _partsRecord); break; case "LaborRateAdj": _laborRecord = _recordContext.GetWorkspaceRecord(_recordContext.WorkspaceTypeName) as IGenericObject; fieldVal = GetFieldValue("labor_rate_rqstd", _laborRecord); //Get value SetFieldValue("labor_rate_adj", fieldVal, _laborRecord); break; case "OtherChargesAdj": _otherchRecord = _recordContext.GetWorkspaceRecord(_recordContext.WorkspaceTypeName) as IGenericObject; fieldVal = GetFieldValue("other_charges_amount", _otherchRecord);//Get value SetFieldValue("other_charges_amount_adj", fieldVal, _otherchRecord); break; default: break; } _recordContext.RefreshWorkspace();//refresh the workspace }
/// <summary> /// Method called by data load event. It does the following: /// 1> Get Onload FSAR value /// 2> Get all affected VIN mapped to currently opened reported Incident /// 3> If _showSRFormAfterSave is set then show SR/VIN form /// </summary> private void _recordContext_DataLoaded(object sender, EventArgs e) { //Making onload async to reduce time of record load var backgroundService = new BackgroundServiceUtil(); backgroundService.RunAsync(() => { //Get all affected VIN's of reported incident _affectedBusIds = new List <string>(); _incidentRecord = (IIncident)_recordContext.GetWorkspaceRecord(RightNow.AddIns.Common.WorkspaceRecordType.Incident); if (_incidentRecord != null) { string[] response = RightNowConnectService.GetService().GetAffectedBus(_incidentRecord.ID); if (response != null) { _affectedBusIds = response.ToList(); } } //Get FSAR value on Load _onLoadFSARVal = RightNowConnectService.GetService().getFieldFromIncidentRecord("CO", "FSAR", _incidentRecord); string[] internalIncident = RightNowConnectService.GetService().GetAllInternalIncident(_incidentRecord.ID); if (internalIncident != null) { RightNowConnectService.GetService().setIncidentField("CO", "no_of_sr", internalIncident.Length.ToString(), _incidentRecord); } }); }
/* For showing the Siebel Contact Details. * It can also be run in Report Explorer by creating a required filter on PERSON_PARTY_ID */ public override IList <IReportRow> GetRows(IList <string> columns, IReportFilterNode filterNode) { IList <IReportRow> reportRows = new List <IReportRow>(); IRecordContext _context = ((SiebelVirtualReportTablesPackage)this.Parent)._globalContext.AutomationContext.CurrentWorkspace; Dictionary <string, string> dictDetail = null; if (_context == null) { return(reportRows); } IIncident incidentRecord = _context.GetWorkspaceRecord(RightNow.AddIns.Common.WorkspaceRecordType.Incident) as IIncident; if (incidentRecord == null) { return(reportRows); } string serialNum = null; // get the serialNum custom attribute on the incident workspace serialNum = getIncidentWSCustomAttr(incidentRecord, "siebel_serial_number"); if (serialNum == "" || serialNum == null) { return(reportRows); } string logMessage = "Calling LookupAsset for Asset." + "serialNum: " + serialNum; ConfigurationSetting.logWrap.DebugLog(incidentRecord.ID, 0, logMessage: logMessage); string orgId = null; IContact contactRecord = _context.GetWorkspaceRecord(RightNow.AddIns.Common.WorkspaceRecordType.Contact) as IContact; if (contactRecord != null) { orgId = getContactOrgIdCustomAttr(contactRecord); } if (orgId == "" || orgId == null) { return(reportRows); } // call Siebel Asset.LookupAsset, which return <columnName, type+TYPE_VALUE_DELIMITER+value) dictDetail = Asset.LookupAsset(columns, serialNum, orgId, 0, incidentRecord.ID); if (dictDetail == null) { return(reportRows); } ReportDataRow reportDataRow = new ReportDataRow(this.Columns.Count); addDetailRow(dictDetail, ref columns, ref reportDataRow, ref reportRows); return(reportRows); }
/// <summary> /// /// </summary> public void Execute(IList <IReportRow> rows) { _selectedRows = rows; _recordContext = _globalContext.AutomationContext.CurrentWorkspace; _workOrder = (IGenericObject)_recordContext.GetWorkspaceRecord("TOA$Work_Order"); _workOrderExtra = (IGenericObject)_recordContext.GetWorkspaceRecord("TOA$Work_Order_Extra"); System.Threading.Thread th = new System.Threading.Thread(ProcessSelectedRowInfo); th.Start(); form.Show(); }
public void Execute(IList <IReportRow> rows) { _selectedRows = rows; _recordContext = _globalContext.AutomationContext.CurrentWorkspace; _incidentRecord = _recordContext.GetWorkspaceRecord(WorkspaceRecordType.Incident) as IIncident; _incidentExtra = _recordContext.GetWorkspaceRecord("CO$Incident_Extra") as IGenericObject; System.Threading.Thread th = new System.Threading.Thread(ProcessSelectedRowInfo); th.Start(); form.Show(); }
void _rContext_DataLoaded(object sender, System.EventArgs e) { if (_Model.IsRunning) { _Model.Render(false); return; } WorkspaceRecordType wsType = _recordContext.WorkspaceType; if (WorkspaceRecordType.Incident == wsType) { _Incident = _recordContext.GetWorkspaceRecord(WorkspaceRecordType.Incident) as IIncident; _Contact = _recordContext.GetWorkspaceRecord(WorkspaceRecordType.Contact) as IContact; //get the ebs incident id if (null != _Incident) { IList <ICustomAttribute> customAttributes = _Incident.CustomAttributes; foreach (ICustomAttribute cusAttr in customAttributes) { if (cusAttr.PackageName == "Accelerator" && cusAttr.GenericField.Name == "Accelerator$ebs_sr_id") { object id = cusAttr.GenericField.DataValue.Value; EbsIncidentId = (id != null) ? Convert.ToDecimal(id) : 0; } } } } // get ebs contact org id if (null != _Contact) { IList <ICustomAttribute> customAttributes = _Contact.CustomAttributes; foreach (ICustomAttribute cusAttr in customAttributes) { if (cusAttr.PackageName == "Accelerator" && cusAttr.GenericField.Name == "Accelerator$ebs_contact_org_id") { object id = cusAttr.GenericField.DataValue.Value; _EbsContactOrgId = (id != null) ? Convert.ToDecimal(id) : 0; } } } _Model.EbsSrId = EbsIncidentId; _Model.EbsContactOrgId = _EbsContactOrgId; _Model.RntIncidentId = null == _Incident ? 0 : _Incident.ID; _Model.RntContactId = null == _Contact ? 0 : _Contact.ID; _Model.IsRecordLoaded = true; _Model.InDemo = false; _Model.InDemo = (0 == EbsIncidentId || 0 == _Model.EbsOwnerId); _Model.Render(true); }
/// <summary> /// Method called by data load event. It does the following: /// 1> Get Onload FSAR value /// 2> Get all affected VIN mapped to currently opened FSAR /// </summary> private void _recordContext_DataLoaded(object sender, System.EventArgs e) { _affectedBusId = new List <string>(); _fsarRecord = (IGenericObject)_recordContext.GetWorkspaceRecord("CO$FSAR"); if (_fsarRecord != null) { string[] response = RightNowConnectService.GetService().GetAffectedBus(_fsarRecord.Id); if (response != null) { _affectedBusId = response.ToList(); } } }
/// <summary> /// Method which is called when any Workspace Rule Action is invoked. /// </summary> /// <param name="ActionName">The name of the Workspace Rule Action that was invoked.</param> public void RuleActionInvoked(string ActionName) { switch (ActionName) { case "Send_SupplierCredit": _incidentRecord = _recordContext.GetWorkspaceRecord(RightNow.AddIns.Common.WorkspaceRecordType.Incident) as IIncident; _sClaimRecord = (IGenericObject)_recordContext.GetWorkspaceRecord("CO$sClaim"); _form.Show(); //start progress form SendSupplierCredit(); break; } }
/// <summary> /// Reload the workspace and load the incident and contact records /// </summary> public void LoadWorkspaceRecords() { try { recordContext.RefreshWorkspace(); incidentWorkspaceRecord = (IIncident)recordContext.GetWorkspaceRecord(WorkspaceRecordType.Incident); contactWorkspaceRecord = (IContact)recordContext.GetWorkspaceRecord(WorkspaceRecordType.Contact); } catch (Exception ex) { throw new Exception("Failed to load workspace records", ex); } }
void _recordContext_DataLoaded(object sender, System.EventArgs e) { try { IIncident i = _recordContext.GetWorkspaceRecord(RightNow.AddIns.Common.WorkspaceRecordType.Incident) as IIncident; this.EnableControl(i); } catch (Exception ex) { string logMessage = "Error in loading Repair Order. Cancel Async Thread. Error: " + ex.Message; string logNote = ""; _log.ErrorLog(incidentId: _logIncidentId, logMessage: logMessage, logNote: logNote); } }
/// <summary> /// /// </summary> /// <param name="recordContext"></param> /// <param name="orgExternalRef"></param> /// <param name="contactExternalRef"></param> /// <param name="orgID"></param> /// <returns></returns> private bool validateExternalReference(IRecordContext recordContext, long?orgExternalRef, long?contactExternalRef, int?orgID) { //B2C Case: If Contact is there but if no external reference is associated it needs to be first synced to create lead. logger.Debug("Validate B2C case, contact is specified and there is no Org"); if (-1 == contactExternalRef && (null == orgID)) { IContact contactRecord = recordContext.GetWorkspaceRecord(WorkspaceRecordType.Contact) as IContact; MessageBox.Show(String.Format(OSCExceptionMessages.ContactDoesNotExistMessage, contactRecord.NameFirst, contactRecord.NameLast), OSCExceptionMessages.LeadNotCreatedTitle, MessageBoxButton.OK, MessageBoxImage.Error); return(false); } //B2B Case logger.Debug("Validate B2B Case"); if (null != orgID) { //B2B Case 1: Contact is synced but org is still not synced. if (-1 == orgExternalRef && contactExternalRef > 0) { IOrganization organizationRecord = recordContext.GetWorkspaceRecord(WorkspaceRecordType.Organization) as IOrganization; MessageBox.Show(String.Format(OSCExceptionMessages.OrganizationDoesNotExistMessage, organizationRecord.Name), OSCExceptionMessages.LeadNotCreatedTitle, MessageBoxButton.OK, MessageBoxImage.Error); logger.Debug("Contact is synced but Organization is not synced"); return(false); } //B2B Case 2: Contact is not synced but org is synced. if (orgExternalRef > 0 && contactExternalRef == -1) { IContact contactRecord = recordContext.GetWorkspaceRecord(WorkspaceRecordType.Contact) as IContact; MessageBox.Show(String.Format(OSCExceptionMessages.ContactDoesNotExistMessage, contactRecord.NameFirst, contactRecord.NameLast), OSCExceptionMessages.LeadNotCreatedTitle, MessageBoxButton.OK, MessageBoxImage.Error); logger.Debug("Contact is not synced but Organization is synced"); return(false); } //B2B Case 3: Both Contact and Org not synced. if (-1 == orgExternalRef && -1 == contactExternalRef) { IContact contactRecord = recordContext.GetWorkspaceRecord(WorkspaceRecordType.Contact) as IContact; IOrganization organizationRecord = recordContext.GetWorkspaceRecord(WorkspaceRecordType.Organization) as IOrganization; MessageBox.Show(String.Format(OSCExceptionMessages.OrganizationContactDoesNotExistMessage, organizationRecord.Name, contactRecord.NameFirst, contactRecord.NameLast), OSCExceptionMessages.LeadNotCreatedTitle, MessageBoxButton.OK, MessageBoxImage.Error); logger.Debug("Contact and Organization not synced"); return(false); } } //B2C or B2B Cases all valid. logger.Debug("B2B/B2C cases valid ExtRef"); return(true); }
/// <summary> /// Method which is called when any Workspace Rule Action is invoked. /// </summary> /// <param name="ActionName">The name of the Workspace Rule Action that was invoked.</param> public void RuleActionInvoked(string ActionName) { string[] pResults; string[] lResults; string[] oResults; decimal totallabor = 0; decimal totalpartsCost = 0; decimal totalpartsPrice = 0; decimal totalother = 0; decimal net = 0; decimal approvalamt = 0; try { _incidentRecord = (IIncident)_recordContext.GetWorkspaceRecord(RightNow.AddIns.Common.WorkspaceRecordType.Incident); pResults = _rnConnectService.GetParts(_incidentRecord.ID.ToString()); lResults = _rnConnectService.GetLabor(_incidentRecord.ID.ToString()); totallabor = Labor(lResults); oResults = _rnConnectService.GetOther(_incidentRecord.ID.ToString()); totalother = OtherCharges(oResults); totalpartsPrice = PartsPrice(pResults); totalpartsCost = PartsCost(pResults); // MessageBox.Show("action" + ActionName); /// MessageBox.Show("totalpartsCost" + totallabor); switch (ActionName) { case "NetReg": net = totalpartsPrice + totallabor + totalother; approvalamt = net; break; case "NetWCD": approvalamt = totalpartsCost + totallabor + totalother; net = totalpartsPrice + totallabor + totalother; break; default: break; } SetIncidentField("c", "Net Amount", Math.Round(net, 0).ToString()); SetIncidentField("CO", "net_amount_text", Math.Round(net, 2).ToString()); SetIncidentField("c", "Approval_Amount", Math.Round(approvalamt, 0).ToString()); } catch (Exception e) { MessageBox.Show("error in net calculation"); } }
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 LeadOpportunitySaveHandler(IRecordContext RecordContext,System.ComponentModel.CancelEventArgs e) { _recordContext = RecordContext; _leadOpportunityRecord = _recordContext.GetWorkspaceRecord(_recordContext.WorkspaceTypeName) as ICustomObject; cancelSaveOperation = e; logger = OSCLogService.GetLog(); }
/* For showing the Siebel Contact Details. * It can also be run in Report Explorer by creating a required filter on PERSON_PARTY_ID */ public override IList <IReportRow> GetRows(IList <string> columns, IReportFilterNode filterNode) { IList <IReportRow> reportRows = new List <IReportRow>(); if (((SiebelVirtualReportTablesPackage)this.Parent)._globalContext == null) { return(reportRows); } IRecordContext _context = ((SiebelVirtualReportTablesPackage)this.Parent)._globalContext.AutomationContext.CurrentWorkspace; Dictionary <string, string> dictDetail = null; String partyID = ""; // for running standalone report (from Report Explorer) if (_context == null) { // filter is PERSON_PARTY_ID if (filterNode != null && filterNode.FilterNodes != null) { IReportFilterNode partyIDFilterNode = filterNode.FilterNodes.ToList <IReportFilterNode>().Find(fn => fn.ReportFilter.Expression == string.Format("{0}${1}.PERSON_PARTY_ID", this.Parent.Name, this.Name)); if (partyIDFilterNode != null) { partyID = partyIDFilterNode.ReportFilter.Value; System.Diagnostics.Debug.WriteLine(partyIDFilterNode.ReportFilter.OperatorType.ToString()); } } if (partyID == "" || partyID == null) { return(reportRows); } dictDetail = ContactModel.LookupDetail(columns, partyID); } else { IContact contactRecord = _context.GetWorkspaceRecord(RightNow.AddIns.Common.WorkspaceRecordType.Contact) as IContact; string contactPartyID = ""; contactPartyID = getContactPartyIdCustomAttr(contactRecord); if (contactPartyID == "") { return(reportRows); } string logMessage = "Calling LookupDetail for Contact." + "contactPartyID: " + contactPartyID; ConfigurationSetting.logWrap.DebugLog(0, contactRecord.ID, logMessage: logMessage); // call Siebel Contact.LookupDetail, which return <columnName, type+TYPE_VALUE_DELIMITER+value) dictDetail = ContactModel.LookupDetail(columns, contactPartyID, 0, contactRecord.ID); } ReportDataRow reportDataRow = new ReportDataRow(this.Columns.Count); addDetailRow(dictDetail, ref columns, ref reportDataRow, ref reportRows); return(reportRows); }
// TODO : Remove below line //public WorkOrderSaveHandler() public WorkOrderSaveHandler(IRecordContext RecordContext, System.ComponentModel.CancelEventArgs e) { _recordContext = RecordContext; _cancelEventArgs = e; _workOrderRecord = _recordContext.GetWorkspaceRecord(_recordContext.WorkspaceTypeName) as ICustomObject; _log = ToaLogService.GetLog(); }
/// <summary> /// Data loaded event of the Contact workspace /// </summary> /// <param name="sender"></param> /// <param name="e"></param> void RecordContext_DataLoaded(object sender, System.EventArgs e) { if (_recordContext.WorkspaceType == WorkspaceRecordType.Contact) { _contactRecord = (IContact)_recordContext.GetWorkspaceRecord(WorkspaceRecordType.Contact); } }
public LeadOpportunitySaveHandler(IRecordContext RecordContext, System.ComponentModel.CancelEventArgs e) { _recordContext = RecordContext; _leadOpportunityRecord = _recordContext.GetWorkspaceRecord(_recordContext.WorkspaceTypeName) as ICustomObject; cancelSaveOperation = e; logger = OSCLogService.GetLog(); }
void getrecords() { var responseValue = string.Empty; try { _OracleBaseUrl = "https://coeinterview-1.custhelp.com/services/rest/connect/v1.3/analyticsReportResults"; _incident = _recordContext.GetWorkspaceRecord(RightNow.AddIns.Common.WorkspaceRecordType.Incident) as IIncident; var incidentID = _incident.ID; var ReportID = 100005; var payload = "{\"id\":" + ReportID + ",\"filters\":{\"name\":\"RefNumber\",\"values\":\"" + incidentID + "\"}}"; HttpWebRequest request = (HttpWebRequest)WebRequest.Create(_OracleBaseUrl); request.Method = "POST"; request.Timeout = 30000; request.ContentType = "application/json"; request.ContentLength = payload.Length; request.Headers.Add("Authorization", "Basic Y29lX2d1cnByZWV0OlNyaXNodGlAMjAxOQ=="); using (Stream webStream = request.GetRequestStream()) using (StreamWriter requestWriter = new StreamWriter(webStream, System.Text.Encoding.ASCII)) { requestWriter.Write(payload); } try { WebResponse webResponse = request.GetResponse(); using (Stream webStream = webResponse.GetResponseStream() ?? Stream.Null) using (StreamReader responseReader = new StreamReader(webStream)) { responseValue = responseReader.ReadToEnd(); Console.Out.WriteLine(responseValue); var count = (JObject.Parse(responseValue)).First; if (Convert.ToInt32(count.ToString().Split(':')[1]) > 0) { string message = "Do you want to Close the parent Incident,If Clicked Yes Child Incidents will get close with this incident, Please refer to Related Incident Tab for Open Child Incidents"; string title = "Incident Alert"; MessageBoxButtons buttons = MessageBoxButtons.YesNo; DialogResult result = MessageBox.Show(message, title, buttons, MessageBoxIcon.Warning); if (result == DialogResult.No) { IsCanceled = true; } } } } catch (Exception ex) { Console.Out.WriteLine("-----------------"); Console.Out.WriteLine(ex.Message); } } catch (Exception ex) { Console.Out.WriteLine("-----------------"); Console.Out.WriteLine(ex.Message); } }
/// <summary> /// /// </summary> public void Execute(IList <IReportRow> rows) { _selectedRows = rows; _recordContext = _globalContext.AutomationContext.CurrentWorkspace; _incidentRecord = (IIncident)_recordContext.GetWorkspaceRecord(RightNow.AddIns.Common.WorkspaceRecordType.Incident); System.Threading.Thread th = new System.Threading.Thread(ProcessSelectedRowInfo); th.Start(); form.Show(); }
/* For showing the Siebel Activity Details. * It can also be run in Report Explorer by creating a required filter on PERSON_PARTY_ID */ public override IList <IReportRow> GetRows(IList <string> columns, IReportFilterNode filterNode) { IList <IReportRow> reportRows = new List <IReportRow>(); IRecordContext _context = ((SiebelVirtualReportTablesPackage)this.Parent)._globalContext.AutomationContext.CurrentWorkspace; Dictionary <string, string> dictDetail = null; if (_context == null) { return(reportRows); } String actvtyId = ""; string filterValue = null; // filter is ActivityId if (filterNode != null && filterNode.FilterNodes != null) { IReportFilterNode actvtyIDFilterNode = filterNode.FilterNodes.ToList <IReportFilterNode>().Find(fn => fn.ReportFilter.Expression == string.Format("{0}${1}.ActivityId", this.Parent.Name, this.Name)); if (actvtyIDFilterNode != null) { actvtyId = actvtyIDFilterNode.ReportFilter.Value; } } IIncident incidentRecord = _context.GetWorkspaceRecord(RightNow.AddIns.Common.WorkspaceRecordType.Incident) as IIncident; string siebelSrId = null; if (incidentRecord != null) { siebelSrId = getIncidentWSCustomAttr(incidentRecord, "siebel_sr_id"); } if (siebelSrId == "" || siebelSrId == null) { return(reportRows); } string logMessage = "Calling LookupActivityDetail for a Siebel SR." + "siebelSrId: " + siebelSrId + ", actvtyId: " + actvtyId; ConfigurationSetting.logWrap.DebugLog(incidentRecord.ID, 0, logMessage: logMessage); // call Siebel Activity.LookupActivityDetail, which return <columnName, type+TYPE_VALUE_DELIMITER+value) dictDetail = Activity.LookupActivityDetail(columns, siebelSrId, actvtyId, incidentRecord.ID, 0); if (dictDetail == null) { return(reportRows); } ReportDataRow reportDataRow = new ReportDataRow(this.Columns.Count); addDetailRow(dictDetail, ref columns, ref reportDataRow, ref reportRows); return(reportRows); }
/// <summary> /// Method which is called when any Workspace Rule Action is invoked. /// </summary> /// <param name="ActionName">The name of the Workspace Rule Action that was invoked.</param> public void RuleActionInvoked(string ActionName) { _laborRecord = _recordContext.GetWorkspaceRecord(_recordContext.WorkspaceTypeName) as ICustomObject; if (ActionName.Contains("DecimalConvert")) { string fielName = ActionName.Split('@')[1]; //Get the field name, which was changed string fieldVal = GetFieldValue(fielName); //Get value string convertedFieldValue = Decimalconversion(fieldVal, fielName); //Convert it 2 decimal if (convertedFieldValue != "") { SetFieldValue(fielName, convertedFieldValue); //set the value } _recordContext.RefreshWorkspace(); //refresh the workspace } if (ActionName.Contains("getOrgRate")) { string orgLaborRate = getOrgField("CO", "labor_rate"); if (orgLaborRate == "") { MessageBox.Show(_orgRecord.Name + " doesn't have any labor rate"); } if (ActionName == "getOrgRateClaim") { SetFieldValue("labor_rate_adj", orgLaborRate); } else { SetFieldValue("labor_rate_rqstd_org", orgLaborRate); } } if (ActionName.Contains("@CopyTO@")) { string[] fields = ActionName.Split(new string[] { "@CopyTO@" }, StringSplitOptions.None); string sourceFielName = fields[0]; //Get the field name, which was changed string destinationFieldName = fields[1]; string fieldVal = GetFieldValue(sourceFielName); //Get value SetFieldValue(destinationFieldName, fieldVal); //set the value _recordContext.RefreshWorkspace(); //refresh the workspace } }
private void _recordContext_DataLoaded(object sender, EventArgs e) { if (_recordContext != null) { //string CompanyID = string.Empty; var workspace = (_recordContext.GetWorkspaceRecord(RightNow.AddIns.Common.WorkspaceRecordType.Contact) as IContact); if (workspace.CustomField != null && workspace.CustomField.Any(z => z.CfId == _CompanyID_CustomField_ID) && !String.IsNullOrEmpty(workspace.CustomField.First(z => z.CfId == _CompanyID_CustomField_ID).ValStr)) { CompanyID = workspace.CustomField.First(z => z.CfId == _CompanyID_CustomField_ID).ValStr; } if (!string.IsNullOrWhiteSpace(CompanyID)) { if (_attemptedSaveAndClose) { bool _error = false; switch (UpdateStatusHandler.Instance.GetUpdateStatus(CompanyID).updateCustomerStatus) { case UpdateStatuses.UpdateStatus.Called: _error = true; break; case UpdateStatuses.UpdateStatus.Failure: _error = true; break; } switch (UpdateStatusHandler.Instance.GetUpdateStatus(CompanyID).updateOrgStatus) { case UpdateStatuses.UpdateStatus.Called: _error = true; break; case UpdateStatuses.UpdateStatus.Failure: _error = true; break; } switch (UpdateStatusHandler.Instance.GetUpdateStatus(CompanyID).updateSalesStatus) { case UpdateStatuses.UpdateStatus.Called: _error = true; break; case UpdateStatuses.UpdateStatus.Failure: _error = true; break; } if (!_error) { _recordContext.ExecuteEditorCommand(RightNow.AddIns.Common.EditorCommand.Close); } } } } }
internal void LoadData() { try { Incident = (IIncident)recordContext.GetWorkspaceRecord(WorkspaceRecordType.Incident); SENEAMOvers = recordContext.GetWorkspaceRecord("CO$SENEAMOvers") as IGenericObject; if (Incident != null && SENEAMOvers != null) { // MessageBox.Show(Incident.ID.ToString()); // MessageBox.Show(SENEAMOvers.Id.ToString()); fields = SENEAMOvers.GenericFields; } else { btnCalculate.Enabled = false; } } catch (Exception ex) { MessageBox.Show("Load: " + ex.Message + "Det" + ex.StackTrace); } }
public SalesReleaseVINSearchForm(string[] srList, List <string> existingAffectedVins, IRecordContext recordContext) { InitializeComponent(); _recordContext = recordContext; _incidentRecord = (IIncident)_recordContext.GetWorkspaceRecord(RightNow.AddIns.Common.WorkspaceRecordType.Incident); _contactRecord = (IContact)_recordContext.GetWorkspaceRecord(RightNow.AddIns.Common.WorkspaceRecordType.Contact); _existingAffectedVins = existingAffectedVins; //Set SR combox SR_Cmbbx.Items.Add(new KeyValuePair <int, string>(0, "[No Value]")); foreach (string sr in srList) { int key = Convert.ToInt32(sr.Split('~')[1]); string value = sr.Split('~')[0]; SR_Cmbbx.Items.Add(new KeyValuePair <int, string>(key, value)); } SR_Cmbbx.DisplayMember = "Value"; SR_Cmbbx.ValueMember = "Key"; form = new ProgressForm(); }
/// <summary> /// /// </summary> /// <param name="recordContext"></param> /// <param name="orgExternalRef"></param> /// <param name="contactExternalRef"></param> /// <param name="contactID"></param> /// <param name="orgID"></param> /// <param name="e"></param> /// <returns></returns> public bool validateRequest(IRecordContext recordContext, long?orgExternalRef, long?contactExternalRef, int?contactID, int?orgID, System.ComponentModel.CancelEventArgs e) { logger.Debug("ValidateRequest Start"); bool isSuccess = true; logger.Debug("Validate Create or Update"); //Validate Record Status isSuccess = validateCreateOrUpdate(recordContext); logger.Debug("Validate Create or Update done. Validation status=" + isSuccess); if (!isSuccess) { //validation failed, cancel save operation e.Cancel = true; return(isSuccess); } logger.Debug("Validate opportunity type"); //Validate lead_oppty_type isSuccess = validateLeadOpportunityType(recordContext); logger.Debug("validate opportunity type done. validation status=" + isSuccess); if (!isSuccess) { //Set submit_status to failed //ICustomObject leadOpportunityObject = recordContext.GetWorkspaceRecord(recordContext.WorkspaceTypeName) as ICustomObject; //setFieldLeadOpportunity(leadOpportunityObject, OSCOpportunitiesCommon.LeadOpportunityStatusFieldName, (object)OSCOpportunitiesCommon.LeadOpportunityFailedStatus); //validation failed, cancel save operation e.Cancel = true; return(isSuccess); } logger.Debug("Validate contact is mandatory or not"); //Validate Contact mandatory isSuccess = validateMandatoryContact(contactID); logger.Debug("Validation mandatory contact is done. Validation status=" + isSuccess); if (!isSuccess) { //validation failed, cancel save operation e.Cancel = true; return(isSuccess); } logger.Debug("Validate external reference"); //Validate External Reference isSuccess = validateExternalReference(recordContext, orgExternalRef, contactExternalRef, orgID); if (!isSuccess) { //Set submit_status to failed ICustomObject leadOpportunityObject = recordContext.GetWorkspaceRecord(recordContext.WorkspaceTypeName) as ICustomObject; setFieldLeadOpportunity(leadOpportunityObject, OSCOpportunitiesCommon.LeadOpportunityStatusFieldName, (object)OSCOpportunitiesCommon.LeadOpportunityFailedStatus); } logger.Debug("Validate external reference done. validation status=" + isSuccess); return(isSuccess); }
/// <summary> /// Method which is called when any Workspace Rule Action is invoked. /// </summary> /// <param name="ActionName">The name of the Workspace Rule Action that was invoked.</param> public void RuleActionInvoked(string ActionName) { string[] pResults; Decimal calc = 0; Decimal dAmt = 0; string amt = ""; try { _sClaimRecord = _recordContext.GetWorkspaceRecord(_recordContext.WorkspaceTypeName) as ICustomObject; string sClaim = _sClaimRecord.Id.ToString(); pResults = _rnConnectService.getCredits(sClaim); List <string> creds = new List <string>(); switch (ActionName) { case "Recovered": if (pResults != null && pResults.Length > 0) { creds = pResults.ToList(); foreach (string c in creds) { amt = c.Split('~')[0]; dAmt = Convert.ToDecimal(amt); calc = calc + dAmt; } calc = Math.Round(calc, 2); } break; default: break; } SetFieldValue("recovered_amount", calc.ToString()); _recordContext.ExecuteEditorCommand(RightNow.AddIns.Common.EditorCommand.Save); } catch (Exception e) { MessageBox.Show("error in recovered calculation"); } }
/// <summary> /// Fetch Work Order Areas for a given zipcode /// </summary> /// <param name="_rcontext"></param> public void GetWorkOrderAreas(IRecordContext _rcontext) { ICustomObject record = _rcontext.GetWorkspaceRecord(_rcontext.WorkspaceTypeName) as ICustomObject; IList<IGenericField> fields = record.GenericFields; string postalCode = null; foreach (IGenericField field in fields) { if (field.Name == "Contact_Postal_Code") { postalCode = field.DataValue.Value.ToString(); break; } } var WorkOrderAreaViewModel = new WorkOrderAreaViewModel(); WorkOrderAreaViewModel.getWorkOrderArea(postalCode); DataContext = WorkOrderAreaViewModel; }
/// <summary> /// Method to fetch Opportunity and return respective models. /// </summary> /// <param name="context"></param> /// <returns>List of Opportunity Models</returns> private List<OpportunityModel> getOpportunitesList(IRecordContext context) { var opportunitiesList = new List<OpportunityModel>(); if (context != null) { var tokenSource = new CancellationTokenSource(); CancellationToken token = tokenSource.Token; Boolean timeout = false; string timeoutValue = RightNowConfigService.GetConfigValue(RightNowConfigKeyNames.SalesTimeout); var orgRecord = context.GetWorkspaceRecord(WorkspaceRecordType.Organization) as IOrganization; if (orgRecord != null) { string ext_ref = RightNowConnectService.GetService().GetContactOrgExternalReference(orgRecord.ID, false, OracleRightNowOSCAddInNames.OpportunityReportTableAddIn); //If the contact is a non sales contact if (String.IsNullOrEmpty(ext_ref)) { _logger.Debug("External reference is empty or null for the org. Returning empty opportunity list."); return opportunitiesList; } if (!String.IsNullOrEmpty(timeoutValue)) { var task = Task.Factory.StartNew(() => OpportunityService.GetService().FindOpenOpportunities(OSCOpportunitiesTableMetadata.OrgFilterColumn, ext_ref), token); if (!task.Wait(Convert.ToInt32(timeoutValue))) { timeout = true; tokenSource.Cancel(); } else { opportunitiesList = task.Result; task.Dispose(); } } else { _logger.Debug("Sales Timesout value is either empty or null"); opportunitiesList = OpportunityService.GetService().FindOpenOpportunities(OSCOpportunitiesTableMetadata.OrgFilterColumn, ext_ref); } _logger.Debug("No. of opportunities fetched for Org #" + ext_ref + " : " + ((opportunitiesList != null) ? opportunitiesList.Count.ToString() : "null")); } else { var contactRecord = context.GetWorkspaceRecord(WorkspaceRecordType.Contact) as IContact; if (contactRecord != null) { string ext_ref = RightNowConnectService.GetService().GetContactOrgExternalReference(contactRecord.ID, true, OracleRightNowOSCAddInNames.OpportunityReportTableAddIn); //If the contact is a non sales contact if (String.IsNullOrEmpty(ext_ref)) { _logger.Debug("External reference is empty or null for contact. Returning empty opportunity list."); return opportunitiesList; } if (!String.IsNullOrEmpty(timeoutValue)) { var task = Task.Factory.StartNew(() => OpportunityService.GetService().FindOpenOpportunities(OSCOpportunitiesTableMetadata.ContactFilterColumn, ext_ref), token); if (!task.Wait(Convert.ToInt32(timeoutValue))) { timeout = true; tokenSource.Cancel(); } else { opportunitiesList = task.Result; task.Dispose(); } } else { _logger.Debug("Sales Timesout value is either empty or null"); opportunitiesList = OpportunityService.GetService().FindOpenOpportunities(OSCOpportunitiesTableMetadata.ContactFilterColumn, ext_ref); } _logger.Debug("No. of opportunities fetched for Contact #" + ext_ref + " : " + ((opportunitiesList != null) ? opportunitiesList.Count.ToString() : "null")); } } if (timeout) { _logger.Debug("FindOpportunity request timed out!"); MessageBox.Show(OSCExceptionMessages.FindOppTimedOut, OSCOpportunitiesCommon.FindOppTimedOutTitle, MessageBoxButtons.OK, MessageBoxIcon.Exclamation); } } return opportunitiesList; }
public PopulateLeadOpportunityDetailsHandler(IRecordContext RecordContext) { _recordContext = RecordContext; _leadRecord = _recordContext.GetWorkspaceRecord(_recordContext.WorkspaceTypeName) as ICustomObject; }
/// <summary> /// /// </summary> /// <param name="recordContext"></param> /// <param name="orgExternalRef"></param> /// <param name="contactExternalRef"></param> /// <param name="contactID"></param> /// <param name="orgID"></param> /// <param name="e"></param> /// <returns></returns> public bool validateRequest(IRecordContext recordContext, long? orgExternalRef, long? contactExternalRef, int? contactID, int? orgID ,System.ComponentModel.CancelEventArgs e) { logger.Debug("ValidateRequest Start"); bool isSuccess = true; logger.Debug("Validate Create or Update"); //Validate Record Status isSuccess = validateCreateOrUpdate(recordContext); logger.Debug("Validate Create or Update done. Validation status="+isSuccess); if (!isSuccess) { //validation failed, cancel save operation e.Cancel = true; return isSuccess; } logger.Debug("Validate opportunity type"); //Validate lead_oppty_type isSuccess = validateLeadOpportunityType(recordContext); logger.Debug("validate opportunity type done. validation status="+isSuccess); if (!isSuccess) { //Set submit_status to failed //ICustomObject leadOpportunityObject = recordContext.GetWorkspaceRecord(recordContext.WorkspaceTypeName) as ICustomObject; //setFieldLeadOpportunity(leadOpportunityObject, OSCOpportunitiesCommon.LeadOpportunityStatusFieldName, (object)OSCOpportunitiesCommon.LeadOpportunityFailedStatus); //validation failed, cancel save operation e.Cancel = true; return isSuccess; } logger.Debug("Validate contact is mandatory or not"); //Validate Contact mandatory isSuccess = validateMandatoryContact(contactID); logger.Debug("Validation mandatory contact is done. Validation status="+isSuccess); if (!isSuccess) { //validation failed, cancel save operation e.Cancel = true; return isSuccess; } logger.Debug("Validate external reference"); //Validate External Reference isSuccess = validateExternalReference(recordContext, orgExternalRef, contactExternalRef, orgID); if (!isSuccess) { //Set submit_status to failed ICustomObject leadOpportunityObject = recordContext.GetWorkspaceRecord(recordContext.WorkspaceTypeName) as ICustomObject; setFieldLeadOpportunity(leadOpportunityObject, OSCOpportunitiesCommon.LeadOpportunityStatusFieldName, (object)OSCOpportunitiesCommon.LeadOpportunityFailedStatus); } logger.Debug("Validate external reference done. validation status="+isSuccess); return isSuccess; }
/// <summary> /// /// </summary> /// <param name="recordContext"></param> /// <returns></returns> private bool validateCreateOrUpdate(IRecordContext recordContext) { ICustomObject leadOpportunityRecord = recordContext.GetWorkspaceRecord(recordContext.WorkspaceTypeName) as ICustomObject; String leadOpportunityExtRef = (String)getFieldFromLeadOpportunity(leadOpportunityRecord, OSCOpportunitiesCommon.LeadOpportunityExtRef); logger.Debug("Lead/Opportunity ExtRef is "+leadOpportunityExtRef); if (!String.IsNullOrWhiteSpace(leadOpportunityExtRef) && !leadOpportunityExtRef.Equals(OSCOpportunitiesCommon.DefaultOpportunitySalesLeadID.ToString(),StringComparison.CurrentCultureIgnoreCase)) { //This is update MessageBox.Show(OSCExceptionMessages.LeadOpportunityUpdateNotSupportedMessage, OSCExceptionMessages.LeadOpportunityUpdateNotSupportedTitle, MessageBoxButton.OK, MessageBoxImage.Information); return false; } //This is create logger.Debug("This is create Opportunity or Lead"); return true; }
/// <summary> /// /// </summary> /// <param name="recordContext"></param> /// <param name="orgExternalRef"></param> /// <param name="contactExternalRef"></param> /// <param name="orgID"></param> /// <returns></returns> private bool validateExternalReference(IRecordContext recordContext, long? orgExternalRef, long? contactExternalRef, int? orgID) { //B2C Case: If Contact is there but if no external reference is associated it needs to be first synced to create lead. logger.Debug("Validate B2C case, contact is specified and there is no Org"); if (-1 == contactExternalRef && (null == orgID)) { IContact contactRecord = recordContext.GetWorkspaceRecord(WorkspaceRecordType.Contact) as IContact; MessageBox.Show(String.Format(OSCExceptionMessages.ContactDoesNotExistMessage, contactRecord.NameFirst, contactRecord.NameLast), OSCExceptionMessages.LeadNotCreatedTitle, MessageBoxButton.OK, MessageBoxImage.Error); return false; } //B2B Case logger.Debug("Validate B2B Case"); if (null != orgID) { //B2B Case 1: Contact is synced but org is still not synced. if (-1 == orgExternalRef && contactExternalRef > 0) { IOrganization organizationRecord = recordContext.GetWorkspaceRecord(WorkspaceRecordType.Organization) as IOrganization; MessageBox.Show(String.Format(OSCExceptionMessages.OrganizationDoesNotExistMessage, organizationRecord.Name), OSCExceptionMessages.LeadNotCreatedTitle, MessageBoxButton.OK, MessageBoxImage.Error); logger.Debug("Contact is synced but Organization is not synced"); return false; } //B2B Case 2: Contact is not synced but org is synced. if (orgExternalRef > 0 && contactExternalRef == -1) { IContact contactRecord = recordContext.GetWorkspaceRecord(WorkspaceRecordType.Contact) as IContact; MessageBox.Show(String.Format(OSCExceptionMessages.ContactDoesNotExistMessage, contactRecord.NameFirst, contactRecord.NameLast), OSCExceptionMessages.LeadNotCreatedTitle, MessageBoxButton.OK, MessageBoxImage.Error); logger.Debug("Contact is not synced but Organization is synced"); return false; } //B2B Case 3: Both Contact and Org not synced. if (-1 == orgExternalRef && -1 == contactExternalRef) { IContact contactRecord = recordContext.GetWorkspaceRecord(WorkspaceRecordType.Contact) as IContact; IOrganization organizationRecord = recordContext.GetWorkspaceRecord(WorkspaceRecordType.Organization) as IOrganization; MessageBox.Show(String.Format(OSCExceptionMessages.OrganizationContactDoesNotExistMessage,organizationRecord.Name,contactRecord.NameFirst,contactRecord.NameLast), OSCExceptionMessages.LeadNotCreatedTitle, MessageBoxButton.OK, MessageBoxImage.Error); logger.Debug("Contact and Organization not synced"); return false; } } //B2C or B2B Cases all valid. logger.Debug("B2B/B2C cases valid ExtRef"); return true; }
public PopulateManualDuration(IRecordContext RecordContext) { _recordContext = RecordContext; _workOrderRecord = _recordContext.GetWorkspaceRecord(_recordContext.WorkspaceTypeName) as ICustomObject; _log = ToaLogService.GetLog(); }
private bool validateLeadOpportunityType(IRecordContext recordContext) { ICustomObject leadOpportunityRecord = recordContext.GetWorkspaceRecord(recordContext.WorkspaceTypeName) as ICustomObject; String leadOpportunityType = (String)getFieldFromLeadOpportunity(leadOpportunityRecord, OSCOpportunitiesCommon.LeadTypeFieldName); logger.Debug("Lead/Opportunity Type "+leadOpportunityType); if(String.IsNullOrWhiteSpace(leadOpportunityType) || (!leadOpportunityType.Equals(OSCOpportunitiesCommon.OpportunityRecordType) && !leadOpportunityType.Equals(OSCOpportunitiesCommon.SalesLeadRecordType))) { //Show appropriate message MessageBox.Show(OSCExceptionMessages.MisConfiguredLeadOpportunityTypeMessage, OSCExceptionMessages.LeadNotCreatedTitle, MessageBoxButton.OK, MessageBoxImage.Error); return false; } logger.Debug("Correct type specified"); return true; }
public WorkOrderModel GetWorkOrderModel(IRecordContext RecordContext) { ICustomObject workOrder = RecordContext.GetWorkspaceRecord(RecordContext.WorkspaceTypeName) as ICustomObject; IContact contact = RecordContext.GetWorkspaceRecord(WorkspaceRecordType.Contact) as IContact; WorkOrderModel workOrderModel = new WorkOrderModel(); _log.Notice("Processing WorkOrder:" + workOrder.Id.ToString()); if (workOrder != null) { IList<IGenericField> fields = workOrder.GenericFields; workOrderModel.AppointmentNumber = workOrder.Id.ToString(); InventoryModel primaryAssetInventoryModel = null; int workorderTypeId = (Int32)getFieldFromWorOrderRecord(workOrder, "WO_Type"); string[] workordertype = RightNowConnectService.GetService().GetWorkOrderTypeFromID(workorderTypeId); _log.Notice("WorkOrder Type ID:" + workordertype[0]); foreach (IGenericField field in fields) { if (field.DataValue.Value != null) { switch (field.Name) { case "Asset" : //cannot use record context here as Asset WorkspaceType is not exposed through RightNow.AddIns.Common. //TODO Un-Comment below lines when RN Connect Services are available if (null != field.DataValue.Value) { primaryAssetInventoryModel = new InventoryModel(); int assetid = (int)field.DataValue.Value; _log.Notice("WorkOrder Primary Asset ID:" + assetid); string[] details = RightNowConnectService.GetService().GetAssetDetailsFromAssetID(assetid.ToString()); string[] productDetails = RightNowConnectService.GetService().GetProductDetailsFromProductID(details[0]);//Type = Product's ID (i.e. SalesProduct.PartNumber) if (null != productDetails && productDetails.Length > 0) { primaryAssetInventoryModel.Type = productDetails[0]; } else { _log.Warning("invtype_label is not valid for primary asset."); } if (details.Length > 1) { primaryAssetInventoryModel.SerialNumber = details[1]; //model = Serial Number } } break; case "Case_Note": workOrderModel.SetPropertyValue("XA_CASE_NOTES", field.DataValue.Value.ToString()); break; case "Cancel_Reason": workOrderModel.CancelReason = field.DataValue.Value.ToString(); break; case "Contact": if (contact != null) { workOrderModel.CustomerNumber = contact.ID.ToString(); _log.Notice("WorkOrder Contact ID:" + contact.ID.ToString()); workOrderModel.Name = contact.NameFirst + " " + contact.NameLast; } break; case "Contact_City": workOrderModel.City = field.DataValue.Value.ToString(); break; case "Contact_Email": workOrderModel.EmailAddress = field.DataValue.Value.ToString(); break; case "Contact_Mobile_Phone": workOrderModel.MobileNumber = field.DataValue.Value.ToString(); break; case "Contact_Phone": workOrderModel.PhoneNumber = field.DataValue.Value.ToString(); break; case "Contact_Postal_Code": workOrderModel.ZipCode = field.DataValue.Value.ToString(); break; case "Contact_Province_State": int province_id = (Int32)field.DataValue.Value; string name = RightNowConnectService.GetService().GetProvinceName(province_id); if (name != null) { workOrderModel.State = name; } break; case "Contact_Street": workOrderModel.Address = field.DataValue.Value.ToString(); break; case "Duration": if(null == field.DataValue.Value) { if (workordertype[1].Equals("1")) { workOrderModel.Duration = workordertype[2]; } _log.Notice("WorkOrder Duration :" + workOrderModel.Duration); }else { workOrderModel.Duration = field.DataValue.Value.ToString(); _log.Notice("WorkOrder Duration :" + workOrderModel.Duration); } break; case "Reminder_Time": if (null != field.DataValue.Value) { int id = Convert.ToInt32(field.DataValue.Value); string[] remindertime1 = RightNowConnectService.GetService().GetReminder_TimeFromID(id); workOrderModel.ReminderTime = Convert.ToInt32(remindertime1[0]); } break; case "Requested_Service_End": workOrderModel.ServiceWindowEnd = field.DataValue.Value.ToString(); break; case "Requested_Service_Start": workOrderModel.ServiceWindowStart = field.DataValue.Value.ToString(); break; case "Resolution_Due": workOrderModel.SlaWindowEnd = Convert.ToDateTime(field.DataValue.Value); break; case "WO_Area": workOrderModel.ExternalId = field.DataValue.Value.ToString(); break; case "WO_Date": workOrderModel.AssignedDate = ((DateTime)field.DataValue.Value).ToString("yyyy-MM-dd"); break; case "WO_Status": //Set it for each handler and not in generic code. break; case "WO_Time_Slot": workOrderModel.TimeSlot = field.DataValue.Value.ToString(); break; case "WO_Type": workOrderModel.WorkType = workordertype[0]; break; } } } //Set Duration if (workOrderModel.Duration == null) { if (workordertype[1].Equals("1")) { workOrderModel.Duration = workordertype[2]; } _log.Notice("WorkOrder Duration :" + workOrderModel.Duration); } // Set Cancel Activity if (workOrderModel.CancelReason != null && !workOrderModel.CancelReason.Trim().Equals("")) { workOrderModel.CommandType = Client.Common.ActivityCommandType.Cancel; } else // Set Update Activity { workOrderModel.Status = Client.Common.ActivityStatus.Pending; workOrderModel.CommandType = Client.Common.ActivityCommandType.Update; } _log.Notice("WorOrder Command Type is set as " + ToaStringsUtil.GetString(workOrderModel.CommandType)); workOrderModel.SetActionIfCompleted = Client.Common.ActionIfCompleted.CreateIfAssignOrReschedule; //TODO UnComment below code SetInventoryModel(workOrderModel, workOrder.Id, primaryAssetInventoryModel, workorderTypeId); } return workOrderModel; }