// This method gets called by the runtime. Use this method to add services to the container. public void ConfigureServices(IServiceCollection services) { //set password validation services.Configure <IdentityOptions>(options => { options.Password.RequireDigit = false; options.Password.RequiredLength = 8; options.Password.RequireLowercase = false; options.Password.RequireNonAlphanumeric = false; options.Password.RequireUppercase = false; options.Password.RequiredUniqueChars = 0; }); //get app config from database ConfigDA da = new ConfigDA(AppConfig.AppDbConn); var config = da.GetConfig <Config>(AppConfig.AppName); AppConfig.PreSetConfigInMemory(config); // Adds a default in-memory implementation of IDistributedCache. services.AddDistributedMemoryCache(); services.AddSession(options => { options.Cookie.Name = config.CookieName; options.IdleTimeout = TimeSpan.FromSeconds(config.WebSessionIdleTimeout); }); services.AddMvc(); }
public static void Init() { Dictionary <string, string> dic = ConfigDA.List(); client_version_no = dic["client_version_no"]; client_version = int.Parse(dic["client_version"]); }
// This method gets called by the runtime. Use this method to add services to the container. public void ConfigureServices(IServiceCollection services) { //get app config from database ConfigDA da = new ConfigDA(AppConfig.AppDbConn); var config = da.GetConfig <Config>(AppConfig.AppName); AppConfig.PreSetConfigInMemory(config); // Adds a default in-memory implementation of IDistributedCache. services.AddDistributedMemoryCache(); services.AddRouting(options => options.LowercaseUrls = true); services.Configure <Models.PagingOptions>(Configuration.GetSection("DefaultPagingOptions")); services.AddMvc() .AddJsonOptions(opt => { // These should be the defaults, but we can be explicit: opt.SerializerSettings.DateTimeZoneHandling = DateTimeZoneHandling.Utc; opt.SerializerSettings.DateFormatHandling = DateFormatHandling.IsoDateFormat; opt.SerializerSettings.DateParseHandling = DateParseHandling.DateTimeOffset; }); }
private void btnSave_Click(object sender, EventArgs e) { if (files_upgrade.Count == 0) { MessageBox.Show("没有可发布的文件", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning); return; } if (string.IsNullOrEmpty(txt_version_new.Text) || string.IsNullOrEmpty(txt_version_no_new.Text)) { MessageBox.Show("新版本与新版本号不允许为空", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning); return; } if (txt_version_new.Text == txt_version_old.Text || txt_version_no_new.Text == txt_version_no_old.Text) { MessageBox.Show("新旧版本与版本号不允许相同", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning); return; } if (ClientFileDA.Add(files_upgrade, txt_version_new.Text)) { ConfigDA.Update(txt_version_new.Text, txt_version_no_new.Text); LoadConfig(); MessageBox.Show("保存成功!共更新" + files_upgrade.Count + "个文件。", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information); Close(); } else { MessageBox.Show("保存失败!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
public static void RefreshConfig() { ConfigDA da = new ConfigDA(AppConfig.AppDbConn); Config config = da.GetConfig <Config>(AppName); PreSetConfigInMemory(config); }
public FrmMain() { InitializeComponent(); dgvFiles.AutoGenerateColumns = false; Dictionary <string, string> dic = ConfigDA.List(); txt_version_no_old.Text = dic["client_version_no"]; txt_version_old.Text = dic["client_version"]; txt_version_new.Text = DateTime.Now.ToString("yyyyMMdd") + "01"; string dir = ConfigurationManager.AppSettings["ClientDir"]; List <ClientFile> files_old = ClientFileDA.List(); List <ClientFile> files_new = new List <ClientFile>(); GetDirectorFiles(dir, ref files_new); List <ClientFileCompare> files_compare = files_old.Select(f => new ClientFileCompare() { name = f.name, size = f.size, time = f.time, version = f.version }).ToList(); foreach (ClientFile fn in files_new) { fn.name = fn.name.Substring(dir.Length).Replace('\\', '/'); ClientFileCompare fc = files_compare.Find(f => f.name == fn.name); if (fc == null) { files_compare.Add(new ClientFileCompare() { name = fn.name, size_new = fn.size, time_new = fn.time, need_upgrade = "是" }); } else { fc.size_new = fn.size; fc.time_new = fn.time; fc.need_upgrade = fc.time != fc.time_new ? "是" : "否"; } } dgvFiles.DataSource = files_compare.OrderByDescending(f => f.need_upgrade).ToList(); files_upgrade = files_compare.Where(f => f.time != f.time_new).ToList(); btnSave.Text += "\r\n(可发布" + files_upgrade.Count + "个文件)"; }