Exemplo n.º 1
0
        /// <summary>
        /// Build Material To Stock Mapping List
        /// </summary>
        /// <param name="pDBRecord"></param>
        /// <param name="pWincashWSAdapterConfig"></param>
        /// <returns></returns>
        internal static materialToStockMapping[] BuildMaterialToStockMappingList(DBRecordInfo pDBRecord, WincashWSAdapterConfig pWincashWSAdapterConfig)
        {
            List <materialToStockMapping> materialToStockMappings = null;

            try
            {
                string sStockMapping = pDBRecord.GetFieldValue <String>(QueryFields.stockMapping);

                if (!sStockMapping.IsValidString())
                {
                    return(null);
                }

                string[] stocksParts = sStockMapping.Split(pWincashWSAdapterConfig.StockMappingMainSplitter);

                foreach (string sStock in stocksParts)
                {
                    try
                    {
                        string[] stockItemParts = sStock.Split(pWincashWSAdapterConfig.StockMappingInnerSplitter);

                        if (stockItemParts != null && stockItemParts.Length == 8)
                        {
                            if (materialToStockMappings == null)
                            {
                                materialToStockMappings = new List <materialToStockMapping>();
                            }

                            materialToStockMappings.Add(new materialToStockMapping()
                            {
                                Item1              = stockItemParts[0],          //stockName
                                Item1ElementName   = Item1ChoiceType7.stockName,
                                isStandard         = stockItemParts[1].ToFlag(), //isStandard
                                masterDataSettings = new masterDataSettings()
                                {
                                    status          = stockItemParts[2].ToStatus(), //status
                                    statusSpecified = true
                                },
                                usageSettings = new stockUsageSettings()
                                {
                                    showSale              = stockItemParts[3].ToFlag(), //showSale
                                    showSaleSpecified     = true,
                                    showReturn            = stockItemParts[4].ToFlag(), //showReturn
                                    showReturnSpecified   = true,
                                    showOrder             = stockItemParts[5].ToFlag(), //showOrder
                                    showOrderSpecified    = true,
                                    showLeaseOut          = stockItemParts[6].ToFlag(), //showLeaseOut
                                    showLeaseOutSpecified = true,
                                    showLeaseIn           = stockItemParts[7].ToFlag(), //showLeaseIn
                                    showLeaseInSpecified  = true
                                }
                            });
                        }
                    }
                    catch (Exception ex)
                    {
                        LogManager.LogException(ex);
                    }
                }
            }
            catch (Exception ex)
            {
                LogManager.LogException(ex);
            }

            return(materialToStockMappings != null?materialToStockMappings.ToArray() : null);
        }
Exemplo n.º 2
0
        /// <summary>
        /// Build Material To Supplier Mapping List
        /// </summary>
        /// <param name="pDBRecord"></param>
        /// <param name="pWincashWSAdapterConfig"></param>
        /// <returns></returns>
        internal static materialToSupplier[] BuildMaterialToSupplierList(DBRecordInfo pDBRecord, WincashWSAdapterConfig pWincashWSAdapterConfig)
        {
            List <materialToSupplier> materialToSupplierMappings = null;

            try
            {
                string supplierName = pDBRecord.GetFieldValue <String>(QueryFields.supplierName);

                if (!supplierName.IsValidString())
                {
                    return(null);
                }

                materialToSupplierMappings = new List <materialToSupplier>();

                // Only one materialToSupplierMappings is considered
                materialToSupplierMappings.Add(new materialToSupplier()
                {
                    Item1            = pDBRecord.GetFieldValue <String>(QueryFields.supplierName), //[supplierID or supplierName]
                    Item1ElementName = Item1ChoiceType6.supplierName,
                    defaultSupplier  = pDBRecord.GetFieldValue <String>(QueryFields.defaultSupplier).ToFlag(),
                    deliveryTime     = pDBRecord.GetFieldValue <String>(QueryFields.deliveryTime),
                    priceSettings    = new supplierPriceSettings()
                    {
                        averageCostPrice = pDBRecord.BuildNonFractionNumber(QueryFields.averageCostPriceValue, QueryFields.averageCostPriceMultiplier),
                        costPrice        = pDBRecord.BuildNonFractionNumber(QueryFields.costPriceValue, QueryFields.costPriceMultiplier),
                        Item             = pDBRecord.GetFieldValue <String>(QueryFields.currencyName), //[currencyID or currencyName]
                        ItemElementName  = ItemChoiceType10.currencyName
                    },
                    quantitySettings = new supplierQuantitySettings()
                    {
                        maximumQuantity    = pDBRecord.BuildNonFractionNumber(QueryFields.maximumQuantityValue, QueryFields.maximumQuantityMultiplier),
                        minimumQuantity    = pDBRecord.BuildNonFractionNumber(QueryFields.minimumQuantityValue, QueryFields.minimumQuantityMultiplier),
                        quantityMultiplier = pDBRecord.BuildNonFractionNumber(QueryFields.quantityMultiplier, QueryFields.quantityMultiplierMultiplier),
                        Item            = pDBRecord.GetFieldValue <String>(QueryFields.unitName), //[unitID or unitName]
                        ItemElementName = ItemChoiceType11.unitName
                    }
                });
            }
            catch (Exception ex)
            {
                LogManager.LogException(ex);
            }

            return(materialToSupplierMappings != null?materialToSupplierMappings.ToArray() : null);
        }
