public OpenStreamCommand(string key, StreamModes mode, string group, string subgroup, DateTime absolute, TimeSpan sliding, CacheDependency dependency, Runtime.CacheItemPriority priority, int methodOverload) { base.name = "OpenStreamCommand"; _openStreamCommand = new Alachisoft.NCache.Common.Protobuf.OpenStreamCommand(); _openStreamCommand.key = key; _openStreamCommand.streamMode = (int)mode; _openStreamCommand.group = group; _openStreamCommand.subGroup = subgroup; _methodOverlaod = methodOverload; if (absolute != Alachisoft.NCache.Web.Caching.Cache.NoAbsoluteExpiration) { _openStreamCommand.absoluteExpiration = absolute.Ticks; } if (sliding != Alachisoft.NCache.Web.Caching.Cache.NoSlidingExpiration) { _openStreamCommand.slidingExpiration = sliding.Ticks; } _openStreamCommand.priority = (int)priority; _openStreamCommand.requestId = base.RequestId; if (dependency != null) { _openStreamCommand.dependency = Alachisoft.NCache.Common.Util.DependencyHelper.GetProtoBufDependency(dependency); } }
public void Send(TcpCommunication connection) { RelativePaths(); con = connection; mode = StreamModes.Write; stream = connection.Stream; var w = connection.writer; System.Diagnostics.Debugger.Log(1, "", " "); long position = 0; foreach (var file in EnumerateFiles()) { if (!string.IsNullOrEmpty(file.Name)) { w.Write(file.Name); var comp = NeedsCompression(connection, file.Name); w.Write(comp); w.Write((Int64)file.Content.Length); Stream writer; if (comp) { writer = new DeflateStream(stream, CompressionLevel.Fastest, true); } else { writer = stream; } file.Content.CopyTo(writer, pos => Progress(((double)(position + pos)) / TotalSize)); position += file.Content.Length; } } w.Write(""); }
/// <summary>Downloads a file from the remote server.</summary> /// <param name="RemoteFile">Specifies the remote file to download.</param> /// <param name="LocalFile">Specifies the local file to download to.</param> /// <param name="StreamMode">Specifies the transfer type.</param> /// <param name="FileMode">Specifies the file mode.</param> /// <param name="AppendFrom">Specifies where to append from.</param> /// <returns>Returns True if the request was successful, False otherwise.</returns> public bool DownloadFile(string RemoteFile, string LocalFile, StreamModes StreamMode, DataConnection.FileModes FileMode, long AppendFrom) { SendCommand("TYPE " + Convert.ToChar(StreamMode)); if (!CreateDataSocket(LocalFile, FileMode, DataConnection.StreamDirections.Download, AppendFrom)) { OnCommandCompleted(); return(false); } if (!passiveTransfers) { IPEndPoint MyEndPoint = dataSocket.GetLocalEndPoint; SendCommand("PORT " + MyEndPoint.Address.ToString().Replace(".", ",") + "," + ((int)Math.Floor(MyEndPoint.Port / 256)).ToString() + "," + (MyEndPoint.Port % 256).ToString()); } if (FileMode == DataConnection.FileModes.Append && AppendFrom > 0) { SendCommand("REST " + AppendFrom.ToString()); } SendCommand("RETR " + RemoteFile); if (lastResponseType != 4 && lastResponseType != 5) { try { dataSocket.ReceiveFromSocket(); } catch { dataSocket.Close(); WaitForResponse(); OnCommandCompleted(); return(false); } WaitForResponse(); } dataSocket.Close(); OnCommandCompleted(); return(true); }
public void Deserialize(CompactReader reader) { _key = reader.ReadObject() as string; _mode = (StreamModes)reader.ReadInt16(); _group = reader.ReadObject() as string; _subGroup = reader.ReadObject() as string; _expHint = reader.ReadObject() as ExpirationHint; _evictionHint = reader.ReadObject() as EvictionHint; _lockHandle = reader.ReadObject() as string; _operationContext = reader.ReadObject() as OperationContext; }
public OpenStreamOperation(string key, string lockHandle, StreamModes mode, string group, string subGroup, ExpirationHint expHint, EvictionHint evHint, OperationContext operationContext) { _key = key; _group = group; _subGroup = subGroup; _expHint = expHint; _evictionHint = evHint; _mode = mode; _lockHandle = lockHandle; _operationContext = operationContext; }
public override bool OpenStream(string key, string lockHandle, StreamModes mode, string group, string subGroup, ExpirationHint hint, EvictionHint evictinHint, OperationContext operationContext) { try { base.Sync.AcquireWriterLock(-1); return(this.InternalCache.OpenStream(key, lockHandle, mode, group, subGroup, hint, evictinHint, operationContext)); } finally { base.Sync.ReleaseWriterLock(); } }
public override bool OpenStream(string key, string lockHandle, StreamModes mode, string group, string subGroup, ExpirationHint hint, EvictionHint evictinHint, OperationContext operationContext) { object[] keyDependencyTable = CacheHelper.GetKeyDependencyTable(hint); if ((keyDependencyTable != null) && (mode == StreamModes.Write)) { Hashtable hashtable = this.Contains(keyDependencyTable, operationContext); if (!hashtable.ContainsKey("items-found")) { throw new OperationFailedException("One of the dependency keys does not exist."); } if (hashtable["items-found"] == null) { throw new OperationFailedException("One of the dependency keys does not exist."); } if (((ArrayList)hashtable["items-found"]).Count != keyDependencyTable.Length) { throw new OperationFailedException("One of the dependency keys does not exist."); } } bool flag = this.Internal.OpenStream(key, lockHandle, mode, group, subGroup, hint, evictinHint, operationContext); if ((flag && (mode == StreamModes.Write)) && (keyDependencyTable != null)) { Hashtable table = new Hashtable(); for (int i = 0; i < keyDependencyTable.Length; i++) { if (table[keyDependencyTable[i]] == null) { table.Add(keyDependencyTable[i], new ArrayList()); } ((ArrayList)table[keyDependencyTable[i]]).Add(key); } this.Internal.AddDependencyKeyList(table, operationContext); } return(flag); }
public virtual bool OpenStream(string key, string lockHandle, StreamModes mode, string group, string subGroup, ExpirationHint hint, EvictionHint evictinHint, OperationContext operationContext) { return(false); }
/// <summary>Uploads a file to the remote server.</summary> /// <param name="LocalFile">Specifies the local file to upload.</param> /// <param name="RemoteFile">Specifies the remote file to upload to.</param> /// <param name="StreamMode">Specifies the transfer type.</param> /// <returns>Returns True if the request was successful, False otherwise.</returns> public bool UploadFile(string LocalFile, string RemoteFile, StreamModes StreamMode) { return(UploadFile(LocalFile, RemoteFile, StreamMode, DataConnection.FileModes.Overwrite, 0)); }
public virtual string OpenStream(string key, StreamModes mode, string group, string subGroup, DateTime absExpiration, TimeSpan slidingExpiration, CacheDependency dependency, CacheItemPriority priority) { return(null); }