예제 #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
        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);
        }