نظرات مطالب
بررسی ویجت Kendo UI File Upload
با سلام ؛ من یک مشکل در هنگام ثبت فایل در دیتابس دارم که موقع ثبت چند فایل پشت سر هم در هنگام ثبت کوئری ایی که اطلاعات از دیتابیس هنگام ثبت میگیرند درست عمل نمیکنند و فقط بار اول اعمال می‌شوند
public ActionResult EditSave(IEnumerable<HttpPostedFileBase> files, int referid)
       {
           // OASEntities db = new OASEntities();
           // The Name of the Upload component is "files"
           if (files != null)
           {
 
 
               int i =(int)db.letterdatas.Where(x => x.referletid == referid).Max(p => p.seq);
               foreach (var file in files)
               {
                   bool failtestsize = false;
                   if (file.ContentLength > 5096000) failtestsize = true;
                   if (failtestsize) return Content(new Exception("خطا : حجم فایل ارسالی بیش از حد مجاز می‌باشد").Message);
                 //  System.Threading.Thread.Sleep(2000);
                   var xi = db.letterdatas.Where(x => x.referletid == referid).Count();
                   if (xi > 4) return Content(new Exception("خطا : تعداد فایلهای ارسالی بیش از حد مجاز می‌باشد").Message);
 
 
                   i++;
                    
                  
                   var fileName = Path.GetFileName(file.FileName);
 
 
                 
                   byte[] filedata = new byte[file.ContentLength];
                   Stream st = file.InputStream;
                   st.Read(filedata, 0, file.ContentLength);
                   var letterdata = new letterdata
                   {
                       data = filedata,
                       extention = Path.GetExtension(file.FileName),
                       filename = fileName,
                       seq = i,
                       referletid = referid,
                       templetguid = null,
                       fileid = Guid.NewGuid(),
                       userid = db.users.Where(x => x.username == User.Identity.Name).Select(x => x.userid).FirstOrDefault()
 
 
                   };
                   db.letterdatas.Add(letterdata);
                   db.SaveChanges();
                  
               }
               
           }
            
           return Content("");
       }
تو اکشن بالا فایل از kendo upload دریافت و ثبت می‌شه و لی موقعی که چند فایل ارسال میشه دو کوئری زیر درست عمل نمی‌کنند 
int i =(int)db.letterdatas.Where(x => x.referletid == referid).Max(p => p.seq);
var xi = db.letterdatas.Where(x => x.referletid == referid).Count();
یعنی سرعت ثبت بالاتر از حدی که کوئری‌ها اطلاعات رو از db برای هر ثبت فایل بگیرند ضمنا kendo upload به صورت زیر تنظیم شده بدون ارسال همزمان batch غیرفعال است
@(Html.Kendo().Upload()
           .Name("files")
           .ShowFileList(true)
           .Events(x => x.Select("onxselect").Upload("onxupload").Error("o  nxerror"))
         //  .Multiple(false)
         .HtmlAttributes(
       new
       {
           accept =
               ".pdf"
       })
           .Messages(x => x.Select("انتخاب فایل‌های نامه"))
           .Messages(x => x.Remove("حذف فایل"))
            .Messages(x => x.Cancel("لغو فایل"))
           .Messages(x => x.Retry("دوباره"))
             .Messages(x => x.UploadSelectedFiles("در حال ارسال فایلها ..."))
             .Messages(x => x.HeaderStatusUploaded("کلیه فایلها ارسال شد"))
            .Messages(x => x.DropFilesHere("فایل‌ها را به اینجا بکشید"))
           .Async(a => a
               .Save("EditSave", "Lettersdata", new { referid = @ViewBag.referid })
              .Remove("EditRemove", "Lettersdata", new { referid = @ViewBag.referid })
               .AutoUpload(true)
                
              // .Batch(true)
           )
                   .Files(files =>
                   {
                       foreach (var f in @ViewBag.files)
                       {
                           files.Add().Name(f.filename);
 
 
                       }
                   }
                       )
                       )

اشتراک‌ها
کتابخانه animated_alert
Animated alerts are the jQuery plugin based on css3 animation. Using it you can effectively communicate to users the right information. There are 68 animations, multiple color themes and types of messages and detailed documentation. Also you can develop your own themes, because of the efficient organization of the code. The plugin works in all modern browsers and on all devices. 
کتابخانه animated_alert
بازخوردهای پروژه‌ها
خطا هنگام اجرا
Url: C:\Users\Morteza\Downloads\ExplorerPCalV.1.1\Bin\ExplorerPCal.exe 
-> ExplorerPCal, Version=1.1.0.0, Culture=neutral, PublicKeyToken=a55a2614eb2aee77
Caller: ExplorerPCal.App -> appDispatcherUnhandledException
Exception classes:
   System.NullReferenceException
   System.Reflection.TargetInvocationException
   System.Reflection.TargetInvocationException

Exception messages:
   Object reference not set to an instance of an object.
   Exception has been thrown by the target of an invocation.

   Exception has been thrown by the target of an invocation.

Stack Traces:
   at ExplorerPCal.Utils.ConfigSetGet.GetConfigData(String key)
اشتراک‌ها
38 ترابایت داده خصوصی مایکروسافت در حین توسعه‌ی برنامه‌های AI، عمومی شدند!

The leak was discovered on the company's AI GitHub repository and is said to have been inadvertently made public when publishing a bucket of open-source training data, Wiz said. It also included a disk backup of two former employees' workstations containing secrets, keys, passwords, and over 30,000 internal Teams messages. 

