Example #1
0
        public static FileInfo DeserializeFile(XmlNode nodeFile, int portalId, int folderId)
        {
            var node = nodeFile.SelectSingleNode("file");

            var newFile = new FileInfo
            {
                UniqueId        = new Guid(XmlUtils.GetNodeValue(node.CreateNavigator(), "uniqueid")),
                VersionGuid     = new Guid(XmlUtils.GetNodeValue(node.CreateNavigator(), "versionguid")),
                PortalId        = portalId,
                FileName        = XmlUtils.GetNodeValue(node.CreateNavigator(), "filename"),
                Folder          = XmlUtils.GetNodeValue(node.CreateNavigator(), "folder"),
                FolderId        = folderId,
                ContentType     = XmlUtils.GetNodeValue(node.CreateNavigator(), "contenttype"),
                Extension       = XmlUtils.GetNodeValue(node.CreateNavigator(), "extension"),
                StorageLocation = XmlUtils.GetNodeValueInt(node, "storagelocation"),
                IsCached        = XmlUtils.GetNodeValueBoolean(node, "iscached", false),
                Size            = XmlUtils.GetNodeValueInt(node, "size", Null.NullInteger),
                Width           = XmlUtils.GetNodeValueInt(node, "width", Null.NullInteger),
                Height          = XmlUtils.GetNodeValueInt(node, "height", Null.NullInteger)
            };

            // create/update file
            var fileCtrl = new FileController();

            var originalFile = fileCtrl.GetFileByUniqueID(newFile.UniqueId);

            if (originalFile == null)
            {
                var folder = FolderManager.Instance.GetFolder(folderId);
                using (var fileContent = FileManager.Instance.GetFileContent(newFile))
                {
                    newFile.FileId = FileManager.Instance.AddFile(folder, newFile.FileName, fileContent, false).FileId;
                }
            }
            else
            {
                newFile.FileId = originalFile.FileId;
            }

            return((FileInfo)FileManager.Instance.UpdateFile(newFile));
        }
Example #2
0
        public static FileInfo DeserializeFile(XmlNode nodeFile, int portalId, int folderId)
        {
            var node = nodeFile.SelectSingleNode("file");
            
            var newFile = new FileInfo
            {
                UniqueId = new Guid(XmlUtils.GetNodeValue(node.CreateNavigator(), "uniqueid")),
                VersionGuid = new Guid(XmlUtils.GetNodeValue(node.CreateNavigator(), "versionguid")),
                PortalId = portalId,
                FileName = XmlUtils.GetNodeValue(node.CreateNavigator(), "filename"),
                Folder = XmlUtils.GetNodeValue(node.CreateNavigator(), "folder"),
                FolderId = folderId,
                ContentType = XmlUtils.GetNodeValue(node.CreateNavigator(), "contenttype"),
                Extension = XmlUtils.GetNodeValue(node.CreateNavigator(), "extension"),
                StorageLocation = XmlUtils.GetNodeValueInt(node, "storagelocation"),
                IsCached = XmlUtils.GetNodeValueBoolean(node, "iscached", false),
                Size = XmlUtils.GetNodeValueInt(node, "size", Null.NullInteger),
                Width = XmlUtils.GetNodeValueInt(node, "width", Null.NullInteger),
                Height = XmlUtils.GetNodeValueInt(node, "height", Null.NullInteger)
            };

            // create/update file
            var fileCtrl = new FileController();

            var originalFile = fileCtrl.GetFileByUniqueID(newFile.UniqueId);

            if (originalFile == null)
            {
                var folder = FolderManager.Instance.GetFolder(folderId);
                using (var fileContent = FileManager.Instance.GetFileContent(newFile))
                {
                    newFile.FileId = FileManager.Instance.AddFile(folder, newFile.FileName, fileContent, false).FileId;
                }
            }
            else
            {
                newFile.FileId = originalFile.FileId;
            }

            return (FileInfo)FileManager.Instance.UpdateFile(newFile);
        }