コード例 #1
0
        /// <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();
                    }
                }
            }
        }