/// <summary> /// Get required details to build WebRequest /// </summary> /// <param name="partNumber"></param> /// <param name="partQty"></param> /// <param name="incidentRecord"></param> /// <param name="partsOrderID"></param> public void GetDetails(List <OELINEREC> lineRecords, IIncident incidentRecord, int numOfVIN, POEHEADERREC partsHeaderRecord, int shipToSiteID, int partOdrInstrID) { _incidentRecord = incidentRecord; _lineRecords = lineRecords; _partsHeaderRecord = partsHeaderRecord; //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 == "") { //Destroy the partsorder objects _rnConnectService.DestroyPartsOrder(_lineRecords); ReportCommandAddIn.form.Hide(); MessageBox.Show("Server didn't return any info"); } else { ExtractResponse(jsonResponse, numOfVIN, shipToSiteID, partOdrInstrID); } }
/// <summary> /// To update PartsOrder object to keep log of info send to EBS for parts order /// </summary> /// <param name="lineRecords">Line record passed to EBS</param> /// <param name="salesOrderNo"></param> /// <param name="numOfVIN"></param> /// <param name="partsHeaderRecord"></param> /// <param name="shipToSiteID"></param> /// <param name="partOdrInstrID"></param> public void UpdatePartsOrder(List <OELINEREC> lineRecords, string salesOrderNo, POEHEADERREC partsHeaderRecord, int shipToSiteID) { try { List <RNObject> rnObjs = new List <RNObject>(); //Loop over each partsIDToBeOrder that has parts ID that's order recently foreach (OELINEREC lineRecord in lineRecords) { GenericObject genObject = new GenericObject(); genObject.ObjectType = new RNObjectType { Namespace = "CO", TypeName = "PartsOrder" }; genObject.ID = new ID { id = lineRecord.ORDERED_ID, idSpecified = true }; List <GenericField> customFields = new List <GenericField>(); customFields.Add(createGenericField("SalesOrderNumber", createStringDataValue(salesOrderNo), DataTypeEnum.STRING)); customFields.Add(createGenericField("OrderType", createStringDataValue(partsHeaderRecord.ORDER_TYPE), DataTypeEnum.STRING)); customFields.Add(createGenericField("RequestedShipDate", createDateDataValue(partsHeaderRecord.SHIP_DATE), DataTypeEnum.STRING)); customFields.Add(createGenericField("NumberOfVINS", createIntegerDataValue(1), DataTypeEnum.INTEGER)); //customFields.Add(createGenericField("SRNumber", createStringDataValue("SR-"+partsHeaderRecord.PROJECT_NUMBER.Substring(2)), DataTypeEnum.STRING)); customFields.Add(createGenericField("ShipToSite", createNamedIDDataValue(shipToSiteID), DataTypeEnum.NAMED_ID)); genObject.GenericFields = customFields.ToArray(); rnObjs.Add(genObject); } callBatchJob(getUpdateMsg(rnObjs)); } catch (Exception ex) { ReportCommandAddIn.form.Hide(); MessageBox.Show("Exception in updating PartsOrder Record: " + ex.Message); } }
/// <summary> /// To get Parts details and Call Webservice /// </summary> public void ProcessSelectedRowInfo() { POEHEADERREC partsHeaderRecord = new POEHEADERREC(); RightNowConnectService _rnConnectService = RightNowConnectService.GetService(); /*Get Work Order Info*/ //Get ship set from Current Reported Incident string shipSet = _rnConnectService.GetCOFieldValue("ship_set", _workOrder); //Get Num of VIN for which this order will be placed int numOfVIN = 1;//will always be one string orderTypeId = _rnConnectService.GetCOFieldValue("Order_Type", _workOrderExtra); if (orderTypeId == String.Empty) { form.Hide(); MessageBox.Show("Order Type is empty"); return; } partsHeaderRecord.ORDER_TYPE = _rnConnectService.GetOrderTypeName(Convert.ToInt32(orderTypeId)); string shipToId = _rnConnectService.GetCOFieldValue("Ship_To_Site", _workOrder); if (shipToId == String.Empty) { form.Hide(); MessageBox.Show("Ship to Site is empty"); return; } partsHeaderRecord.SHIP_TO_ORG_ID = Convert.ToInt32(_rnConnectService.GetEbsID(Convert.ToInt32(shipToId))); string shipDate = _rnConnectService.GetCOFieldValue("requested_ship_date", _workOrder); if (shipDate == String.Empty) { shipDate = DateTime.Today.ToString();//set to today's date } partsHeaderRecord.SHIP_DATE = Convert.ToDateTime(shipDate).ToString("dd-MMM-yyyy"); string dcID = _rnConnectService.GetCOFieldValue("Distribution_center", _workOrderExtra); if (dcID == String.Empty) { form.Hide(); MessageBox.Show("Distribution Center is empty"); return; } partsHeaderRecord.WAREHOUSE_ORG = _rnConnectService.GetDistributionCenterIDName(Convert.ToInt32(dcID)); string Organization = _rnConnectService.GetCOFieldValue("Organization", _workOrder); partsHeaderRecord.CUSTOMER_ID = Convert.ToInt32(_rnConnectService.GetCustomerEbsID(Convert.ToInt32(Organization))); string incVinID = _rnConnectService.GetCOFieldValue("Incident_VIN_ID", _workOrder); partsHeaderRecord.CLAIM_NUMBER = _rnConnectService.GetRefNum(Convert.ToInt32(incVinID)); partsHeaderRecord.PROJECT_NUMBER = _rnConnectService.GetCOFieldValue("Project_Number", _workOrder); // partsHeaderRecord.RETROFIT_NUMBER = _rnConnectService.GetCOFieldValue("retrofit_number", _workOrder); partsHeaderRecord.CUST_PO_NUMBER = _rnConnectService.GetCOFieldValue("PO_Number", _workOrder);// partsHeaderRecord.SHIPPING_INSTRUCTIONS = _rnConnectService.GetCOFieldValue("Shipping_Instruction", _workOrder); List <OELINEREC> lineRecords = new List <OELINEREC>(); //Loop over each selected parts that user wants to order //Get required info needed for EBS web-service foreach (IReportRow row in _selectedRows) { OELINEREC lineRecord = new OELINEREC(); IList <IReportCell> cells = row.Cells; foreach (IReportCell cell in cells) { if (cell.Name == "Part ID") { //Create PartsOrder record first as EBS web-service need PartsOrder ID lineRecord.ORDERED_ID = _rnConnectService.CreatePartsOrder(Convert.ToInt32(cell.Value));//Pass parts Order ID } if (cell.Name == "Part #") { lineRecord.ORDERED_ITEM = cell.Value; } if (cell.Name == "Qty") { lineRecord.ORDERED_QUANTITY = Convert.ToDouble(Math.Round(Convert.ToDecimal(cell.Value), 2).ToString()) * numOfVIN;//get total qyantity } if (cell.Name == "Source Type") { lineRecord.SOURCE_TYPE = cell.Value; } } lineRecord.SHIP_SET = shipSet; lineRecords.Add(lineRecord); } //Call PartsRequired Model to send parts info to EBS PartsRequiredModel partsRequired = new PartsRequiredModel(_recordContext); partsRequired.GetDetails(lineRecords, _workOrder, partsHeaderRecord, Convert.ToInt32(shipToId)); form.Hide(); _recordContext.ExecuteEditorCommand(RightNow.AddIns.Common.EditorCommand.Save); }
/// <summary> /// To get Parts details and Call Webservice /// </summary> public void ProcessSelectedRowInfo() { POEHEADERREC partsHeaderRecord = new POEHEADERREC(); RightNowConnectService _rnConnectService = RightNowConnectService.GetService(); /*Get Reported Incident Info*/ //Get Incident Type string incType = _rnConnectService.getIncidentField("c", "Incident Type", _incidentRecord); //Get ship set from Current Reported Incident string shipSet = _rnConnectService.getIncidentField("CO", "ship_set", _incidentRecord); //Get Num of VIN for which this order will be placed string numOfVINInString = _rnConnectService.getIncidentField("CO", "no_of_vins", _incidentRecord); if (numOfVINInString == String.Empty) { if (incType == "30") //case of claim type { numOfVINInString = "1"; //set it to 1 } else { form.Hide(); MessageBox.Show("Number Of VIN is empty"); return; } } int numOfVIN = Convert.ToInt32(numOfVINInString); string orderTypeId = _rnConnectService.getIncidentField("CO", "order_type", _incidentRecord); if (orderTypeId == String.Empty) { form.Hide(); MessageBox.Show("Order Type is empty"); return; } partsHeaderRecord.ORDER_TYPE = _rnConnectService.GetOrderTypeName(Convert.ToInt32(orderTypeId)); string shipToId = _rnConnectService.getIncidentField("CO", "Ship_to_site", _incidentRecord); if (shipToId == String.Empty) { form.Hide(); MessageBox.Show("Ship to Site is empty"); return; } partsHeaderRecord.SHIP_TO_ORG_ID = Convert.ToInt32(_rnConnectService.GetEbsID(Convert.ToInt32(shipToId))); string shipDate = _rnConnectService.getIncidentField("CO", "requested_ship_date", _incidentRecord); if (shipDate == String.Empty) { if (incType == "30") //case of claim { shipDate = DateTime.Today.ToString(); //set to today's date } else { form.Hide(); MessageBox.Show("Requested Ship Date is empty"); return; } } partsHeaderRecord.SHIP_DATE = Convert.ToDateTime(shipDate).ToString("dd-MMM-yyyy"); string dcID = _rnConnectService.GetIncidentExtraFieldValue("Distribution_center", _incidentExtra); if (dcID == String.Empty) { form.Hide(); MessageBox.Show("Distribution Center is empty"); return; } partsHeaderRecord.WAREHOUSE_ORG = _rnConnectService.GetDistributionCenterIDName(Convert.ToInt32(dcID)); partsHeaderRecord.CUSTOMER_ID = Convert.ToInt32(_rnConnectService.GetCustomerEbsID((int)_incidentRecord.OrgID)); partsHeaderRecord.CLAIM_NUMBER = _incidentRecord.RefNo; partsHeaderRecord.PROJECT_NUMBER = _rnConnectService.getIncidentField("CO", "project_number", _incidentRecord); partsHeaderRecord.RETROFIT_NUMBER = _rnConnectService.getIncidentField("CO", "retrofit_number", _incidentRecord); partsHeaderRecord.CUST_PO_NUMBER = _rnConnectService.getIncidentField("CO", "PO_Number", _incidentRecord); partsHeaderRecord.SHIPPING_INSTRUCTIONS = _rnConnectService.getIncidentField("CO", "shipping_instructions", _incidentRecord); string partOdrInstrIDString = _rnConnectService.getIncidentField("CO", "PartOrderInstruction_ID", _incidentRecord); int partOdrInstrID = 0;//default case where we won't have partsorderinstruction if (partOdrInstrIDString != String.Empty) { partOdrInstrID = Convert.ToInt32(partOdrInstrIDString); } //List<int> partsIDOrdered = new List<int>(); List <OELINEREC> lineRecords = new List <OELINEREC>(); //Loop over each selected parts that user wants to order //Get required info needed for EBS web-service double oq = 0.00; foreach (IReportRow row in _selectedRows) { OELINEREC lineRecord = new OELINEREC(); IList <IReportCell> cells = row.Cells; foreach (IReportCell cell in cells) { if (cell.Name == "Part ID") { //Create PartsOrder record first as EBS web-service need PartsOrder ID lineRecord.ORDERED_ID = _rnConnectService.CreatePartsOrder(Convert.ToInt32(cell.Value));//Pass parts Order ID } if (cell.Name == "Part #") { lineRecord.ORDERED_ITEM = cell.Value; } if (cell.Name == "Qty") { oq = Convert.ToDouble(Math.Round(Convert.ToDecimal(cell.Value), 2).ToString()) * numOfVIN; lineRecord.ORDERED_QUANTITY = Math.Round(oq, 2);//get total qyantity } if (cell.Name == "Source Type") { lineRecord.SOURCE_TYPE = cell.Value; } } lineRecord.SHIP_SET = shipSet; lineRecords.Add(lineRecord); } //Call PartsRequired Model to send parts info to EBS PartsRequiredModel partsRequired = new PartsRequiredModel(_recordContext); partsRequired.GetDetails(lineRecords, _incidentRecord, numOfVIN, partsHeaderRecord, Convert.ToInt32(shipToId), partOdrInstrID); form.Hide(); _recordContext.ExecuteEditorCommand(RightNow.AddIns.Common.EditorCommand.Save); }