public override void CopyFrom(EntityBase entity)
        {
            base.CopyFrom(entity);
            PhysicalFileInfoData sourceEntity = entity as PhysicalFileInfoData;

            if (sourceEntity != null)
            {
                this.LogicFileID    = sourceEntity.LogicFileID;
                this.Version        = sourceEntity.Version;
                this.FileLength     = sourceEntity.FileLength;
                this.CompressModeID = sourceEntity.CompressModeID;
                this.EncryptModeID  = sourceEntity.EncryptModeID;
                this.StoreModeID    = sourceEntity.StoreModeID;
            }
        }
Exemple #2
0
            internal void Initialize(RemoteStreamContext context)
            {
                __Error.CheckNullReference(context, "context");
                if (context.FileID == Guid.Empty)
                {
                    __Error.InvalidateFileID();
                }
                _context = context;
                _proxy   = CreateServiceProxy(context);
                //Stopwatch w = new Stopwatch();
                //w.Start();
                _itemResult = FileManager.OpenFile(context, _proxy);
                //w.Stop();
                //Console.WriteLine("Open File execute times:" + w.ElapsedMilliseconds);
                //_logicFileInfo = FileManager.GetFileInfo(context.FileID, context.Version);
                if (context.FileMode == FileMode.None)
                {
                    __Error.InvalidateFileMode();
                }

                FileAccess access = context.FileAccess;

                if (FileMode.Truncate == context.FileMode)
                {
                    access = FileAccess.Write;
                }

                LogicFileInfoData logicFileInfo = LogicFileInfo;

                if (logicFileInfo == null)
                {
                    if (context.FileMode == FileMode.Open ||
                        context.FileMode == FileMode.Append ||
                        context.FileMode == FileMode.Truncate)
                    {
                        __Error.NotExistsFileID(context.FileID);
                    }
                }

                if (logicFileInfo != null)
                {
                    if (logicFileInfo.ReadOnly && this._canWrite)
                    {
                        __Error.FileReadOnly(context.FileID);
                    }

                    if (context.FileMode == FileMode.CreateNew)
                    {
                        __Error.ExistsFileID(context.FileID);
                    }
                }

                this._canRead  = (access & FileAccess.Read) != 0;
                this._canWrite = (access & FileAccess.Write) != 0;

                PhysicalFileInfoData physicalFileInfo = this.PhysicalFileInfo;

                if (physicalFileInfo != null)
                {
                    this._fileLength = physicalFileInfo.FileLength;
                }

                if (context.FileMode == FileMode.Append)
                {
                    _origin = _fileLength;
                }
            }