/// <summary> /// Get required details to build WebRequest /// </summary> public void GetDetails(IIncident incidentRecord, IRecordContext recordContext) { _incidentRecord = incidentRecord; //Get the VIN Number string[] vinDetails = RightNowConnectService.GetService().getBusInfo(_incidentRecord.ID); if (vinDetails != null) { _vin = vinDetails[0].Split('~')[0]; } //Get OOTB ORG ID _supplierID = RightNowConnectService.GetService().getFieldFromIncidentRecord("CO", "supplier_from_webservice", _incidentRecord); if (_supplierID == String.Empty) { WorkspaceAddIn.InfoLog("Supplier ID is blank"); return; } else { //Get EBS ORG ID _supplierID = RightNowConnectService.GetService().GetEbsOrgID(Convert.ToInt32(_supplierID)); } _causalPartNumber = RightNowConnectService.GetService().getFieldFromIncidentRecord("CO", "causal_part_nmbr", _incidentRecord); if (_causalPartNumber == String.Empty) { WorkspaceAddIn.InfoLog("Causal Part Number is blank"); return; } _odometerReading = RightNowConnectService.GetService().getFieldFromIncidentRecord("CO", "odometer_reading", _incidentRecord); if (_odometerReading == String.Empty) { WorkspaceAddIn.InfoLog("Odometer Reading is blank"); return; } _failedDate = RightNowConnectService.GetService().getFieldFromIncidentRecord("CO", "failure_date", _incidentRecord); if (_failedDate == String.Empty) { WorkspaceAddIn.InfoLog("Failed Date is blank"); return; } //If all required info is valid then form jSon request parameter var content = GetReqParam(); var jsonContent = WebServiceRequest.JsonSerialize(content); jsonContent = jsonContent.Replace("xmlns", "@xmlns"); //Call webservice string jsonResponse = WebServiceRequest.Get(_curlURL, jsonContent, "POST"); if (jsonResponse == "") { WorkspaceAddIn.InfoLog("Server didn't return any info"); } else { ExtractResponse(jsonResponse); } return; }
/// <summary> /// Method to perform warranty check for creating "WARRANTY" type work order using old BOM query. /// </summary> public void WarrantyCheck(IIncident incidentRecord) { _rnConnectService = RightNowConnectService.GetService(); _rnConnectService._incidentVINObjects.Clear();//Clear the _incidentVINObjects variable that holds all incident_vin record to be updated with response _incidentRecord = incidentRecord; //Get basic field that need to be pass in webservce call, //Null validation of these fields are handle by workspace rules _odometer = RightNowConnectService.GetService().getFieldFromIncidentRecord("CO", "odometer_reading", _incidentRecord); _causalPart = RightNowConnectService.GetService().getFieldFromIncidentRecord("CO", "causal_part_nmbr", _incidentRecord); string failureDateInSTring = RightNowConnectService.GetService().getFieldFromIncidentRecord("CO", "failure_date", _incidentRecord); _failureDate = Convert.ToDateTime(failureDateInSTring).ToString("dd-MMM-yyyy"); string[] busInfo = _rnConnectService.getBusInfo(_incidentRecord.ID); if (busInfo != null && busInfo.Length > 0) { if (busInfo.Length > 1) { WorkspaceAddIn.InfoLog("It seems multi VIN are mapped with Reporting Incident, warrant type work order" + " works only for individual VIN"); return; } else { _vin = busInfo[0].Split('~')[0]; _srNum = busInfo[0].Split('~')[1]; _incVinID = Convert.ToInt32(busInfo[0].Split('~')[2]); //If all required info is valid then form jSon request parameter var content = GetWarrantyReqParam(); var jsonContent = WebServiceRequest.JsonSerialize(content); jsonContent = jsonContent.Replace("xmlns", "@xmlns"); //Call webservice string jsonResponse = WebServiceRequest.Get(_curlURL, jsonContent, "POST"); if (jsonResponse == "") { WorkspaceAddIn.InfoLog("Server didn't returned any info"); return; } else { ExtractResponse(jsonResponse); _rnConnectService.updateIncidentVinRecords(); } } } else { WorkspaceAddIn.InfoLog("No Bus info found, please map a bus to reporting Incident and then click check warranty button"); return; } return; }
/// <summary> /// This function does basic validation like if unordered parts beed added to reported Incident, if so then /// Call EBS parts order web-service to pass parts related info and store NF_SALES_ORDER no to each parts record /// </summary> /// <returns>string content that need to send to web-service</returns> public void OrderParts(IIncident incidentRecord) { //Get reported Incident Info int orderTypeId = Convert.ToInt32(RightNowConnectService.GetService().getFieldFromIncidentRecord("CO", "order_type", incidentRecord)); int billToId = Convert.ToInt32(RightNowConnectService.GetService().getFieldFromIncidentRecord("CO", "Bill_to_site", incidentRecord)); int shipToId = Convert.ToInt32(RightNowConnectService.GetService().getFieldFromIncidentRecord("CO", "Ship_to_site", incidentRecord)); string claimNum = incidentRecord.RefNo; string projectNum = RightNowConnectService.GetService().getFieldFromIncidentRecord("CO", "project_number", incidentRecord); string retrofitNum = RightNowConnectService.GetService().getFieldFromIncidentRecord("CO", "retrofit_number", incidentRecord); //Get EBS ID from OSvC OOTB ID string billToEbsID = _rnConnectService.GetEbsID(billToId); string shipToEbsID = _rnConnectService.GetEbsID(shipToId); string orgEbsID = _rnConnectService.GetBusOwnerEbsID(Convert.ToInt32(incidentRecord.OrgID)); string odrTypName = _rnConnectService.GetOrderTypeName(orderTypeId); //Get unordered Parts mapped to reported incident _partsInfo = _rnConnectService.GetPartsInfo(incidentRecord.ID); if (_partsInfo == null || _partsInfo.Length <= 0) { WorkspaceAddIn.InfoLog("No parts have beed added to order"); return; } else { //Frame parts order request param structure var content = GetPartsOdrReqParam(odrTypName, orgEbsID, shipToEbsID, billToEbsID, claimNum, projectNum, retrofitNum); if (content == null) { return; } else { //Convert object to jSon string var jsonContent = WebServiceRequest.JsonSerialize(content); jsonContent = jsonContent.Replace("xmlns", "@xmlns"); //Call web-service string jsonResponse = WebServiceRequest.Get(_curlURL, jsonContent, "POST"); if (jsonResponse == "") { WorkspaceAddIn.InfoLog("Server didn't returned any info"); return; } else { ExtractResponse(jsonResponse); _rnConnectService.updateIncidentVinRecords(); } } } }
/// <summary> /// Build Request-Response /// </summary> /// <param name="internalIncident">Internal incident info in string separated by "~"</param> public void RequestPerSR(string internalIncident) { try { //Get VIN and Incident_VIN record ID from Internal incident string[] vinsOfInternalInc = _rnConnectService.GetVins(Convert.ToInt32(internalIncident.Split('~')[0])); if (vinsOfInternalInc != null) { List <VINREC> vinlist = new List <VINREC>(); foreach (string individualVIN in vinsOfInternalInc) { string VinNo = individualVIN.Split('~')[0];//get VIN # VINREC vinRecord = new VINREC { VIN = VinNo }; vinlist.Add(vinRecord); } //If all required info is valid then form jSon request parameter var content = GetMultiVinWarrantyReqParam(internalIncident.Split('~')[2], vinlist); var jsonContent = WebServiceRequest.JsonSerialize(content); jsonContent = jsonContent.Replace("xmlns", "@xmlns"); //Call webservice string jsonResponse = WebServiceRequest.Get(_curlURL, jsonContent, "POST"); if (jsonResponse == "") { WorkspaceAddIn.InfoLog("Server didn't returned any info"); return; } else { ExtractResponse(jsonResponse, vinsOfInternalInc); _rnConnectService.updateIncidentVinRecords(); } } } catch (Exception ex) { WorkspaceAddIn.InfoLog("Exception in WebRequest: " + ex.Message); } }