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);
        }
예제 #2
0
 public void SetProductData(ProductStandardData productData)
 {
     if (productData != null)
     {
         data = productData;
     }
 }
        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);
        }
예제 #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);
            }
        }