Ejemplo n.º 1
0
        public static bool SaveProductStandardData(ProductStandardData product, string path)
        {
            string fileName = Path.Combine(path, ProductDataFilename);

            if (Directory.Exists(path))
            {
                try
                {
                    XmlSerializer serializer = new XmlSerializer(typeof(ProductStandardData));

                    using (StreamWriter writer = new StreamWriter(fileName))
                    {
                        serializer.Serialize(writer, product);
                        writer.Close();
                    }

                    return(true);
                }
                catch
                {
                    return(false);
                }
            }
            return(false);
        }
Ejemplo n.º 2
0
 public void SetProductData(ProductStandardData productData)
 {
     if (productData != null)
     {
         data = productData;
     }
 }
Ejemplo n.º 3
0
        public static ProductStandardData GetProductStandardData(string path)
        {
            string fileName = Path.Combine(path, ProductDataFilename);

            if (File.Exists(fileName))
            {
                try
                {
                    XmlSerializer       serializer = new XmlSerializer(typeof(ProductStandardData));
                    ProductStandardData product    = null;

                    using (FileStream fileStream = new FileStream(fileName, FileMode.Open, FileAccess.Read))
                    {
                        product = (ProductStandardData)serializer.Deserialize(fileStream);
                        fileStream.Close();
                    }

                    return(product);
                }
                catch
                {
                    return(null);
                }
            }
            return(null);
        }
Ejemplo n.º 4
0
        public ProductStandard(Product product)
        {
            // Set all default values for all fields
            versions   = new VersionWrapperList();
            data       = new ProductStandardData();
            Parameters = new Parameters();

            if (product != null)
            {
                // Set product info
                Company     = product.Company;
                ProductName = product.ProductName;
                ProductType = product.ProductType;
                ProductId   = product.ProductId;
                Parameters.AddRange(product.Parameters);
            }
        }