public async Task <IActionResult> OnGetLogoutAsync() { SenparcTrace.SendCustomLog("����Ա�˳���¼", $"�û�����{base.UserName}"); await _userInfoService.LogoutAsync(); return(RedirectToPage(new { area = "Admin" })); }
public void SendCustomLogTest() { var keyword = Guid.NewGuid().ToString();//随机字符串 SenparcTrace.SendCustomLog("标题", $"添加Log:{keyword}"); Assert.IsTrue(UnitTestHelper.CheckKeywordsExist(LogFilePath, "标题", keyword)); }
public async Task <IActionResult> OnGetLogoutAsync() { SenparcTrace.SendCustomLog("¹ÜÀíÔ±Í˳öµÇ¼", $"Óû§Ãû£º{base.UserName}"); await _userInfoService.Logout(); return(Redirect("/")); }
protected override void OnModelCreating(ModelBuilder modelBuilder) { #region 系统表 //实现 [XncfAutoConfigurationMapping] 特性之后,可以自动执行,无需手动添加 //modelBuilder.ApplyConfiguration(new AdminUserInfoConfigurationMapping()); //modelBuilder.ApplyConfiguration(new FeedbackConfigurationMapping()); #endregion #region 其他动态模块 foreach (var databaseRegister in Senparc.Ncf.XncfBase.Register.XncfDatabaseList) { databaseRegister.OnModelCreating(modelBuilder); } #endregion #region 全局自动注入(请勿改变此命令位置) //注册所有 XncfAutoConfigurationMapping 动态模块 var dt1 = SystemTime.Now; Senparc.Ncf.XncfBase.Register.ApplyAllAutoConfigurationMapping(modelBuilder); SenparcTrace.SendCustomLog("SenparcEntities 数据库实体注入", $"耗时:{SystemTime.DiffTotalMS(dt1)}ms"); #endregion base.OnModelCreating(modelBuilder); }
public IMvcBuilder AuthorizeConfig(IMvcBuilder builder, IHostEnvironment env) { builder.Services .AddAuthentication(CookieAuthenticationDefaults.AuthenticationScheme) .AddCookie(Utils.ConfigurationHelper.SWAGGER_ATUH_COOKIE, options => { if (Utils.ConfigurationHelper.CustsomSwaggerOptions.UseAdminAuth) { options.LoginPath = "/Admin/Login/"; } else { options.LoginPath = $"/{Utils.ConfigurationHelper.CustsomSwaggerOptions.RoutePrefix}/login.html"; } options.Cookie.HttpOnly = false; }); builder.AddRazorPagesOptions(options => { //此处可配置页面权限 }); SenparcTrace.SendCustomLog("Swagger 启动", "完成 Area:Senparc.Xncf.Swagger 注册"); return(builder); }
/// <summary> /// 自动注册所有 Area /// </summary> /// <param name="builder"></param> /// <param name="env"></param> /// <param name="eachRegsiterAction">遍历到每一个 Register 额外的操作</param> /// <returns></returns> public static IMvcBuilder AddNcfAreas(this IMvcBuilder builder, Microsoft.Extensions.Hosting.IHostEnvironment /*IWebHostEnvironment*/ env, Action <IAreaRegister> eachRegsiterAction = null) { AssembleScanHelper.AddAssembleScanItem(assembly => { try { var areaRegisterTypes = assembly.GetTypes() .Where(z => z.GetInterface(nameof(IAreaRegister)) != null) .ToArray(); foreach (var registerType in areaRegisterTypes) { var register = Activator.CreateInstance(registerType, true) as IAreaRegister; if (register != null) { register.AuthorizeConfig(builder, env); //进行注册 eachRegsiterAction?.Invoke(register); //执行额外的操作 } else { SenparcTrace.BaseExceptionLog(new BaseException($"{registerType.Name} 类型没有实现接口 IAreaRegister!")); } } } catch (Exception ex) { SenparcTrace.SendCustomLog("AddNcfAreas() 自动扫描程序集报告(非程序异常):" + assembly.FullName, ex.ToString()); } }, false); return(builder); }
/// <summary> /// 测试日志记录 /// </summary> /// <returns></returns> public IActionResult LogTest() { var logMsg = $"加入到队列,通过 {Request.PathAndQuery()} 访问,{SystemTime.Now.ToString()}"; SenparcTrace.SendCustomLog("日志记录测试", logMsg); return(Content($"记录完成,请到【App_Data/SenparcTraceLog/SenparcTrace-{SystemTime.Now.ToString("yyyyMMdd")}.log】文件下查看记录,记录内容:{logMsg}")); }
protected override void OnModelCreating(ModelBuilder modelBuilder) { #region 系统表 //实现 [XncfAutoConfigurationMapping] 特性之后,可以自动执行,无需手动添加 //modelBuilder.ApplyConfiguration(new AdminUserInfoConfigurationMapping()); //modelBuilder.ApplyConfiguration(new FeedbackConfigurationMapping()); #endregion #region 其他动态模块 foreach (var databaseRegister in XncfRegisterManager.XncfDatabaseList) { Console.WriteLine("SenparcEntities 动态加载:" + databaseRegister.GetType().Name + " | DbContextType:" + databaseRegister.TryGetXncfDatabaseDbContextType.Name); databaseRegister.OnModelCreating(modelBuilder); } #endregion #region 全局自动注入(请勿改变此命令位置) //注册所有 XncfAutoConfigurationMapping 动态模块 var dt1 = SystemTime.Now; Senparc.Ncf.XncfBase.Register.ApplyAllAutoConfigurationMapping(modelBuilder); SenparcTrace.SendCustomLog("SenparcEntities 数据库实体注入", $"耗时:{SystemTime.DiffTotalMS(dt1)}ms"); #endregion //基类中的系统表处理 base.OnModelCreating(modelBuilder); }
};//Admin比较特殊,不需要全部输出 public IMvcBuilder AuthorizeConfig(IMvcBuilder builder, IWebHostEnvironment env) { //鉴权配置 //添加基于Cookie的权限验证:https://docs.microsoft.com/en-us/aspnet/core/security/authentication/cookie?view=aspnetcore-2.1&tabs=aspnetcore2x builder.Services .AddAuthentication(CookieAuthenticationDefaults.AuthenticationScheme) .AddCookie(AdminAuthorizeAttribute.AuthenticationScheme, options => { options.AccessDeniedPath = "/Admin/Forbidden/"; options.LoginPath = "/Admin/Login/"; options.Cookie.HttpOnly = false; }); builder.Services .AddAuthorization(options => { options.AddPolicy("AdminOnly", policy => { policy.RequireClaim("AdminMember"); }); }); builder.AddRazorPagesOptions(options => { options.Conventions.AuthorizePage("/", "AdminOnly"); //必须登录 options.Conventions.AllowAnonymousToPage("/Login"); //允许匿名 //更多:https://docs.microsoft.com/en-us/aspnet/core/security/authorization/razor-pages-authorization?view=aspnetcore-2.2 }); SenparcTrace.SendCustomLog("系统启动", "完成 Area:Admin 注册"); return(builder); }
/// <summary> /// 执行扫描 /// </summary> public static void RunScan() { var dt1 = SystemTime.Now; lock (_scanLock) { //查找所有扩展缓存B var scanTypesCount = 0; var assembiles = AppDomain.CurrentDomain.GetAssemblies(); var toScanItems = ScanAssamblesActions.Where(z => z.ScanFinished == false).ToList(); foreach (var assembly in assembiles) { try { scanTypesCount++; foreach (var scanItem in toScanItems) { scanItem.Run(assembly);//执行扫描过程 } } catch (Exception ex) { SenparcTrace.SendCustomLog("ScanAssambles() 自动扫描程序集报告(非程序异常):" + assembly.FullName, ex.ToString()); } } toScanItems.ForEach(z => z.Finished());//标记结束 var dt2 = SystemTime.Now; SenparcTrace.SendCustomLog("ScanAssambles", $"RegisterAllAreas 用时:{(dt2 - dt1).TotalMilliseconds}ms"); return; } }
internal void Build(IApplicationBuilder app, IXncfRegister register) { var threadRegister = register as IXncfThread; if (threadRegister == null) { return; } var i = 0; //遍历单个 XNCF 内所有线程配置 foreach (var threadInfo in _threadInfoList) { if (threadInfo.Task == null) { continue; } try { i++; //定义线程 Thread thread = new Thread(async() => { SenparcTrace.SendCustomLog("启动线程", $"{register.Name}-{threadInfo.Name}"); await Task.Delay(TimeSpan.FromSeconds(i)); while (true) { try { await threadInfo.Task.Invoke(app, threadInfo); // 建议开发者自己在内部做好线程内的异常处理 } catch (Exception ex) { if (threadInfo.ExceptionHandler != null) { await threadInfo.ExceptionHandler.Invoke(ex); } else { SenparcTrace.BaseExceptionLog(ex); } } finally { //进行延迟 await Task.Delay(threadInfo.IntervalTime); } } }); thread.Name = $"{register.Uid}-{threadInfo.Name ?? Guid.NewGuid().ToString()}"; thread.Start();//启动 Register.ThreadCollection[threadInfo] = thread; } catch (Exception ex) { SenparcTrace.BaseExceptionLog(ex); } } }
private void ChangeFileVersion(PropertyGroup propertyGroup, Action <VersionObject> versionOperate) { try { var version = VersionHelper.GetVersionObject(propertyGroup.Version); versionOperate(version); propertyGroup.Version = version.ToString(); } catch (Exception ex) { //some projects many not have a invalid verion number. SenparcTrace.SendCustomLog("version not changed", ex.Message); } finally { VersionObject version = null; try { version = VersionHelper.GetVersionObject(SelectedFile.Version); } catch { version = new VersionObject(); } txtVersion.Dispatcher.Invoke(() => txtVersion.Text = SelectedFile.Version); txtQualifier.Dispatcher.Invoke(() => txtQualifier.Text = version.QualifierVersion); } }
/// <summary> /// 自动扫描并注册 ApiBind /// </summary> public static void RegisterApiBind() { DateTime dt1 = SystemTime.Now; var cacheStragegy = CacheStrategyFactory.GetObjectCacheStrategyInstance(); using (cacheStragegy.BeginCacheLock("Senparc.NeuChar.Register", "RegisterApiBind")) { if (RegisterApiBindFinished == true) { return; } //查找所有扩展缓存 var scanTypesCount = 0; var assembiles = AppDomain.CurrentDomain.GetAssemblies(); foreach (var assembly in assembiles) { try { scanTypesCount++; var classTypes = assembly.GetTypes() .Where(z => z.Name.EndsWith("api", StringComparison.OrdinalIgnoreCase) || z.Name.EndsWith("apis", StringComparison.OrdinalIgnoreCase)) .ToArray(); foreach (var type in classTypes) { if (/*type.IsAbstract || 静态类会被识别为 IsAbstract*/ !type.IsPublic || !type.IsClass || type.IsEnum) { continue; } var methods = type.GetMethods(BindingFlags.Public | BindingFlags.Static | BindingFlags.InvokeMethod); foreach (var method in methods) { var attrs = method.GetCustomAttributes(typeof(ApiBindAttribute), false); foreach (var attr in attrs) { ApiBindInfoCollection.Instance.Add(method, attr as ApiBindAttribute); } } } } catch (Exception ex) { SenparcTrace.SendCustomLog("RegisterApiBind() 自动扫描程序集报告(非程序异常):" + assembly.FullName, ex.ToString()); } } RegisterApiBindFinished = true; DateTime dt2 = SystemTime.Now; Console.WriteLine($"RegisterApiBind 用时:{(dt2 - dt1).TotalMilliseconds}ms"); } }
public IActionResult BaseCallback(string code, string state, string returnUrl) { try { if (string.IsNullOrEmpty(code)) { return(Content("您拒绝了授权!")); } if (state != HttpContext.Session.GetString("State")) { //这里的state其实是会暴露给客户端的,验证能力很弱,这里只是演示一下, //建议用完之后就清空,将其一次性使用 //实际上可以存任何想传递的数据,比如用户ID,并且需要结合例如下面的Session["OAuthAccessToken"]进行验证 return(Content("验证失败!请从正规途径进入!")); } //通过,用code换取access_token var result = OAuthApi.GetAccessToken(appId, appSecret, code); if (result.errcode != Senparc.Weixin.ReturnCode.请求成功) { return(Content("错误:" + result.errmsg)); } //下面2个数据也可以自己封装成一个类,储存在数据库中(建议结合缓存) //如果可以确保安全,可以将access_token存入用户的cookie中,每一个人的access_token是不一样的 HttpContext.Session.SetString("OAuthAccessTokenStartTime", SystemTime.Now.ToString()); HttpContext.Session.SetString("OAuthAccessToken", result.ToJson()); //因为这里还不确定用户是否关注本微信,所以只能试探性地获取一下 OAuthUserInfo userInfo = null; try { //已关注,可以得到详细信息 userInfo = OAuthApi.GetUserInfo(result.access_token, result.openid); if (!string.IsNullOrEmpty(returnUrl)) { return(Redirect(returnUrl)); } ViewData["ByBase"] = true; return(View("UserInfoCallback", userInfo)); } catch (ErrorJsonResultException ex) { SenparcTrace.SendCustomLog("获取用户讯息失败", ex.ToString()); //未关注,只能授权,无法得到详细信息 //这里的 ex.JsonResult 可能为:"{\"errcode\":40003,\"errmsg\":\"invalid openid\"}" return(Content("用户已授权,授权Token:" + result, "text/html", Encoding.UTF8)); } } catch (Exception ex) { SenparcTrace.SendCustomLog("BaseCallback 发生错误", ex.ToString()); return(Content("发生错误:" + ex.ToString())); } }
/// <summary> /// 发送文本客服消息 /// </summary> /// <param name="accessTokenOrAppId"></param> /// <param name="openId"></param> /// <param name="content"></param> /// <returns></returns> public override async Task <ApiResult> SendText(string accessTokenOrAppId, string openId, string content) { SenparcTrace.SendCustomLog("wxTest-sendText", "openID:" + openId + " || appID:" + accessTokenOrAppId + "|| content:" + content); var result = await AdvancedAPIs.CustomApi.SendTextAsync(accessTokenOrAppId, openId, content); return(new ApiResult((int)result.errcode, result.errmsg, result)); }
/// <summary> /// 发送文本客服消息 /// </summary> /// <param name="accessTokenOrAppId"></param> /// <param name="openId"></param> /// <param name="content"></param> /// <returns></returns> public override ApiResult SendText(string accessTokenOrAppId, string openId, string content) { SenparcTrace.SendCustomLog("wxTest-sendText", "openID:" + openId + " || appID:" + accessTokenOrAppId + "|| content:" + content); var reuslt = CustomApi.SendText(accessTokenOrAppId, openId, content); return(new ApiResult((int)reuslt.errcode, reuslt.errmsg, reuslt)); }
public APMException(string message, string domain, string kindName, string method, Exception inner = null) : base(message, inner, true) { SenparcTrace.SendCustomLog("APM 执行出错", $@"Domain: {domain} KindName: {kindName} Message: {message} Exception: {inner?.ToString()}"); }
public MainWindow() { InitializeComponent(); SenparcTrace.SendCustomLog("System", "Window opened."); txtPath.Text = Environment.CurrentDirectory; Init(); }
public IMvcBuilder AuthorizeConfig(IMvcBuilder builder, IWebHostEnvironment env) { builder.AddRazorPagesOptions(options => { //此处可配置页面权限 }); SenparcTrace.SendCustomLog("系统启动", "完成 Area:MyApp 注册"); return(builder); }
public IMvcBuilder AuthorizeConfig(IMvcBuilder builder, IHostEnvironment env) { builder.AddRazorPagesOptions(options => { //此处可配置页面权限 }); SenparcTrace.SendCustomLog("Message 启动", "完成 Area:WorkShop.Xncf.Message 注册"); return(builder); }
public IMvcBuilder AuthorizeConfig(IMvcBuilder builder, IHostEnvironment env) { builder.AddRazorPagesOptions(options => { //此处可配置页面权限 }); SenparcTrace.SendCustomLog("Template_XncfName 启动", "完成 Area:Template_OrgName.Xncf.Template_XncfName 注册"); return(builder); }
public void OnLogFuncTest() { var onlogCount = 0; SenparcTrace.OnLogFunc = () => onlogCount++; var keyword = Guid.NewGuid().ToString();//随机字符串 SenparcTrace.SendCustomLog("测试OnLogFuncTest", keyword); Assert.IsTrue(UnitTestHelper.CheckKeywordsExist(LogFilePath, keyword)); Assert.AreEqual(1, onlogCount); }
private void RegisterTraceLogAction() { registerTraceLogActionRun = true; SenparcTrace.SendCustomLog("Test系统日志", "Test系统启动");//只在Senparc.Weixin.Config.IsDebug = true的情况下生效 //自定义日志记录回调 SenparcTrace.OnLogFunc = () => { //加入每次触发Log后需要执行的代码 }; }
/// <summary> /// 原生支付 模式一 /// </summary> /// <returns></returns> public ActionResult Native() { try { RequestHandler nativeHandler = new RequestHandler(null); string timeStamp = TenPayV3Util.GetTimestamp(); string nonceStr = TenPayV3Util.GetNoncestr(); //商品Id,用户自行定义 string productId = SystemTime.Now.ToString("yyyyMMddHHmmss"); nativeHandler.SetParameter("appid", TenPayV3Info.AppId); nativeHandler.SetParameter("mch_id", TenPayV3Info.MchId); nativeHandler.SetParameter("time_stamp", timeStamp); nativeHandler.SetParameter("nonce_str", nonceStr); nativeHandler.SetParameter("product_id", productId); string sign = nativeHandler.CreateMd5Sign("key", TenPayV3Info.Key); var url = TenPayOldV3.NativePay(TenPayV3Info.AppId, timeStamp, TenPayV3Info.MchId, nonceStr, productId, sign); BitMatrix bitMatrix; bitMatrix = new MultiFormatWriter().encode(url, BarcodeFormat.QR_CODE, 600, 600); var bw = new ZXing.BarcodeWriterPixelData(); var pixelData = bw.Write(bitMatrix); var bitmap = new System.Drawing.Bitmap(pixelData.Width, pixelData.Height, System.Drawing.Imaging.PixelFormat.Format32bppRgb); var fileStream = new MemoryStream(); var bitmapData = bitmap.LockBits(new System.Drawing.Rectangle(0, 0, pixelData.Width, pixelData.Height), System.Drawing.Imaging.ImageLockMode.WriteOnly, System.Drawing.Imaging.PixelFormat.Format32bppRgb); try { // we assume that the row stride of the bitmap is aligned to 4 byte multiplied by the width of the image System.Runtime.InteropServices.Marshal.Copy(pixelData.Pixels, 0, bitmapData.Scan0, pixelData.Pixels.Length); } finally { bitmap.UnlockBits(bitmapData); } bitmap.Save(_fileStream, System.Drawing.Imaging.ImageFormat.Png); _fileStream.Seek(0, SeekOrigin.Begin); return(File(_fileStream, "image/png")); } catch (Exception ex) { SenparcTrace.SendCustomLog("TenPayV3.Native 执行出错", ex.Message); SenparcTrace.BaseExceptionLog(ex); throw; } }
/// <summary> /// 安装模块 /// </summary> /// <param name="uid">模块 Uid</param> /// <returns></returns> //public async Task<Tuple<PagedList<XncfModule>, string, InstallOrUpdate?>> InstallModuleAsync(string uid) public async Task <(PagedList <XncfModule> XncfModuleList, string scanAndInstallResult, InstallOrUpdate?InstallOrUpdate)> InstallModuleAsync(string uid) { if (uid.IsNullOrEmpty()) { throw new Exception("模块不存在!"); } var xncfRegister = XncfRegisterManager.RegisterList.FirstOrDefault(z => z.Uid == uid); if (xncfRegister == null) { throw new Exception("模块不存在!"); } var xncfModule = await base.GetObjectAsync(z => z.Uid == xncfRegister.Uid && z.Version == xncfRegister.Version).ConfigureAwait(false); if (xncfModule != null) { throw new Exception("相同版本模块已安装,无需重复安装!"); } PagedList <XncfModule> xncfModules = await base.GetObjectListAsync(1, 999, _ => true, _ => _.AddTime, Ncf.Core.Enums.OrderingType.Descending).ConfigureAwait(false); var xncfModuleDtos = xncfModules.Select(z => base.Mapper.Map <CreateOrUpdate_XncfModuleDto>(z)).ToList(); var se = _serviceProvider.GetService(typeof(SystemServiceEntities_SqlServer)); //进行模块扫描 InstallOrUpdate?installOrUpdateValue = null; var result = await Senparc.Ncf.XncfBase.Register.ScanAndInstall(xncfModuleDtos, _serviceProvider, async (register, installOrUpdate) => { installOrUpdateValue = installOrUpdate; //底层系统模块此时还没有设置好初始化的菜单信息,不能设置菜单 if (register.Uid != Senparc.Ncf.Core.Config.SiteConfig.SYSTEM_XNCF_MODULE_SERVICE_UID && register.Uid != Senparc.Ncf.Core.Config.SiteConfig.SYSTEM_XNCF_MODULE_AREAS_ADMIN_UID ) { await InstallMenuAsync(register, installOrUpdate); } }, uid).ConfigureAwait(false); //记录日志 var installOrUpdateMsg = installOrUpdateValue.HasValue ? (installOrUpdateValue.Value == InstallOrUpdate.Install ? "安装" : "更新") : "失败"; SenparcTrace.SendCustomLog($"安装或更新模块({installOrUpdateMsg})", result.ToString()); return(xncfModules, result, installOrUpdateValue); }
public void AddXscfDatabaseModule(IServiceCollection services) { SenparcTrace.SendCustomLog("执行调试", "DatabaseToolkit.AddXscfDatabaseModule"); services.AddScoped <DbConfig>(); services.AddScoped <SetConfig>(); services.AddScoped <SetConfig.SetConfig_Parameters>(); //AutoMap映射 base.AddAutoMapMapping(profile => { profile.CreateMap <SetConfig.SetConfig_Parameters, SetConfig>(); profile.CreateMap <SetConfig.SetConfig_Parameters, DbConfig>(); }); }
/// <summary> /// 设置数据 /// </summary> /// <param name="kindName">统计类别名称</param> /// <param name="value">统计值</param> /// <param name="data">复杂类型数据</param> /// <param name="tempStorage">临时储存信息</param> /// <param name="dateTime">发生时间,默认为当前系统时间</param> /// <returns></returns> public async Task <DataItem> SetAsync(string kindName, double value, object data = null, object tempStorage = null, DateTimeOffset?dateTime = null) { if (!Config.EnableAPM) { return(null);//不启用,不进行记录 } var dataItem = new DataItem() { KindName = kindName, Value = value, Data = data, TempStorage = tempStorage, DateTime = dateTime ?? SystemTime.Now }; MessageQueue.SenparcMessageQueue queue = new MessageQueue.SenparcMessageQueue(); queue.Add($"SenparcAPM-{kindName}-{DateTime.Now.Ticks}", async() => { try { var dt1 = SystemTime.Now; var cacheStragety = Cache.CacheStrategyFactory.GetObjectCacheStrategyInstance(); var finalKey = BuildFinalKey(kindName); //使用同步锁确定写入顺序 using (await cacheStragety.BeginCacheLockAsync("SenparcAPM", finalKey).ConfigureAwait(false)) { var list = await GetDataItemListAsync(kindName).ConfigureAwait(false); list.Add(dataItem); await cacheStragety.SetAsync(finalKey, list, Config.DataExpire, true).ConfigureAwait(false); await RegisterFinalKeyAsync(kindName).ConfigureAwait(false);//注册Key if (SenparcTrace.RecordAPMLog) { SenparcTrace.SendCustomLog($"APM 性能记录 - DataOperation.Set - {_domain}:{kindName}", SystemTime.DiffTotalMS(dt1) + " ms"); } return;// dataItem; } } catch (Exception e) { new APMException(e.Message, _domain, kindName, $"DataOperation.Set - {_domain}:{kindName}"); return;// null; } }); return(dataItem); }
public async Task <IActionResult> OnGetLogoutAsync(string ReturnUrl) { SenparcTrace.SendCustomLog("����Ա�˳���¼", $"�û�����{base.UserName}"); await _userInfoService.LogoutAsync(); if (string.IsNullOrEmpty(ReturnUrl)) { return(RedirectToPage(new { area = "Admin" })); } else { return(LocalRedirect(ReturnUrl.UrlDecode())); } }
public async Task OnGetAsync(string uid) { if (uid.IsNullOrEmpty()) { throw new Exception("模块编号未提供!"); } XscfModule = await _xscfModuleService.GetObjectAsync(z => z.Uid == uid).ConfigureAwait(false); if (XscfModule == null) { throw new Exception("模块未添加!"); } if (!XscfModule.UpdateLog.IsNullOrEmpty()) { XscfModuleUpdateLog = XscfModule.UpdateLog .Split(new[] { "\r", "\n" }, StringSplitOptions.RemoveEmptyEntries) .ToList(); } else { XscfModuleUpdateLog = new List <string>(); } XscfRegister = Senparc.Scf.XscfBase.Register.RegisterList.FirstOrDefault(z => z.Uid == uid); if (XscfRegister == null) { throw new Exception($"模块丢失或未加载({Senparc.Scf.XscfBase.Register.RegisterList.Count})!"); } try { foreach (var functionType in XscfRegister.Functions) { var function = _serviceProvider.GetService(functionType) as FunctionBase;//如:Senparc.Xscf.ChangeNamespace.Functions.ChangeNamespace FunctionParameterInfoCollection[function] = await function.GetFunctionParameterInfoAsync(_serviceProvider, true); } } catch (Exception ex) { SenparcTrace.SendCustomLog("模块读取失败", @$ "模块:{XscfModule.Name} / {XscfModule.MenuName} / {XscfModule.Uid} 请尝试更新此模块后刷新页面!"); MustUpdate = true; } RegisteredThreadInfo = XscfRegister.RegisteredThreadInfo; }
/// <summary> /// 执行微信请求 /// </summary> public override void BuildResponseMessage() { #region NeuChar 执行过程 //var neuralSystem = NeuralSystem.Instance; //var messageHandlerNode = neuralSystem.GetNode("MessageHandlerNode") as MessageHandlerNode; //messageHandlerNode = messageHandlerNode ?? new MessageHandlerNode(); var weixinAppId = this._postModel == null ? "" : this._postModel.AppId; switch (RequestMessage.MsgType) { case RequestMsgType.Text: { //SenparcTrace.SendCustomLog("wxTest-request", RequestMessage.ToJson()); ResponseMessage = CurrentMessageHandlerNode.Execute(RequestMessage, this, weixinAppId) ?? OnTextRequest(RequestMessage as RequestMessageText); //SenparcTrace.SendCustomLog("wxTest-response", ResponseMessage.ToJson()); //SenparcTrace.SendCustomLog("WxOpen RequestMsgType", ResponseMessage.ToJson()); SenparcTrace.SendCustomLog("WXOPEN-TEXT ResponseMessage:", ResponseMessage.ToJson()); } break; case RequestMsgType.Image: { ResponseMessage = CurrentMessageHandlerNode.Execute(RequestMessage, this, weixinAppId) ?? OnImageRequest(RequestMessage as RequestMessageImage); } break; case RequestMsgType.NeuChar: ResponseMessage = OnNeuCharRequestAsync(RequestMessage as RequestMessageNeuChar).GetAwaiter().GetResult(); break; case RequestMsgType.Event: { OnEventRequest(RequestMessage as IRequestMessageEventBase); } break; default: throw new UnknownRequestMsgTypeException("未知的MsgType请求类型", null); } #endregion }