// This method gets called by the runtime. Use this method to configure the HTTP request pipeline. public void Configure(IApplicationBuilder app, IHostingEnvironment env, IOptions <RedisConfigurationFromJson> options) { PrivilegeConfigurationProvider.serviceProvider = app.ApplicationServices; RedisConfiguration.ConnectionString = JsonConfigurationHelper.GetAppSettings(Configuration, options).ConnectionString; RedisConfiguration.DatabaseId = JsonConfigurationHelper.GetAppSettings(Configuration, options).DatabaseId; RedisConfiguration.Password = JsonConfigurationHelper.GetAppSettings(Configuration, options).Password; RedisConfiguration.ServiceName = JsonConfigurationHelper.GetAppSettings(Configuration, options).ServiceName; RedisConfiguration.SyncTimeOut = JsonConfigurationHelper.GetAppSettings(Configuration, options).SyncTimeOut; if (env.IsDevelopment()) { #region Swagger app.UseSwagger(); app.UseSwaggerUI(c => { c.SwaggerEndpoint("/swagger/v1/swagger.json", "ApiHelp V1"); }); #endregion app.UseMiddleware(typeof(RequestLoggingMiddleware)); app.UseMiddleware(typeof(ExceptionHandlerMiddleWare)); } else { app.UseHsts(); #region Swagger app.UseSwagger(); app.UseSwaggerUI(c => { c.SwaggerEndpoint("/swagger/v1/swagger.json", "ApiHelp V1"); }); #endregion app.UseMiddleware(typeof(RequestLoggingMiddleware)); app.UseMiddleware(typeof(ExceptionHandlerMiddleWare)); } app.UseMvc(); }
public SysDbContext CreateDbContext(string[] args) { var builder = new DbContextOptionsBuilder <SysDbContext>(); var connection = JsonConfigurationHelper.GetAppSettings <ConnectionService>("appsettings.json", "ConnectionStrings"); builder.UseSqlServer(connection.SqlConnection); return(new SysDbContext(builder.Options)); }
public JsonResult Index() { var tableConfigList = JsonConfigurationHelper.GetAppSettings <TableConfiguration>(); var tableConfigEntity = tableConfigList.Where(q => q.Name == "WALIUJR_SYS").Select(q => q.ConnectString).FirstOrDefault(); return(Json(tableConfigEntity, JsonRequestBehavior.AllowGet)); }
public async Task <JsonResult> GetToken(string user_name, string password) { return(await Task.Run <JsonResult>(() => { //自定义返回json对象 Json json = new Json(); //1.开始参数验证 if (string.IsNullOrEmpty(user_name)) { json.status = -1; json.msg = "用户名不能为空!"; return Json(json); } if (string.IsNullOrEmpty(password)) { json.status = -1; json.msg = "密码不能为空!"; return Json(json); } //自定义参数模板 List <SearchTemplate> st = new List <SearchTemplate>(); st.Add(new SearchTemplate() { key = "user_name", value = user_name, searchType = EnumBase.SearchType.Eq }); st.Add(new SearchTemplate() { key = "password", value = password, searchType = EnumBase.SearchType.Eq }); var list = _UsersService.GetList(st, null); if (list.Count > 0) { //获取token var tokenconfig = JsonConfigurationHelper.GetAppSettings <TokenConfig>("TokenConfig.json", "TokenConfig"); Token tokenHelper = new Token(); var token = tokenHelper.CreateToken(user_name, password, tokenconfig.Sign); //登录成功,设置用户token _Cache.GetOrCreate(token, entry => { entry.SetSlidingExpiration(TimeSpan.FromSeconds(15 * 60)); //15分钟 return (list[0].id); }); //var result = _Cache.Get(token); json.msg = "登录成功!"; json.data = token; } else { json.status = -1; json.msg = "用户名或密码不正确!"; } return Json(json); })); }
public ConferenceContext CreateDbContext(string[] args) { var builder = new DbContextOptionsBuilder <ConferenceContext>(); //读取Appsettings.json的数据库连接字符串 var connection = JsonConfigurationHelper.GetAppSettings <ConnectionService>("appsettings.json", "ConnectionService"); builder.UseSqlServer(connection.ConnectionSqlService); return(new ConferenceContext(builder.Options)); }
public IEnumerable <string> Get() { var config = JsonConfigurationHelper.GetAppSettings <ManageConfig>("ManageConfig.json", "ManageConfig"); //Users m_user = new Users(); //m_user.user_name = "这是测试哦"; //_UsersService.Save(m_user); var res = _UsersService.Get(1); return(new string[] { res.id.ToString(), res.user_name }); }
public static IDbConnection DapperInstance() { lock (Locker) { if (Connection == null) { var conn = JsonConfigurationHelper.GetAppSettings <ConnectionService>("appsettings.json", "ConnectionService"); Connection = new SqlConnection(conn.ConnectionSqlService); } } return(Connection); }
public async Task <IEnumerable <v_PageImages> > GetPageImagesByPageIdAsync(int pageId) { var list = await _pageDAL.GetDataPageImagesByPageIdAsync(pageId); string ossHost = JsonConfigurationHelper.GetAppSettings("osshost"); foreach (var item in list) { item.ImagePath = ossHost + item.ImagePath; } return(list); }
// This method gets called by the runtime. Use this method to configure the HTTP request pipeline. public void Configure(IApplicationBuilder app, IHostingEnvironment env, IOptions <MultiLanguageChoose> options) { //MultiLaguagePower.languageBind(JsonConfigurationHelper.GetAppSettings<MultiLanguageChoose>("MultiLanguageChoose").DirPath, JsonConfigurationHelper.GetAppSettings<MultiLanguageChoose>("MultiLanguageChoose").Language); MultiLaguagePower.languageBind(JsonConfigurationHelper.GetAppSettings(Configuration, options).DirPath, JsonConfigurationHelper.GetAppSettings(Configuration, options).Language); MultiLanguageConfigurationProvider.ServiceProvider = app.ApplicationServices; if (env.IsDevelopment()) { app.UseDeveloperExceptionPage(); } app.UseMvc(); }
// This method gets called by the runtime. Use this method to configure the HTTP request pipeline. public void Configure(IApplicationBuilder app, IHostingEnvironment env, IOptions <RedisConfigurationFromJson> options) { RedisConfiguration.ConnectionString = JsonConfigurationHelper.GetAppSettings(Configuration, options).ConnectionString; RedisConfiguration.DatabaseId = JsonConfigurationHelper.GetAppSettings(Configuration, options).DatabaseId; RedisConfiguration.Password = JsonConfigurationHelper.GetAppSettings(Configuration, options).Password; RedisConfiguration.ServiceName = JsonConfigurationHelper.GetAppSettings(Configuration, options).ServiceName; RedisConfiguration.SyncTimeOut = JsonConfigurationHelper.GetAppSettings(Configuration, options).SyncTimeOut; if (env.IsDevelopment()) { app.UseDeveloperExceptionPage(); } app.UseMvc(); }
public IDatabase GetDatabase() { #if NETSTANDARD2_0 var tableConfigList = JsonConfigurationHelper.GetAppSettings <List <TableConfiguration> >("TableConfigCollection"); var tableConfigEntity = tableConfigList.Where(q => q.Name == _dbName).Select(q => q.ConnectString).FirstOrDefault(); #elif NET45 var tableConfigList = JsonConfigurationHelper.GetAppSettings <TableConfiguration>(); var tableConfigEntity = tableConfigList.Where(q => q.Name == _dbName).Select(q => q.ConnectString).FirstOrDefault(); #endif var connection = new SqlConnection(tableConfigEntity); var config = new DapperExtensionsConfiguration(typeof(AutoClassMapper <>), new List <Assembly>(), new SqlServerDialect()); var sqlGenerator = new SqlGeneratorImpl(config); return(new Database(connection, sqlGenerator)); }
/// <summary> /// 单例模式获取redis连接实例 /// </summary> public static ConnectionMultiplexer Instance() { //读取appsettings.json的数据库连接字符串 var connection = JsonConfigurationHelper.GetAppSettings <ConnectionService>("appsettings.json", "ConnectionService"); lock (Locker) { if (_instance == null) { _instance = ConnectionMultiplexer.Connect(connection.ConnectionRedis); } } return(_instance); }
public static string GetByDepartmentIdForAdmin(string access_token) { return(string.Format(JsonConfigurationHelper.GetAppSettings("DingTalkSettings", "GetByDepartmentIdForAdmin"), access_token)); }
public BaseRepository() { config = JsonConfigurationHelper.GetAppSettings <ManageConfig>("ManageConfig.json", "ManageConfig"); //config = new ManageConfig() { TibosDB = new DBConfig() { ConnType = "mysql", ConnName="server=47.104.247.70;database=tibos;uid=root;pwd=Root123.;port=3306;Charset=utf8;" } }; }
public ResponseModel Post(string signature, string timestamp, string nonce, [FromBody] RequestModel model) { ResponseModel result = new ResponseModel(); var Ddb = DBHelper.Ddb; var Edb = DBHelper.Edb; _log.Info("请求参数为: signature=" + signature + "×tamp=" + timestamp + "&nonce=" + nonce + ", FromBody=" + JsonHelper.JsonSerializer(model) + "\n"); DingTalkCrypt dingTalkCrypt = new DingTalkCrypt(JsonConfigurationHelper.GetAppSettings("DingTalkSettings", "CallBack_Token"), JsonConfigurationHelper.GetAppSettings("DingTalkSettings", "CallBack_SuiteKey"), JsonConfigurationHelper.GetAppSettings("DingTalkSettings", "CorpID")); int decryptMsgcount = 1; int encryptMsgCount = 1; string dd_result = ""; string sEncryptMsg = ""; string msg_signature = ""; decryptMsgcount = dingTalkCrypt.DecryptMsg(signature, timestamp, nonce, model.encrypt, ref dd_result); result.timeStamp = timestamp; result.nonce = nonce; try { if (decryptMsgcount == 0) { ContactsEventModel contactsEventModel = JsonConvert.DeserializeObject <ContactsEventModel>(dd_result); if (contactsEventModel.EventType == "check_url") { encryptMsgCount = dingTalkCrypt.EncryptMsg("success", timestamp, nonce, ref sEncryptMsg, ref msg_signature); result.encrypt = sEncryptMsg; result.msg_signature = msg_signature; _log.Error(JsonConvert.SerializeObject(result)); return(result); } List <DingTalkCallBackLog> LogList = new List <DingTalkCallBackLog>(); int sqlExeCount = 0; if (contactsEventModel.UserId != null) { foreach (var item in contactsEventModel.UserId) { DingTalkCallBackLog log = new DingTalkCallBackLog { UserId = item, EventType = contactsEventModel.EventType, TimeStamp = contactsEventModel.TimeStamp }; LogList.Add(log); } if (LogList.Count > 0) { sqlExeCount = Ddb.Insertable(LogList).ExecuteCommand(); } if (sqlExeCount > 0) { encryptMsgCount = dingTalkCrypt.EncryptMsg("success", timestamp, nonce, ref sEncryptMsg, ref msg_signature); if (encryptMsgCount == 0) { List <DingTalkCallBackOperation> userList = new List <DingTalkCallBackOperation>(); //日志记录成功后,根据钉钉回调的员工,检查hr中该员工状态为在职的人员 var user = Edb.Queryable <V_EmployeeToDingTalk>().Where(it => contactsEventModel.UserId.Contains(it.UserId) && it.Enabled == 1).ToList(); foreach (var item in user) { //将员工为在职的人员重新添加到钉钉中 bool b = EmployeeForDingTalkBll.AddEmployee(Edb, Ddb, item); DingTalkCallBackOperation DD_User = new DingTalkCallBackOperation(); DD_User.EventType = contactsEventModel.EventType; DD_User.TimeStamp = contactsEventModel.TimeStamp; DD_User.UserId = item.UserId; DD_User.CreateDate = DateTime.Now; if (b) { DD_User.IsOperation = 1; } userList.Add(DD_User); } if (userList.Count > 0) { sqlExeCount = Ddb.Insertable(userList).ExecuteCommand(); _log.Debug(sqlExeCount + "条数据执行成功\n"); } result.encrypt = sEncryptMsg; result.msg_signature = msg_signature; } else { _log.Error("将消息加密,返回加密后字符串失败,返回加密前的参数为:" + dd_result + ",返回编码为: " + encryptMsgCount + "\n"); } } } else { _log.Error("钉钉传递的UserList为空,返回解密前的参数为:" + JsonHelper.JsonSerializer(model) + ",返回编码为: " + decryptMsgcount + "\n"); } } else { _log.Error("回调失败,请求参数为: signature = " + signature + " & timestamp = " + timestamp + " & nonce = " + nonce + ", FromBody = " + JsonHelper.JsonSerializer(model) + "\n错误详情如下:\n"); } } catch (Exception ex) { _log.Error("回调失败,请求参数为: signature = " + signature + " & timestamp = " + timestamp + " & nonce = " + nonce + ", FromBody = " + JsonHelper.JsonSerializer(model) + "\n错误详情如下:\n" + ex); } return(result); }
public string JsonConfig() { var jsonStr = JsonConfigurationHelper.GetAppSettings <ConfigDTO>("ConnectionStrings"); return(jsonStr.ITLifeBlog); }
public BaseRepository() { config = JsonConfigurationHelper.GetAppSettings <ManageConfig>("ManageConfig.json", "ManageConfig"); }
public static string UpdateDepartment(string access_token) { return(string.Format(JsonConfigurationHelper.GetAppSettings("DingTalkSettings", "UpdateDepartment"), access_token)); }
public static string DeleteDepartment(string access_token, string id) { return(string.Format(JsonConfigurationHelper.GetAppSettings("DingTalkSettings", "DeleteDepartment"), access_token, id)); }
public IEnumerable <string> Get() { var config = JsonConfigurationHelper.GetAppSettings <ManageConfig>("ManageConfig.json", "ManageConfig"); return(new string[] { "" }); }
public static string GetUseridByUnionid(string access_token, string unionid) { return(string.Format(JsonConfigurationHelper.GetAppSettings("DingTalkSettings", "GetUseridByUnionid"), access_token, unionid)); }
public static string DeleteEmployee(string access_token, string userid) { return(string.Format(JsonConfigurationHelper.GetAppSettings("DingTalkSettings", "DeleteEmployee"), access_token, userid)); }
public void SqlMasterSlaveConn() { var connection = JsonConfigurationHelper.GetAppSettings <ConnectionService>("appsettings.json", "ConnectionService"); _dbContext.Database.GetDbConnection().ConnectionString = connection.ConnectionSqlServiceTwo; }
public static string GetByDepartmentIdForUserInfoList(string access_token, string department_id) { return(string.Format(JsonConfigurationHelper.GetAppSettings("DingTalkSettings", "GetByDepartmentIdForUserInfoList"), access_token, department_id)); }
public static string BatchDeleteEmployee(string access_token) { return(string.Format(JsonConfigurationHelper.GetAppSettings("DingTalkSettings", "BatchDeleteEmployee"), access_token)); }
public static string GetRegisterCallBack(string access_token) { return(string.Format(JsonConfigurationHelper.GetAppSettings("DingTalkSettings", "RegisterCallBack"), access_token)); }
public JsonResult Get() { var person = JsonConfigurationHelper.GetAppSettings <List <TableConfiguration> >("TableConfigCollection"); return(Json(person)); }