Exemplo n.º 3
0
        /// <summary>
        /// Build Standard Material Object
        /// </summary>
        /// <param name="pDBRecord"></param>
        /// <returns></returns>
        internal static standardMaterial BuildStandardMaterialObject(DBRecordInfo pDBRecord, WincashWSAdapterConfig pWincashWSAdapterConfig)
        {
            standardMaterial material = null;

            try
            {
                if (pDBRecord == null || pDBRecord.Row == null)
                {
                    return(null);
                }

                material = new standardMaterial()
                {
                    materialNumber = pDBRecord.GetFieldValue <String>(QueryFields.materialNumber)
                };

                DateTime modificationStamp = WincashWSAdapterUtilities.ParseModificationStamp(
                    pDBRecord.GetFieldValue <String>(QueryFields.modificationStamp));

                if (modificationStamp != DateTime.MinValue)
                {
                    material.modificationStamp          = modificationStamp;
                    material.modificationStampSpecified = true;
                }

                if (!material.materialNumber.IsValidString())
                {
                    return(null);
                }

                #region Master Data Settings

                material.masterDataSettings = new masterDataSettings()
                {
                    status          = pDBRecord.GetFieldValue <String>(QueryFields.status).ToStatus(),
                    statusSpecified = true
                };

                #endregion

                #region Inheritance Settings

                material.inheritanceSettings = new inheritanceSettings()
                {
                    Item            = pDBRecord.GetFieldValue <String>(QueryFields.treeID), // [shopName or treeID]
                    ItemElementName = ItemChoiceType.treeID
                };

                #endregion

                #region General Settings

                // Material Name Translations
                List <translation> _materialNameTranslations = new List <translation>();
                _materialNameTranslations.Add(new translation()
                {
                    translatedLanguage = "EN",
                    translatedText     = pDBRecord.GetFieldValue <String>(QueryFields.materialName)
                });
                List <translation> _materialName2Translations = new List <translation>();
                _materialName2Translations.Add(new translation()
                {
                    translatedLanguage = "EN",
                    translatedText     = pDBRecord.GetFieldValue <String>(QueryFields.materialName2)
                });

                material.generalSettings = new generalSettings()
                {
                    materialName              = pDBRecord.GetFieldValue <String>(QueryFields.materialName),
                    materialNameTranslations  = _materialNameTranslations.ToArray(),
                    materialName2             = pDBRecord.GetFieldValue <String>(QueryFields.materialName2),
                    materialName2Translations = _materialName2Translations.ToArray(),
                    Item                   = pDBRecord.GetFieldValue <String>(QueryFields.goodsGroupName),
                    ItemElementName        = ItemChoiceType3.goodsGroupName,
                    Item1                  = pDBRecord.GetFieldValue <String>(QueryFields.materialGroupName),
                    Item1ElementName       = Item1ChoiceType2.materialGroupName,
                    Item2                  = pDBRecord.GetFieldValue <String>(QueryFields.unitName),
                    Item2ElementName       = Item2ChoiceType.unitName,
                    supplierMaterialNumber = pDBRecord.GetFieldValue <String>(QueryFields.supplierMaterialNumber)
                };

                #endregion

                #region Price Settings

                material.priceSettings = new priceSettings()
                {
                    price                              = pDBRecord.BuildNonFractionNumber(QueryFields.price, QueryFields.priceMultiplier),
                    Item                               = pDBRecord.GetFieldValue <String>(QueryFields.currencyName), // [currencyID or currencyName]
                    ItemElementName                    = ItemChoiceType4.currencyName,
                    Item1                              = pDBRecord.GetFieldValue <String>(QueryFields.taxNumber),    // [taxID or taxNumber]
                    Item1ElementName                   = Item1ChoiceType9.taxNumber,
                    denyPriceOverwriting               = pDBRecord.GetFieldValue <String>(QueryFields.denyPriceOverwriting).ToFlag(),
                    denyPriceOverwritingSpecified      = true,
                    denyReduction                      = pDBRecord.GetFieldValue <String>(QueryFields.denyReduction).ToFlag(),
                    denyReductionSpecified             = true,
                    allowNegativeReducedPrice          = pDBRecord.GetFieldValue <String>(QueryFields.allowNegativeReducedPrice).ToFlag(),
                    allowNegativeReducedPriceSpecified = true,
                    maximumPrice                       = pDBRecord.BuildNonFractionNumber(QueryFields.maximumPriceValue, QueryFields.maximumPriceMultiplier),
                    minimumPrice                       = pDBRecord.BuildNonFractionNumber(QueryFields.minimumPriceValue, QueryFields.minimumPriceMultiplier),
                    turnoverRelevancy                  = pDBRecord.BuildNonFractionNumber(QueryFields.turnoverRelevancyValue, QueryFields.turnoverRelevancyMultiplier),
                    priceListsAvailable                = pDBRecord.GetFieldValue <String>(QueryFields.priceListsAvailable).ToFlag(),
                    priceListsAvailableSpecified       = true
                };

                #endregion

                #region Serial Settings

                List <serialNumberDefinition> _serialNumberDefinitions = new List <serialNumberDefinition>();
                _serialNumberDefinitions.Add(new serialNumberDefinition()
                {
                    serialLength        = pDBRecord.GetFieldValue <String>(QueryFields.serialLength),
                    serialType          = pDBRecord.GetFieldValue <String>(QueryFields.serialType).ToSerialType(),
                    serialTypeSpecified = true
                });

                material.serialSettings = new serialSettings()
                {
                    forceSerial                = pDBRecord.GetFieldValue <String>(QueryFields.forceSerial).ToFlag(),
                    forceSerialSpecified       = true,
                    serialPoolTracked          = pDBRecord.GetFieldValue <String>(QueryFields.serialPoolTracked).ToFlag(),
                    serialPoolTrackedSpecified = true,
                    serialNumberDefinitions    = _serialNumberDefinitions.ToArray()
                };

                #endregion

                #region Inventory Handling

                material.inventoryHandling = new inventoryHandling()
                {
                    inventoryAssignments = WincashWSAdapterUtilities.BuildMaterialToStockMappingList(pDBRecord, pWincashWSAdapterConfig),
                    supplierAssignments  = WincashWSAdapterUtilities.BuildMaterialToSupplierList(pDBRecord, pWincashWSAdapterConfig),
                    valuationPrice       = pDBRecord.BuildNonFractionNumber(QueryFields.valuationPriceValue, QueryFields.valuationPriceMultiplier),
                    // Flags
                    stockControl                       = pDBRecord.GetFieldValue <String>(QueryFields.stockControl).ToFlag(),
                    stockControlSpecified              = true,
                    denyAutomaticOrder                 = pDBRecord.GetFieldValue <String>(QueryFields.denyAutomaticOrder).ToFlag(),
                    denyAutomaticOrderSpecified        = true,
                    denyNegativeStockQuantity          = pDBRecord.GetFieldValue <String>(QueryFields.denyNegativeStockQuantity).ToFlag(),
                    denyNegativeStockQuantitySpecified = true
                };

                #endregion

                #region Extended Settings

                List <translation> _materialDescriptionTranslations = new List <translation>();
                _materialDescriptionTranslations.Add(new translation()
                {
                    translatedLanguage = "EN",
                    translatedText     = pDBRecord.GetFieldValue <String>(QueryFields.materialDescription)
                });

                material.extendedSettings = new extendedSettings()
                {
                    usageSettings = new usageSettings()
                    {
                        allowQuantityOverwriting          = pDBRecord.GetFieldValue <String>(QueryFields.allowQuantityOverwriting).ToFlag(),
                        allowQuantityOverwritingSpecified = true,
                        rejectionReason                   = pDBRecord.GetFieldValue <String>(QueryFields.rejectionReason).ToFlag(),
                        rejectionReasonSpecified          = true,
                        isUseUserItemRestriction          = pDBRecord.GetFieldValue <String>(QueryFields.isUseUserItemRestriction).ToFlag(),
                        isUseUserItemRestrictionSpecified = true
                    },
                    extendedMaterialDescription = new extendedMaterialDescription()
                    {
                        materialDescription             = pDBRecord.GetFieldValue <String>(QueryFields.materialDescription),
                        materialDescriptionTranslations = _materialDescriptionTranslations.ToArray(),
                        hyperlink       = pDBRecord.GetFieldValue <String>(QueryFields.hyperlink),
                        materialPicture = pDBRecord.GetFieldValue <String>(QueryFields.materialPicture)
                    },
                    leaseSettings = new leaseSettings()
                    {
                        denyLeaseExchange          = pDBRecord.GetFieldValue <String>(QueryFields.denyLeaseExchange).ToFlag(),
                        denyLeaseExchangeSpecified = true
                    },
                    reservationSettings = new reservationSettings()
                    {
                        denyReservation          = pDBRecord.GetFieldValue <String>(QueryFields.denyReservation).ToFlag(),
                        denyReservationSpecified = true
                    }
                };

                #endregion
            }
            catch (Exception ex)
            {
                LogManager.LogException(ex);
            }

            return(material);
        }