Пример #1
0
        public void GetProKnowDetails(string sManufacturer, string sModel, out manModelReplyType _ReturnedManModelReplyType, out ProKnowLookupAction LookupMatch)
        {
            Error        = false;
            ErrorMessage = "";

            _ReturnedManModelReplyType = new manModelReplyType();
            LookupMatch = ProKnowLookupAction.NO_ACTION;

            if (sManufacturer == "" || sModel == "")
            {
                Error        = true;
                ErrorMessage = "Need to provide both Manufacturer and Model before continuing.";
                return;
            }
            //Cleanup(ref sManufacturer);
            //Cleanup(ref sModel);
            _ReturnedManModelReplyType = DesktopSession.CallProKnow.GetProKnowDetails(sManufacturer, sModel);

            if (DesktopSession.CallProKnow.Error)
            {
                Error        = true;
                ErrorMessage = "Pro-Know is experiencing technical difficulties.  Please manually categorize items";
            }
            else
            {
                if (_ReturnedManModelReplyType.serviceData.Items.Length == 1)
                {
                    Type serviceDataType = _ReturnedManModelReplyType.serviceData.Items[0].GetType();

                    switch (serviceDataType.Name)
                    {
                    case "businessExceptionType":
                        var statusBusinessExceptionType = (businessExceptionType)_ReturnedManModelReplyType.serviceData.Items[0];
                        if (statusBusinessExceptionType.responseCode == "NO_MATCH_FOUND")
                        {
                            LookupMatch = ProKnowLookupAction.NO_MATCH_FOUND;
                        }
                        else
                        {
                            Error        = true;
                            ErrorMessage = "Unknown Business Exception Type.";
                        }
                        break;

                    case "manModelMatchType":
                        LookupMatch = ProKnowLookupAction.MATCH_FOUND;
                        break;
                    }
                }
                else if (_ReturnedManModelReplyType.serviceData.Items.Length > 1)
                {
                    if (_ReturnedManModelReplyType.serviceData.Items[0].GetType() == typeof(manModelMatchType))
                    {
                        LookupMatch = ProKnowLookupAction.MATCH_MULTI_FOUND;
                    }
                }
            }
        }
        public manModelReplyType GetProKnowDetails(string sManufacturer, string sModel)
        {
            Error        = false;
            ErrorMessage = "";

            manModelReplyType   modelsReplyType     = new manModelReplyType();
            manModelRequestType manModelRequestType = new manModelRequestType();
            Guid gdTransactionID = Guid.NewGuid();

            try
            {
                // all of this information needs to be system variables
                var conf           = SecurityAccessor.Instance.EncryptConfig;
                var proKnowService = conf.GetProKnowESBService();
                manModelRequestType.serviceInformation               = new serviceInformationType();
                manModelRequestType.serviceInformation.domain        = conf.DecryptValue(proKnowService.Domain);
                manModelRequestType.serviceInformation.shopNumber    = GlobalDataAccessor.Instance.CurrentSiteId.StoreNumber;
                manModelRequestType.serviceInformation.terminalID    = GlobalDataAccessor.Instance.CurrentSiteId.TerminalId;
                manModelRequestType.serviceInformation.userID        = DesktopSession.UserName;
                manModelRequestType.serviceInformation.transactionID = gdTransactionID.ToString();
                manModelRequestType.serviceInformation.timeStamp     = ShopDateTime.Instance.ShopDate;
                manModelRequestType.serviceData = new manModelRequestTypeServiceData();
                manModelRequestType.serviceData.manufacturer = sManufacturer.ToUpper();
                manModelRequestType.serviceData.model        = sModel;

                string ePName = conf.DecryptValue(proKnowService.EndPointName);
                string ePUri  = conf.DecryptValue(proKnowService.Uri);
                Port = new proknowPortClient(ePName, ePUri);
                Port.Open();
                modelsReplyType = Port.GetProknowDetails(manModelRequestType);
                Port.Close();

                if (manModelRequestType.serviceInformation.status != null)
                {
                    Error        = true;
                    ErrorMessage = manModelRequestType.serviceInformation.status.sourceMessage;
                    FileLogger.Instance.logMessage(LogLevel.WARN, this, "GetProKnowDetails errored:  " + ErrorMessage + " [" + gdTransactionID.ToString() + "]");
                }
                else
                {
                    FileLogger.Instance.logMessage(LogLevel.INFO, this, "GetProKnowDetails called. [" + gdTransactionID.ToString() + "]");
                }
            }
            catch (Exception exp)
            {
                Error        = true;
                ErrorMessage = exp.Message;
                FileLogger.Instance.logMessage(LogLevel.ERROR, this, "GetProKnowDetails errored:  " + ErrorMessage + " [" + gdTransactionID.ToString() + "]");
            }

            return(modelsReplyType);
        }