38 ترابایت داده خصوصی مایکروسافت در حین توسعه‌ی برنامه‌های AI، عمومی شدند!
اشتراک‌ها
کتابخانه jquery-popdown
What is a popdown? It's a simple dialog that pops down from the top of your browser window once it's loaded HTML in the background. A simple way to load web forms, content, user feedback messages, media and any other in place style content. It's lightweight (4kb) and fast.  Demo
کتابخانه jquery-popdown
نظرات مطالب
غیرمعتبر شدن کوکی‌های برنامه‌های ASP.NET Core هاست شده‌ی در IIS پس از ری‌استارت آن
یک نکته‌ی تکمیلی: پیاده سازی IXmlRepository مایکروسافت برای EF Core

از زمان ارائه‌ی NET Core 2.2.، بسته‌ی نیوگت جدید Microsoft.AspNetCore.DataProtection.EntityFrameworkCore ارائه شده‌است که کار آن دقیقا شبیه به پیاده سازی «یک نکته‌ی تکمیلی: روش ذخیره سازی کلید موقتی تولید شده در بانک اطلاعاتی بجای حافظه‌ی سرور» است که در نظرات فوق ارائه شد.
برای استفاده‌ی از آن، ابتدا بسته‌ی نیوگت آن‌را به برنامه اضافه کنید:
dotnet add package Microsoft.AspNetCore.DataProtection.EntityFrameworkCore

سپس Context ای را که بر اساس اینترفیس IDataProtectionKeyContext آن پیاده سازی شده‌است و دارای DbSet جدید از نوع DataProtectionKey است، تعریف کنید:
    public class MyKeysContext : DbContext, IDataProtectionKeyContext
    {
        // A recommended constructor overload when using EF Core 
        // with dependency injection.
        public MyKeysContext(DbContextOptions<MyKeysContext> options) 
            : base(options) { }

       // This maps to the table that stores keys.
        public DbSet<DataProtectionKey> DataProtectionKeys { get; set; }
    }
که با اجرای مهاجرت‌ها، یک جدول جدید را با سه فیلد زیر، ایجاد می‌کند:
public int Id { get; set; }
public string FriendlyName { get; set; }
public string XmlData { get; set; }

در آخر روش معرفی این Context به سیستم DataProtection به صورت زیر است:
public void ConfigureServices(IServiceCollection services)
{
   // using Microsoft.AspNetCore.DataProtection;
    services.AddDataProtection()
        .PersistKeysToDbContext<MyKeysContext>();
}
به این ترتیب، به صورت خودکار، اطلاعات موقتی کلیدهای رمزنگاری سیستم data-protection در بانک اطلاعاتی ذخیره شده و یا بازیابی می‌شوند.
اشتراک‌ها
انتخاب الگوریتم‌های هش سریع

این هش‌ها برای کارهای امن استفاده نمی‌شوند و صرفا کاربردهایی جهت تولید بانک‌های اطلاعاتی فوق سریع (key/value stores)، سیستم‌ها کش (تولید سریع کلید منحصربفرد) و یا جاهائیکه کارآیی بسیار مهم است، دارند. البته به نظر در حال حاضر xxHash از تمام این‌ها سریعتر است. یک نمونه پیاده سازی xxHash سریع در دات نت.

انتخاب الگوریتم‌های هش سریع
نظرات مطالب
استفاده‌ی گسترده از DateTimeOffset در NET Core.
یک نکته‌ی تکمیلی: تبدیلگرهای DateTimeOffset برای بانک‌های اطلاعاتی که از آن پشتیبانی نمی‌کنند

خود EF Core به همراه تبدیلگرهای توکار زیر برای کار ساده‌تر با DateTimeOffset در بانک اطلاعاتی‌هایی مانند SQLite و یا MySQL است:

DateTimeOffsetToBinaryConverter - DateTimeOffset to binary-encoded 64-bit value (stores it as a long, slight reduction in precision)

DateTimeOffsetToBytesConverter - DateTimeOffset to byte array (stores it as a 12 byte array, 8 bytes for time, 4 bytes for offset. Full precision.)

DateTimeOffsetToStringConverter - DateTimeOffset to string (ISO 8601 string including timezone) 

و برای مثال می‌توان آن‌ها را به صورت زیر و سراسری، به سیستم معرفی کرد:
protected override void OnModelCreating(ModelBuilder builder)
{
    base.OnModelCreating(builder);

    if (Database.ProviderName == "Microsoft.EntityFrameworkCore.Sqlite")
    {
        // SQLite does not have proper support for DateTimeOffset via Entity Framework Core, see the limitations
        // here: https://docs.microsoft.com/en-us/ef/core/providers/sqlite/limitations#query-limitations
        // To work around this, when the Sqlite database provider is used, all model properties of type DateTimeOffset
        // use the DateTimeOffsetToBinaryConverter
        // Based on: https://github.com/aspnet/EntityFrameworkCore/issues/10784#issuecomment-415769754
        // This only supports millisecond precision, but should be sufficient for most use cases.
        foreach (var entityType in builder.Model.GetEntityTypes())
        {
            var properties = entityType.ClrType.GetProperties().Where(p => p.PropertyType == typeof(DateTimeOffset));
            foreach (var property in properties)
            {
                builder
                    .Entity(entityType.Name)
                    .Property(property.Name)
                    .HasConversion(new DateTimeOffsetToBinaryConverter());
            }
        }
    }
}