Exemplo n.º 1
0
        /// <summary>
        /// Gets the web dav URL by WebDavTicket.
        /// </summary>
        /// <param name="ticket">The ticket.</param>
        /// <returns></returns>
        public static string GetWebDavUrl(string ticket)
        {
            string       retVal       = string.Empty;
            WebDavTicket webDavTicket = WebDavTicket.Parse(ticket);

            //Попытаемся определить имя файла
            if (String.IsNullOrEmpty(webDavTicket.AbsolutePath.FileName))
            {
                if (webDavTicket.AbsolutePath.StorageType == ObjectTypes.File_FileStorage)
                {
                    FileStorageAbsolutePath fsAbsPath = webDavTicket.AbsolutePath as FileStorageAbsolutePath;
                    if (fsAbsPath != null)
                    {
                        FileStorage fs = new FileStorage();
                        Mediachase.IBN.Business.ControlSystem.FileInfo fileInfo = fs.GetFile(fsAbsPath.UniqueId);
                        if (fileInfo != null)
                        {
                            webDavTicket.AbsolutePath.FileName = fileInfo.Name;
                        }
                    }
                }
                else if (webDavTicket.AbsolutePath.StorageType == ObjectTypes.File_MetaData)
                {
                    MetaDataAbsolutePath mdAbsPath = webDavTicket.AbsolutePath as MetaDataAbsolutePath;
                    if (mdAbsPath != null)
                    {
                        Mediachase.Ibn.Data.Meta.FileInfo fileInfo = new Mediachase.Ibn.Data.Meta.FileInfo(mdAbsPath.FileUID);
                        webDavTicket.AbsolutePath.FileName = fileInfo.Name;
                    }
                }
                else if (webDavTicket.AbsolutePath.StorageType == ObjectTypes.File_MetaDataPlus)
                {
                    MetaDataPlusAbsolutePath mdpAbsPath = webDavTicket.AbsolutePath as MetaDataPlusAbsolutePath;
                    if (mdpAbsPath != null)
                    {
                        Mediachase.MetaDataPlus.MetaObject obj = MetaDataWrapper.LoadMetaObject(mdpAbsPath.MetaObjectId, mdpAbsPath.MetaObjectType);
                        MetaFile mf = obj[mdpAbsPath.MetaFieldName] as MetaFile;
                        if (mf != null)
                        {
                            webDavTicket.AbsolutePath.FileName = mf.Name;
                        }
                    }
                }
                else if (webDavTicket.AbsolutePath.StorageType == ObjectTypes.File_Incident)
                {
                    EmailStorageAbsolutePath emlAbsPath = webDavTicket.AbsolutePath as EmailStorageAbsolutePath;
                    if (emlAbsPath != null)
                    {
                        EMailMessageInfo emlInfo    = EMailMessageInfo.Load(emlAbsPath.EmailMsgId);
                        AttachmentInfo   attachInfo = emlInfo.Attachments[emlAbsPath.EmailAttachmentIndex];
                        webDavTicket.AbsolutePath.FileName = attachInfo.FileName;
                    }
                }
            }

            retVal = GetWebDavUrl(webDavTicket.AbsolutePath, true);


            return(retVal);
        }
Exemplo n.º 2
0
        /// <summary>
        /// Opens the read.
        /// </summary>
        /// <param name="element">The element.</param>
        /// <returns></returns>
        public override System.IO.Stream OpenRead(Mediachase.Net.Wdom.WebDavElementInfo element)
        {
            if (element == null || element is CollectionInfo)
            {
                return(null);
            }

            Mediachase.Ibn.Data.Meta.FileInfo fileInfo = (Mediachase.Ibn.Data.Meta.FileInfo)element.Tag;
            return(fileInfo.OpenRead());
        }
Exemplo n.º 3
0
        /// <summary>
        /// Gets the web dav URL.
        /// </summary>
        /// <param name="fileInfo">The file info.</param>
        /// <param name="withAuthToken">if set to <c>true</c> [with auth token].</param>
        /// <returns></returns>
        public static string GetMetaDataWebDavUrl(Mediachase.Ibn.Data.Meta.FileInfo fileInfo, bool withAuthToken)
        {
            if (fileInfo == null)
            {
                throw new ArgumentNullException("fileInfo");
            }

            MetaDataAbsolutePath absPath = (MetaDataAbsolutePath)WebDavAbsolutePath.CreateInstance(ObjectTypes.File_MetaData);

            absPath.FileUID  = fileInfo.FileUID;
            absPath.FileName = fileInfo.Name;

            return(GetWebDavUrl(absPath, withAuthToken));
        }
