private RecordLockedData Lock(Guid fileID, Guid userID)
        {
            RecordLockedData result = null;
            RecordLockedData data   = new RecordLockedData();

            data.ID           = CombineGuid.NewComboGuid();
            data.FormID       = LogicFileFormID;
            data.FormUniqueID = fileID;
            data.LockUserID   = userID;

            RecordLockedManager.ServiceProxy.SetDataProvider(RecordLockedDataProvider);
            result = RecordLockedManager.Lock(data);
            return(result);
        }
        protected Guid GetLockID(Guid fileID)
        {
            if (fileID != Guid.Empty)
            {
                RecordLockedFetchParameter fetchParam = new RecordLockedFetchParameter();
                fetchParam.FormID       = LogicFileFormID;
                fetchParam.FormUniqueID = fileID;

                RecordLockedManager.ServiceProxy.SetDataProvider(RecordLockedDataProvider);
                RecordLockedDataCollection lockResult = RecordLockedManager.GetRecordLockedInfo(fetchParam);
                if (lockResult != null && lockResult.Count > 0)
                {
                    return(lockResult[0].ID);
                }
            }
            return(Guid.Empty);
        }
        protected WriteFileResultItemData WriteFileItem(WriteFileItemData itemParam, Guid userID, DbTransaction trans)
        {
            WriteFileResultItemData item = new WriteFileResultItemData();

            RecordLockedManager.ServiceProxy.SetDataProvider(RecordLockedDataProvider);
            RecordLockedManager.UpdateLockInfo(itemParam.LockID, DateTime.UtcNow.Add(RecordLocked.DefaultExpireTimeSpan));
            string extendsionName = string.Empty;

            if (!string.IsNullOrEmpty(itemParam.ClientFileName))
            {
                extendsionName = Path.GetExtension(itemParam.ClientFileName);
            }

            long length = FileStorageManager.WriteFile(this.DataProvider, itemParam.PhysicalFileID, extendsionName, itemParam.Position, itemParam.WriteData);

            this.DataProvider.UpdatePhysicalFileLength(itemParam.PhysicalFileID, length, DateTime.UtcNow, userID, trans);
            return(item);
        }
        protected CloseFileResultItemData CloseFileItem(CloseFileItemData itemParam, Guid userID, DbTransaction trans)
        {
            CloseFileResultItemData item = new CloseFileResultItemData();
            Guid lockID = Guid.Empty;

            if (itemParam.LockID != Guid.Empty)
            {
                lockID = itemParam.LockID;
            }
            else if (itemParam.FileID != Guid.Empty)
            {
                lockID = GetLockID(itemParam.FileID);
            }
            if (lockID != Guid.Empty)
            {
                RecordLockedManager.ServiceProxy.SetDataProvider(RecordLockedDataProvider);
                RecordLockedManager.Unlock(lockID);
                //item.Succeed = true;
            }
            return(item);
        }
        protected ReadFileResultItemData ReadFileItem(ReadFileItemData itemParam, Guid userID, DbTransaction trans)
        {
            ReadFileResultItemData    item         = new ReadFileResultItemData();
            IRecordLockedDataProvider dataProvider = RecordLockedDataProvider;

            if (dataProvider != null)
            {
                RecordLockedManager.ServiceProxy.SetDataProvider(dataProvider);
            }
            if (itemParam.LockID != Guid.Empty)
            {
                RecordLockedManager.UpdateLockInfo(itemParam.LockID, DateTime.UtcNow.Add(RecordLocked.DefaultExpireTimeSpan));
            }
            string extendsionName = string.Empty;

            if (!string.IsNullOrEmpty(itemParam.ClientFileName))
            {
                extendsionName = Path.GetExtension(itemParam.ClientFileName);
            }

            item.ReadData = FileStorageManager.ReadFile(this.DataProvider, itemParam.PhysicalFileID, extendsionName, itemParam.Position, itemParam.ReadCount);
            return(item);
        }