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 void Insertfilerestrict(WTF.Resource.Entity.resource_filerestrict objresource_filerestrict) { objresource_filerestrict.RestrictName.CheckIsNull <string>("请输入限制名称", "ResourceLog"); objresource_filerestrict.RestrictCode.CheckIsNull <string>("请输入限制码", "ResourceLog"); this.CurrentEntities.AddToresource_filerestrict(objresource_filerestrict); this.CurrentEntities.SaveChanges(); }
public ResourceInfo SaveResource(string ResourceCode, string RestrictCode, string resourceFileName, Stream objStream) { ResourceCode.CheckIsNull("请设置资源类型编码ResourceCode", LogModuleType.ResourceLog); RestrictCode.CheckIsNull("请设置RestrictCode", LogModuleType.ResourceLog); WTF.Resource.Entity.resource_filerestrict _filerestrict = this.resource_filerestrict.Where("it.RestrictCode='" + RestrictCode + "' and it.resource_fileresource.FileResourceCode='" + ResourceCode + "'", new ObjectParameter[0]).Include("resource_filestoragepath").FirstOrDefault <WTF.Resource.Entity.resource_filerestrict>(); if (_filerestrict == null) { SysAssert.InfoHintAssert("找不到此文件配置"); } return(this.SaveResource(_filerestrict, resourceFileName, objStream)); }
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)); }