Ejemplo n.º 1
0
        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);
                }
            }
        }
Ejemplo n.º 2
0
        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?}");
            });
        }
Ejemplo n.º 3
0
 /// <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));
     }
 }
Ejemplo n.º 4
0
 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);
     }
 }
Ejemplo n.º 5
0
    /// <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);
    }
Ejemplo n.º 6
0
        /// <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));
        }
Ejemplo n.º 7
0
        static TestLog()
        {
            var manager = LogManager.Default;

            manager.AutoInitialize();
            instance = manager.GetLog(Name);
        }
Ejemplo n.º 8
0
        /// <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);
            }
        }
Ejemplo n.º 9
0
        /// <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);
            }
        }
Ejemplo n.º 10
0
 public BaseAction(int ActionID, HttpGet HttpGet)
 {
     httpGet   = HttpGet;
     _actionID = ActionID;
     basePack  = new BasePack();
     baseLog   = new BaseLog(httpGet.param);
 }
Ejemplo n.º 11
0
        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);
            }
        }
Ejemplo n.º 12
0
 public RssFeedReader(
     RssFeedSettings feedSettings,
     BaseLog log)
 {
     this.FeedSettings = feedSettings;
     this.Log          = log;
 }
Ejemplo n.º 13
0
        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);
                }
            }
        }
Ejemplo n.º 14
0
        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();
            });
        }
Ejemplo n.º 15
0
 /// <summary>
 /// 系统关机
 /// </summary>
 protected override void OnShutdown()
 {
     while (this.CanStop)
     {
         BaseLog.SaveLog("系统关机停止服务", "FastEtlService");
     }
 }
Ejemplo n.º 16
0
 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));
     }
 }
Ejemplo n.º 17
0
 public DemoCmpFieldMapping(ICmpConverterMapper mapper, BaseLog logger, CmpHelper cmpHelper,
                            CmpSettings settings) : base(mapper, logger, cmpHelper, settings)
 {
     this._mapper = mapper;
     DemoCmpFieldMapping._settings = settings;
     this._cmpHelper = cmpHelper;
 }
Ejemplo n.º 18
0
        /// <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>();
        }
Ejemplo n.º 22
0
 /// <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);
 }
Ejemplo n.º 23
0
 /// <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();
 }
Ejemplo n.º 24
0
 /// <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);
 }
Ejemplo n.º 25
0
        // Constructors

        public AsyncFutureResult(Func <T> worker, BaseLog logger)
        {
            ArgumentValidator.EnsureArgumentNotNull(worker, "worker");

            this.logger = logger;

            task = Task.Run(worker);
        }
Ejemplo n.º 26
0
 public RedirectSearcher(
     BaseSettings settings,
     ITemplateService templateService,
     BaseLog logger)
 {
     this.settings        = settings;
     this.templateService = templateService;
     this.logger          = logger;
 }
Ejemplo n.º 27
0
 public RedirectSearchDataService(
     IUrlMapperContext context,
     BaseSettings settings,
     BaseLog logger)
 {
     this.context  = context;
     this.settings = settings;
     this.logger   = logger;
 }
Ejemplo n.º 28
0
 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;
 }
Ejemplo n.º 30
0
 private void InitLogger()
 {
     log = new DelegateLog(LOGLEVEL.INFO, str =>
     {
         //跨线程调用
         listBox1.Invoke(new Action <string>(s =>
         {
             listBox1.Items.Add(s);
         }), str);
     });
 }
Ejemplo n.º 31
0
        /// <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;
        }
Ejemplo n.º 32
0
 public DictionaryService(
     DictionaryItemRepository repository,
     DictionarySettings setting,
     DictionaryCache cache,
     BaseLog logger)
 {
     this.repository = repository;
     this.setting    = setting;
     this.cache      = cache;
     this.logger     = logger;
 }