Exemplo n.º 1
0
        public static void Parse(XDocument document, string password)
        {
            var keys = document.Descendants(Utility.Format2012Header).Descendants().Where(x => x.Name == Utility.Format2012Element);

            if (keys.Count() > 0)
            {
                foreach (var productKey in keys)
                {
                    string productName = Utility.GetAttributeValue(productKey.Attribute("Name"), string.Empty);
                    foreach (var key in productKey.Elements("Key"))
                    {
                        var productTable = new ProductKey();
                        var newKey       = new {
                            Name        = productName,
                            KeyType     = Utility.GetAttributeValue(key.Attribute("Type"), string.Empty),
                            Key         = Security.Encrypt(Utility.GetElementValue(key, string.Empty), password),
                            ClaimedDate = DateTime.Parse(Utility.ReformatDate(Utility.GetAttributeValue(key.Attribute("ClaimeDate"), "1/1/1900"), '/', '-'))
                        };

                        productTable.Insert(newKey);
                    }
                }
            }
            return;
        }
Exemplo n.º 2
0
        public static void Parse(XDocument document, string password)
        {
            var keys = document.Descendants(Utility.Format2008Header).Descendants().Where(x => x.Name == Utility.Format2008Element);

            if (keys.Count() > 0)
            {
                foreach (var key in keys)
                {
                    var productTable = new ProductKey();
                    var productKey   = new {
                        Name        = Utility.GetAttributeValue(key.Attribute("Name"), string.Empty),
                        KeyType     = Utility.GetAttributeValue(key.Attribute("Key_Type"), string.Empty),
                        Key         = Security.Encrypt(Utility.GetAttributeValue(key.Attribute("Key"), string.Empty), password),
                        ClaimedDate = DateTime.Parse(Utility.GetAttributeValue(key.Attribute("Date_Key_Claimed"), "1900-01-01"))
                    };

                    productTable.Insert(productKey);
                }
            }
            return;
        }