示例#1
0
        public static bool ContentTypeChanged(XElement node)
        {
            string filehash = XmlDoc.GetPreCalculatedHash(node);

            if (string.IsNullOrEmpty(filehash))
            {
                return(true);
            }

            XElement aliasElement = node.Element("Info").Element("Alias");

            if (aliasElement == null)
            {
                return(true);
            }

            //var _contentService = ApplicationContext.Current.Services.ContentTypeService;
            var item = _contentService.GetContentType(aliasElement.Value);

            if (item == null) // import because it's new.
            {
                return(true);
            }

            XElement export = item.ExportToXml();
            string   dbMD5  = XmlDoc.CalculateMD5Hash(export);

            // XmlDoc.SaveElement("doctmp", item.Alias, export);

            return(!filehash.Equals(dbMD5));
        }
示例#2
0
        public static bool StylesheetChanges(XmlDocument xDoc)
        {
            XElement node = XElement.Load(new XmlNodeReader(xDoc));

            string filehash = XmlDoc.GetPreCalculatedHash(node);

            if (string.IsNullOrEmpty(filehash))
            {
                return(true);
            }

            XElement name = node.Element("Name");

            if (name == null)
            {
                return(true);
            }

            var item = StyleSheet.GetByName(name.Value);

            if (item == null)
            {
                return(true);
            }

            XmlDocument xmlDoc = helpers.XmlDoc.CreateDoc();

            xmlDoc.AppendChild(item.ToXml(xmlDoc));
            string dbMD5 = XmlDoc.CalculateMD5Hash(xmlDoc);

            return(!filehash.Equals(dbMD5));
        }
示例#3
0
        public static bool TemplateChanged(XElement node)
        {
            string filehash = XmlDoc.GetPreCalculatedHash(node);

            if (string.IsNullOrEmpty(filehash))
            {
                return(true);
            }

            XElement alias = node.Element("Alias");

            if (alias == null)
            {
                return(true);
            }

            //var _fileService = ApplicationContext.Current.Services.FileService;
            var item = _fileService.GetTemplate(alias.Value);

            if (item == null)
            {
                return(true);
            }

            // for a template - we never change the contents - lets just md5 the two
            // properties we care about (and save having to load the thing from disk?

            string values = item.Alias + item.Name;
            string dbMD5  = XmlDoc.CalculateMD5Hash(values);

            return(!filehash.Equals(dbMD5));
        }
示例#4
0
        public static bool DataTypeChanged(XElement node)
        {
            string filehash = XmlDoc.GetPreCalculatedHash(node);

            if (string.IsNullOrEmpty(filehash))
            {
                return(true);
            }

            var dataTypeDefinitionId = new Guid(node.Attribute("Definition").Value);

            XAttribute defId = node.Attribute("Definition");

            if (defId == null)
            {
                return(true);
            }

            //var _dataTypeService = ApplicationContext.Current.Services.DataTypeService;
            var item = _dataTypeService.GetDataTypeDefinitionById(new Guid(defId.Value));

            if (item == null)
            {
                return(true);
            }

            //var packagingService = ApplicationContext.Current.Services.PackagingService;
            XElement export = _packagingService.Export(item, false);
            string   dbMD5  = XmlDoc.CalculateMD5Hash(export);

            // LogHelper.Info<uSync>("File {0} : Guid {1}", () => filehash, () => dbMD5);

            return(!filehash.Equals(dbMD5));
        }
        public static bool TemplateChanged(XElement node)
        {
            var hashProps = new string[] { "Name", "Alias", "Master" };

            string filehash = XmlDoc.CalculateMD5Hash(node, hashProps);

            if (string.IsNullOrEmpty(filehash))
            {
                return(true);
            }

            XElement alias = node.Element("Alias");

            if (alias == null)
            {
                return(true);
            }

            //var _fileService = ApplicationContext.Current.Services.FileService;
            var item = _fileService.GetTemplate(alias.Value);

            if (item == null)
            {
                return(true);
            }

            // for a template - we never change the contents - lets just md5 the two
            var    export = _packagingService.Export(item);
            string dbMD5  = XmlDoc.CalculateMD5Hash(export, hashProps);

            return(!filehash.Equals(dbMD5));
        }
        public static void AddMD5Hash(this XmlDocument node)
        {
            string md5 = XmlDoc.CalculateMD5Hash(node);
            var    n   = node.CreateElement("Hash");

            n.InnerText = md5;
            node.DocumentElement.AppendChild(n);
        }
示例#7
0
        public static bool DataTypeChanged(XElement node)
        {
            string filehash = XmlDoc.GetPreCalculatedHash(node);

            if (string.IsNullOrEmpty(filehash))
            {
                return(true);
            }

            var dataTypeDefinitionId = new Guid(node.Attribute("Definition").Value);

            XAttribute defId = node.Attribute("Definition");

            if (defId == null)
            {
                return(true);
            }

            /*
             * //var _dataTypeService = ApplicationContext.Current.Services.DataTypeService;
             * var item = _dataTypeService.GetDataTypeDefinitionById(new Guid(defId.Value));
             */
            if (_dataTypes == null)
            {
                // speed test, calling data types seems slow,
                // so we load all them at once, then refrence this when doing the compares.
                // this is a little bit faster than calling each one as we go through...
                _dataTypes = new Dictionary <Guid, IDataTypeDefinition>();
                foreach (IDataTypeDefinition dtype in _dataTypeService.GetAllDataTypeDefinitions())
                {
                    _dataTypes.Add(dtype.Key, dtype);
                }
            }

            Guid defGuid = new Guid(defId.Value);

            if (!_dataTypes.ContainsKey(defGuid))
            {
                return(true);
            }

            //var packagingService = ApplicationContext.Current.Services.PackagingService;
            XElement export = _packagingService.Export(_dataTypes[defGuid], false);
            string   dbMD5  = XmlDoc.CalculateMD5Hash(export, true);

            // LogHelper.Info<uSync>("XML File (we just got to hash from) {0}", () => export.ToString());
            // LogHelper.Info<uSync>("File {0} : Guid {1}", () => filehash, () => dbMD5);

            return(!filehash.Equals(dbMD5));
        }
        public static void AddMD5Hash(this XElement node, string values)
        {
            string md5 = XmlDoc.CalculateMD5Hash(values);

            node.Add(new XElement("Hash", md5));
        }
示例#9
0
        public static void AddMD5Hash(this XElement node, Boolean removePreValIds)
        {
            string md5 = XmlDoc.CalculateMD5Hash(node, removePreValIds);

            node.Add(new XElement("Hash", md5));
        }