我想将旧blob添加到列表中,然后遍历它并删除它们.
因此,如果自上次修改blob后已过去7天,我想删除它.Blob得到了一个名为last修改过的属性,但看起来它的类型为bool(?)
以前有人走过这条路吗?
像这样的东西:
CloudBlobContainer container = CloudStorageServices.GetCloudBlobsContainer();
var blobs = container.ListBlobs().OfType<CloudBlockBlob>().Where(b=>b.Properties.LastModified - b.Properties.LastModified.AddDays(7)).TotalHours <= 0);
Run Code Online (Sandbox Code Playgroud)
谢谢!
我正在使用此解决方案下载文件,压缩并发送给用户,(Azure blobs).
这是我到目前为止所提出的:
public void DownloadImages(DownloadImagesModel model)
{
if (ModelState.IsValid && model.ImageIDs != null && model.ImageIDs.Count > 0)
{
var currentUser = _claimService.GetCurrentClaimsIdentity(TimeZoneExtensions.GetCurrentDate());
var images = _fileService.GetImages(currentUser.CompanyID, model.ImageIDs).ToList();
if (images != null && images.Count > 0)
{
string imageContainerURL = _fileService.GetImageContainerURL(currentUser.CompanyID) + currentUser.ImageContainerToken;
using (var zipOutputStream = new ZipOutputStream(Response.OutputStream))
{
zipOutputStream.SetLevel(0); // 0 - store only to 9 - means best compression
Response.BufferOutput = false;
Response.AddHeader("Content-Disposition", "attachment; filename=" + "zipFileName.rar");
Response.ContentType = "application/octet-stream";
foreach (var image in images) …Run Code Online (Sandbox Code Playgroud) 我已经使用 .NET Core 类库通过以下命令成功创建了一个迁移文件: dotnet ef --startup-project ../Project.Web migrations add Init
因为我在不同的层(web 层)中注册了我的 db 上下文,并且有类库,所以我必须将我的启动项目设置为 Project.Web。
创建我的初始迁移后,它看起来像这样:
但现在我想将迁移文件夹移动Project.Data/Migrations到Project.Data/Database/Migrations
我尝试使用 output-dir 参数:
dotnet ef --startup-project ../Project.Web --output-dir Database migrations add Init
Run Code Online (Sandbox Code Playgroud)
但后来我得到:
dotnet : 无法识别的选项“--output-dir”
启动(在不同的项目中,业务层)
public static IServiceCollection InjectBusinessContext(this IServiceCollection services, string connectionString)
{
services.AddEntityFrameworkSqlServer().AddDbContext<ProjectContext>((serviceProvider, options) => options.UseSqlServer(connectionString, b => b.MigrationsAssembly("Database")).UseInternalServiceProvider(serviceProvider));
return services;
}
Run Code Online (Sandbox Code Playgroud)
上下文(数据层)
public class ProjectContext : DbContext
{
public ProjectContext(DbContextOptions<ProjectContext> options) : base(options)
{
}
public DbSet<Account> Account { get; set; } …Run Code Online (Sandbox Code Playgroud) .net entity-framework entity-framework-core .net-core asp.net-core
我在与Aurelia Dialog一起使用异步等待时遇到问题。基本上,我想在关闭对话框时发送请求,当前它给我语法错误:
找不到名称“ await”
如果将请求移到.WhenClosed函数之外,我不会收到任何语法错误,并且可以触发请求。
这就是我在其中一个视图中获取资源字符串的方式:
@MyProject.Resources.ResourceEN.MyResourceStringName
//Gives back mystring in desired language
Run Code Online (Sandbox Code Playgroud)
如果我有一个想要发送的字符串变量怎么办?
@string HelloWorld;
@MyProject.Resources.ResourceEN.HelloWorld
Run Code Online (Sandbox Code Playgroud)
这显然不起作用,因为它查找资源名称“HelloWorld”而不是该字符串变量的内容。
是否有可能为此使用变量?
我想保护我的公共方法不被用户调用.
因为我从ajax脚本调用动作,所以我不能使用任何访问修饰符(私有,受保护等).
此外,[HttpPost]不会阻止用户执行虚假请求.
有人有解决方案吗?
谢谢
asp.net-mvc ×3
c# ×3
azure ×2
.net ×1
.net-core ×1
asp.net ×1
asp.net-core ×1
async-await ×1
asynchronous ×1
aurelia ×1
javascript ×1
resources ×1
typescript ×1