예제 #1
0
        private LogicFileInfoData UpdateFile(OpenFileItemData itemParam, LogicFileInfoData logicFileInfo, long fileLength, Guid userID, DbTransaction trans)
        {
            LogicFileInfoData result     = logicFileInfo;
            UpdateMode        updateMode = itemParam.UpdateMode;
            FileMode          mode       = itemParam.FileMode;
            long length = 0;

            if (updateMode == UpdateMode.None)
            {
                updateMode = UpdateMode.Override;
            }
            if (updateMode == UpdateMode.NewVersion)
            {
                PhysicalFileInfoData oldFileData = logicFileInfo.PhysicalFileInfos[logicFileInfo.PhysicalFileInfos.Count - 1];
                Guid physcicalFileID             = CombineGuid.NewComboGuid();
                switch (mode)
                {
                case FileMode.Truncate:
                case FileMode.Create:
                    FileStorageManager.SetFileLength(this.DataProvider, physcicalFileID, result.LogicFileExt, 0);
                    break;

                default:
                    length = FileStorageManager.CopyFile(this.DataProvider, oldFileData.ID, physcicalFileID, logicFileInfo.LogicFileExt);
                    break;
                }
                PhysicalFileInfoData fileData = new PhysicalFileInfoData();
                fileData.ID          = physcicalFileID;
                fileData.LogicFileID = result.ID;
                fileData.FileLength  = length;
                fileData.Version     = GetFileVersion(logicFileInfo, trans);
                fileData.StoreModeID = FileStorageManager.GetCurrentStoreModeID(this.DataProvider);
                this.DataProvider.CreatePhysicalFileInfo(fileData, trans);
                result.PhysicalFileInfos.Add(fileData);
                result.LatestPhysicalFileID = physcicalFileID;
                this.DataProvider.UpdateFileInfo(logicFileInfo, trans);
            }
            else if (updateMode == UpdateMode.Override)
            {
                switch (mode)
                {
                case FileMode.Truncate:
                case FileMode.Create:
                    FileStorageManager.SetFileLength(this.DataProvider, logicFileInfo.LatestPhysicalFileID, result.LogicFileExt, 0);
                    break;
                }
            }
            return(result);
        }
예제 #2
0
        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);
        }
예제 #3
0
        public static IFileStorageProvider CreateFileStorageProvider(IFileStorageProviderDataProvider dataProvider, ConfigSettingData configData, Guid physicalFileID, string extendsionName)
        {
            IFileStorageProvider provider = null;

            if (configData == null)
            {
                configData = FileStorageManager.GetConfigSetting(dataProvider, physicalFileID);
            }
            if (configData != null && configData.FileStorage != null)
            {
                provider = ObjectFactory.CreateObject(configData.FileStorage.Provider) as IFileStorageProvider;
                if (provider != null)
                {
                    provider.Initialize(configData, physicalFileID, extendsionName);
                }
            }
            return(provider);
        }
예제 #4
0
        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);
        }
예제 #5
0
        private LogicFileInfoData CreateNewFile(OpenFileItemData itemParam, Guid userID, DbTransaction trans)
        {
            LogicFileInfoData result = new LogicFileInfoData();
            Guid physcicalFileID     = CombineGuid.NewComboGuid();

            if (itemParam.FileID != Guid.Empty)
            {
                result.ID = itemParam.FileID;
            }
            else
            {
                result.ID = CombineGuid.NewComboGuid();
            }
            if (!string.IsNullOrEmpty(itemParam.ClientFileName))
            {
                result.LogicFileName = Path.GetFileName(itemParam.ClientFileName);
                result.LogicFileExt  = Path.GetExtension(itemParam.ClientFileName);
            }
            result.LogicFileStatus      = LogicFileStatus.Normal;
            result.IsReadOnly           = false;
            result.LatestPhysicalFileID = physcicalFileID;
            result.CurrentUserID        = userID;
            this.DataProvider.CreateFileInfo(result, trans);

            PhysicalFileInfoData fileData = new PhysicalFileInfoData();

            fileData.ID          = physcicalFileID;
            fileData.LogicFileID = result.ID;
            fileData.FileLength  = 0;
            fileData.Version     = 1;
            fileData.StoreModeID = FileStorageManager.GetCurrentStoreModeID(this.DataProvider);
            this.DataProvider.CreatePhysicalFileInfo(fileData, trans);
            result.PhysicalFileInfos.Add(fileData);
            FileStorageManager.CreateNewFile(this.DataProvider, physcicalFileID, result.LogicFileExt);
            return(result);
        }