Пример #3
0
        // Standard Method to update the ProKnow Manufacturer's Model information
        public List <ProKnowMatch> ProKnowLookup(string sManufacturer, string sModel, out ProKnowLookupAction LookupMatch)
        {
            ProKnowMatch proKnowMatch;
            var          _lstProKnowMatch           = new List <ProKnowMatch>();
            var          _ReturnedManModelReplyType = new manModelReplyType();
            string       sLevelNest = string.Empty;

            LookupMatch = ProKnowLookupAction.NO_ACTION;
            _ReturnedManModelReplyType = DesktopSession.CallProKnow.GetProKnowDetails(sManufacturer, sModel);

            if (DesktopSession.CallProKnow.Error)
            {
                Error        = true;
                ErrorMessage = "Pro-Know is experiencing technical difficulties.  Please manually categorize items";
                return(_lstProKnowMatch);
            }
            if (_ReturnedManModelReplyType.serviceData.Items.Length == 1)
            {
                Type serviceDataType = _ReturnedManModelReplyType.serviceData.Items[0].GetType();

                switch (serviceDataType.Name)
                {
                case "businessExceptionType":
                    var statusBusinessExceptionType = (businessExceptionType)_ReturnedManModelReplyType.serviceData.Items[0];
                    if (statusBusinessExceptionType.responseCode == "NO_MATCH_FOUND")
                    {
                        LookupMatch = ProKnowLookupAction.NO_MATCH_FOUND;
                    }
                    else
                    {
                        Error        = true;
                        ErrorMessage = "Unknown Business Exception Type.";
                    }
                    break;

                case "manModelMatchType":
                    LookupMatch = ProKnowLookupAction.MATCH_FOUND;
                    break;
                }
            }
            else if (_ReturnedManModelReplyType.serviceData.Items.Length > 1)
            {
                if (_ReturnedManModelReplyType.serviceData.Items[0].GetType() == typeof(manModelMatchType))
                {
                    LookupMatch = ProKnowLookupAction.MATCH_MULTI_FOUND;
                }
            }

            switch (LookupMatch)
            {
            case ProKnowLookupAction.MATCH_FOUND:
                var foundManModelMatchType = (manModelMatchType)_ReturnedManModelReplyType.serviceData.Items[0];
                proKnowMatch = new ProKnowMatch
                {
                    manufacturerModelInfo = new List <Answer>()
                };
                ParseProKnowDetails(ref proKnowMatch, ref sLevelNest, foundManModelMatchType, ActiveManufacturer.PRIMARY, out LookupMatch);
                _lstProKnowMatch.Add(proKnowMatch);
                break;

            case ProKnowLookupAction.MATCH_MULTI_FOUND:
                foreach (object oManModelMatchType in _ReturnedManModelReplyType.serviceData.Items)
                {
                    var objectManModelMatchType = (manModelMatchType)oManModelMatchType;
                    proKnowMatch = new ProKnowMatch
                    {
                        manufacturerModelInfo = new List <Answer>()
                    };
                    sLevelNest = string.Empty;
                    ParseProKnowDetails(ref proKnowMatch, ref sLevelNest, objectManModelMatchType, ActiveManufacturer.PRIMARY, out LookupMatch);
                    _lstProKnowMatch.Add(proKnowMatch);
                }
                break;
            }

            return(_lstProKnowMatch);
        }