Exemplo n.º 4
0
        /// <summary>
        /// Gets the web dav URL.
        /// </summary>
        /// <param name="property">The property.</param>
        /// <returns></returns>
        public static string GetMetaDataWebDavUrl(MetaObjectProperty property, bool withAuthToken)
        {
            if (property == null)
            {
                throw new ArgumentNullException("property");
            }

            Mediachase.Ibn.Data.Meta.FileInfo fileInfo = property.Value as Mediachase.Ibn.Data.Meta.FileInfo;
            if (fileInfo == null)
            {
                throw new ArgumentException("metaproperty " + property.Name + " is not a FileInfo type");
            }

            return(GetMetaDataWebDavUrl(fileInfo, withAuthToken));
        }
Exemplo n.º 5
0
        /// <summary>
        /// Opens the write.
        /// </summary>
        /// <param name="element">The element.</param>
        /// <returns></returns>
        public override System.IO.Stream OpenWrite(Mediachase.Net.Wdom.WebDavElementInfo element, long contentLength)
        {
            if (element == null || element is CollectionInfo)
            {
                return(null);
            }

            Mediachase.Ibn.Data.Meta.FileInfo fileInfo = (Mediachase.Ibn.Data.Meta.FileInfo)element.Tag;
            try
            {
                AutoCommitedTransactedStream tranStream = new AutoCommitedTransactedStream(DataContext.Current.BeginTransaction(), contentLength);
                tranStream.InnerStream = fileInfo.OpenWrite();
                tranStream.SetLength(0);

                return(tranStream);
            }
            catch (Exception)
            {
                throw new HttpException(404, "Not Found");
            }
        }
Exemplo n.º 6
0
        protected override ResourceInfo GetResourceInfo(WebDavTicket ticket)
        {
            MetaDataAbsolutePath metaAbsPath = ticket.AbsolutePath as MetaDataAbsolutePath;

            if (metaAbsPath == null)
            {
                throw new ArgumentException("absPath");
            }

            ResourceInfo retVal = new ResourceInfo();

            Mediachase.Ibn.Data.Meta.FileInfo fileInfo = new Mediachase.Ibn.Data.Meta.FileInfo(metaAbsPath.FileUID);

            retVal.AbsolutePath  = ticket.ToString();
            retVal.Tag           = fileInfo;
            retVal.Name          = fileInfo.Name;
            retVal.ContentType   = ContentTypeResolver.Resolve(Path.GetExtension(fileInfo.Name));
            retVal.ContentLength = fileInfo.Length;
            retVal.ParentName    = "root";
            retVal.Modified      = DateTime.Now;
            retVal.Created       = DateTime.Now;

            return(retVal);
        }
Exemplo n.º 7
0
        /// <summary>
        /// Gets the web dav URL.
        /// </summary>
        /// <param name="fileUID">The file UID.</param>
        /// <param name="withAuthToken">if set to <c>true</c> [with auth token].</param>
        /// <returns></returns>
        public static string GetMetaDataWebDavUrl(Guid fileUID, bool withAuthToken)
        {
            Mediachase.Ibn.Data.Meta.FileInfo fileInfo = new Mediachase.Ibn.Data.Meta.FileInfo(fileUID);

            return(GetMetaDataWebDavUrl(fileInfo, withAuthToken));
        }
