Ejemplo n.º 1
0
        /// <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;
        }
Ejemplo n.º 2
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();
                    }
                }
            }
        }
        /// <summary>
        /// Get required details to build WebRequest
        /// </summary>
        public void MultiVinWarrantyCheck(IIncident incidentRecord)
        {
            try
            {
                _rnConnectService = RightNowConnectService.GetService();
                _incidentRecord   = incidentRecord;
                string multiWarrantyConfigValue = _rnConnectService.GetConfigValue("CUSTOM_CFG_NEW_BOM_QUERY");
                if (multiWarrantyConfigValue != null)
                {
                    var s = new JavaScriptSerializer();

                    var configVerb = s.Deserialize <ConfigVerbs.RootObject>(multiWarrantyConfigValue);
                    _curlURL         = configVerb.URL;
                    _headerURL       = configVerb.xmlns;
                    _xmlnsURL        = configVerb.RESTHeader.xmlns;
                    _respApplication = configVerb.RESTHeader.RespApplication;
                    _responsibility  = configVerb.RESTHeader.Responsibility;
                    _securityGroup   = configVerb.RESTHeader.SecurityGroup;
                    _nLSLanguage     = configVerb.RESTHeader.NLSLanguage;
                    _orgID           = configVerb.RESTHeader.Org_Id;
                }

                _rnConnectService._incidentVINObjects.Clear();//Clear the _incidentVINObjects variable that holds all incident_vin record to be updated with response

                _causalPart = RightNowConnectService.GetService().getFieldFromIncidentRecord("CO", "causal_part_nmbr", incidentRecord);

                string[] internalIncInfo = _rnConnectService.GetInternalIncident(incidentRecord.ID);
                if (internalIncInfo != null)
                {
                    _allInternalincident = internalIncInfo.ToList();
                }
                if (_allInternalincident.Count > 0)
                {
                    var tasks = new Task[_allInternalincident.Count];
                    int ii    = 0;
                    foreach (string internalIncident in _allInternalincident)
                    {
                        tasks[ii++] = Task.Factory.StartNew(() => RequestPerSR(internalIncident));
                    }
                    Task.WaitAll(tasks);
                    _rnConnectService.updateIncidentVinRecords();//Once all task over, call batch job to update Incident_VIN record
                }
            }
            catch (Exception ex)
            {
                WorkspaceAddIn.InfoLog("Exeption in GetDetails: " + ex.Message);
            }
        }
        /// <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);
            }
        }