Пример #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 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));
        }
Пример #3
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));
        }
Пример #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));
        }
Пример #5
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));
        }