Exemplo n.º 8
0
        /// <summary>
        /// Gets the web dav URL by WebDavTicket.
        /// </summary>
        /// <param name="ticket">The ticket.</param>
        /// <returns></returns>
        public static string GetWebDavUrl(string ticket)
        {
            string retVal = string.Empty;
            WebDavTicket webDavTicket = WebDavTicket.Parse(ticket);

            //Попытаемся определить имя файла
            if (String.IsNullOrEmpty(webDavTicket.AbsolutePath.FileName))
            {
                if (webDavTicket.AbsolutePath.StorageType == ObjectTypes.File_FileStorage)
                {
                    FileStorageAbsolutePath fsAbsPath = webDavTicket.AbsolutePath as FileStorageAbsolutePath;
                    if (fsAbsPath != null)
                    {
                        FileStorage fs = new FileStorage();
                        Mediachase.IBN.Business.ControlSystem.FileInfo fileInfo = fs.GetFile(fsAbsPath.UniqueId);
                        if (fileInfo != null)
                        {
                            webDavTicket.AbsolutePath.FileName = fileInfo.Name;
                        }
                    }

                }
                else if (webDavTicket.AbsolutePath.StorageType == ObjectTypes.File_MetaData)
                {
                    MetaDataAbsolutePath mdAbsPath = webDavTicket.AbsolutePath as MetaDataAbsolutePath;
                    if (mdAbsPath != null)
                    {
                        Mediachase.Ibn.Data.Meta.FileInfo fileInfo = new Mediachase.Ibn.Data.Meta.FileInfo(mdAbsPath.FileUID);
                        webDavTicket.AbsolutePath.FileName = fileInfo.Name;
                    }
                }
                else if (webDavTicket.AbsolutePath.StorageType == ObjectTypes.File_MetaDataPlus)
                {
                    MetaDataPlusAbsolutePath mdpAbsPath = webDavTicket.AbsolutePath as MetaDataPlusAbsolutePath;
                    if (mdpAbsPath != null)
                    {
                        Mediachase.MetaDataPlus.MetaObject obj = MetaDataWrapper.LoadMetaObject(mdpAbsPath.MetaObjectId, mdpAbsPath.MetaObjectType);
                        MetaFile mf = obj[mdpAbsPath.MetaFieldName] as MetaFile;
                        if (mf != null)
                        {
                            webDavTicket.AbsolutePath.FileName = mf.Name;
                        }
                    }

                }
                else if (webDavTicket.AbsolutePath.StorageType == ObjectTypes.File_Incident)
                {
                    EmailStorageAbsolutePath emlAbsPath = webDavTicket.AbsolutePath as EmailStorageAbsolutePath;
                    if (emlAbsPath != null)
                    {
                        EMailMessageInfo emlInfo = EMailMessageInfo.Load(emlAbsPath.EmailMsgId);
                        AttachmentInfo attachInfo = emlInfo.Attachments[emlAbsPath.EmailAttachmentIndex];
                        webDavTicket.AbsolutePath.FileName = attachInfo.FileName;
                    }
                }
            }

            retVal = GetWebDavUrl(webDavTicket.AbsolutePath, true);

            return retVal;
        }
Exemplo n.º 9
0
        /// <summary>
        /// Gets the web dav URL.
        /// </summary>
        /// <param name="fileUID">The file UID.</param>
        /// <param name="withAuthToken">if set to <c>true</c> [with auth token].</param>
        /// <returns></returns>
        public static string GetMetaDataWebDavUrl(Guid fileUID, bool withAuthToken)
        {
            Mediachase.Ibn.Data.Meta.FileInfo fileInfo = new Mediachase.Ibn.Data.Meta.FileInfo(fileUID);

            return GetMetaDataWebDavUrl(fileInfo, withAuthToken);
        }
Exemplo n.º 10
0
        protected override ResourceInfo GetResourceInfo(WebDavTicket ticket)
        {
            MetaDataAbsolutePath metaAbsPath = ticket.AbsolutePath as MetaDataAbsolutePath;
            if (metaAbsPath == null)
                throw new ArgumentException("absPath");

            ResourceInfo retVal = new ResourceInfo();

            Mediachase.Ibn.Data.Meta.FileInfo fileInfo = new Mediachase.Ibn.Data.Meta.FileInfo(metaAbsPath.FileUID);

            retVal.AbsolutePath = ticket.ToString();
            retVal.Tag = fileInfo;
            retVal.Name = fileInfo.Name;
            retVal.ContentType = ContentTypeResolver.Resolve(Path.GetExtension(fileInfo.Name));
            retVal.ContentLength = fileInfo.Length;
            retVal.ParentName = "root";
            retVal.Modified = DateTime.Now;
            retVal.Created = DateTime.Now;

            return retVal;
        }