public static User Login(string email, string password, out string tokenSession) { User u; tokenSession = string.Empty; using (var db = new AuthenticateDbContext(_connectionString)) { u = db.Users.Where(i => i.Username.Equals(email, StringComparison.OrdinalIgnoreCase) && i.Password.Equals(password, StringComparison.OrdinalIgnoreCase)).FirstOrDefault(); } if (u == null) { return(null); } tokenSession = $"{Guid.NewGuid()}_{email.GetHashCode()}_{DateTime.Now.GetHashCode()}"; using (var db = new AuthenticateDbContext(_connectionString)) { u.TokenSession = tokenSession; db.SaveChanges(); } RedisServices.Set <User>(tokenSession, u, new TimeSpan(0, EpireAfterMinutes, 0)); return(u); }
static void Main(string[] args) { RedisServices.Init("127.0.0.1", null, string.Empty); CommandsAndEventsRegisterEngine.AutoRegister(); EngineeCommandWorkerQueue.Start(); EngineeEventWorkerQueue.Start(); while (true) { var cmd = Console.ReadLine(); switch (cmd.ToLower()) { case "quit": _stop = true; Environment.Exit(0); break; case "stop": _stop = true; break; case "start": _stop = false; MessiveSendCmd(); break; } } }
// This method gets called by the runtime. Use this method to configure the HTTP request pipeline. public void Configure(IApplicationBuilder app, IWebHostEnvironment env, RedisServices redisService) { if (env.IsDevelopment()) { app.UseDeveloperExceptionPage(); } else { app.UseExceptionHandler("/Home/Error"); // The default HSTS value is 30 days. You may want to change this for production scenarios, see https://aka.ms/aspnetcore-hsts. app.UseHsts(); } app.UseHttpsRedirection(); app.UseStaticFiles(); app.UseRouting(); app.UseAuthorization(); //uygulama ayaga kalktýgý zaman direkt connect metoduna gidicek. redisService.Connect(); app.UseEndpoints(endpoints => { endpoints.MapControllerRoute( name: "default", pattern: "{controller=Home}/{action=Index}/{id?}"); }); }
private static void Run() { var redishost = ConfigurationManagerExtensions.GetConnectionString("RedisConnectionString"); RedisServices.Init(redishost, null, string.Empty); CommandsAndEventsRegisterEngine.AutoRegister(); EngineeCommandWorkerQueue.Start(); EngineeEventWorkerQueue.Start(); var cmd = (Console.ReadLine() ?? string.Empty).ToLower().Trim(); while (!cmd.Equals("quit")) { switch (cmd) { case "quit": _stop = true; break; case "stop": _stop = true; break; case "start": _stop = false; MessiveSendCmd(null); break; case "pubsub": CommandEventSender.Send(new SampleEventCreated() { PublishedEventId = Guid.NewGuid(), SampleVersion = DateTime.Now.ToString(), Version = 0 }); break; case "pubsubmad": _stop = false; MessiveSendCmd(() => { CommandEventSender.Send(new SampleEventCreated() { PublishedEventId = Guid.NewGuid(), SampleVersion = DateTime.Now.ToString(), Version = 0 }); }); break; } cmd = (Console.ReadLine() ?? string.Empty).ToLower().Trim(); } Console.Read(); }
static void Main(string[] args) { RedisServices.Init("127.0.0.1", null, string.Empty); CommandsAndEventsRegisterEngine.AutoRegisterForHandlers(); Guid sampleId = Guid.NewGuid(); CommandPublisher.Instance.Send(new CreateSample(sampleId, "Version.1.0", "{}")); CommandPublisher.Instance.Send(new ChangeVersionOfSample(sampleId, "Version.2.0")); }
// This method gets called by the runtime. Use this method to add services to the container. public void ConfigureServices(IServiceCollection services) { services.AddControllers().AddNewtonsoftJson(opt => { opt.SerializerSettings.ReferenceLoopHandling = Newtonsoft.Json.ReferenceLoopHandling.Ignore; }); services.AddControllers(); MySqlServices.ConfigureServices(services, Configuration); RedisServices.ConfigureServices(services, Configuration); CasoUsoServices.ConfigureServices(services); }
// This method gets called by the runtime. Use this method to add services to the container. public void ConfigureServices(IServiceCollection services) { services.AddMvc().SetCompatibilityVersion(CompatibilityVersion.Version_2_1); RedisServices.Init("127.0.0.1", null, string.Empty); CommandsAndEventsRegisterEngine.AutoRegister(); EngineeCommandWorkerQueue.Start(); EngineeEventWorkerQueue.Start(); services.AddSwagger(); }
private static void Server_OnClientAttendance(RequestData arg1, System.Collections.Generic.List <AttLogInfo> arg2) { var redisHost = ConfigurationManager.AppSettings["ATTENDANCE_RedisHost"]; var redisPort = int.Parse(ConfigurationManager.AppSettings["ATTENDANCE_RedisPort"]); var redisPwd = ConfigurationManager.AppSettings["ATTENDANCE_RedisPwd"]; var redisNotiDb = int.Parse(ConfigurationManager.AppSettings["ATTENDANCE_RedisDb"]); string queueName = ConfigurationManager.AppSettings["ATTENDANCE_RedisQueue"]; RedisServices redis = new RedisServices().Init(redisHost, redisPort, redisPwd, redisNotiDb); redis.TryEnqueue(queueName, JsonConvert.SerializeObject(new { request = arg1, data = arg2 })); }
// This method gets called by the runtime. Use this method to add services to the container. public void ConfigureServices(IServiceCollection services) { services.AddCors(); services.AddMvc(option => { // option.Filters.Add(new IotHubAuthorizeAttribute()); }).SetCompatibilityVersion(CompatibilityVersion.Version_2_1); //RedisServices.Init("172.16.10.166", null, string.Empty); var redishost = ConfigurationManagerExtensions.GetConnectionString("RedisConnectionString"); RedisServices.Init(redishost, null, string.Empty); CommandsAndEventsRegisterEngine.AutoRegister(); EngineeCommandWorkerQueue.Start(); EngineeEventWorkerQueue.Start(); services.AddSwagger(); }
public ListTypeController(RedisServices redisService) { _redisService = redisService; db = _redisService.GetDb(1); }
public StringTypeController(RedisServices redisService) { _redisService = redisService; db = _redisService.GetDb(0); }
public SortedSetTypeController(RedisServices redisService) { _redisService = redisService; db = _redisService.GetDb(3); }
public static bool IsValidToken(string tokenSession) { var u = RedisServices.Get <User>(tokenSession); return(u != null); }