Пример #1
0
        private ProductDocument GetProductDocument(Sage.Integration.Northwind.Application.Entities.Product.DataSets.Product.ProductsRow productRow, Token lastToken, NorthwindConfig config)
        {
            ProductDocument productDoc;
            string identity;
            bool active;

            identity = productRow.ProductID.ToString();

            // create Product Document
            productDoc = new ProductDocument();
            productDoc.Id = identity;

            if (lastToken.InitRequest)
                productDoc.LogState  = LogState.Created;

            else if (productRow.IsCreateIDNull() || productRow.IsModifyIDNull()
                || productRow.IsCreateUserNull() || productRow.IsModifyUserNull())
                productDoc.LogState = LogState.Created;

            else if ((productRow.CreateID >= lastToken.SequenceNumber) && (productRow.CreateUser != config.CrmUser))
                productDoc.LogState  = LogState.Created;
            else if ((productRow.ModifyID >= lastToken.SequenceNumber) && (productRow.ModifyUser != config.CrmUser))
                productDoc.LogState  = LogState.Updated;

            active = productRow.IsDiscontinuedNull() ? false : !productRow.Discontinued;
            productDoc.active.Value = active ? Constants.DefaultValues.Active : Constants.DefaultValues.NotActive;

            productDoc.code.Value = identity;

            productDoc.name.Value = productRow.IsProductNameNull() ? null : productRow.ProductName;

            productDoc.productfamilyid.Value = productRow.IsCategoryIDNull() ? 0 : productRow.CategoryID;

            productDoc.uomcategory.Value = identity;

            productDoc.instock.Value = productRow.IsUnitsInStockNull() ? 0 : Convert.ToInt32(productRow.UnitsInStock);

            return productDoc;
        }