public ResourceInfo SaveResource(WTF.Resource.Entity.resource_filerestrict objresource_filerestrict, string resourceFileName, Stream objStream) { SysAssert.CheckCondition(objresource_filerestrict == null, "传入的资源配置不存在", LogModuleType.ResourceLog); SysAssert.CheckCondition((objStream == null) || (objStream.Length == 0L), "资源流为空", LogModuleType.ResourceLog); string fileResourceCode = objresource_filerestrict.resource_fileresource.FileResourceCode; DateTime now = DateTime.Now; string resourceVerID = Guid.NewGuid().ToString(); WTF.Resource.Entity.resource_filestoragepath _filestoragepath = objresource_filerestrict.resource_filestoragepath; string resourceGUIDFileName = resourceVerID + Path.GetExtension(resourceFileName); string randomSwitchString = _filestoragepath.VirtualName.GetRandomSwitchString(); string pathFormatValue = WTF.Resource.ResourceHelper.GetResourcePathFormatValue(now, resourceVerID, objresource_filerestrict.PathFormatCodeType); string resourcePath = WTF.Resource.ResourceHelper.GetResourceURL(randomSwitchString, (AccessModeCodeType)objresource_filerestrict.AccessModeCodeType, fileResourceCode, pathFormatValue, resourceGUIDFileName, resourceFileName, resourceVerID); string fileNamePath = WTF.Resource.ResourceHelper.GetresourceFullFileNamePath(_filestoragepath.StoragePath, (AccessModeCodeType)objresource_filerestrict.AccessModeCodeType, fileResourceCode, pathFormatValue, resourceGUIDFileName, resourceFileName, true); string str8 = WTF.Resource.ResourceHelper.GetDirectoryPath((AccessModeCodeType)objresource_filerestrict.AccessModeCodeType, fileResourceCode, pathFormatValue, resourceGUIDFileName, resourceFileName); byte[] bytes = new BinaryReader(objStream).ReadBytes((int)objStream.Length); string str9 = ""; if (objresource_filerestrict.IsMd5 == 1) { str9 = bytes.MD5Encrypt(); } bytes.CreateFile(fileNamePath, true); if (objStream != null) { objStream.Close(); } return(new ResourceInfo(Guid.Empty.ToString(), resourceVerID, 0, resourcePath, fileNamePath, resourceFileName) { Md5Value = str9 }); }
public ResourceInfo SaveResource(WTF.Resource.Entity.resource_filerestrict objresource_filerestrict, HttpPostedFile objPostedFile) { string fileName = Path.GetFileName(objPostedFile.FileName); int contentLength = objPostedFile.ContentLength; string contentType = objPostedFile.ContentType; SysAssert.CheckCondition(objresource_filerestrict == null, "传入的资源配置不存在", LogModuleType.ResourceLog); string fileResourceCode = objresource_filerestrict.resource_fileresource.FileResourceCode; DateTime now = DateTime.Now; string resourceVerID = Guid.NewGuid().ToString(); WTF.Resource.Entity.resource_filestoragepath _filestoragepath = objresource_filerestrict.resource_filestoragepath; string resourceGUIDFileName = resourceVerID + Path.GetExtension(fileName); string pathFormatValue = WTF.Resource.ResourceHelper.GetResourcePathFormatValue(now, resourceVerID, objresource_filerestrict.PathFormatCodeType); string resourcePath = WTF.Resource.ResourceHelper.GetResourceURL(_filestoragepath.VirtualName, (AccessModeCodeType)objresource_filerestrict.AccessModeCodeType, fileResourceCode, pathFormatValue, resourceGUIDFileName, fileName, resourceVerID); string str8 = WTF.Resource.ResourceHelper.GetresourceFullFileNamePath(_filestoragepath.StoragePath, (AccessModeCodeType)objresource_filerestrict.AccessModeCodeType, fileResourceCode, pathFormatValue, resourceGUIDFileName, fileName, true); string str9 = WTF.Resource.ResourceHelper.GetDirectoryPath((AccessModeCodeType)objresource_filerestrict.AccessModeCodeType, fileResourceCode, pathFormatValue, resourceGUIDFileName, fileName); str8.CreateFileDirectory(); objPostedFile.SaveAs(str8); return(new ResourceInfo(Guid.Empty.ToString(), resourceVerID, 0, resourcePath, str8, fileName)); }
public void Insertfilestoragepath(WTF.Resource.Entity.resource_filestoragepath objresource_filestoragepath) { objresource_filestoragepath.StoragePathName.CheckIsNull <string>("请输入存储名称", "ResourceLog"); this.CurrentEntities.AddToresource_filestoragepath(objresource_filestoragepath); this.CurrentEntities.SaveChanges(); }