Пример #1
0
        public Stream ReadRecordingFile(int id)
        {
            try
            {
                WebRecordingFileInfo info = GetRecordingFileInfo(id);

                // read it as a regular file
                if (info.Exists && info.IsLocalFile && !info.OnNetworkDrive && File.Exists(info.Path))
                {
                    return(new FileStream(info.Path, FileMode.Open, FileAccess.Read));
                }

                // try to load it from a network drive
                if (info.Exists && info.IsLocalFile && info.OnNetworkDrive)
                {
                    using (var context = NetworkContextFactory.Create())
                        return(new FileStream(context.RewritePath(info.Path), FileMode.Open, FileAccess.Read));
                }

                // failed
                Log.Warn("No method to read file for recording {0} with path {1}", id, info.Path);
                WCFUtil.SetResponseCode(System.Net.HttpStatusCode.NotFound);
                return(Stream.Null);
            }
            catch (Exception ex)
            {
                Log.Warn(String.Format("Failed to read file for recording {0}", id), ex);
                WCFUtil.SetResponseCode(System.Net.HttpStatusCode.InternalServerError);
                return(Stream.Null);
            }
        }
Пример #2
0
 public INetworkContext CreateNetworkContext()
 {
     return(NetworkContextFactory.Create(NeedsImpersonation));
 }