protected void Page_Load(object sender, EventArgs e) { System.Web.HttpResponse response = System.Web.HttpContext.Current.Response; //new HttpResponse(sw); response.Charset = "unicode"; // "unicode"; HttpGet httpGet = new HttpGet(); String ActionID = string.Empty; if (httpGet.GetString("ActionID", ref ActionID)) { try { string actionName = string.Concat("Action", ActionID); string sname = string.Concat("ZyGames.DirCenter.Action." + actionName); object[] args = new object[1]; args[0] = response; BaseStruct obj = (BaseStruct)Activator.CreateInstance(Type.GetType(sname), new object[] { httpGet }); if (obj.ReadUrlElement() && obj.DoAction() && !obj.GetError()) { obj.BuildPacket(); obj.WriteAction(); } else { obj.WriteErrorAction(); return; } } catch (Exception ex) { BaseLog oBaseLog = new BaseLog("DirCenterErrMain"); oBaseLog.SaveLog(ex); } } }
public void Configure(IApplicationBuilder app, IHostingEnvironment env) { app.UseExceptionHandler(error => { error.Use(async(context, next) => { var contextFeature = context.Features.Get <IExceptionHandlerFeature>(); if (contextFeature != null) { BaseLog.SaveLog(contextFeature.Error.Message, "error"); context.Response.ContentType = "application/json;charset=utf-8"; context.Response.StatusCode = 200; var result = new Dictionary <string, object>(); result.Add("success", false); result.Add("msg", contextFeature.Error.Message); await context.Response.WriteAsync(BaseJson.ModelToJson(result)); } }); }); app.UseStaticFiles(); app.UseMiddleware <FastApiHandler>(); app.UseMvc(routes => { routes.MapRoute( name: "default", template: "{action=index}/{id?}"); }); }
/// <summary> /// 数据库sql code first日志 /// </summary> /// <param name="IsOutSql"></param> /// <param name="IsAsyc"></param> /// <param name="sql"></param> /// <param name="dbType"></param> public static void LogSql(bool IsOutSql, string sql, string dbType) { if (IsOutSql) { BaseLog.SaveLog(string.Format("{0}", sql), string.Format("{0}_CodeFirst_Sql", dbType)); } }
protected void Page_Load(object sender, EventArgs e) { BaseLog log = new BaseLog("OfficialService"); try { string result = ""; int gameId; string gameParam = Request["gid"]; if (!string.IsNullOrEmpty(gameParam) && int.TryParse(gameParam, out gameId)) { result = DoComboWrite(gameId); } else { result = "FAILURE"; log.SaveLog("OfficialService param error."); } Response.Write(result); } catch (Exception ex) { Response.Write("FAILURE"); log.SaveLog(ex); } }
/// <summary> /// 是否第一次抽取数据 /// </summary> /// <param name="cmd"></param> /// <param name="type"></param> /// <returns></returns> private static bool IsFirtExtract(DbCommand cmd, string tableName) { var isExists = true; cmd.CommandText = string.Format("select count(0) from {0}", tableName); try { var dr = cmd.ExecuteReader(); while (dr.Read()) { if (dr[0].ToStr().ToInt(0) > 0) { isExists = false; } } dr.Close(); } catch (Exception ex) { BaseLog.SaveLog(ex.ToString() + cmd.CommandText, "IsFirtExtractError"); } return(isExists); }
/// <summary> /// 写入操作日志 /// </summary> /// <param name="log"></param> /// <returns></returns> public int InsertBaseLog(BaseLog log) { Dictionary <string, object> keyValuePairs = log.ToDictionary(); keyValuePairs.Remove("ID"); return(aideIBaseLog.Insert(keyValuePairs)); }
static TestLog() { var manager = LogManager.Default; manager.AutoInitialize(); instance = manager.GetLog(Name); }
/// <summary> /// webapi 宿主类 /// </summary> public static HttpSelfHostServer GetHost(string url) { try { // 配置一个自宿主 http 服务 var HostConfig = new HttpSelfHostConfiguration(new Uri(url)); // 配置 http 服务的路由 HostConfig.Routes.MapHttpRoute( name: "DefaultApi", routeTemplate: "api/{controller}/{id}", defaults: new { id = RouteParameter.Optional } ); var host = new HttpSelfHostServer(HostConfig); host.OpenAsync().Wait(); return(host); } catch (HttpException ex) { BaseLog.SaveLog(ex.ToString(), "WebApiHost_exp.txt"); return(null); } }
/// <summary> /// 获取配置节点 /// </summary> /// <returns></returns> public static MapConfigModel GetConfig(string mapFile = "SqlMap.config") { try { var key = "FastData.Config.SqlMap"; var exeConfig = new ExeConfigurationFileMap(); exeConfig.ExeConfigFilename = string.Format("{0}{1}", AppDomain.CurrentDomain.BaseDirectory, mapFile); var info = new FileInfo(exeConfig.ExeConfigFilename); if (!DbCache.Exists(CacheType.Web, key)) { var temp = getModel(exeConfig, info); DbCache.Set <MapConfigModel>(CacheType.Web, key, temp); return(temp); } else if (DbCache.Get <MapConfigModel>(CacheType.Web, key).LastWrite != info.LastWriteTime) { var temp = getModel(exeConfig, info); DbCache.Set <MapConfigModel>(CacheType.Web, key, temp); return(temp); } else { return(DbCache.Get <MapConfigModel>(CacheType.Web, key)); } } catch (Exception ex) { BaseLog.SaveLog(ex.ToString(), "MapConfig"); return(null); } }
public BaseAction(int ActionID, HttpGet HttpGet) { httpGet = HttpGet; _actionID = ActionID; basePack = new BasePack(); baseLog = new BaseLog(httpGet.param); }
public RssFeedReader( RssFeedSettings feedSettings, BaseLog log) { this.FeedSettings = feedSettings; this.Log = log; }
protected void Page_Load(object sender, EventArgs e) { System.Web.HttpResponse response = System.Web.HttpContext.Current.Response;//new HttpResponse(sw); response.Charset = "unicode";// "unicode"; HttpGet httpGet = new HttpGet(); String ActionID = string.Empty; if (httpGet.GetString("ActionID", ref ActionID)) { try { string actionName = string.Concat("Action", ActionID); string sname = string.Concat("ZyGames.DirCenter.Action." + actionName); object[] args = new object[1]; args[0] = response; BaseStruct obj = (BaseStruct) Activator.CreateInstance(Type.GetType(sname), new object[] { httpGet }); if (obj.ReadUrlElement() && obj.DoAction() && !obj.GetError()) { obj.BuildPacket(); obj.WriteAction(); } else { obj.WriteErrorAction(); return; } } catch (Exception ex) { BaseLog oBaseLog = new BaseLog("DirCenterErrMain"); oBaseLog.SaveLog(ex); } } }
public void Configure(IApplicationBuilder app, IWebHostEnvironment env) { app.UseExceptionHandler(error => { error.Use(async(context, next) => { var contextFeature = context.Features.Get <IExceptionHandlerFeature>(); if (contextFeature != null) { BaseLog.SaveLog(contextFeature.Error.Message, "error"); context.Response.ContentType = "application/json;charset=utf-8"; context.Response.StatusCode = 200; var result = new Dictionary <string, object>(); result.Add("success", false); result.Add("msg", contextFeature.Error.Message); await context.Response.WriteAsync(BaseJson.ModelToJson(result)); } }); }); app.UseStaticFiles(); app.UseRouting(); app.UseEndpoints(endpoints => { endpoints.MapRazorPages(); }); }
/// <summary> /// 系统关机 /// </summary> protected override void OnShutdown() { while (this.CanStop) { BaseLog.SaveLog("系统关机停止服务", "FastEtlService"); } }
public JsonResult remove(int id = 0) { try { BaseLog model = db.BaseLogs.Find(id); if (model != null) { BoolString validation = model.BeforeDelete(db); if (validation.BoolValue) { return(Json(new { Message = validation.StringValue }, JsonRequestBehavior.AllowGet)); } db.BaseLogs.Remove(model); db.SaveChanges(); validation = model.AfterDelete(db); if (validation.BoolValue) { return(Json(new { Message = validation.StringValue }, JsonRequestBehavior.AllowGet)); } return(Json(new { id = model.created, MessageSucess = "That Log deleted successfully." }, JsonRequestBehavior.AllowGet)); } return(Json(new { Message = "This record no longer exists" }, JsonRequestBehavior.AllowGet)); } catch (Exception ex) { return(Json(new { Message = Helper.ModeralException(ex).Replace("@table", "Log") }, JsonRequestBehavior.AllowGet)); } }
public DemoCmpFieldMapping(ICmpConverterMapper mapper, BaseLog logger, CmpHelper cmpHelper, CmpSettings settings) : base(mapper, logger, cmpHelper, settings) { this._mapper = mapper; DemoCmpFieldMapping._settings = settings; this._cmpHelper = cmpHelper; }
/// <summary> /// Returns an exception informing internal error has occurred. /// </summary> /// <param name="description">Error description.</param> /// <param name="log"><see cref="BaseLog"/> instance to log the problem; /// <see langword="null"/> means logging is not necessary.</param> /// <returns>Newly created exception.</returns> public static InvalidOperationException InternalError(string description, BaseLog log) { var exception = new InvalidOperationException(string.Format(Strings.ExInternalError, description)); log.Error(null, null, exception); return(exception); }
public DictionaryItemMessageHandler( DictionaryItemRepository repository, BaseLog logger) { this.repository = repository; this.logger = logger; }
public OverrideDefaultSettings(BaseFactory factory, BaseLog log) { Assert.ArgumentNotNull(factory, "factory"); Assert.ArgumentNotNull(log, "log"); _factory = factory; _log = log; _ds = new Sitecore.Configuration.DefaultSettings(factory, log); }
public SitecoreCacheManager(BaseLog logger, ISitecoreCacheFactory cacheFactory) { this.logger = logger; this.cacheFactory = cacheFactory; this.Caches = new ConcurrentDictionary <string, ICache>(); }
/// <summary> /// 保存日志到文本文件 /// </summary> /// <param name="aUseLog"></param> /// <param name="aExObj"></param> protected void SaveLog(String aUseLog, Exception aExObj) { if (oBaseLog == null) { oBaseLog = new BaseLog("Action" + this.actionId.ToString()); } oBaseLog.SaveLog(aUseLog, aExObj); }
/// <summary> /// 建造基本信息 /// </summary> /// <param name="log">日志</param> /// <param name="context">方法元数据</param> public static void BuildBasicInfo(this BaseLog log, MethodAdviceContext context) { log.Namespace = context.TargetMethod.DeclaringType?.Namespace; log.ClassName = context.TargetMethod.DeclaringType?.Name; log.MethodName = context.TargetMethod.Name; log.MethodType = context.TargetMethod.IsStatic ? "静态" : "实例"; log.IPAddress = GetLocalIPAddress(); }
/// <summary> /// Saves the debu log. /// </summary> /// <param name="aUseLog">A use log.</param> protected void SaveDebuLog(String aUseLog) { if (oBaseLog == null) { oBaseLog = new BaseLog(); } oBaseLog.SaveDebugLog(aUseLog); }
// Constructors public AsyncFutureResult(Func <T> worker, BaseLog logger) { ArgumentValidator.EnsureArgumentNotNull(worker, "worker"); this.logger = logger; task = Task.Run(worker); }
public RedirectSearcher( BaseSettings settings, ITemplateService templateService, BaseLog logger) { this.settings = settings; this.templateService = templateService; this.logger = logger; }
public RedirectSearchDataService( IUrlMapperContext context, BaseSettings settings, BaseLog logger) { this.context = context; this.settings = settings; this.logger = logger; }
public SetCustomIcons( DictionarySettings settings, DictionaryIconSettings iconSettings, BaseLog logger) { this.settings = settings; this.iconSettings = iconSettings; this.logger = logger; }
public DictionaryItemRepository( DictionarySettings settings, IMessageBus <DictionaryMessageBus> messageBus, BaseLog logger) { this.settings = settings; this.messageBus = messageBus; this.logger = logger; }
private void InitLogger() { log = new DelegateLog(LOGLEVEL.INFO, str => { //跨线程调用 listBox1.Invoke(new Action <string>(s => { listBox1.Items.Add(s); }), str); }); }
/// <summary> /// 开始服务 /// </summary> /// <param name="args"></param> protected override void OnStart(string[] args) { BaseLog.SaveLog("启动服务", "FastEtlService"); //定时器 轮循时间 半小时 var timer = new Timer(1000 * 60 * 30); timer.Elapsed += new ElapsedEventHandler(SynData); timer.Enabled = true; timer.AutoReset = true; }
public DictionaryService( DictionaryItemRepository repository, DictionarySettings setting, DictionaryCache cache, BaseLog logger) { this.repository = repository; this.setting = setting; this.cache = cache; this.logger = logger; }