Exemple #1
0
        /// <summary>
        /// Funtion to handle ebs webservice response
        /// </summary>
        /// <param name="respJson">response in jSON string</param>
        public void ExtractResponse(string jsonResp, int numOfVIN, int shipToSiteID, int partOdrInstrID)
        {
            Dictionary <String, object> retunTblItem;
            //Extract response
            var deserializeJson = new JavaScriptSerializer().Deserialize <dynamic>(jsonResp);
            Dictionary <String, object> data             = (Dictionary <string, object>)deserializeJson;
            Dictionary <String, object> outputParameters = (Dictionary <String, object>)data["OutputParameters"];
            Dictionary <String, object> returnTbl        = (Dictionary <String, object>)outputParameters["P_RETURN_TBL"];

            //Check if its an array, is so extract first element
            if (IsArray(returnTbl["P_RETURN_TBL_ITEM"]))
            {
                object[] tblItems = (object[])returnTbl["P_RETURN_TBL_ITEM"];
                retunTblItem = (Dictionary <string, object>)tblItems[0];
            }
            else
            {
                retunTblItem = (Dictionary <String, object>)returnTbl["P_RETURN_TBL_ITEM"];
            }

            if (retunTblItem["HASERROR"].ToString() == "0")//If Success
            {
                //if (partsOrderID != 0)
                //{
                string salesOrderNum = retunTblItem["SALES_ORDER_NO"].ToString();

                //Update PartsOrder Object with SalesOrder Number and other Reported Incident Info
                _rnConnectService.UpdatePartsOrder(_lineRecords, salesOrderNum, numOfVIN, _partsHeaderRecord, shipToSiteID, partOdrInstrID);

                //Clear out some of Reported Incident field that were specific for this order only for Retrofit case only
                if (partOdrInstrID > 0)
                {
                    IRecordContext recordContext = ReportCommandAddIn._globalContext.AutomationContext.CurrentWorkspace;
                    recordContext.TriggerNamedEvent("clearPartsOrderFields");
                }
                //}
            }
            else
            {
                //Destroy the partsorder objects
                _rnConnectService.DestroyPartsOrder(_lineRecords);
                ReportCommandAddIn.form.Hide();
                MessageBox.Show(retunTblItem["DESCRIPTION"].ToString());
            }
        }