// Extracts the information returned from ProKnow manModelMatchType object public void ParseProKnowDetails(ref ProKnowMatch proKnowMatch, ref string levelNest, manModelMatchType selectedManModelMatchType, ActiveManufacturer _ActiveManufacturerModel, out ProKnowLookupAction LookupMatch) { Error = false; ErrorMessage = ""; LookupMatch = ProKnowLookupAction.NO_ACTION; CategoryNode cnCategoryNodeWalker = DesktopSession.CategoryXML.GetMerchandiseCategory(selectedManModelMatchType.categoryCode.ToString(), ref levelNest); if (cnCategoryNodeWalker != null && _ActiveManufacturerModel == ActiveManufacturer.PRIMARY) { proKnowMatch.primaryCategoryCode = cnCategoryNodeWalker.CategoryCode; proKnowMatch.primaryCategoryCodeDescription = cnCategoryNodeWalker.Description; proKnowMatch.primaryMaskPointer = cnCategoryNodeWalker.Masks; } // Update Manufacturer and Model AnswerCodes ManufacturerUpdate(ref proKnowMatch, _ActiveManufacturerModel, proKnowMatch.manufacturerModelInfo[(int)_ActiveManufacturerModel].AnswerText, cnCategoryNodeWalker.CategoryCode); // Get all the masknn properties from the manModelMatchType returned foreach (PropertyInfo pi in selectedManModelMatchType.preAnswered.GetType().GetProperties()) { if (pi.Name.StartsWith("mask", StringComparison.OrdinalIgnoreCase) && !pi.Name.EndsWith("Specified", StringComparison.OrdinalIgnoreCase)) { var iPiValue = Convert.ToInt32(pi.GetValue(selectedManModelMatchType.preAnswered, null)); if (iPiValue > 0) { var manModelMatchAnswer = new Answer { AnswerText = pi.Name, AnswerCode = Convert.ToInt32(pi.GetValue( selectedManModelMatchType.preAnswered, null)) }; if (proKnowMatch.preAnsweredQuestions == null) { proKnowMatch.preAnsweredQuestions = new List <Answer>(); } proKnowMatch.preAnsweredQuestions.Add(manModelMatchAnswer); } } } // Get FixedFeatures if (selectedManModelMatchType.fixedFeatures != null) { proKnowMatch.displayFixedFeaturesOnTag = selectedManModelMatchType.fixedFeatures.printTag; // Check to see if fixedFeaturesList has not been instantiated yet. Instantiate it. if (proKnowMatch.fixedFeaturesList == null) { proKnowMatch.fixedFeaturesList = new List <FixedFeature>(); } foreach (var foundFixedFeatureType in selectedManModelMatchType.fixedFeatures.feature) { var fixFeature = new FixedFeature { AnswerCode = foundFixedFeatureType.answerNumber, AnswerText = foundFixedFeatureType.description }; proKnowMatch.fixedFeaturesList.Add(fixFeature); } } // Get data from <values#> blocks foreach (PropertyInfo value in selectedManModelMatchType.GetType().GetProperties()) { if (value != null && !string.IsNullOrEmpty(value.Name) && value.Name.StartsWith("values", StringComparison.OrdinalIgnoreCase)) { var foundValueType = (valuesType)value.GetValue(selectedManModelMatchType, null); if (foundValueType != null) { var foundProKnowData = new ProKnowData { ConditionLevel = Convert.ToInt32(value.Name.Replace("values", string.Empty)), LoanAmount = Convert.ToDecimal(foundValueType.loanAmount), LoanVarHighAmount = Convert.ToDecimal(foundValueType.loanVarHigh), LoanVarLowAmount = Convert.ToDecimal(foundValueType.loanVarLow), PurchaseAmount = Convert.ToDecimal(foundValueType.purchaseAmount), RetailAmount = Convert.ToDecimal(foundValueType.retailAmount), RetailVarHighAmount = Convert.ToDecimal(foundValueType.purchaseVarHigh), RetailVarHighRetailer = string.Empty, RetailVarLowAmount = Convert.ToDecimal(foundValueType.purchaseVarLow), RetailVarLowRetailer = string.Empty }; if (proKnowMatch.proKnowData == null) { proKnowMatch.proKnowData = new List <ProKnowData>(); } proKnowMatch.selectedPKData = foundProKnowData; proKnowMatch.proKnowData.Add(foundProKnowData); } } } // Get <ProCallData> information if (selectedManModelMatchType.proCallData != null && _ActiveManufacturerModel == ActiveManufacturer.PRIMARY) { var proCallData = new ProCallData { LastUpdateDate = selectedManModelMatchType.proCallData.lastUpdateDate }; if (!string.IsNullOrEmpty(selectedManModelMatchType.proCallData.newRetail)) { proCallData.NewRetail = Utilities.GetDecimalValue(selectedManModelMatchType.proCallData.newRetail, 0); } proCallData.YearDiscontinued = selectedManModelMatchType.proCallData.yearDiscontinued; proCallData.YearIntroduced = selectedManModelMatchType.proCallData.yearIntroduced; // Check to see if proCallData has not been instantiated yet. Instantiate it. proKnowMatch.proCallData = proCallData; } if (selectedManModelMatchType.combinationCategoryInfo != null && proKnowMatch.transitionStatus != TransitionStatus.MAN_MODEL_PROKNOW_COMBO) { var describedMerchandise = new DescribedMerchandise(proKnowMatch.primaryMaskPointer); if (describedMerchandise.Exists) { // If CashlinxDesktopSesson ActivePawnLoan is null, create a PawnLoad // and add pawnItem to it Item item = describedMerchandise.SelectedPawnItem; if (DesktopSession.HistorySession.Trigger.Equals(Commons.TriggerTypes.CUSTOMERPURCHASE, StringComparison.OrdinalIgnoreCase) || DesktopSession.HistorySession.Trigger.Equals(Commons.TriggerTypes.DESCRIBEITEMCUSTOMERPURCHASE, StringComparison.OrdinalIgnoreCase) || DesktopSession.HistorySession.Trigger.Equals(Commons.TriggerTypes.CUSTOMERPURCHASEPFI, StringComparison.OrdinalIgnoreCase) || DesktopSession.HistorySession.Trigger.Equals(Commons.TriggerTypes.VENDORPURCHASE, StringComparison.OrdinalIgnoreCase)) { if (DesktopSession.ActivePurchase == null) { DesktopSession.ActivePurchase = new PurchaseVO(); } item.mItemOrder = DesktopSession.ActivePurchase.Items.Count + 1; DesktopSession.ActivePurchase.Items.Add(item); } else { if (DesktopSession.ActivePawnLoan == null) { DesktopSession.ActivePawnLoan = new PawnLoan(); } item.mItemOrder = DesktopSession.ActivePawnLoan.Items.Count + 1; DesktopSession.ActivePawnLoan.Items.Add(item); } if (_ActiveManufacturerModel == ActiveManufacturer.PRIMARY) { // Create Secondary Manufacturer Answer object and add to Manufacturer Model Info var secondaryManufacturer = new Answer { AnswerCode = selectedManModelMatchType.combinationCategoryInfo. secondaryManufacturer }; ItemAttribute secondManufacturerItemAttribute = item.Attributes.Find( iaManufacturer => iaManufacturer.AttributeCode == secondaryManufacturer.AnswerCode); secondaryManufacturer.AnswerText = secondManufacturerItemAttribute.Description; secondaryManufacturer.InputKey = secondManufacturerItemAttribute.Description; proKnowMatch.manufacturerModelInfo.Add(secondaryManufacturer); // Create Secondary Model Answer object and add to Manufacturer Model Info var secondaryModel = new Answer { AnswerCode = selectedManModelMatchType.combinationCategoryInfo.secondaryModel }; ItemAttribute secondModelItemAttribute = item.Attributes.Find( iaModel => iaModel.AttributeCode == secondaryModel.AnswerCode); secondaryModel.AnswerText = secondModelItemAttribute.Description; secondaryModel.InputKey = secondModelItemAttribute.Description; proKnowMatch.manufacturerModelInfo.Add(secondaryModel); proKnowMatch.transitionStatus = TransitionStatus.MAN_MODEL_PROKNOW_COMBO; LookupMatch = ProKnowLookupAction.SECONDARY; } } } else { proKnowMatch.transitionStatus = proKnowMatch.transitionStatus != TransitionStatus.MAN_MODEL_PROKNOW_COMBO ? TransitionStatus.MAN_MODEL_PROKNOW : TransitionStatus.MAN_MODEL_PROKNOW_COMBO; if (proKnowMatch.transitionStatus == TransitionStatus.MAN_MODEL_PROKNOW_COMBO) { // Update Manufacturer and Model AnswerCodes DataRow[] myDataRows = DesktopSession.MerchandiseManufacturers.Select("ANS_DESC='" + proKnowMatch.manufacturerModelInfo[2].AnswerText + "'"); if (myDataRows.Length > 0) { ManufacturerUpdate(ref proKnowMatch, _ActiveManufacturerModel, proKnowMatch.manufacturerModelInfo[(int)_ActiveManufacturerModel].AnswerText, Convert.ToInt32(myDataRows[0]["ANS_ID"])); } } LookupMatch = ProKnowLookupAction.DESCRIBE_ITEM_DOUBLE; } }
public static List <IItem> GetJsupItemsByStore(DesktopSession dSession, string pStoreNumber, string pTransferType, out string errorMessage) { // Declare OUT parameters. DataTable table = new DataTable(); DataTable tableDesc = new DataTable(); string errorCode; string errorText; errorMessage = string.Empty; List <IItem> items = new List <IItem>(); bool retVal = TransfersDBProcedures.ExecuteGetJsupMerchandise( pStoreNumber, pTransferType, out table, out tableDesc, out errorCode, out errorText); if (retVal == false || table == null || string.IsNullOrEmpty(errorText) == false) { errorMessage = errorCode + ": " + errorText; FileLogger.Instance.logMessage(LogLevel.ERROR, null, errorMessage); return(items); } IItem item = new Item(); //re-instantiated and re-used in each loop iteration foreach (DataRow r in table.Rows) { if (pTransferType.Equals("SCRAP", StringComparison.CurrentCultureIgnoreCase)) { item = new ScrapItem(); } else if (pTransferType.Equals("REFURB", StringComparison.CurrentCultureIgnoreCase)) { //item = new Item(); item = new ScrapItem(); } else if (pTransferType.Equals("EXCESS", StringComparison.CurrentCultureIgnoreCase)) { // item = new Item(); item = new ScrapItem(); } //else handled by TransfersDBProcedures's call above returning false with errorCode and errorText having been set int icndocFromRow = Utilities.GetIntegerValue(r["ICN_DOC"], -1); string storeNumberFromRow = Utilities.GetStringValue(r["STORENUMBER"], ""); item.RefurbNumber = Utilities.GetIntegerValue(r["RFB_NO"]); item.Icn = Utilities.GetStringValue(r["ICN"]); item.TicketDescription = Utilities.GetStringValue(r["MD_DESC"]); item.ItemAmount = Utilities.GetDecimalValue(r["PFI_AMOUNT"]); item.ItemStatus = (ProductStatus)Enum.Parse(typeof(ProductStatus), Utilities.GetStringValue(r["STATUS_CD"], "")); item.mDocType = Utilities.GetStringValue(r["ICN_DOC_TYPE"]); item.mStore = Utilities.GetIntegerValue(r["ICN_STORE"]); item.CategoryCode = Utilities.GetIntegerValue(r["CAT_CODE"], 0); item.CategoryDescription = Utilities.GetStringValue(r["CAT_DESC"], ""); item.mItemOrder = Utilities.GetIntegerValue(r["ICN_ITEM"]); item.CaccLevel = Utilities.GetIntegerValue(r["CACC_LEV"], -1); item.Attributes = new List <ItemAttribute>(); //Used to get the attributes of the item. //This will be helpful later, such as determining the type of metal for scraps. for (int iMask = 1; iMask <= 15; iMask++) { ItemAttribute itemAttribute = new ItemAttribute(); if (Utilities.GetIntegerValue(r["MASK" + iMask.ToString()], 0) > 0) { itemAttribute.MaskOrder = iMask; Answer answer = new Answer(); answer.AnswerCode = Utilities.GetIntegerValue(r["MASK" + iMask.ToString()], 0); answer.AnswerText = Utilities.GetStringValue(r["MASK_DESC" + iMask.ToString()], ""); // Pull from Other Description List Table if (tableDesc != null && answer.AnswerCode == 999) { string sOtherDscFilter = "STORENUMBER = '" + storeNumberFromRow + "'"; sOtherDscFilter += " and ICN_STORE = " + item.mStore.ToString(); sOtherDscFilter += " and ICN_YEAR = " + item.mYear.ToString(); sOtherDscFilter += " and ICN_DOC = '" + icndocFromRow + "' "; sOtherDscFilter += " and ICN_DOC_TYPE = " + item.mDocType; sOtherDscFilter += " and ICN_ITEM = " + item.mItemOrder; sOtherDscFilter += " and ICN_SUB_ITEM = 0"; sOtherDscFilter += " and MASK_SEQ = " + iMask.ToString(); DataRow[] dataOtherDScRows = tableDesc.Select(sOtherDscFilter); if (dataOtherDScRows.Length > 0) { answer.AnswerCode = 999; answer.AnswerText = Utilities.GetStringValue(dataOtherDScRows[0]["OD_DESC"], ""); } else { answer.AnswerCode = 0; answer.AnswerText = ""; } } itemAttribute.Answer = answer; } if (itemAttribute.Answer.AnswerCode == 999 || itemAttribute.Answer.AnswerCode > 0) { item.Attributes.Add(itemAttribute); } } //Set item attributes int iCategoryMask = dSession.CategoryXML.GetCategoryMask(item.CategoryCode); DescribedMerchandise dmPawnItem = new DescribedMerchandise(iCategoryMask); Item pawnItem = (Item)item; Item.PawnItemMerge(ref pawnItem, dmPawnItem.SelectedPawnItem, true); //Should copy the description, etc. over to the item. PropertyInfo[] fromFields = typeof(Item).GetProperties(); PropertyInfo[] toFields = //typeof(ScrapItem).GetProperties(); item.GetType().GetProperties(); PropertyHandler.SetProperties(fromFields, toFields, pawnItem, item); //Does not merge well. item.Quantity = Utilities.GetIntegerValue(r["QUANTITY"]); if (item is ScrapItem) { //Wait to add scrap items until after merge. ((ScrapItem)item).StoreNumber = storeNumberFromRow; ((ScrapItem)item).TicketNumber = icndocFromRow; } items.Add(item); } return(items); }