public BatchJob() { InitializeComponent(); log4net.Config.XmlConfigurator.Configure(); log = log4net.LogManager.GetLogger("Log.BatchJob"); this.ServiceName = "BatchJob"; }
public Log4NetImp(string log4ConfigFileFullPath,string log4ConfigLoggerName) { _log4ConfigFileFullPath = log4ConfigFileFullPath; _log4ConfigLoggerName = log4ConfigLoggerName; //Log4Net--初始化 if (!File.Exists(_log4ConfigFileFullPath)) { throw new Exception(string.Format( "Log4Net配置信息文件没有找到!检查配置节点{{ConfigInfo_NewMyCat:Log4NetConfigFileName}}是否正确。{0}FilePath:{1}", System.Environment.NewLine, _log4ConfigFileFullPath)); } // var logCfg = new FileInfo(this._log4ConfigFileFullPath); XmlConfigurator.ConfigureAndWatch(logCfg); // if (string.IsNullOrWhiteSpace(log4ConfigLoggerName)) { throw new Exception(string.Format("在项目配置文件中检查配置节点{{ConfigInfo_NewMyCat:Log4ConfigLoggerName}}不能为空。")); } // var repository = log4net.LogManager.GetRepository(); if (repository.GetLogger(_log4ConfigLoggerName) == null) { throw new Exception(string.Format("在log4net日志配置文件({0})中检查配置节点<logger name=\"{1}\" additivity=\"false\">不存在。", log4ConfigFileFullPath,log4ConfigLoggerName)); } _logger = log4net.LogManager.GetLogger(_log4ConfigLoggerName); }
public Log4netLogger(Type type) { //_innerLogger = log4net.LogManager.GetLogger(type); log4net.ILog[] loggers = log4net.LogManager.GetCurrentLoggers(); _innerLogger = log4net.LogManager.GetLogger("Logging"); log4net.Config.DOMConfigurator.Configure(); }
public Log4NetLog(ILog4NetLog log) { if (log == null) throw new ArgumentNullException("log"); this.log = log; }
public MemcachedAccessTokenProvider(IMemcachedClient memcachedClient, string cookieName, bool useSecureCookie) { _memcachedClient = memcachedClient; _cookieName = cookieName; _useSecureCookie = useSecureCookie; _logger = log4net.LogManager.GetLogger(this.GetType()); }
/* * Constructor for Google Maps API utilities */ public GoogleMapsEngineAPI(ref log4net.ILog log) { // establish the Google APIs project key this.GOOGLE_API_KEY = Properties.Settings.Default.gme_api_key; // establish the Google Maps Engine API settings this.GME_API_PROTOCOL = Properties.Settings.Default.gme_api_protocol; this.GME_API_DOMAIN = Properties.Settings.Default.gme_api_domain; this.GME_API_SERVICE = Properties.Settings.Default.gme_api_service; this.GME_API_VERSION = Properties.Settings.Default.gme_api_version; // set the log this.log = log; // retrieve a reference to the extension log.Debug("Retrieiving a reference to the extension object."); ext = GoogleMapsEngineToolsExtensionForArcGIS.GetExtension(); // create a Google Maps Engine Session Id for this set of sessions GoogleMapsEngineAPISessionId = Guid.NewGuid(); // if debug, create a debug folder to keep track of information if (log.IsDebugEnabled) { // create a temporary folder debugDirectory = System.IO.Directory.CreateDirectory( ext.getLocalWorkspaceDirectory() + "\\GME_API_TMP_" + GoogleMapsEngineAPISessionId.ToString().Replace("-","")); } }
protected override void OnException(ExceptionContext filterContext) { //Log error logger = log4net.LogManager.GetLogger(filterContext.Controller.ToString()); logger.Error(filterContext.Exception.Message, filterContext.Exception); }
public Log4NetProxy(log4net.ILog logger) { if (logger == null) throw new ArgumentNullException("logger"); _logger = logger; }
public AudioManager(bool hardware = true) { _log = Logging.LogManager.GetLogger(this); _log.Info("Initializing AudioManager..."); _log.Info("Creating FMOD system..."); uint version = 0; RESULT result = Factory.System_Create(ref _system); ErrCheck(result); _log.Debug("Checking FMOD version..."); result = _system.getVersion(ref version); ErrCheck(result); if (version < VERSION.number) { var msg = string.Format("Error! You are using an old version of FMOD: {0}. This program requires: {1}.", version.ToString("X"), VERSION.number.ToString("X")); _log.Fatal(msg); throw new FMODException(msg); } result = _system.init(MaxChannels, INITFLAGS.NORMAL, (IntPtr) null); ErrCheck(result); _soundManager = new SoundManager(_system, hardware); _songManager = new SongManager(_system, hardware); _log.Info("AudioManager initialized!"); }
static void Main(string[] args) { if (string.IsNullOrEmpty(Thread.CurrentThread.Name)) Thread.CurrentThread.Name = "Main"; #if WINDOWS && DEBUG if (!System.Diagnostics.Debugger.IsAttached) { AllocConsole(); var stdHandle = GetStdHandle(STD_OUTPUT_HANDLE); var safeFileHandle = new SafeFileHandle(stdHandle, true); var fileStream = new FileStream(safeFileHandle, FileAccess.Write); var encoding = Encoding.GetEncoding(CODE_PAGE); var stdOut = new StreamWriter(fileStream, encoding) { AutoFlush = true }; Console.SetOut(stdOut); } #endif _log = LogManager.GetLogger(typeof(Program)); _log.Info("### !!! APPLICATION LOAD !!! ###"); _log.Info("Deleting old log files (>7 days)..."); // Delete log files older than 7 days if (Directory.Exists("logs")) { var now = DateTime.Now; var max = new TimeSpan(7, 0, 0, 0); // 7 days foreach (var file in from file in Directory.GetFiles("logs") let modTime = File.GetLastAccessTime(file) let age = now.Subtract(modTime) where age > max select file) { try { File.Delete(file); _log.Info("Deleted old log file: " + file); } catch (IOException ex) { _log.Warn("Failed to delete log file: " + file + "(" + ex.Message + ")"); } } } _log.Info("Old log files deleted!"); _log.Info("Starting game..."); using (var game = new MainGame()) game.Run(); #if WINDOWS && DEBUG _log.Debug("Unloading console..."); FreeConsole(); _log.Debug("Console unloaded!"); #endif _log.Info("### !!! APPLICATION EXIT !!! ###"); }
public TextManager(Map map) { _log = Logging.LogManager.GetLogger(this); _log.Info("TextManager is loading map text entries..."); _texts = new List<Text>(); _activeText = null; if (!map.HasLayer("text")) { _log.Info("No text layer detected on map, aborting..."); return; } foreach (var obj in map.FindObjects((l, o) => l.Name == "text")) { string title = obj.Properties.ContainsKey("title") ? obj.Properties["title"] : "<No Title>"; string subtitle = obj.Properties.ContainsKey("subtitle") ? obj.Properties["subtitle"] : null; _log.DebugFormat("Adding new text {0} of type {1}", obj.Name, obj.Type); _texts.Add(new Text(obj.Bounds, obj.Name, obj.Type, title, subtitle)); } _log.Debug("TextManager initialized!"); }
/// <summary> /// Initializes a new instance of the <see cref="Log4NetLog"/> class. /// </summary> /// <param name="log">The log.</param> public Log4NetLog(log4net.ILog log) { if (log == null) throw new ArgumentNullException("log"); m_Log = log; }
public CLI(IDirectoryLocator directoryLocator, PluginLoader pluginLoader, IController controller) { _logger = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType); _directoryLocator = directoryLocator; _pluginLoader = pluginLoader; _controller = controller; }
public LoggingSchemaProviderAdapter(ISchemaProvider provider) { if (provider == null) throw new ArgumentNullException("provider"); _provider = provider; Log = log4net.LogManager.GetLogger("Zetbox.Server.Schema." + provider.ConfigName); }
public void WriteLog(LogEnum name, LogLevel level, string logContent) { log = log4net.LogManager.GetLogger(name.ToString()); //log = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType); switch (level) { case LogLevel.DEBUG: log.Debug(logContent); break; case LogLevel.ERROR: log.Error(logContent); break; case LogLevel.FATAL: log.Fatal(logContent); break; case LogLevel.INFO: log.Info(logContent); break; case LogLevel.WARN: log.Warn(logContent); break; default: log.Debug(logContent); break; } }
protected override void OnStart(string[] args) { string baseDir = AppDomain.CurrentDomain.BaseDirectory; log4net.Config.XmlConfigurator.ConfigureAndWatch(new System.IO.FileInfo(baseDir + "log4net.xml")); log = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType); try { // Pick one //RemotingConfiguration.CustomErrorsEnabled(false); RemotingConfiguration.CustomErrorsMode = CustomErrorsModes.Off; //RemotingConfiguration.Configure(baseDir + "RrdbFileService.exe.config"); log.Info("RrdDb file server started"); var nameValueCollection = (NameValueCollection)ConfigurationManager.GetSection("rrdbfileserver"); log.InfoFormat("Database file base path:{0}", nameValueCollection["databasepath"]); string port = nameValueCollection["port"]; int portNumber = int.Parse(port); channel = new TcpChannel(portNumber); ChannelServices.RegisterChannel(channel, false); log.InfoFormat("Server object registerd on port {0}", portNumber); RemotingConfiguration.RegisterWellKnownServiceType( typeof(RrdDbAdapter), "GetRrdDbAdapter", WellKnownObjectMode.Singleton); log.Info("Service up and running"); } catch (Exception ex) { log.Error(ex); throw; } }
static void Main(string[] args) { log4net.Config.XmlConfigurator.Configure(); Log = log4net.LogManager.GetLogger(typeof(Program)); Root = ConfigurationManager.AppSettings["serviceRoot"]; Apploader = ConfigurationManager.AppSettings["apploader"]; Apps = new Dictionary<string, Process>(); Log.Info("==== AppServer && Apploader ===="); Log.InfoFormat("从目录{0}下开始启动各应用", Root); //TODO:支持指定pid,可通过读取对应目录下的xxxconfig来完成 Directory.GetDirectories(Root) .Where(o => Filter(o)).ToList().ForEach(o => Start(o)); //激活AppAgent Log.Info("启用AppAgent"); new DefaultAgent(new Log4NetLogger(Log) , ConfigurationManager.AppSettings["appAgent_master"] , ConfigurationManager.AppSettings["appAgent_name"] , ConfigurationManager.AppSettings["appAgent_description"] , new CommandHandle()) .Run(); Log.Info("==== 启动完成 ====\n\n"); RenderOutput(); System.Console.ReadKey(); }
public OrderReplaceProcessor(DriverBase myHandler, BlockingCollection<RequestData> replaceRequestsCollection) { replaceRequests = replaceRequestsCollection; _Handler = myHandler; _replaceRequest = new Dictionary<string, RequestData>(); m_DriverLog = log4net.LogManager.GetLogger("KaiDriverLog"); }
protected DriverManager() { _loadedDrivers = new Dictionary<string, IDriver>(); _driverDefinition = new Dictionary<string, KaiTrade.Interfaces.IDriverDef>(); AppDomain.CurrentDomain.AssemblyResolve += new ResolveEventHandler(MyResolveEventHandler); _wireLog = log4net.LogManager.GetLogger("KaiTradeWireLog"); _wireLog.Info("DriverManager Created"); }
/// <summary> /// 初始化 /// </summary> /// <param name="log"></param> /// <param name="properties"> /// 可用于传递系统或环境变量等,可以作为property输出在日志内容中,layout格式如:%property{name} /// Tip:利用ToString()重载可以实现Active Property,但需要注意此特性对性能的消耗,建议合理配合使用IsDebugEnabled等属性 /// http://logging.apache.org/log4net/release/manual/contexts.html /// 不需要则留空 /// </param> /// <param name="propertiesWhenError">在Error以及Fatal级别时使用的变量集合,不需要则留空</param> public Log4NetLogger(log4net.ILog log , Func<IDictionary<string, object>> properties , Func<IDictionary<string, object>> propertiesWhenError) { this._log = log; this._properties = properties; this._propertiesWhenError = propertiesWhenError; }
public static void Initialize() { if (instance != null) throw new InvalidOperationException("Already initialised the License Manager"); Logger = log4net.LogManager.GetLogger("License Manager"); instance = new LicenseManager(); }
internal FrameRateDisplay(Game game) : base(game) { _log = LogManager.GetLogger(this); _log.Debug("FrameRateDisplay created!"); _content = new ContentManager(game.Services, Constants.ContentDirectory); game.Exiting += (s, e) => UnloadContent(); }
/// <summary> /// Initialize a new <c>SteamFriendList</c>. /// </summary> internal SteamFriendList() { _log = LogManager.GetLogger(this); _list = new List<SteamFriend>(); _updateTimer = new Timer(Update, null, 0, 60000); SteamManager.OnSteamClose += SteamClose; _log.Info("SteamFriendList loaded!"); }
public Subtitles(log4net.ILog log = null) { Log = log; items = new List<SubtitleItem>(); rwLock = new ReaderWriterLockSlim(); SubtitleLocations = new List<string>(); track = -1; }
//ServiceHost _queryHost = null; public PubSubSvc() { InitializeComponent(); container = new WindsorContainer(); //container.Install(Configuration.FromAppConfig()); container.Install(FromAssembly.This()); log = log4net.LogManager.GetLogger("Log.PubSubSvc"); }
public Recorder() { //預設路徑是跟dll放在一起 //預設名稱是log4net.config.xml string configPathDirectory = System.Environment.CurrentDirectory; string configFilePath = Path.Combine(configPathDirectory, "log4net.config.xml"); log=log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType); SetConfigFile(configFilePath); }
public KanjiEtl(RadicalDictionary radicalDictionary) : base() { _radicalDictionary = radicalDictionary; _log = log4net.LogManager.GetLogger(this.GetType()); CreateJlptDictionary(); CreateFrequencyRankDictionary(); CreateWkDictionary(); }
public ProcessViewModel(ScreenCoordinator screenCoordinator) { ScreenCoordinator = screenCoordinator; Logger = log4net.LogManager.GetLogger(GetType()); ProcessAction = () => { }; CompleteAction = () => { }; ErrorAction = ex => { ScreenCoordinator.HandleFault(ex); }; }
internal UserInfoDisplay(Game game) : base(game) { _log = LogManager.GetLogger(this); _log.Debug("UserInfoDisplay created!"); _sc = (Sharpcraft) game; _content = new ContentManager(game.Services, Constants.ContentDirectory); game.Exiting += (s, e) => UnloadContent(); }
public StatusController(Dispatcher uiDispatcher, int period, log4net.ILog visitLogger, log4net.ILog statusLogger) { this.visitLogger = visitLogger; this.statusLogger = statusLogger; _dispatcher = uiDispatcher; lastControllerId = -1; Trigger = new Timer(new TimerCallback(TimerCallback), null, 0, period); lastPositions = new Dictionary<int, Point3D>(); }
/// <summary> /// 传入配置文件中logger名称 /// 用来调用不同的设置 /// 如:异常日志、审计日志 /// </summary> /// <param name="logger"></param> public Log4netLogger(string name) { log = log4net.LogManager.GetLogger(name); }
/// <summary> /// /// </summary> /// <returns></returns> public string ToTechnologyGroup() { log4net.ILog logger = log4net.LogManager.GetLogger(typeof(string)); //Declaring Log4Net string telegramPublishPath = System.Configuration.ConfigurationManager.AppSettings["TelegramPublishPath"].ToString(); string telegramTechnologyGroupID = System.Configuration.ConfigurationManager.AppSettings["TelegramTechnologyGroupID"].ToString(); string telegramTechnologyGroupName = System.Configuration.ConfigurationManager.AppSettings["TelegramTechnologyGroupName"].ToString(); //string telegramLoggerPath = System.Configuration.ConfigurationManager.AppSettings["telegramLoggerPath"].ToString(); try { // Send Post Queue To Telegram Technology Channel var telegramQueuePath = telegramPublishPath + "TechnologyPostQueue.json"; var telegramJsonData = System.IO.File.ReadAllText(telegramQueuePath); // Check Telegram Queue is not Empty if (telegramJsonData == null || telegramJsonData == "[]") { logger.Error("List is Empty."); return("OK"); } var telegramPostList = Newtonsoft.Json.JsonConvert.DeserializeObject <System.Collections.Generic.List <PostModel> >(telegramJsonData) ?? new System.Collections.Generic.List <PostModel>(); // First Selection Method : Max Article Length PostModel post = telegramPostList.OrderByDescending(x => x.ArticleLength).FirstOrDefault(); // Two Selection Method : High Post Priority if (post == null) { } // Three Selection Method : Max Caption White Word Count if (post == null) { } // Four Selection Method : Max Article Image Count if (post == null) { } // Anyway : First Post in Queue if (post == null) { post = telegramPostList.FirstOrDefault(); } TelegramAPI telegram = new TelegramAPI(); // Send Photo Post if (post.Content == PostContentType.Photo) { var caption = post.Caption + "\n\n" + post.ShortArticle + "\n\n🔗 " + post.ShortLink.Replace("http://", "") + "\n\n" + telegramTechnologyGroupName; telegram.SendPhoto(telegramTechnologyGroupID, post.Photo, caption); } // Delete Post telegramPostList.Remove(post); telegramJsonData = Newtonsoft.Json.JsonConvert.SerializeObject(telegramPostList); System.IO.File.WriteAllText(telegramQueuePath, telegramJsonData); return("OK"); } catch (System.Exception ex) { logger.Error(ex.ToString()); return("BAD"); } }
public static ILogger GetLogger() { log4net.ILog logger = log4net.LogManager.GetLogger("LOGGER"); return(new Logger(logger)); }
private Log4NetLogger(log4net.ILog logger) { this.log4netLogger = logger; }
public Log4NetLogger(Type typeToLog) { this.log = log4net.LogManager.GetLogger(typeToLog); }
public Logger(string nameOfLogger) { logger = log4net.LogManager.GetLogger(nameOfLogger); AddCallingMethod = CallingMethodDetail.None; }
/// <summary> /// 输出日志到Log4Net /// </summary> /// <param name="Name">你的方法名</param> /// <param name="msg">你的错误信息</param> public void WriteLog(string Name, string msg) { log4net.ILog log = log4net.LogManager.GetLogger(Name); log.Error(msg); }
/// <summary> /// 输出日志到Log4Net /// </summary> /// <param name="Name">你的方法名</param> /// <param name="msg">你的错误信息</param> public void WriteLog(string Name, Exception ex) { log4net.ILog log = log4net.LogManager.GetLogger(Name); log.Error("Error", ex); }
public static void ErrorLog(object msg) { log4net.ILog log = log4net.LogManager.GetLogger("logerror"); Task.Run(() => log.Error(msg)); //异步 }
public ExtendedLog4netLogger(log4net.ILog log, Castle.Services.Logging.Log4netIntegration.ExtendedLog4netFactory factory) { }
public static void Main(string[] args) { if (!log4net.LogManager.GetRepository().Configured) { log4net.Config.BasicConfigurator.Configure(); } log4net.ILog logger = log4net.LogManager.GetLogger("GroupSum.Program"); logger.Info("Starting up Group Sum"); var settings = new GroupSumSettings() { IsDebugMode = false, ScreenWidth = DisplayDevice.Default.Width, ScreenHeight = DisplayDevice.Default.Height, Fullscreen = false, Players = 0, Port = 0, FirstRoundSeconds = 0, RoundSeconds = 10, ShowNumericFeedback = false, UsePreviousRoundInput = false }; logger.Debug("Parsing command-line options"); // Parse command-line options bool showHelp = false; int rangeStart = 0, rangeEnd = 9; var options = new OptionSet() { { "h|?|help", "Show this help message", v => showHelp = !string.IsNullOrEmpty(v) }, { "debug", "Enable debug mode (random commands can be issued with 'R')", v => settings.IsDebugMode = !string.IsNullOrEmpty(v) }, { "screen-width=", "Screen width in pixels (default: current)", v => settings.ScreenWidth = Convert.ToInt32(v) }, { "screen-height=", "Screen heigh in pixels (default: current)", v => settings.ScreenHeight = Convert.ToInt32(v) }, { "full-screen", "Enables full-screen mode", v => settings.Fullscreen = !string.IsNullOrEmpty(v) }, { "players=", "Number of players (required)", v => settings.Players = Convert.ToInt32(v) }, { "port=", "Network port of input server", v => settings.Port = Convert.ToInt32(v) }, { "data-file=", "Path to the output data file", v => settings.DataFilePath = v }, { "description=", "Text to display at the top of the screen during gameplay", v => settings.GameDescription = v }, { "target-number=", "The number the group is attempting to guess (default: random)", v => settings.TargetNumber = Convert.ToInt32(v) }, { "first-round-seconds=", "Length of the first round in seconds (default: round-seconds)", v => settings.FirstRoundSeconds = Convert.ToInt32(v) }, { "round-seconds=", "Length of each round in seconds (default: 10)", v => settings.RoundSeconds = Convert.ToInt32(v) }, { "range-start=", "Start of number range, multiplied by player count (default: 0)", v => rangeStart = Convert.ToInt32(v) }, { "range-end=", "End of number range, multiplied by player count (default: 9)", v => rangeEnd = Convert.ToInt32(v) }, { "numeric-feedback", "If set, players are show how far they were from the answer (default: false)", v => settings.ShowNumericFeedback = !string.IsNullOrEmpty(v) }, { "previous-input", "If not set, player answers are reset each round (default: false)", v => settings.UsePreviousRoundInput = !string.IsNullOrEmpty(v) } }; options.Parse(args); if (showHelp) { options.WriteOptionDescriptions(Console.Out); return; } if (settings.Players < 1) { logger.Fatal("players option is required"); return; } // Flip range if necessary if (rangeStart > rangeEnd) { int rangeTemp = rangeStart; rangeStart = rangeEnd; rangeEnd = rangeTemp; } settings.MinNumber = settings.Players * rangeStart; settings.MaxNumber = settings.Players * rangeEnd; if (settings.TargetNumber < 1) { settings.TargetNumber = new Random().Next(settings.MinNumber - 1, settings.MaxNumber) + 1; } if (settings.FirstRoundSeconds <= 0) { settings.FirstRoundSeconds = settings.RoundSeconds; } if (settings.IsDebugMode) { logger.Info("Debug mode is enabled"); } using (var game = new GroupSumWindow(settings)) { // Start game logger.Debug("Running game loop"); game.Run(0, 0); } }
public ToolsController() { logger = log4net.LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); }
static Log() { log4net.Config.XmlConfigurator.Configure(); error = log4net.LogManager.GetLogger("logerror"); info = log4net.LogManager.GetLogger("loginfo"); }
/// <summary> /// Initializes a new instance of the Database class. /// </summary> private Database() { this.Log = Logger.Get(this); this.arcFiles = new Dictionary <string, ArcFile>(); }
public ILogger GetLogger(string name) { log4net.ILog logger = log4net.LogManager.GetLogger(name); return(new Logger(logger)); }
public static void Info(string msg) { log4net.ILog log = log4net.LogManager.GetLogger("SmartBox.Console.Common.Log4NetHelper"); log.Info(msg); }
public StudentController(IStudent _adb) { adb = _adb; _log4net = log4net.LogManager.GetLogger(typeof(StudentController)); }
public static void SaveFileFromURL(string url, string destinationFileName, int timeoutInSeconds, BackgroundWorker bw, DoWorkEventArgs e, log4net.ILog log) { // Create a web request to the URL HttpWebRequest MyRequest = (HttpWebRequest)WebRequest.Create(url); MyRequest.Timeout = timeoutInSeconds * 1000; try { // Get the web response HttpWebResponse MyResponse = (HttpWebResponse)MyRequest.GetResponse(); // Make sure the response is valid if (HttpStatusCode.OK == MyResponse.StatusCode) { // Open the response stream using (Stream MyResponseStream = MyResponse.GetResponseStream()) { // Set step for backgroundWorker Form1.activeStep = "Load file.."; bw.ReportProgress(0); // start new step of background process // Open the destination file using ( FileStream MyFileStream = new FileStream(destinationFileName, FileMode.OpenOrCreate, FileAccess.Write)) { // Get size of stream - it is impossible in advance at all // so we just can set approximate value if know it or get it before by experience long countBuffer = 1000000; long currentBuffer = 0; // Create a 4K buffer to chunk the file byte[] MyBuffer = new byte[4096]; int BytesRead; // Read the chunk of the web response into the buffer while (0 < (BytesRead = MyResponseStream.Read(MyBuffer, 0, MyBuffer.Length))) { // Write the chunk from the buffer to the file MyFileStream.Write(MyBuffer, 0, BytesRead); // show progress & catch Cancel currentBuffer++; if (bw.CancellationPending) { // cancel background work e.Cancel = true; // Due to too huge size of download it is neccessary explicit closing Stream else operation in background will be cancelled after total download file MyRequest.Abort(); break; } else if (bw.WorkerReportsProgress && currentBuffer % 100 == 0) { bw.ReportProgress((int)(100 * currentBuffer / countBuffer)); } } // visualization finish process if (!e.Cancel && currentBuffer < countBuffer) { bw.ReportProgress(100); Thread.Sleep(100); } } } } } catch (Exception err) { e.Result = "ERROR:" + err.Message; log.Error("Error error logging", err); } }
public ILogger GetLogger(Type type) { log4net.ILog logger = log4net.LogManager.GetLogger(type); return(new Logger(logger)); }
public OrdersController(IOrdersRep _db) { db = _db; _log4net = log4net.LogManager.GetLogger(typeof(OrdersController)); }
public AuditChecklistController() { _log4net = log4net.LogManager.GetLogger(typeof(AuditChecklistController)); }
public Logger(string title) { _logger = log4net.LogManager.GetLogger(title); }
public AccountController(IAccountRepository _accountRepository) { _log4net = log4net.LogManager.GetLogger(typeof(AccountController)); accountRepository = _accountRepository; }
public void ExecuteCommand(GameSession session, ProtobufRequestInfo requestInfo) { log4net.ILog log = log4net.LogManager.GetLogger("ColoredConsoleAppender"); // ILog log = log4net.LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); var info = CouponsBusiness.ParseFrom(requestInfo.Body); DAL.DAL.Business business = new DAL.DAL.Business(); //获取用户积分消费卷信息 IntegralInfo integralInfo = business.GetIntegralInfo(info.UserID); if (integralInfo == null) { log.Error("用户不存在"); business.InsertIntegralInfo(info.UserID); var data = Result.CreateBuilder().SetStatus(0).SetMessage("用户不存在").Build().ToByteArray(); session.Send(new ArraySegment <byte>(CreateHead.CreateMessage(10001, data.Length, requestInfo.MessageNum, data))); session.Close(); return; } //获取业务信息 BusinessModel businessInfo = business.SelectBusiness(info.BusinessID); if (businessInfo == null) { log.Error("该业务不存在"); var data = Result.CreateBuilder().SetStatus(0).SetMessage("该业务不存在").Build().ToByteArray(); session.Send(new ArraySegment <byte>(CreateHead.CreateMessage(10001, data.Length, requestInfo.MessageNum, data))); session.Close(); return; } //获取操作方式 ActionModel actionInfo = business.SelectAction(businessInfo.action_id); // 处理业务 更新积分信息并返回 integralInfo = business.UpdateIntegralInfo(info.UserID, businessInfo.type, actionInfo, info.Counts); log.Info("更新成功"); var dataResult = Result.CreateBuilder().SetStatus(1).SetMessage("更新成功").Build().ToByteArray(); session.Send(new ArraySegment <byte>(CreateHead.CreateMessage(10001, dataResult.Length, requestInfo.MessageNum, dataResult))); session.Send("更新成功"); //写入日志 var logModel = new LogModel { userID = info.UserID, action = actionInfo.title, business = businessInfo.tittle, type = businessInfo.type, count = info.Counts, dateTime = DateTime.Now, }; business.WriteLog(logModel); }
public virtual void Setup() { log4net.Config.XmlConfigurator.ConfigureAndWatch(new System.IO.FileInfo(System.AppDomain.CurrentDomain.SetupInformation.ConfigurationFile)); logger = log4net.LogManager.GetLogger(this.GetType()); System.IO.Directory.SetCurrentDirectory(OriginalWorkingDirectory); }
public CouponPushTask() { _apiDomain = AppContext.Settings.YunService; _logger = log4net.LogManager.GetLogger(ScheduleJobIdentity); }
public ImpuestosController() { logger = log4net.LogManager.GetLogger("Impuestos"); consulta = new QueriesImpuestos(); }
public static void InitVariablesPosMainWindow() { //Log4Net log4net.ILog log = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType); // Put in Config and Load From Config // ConfigValues to ExpressionVars try { // Config /* IN008024 */ /* For CustomAppOperationMode.RETAIL */ //IN009345 - Front-End - Falta de funcionalidades em modo Retalho (Botões) int intEventBoxPosTicketPadColumns = 4; int intEventBoxPosTicketPadRows = 4; if (SettingsApp.IsDefaultTheme) { //intEventBoxPosTicketPadColumns = 4; intEventBoxPosTicketPadRows = 5; } // Detect Dynamic Size bool appThemeCalcDynamicSize = Convert.ToBoolean(GlobalFramework.Settings["appThemeCalcDynamicSize"]); Size sizePosBaseButtonSize = new Size(0, 0); Size sizePosToolbarButtonSize = new Size(0, 0); Size sizePosTicketPadButtonSize = new Size(0, 0); Size sizePosTicketPadButtonDoubleWidth = new Size(0, 0); Size sizePosToolbarButtonIconSize = new Size(0, 0); Size sizePosTicketPadButtonIconSize = new Size(0, 0); string sizePosBaseButtonString = GlobalFramework.Settings["sizePosBaseButton"].Replace(" ", string.Empty); string fontTicketListColumnTitle = string.Empty; string fontTicketListColumn = string.Empty; string enumScreenSize = string.Format("res{0}x{1}", GlobalApp.ScreenSize.Width, GlobalApp.ScreenSize.Height); try { ScreenSize screenSizeEnum = (ScreenSize)Enum.Parse(typeof(ScreenSize), enumScreenSize, true); if (appThemeCalcDynamicSize) { switch (screenSizeEnum) { case ScreenSize.res800x600: sizePosBaseButtonSize = new Size(100, 75); sizePosToolbarButtonSize = new Size(54, 38); sizePosTicketPadButtonSize = new Size(sizePosToolbarButtonSize.Width, sizePosToolbarButtonSize.Height); sizePosTicketPadButtonDoubleWidth = new Size(sizePosToolbarButtonSize.Width * 2, sizePosToolbarButtonSize.Height); sizePosToolbarButtonIconSize = new Size(22, 22); sizePosTicketPadButtonIconSize = new Size(sizePosToolbarButtonIconSize.Width, sizePosToolbarButtonIconSize.Height); fontTicketListColumnTitle = "Bold 8"; fontTicketListColumn = "8"; fontDocumentsSizeDefault = "6"; break; case ScreenSize.res1024x600: case ScreenSize.res1024x768: sizePosBaseButtonSize = new Size(120, 90); sizePosToolbarButtonSize = new Size(80, 60); sizePosTicketPadButtonSize = new Size(sizePosToolbarButtonSize.Width, sizePosToolbarButtonSize.Height); sizePosTicketPadButtonDoubleWidth = new Size(sizePosToolbarButtonSize.Width * 2, sizePosToolbarButtonSize.Height); sizePosToolbarButtonIconSize = new Size(34, 34); sizePosTicketPadButtonIconSize = new Size(sizePosToolbarButtonIconSize.Width, sizePosToolbarButtonIconSize.Height); fontTicketListColumnTitle = "Bold 9"; fontTicketListColumn = "9"; fontDocumentsSizeDefault = "6"; break; case ScreenSize.res1152x864: case ScreenSize.res1280x720: case ScreenSize.res1280x768: case ScreenSize.res1280x800: case ScreenSize.res1280x1024: case ScreenSize.res1360x768: case ScreenSize.res1366x768: case ScreenSize.res1440x900: case ScreenSize.res1536x864: case ScreenSize.res1600x900: fontTicketListColumnTitle = "Bold 10"; fontTicketListColumn = "10"; sizePosBaseButtonSize = new Size(140, 105); sizePosToolbarButtonSize = new Size(100, 75); sizePosTicketPadButtonSize = new Size(sizePosToolbarButtonSize.Width, sizePosToolbarButtonSize.Height); sizePosTicketPadButtonDoubleWidth = new Size(sizePosToolbarButtonSize.Width * 2, sizePosToolbarButtonSize.Height); sizePosToolbarButtonIconSize = new Size(42, 42); sizePosTicketPadButtonIconSize = new Size(sizePosToolbarButtonIconSize.Width, sizePosToolbarButtonIconSize.Height); fontDocumentsSizeDefault = "8"; break; case ScreenSize.res1680x1050: case ScreenSize.res1920x1080: case ScreenSize.res1920x1200: case ScreenSize.res2160x1440: case ScreenSize.res2560x1080: case ScreenSize.res2560x1440: case ScreenSize.res3440x1440: case ScreenSize.res3840x2160: sizePosBaseButtonSize = new Size(160, 120); sizePosToolbarButtonSize = new Size(120, 90); sizePosTicketPadButtonSize = new Size(sizePosToolbarButtonSize.Width, sizePosToolbarButtonSize.Height); sizePosTicketPadButtonDoubleWidth = new Size(sizePosToolbarButtonSize.Width * 2, sizePosToolbarButtonSize.Height); sizePosToolbarButtonIconSize = new Size(50, 50); sizePosTicketPadButtonIconSize = new Size(sizePosToolbarButtonIconSize.Width, sizePosToolbarButtonIconSize.Height); fontTicketListColumnTitle = "Bold 10"; fontTicketListColumn = "10"; fontDocumentsSizeDefault = "10"; break; /* IN008023: apply "1024x768" settings as default */ default: sizePosBaseButtonSize = new Size(120, 90); sizePosToolbarButtonSize = new Size(80, 60); sizePosTicketPadButtonSize = new Size(sizePosToolbarButtonSize.Width, sizePosToolbarButtonSize.Height); sizePosTicketPadButtonDoubleWidth = new Size(sizePosToolbarButtonSize.Width * 2, sizePosToolbarButtonSize.Height); sizePosToolbarButtonIconSize = new Size(34, 34); sizePosTicketPadButtonIconSize = new Size(sizePosToolbarButtonIconSize.Width, sizePosToolbarButtonIconSize.Height); fontTicketListColumnTitle = "Bold 9"; fontTicketListColumn = "9"; fontDocumentsSizeDefault = "6"; break; } } else { // Use Defaults from Config sizePosBaseButtonSize = Utils.StringToSize(GlobalFramework.Settings["sizePosBaseButton"]); sizePosToolbarButtonSize = Utils.StringToSize(GlobalFramework.Settings["sizePosToolbarButton"]); sizePosTicketPadButtonSize = Utils.StringToSize(GlobalFramework.Settings["sizePosTicketPadButton"]); sizePosTicketPadButtonDoubleWidth = Utils.StringToSize(GlobalFramework.Settings["sizePosTicketPadButtonDoubleWidth"]); sizePosToolbarButtonIconSize = Utils.StringToSize(GlobalFramework.Settings["sizePosToolbarButtonIcon"]); sizePosTicketPadButtonIconSize = Utils.StringToSize(GlobalFramework.Settings["sizePosTicketPadButtonIcon"]); } } catch (Exception ex) { log.Error(ex.Message, ex); Utils.ShowMessageTouchUnsupportedResolutionDetectedAndExit(GlobalApp.WindowStartup, GlobalApp.ScreenSize.Width, GlobalApp.ScreenSize.Height); } int posMainWindowComponentsMargin = Convert.ToInt16(GlobalFramework.Settings["intPosMainWindowComponentsMargin"]); int posMainWindowEventBoxPosTicketListColumnWidth = sizePosTicketPadButtonSize.Width * 4; int posMainWindowEventBoxStatusBar1And2Height = Convert.ToInt16(GlobalFramework.Settings["intPosMainWindowEventBoxStatusBar1And2Height"]); // Remove Margin, Column Price, Qnt, Total int posMainWindowEventBoxPosTicketListColumnsDesignationWidth = posMainWindowEventBoxPosTicketListColumnWidth - 10 - 65 - 55 - 75; //IN009257 Redimensionar botões para a resolução 1024 x 768. sizePosBaseButtonSizeDefault = sizePosBaseButtonSize; sizePosToolbarButtonSizeDefault = new Size((int)(sizePosToolbarButtonSize.Width / 1.4), (int)(sizePosToolbarButtonSize.Height / 1.4)); sizePosTicketPadButtonSizeDefault = sizePosTicketPadButtonSize; sizePosTicketPadButtonDoubleWidthDefault = sizePosTicketPadButtonDoubleWidth; sizePosToolbarButtonIconSizeDefault = new Size((int)(sizePosToolbarButtonIconSize.Width / 1.7), (int)(sizePosToolbarButtonIconSize.Height / 1.7)); sizePosTicketPadButtonIconSizeDefault = sizePosTicketPadButtonIconSize; //IN009257 END GlobalApp.ExpressionEvaluator.Variables.Add("posMainWindowTicketPadColumns", intEventBoxPosTicketPadColumns); GlobalApp.ExpressionEvaluator.Variables.Add("posMainWindowTicketPadRows", intEventBoxPosTicketPadRows); GlobalApp.ExpressionEvaluator.Variables.Add("posMainWindowTicketPadButtonSize", sizePosTicketPadButtonSize); GlobalApp.ExpressionEvaluator.Variables.Add("posMainWindowTicketPadButtonDoubleWidthSize", sizePosTicketPadButtonDoubleWidth); GlobalApp.ExpressionEvaluator.Variables.Add("posMainWindowToolbarButtonSize", sizePosToolbarButtonSize); GlobalApp.ExpressionEvaluator.Variables.Add("posMainWindowComponentsMargin", posMainWindowComponentsMargin); GlobalApp.ExpressionEvaluator.Variables.Add("posMainWindowEventBoxPosTicketListColumnWidth", posMainWindowEventBoxPosTicketListColumnWidth); GlobalApp.ExpressionEvaluator.Variables.Add("posMainWindowEventBoxStatusBar1And2Height", posMainWindowEventBoxStatusBar1And2Height); GlobalApp.ExpressionEvaluator.Variables.Add("posMainWindowEventboxToolbarIconSize", sizePosToolbarButtonIconSize); GlobalApp.ExpressionEvaluator.Variables.Add("posMainWindowEventBoxPosTicketPadButtonsIconSize", sizePosTicketPadButtonIconSize); GlobalApp.ExpressionEvaluator.Variables.Add("posMainWindowEventBoxPosTicketListColumnsDesignationWidth", posMainWindowEventBoxPosTicketListColumnsDesignationWidth); // Calculate TablePads TableConfig and Button Sizes, from starter sizePosBaseButton //Override this from Config int usefullAreaForMainTablePadsWidth = GlobalApp.ScreenSize.Width - posMainWindowComponentsMargin - (posMainWindowEventBoxPosTicketListColumnWidth + posMainWindowComponentsMargin * 2); int usefullAreaForMainTablePadsHeight = GlobalApp.ScreenSize.Height - (posMainWindowEventBoxStatusBar1And2Height * 2) - posMainWindowComponentsMargin - posMainWindowEventBoxStatusBar1And2Height - (sizePosToolbarButtonSize.Height + posMainWindowComponentsMargin * 2); // Get Columns and Rows based on sizePosBaseButton, leaving remains space to split after int guessedTablePadColumns = Convert.ToInt16(usefullAreaForMainTablePadsWidth / sizePosBaseButtonSize.Width); int guessedTablePadRows = Convert.ToInt16(usefullAreaForMainTablePadsHeight / sizePosBaseButtonSize.Height); // Get Remain Space int remainSpaceInColumns = usefullAreaForMainTablePadsWidth - (sizePosBaseButtonSize.Width * guessedTablePadColumns); int remainSpaceInRows = usefullAreaForMainTablePadsHeight - (sizePosBaseButtonSize.Height * guessedTablePadRows); // Distribute Remain Space for Calculated Buttons int remainSpaceForEveryButtonWidth = Convert.ToInt16(remainSpaceInColumns / guessedTablePadColumns); int remainSpaceForEveryButtonHeight = Convert.ToInt16(remainSpaceInRows / guessedTablePadRows); // Finished Add remainSpace to Button Size sizePosBaseButtonSize.Width += remainSpaceForEveryButtonWidth; sizePosBaseButtonSize.Height += remainSpaceForEveryButtonHeight; // Create Variables for TableConfig to Override Config Defaults TableConfig tableConfigTablePadFamily = new TableConfig(1, Convert.ToUInt16(guessedTablePadRows - 1)); TableConfig tableConfigTablePadSubFamily = new TableConfig(Convert.ToUInt16(guessedTablePadColumns - 1), 1); TableConfig tableConfigTablePadArticle = new TableConfig(Convert.ToUInt16(guessedTablePadColumns - 1), Convert.ToUInt16(guessedTablePadRows - 1)); // After has final sizePosBaseButton Position positionButtonFavorites = new Position(posMainWindowComponentsMargin, (posMainWindowEventBoxStatusBar1And2Height * 2) + posMainWindowComponentsMargin); Position positionTablePadFamily = new Position(posMainWindowComponentsMargin, (posMainWindowEventBoxStatusBar1And2Height * 2) + sizePosBaseButtonSize.Height + posMainWindowComponentsMargin); Position positionTablePadSubFamily = new Position(posMainWindowComponentsMargin + sizePosBaseButtonSize.Width, (posMainWindowEventBoxStatusBar1And2Height * 2) + posMainWindowComponentsMargin); Position positionTablePadArticle = new Position(posMainWindowComponentsMargin + sizePosBaseButtonSize.Width, (posMainWindowEventBoxStatusBar1And2Height * 2) + sizePosBaseButtonSize.Height + posMainWindowComponentsMargin); // ButtonNext/Prev Position tablePadFamilyButtonPrevPosition = new Position(posMainWindowComponentsMargin, posMainWindowEventBoxStatusBar1And2Height + posMainWindowComponentsMargin); Position tablePadFamilyButtonNextPosition = new Position(posMainWindowComponentsMargin, (posMainWindowEventBoxStatusBar1And2Height * 2) + (posMainWindowComponentsMargin / 2) + (sizePosBaseButtonSize.Height * guessedTablePadRows) + (posMainWindowComponentsMargin / 2)); Position tablePadSubFamilyButtonPrevPosition = new Position(posMainWindowComponentsMargin + (sizePosBaseButtonSize.Width * (guessedTablePadColumns - 1)), tablePadFamilyButtonPrevPosition.Y); Position tablePadSubFamilyButtonNextPosition = new Position(posMainWindowComponentsMargin + (sizePosBaseButtonSize.Width * (guessedTablePadColumns - 1)) + (sizePosBaseButtonSize.Width / 2), tablePadFamilyButtonPrevPosition.Y); Position tablePadArticleButtonPrevPosition = new Position(tablePadSubFamilyButtonPrevPosition.X, tablePadFamilyButtonNextPosition.Y); Position tablePadArticleButtonNextPosition = new Position(tablePadSubFamilyButtonNextPosition.X, tablePadFamilyButtonNextPosition.Y); Size sizePosSmallButtonScrollerSize = new Size(Convert.ToInt16(sizePosBaseButtonSize.Width / 2), posMainWindowEventBoxStatusBar1And2Height); GlobalApp.ExpressionEvaluator.Variables.Add("posMainWindowBaseButtonSize", sizePosBaseButtonSize); GlobalApp.ExpressionEvaluator.Variables.Add("posMainWindowTablePadFamilyTableConfig", tableConfigTablePadFamily); GlobalApp.ExpressionEvaluator.Variables.Add("posMainWindowTablePadSubFamilyTableConfig", tableConfigTablePadSubFamily); GlobalApp.ExpressionEvaluator.Variables.Add("posMainWindowTablePadArticleTableConfig", tableConfigTablePadArticle); GlobalApp.ExpressionEvaluator.Variables.Add("posMainWindowButtonFavoritesPosition", positionButtonFavorites); GlobalApp.ExpressionEvaluator.Variables.Add("posMainWindowTablePadFamilyPosition", positionTablePadFamily); GlobalApp.ExpressionEvaluator.Variables.Add("posMainWindowTablePadSubFamilyPosition", positionTablePadSubFamily); GlobalApp.ExpressionEvaluator.Variables.Add("posMainWindowTablePadArticlePosition", positionTablePadArticle); GlobalApp.ExpressionEvaluator.Variables.Add("posMainWindowTablePadFamilyButtonPrevPosition", tablePadFamilyButtonPrevPosition); GlobalApp.ExpressionEvaluator.Variables.Add("posMainWindowTablePadFamilyButtonNextPosition", tablePadFamilyButtonNextPosition); GlobalApp.ExpressionEvaluator.Variables.Add("posMainWindowTablePadSubFamilyButtonPrevPosition", tablePadSubFamilyButtonPrevPosition); GlobalApp.ExpressionEvaluator.Variables.Add("posMainWindowTablePadSubFamilyButtonNextPosition", tablePadSubFamilyButtonNextPosition); GlobalApp.ExpressionEvaluator.Variables.Add("posMainWindowTablePadArticleButtonPrevPosition", tablePadArticleButtonPrevPosition); GlobalApp.ExpressionEvaluator.Variables.Add("posMainWindowTablePadArticleButtonNextPosition", tablePadArticleButtonNextPosition); GlobalApp.ExpressionEvaluator.Variables.Add("posMainWindowSmallButtonScrollerSize", sizePosSmallButtonScrollerSize); GlobalApp.ExpressionEvaluator.Variables.Add("posMainWindowEventBoxPosTicketListTicketListColumnTitleFont", fontTicketListColumnTitle); GlobalApp.ExpressionEvaluator.Variables.Add("posMainWindowEventBoxPosTicketListTicketListColumnFont", fontTicketListColumn); // Test Expressions Here //string hardCodeExpression = "Size((tableConfigTablePadArticle.Columns - 2) * posMainWindowBaseButtonSize.Width, posMainWindowEventBoxStatusBar1And2Height)"; //string hardCodeResult = GlobalApp.ExpressionEvaluator.Evaluate(hardCodeExpression).ToString(); //log.Debug(string.Format("result: [{0}]", GlobalApp.ExpressionEvaluator.Evaluate(hardCodeExpression).ToString())); } catch (Exception ex) { log.Error(ex.Message, ex); } }
public static void WriteLog(Type t, string msg) { log4net.ILog log = log4net.LogManager.GetLogger(t); log.Error(msg); }
public static void WriteLog(Type t, Exception ex) { log4net.ILog log = log4net.LogManager.GetLogger(t); log.Error("Error", ex); }